recleaner_step2_data = lambda : fastCombinedObjectRecleaner(label="Recl", inlabel="_InternalRecl",
	cleanTausWithLooseLeptons=True,
	cleanJetsWithFOTaus=True,
	doVetoZ=False, doVetoLMf=False, doVetoLMt=False,
	jetPts=[25,40],
	jetPtsFwd=[25,40],
	btagL_thr=lambda year: 0.4 if year==2016 else 0.1522 if year==2017 else 0.1241,
	btagM_thr=lambda year: 0.6324 if year==2016 else 0.4941 if year==2017 else 0.4184,
  jetBTag='btagDeepB',
	isMC = False)

from CMGTools.TTHAnalysis.tools.eventVars_2lss import EventVars2LSS
eventVars = lambda : EventVars2LSS('','Recl', doSystJEC=False)

from CMGTools.TTHAnalysis.tools.objTagger import ObjTagger
isMatchRightCharge = lambda : ObjTagger('isMatchRightCharge','LepGood', [lambda l,g: (l.genPartFlav==1 or l.genPartFlav == 15) and (g.pdgId*l.pdgId > 0) ], linkColl='GenPart',linkVar='genPartIdx')
mcMatchId     = lambda : ObjTagger('mcMatchId','LepGood', [lambda l: (l.genPartFlav==1 or l.genPartFlav == 15) ])
mcPromptGamma = lambda : ObjTagger('mcPromptGamma','LepGood', [lambda l: (l.genPartFlav==22)])
mcMatch_seq   = [ isMatchRightCharge, mcMatchId ,mcPromptGamma]

from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetmetUncertainties import jetmetUncertainties2016, jetmetUncertainties2017, jetmetUncertainties2018

isVLFOEle = lambda : ObjTagger('isVLFOEle', "Electron", [lambda lep,year: VLooseFOEleID(lep,year) ])
isTightEle = lambda : ObjTagger('isTightEle', "Electron", [lambda lep,year: tightEleID(lep,year)  ])

isCleanEle = lambda : ObjTagger('isCleanEle', "Electron", [ lambda lep,year: fullCleaningLeptonSel(lep,year) and electronSelection(lep) ])
isCleanMu = lambda : ObjTagger('isCleanMu', "Muon", [ lambda lep,year: fullCleaningLeptonSel(lep,year) and muonSelection(lep) ])
isCleanEle_noBtag = lambda : ObjTagger('isCleanEle_noBtag', "Electron", [ lambda lep,year: fullCleaningLeptonSel_noBtag(lep,year) and electronSelection(lep)  ])
isCleanMu_noBtag = lambda : ObjTagger('isCleanMu_noBtag', "Muon", [ lambda lep,year: fullCleaningLeptonSel_noBtag(lep,year) and muonSelection(lep) ])

isTightSOSEle = lambda : ObjTagger('isTightSOSEle', "Electron", [ lambda lep,year: fullTightLeptonSel(lep,year) and electronSelection(lep) ])
Esempio n. 2
0
            lambda lep : abs(lep.dz)<0.1,
            lambda lep : lep.pt > 10,
            lambda lep : ((abs(lep.eta)<2.4 and abs(lep.pdgId)==13) or (abs(lep.eta)<2.5 and abs(lep.pdgId)==11)),
            lambda lep : ((abs(lep.pdgId)!=11) or abs(lep.eta)<1.4442 or abs(lep.eta)>1.566),
            lambda lep : (lep.mediumMuonId > 0 or abs(lep.pdgId)!=13),
            lambda lep : (lep.mvaIdPhys14 > -0.11+(-0.35+0.11)*(abs(lep.eta)>0.8)+(-0.55+0.35)*(abs(lep.eta)>1.479) or abs(lep.pdgId)!=11),
            lambda lep : (lep.lostHits==0 or abs(lep.pdgId)!=11),
            lambda lep : lep.convVeto,
            lambda lep : lep.tightCharge > (abs(lep.pdgId) == 11),
            lambda lep: (lep.mcMatchId == 0) if hasattr(lep,"mcMatchId") else True
            ]

from CMGTools.TTHAnalysis.tools.objTagger import ObjTagger
MODULES.append ( ('leptonFakeRateFO1', ObjTagger('FO1','LepGood',
            list_cuts_tightlepid_nomultiiso_noeltightmvaid_nosip_nodxy+[
                lambda lep : (lep.mvaIdPhys14 > 0.73+(0.57-0.73)*(abs(lep.eta)>0.8)+(+0.05-0.57)*(abs(lep.eta)>1.479) or abs(lep.pdgId)!=11),
                lambda lep : lep.sip3d<4,
                lambda lep : abs(lep.dxy)<0.05,
            ]) ) )
MODULES.append ( ('leptonFakeRateFO2', ObjTagger('FO2','LepGood',
            list_cuts_tightlepid_nomultiiso_noeltightmvaid_nosip_nodxy+[
                lambda lep : lep.sip3d<4,
                lambda lep : abs(lep.dxy)<0.05,
            ]) ) )
MODULES.append ( ('leptonFakeRateFO3', ObjTagger('FO3','LepGood',
            list_cuts_tightlepid_nomultiiso_noeltightmvaid_nosip_nodxy+[
                lambda lep : _susy2lss_multiIso_withMiniIsoRelaxed_ConePtJetPtRatio(lep),
                lambda lep : (lep.mvaIdPhys14 > 0.73+(0.57-0.73)*(abs(lep.eta)>0.8)+(+0.05-0.57)*(abs(lep.eta)>1.479) or abs(lep.pdgId)!=11),
                lambda lep : lep.sip3d<4,
                lambda lep : abs(lep.dxy)<0.05,
            ]) ) )
MODULES.append ( ('leptonFakeRateFO4', ObjTagger('FO4','LepGood',
        cleanTau=lambda lep, tau, dr: dr < 0.4,
        looseTau=lambda tau: _susyEWK_tauId_CBloose(tau),  # used in cleaning
        tightTau=lambda tau: _susyEWK_tauId_CBtight(tau),  # on top of loose
        cleanJetsWithTaus=True,
        doVetoZ=True,
        doVetoLMf=True,
        doVetoLMt=True,
        jetPt=40,
        bJetPt=25,
        coneptdef=lambda lep: conept_SSDL(lep))))

MODULES.append(('MediumMuonID2016', lambda: ObjTagger(
    label='ICHEPmediumMuonId',
    coll='LepGood',
    sel=[
        lambda x: abs(x.pdgId) == 13, lambda x: x.isGlobalMuon or x.
        isTrackerMuon, lambda x: x.innerTrackValidHitFraction > 0.49, lambda x:
        x.segmentCompatibility > 0.451 or
        (x.isGlobalMuon and x.globalTrackChi2 < 3 and x.chi2LocalPosition < 12
         and x.trkKink < 20 and x.segmentCompatibility > 0.303)
    ])))

MODULES.append((
    'leptonJetReCleanerTTH',
    lambda: LeptonJetReCleaner(
        "Recl",  # b1E2 definition of FO, 80X b-tag WP
        looseLeptonSel=lambda lep: lep.miniRelIso < 0.4 and lep.sip3d < 8,
        cleaningLeptonSel=lambda lep: lep.conept > 10 and lep.jetBTagCSV < 0.80
        and (abs(lep.pdgId) != 11 or lep.conept < 30 or _ttH_idEmu_cuts_E2(lep)
             ) and ((lep.jetPtRatiov2 > 0.3 and lep.jetBTagCSV < 0.46) or lep.
                    mvaTTH > 0.75),  # cuts applied on top of loose
        FOLeptonSel=lambda lep, ht: lep.conept > 10 and lep.jetBTagCSV < 0.80
Esempio n. 4
0
    doVetoLMt=False,
    jetPts=[25, 40],
    jetPtsFwd=[25, 60
               ],  # second number for 2.7 < abseta < 3, the first for the rest
    btagL_thr=-99.,  # they are set at runtime  
    btagM_thr=-99.,  # they are set at runtime  
    isMC=False)

from CMGTools.TTHAnalysis.tools.eventVars_2lss import EventVars2LSS
eventVars = lambda: EventVars2LSS('', 'Recl')

from CMGTools.TTHAnalysis.tools.objTagger import ObjTagger
isMatchRightCharge = lambda: ObjTagger('isMatchRightCharge',
                                       'LepGood', [
                                           lambda l, g:
                                           (l.genPartFlav == 1 or l.genPartFlav
                                            == 15) and (g.pdgId * l.pdgId > 0)
                                       ],
                                       linkColl='GenPart',
                                       linkVar='genPartIdx')
mcMatchId = lambda: ObjTagger('mcMatchId', 'LepGood', [
    lambda l: (l.genPartFlav == 1 or l.genPartFlav == 15)
])
mcPromptGamma = lambda: ObjTagger('mcPromptGamma', 'LepGood',
                                  [lambda l: (l.genPartFlav == 22)])
mcMatch_seq = [isMatchRightCharge, mcMatchId, mcPromptGamma]

countTaus = lambda: ObjTagger('Tight', 'TauSel_Recl',
                              [lambda t: t.idDeepTau2017v2p1VSjet & 4])

from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetmetUncertainties import jetmetUncertainties2016All, jetmetUncertainties2017All, jetmetUncertainties2018All
from CMGTools.TTHAnalysis.tools.nanoAOD.jetMetCorrelator import jetMetCorrelations2016, jetMetCorrelations2017, jetMetCorrelations2018
Esempio n. 5
0
MODULES.append(('Trigger_mme', lambda: EvtTagger("Trigger_mme", [
    lambda ev: ev.HLT_BIT_HLT_DiMu9_Ele9_CaloIdL_TrackIdL_DZ_v
])))
MODULES.append(('Trigger_2lss', lambda: EvtTagger("Trigger_2lss", [
    lambda ev: ev.Trigger_1e or ev.Trigger_1m or ev.Trigger_2e or ev.Trigger_2m
    or ev.Trigger_em
])))
MODULES.append(('Trigger_3l', lambda: EvtTagger("Trigger_3l", [
    lambda ev: ev.Trigger_2lss or ev.Trigger_3e or ev.Trigger_3m or ev.
    Trigger_mee or ev.Trigger_mme
])))

from CMGTools.TTHAnalysis.tools.objTagger import ObjTagger
MODULES.append(
    ('TauTightFlag', lambda: ObjTagger("isTauTight", "TauSel_Recl", [
        lambda tau: tauID_oldDMdR0p3wLT2017v2_WP(tau.pt, tau.mvaId2017, 2)
    ])))

from CMGTools.TTHAnalysis.tools.bTagEventWeightsCSVFullShape import BTagEventWeightFriend
MODULES.append(('eventBTagWeight', lambda: BTagEventWeightFriend(
    csvfile=os.environ["CMSSW_BASE"] +
    "/src/CMGTools/TTHAnalysis/data/btag/DeepCSV_94XSF_V2_B_F.csv",
    discrname="btagDeepCSV")))

from CMGTools.TTHAnalysis.tools.higgsRecoTTH import HiggsRecoTTH
MODULES.append(('higgsRecoTTH', lambda: HiggsRecoTTH(label="_Recl",
                                                     cut_BDT_rTT_score=0.0,
                                                     cuts_mW_had=(60., 100.),
                                                     cuts_mH_vis=(80., 140.),
                                                     btagDeepCSVveto=0.1522)))
Esempio n. 6
0
from CMGTools.TTHAnalysis.tools.leptonFakeRateQCDVars import LeptonFakeRateQCDVars
#--- TTH instances
MODULES.append( ('leptonFakeRateQCDVarsTTH', lambda : LeptonFakeRateQCDVars(
                lambda lep : lep.sip3d < 8, # and lep.relIso03 < 0.5 and _tthlep_lepId(lep),
                lambda jet, lep, dr : jet.pt > (20 if abs(jet.eta)<2.4 else 30) and dr > 0.7) ) )
#--- Susy multilep instances
MODULES.append( ('leptonFakeRateQCDVarsSusy', lambda : LeptonFakeRateQCDVars(
                lambda lep : lep.miniRelIso < 0.4 and _susy2lss_lepId_CBloose(lep) and _susy2lss_lepId_loosestFO(lep) and _susy2lss_lepId_IPcuts(lep),
                lambda jet, lep, dr : jet.pt > 40 and abs(jet.eta)<2.4 and dr > 1.0 and jet.id ) ) )

#from CMGTools.TTHAnalysis.tools.leptonJetReCleaner import _susy2lss_multiIso_withMiniIsoRelaxed_ConePtJetPtRatio,_susy2lss_multiIso_withMiniIsoRelaxed_CutForFO4

from CMGTools.TTHAnalysis.tools.objTagger import ObjTagger
MODULES.append ( ('leptonFakeRateFO2', lambda: ObjTagger('FO2','LepGood',[
                lambda lep: lep.miniRelIso<0.4,
                lambda lep: _susy2lss_lepId_CBloose(lep),
                lambda lep: _susy2lss_lepId_loosestFO(lep),
                lambda lep: _susy2lss_lepId_IPcuts(lep),
                ] ) ) )
MODULES.append ( ('leptonFakeRateFO2iso', lambda: ObjTagger('FO2iso','LepGood',[
                lambda lep: lep.miniRelIso<0.4,
                lambda lep: _susy2lss_lepId_CBloose(lep),
                lambda lep: _susy2lss_lepId_tighterFO(lep),
                lambda lep: _susy2lss_lepId_IPcuts(lep),
                ] ) ) )
MODULES.append ( ('leptonFakeRateFO2InSitu', lambda: ObjTagger('FO2InSitu','LepGood',[
                lambda lep: lep.miniRelIso<0.4,
                lambda lep: _susy2lss_lepId_CBloose(lep),
                lambda lep: _susy2lss_lepId_loosestFO(lep),
                ] ) ) )
MODULES.append ( ('leptonFakeRateFO2isoInSitu', lambda: ObjTagger('FO2isoInSitu','LepGood',[
                lambda lep: lep.miniRelIso<0.4,
Esempio n. 7
0
    doVetoLMt=False,
    jetPts=[25, 40],
    jetPtsFwd=[25, 60
               ],  # second number for 2.7 < abseta < 3, the first for the rest
    btagL_thr=-99.,  # they are set at runtime  
    btagM_thr=-99.,  # they are set at runtime  
    isMC=False)

from CMGTools.TTHAnalysis.tools.eventVars_2lss import EventVars2LSS
eventVars = lambda: EventVars2LSS('', 'Recl', doSystJEC=False)

from CMGTools.TTHAnalysis.tools.objTagger import ObjTagger
isMatchRightCharge = lambda: ObjTagger('isMatchRightCharge',
                                       'LepGood', [
                                           lambda l, g:
                                           (l.genPartFlav == 1 or l.genPartFlav
                                            == 15) and (g.pdgId * l.pdgId > 0)
                                       ],
                                       linkColl='GenPart',
                                       linkVar='genPartIdx')
mcMatchId = lambda: ObjTagger('mcMatchId', 'LepGood', [
    lambda l: (l.genPartFlav == 1 or l.genPartFlav == 15)
])
mcPromptGamma = lambda: ObjTagger('mcPromptGamma', 'LepGood',
                                  [lambda l: (l.genPartFlav == 22)])
mcMatch_seq = [isMatchRightCharge, mcMatchId, mcPromptGamma]

from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetmetUncertainties import jetmetUncertainties2016, jetmetUncertainties2017, jetmetUncertainties2018


def _fires(ev, path):
    return getattr(ev, path) if hasattr(ev, path) else False
Esempio n. 8
0
                    ev.HLT_BIT_HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v or \
                    ev.HLT_BIT_HLT_Mu23_TrkIsoVVL_Ele12_CaloIdL_TrackIdL_IsoVL_v or \
                    ev.HLT_BIT_HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_DZ_v \
                    ] )))
MODULES.append( ('Trigger_3l', lambda : EvtTagger("Trigger_3l",[
                lambda ev : \
                    ev.HLT_TripleMu or \
                    ev.HLT_TripleEl or \
                    ev.HLT_DoubleMuEl or \
                    ev.HLT_DoubleElMu or \
                    ev.Trigger_2l \
                    ] )))

from CMGTools.TTHAnalysis.tools.objTagger import ObjTagger

MODULES.append(('TauTightFlag', lambda: ObjTagger(
    "isTauTight", "TauSel_Recl", [lambda tau: tau.idMVAdR03 >= 3])))

from CMGTools.TTHAnalysis.tools.bTagEventWeightsCSVFullShape import BTagEventWeightFriend

MODULES.append(('eventBTagWeight', lambda: BTagEventWeightFriend(
    csvfile=os.environ["CMSSW_BASE"] +
    "/src/CMGTools/TTHAnalysis/data/btag/DeepCSV_94XSF_V1_B_F.csv",
    discrname="btagDeepCSV")))

from CMGTools.TTHAnalysis.tools.BDT_resolvedTopTagger_cpp import BDT_resolvedTopTagger

MODULES.append(('BDT_rTT', lambda: BDT_resolvedTopTagger(
    os.environ["CMSSW_BASE"] +
    "/src/CMGTools/TTHAnalysis/data/kinMVA/tth/resTop_xGBoost_v0.weights.xml")
                ))
Esempio n. 9
0
    #                                         btagL_thr=0.4,#0.1241,#0.1522,
    #                                         btagM_thr=0.6324,#0.4184,#0.4941,
    btagL_thr=lambda year: 0.4 if year == 2016 else 0.1522
    if year == 2017 else 0.1241,  #0.4,#0.1241,#0.1522,
    btagM_thr=lambda year: 0.6324 if year == 2016 else 0.4941
    if year == 2017 else 0.4184,  #0.6324,#0.4184,#0.4941,
    isMC=False)

from CMGTools.TTHAnalysis.tools.eventVars_2lss import EventVars2LSS
eventVars = lambda: EventVars2LSS('', 'Recl', doSystJEC=False)

from CMGTools.TTHAnalysis.tools.objTagger import ObjTagger
isMatchRightCharge = lambda: ObjTagger('isMatchRightCharge',
                                       'LepGood', [
                                           lambda l, g:
                                           (l.genPartFlav == 1 or l.genPartFlav
                                            == 15) and (g.pdgId * l.pdgId > 0)
                                       ],
                                       linkColl='GenPart',
                                       linkVar='genPartIdx')
mcMatchId = lambda: ObjTagger('mcMatchId', 'LepGood', [
    lambda l: (l.genPartFlav == 1 or l.genPartFlav == 15)
])
mcPromptGamma = lambda: ObjTagger('mcPromptGamma', 'LepGood',
                                  [lambda l: (l.genPartFlav == 22)])
mcMatch_seq = [isMatchRightCharge, mcMatchId, mcPromptGamma]

from PhysicsTools.NanoAODTools.postprocessing.modules.jme.jetmetUncertainties import jetmetUncertainties2016, jetmetUncertainties2017, jetmetUncertainties2018

from CMGTools.TTHAnalysis.tools.nanoAOD.lepJetBTagAdder import eleJetBTagDeepCSV, muonJetBTagDeepCSV, eleJetBTagCSV, muonJetBTagCSV

isVLFOEle = lambda: ObjTagger('isVLFOEle', "Electron",