from CMGTools.TTHAnalysis.tools.combinedObjectTaggerForCleaning import CombinedObjectTaggerForCleaning from CMGTools.TTHAnalysis.tools.nanoAOD.fastCombinedObjectRecleaner import fastCombinedObjectRecleaner recleaner_step1 = lambda : CombinedObjectTaggerForCleaning("InternalRecl", looseLeptonSel = lambda lep,year: ((abs(lep.pdgId)==11 and (VLooseFOEleID(lep,year) and lep.lostHits<=1))) or (abs(lep.pdgId)==13 and lep.looseId), cleaningLeptonSel = lambda lep,year: tightLeptonSel_SOS(lep,year) or looseNotTight_SOS(lep,year) , FOLeptonSel = lambda lep,year: tightLeptonSel_SOS(lep,year) or looseNotTight_SOS(lep,year) , tightLeptonSel = lambda lep,year: tightLeptonSel_SOS(lep,year), #tight wp FOTauSel = foTauSel, tightTauSel = tightTauSel, selectJet = lambda jet: abs(jet.eta)<2.4 and jet.pt > 25 and jet.jetId > 0, # FIXME need to select on pt or ptUp or ptDown coneptdef = lambda lep: lep.pt) recleaner_step2_mc = 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 = True) 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)
FOTauSel=foTauSel, tightTauSel=tightTauSel, selectJet=lambda jet: jet.jetId > 0, # pt and eta cuts are (hard)coded in the step2 coneptdef=lambda lep: conept_TTH(lep), ) recleaner_step2_mc_allvariations = lambda: fastCombinedObjectRecleaner( label="Recl", inlabel="_InternalRecl", cleanTausWithLooseLeptons=True, cleanJetsWithFOTaus=True, doVetoZ=False, doVetoLMf=False, 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, isMC=True, variations=['jes%s' % v for v in jecGroups] + [ 'jer%s' % x for x in [ 'barrel', 'endcap1', 'endcap2highpt', 'endcap2lowpt', 'forwardhighpt', 'forwardlowpt' ] ] + ['HEM']) recleaner_step2_mc = lambda: fastCombinedObjectRecleaner( label="Recl", inlabel="_InternalRecl", cleanTausWithLooseLeptons=True, cleanJetsWithFOTaus=True, doVetoZ=False,
(abs(lep.pdgId) != 11 or lep.lostHits <= 1), cleaningLeptonSel=clean_and_FO_selection_TTH, FOLeptonSel=clean_and_FO_selection_TTH, tightLeptonSel=tightLeptonSel, FOTauSel=foTauSel, tightTauSel=tightTauSel, selectJet=lambda jet: jet.jetId > 0, # pt and eta cuts are (hard)coded in the step2 coneptdef=lambda lep: conept_TTH(lep)) recleaner_step2_mc = lambda: fastCombinedObjectRecleaner( label="Recl", inlabel="_InternalRecl", cleanTausWithLooseLeptons=True, cleanJetsWithFOTaus=True, doVetoZ=False, doVetoLMf=False, 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, isMC=True) recleaner_step2_data = lambda: fastCombinedObjectRecleaner( label="Recl", inlabel="_InternalRecl", cleanTausWithLooseLeptons=True, cleanJetsWithFOTaus=True, doVetoZ=False, doVetoLMf=False, doVetoLMt=False, jetPts=[25, 40],
"InternalRecl", #looseLeptonSel = lambda lep : lep.miniPFRelIso_all < 0.4 and lep.sip3d < 8, cleaningLeptonSel=clean_and_FO_selection_TTH, FOLeptonSel=clean_and_FO_selection_TTH, tightLeptonSel=tightLeptonSel, FOTauSel=foTauSel, tightTauSel=tightTauSel, selectJet=lambda jet: abs(jet.eta) < 2.4 and jet.pt > 25, # FIXME need to select on pt or ptUp or ptDown coneptdef=lambda lep: conept_TTH(lep)) recleaner_step2_mc = lambda: fastCombinedObjectRecleaner( label="Recl", inlabel="_InternalRecl", cleanTausWithLooseLeptons=True, cleanJetsWithFOTaus=True, doVetoZ=False, doVetoLMf=False, doVetoLMt=False, jetPts=[25, 40], btagL_thr=0.1522, btagM_thr=0.4941, isMC=True) recleaner_step2_data = lambda: fastCombinedObjectRecleaner( label="Recl", inlabel="_InternalRecl", cleanTausWithLooseLeptons=True, cleanJetsWithFOTaus=True, doVetoZ=False, doVetoLMf=False, doVetoLMt=False, jetPts=[25, 40], btagL_thr=0.1522,