CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
autophobj.py
Go to the documentation of this file.
1 #!/bin/env python
2 from math import *
3 import ROOT
4 #from CMGTools.TTHAnalysis.signedSip import *
7 
8 twoVectorType = NTupleObjectType("twoVector", variables = [
9  NTupleVariable("pt", lambda x : x.pt()),
10  NTupleVariable("phi", lambda x : x.phi()),
11 ])
12 
13 fourVectorType = NTupleObjectType("fourVector", variables = [
14  NTupleVariable("pt", lambda x : x.pt()),
15  NTupleVariable("eta", lambda x : x.eta()),
16  NTupleVariable("phi", lambda x : x.phi()),
17  NTupleVariable("mass", lambda x : x.mass()),
18  NTupleVariable("p4", lambda x : x, "TLorentzVector", default=ROOT.reco.Particle.LorentzVector(0.,0.,0.,0.), filler = lambda vector, obj: vector.SetPtEtaPhiM(obj.pt(), obj.eta(), obj.phi(), obj.mass())),
19  # ^^^^------- Note: p4 normally is not saved unless 'saveTLorentzVectors' is enabled in the tree producer
20 ])
21 particleType = NTupleObjectType("particle", baseObjectTypes = [ fourVectorType ], variables = [
22  NTupleVariable("pdgId", lambda x : x.pdgId(), int),
23 ])
24 
25 ##------------------------------------------
26 ## LEPTON
27 ##------------------------------------------
28 
29 leptonType = NTupleObjectType("lepton", baseObjectTypes = [ particleType ], variables = [
30  NTupleVariable("charge", lambda x : x.charge(), int),
31  NTupleVariable("dxy", lambda x : x.dxy(), help="d_{xy} with respect to PV, in cm (with sign)"),
32  NTupleVariable("dz", lambda x : x.dz() , help="d_{z} with respect to PV, in cm (with sign)"),
33  NTupleVariable("edxy", lambda x : x.edB(), help="#sigma(d_{xy}) with respect to PV, in cm"),
34  NTupleVariable("edz", lambda x : x.gsfTrack().dzError() if abs(x.pdgId())==11 else x.innerTrack().dzError() , help="#sigma(d_{z}) with respect to PV, in cm"),
35 # NTupleVariable("ip3d", lambda x : abs(signedIp3D(x)) , help="d_{3d} with respect to PV, in cm (absolute value)"),
36  NTupleVariable("sip3d", lambda x : x.sip3D(), help="S_{ip3d} with respect to PV (absolute value)"),
37  NTupleVariable("tightId", lambda x : x.tightId(), int, help="POG Tight ID (based on triggering MVA value for electrons, boolean for muons)"),
38  NTupleVariable("convVeto", lambda x : x.passConversionVeto() if abs(x.pdgId())==11 else 1, int, help="Conversion veto (always true for muons)"),
39  NTupleVariable("lostHits", lambda x : x.lostInner() , int, help="Number of lost hits on inner track")
40 ])
41 leptonTypeTTH = NTupleObjectType("leptonTTH", baseObjectTypes = [ leptonType ], variables = [
42  NTupleVariable("tightCharge", lambda lepton : ( lepton.isGsfCtfScPixChargeConsistent() + lepton.isGsfScPixChargeConsistent() ) if abs(lepton.pdgId()) == 11 else 2*(lepton.innerTrack().ptError()/lepton.innerTrack().pt() < 0.2), int, help="Tight charge criteria"),
43  NTupleVariable("relIso", lambda x : x.relIso(dBetaFactor=0.5), help="PF Iso, R=0.4, with deltaBeta correction"),
44  NTupleVariable("chargedRelIso", lambda x : x.chargedHadronIso()/x.pt(), help="PF Iso from charged hadrons only, R=0.4"),
45  NTupleVariable("mvaId", lambda lepton : lepton.mvaNonTrigV0() if abs(lepton.pdgId()) == 11 else 1, help="EGamma POG MVA ID for non-triggering electrons (as HZZ); 1 for muons"),
46  NTupleVariable("mvaIdTrig", lambda lepton : lepton.mvaTrigV0() if abs(lepton.pdgId()) == 11 else 1, help="EGamma POG MVA ID for triggering electrons; 1 for muons"),
47  NTupleVariable("mva", lambda lepton : lepton.mvaValue, help="Lepton MVA (ttH version)"),
48  NTupleVariable("jetPtRatio", lambda lepton : lepton.pt()/lepton.jet.pt()),
49  NTupleVariable("jetBTagCSV", lambda lepton : lepton.jet.btag('combinedSecondaryVertexBJetTags') if hasattr(lepton.jet, 'btag') else -99),
50  NTupleVariable("jetDR", lambda lepton : deltaR(lepton.eta(),lepton.phi(),lepton.jet.eta(),lepton.jet.phi())),
51  NTupleVariable("mcMatchId", lambda x : x.mcMatchId, int, mcOnly=True, help="Match to source from hard scatter (25 for H, 6 for t, 23/24 for W/Z)"),
52  NTupleVariable("mcMatchAny", lambda x : x.mcMatchAny, int, mcOnly=True, help="Match to any final state leptons: -mcMatchId if prompt, 0 if unmatched, 1 if light flavour, 2 if heavy flavour (b)"),
53  NTupleVariable("mcMatchTau", lambda x : x.mcMatchTau, int, mcOnly=True, help="True if the leptons comes from a tau"),
54  NTupleVariable("convVetoFull", lambda x : (x.passConversionVeto() and x.gsfTrack().trackerExpectedHitsInner().numberOfLostHits() == 0) if abs(x.pdgId())==11 else 1, int, help="Conv veto + no missing hits for electrons, always true for muons."),
55 ])
56 leptonTypeSusy = NTupleObjectType("leptonSusy", baseObjectTypes = [ leptonType ], variables = [
57  # Loose id
58  NTupleVariable("looseIdSusy", lambda x : x.looseIdSusy if hasattr(x, 'looseIdSusy') else -1, int, help="Loose ID for Susy ntuples (always true on selected leptons)"),
59  # Isolations with the two radia
60  NTupleVariable("relIso03", lambda x : x.relIso03, help="PF Rel Iso, R=0.3, with deltaBeta correction for muons and rho corrections for electrons"),
61  NTupleVariable("relIso04", lambda x : x.relIso04, help="PF Rel Iso, R=0.4, with deltaBeta correction for muons and rho corrections for electrons"),
62  NTupleVariable("chargedHadRelIso03", lambda x : x.chargedHadronIso(0.3)/x.pt(), help="PF Rel Iso, R=0.3, charged hadrons only"),
63  NTupleVariable("chargedHadRelIso04", lambda x : x.chargedHadronIso(0.4)/x.pt(), help="PF Rel Iso, R=0.4, charged hadrons only"),
64  # Extra electron id variables
65  NTupleVariable("convVetoFull", lambda x : (x.passConversionVeto() and x.gsfTrack().trackerExpectedHitsInner().numberOfLostHits() == 0) if abs(x.pdgId())==11 else 1, int, help="Conv veto + no missing hits for electrons, always true for muons."),
66  #NTupleVariable("eleCutId2012", lambda x : (1*x.electronID("POG_Cuts_ID_2012_Veto") + 1*x.electronID("POG_Cuts_ID_2012_Loose") + 1*x.electronID("POG_Cuts_ID_2012_Medium") + 1*x.electronID("POG_Cuts_ID_2012_Tight")) if abs(x.pdgId()) == 11 else -1, int, help="Electron cut-based id (POG 2012): 0=none, 1=veto, 2=loose, 3=medium, 4=tight"),
67  #NTupleVariable("eleCutId2012_full5x5", lambda x : (1*x.electronID("POG_Cuts_ID_2012_full5x5_Veto") + 1*x.electronID("POG_Cuts_ID_2012_full5x5_Loose") + 1*x.electronID("POG_Cuts_ID_2012_full5x5_Medium") + 1*x.electronID("POG_Cuts_ID_2012_full5x5_Tight")) if abs(x.pdgId()) == 11 else -1, int, help="Electron cut-based id (POG 2012, full5x5 shapes): 0=none, 1=veto, 2=loose, 3=medium, 4=tight"),
68  NTupleVariable("eleCutIdCSA14_25ns_v1", lambda x : (1*x.electronID("POG_Cuts_ID_CSA14_25ns_v1_Veto") + 1*x.electronID("POG_Cuts_ID_CSA14_25ns_v1_Loose") + 1*x.electronID("POG_Cuts_ID_CSA14_25ns_v1_Medium") + 1*x.electronID("POG_Cuts_ID_CSA14_25ns_v1_Tight")) if abs(x.pdgId()) == 11 else -1, int, help="Electron cut-based id (POG CSA14_25ns_v1): 0=none, 1=veto, 2=loose, 3=medium, 4=tight"),
69  NTupleVariable("eleCutIdCSA14_50ns_v1", lambda x : (1*x.electronID("POG_Cuts_ID_CSA14_50ns_v1_Veto") + 1*x.electronID("POG_Cuts_ID_CSA14_50ns_v1_Loose") + 1*x.electronID("POG_Cuts_ID_CSA14_50ns_v1_Medium") + 1*x.electronID("POG_Cuts_ID_CSA14_50ns_v1_Tight")) if abs(x.pdgId()) == 11 else -1, int, help="Electron cut-based id (POG CSA14_50ns_v1): 0=none, 1=veto, 2=loose, 3=medium, 4=tight"),
70  #NTupleVariable("eleMVAId", lambda x : (x.electronID("POG_MVA_ID_NonTrig") + 2*x.electronID("POG_MVA_ID_Trig")) if abs(x.pdgId()) == 11 else -1, int, help="Electron mva id working point: 0=none, 1=non-trig, 2=trig, 3=both"),
71  NTupleVariable("eleMVAId", lambda x : (x.electronID("POG_MVA_ID_NonTrig_full5x5") + 2*x.electronID("POG_MVA_ID_Trig_full5x5")) if abs(x.pdgId()) == 11 else -1, int, help="Electron mva id working point (2012, full5x5 shapes): 0=none, 1=non-trig, 2=trig, 3=both"),
72  NTupleVariable("tightCharge", lambda lepton : ( lepton.isGsfCtfScPixChargeConsistent() + lepton.isGsfScPixChargeConsistent() ) if abs(lepton.pdgId()) == 11 else 2*(lepton.innerTrack().ptError()/lepton.innerTrack().pt() < 0.2), int, help="Tight charge criteria"),
73  #NTupleVariable("mvaId", lambda lepton : lepton.mvaNonTrigV0() if abs(lepton.pdgId()) == 11 else 1, help="EGamma POG MVA ID for non-triggering electrons (as HZZ); 1 for muons"),
74  NTupleVariable("mvaId", lambda lepton : lepton.mvaNonTrigV0(full5x5=True) if abs(lepton.pdgId()) == 11 else 1, help="EGamma POG MVA ID for non-triggering electrons (as HZZ); 1 for muons"),
75  NTupleVariable("mvaIdTrig", lambda lepton : lepton.mvaTrigV0(full5x5=True) if abs(lepton.pdgId()) == 11 else 1, help="EGamma POG MVA ID for triggering electrons; 1 for muons"),
76  # Muon-speficic info
77  NTupleVariable("nStations", lambda lepton : lepton.numberOfMatchedStations() if abs(lepton.pdgId()) == 13 else 4, help="Number of matched muons stations (4 for electrons)"),
78  NTupleVariable("trkKink", lambda lepton : lepton.combinedQuality().trkKink if abs(lepton.pdgId()) == 13 else 0, help="Tracker kink-finder"),
79  NTupleVariable("caloCompatibility", lambda lepton : lepton.caloCompatibility() if abs(lepton.pdgId()) == 13 else 0, help="Calorimetric compatibility"),
80  NTupleVariable("globalTrackChi2", lambda lepton : lepton.globalTrack().normalizedChi2() if abs(lepton.pdgId()) == 13 and lepton.globalTrack().isNonnull() else 0, help="Global track normalized chi2"),
81  # Extra tracker-related id variables
82  NTupleVariable("trackerLayers", lambda x : (x.track() if abs(x.pdgId())==13 else x.gsfTrack()).hitPattern().trackerLayersWithMeasurement(), int, help="Tracker Layers"),
83  NTupleVariable("pixelLayers", lambda x : (x.track() if abs(x.pdgId())==13 else x.gsfTrack()).hitPattern().pixelLayersWithMeasurement(), int, help="Pixel Layers"),
84  # TTH-id related variables
85  NTupleVariable("mvaTTH", lambda lepton : lepton.mvaValue if hasattr(lepton,'mvaValue') else -1, help="Lepton MVA (ttH version)"),
86  NTupleVariable("jetPtRatio", lambda lepton : lepton.pt()/lepton.jet.pt() if hasattr(lepton,'jet') else -1, help="pt(lepton)/pt(nearest jet)"),
87  NTupleVariable("jetBTagCSV", lambda lepton : lepton.jet.btag('combinedSecondaryVertexBJetTags') if hasattr(lepton,'jet') and hasattr(lepton.jet, 'btag') else -99, help="btag of nearest jet"),
88  NTupleVariable("jetDR", lambda lepton : deltaR(lepton.eta(),lepton.phi(),lepton.jet.eta(),lepton.jet.phi()) if hasattr(lepton,'jet') else -1, help="deltaR(lepton, nearest jet)"),
89  # MC-match info
90  NTupleVariable("mcMatchId", lambda x : x.mcMatchId, int, mcOnly=True, help="Match to source from hard scatter (25 for H, 6 for t, 23/24 for W/Z)"),
91  NTupleVariable("mcMatchAny", lambda x : x.mcMatchAny, int, mcOnly=True, help="Match to any final state leptons: -mcMatchId if prompt, 0 if unmatched, 1 if light flavour, 2 if heavy flavour (b)"),
92  NTupleVariable("mcMatchTau", lambda x : x.mcMatchTau, int, mcOnly=True, help="True if the leptons comes from a tau"),
93 ])
94 
95 leptonTypeSusyExtra = NTupleObjectType("leptonSusyExtra", baseObjectTypes = [ leptonTypeSusy ], variables = [
96  # IVF variables
97  NTupleVariable("hasSV", lambda x : (2 if getattr(x,'ivfAssoc','') == "byref" else (0 if getattr(x,'ivf',None) == None else 1)), int, help="2 if lepton track is from a SV, 1 if loosely matched, 0 if no SV found."),
98  NTupleVariable("svRedPt", lambda x : getattr(x, 'ivfRedPt', 0), help="pT of associated SV, removing the lepton track"),
99  NTupleVariable("svRedM", lambda x : getattr(x, 'ivfRedM', 0), help="mass of associated SV, removing the lepton track"),
100  NTupleVariable("svLepSip3d", lambda x : getattr(x, 'ivfSip3d', 0), help="sip3d of lepton wrt SV"),
101  NTupleVariable("svSip3d", lambda x : x.ivf.d3d.significance() if getattr(x,'ivf',None) != None else -99, help="S_{ip3d} of associated SV"),
102  NTupleVariable("svNTracks", lambda x : x.ivf.numberOfDaughters() if getattr(x,'ivf',None) != None else -99, help="Number of tracks of associated SV"),
103  NTupleVariable("svChi2n", lambda x : x.vertexChi2()/x.ivf.vertexNdof() if getattr(x,'ivf',None) != None else -99, help="Normalized chi2 of associated SV"),
104  NTupleVariable("svDxy", lambda x : x.ivf.dxy.value() if getattr(x,'ivf',None) != None else -99, help="dxy of associated SV"),
105  NTupleVariable("svM", lambda x : x.ivf.mass() if getattr(x,'ivf',None) != None else -99, help="mass of associated SV"),
106  NTupleVariable("svPt", lambda x : x.ivf.pt() if getattr(x,'ivf',None) != None else -99, help="pt of associated SV"),
107  NTupleVariable("svMCMatchFraction", lambda x : x.ivf.mcMatchFraction if getattr(x,'ivf',None) != None else -99, mcOnly=True, help="Fraction of mc-matched tracks from b/c matched to a single hadron (if >= 2 tracks found), for associated SV"),
108  # MVA muon ID variables
109  NTupleVariable("segmentCompatibility", lambda lepton : lepton.segmentCompatibility() if abs(lepton.pdgId()) == 13 else 0, help="Segment-based compatibility"),
110  NTupleVariable("innerTrackValidHitFraction", lambda lepton : lepton.innerTrack().validFraction() if abs(lepton.pdgId()) == 13 else 0, help="Calorimetric compatibility"),
111  NTupleVariable("chi2LocalPosition", lambda lepton : lepton.combinedQuality().chi2LocalPosition if abs(lepton.pdgId()) == 13 else 0, help="Calorimetric compatibility"),
112  NTupleVariable("chi2LocalMomentum", lambda lepton : lepton.combinedQuality().chi2LocalMomentum if abs(lepton.pdgId()) == 13 else 0, help="Calorimetric compatibility"),
113  NTupleVariable("glbTrackProbability", lambda lepton : lepton.combinedQuality().glbTrackProbability if abs(lepton.pdgId()) == 13 else 0, help="Calorimetric compatibility"),
114  NTupleVariable("trackerHits", lambda x : (x.track() if abs(x.pdgId())==13 else x.gsfTrack()).hitPattern().numberOfValidTrackerHits(), int, help="Tracker hits"),
115  NTupleVariable("lostOuterHits", lambda x : x.gsfTrack().trackerExpectedHitsOuter().numberOfLostHits() if abs(x.pdgId())==11 else x.innerTrack().trackerExpectedHitsOuter().numberOfLostHits(), int, help="Number of lost hits on inner track"),
116  # extra muon variables not used in MVA ID
117  NTupleVariable("caloEMEnergy", lambda lepton : lepton.calEnergy().em if abs(lepton.pdgId()) == 13 else 0, help="Calorimetric compatibility"),
118  NTupleVariable("caloHadEnergy", lambda lepton : lepton.calEnergy().had if abs(lepton.pdgId()) == 13 else 0, help="Calorimetric compatibility"),
119  NTupleVariable("innerTrackChi2", lambda lepton : lepton.innerTrack().normalizedChi2() if abs(lepton.pdgId()) == 13 and lepton.innerTrack().isNonnull() else 0, help="Inner track normalized chi2"),
120  NTupleVariable("stationsWithAnyHits", lambda lepton : lepton.outerTrack().hitPattern().muonStationsWithAnyHits() if abs(lepton.pdgId()) == 13 and lepton.outerTrack().isNonnull() else 0, help="Outer track stations with any hits"),
121  NTupleVariable("stationsWithValidHits", lambda lepton : lepton.outerTrack().hitPattern().muonStationsWithValidHits() if abs(lepton.pdgId()) == 13 and lepton.outerTrack().isNonnull() else 0, help="Outer track stations with valid hits"),
122  NTupleVariable("stationsWithValidHitsGlbTrack", lambda lepton : lepton.globalTrack().hitPattern().muonStationsWithValidHits() if abs(lepton.pdgId()) == 13 and lepton.globalTrack().isNonnull() else 0, help="Global track stations with valid hits"),
123 ])
124 
125 leptonTypeSusyFR = NTupleObjectType("leptonSusyFR", baseObjectTypes = [ leptonTypeTTH ], variables = [
126  NTupleVariable("relIso03", lambda x : x.relIso03, help="PF Rel Iso, R, with deltaBeta correction"),
127  NTupleVariable("looseFakeId", lambda x : x.looseFakeId, int, help="Loose ID for Susy Fake Rate exercise"),
128  NTupleVariable("tightFakeId", lambda x : x.tightFakeId, int, help="Tight ID for Susy Fake Rate exercise"),
129  #NTupleVariable("rho", lambda x : x.rho if hasattr(x, 'rho') else -99.0, help="PF Rel Iso, R, with deltaBeta correction"),
130  #NTupleVariable("EA", lambda x : x.EffectiveArea if hasattr(x, 'EffectiveArea') else -99.0, help="PF Rel Iso, R, with deltaBeta correction"),
131  #NTupleVariable("relIso03_ch", lambda x : x.chargedHadronIso(0.3) if abs(x.pdgId())==11 else 0, help="PF Rel Iso, R, with deltaBeta correction"),
132  #NTupleVariable("relIso03_nh", lambda x : x.neutralHadronIso(0.3) if abs(x.pdgId())==11 else 0, help="PF Rel Iso, R, with deltaBeta correction"),
133  #NTupleVariable("relIso03_ph", lambda x : x.photonIso(0.3) if abs(x.pdgId())==11 else 0, help="PF Rel Iso, R, with deltaBeta correction"),
134 ])
135 leptonTypeFull = NTupleObjectType("leptonFull", baseObjectTypes = [ leptonTypeSusy ], variables = [
136  NTupleVariable("pfMuonId", lambda x : x.muonID("POG_ID_Loose") if abs(x.pdgId())==13 else 1, int, help="Muon POG Loose id"),
137  NTupleVariable("softMuonId", lambda x : x.muonID("POG_ID_Soft") if abs(x.pdgId())==13 else 1, int, help="Muon POG Soft id"),
138 ])
139 
140 
141 ##------------------------------------------
142 ## TAU
143 ##------------------------------------------
144 
145 tauType = NTupleObjectType("tau", baseObjectTypes = [ particleType ], variables = [
146  NTupleVariable("charge", lambda x : x.charge(), int),
147  NTupleVariable("dxy", lambda x : x.dxy(), help="d_{xy} of lead track with respect to PV, in cm (with sign)"),
148  NTupleVariable("dz", lambda x : x.dz() , help="d_{z} of lead track with respect to PV, in cm (with sign)"),
149  #NTupleVariable("idMVA2", lambda x : x.idMVA2, int, help="1,2,3 if the tau passes the loose, medium, tight WP of the By<X>IsolationMVA2 discriminator"),
150  NTupleVariable("idCI3hit", lambda x : x.idCI3hit, int, help="1,2,3 if the tau passes the loose, medium, tight WP of the By<X>CombinedIsolationDBSumPtCorr3Hits discriminator"),
151  NTupleVariable("isoCI3hit", lambda x : x.tauID("byCombinedIsolationDeltaBetaCorrRaw3Hits"), help="byCombinedIsolationDeltaBetaCorrRaw3Hits raw output discriminator"),
152  #NTupleVariable("isoMVA2", lambda x : x.tauID("byIsolationMVA2raw"), help="ByIsolationMVA2 raw output discriminator"),
153 ])
154 tauTypeTTH = NTupleObjectType("tauTTH", baseObjectTypes = [ tauType ], variables = [
155  NTupleVariable("mcMatchId", lambda x : x.mcMatchId, int, mcOnly=True, help="Match to source from hard scatter (25 for H, 6 for t, 23/24 for W/Z)"),
156 ])
157 tauTypeSusy = NTupleObjectType("tauSusy", baseObjectTypes = [ tauType ], variables = [
158  NTupleVariable("mcMatchId", lambda x : x.mcMatchId, int, mcOnly=True, help="Match to source from hard scatter (25 for H, 6 for t, 23/24 for W/Z)"),
159 ])
160 
161 ##------------------------------------------
162 ## ISOTRACK
163 ##------------------------------------------
164 
165 isoTrackType = NTupleObjectType("isoTrack", baseObjectTypes = [ particleType ], variables = [
166  NTupleVariable("charge", lambda x : x.charge(), int),
167  NTupleVariable("dz", lambda x : x.dz() , help="d_{z} of lead track with respect to PV, in cm (with sign)"),
168  NTupleVariable("absIso", lambda x : x.absIso, float, mcOnly=False, help="abs charged iso with condition for isolation such that Min(0.2*pt, 8 GeV)"),
169  NTupleVariable("mcMatchId", lambda x : x.mcMatchId, int, mcOnly=True, help="Match to source from hard scatter (25 for H, 6 for t, 23/24 for W/Z)"),
170 ])
171 
172 
173 ##------------------------------------------
174 ## PHOTON
175 ##------------------------------------------
176 
177 photonTypeSusy = NTupleObjectType("gamma", baseObjectTypes = [ particleType ], variables = [
178  NTupleVariable("idCutBased", lambda x : x.idCutBased, int, help="1,2,3 if the gamma passes the loose, medium, tight WP of PhotonCutBasedID"),
179  NTupleVariable("hOverE", lambda x : x.hOVERe(), float, help="hoverE for photons"),
180  NTupleVariable("r9", lambda x : x.r9(), float, help="r9 for photons"),
181  NTupleVariable("sigmaIetaIeta", lambda x : x.sigmaIetaIeta(), float, help="sigmaIetaIeta for photons"),
182  NTupleVariable("chHadIso", lambda x : x.chargedHadronIso(), float, help="chargedHadronIsolation for photons"),
183  NTupleVariable("neuHadIso", lambda x : x.neutralHadronIso(), float, help="neutralHadronIsolation for photons"),
184  NTupleVariable("phIso", lambda x : x.photonIso(), float, help="gammaIsolation for photons"),
185  NTupleVariable("mcMatchId", lambda x : x.mcMatchId, int, mcOnly=True, help="Match to source from hard scatter (25 for H, 6 for t, 23/24 for W/Z)"),
186 ])
187 
188 ##------------------------------------------
189 ## JET
190 ##------------------------------------------
191 
192 jetType = NTupleObjectType("jet", baseObjectTypes = [ fourVectorType ], variables = [
193  NTupleVariable("btagCSV", lambda x : x.btag('combinedSecondaryVertexBJetTags'), help="CSV discriminator"),
194  NTupleVariable("rawPt", lambda x : x.pt() * x.rawFactor(), help="p_{T} before JEC"),
195  NTupleVariable("mcPt", lambda x : x.mcJet.pt() if x.mcJet else 0., mcOnly=True, help="p_{T} of associated gen jet"),
196  NTupleVariable("mcFlavour", lambda x : x.partonFlavour(), int, mcOnly=True, help="parton flavour (physics definition, i.e. including b's from shower)"),
197  #NTupleVariable("quarkGluonID", lambda x : x.QG, mcOnly=False),
198 ])
199 jetTypeTTH = NTupleObjectType("jetTTH", baseObjectTypes = [ jetType ], variables = [
200  NTupleVariable("mcMatchId", lambda x : x.mcMatchId, int, mcOnly=True, help="Match to source from hard scatter (25 for H, 6 for t, 23/24 for W/Z)"),
201  NTupleVariable("mcMatchFlav", lambda x : x.mcMatchFlav, int, mcOnly=True, help="Flavour of associated parton from hard scatter (if any)"),
202 ])
203 jetTypeSusy = NTupleObjectType("jetSusy", baseObjectTypes = [ jetType ], variables = [
204  NTupleVariable("mcMatchId", lambda x : x.mcMatchId, int, mcOnly=True, help="Match to source from hard scatter (25 for H, 6 for t, 23/24 for W/Z)"),
205  NTupleVariable("mcMatchFlav", lambda x : x.mcMatchFlav, int, mcOnly=True, help="Flavour of associated parton from hard scatter (if any)"),
206  NTupleVariable("area", lambda x : x.jetArea(), help="Catchment area of jet"),
207  NTupleVariable("puId", lambda x : x.puJetIdPassed, int, mcOnly=False, help="puId (full MVA, loose WP, 5.3.X training on AK5PFchs: the only thing that is available now)"),
208  #NTupleVariable("PuId_full", lambda x : x.puId("full"), int, mcOnly=False, help="puId full: returns an integeger containing 3 bits, one for each working point (loose-bit2, medium-bit1, tight-bit0)"),
209  #NTupleVariable("PuId_simple", lambda x : x.puId("simple"), int, mcOnly=False, help="puId simple: returns an integeger containing 3 bits, one for each working point (loose-bit2, medium-bit1, tight-bit0)"),
210  #NTupleVariable("PuId_cut_based", lambda x : x.puId("cut-based"), int, mcOnly=False, help="puId cut-based: returns an integeger containing 3 bits, one for each working point (loose-bit2, medium-bit1, tight-bit0)"),
211  NTupleVariable("id", lambda x : x.jetID("POG_PFID") , int, mcOnly=False,help="POG Loose jet ID"),
212 ])
213 
214 
215 ##------------------------------------------
216 ## MET
217 ##------------------------------------------
218 
219 metType = NTupleObjectType("met", baseObjectTypes = [ fourVectorType ], variables = [
220  NTupleVariable("sumEt", lambda x : x.sumEt() ),
221  NTupleVariable("genPt", lambda x : x.genMET().pt() , mcOnly=True ),
222  NTupleVariable("genPhi", lambda x : x.genMET().phi(), mcOnly=True ),
223  NTupleVariable("genEta", lambda x : x.genMET().eta(), mcOnly=True ),
224 ])
225 
226 ##------------------------------------------
227 ## GENPARTICLE
228 ##------------------------------------------
229 
230 genParticleType = NTupleObjectType("genParticle", baseObjectTypes = [ particleType ], mcOnly=True, variables = [
231  NTupleVariable("charge", lambda x : x.threeCharge()/3.0, float),
232  NTupleVariable("status", lambda x : x.status(),int),
233 
234 ])
235 genParticleWithSourceType = NTupleObjectType("genParticleWithSource", baseObjectTypes = [ genParticleType ], mcOnly=True, variables = [
236  NTupleVariable("sourceId", lambda x : x.sourceId, int, help="origin of the particle: 6=t, 25=h, 23/24=W/Z")
237 ])
238 genParticleWithMotherId = NTupleObjectType("genParticleWithMotherId", baseObjectTypes = [ genParticleType ], mcOnly=True, variables = [
239  #NTupleVariable("motherId", lambda x : x.motherId, int, help="pdgId of the mother of the particle")
240  NTupleVariable("motherId", lambda x : x.mother(0).pdgId() if x.mother(0) else 0, int, help="pdgId of the mother of the particle"),
241  NTupleVariable("grandmaId", lambda x : x.mother(0).mother(0).pdgId() if x.mother(0) and x.mother(0).mother(0) else 0, int, help="pdgId of the grandmother of the particle")
242 ])
243 
244 ##------------------------------------------
245 ## SECONDARY VERTEX CANDIDATE
246 ##------------------------------------------
247 
248 svType = NTupleObjectType("sv", baseObjectTypes = [ fourVectorType ], variables = [
249  NTupleVariable("charge", lambda x : x.charge(), int),
250  NTupleVariable("ntracks", lambda x : x.numberOfDaughters(), int, help="Number of tracks (with weight > 0.5)"),
251  NTupleVariable("chi2", lambda x : x.vertexChi2(), help="Chi2 of the vertex fit"),
252  NTupleVariable("ndof", lambda x : x.vertexNdof(), help="Degrees of freedom of the fit, ndof = (2*ntracks - 3)" ),
253  NTupleVariable("dxy", lambda x : x.dxy.value(), help="Transverse distance from the PV [cm]"),
254  NTupleVariable("edxy", lambda x : x.dxy.error(), help="Uncertainty on the transverse distance from the PV [cm]"),
255  NTupleVariable("ip3d", lambda x : x.d3d.value(), help="3D distance from the PV [cm]"),
256  NTupleVariable("eip3d", lambda x : x.d3d.error(), help="Uncertainty on the 3D distance from the PV [cm]"),
257  NTupleVariable("sip3d", lambda x : x.d3d.significance(), help="S_{ip3d} with respect to PV (absolute value)"),
258  NTupleVariable("cosTheta", lambda x : x.cosTheta, help="Cosine of the angle between the 3D displacement and the momentum"),
259  NTupleVariable("jetPt", lambda x : x.jet.pt() if x.jet != None else 0, help="pT of associated jet"),
260  NTupleVariable("jetBTag", lambda x : x.jet.btag('combinedSecondaryVertexBJetTags') if x.jet != None else -99, help="CSV b-tag of associated jet"),
261  NTupleVariable("mcMatchNTracks", lambda x : x.mcMatchNTracks, int, mcOnly=True, help="Number of mc-matched tracks in SV"),
262  NTupleVariable("mcMatchNTracksHF", lambda x : x.mcMatchNTracksHF, int, mcOnly=True, help="Number of mc-matched tracks from b/c in SV"),
263  NTupleVariable("mcMatchFraction", lambda x : x.mcMatchFraction, mcOnly=True, help="Fraction of mc-matched tracks from b/c matched to a single hadron (or -1 if mcMatchNTracksHF < 2)"),
264  NTupleVariable("mcFlavFirst", lambda x : x.mcFlavFirst, int, mcOnly=True, help="Flavour of last ancestor with maximum number of matched daughters"),
265  NTupleVariable("mcFlavHeaviest", lambda x : x.mcFlavHeaviest, int, mcOnly=True, help="Flavour of heaviest hadron with maximum number of matched daughters"),
266 ])
267 
268 heavyFlavourHadronType = NTupleObjectType("heavyFlavourHadron", baseObjectTypes = [ genParticleType ], variables = [
269  NTupleVariable("flav", lambda x : x.flav, int, mcOnly=True, help="Flavour"),
270  NTupleVariable("sourceId", lambda x : x.sourceId, int, mcOnly=True, help="pdgId of heaviest mother particle (stopping at the first one heaviest than 175 GeV)"),
271  NTupleVariable("svMass", lambda x : x.sv.mass() if x.sv else 0, help="SV: mass"),
272  NTupleVariable("svPt", lambda x : x.sv.pt() if x.sv else 0, help="SV: pt"),
273  NTupleVariable("svCharge", lambda x : x.sv.charge() if x.sv else -99., int, help="SV: charge"),
274  NTupleVariable("svNtracks", lambda x : x.sv.numberOfDaughters() if x.sv else 0, int, help="SV: Number of tracks (with weight > 0.5)"),
275  NTupleVariable("svChi2", lambda x : x.sv.vertexChi2() if x.sv else -99., help="SV: Chi2 of the vertex fit"),
276  NTupleVariable("svNdof", lambda x : x.sv.vertexNdof() if x.sv else -99., help="SV: Degrees of freedom of the fit, ndof = (2*ntracks - 3)" ),
277  NTupleVariable("svDxy", lambda x : x.sv.dxy.value() if x.sv else -99., help="SV: Transverse distance from the PV [cm]"),
278  NTupleVariable("svEdxy", lambda x : x.sv.dxy.error() if x.sv else -99., help="SV: Uncertainty on the transverse distance from the PV [cm]"),
279  NTupleVariable("svIp3d", lambda x : x.sv.d3d.value() if x.sv else -99., help="SV: 3D distance from the PV [cm]"),
280  NTupleVariable("svEip3d", lambda x : x.sv.d3d.error() if x.sv else -99., help="SV: Uncertainty on the 3D distance from the PV [cm]"),
281  NTupleVariable("svSip3d", lambda x : x.sv.d3d.significance() if x.sv else -99., help="SV: S_{ip3d} with respect to PV (absolute value)"),
282  NTupleVariable("svCosTheta", lambda x : x.sv.cosTheta if x.sv else -99., help="SV: Cosine of the angle between the 3D displacement and the momentum"),
283  NTupleVariable("jetPt", lambda x : x.jet.pt() if x.jet != None else 0, help="Jet: pT"),
284  NTupleVariable("jetBTag", lambda x : x.jet.btag('combinedSecondaryVertexBJetTags') if x.jet != None else -99, help="CSV b-tag of associated jet"),
285 ])
286 
287 
T eta() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
Definition: DDAxes.h:10