コード例 #1
0
from HNL.EventSelection.eventCategorization import EventCategory
for entry in event_range:
    chain.GetEntry(entry)
    progress(entry - event_range[0], len(event_range))
 
    cutter.cut(True, 'Total')

    if args.removeOverlap:
        if 'DYJets' in sample.name and chain._zgEventType>=3: continue
        if sample.name == 'ZG' and chain._hasInternalConversion: continue

    if args.genSkim:
        if not select3GenLeptons(chain, new_vars):      continue
    elif not args.oldAnalysisSkim:
        # if not select3Leptons(chain, new_vars, light_algo=args.lightLeptonSelection, tau_algo=args.tauSelection):       continue
        select3Leptons(chain, new_vars, light_algo=args.lightLeptonSelection, tau_algo=args.tauSelection, workingpoint = 'loose')
        if len(chain.leptons) < 3:       continue
    else:
        select3Leptons(chain, new_vars, light_algo='cutbased', workingpoint = 'tight', no_tau = True, cutter = cutter)
        if len(chain.leptons) < 3:       continue

    
    ec = EventCategory(new_vars)
    c = ec.returnCategory()
    new_vars.event_category = c

    print 'calcing'
    calculateGeneralVariables(chain, new_vars, is_reco_level=not args.genSkim)
    calculateThreeLepVariables(chain, new_vars, is_reco_level=not args.genSkim)
    new_vars.lumiweight = lw.getLumiWeight()
    output_tree.Fill()
コード例 #2
0
ファイル: calcTriggerEff.py プロジェクト: lwezenbe/HNL
#prepare object  and event selection
from HNL.ObjectSelection.objectSelection import getObjectSelection
chain.obj_sel = getObjectSelection('default') if not args.oldTriggers else getObjectSelection('AN2017014')

#
# Loop over all events
#
from HNL.Tools.helpers import progress
from HNL.EventSelection.eventSelectionTools import select3Leptons
for entry in event_range:
    
    chain.GetEntry(entry)
    progress(entry - event_range[0], len(event_range))

    if not select3Leptons(chain, chain): continue
    if args.useRef and not chain._passTrigger_ref:     continue

    weightfactor = 1.
    if not sample.is_data: weightfactor *= chain._weight

    if args.separateTriggers is None:    
        analysis_str = 'HNL_old' if args.oldTriggers else 'HNL'
        passed = passTriggers(chain, analysis_str) 
    
    true_cat = ec.returnCategory()

    for c in categories:
        for v in {k for k in var.keys()}: 
            for t in category_map[c]:
                
コード例 #3
0
    if not select3GenLeptons(chain, chain):   continue
    
    if args.genLevel:
        slm = SignalLeptonMatcher(chain)
        slm.saveNewOrder()

    true_cat = ec.returnCategory()

    if args.FOcut:
        tmp = [l for l in xrange(chain._nL) if isFOLepton(chain, l)]
        if len(tmp) < 3: continue   
   
    if not args.genLevel:
        if args.oldANcuts:
            passed = False
            if select3Leptons(chain, chain, no_tau=True, light_algo='cutbased', cutter = cutter):
                if args.massRegion == 'low' and lowMassCuts(chain, chain, cutter):
                    passed = True
                elif args.massRegion == 'high' and highMassCuts(chain, chain, cutter):
                    passed = True
        else:
            passed = False
            if select3Leptons(chain, chain, cutter = cutter) and passBaseCuts(chain, chain, cutter):
                if args.massRegion == 'low' and lowMassCuts(chain, chain, cutter):
                    passed = True
                elif args.massRegion == 'high' and highMassCuts(chain, chain, cutter):
                    passed = True 
    else:
        passed = True

コード例 #4
0
else:
    event_range = sample.getEventRange(args.subJob)

#
# Loop over all events
#
from HNL.Tools.helpers import progress
from HNL.EventSelection.eventSelectionTools import select3Leptons
from HNL.ObjectSelection.electronSelector import isTightElectron
from HNL.ObjectSelection.muonSelector import isTightMuon
for entry in event_range:

    chain.GetEntry(entry)
    progress(entry - event_range[0], len(event_range))

    if not select3Leptons(chain, chain, tau_algo='gen_truth'): continue
    if args.useRef and not chain._passTrigger_ref: continue

    weightfactor = 1.
    if not sample.is_data: weightfactor *= chain._weight

    if args.separateTriggers is None:
        passed = passTriggers(chain, chain.year, oldAN=args.oldTriggers)

    true_cat = ec.returnCategory()

    for c in categories:
        for v in {k for k in var.keys()}:
            for t in category_map[c]:

                # if not true_cat == c: continue
コード例 #5
0
ファイル: cutflow.py プロジェクト: lwezenbe/HNL
    list_of_numbers['reco_tau'] += 1

    chain.leptons = [
        l for l in xrange(chain._nLight, chain._nL)
        if isGoodTau(chain, l, 'tight')
    ]
    if len(chain.leptons) == 0: continue
    list_of_numbers['reco_tau_good'] += 1

    if chain._nTau < 2: continue
    list_of_numbers['two_reco_tau'] += 1

    if len(chain.leptons) < 2: continue
    list_of_numbers['two_good_reco_tau'] += 1

    if not select3Leptons(chain, chain):
        continue
    list_of_numbers['final'] += 1

    chain.event_supercategory = ec.returnSuperCategory()
    if chain.event_supercategory > 1: continue
    list_of_numbers['cat_n'] += 1

print 'total', list_of_numbers['total']
print 'single_lep', list_of_numbers['single_lep']
print 'reco_tau', list_of_numbers['reco_tau']
print 'reco_tau_good', list_of_numbers['reco_tau_good']
print 'two_reco_tau', list_of_numbers['two_reco_tau']
print 'two_good_reco_tau', list_of_numbers['two_good_reco_tau']
print 'final', list_of_numbers['final']
print 'cat_n', list_of_numbers['cat_n']
コード例 #6
0
        
        chain.GetEntry(entry)
        progress(entry - event_range[0], len(event_range))

        if args.noskim: chain.weight = lw.getLumiWeight()
        else: chain.weight = chain.lumiweight

        cutter.cut(True, 'total')

        #Triggers
        if args.oldAnalysisCuts:
            if not cutter.cut(applyCustomTriggers(listOfTriggersAN2017014(chain)), 'pass_triggers'): continue

        #Selecting 3 leptons
        if not args.oldAnalysisCuts:
            if not cutter.cut(select3Leptons(chain, chain, light_algo = 'leptonMVAtZq', cutter=cutter), '3_tight_leptons'):   continue   
        else:   
            if not cutter.cut(select3Leptons(chain, chain, no_tau=True, light_algo = 'cutbased', cutter=cutter), '3_tight_leptons'):   continue   

        # chain.category will be needed in passBaseCutsAN2017014
        chain.category = ec.returnCategory()

        #Check if baseline selection passed, needs to be done after category assignment due to pt cuts dependency on it
        if not args.oldAnalysisCuts:
            if not passBaseCuts(chain, chain, cutter): continue
        else:   
            if not passBaseCutsAN2017014(chain, chain, cutter): continue

        calculateKinematicVariables(chain, chain)

        if args.massRegion is not None: