コード例 #1
0
            try:
                return self.sample.chain.lumiweight
            except:
                self.lumi_weight = self.sample.chain._weight*(self.sample.xsec*LUMINOSITY_MAP[self.sample.chain.year])/self.total_hcount.GetSumOfWeights()
                return self.lumi_weight 
        elif self.sample.is_data:
            return 1.
        else:
            #the _weight is needed because otherwise the hcounter might be wrong for the denominator
            self.lumi_weight = self.sample.chain._weight*(self.sample.xsec*LUMINOSITY_MAP[self.sample.chain.year])/self.total_hcount
            return self.lumi_weight 

if __name__ == '__main__':
    from HNL.Samples.sampleManager import SampleManager
    from HNL.Tools.logger import getLogger, closeLogger
    log = getLogger('INFO')

    sm = SampleManager(2016, 'noskim', 'fulllist_2016')

    # s = sm.getSample('ZZTo4L')
    s = sm.getSample('HNL-tau-m800')
    # s = sm.getSample('DYJetsToLL-M-50')

    chain = s.initTree()
    lw = LumiWeight(s, sm)
    chain.GetEntry(5)
    chain.year = 2016
    print s.name
    print lw.getLumiWeight() 
    print 'chain._weight: ', chain._weight, 'expected -41444.199'
    print 'xsec ', s.xsec, lw.sample.xsec, 'expected 18610'
コード例 #2
0
ファイル: tightToLoose.py プロジェクト: lwezenbe/HNL
if args.flavor == 'tau' and args.tauRegion is None:
    raise RuntimeError(
        "Specify the tauRegion in which to measure the tau fake rate")
if args.flavor != 'tau' and args.tauRegion is not None:
    raise RuntimeError(
        "Option tauRegion can not be used for light lepton measurement")
if args.tauRegion == 'AN2017014' and args.flavor == 'tau':
    raise RuntimeError("AN-2017-014 does not consider any taus")
if args.tauRegion == 'ewkino' and args.flavor in ['e', 'mu']:
    raise RuntimeError("Light lepton fakes for ewkino not implemented")

#
# Open logger
#
from HNL.Tools.logger import getLogger, closeLogger
log = getLogger(args.logLevel)

#
# Imports
#
import numpy as np
from HNL.EventSelection.event import Event
from HNL.ObjectSelection.leptonSelector import isGoodLepton
from HNL.Tools.helpers import makeDirIfNeeded
from HNL.Weights.reweighter import Reweighter

#
# Load in the sample list
#
from HNL.Samples.sampleManager import SampleManager
if args.noskim:
コード例 #3
0
import os
import time
import subprocess

from HNL.Tools.logger import getLogger
log = getLogger()

def system(command):
    return subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT)

def checkQueueOnCream02():
    try:
        queue = int(system('qstat -u $USER | wc -l'))
        if queue > 2000:
            log.info('Too much jobs in queue (' + str(queue) + '), sleeping')
            time.sleep(500)
            checkQueueOnCream02()
    except:
        checkQueueOnCream02()

# Cream02 running
from datetime import datetime
def launchCream02(command, logfile, checkQueue=False, wallTimeInHours='12', queue='localgrid', cores=1, jobLabel=None):
    jobName = jobLabel + datetime.now().strftime("%d_%H%M%S.%f")[:12]
    if checkQueue: checkQueueOnCream02()
    log.info('Launching ' + command + ' on cream02')
    qsubOptions = ['-v dir="' + os.getcwd() + '",command="' + command + '"',
                   '-q ' +queue +'@cream02',
                   '-o ' + logfile,
                   '-e ' + logfile,
                   '-l walltime='+wallTimeInHours+':00:00 '