def conept_TTH_production(lep): if (abs(lep.pdgId()) != 11 and abs(lep.pdgId()) != 13): return lep.pt() if (abs(lep.pdgId()) != 13 or lep.muonID("POG_ID_Medium") > 0) and getattr( lep, 'mvaValueTTH', -1) > 0.75: return lep.pt() else: return 0.85 * jetLepAwareJEC(lep).Pt() if hasattr(lep, 'jet') else -1
MVAVar( "LepGood_jetNDauChargedMVASel", lambda lepton: sum( (deltaR(x.eta(), x.phi(), lepton.jet.eta(), lepton.jet.phi()) <= 0.4 and x.charge() != 0 and x.fromPV() > 1 and qualityTrk( x.pseudoTrack(), lepton.associatedVertex)) for x in lepton.jet.daughterPtrVector()) if hasattr(lepton, 'jet') and lepton.jet != lepton else 0), MVAVar("LepGood_miniRelIsoCharged", lambda x: getattr(x, 'miniAbsIsoCharged', -99) / x.pt()), MVAVar("LepGood_miniRelIsoNeutral", lambda x: getattr(x, 'miniAbsIsoNeutral', -99) / x.pt()), MVAVar("LepGood_jetPtRelv2", lambda x: ptRelv2(x) if hasattr(x, 'jet') else -1), MVAVar( "LepGood_jetPtRatio := min(LepGood_jetPtRatiov2,1.5)", lambda x: min((x.pt() / jetLepAwareJEC(x).Pt() if hasattr(x, 'jet') else -1), 1.5)), MVAVar( "LepGood_jetBTagCSV := max(LepGood_jetBTagCSV,0)", lambda x: max( (x.jet.btag('pfCombinedInclusiveSecondaryVertexV2BJetTags') if hasattr(x.jet, 'btag') else -99), 0.)), MVAVar("LepGood_sip3d", lambda x: x.sip3D()), MVAVar("LepGood_dxy := log(abs(LepGood_dxy))", lambda x: log(abs(x.dxy()))), MVAVar("LepGood_dz := log(abs(LepGood_dz))", lambda x: log(abs(x.dz()))), ], 'SoftJetLessNOBTAG': [ MVAVar("LepGood_pt", lambda x: x.pt()), MVAVar("LepGood_eta", lambda x: x.eta()), MVAVar(
MVAVar("LepGood_mcMatchAny",lambda x: getattr(x,'mcMatchAny',-999)), ], } _CommonSpect['forMoriond_eleOLD'] = _CommonSpect['forMoriond'] _CommonSpect['forMoriond_eleHZZ'] = _CommonSpect['forMoriond'] _CommonSpect['forMoriond_eleGP'] = _CommonSpect['forMoriond'] _CommonVars = { 'forMoriond':[ MVAVar("LepGood_pt",lambda x: x.pt()), MVAVar("LepGood_eta",lambda x: x.eta()), MVAVar("LepGood_jetNDauChargedMVASel",lambda lepton: sum((deltaR(x.eta(),x.phi(),lepton.eta(),lepton.phi())<=0.4 and x.charge()!=0 and x.fromPV()>1 and x.hasTrackDetails() and qualityTrk(x.pseudoTrack(),lepton.associatedVertex)) for x in lepton.jet.daughterPtrVector()) if hasattr(lepton,'jet') and lepton.jet != lepton else 0), MVAVar("LepGood_miniRelIsoCharged",lambda x: getattr(x,'miniAbsIsoCharged',-99)/x.pt()), MVAVar("LepGood_miniRelIsoNeutral",lambda x: getattr(x,'miniAbsIsoNeutral',-99)/x.pt()), MVAVar("LepGood_jetPtRelv2", lambda x : ptRelv2(x) if hasattr(x,'jet') else -1), MVAVar("LepGood_jetPtRatio := min(LepGood_jetPtRatiov2,1.5)", lambda x : min((x.pt()/jetLepAwareJEC(x).Pt() if hasattr(x,'jet') else -1), 1.5)), MVAVar("LepGood_jetBTagCSV := max(LepGood_jetBTagCSV,0)", lambda x : max( (x.jet.btag('pfCombinedInclusiveSecondaryVertexV2BJetTags') if hasattr(x.jet, 'btag') else -99) ,0.)), MVAVar("LepGood_sip3d",lambda x: x.sip3D()), MVAVar("LepGood_dxy := log(abs(LepGood_dxy))",lambda x: log(abs(x.dxy()))), MVAVar("LepGood_dz := log(abs(LepGood_dz))", lambda x: log(abs(x.dz()))), ], 'SoftJetLessNOBTAG': [ MVAVar("LepGood_pt",lambda x: x.pt()), MVAVar("LepGood_eta",lambda x: x.eta()), MVAVar("LepGood_miniRelIsoCharged := min(LepGood_miniRelIsoCharged,4)",lambda x: min(getattr(x,'miniAbsIsoCharged',-99)/x.pt(),4)), MVAVar("LepGood_miniRelIsoNeutral := min(LepGood_miniRelIsoNeutral,4)",lambda x: min(getattr(x,'miniAbsIsoNeutral',-99)/x.pt(),4)), MVAVar("LepGood_isoRelH04",lambda x: isoRelH(x,'04') if hasattr(x,'isoSumRawP4Charged04') else -1), MVAVar("LepGood_RelIsoChargedFix04 := min(LepGood_RelIsoChargedFix04,4)",lambda x: min(getattr(x,'AbsIsoMIVCharged04',-99)/x.pt(),4)), MVAVar("LepGood_RelIsoNeutralFix04 := min(LepGood_RelIsoNeutralFix04,4)",lambda x: min(getattr(x,'AbsIsoMIVNeutral04',-99)/x.pt(),4)), MVAVar("LepGood_sip3d",lambda x: x.sip3D()), MVAVar("LepGood_dxy := log(abs(LepGood_dxy))",lambda x: log(abs(x.dxy()))),
_CommonSpect['forMoriond_eleOLD'] = _CommonSpect['forMoriond'] _CommonSpect['forMoriond_eleHZZ'] = _CommonSpect['forMoriond'] _CommonSpect['forMoriond_eleGP'] = _CommonSpect['forMoriond'] _CommonSpect['ttv_noLepTau_2016'] = _CommonSpect['forMoriond'] _CommonSpect['ttv_noLepTau_2017'] = _CommonSpect['forMoriond'] _CommonSpect['training2017'] = _CommonSpect['forMoriond'] _CommonVars = { 'forMoriond':[ MVAVar("LepGood_pt",lambda x: x.pt()), MVAVar("LepGood_eta",lambda x: x.eta()), MVAVar("LepGood_jetNDauChargedMVASel",lambda lepton: sum((deltaR(x.eta(),x.phi(),lepton.jet.eta(),lepton.jet.phi())<=0.4 and x.charge()!=0 and x.fromPV()>1 and x.hasTrackDetails() and qualityTrk(x.pseudoTrack(),lepton.associatedVertex)) for x in lepton.jet.daughterPtrVector()) if hasattr(lepton,'jet') and lepton.jet != lepton else 0), MVAVar("LepGood_miniRelIsoCharged",lambda x: getattr(x,'miniAbsIsoCharged',-99)/x.pt()), MVAVar("LepGood_miniRelIsoNeutral",lambda x: getattr(x,'miniAbsIsoNeutral',-99)/x.pt()), MVAVar("LepGood_jetPtRelv2", lambda x : ptRelv2(x) if hasattr(x,'jet') else -1), MVAVar("LepGood_jetPtRatio := min(LepGood_jetPtRatiov2,1.5)", lambda x : min((x.pt()/jetLepAwareJEC(x).Pt() if hasattr(x,'jet') else -1), 1.5)), MVAVar("LepGood_jetBTagCSV := max(LepGood_jetBTagCSV,0)", lambda x : max( (x.jet.btag('pfCombinedInclusiveSecondaryVertexV2BJetTags') if hasattr(x.jet, 'btag') else -99) ,0.)), MVAVar("LepGood_sip3d",lambda x: x.sip3D()), MVAVar("LepGood_dxy := log(abs(LepGood_dxy))",lambda x: log(abs(x.dxy()))), MVAVar("LepGood_dz := log(abs(LepGood_dz))", lambda x: log(abs(x.dz()))), ], 'SoftJetLessNOBTAG': [ MVAVar("LepGood_pt",lambda x: x.pt()), MVAVar("LepGood_eta",lambda x: x.eta()), MVAVar("LepGood_miniRelIsoCharged := min(LepGood_miniRelIsoCharged,4)",lambda x: min(getattr(x,'miniAbsIsoCharged',-99)/x.pt(),4)), MVAVar("LepGood_miniRelIsoNeutral := min(LepGood_miniRelIsoNeutral,4)",lambda x: min(getattr(x,'miniAbsIsoNeutral',-99)/x.pt(),4)), MVAVar("LepGood_isoRelH04",lambda x: isoRelH(x,'04') if hasattr(x,'isoSumRawP4Charged04') else -1), MVAVar("LepGood_RelIsoChargedFix04 := min(LepGood_RelIsoChargedFix04,4)",lambda x: min(getattr(x,'AbsIsoMIVCharged04',-99)/x.pt(),4)), MVAVar("LepGood_RelIsoNeutralFix04 := min(LepGood_RelIsoNeutralFix04,4)",lambda x: min(getattr(x,'AbsIsoMIVNeutral04',-99)/x.pt(),4)), MVAVar("LepGood_sip3d",lambda x: x.sip3D()), MVAVar("LepGood_dxy := log(abs(LepGood_dxy))",lambda x: log(abs(x.dxy()))),
def __init__(self,catMvaPairs): self.catMvaPairs = catMvaPairs def __call__(self,lep,ncorr): for c,m in self.catMvaPairs: if c(lep): return m(lep,ncorr) return -99. _CommonSpect = [ ] _CommonVars = { 'WithPtV2':[ MVAVar("LepGood_pt",lambda x: x.pt()), MVAVar("LepGood_miniRelIsoCharged",lambda x: getattr(x,'miniAbsIsoCharged',-99)/x.pt()), MVAVar("LepGood_miniRelIsoNeutral",lambda x: getattr(x,'miniAbsIsoNeutral',-99)/x.pt()), MVAVar("LepGood_jetPtRelv2", lambda x : ptRelv2(x) if hasattr(x,'jet') else -1), MVAVar("LepGood_jetPtRatio := min(LepGood_jetPtRatio_LepAwareJECv2,1.5)", lambda x : min((x.pt()/jetLepAwareJEC(x).Pt() if hasattr(x,'jet') else -1), 1.5)), MVAVar("LepGood_jetBTagCSV := max(LepGood_jetBTagCSV,0)", lambda x : max( (x.jet.btag('pfCombinedInclusiveSecondaryVertexV2BJetTags') if hasattr(x.jet, 'btag') else -99) ,0.)), MVAVar("LepGood_sip3d",lambda x: x.sip3D()), MVAVar("LepGood_dxy := log(abs(LepGood_dxy))",lambda x: log(abs(x.dxy()))), MVAVar("LepGood_dz := log(abs(LepGood_dz))", lambda x: log(abs(x.dz()))), ], 'forMoriond16':[ MVAVar("LepGood_pt",lambda x: x.pt()), MVAVar("LepGood_eta",lambda x: x.eta()), MVAVar("LepGood_jetNDauChargedMVASel",lambda lepton: sum((deltaR(x.eta(),x.phi(),lepton.jet.eta(),lepton.jet.phi())<=0.4 and x.charge()!=0 and x.fromPV()>1 and qualityTrk(x.pseudoTrack(),lepton.associatedVertex)) for x in lepton.jet.daughterPtrVector()) if hasattr(lepton,'jet') and lepton.jet != lepton else 0), MVAVar("LepGood_miniRelIsoCharged",lambda x: getattr(x,'miniAbsIsoCharged',-99)/x.pt()), MVAVar("LepGood_miniRelIsoNeutral",lambda x: getattr(x,'miniAbsIsoNeutral',-99)/x.pt()), MVAVar("LepGood_jetPtRelv2", lambda x : ptRelv2(x) if hasattr(x,'jet') else -1), MVAVar("LepGood_jetPtRatio := min(LepGood_jetPtRatiov2,1.5)", lambda x : min((x.pt()/jetLepAwareJEC(x).Pt() if hasattr(x,'jet') else -1), 1.5)), MVAVar("LepGood_jetBTagCSV := max(LepGood_jetBTagCSV,0)", lambda x : max( (x.jet.btag('pfCombinedInclusiveSecondaryVertexV2BJetTags') if hasattr(x.jet, 'btag') else -99) ,0.)), MVAVar("LepGood_sip3d",lambda x: x.sip3D()), MVAVar("LepGood_dxy := log(abs(LepGood_dxy))",lambda x: log(abs(x.dxy()))),