Exemple #1
0
            (np.array([10., 20., 30., 45., 65., 100.
                       ]), np.array([0., .8, 1.442, 2.5])))
    else:
        raise RuntimeError('Invalid flavor')

    #
    # Loop over all events
    #
    from HNL.Tools.helpers import progress
    from HNL.Triggers.triggerSelection import passTriggers

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

        cutter.cut(True, 'total')

        #
        #Triggers
        #
        # if args.selection == 'AN2017014':
        #     if not cutter.cut(passTriggers(chain, 'HNL_old'), 'pass_triggers'): continue
        # else:
        #     if not cutter.cut(passTriggers(chain, 'HNL'), 'pass_triggers'): continue

        # if not cutter.cut(passTriggers(chain, 'ewkino'), 'pass_triggers'): continue

        event.initEvent()

        #Event selection
        if args.flavor == 'e':
Exemple #2
0
        print sample.name
        #
        # Loop over all events
        #
        from HNL.Tools.helpers import progress, deltaR, getLeptonFourVecFromChain
        from HNL.ObjectSelection.muonSelector import isGoodMuon
        from HNL.ObjectSelection.tauSelector import isGeneralTau
        from HNL.ObjectSelection.leptonSelector import isGoodLightLepton
        ec = EventCategory(chain)
        for entry in event_range:

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

            cutter.cut(True, 'total')

            keep_event = True

            #
            # Select single muon
            #
            muon_index = None
            for mu in xrange(chain._nMu):
                if not isGoodMuon(chain, mu, 'tight'): continue
                if not chain._lPt[mu] < 25: continue
                if muon_index is not None:
                    keep_event = False
                    break
                else:
                    muon_index = mu
Exemple #3
0
#
if args.isTest:
    event_range = range(20000)
    # event_range = sample.getEventRange(args.subJob)    

else:
    event_range = sample.getEventRange(args.subJob)    

from HNL.Tools.helpers import progress
from HNL.EventSelection.eventSelectionTools import calculateThreeLepVariables, calculateGeneralVariables, select3Leptons, select3GenLeptons
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
Exemple #4
0
        chain.HNLmass = float(sample.name.rsplit('-', 1)[1])
    chain.year = int(args.year)

    #
    # Loop over all events
    #
    from HNL.Tools.helpers import progress
    from HNL.ObjectSelection.tauSelector import tau_DMfinding, isCleanFromLightLeptons, passedMuonDiscr, passedElectronDiscr, tau_id_WP, isGoodGenTau
    algo_iso = 'deeptauVSjets'
    for entry in event_range:

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

        for index in xrange(chain._gen_nL):
            cutter.cut(isGoodGenTau(chain, index), 'total gen tau')

        for index in xrange(chain._nLight, chain._nL):
            if chain._tauGenStatus[index] != 5: continue
            cutter.cut(True, 'total reconstructed tau')
            if not cutter.cut(chain._lFlavor[index] == 2, 'lFlavor == 2'):
                continue
            if not cutter.cut(chain._lPt[index] > 20, 'pt > 20 GeV'): continue
            if not cutter.cut(chain._lEta[index] < 2.3, 'eta < 2.3'): continue
            if not cutter.cut(
                    tau_DMfinding[algo_iso](chain)[index]
                    and chain._tauDecayMode[index] != 5
                    and chain._tauDecayMode[index] != 6, 'DM finding'):
                continue
            if not cutter.cut(isCleanFromLightLeptons(chain, index),
                              'clean from light lep'):
Exemple #5
0
    #
    # Loop over all events
    #
    from HNL.Tools.helpers import progress
    from HNL.EventSelection.signalLeptonMatcher import SignalLeptonMatcher
    from HNL.Triggers.triggerSelection import applyCustomTriggers, listOfTriggersAN2017014
    from HNL.ObjectSelection.leptonSelector import isFOLepton, isTightLepton

    print 'tot_range', len(event_range)
    for entry in event_range:

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

        cutter.cut(True, 'total')

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

        #Event selection
        if not es.passedFilter(chain, chain, cutter): continue
        nprompt = 0
        for index in [chain.l1, chain.l2, chain.l3]:
            if chain._lIsPrompt[index]: nprompt += 1
Exemple #6
0
    #
    from HNL.Tools.helpers import progress
    from HNL.EventSelection.eventSelectionTools import select3Leptons, select3GenLeptons, passBaseCutsAN2017014, passBaseCuts, lowMassCuts, highMassCuts, calculateKinematicVariables, containsOSSF
    from HNL.EventSelection.signalLeptonMatcher import SignalLeptonMatcher
    from HNL.Triggers.triggerSelection import applyCustomTriggers, listOfTriggersAN2017014
    from HNL.ObjectSelection.leptonSelector import isFOLepton, isTightLepton
    print 'tot_range', len(event_range)
    for entry in event_range:
        
        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
Exemple #7
0
                                     var[v][2],
                                     getOutputName(),
                                     bins=var[v][1])

    #
    # Loop over all events
    #
    from HNL.Tools.helpers import progress
    from HNL.Triggers.triggerSelection import passTriggers

    print 'tot_range', len(event_range)
    for entry in event_range:
        chain.GetEntry(entry)
        progress(entry - event_range[0], len(event_range))

        cutter.cut(True, 'total')
        #
        #Triggers
        #
        if args.selection == 'AN2017014':
            if not cutter.cut(passTriggers(chain, 'HNL_old'), 'pass_triggers'):
                continue
        else:
            if not cutter.cut(passTriggers(chain, 'HNL'), 'pass_triggers'):
                continue

        #Event selection
        event.initEvent()
        if not event.event_selector.removeOverlapDYandZG(sample.output):
            continue
        if not event.event_selector.selector.passedFilter(cutter, args.region):
Exemple #8
0
                for n in listAvailableMVAs():
                    try:
                        tmva[sel][n] = Reader(chain, 'kBDT', n, sel)
                    except:
                        print 'Error when trying to load in BDT with {0} selection for name {1}'.format(
                            sel, n)

        #
        # Loop over all events
        #
        for entry in event_range:

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

            cutter.cut(True, 'Total')

            #
            #Triggers
            #
            if args.selection == 'AN2017014':
                if not cutter.cut(passTriggers(chain, analysis='HNL_old'),
                                  'pass_triggers'):
                    continue

            #
            # Event selection
            #
            event.initEvent()

            if not event.passedFilter(cutter, sample.output): continue