ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/PFCandidate.h
Revision: 1.11
Committed: Wed Jul 25 03:08:41 2012 UTC (12 years, 9 months ago) by paus
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, HEAD
Changes since 1.10: +17 -2 lines
Log Message:
Preparing for version 029.

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: PFCandidate.h,v 1.10 2012/03/29 23:41:55 paus Exp $
3 //
4 // PFCandidate
5 //
6 // Particle-flow candidate class, for now mostly mirroring the PFCandidate from CMSSW.
7 //
8 // Authors: J.Bendavid
9 //--------------------------------------------------------------------------------------------------
10
11 #ifndef MITANA_DATATREE_PFCandidate_H
12 #define MITANA_DATATREE_PFCandidate_H
13
14 #include "MitCommon/DataFormats/interface/Vect3.h"
15 #include "MitCommon/DataFormats/interface/Vect4M.h"
16 #include "MitAna/DataCont/interface/Ref.h"
17 #include "MitAna/DataTree/interface/CompositeParticle.h"
18 #include "MitAna/DataTree/interface/Track.h"
19 #include "MitAna/DataTree/interface/Muon.h"
20 #include "MitAna/DataTree/interface/Electron.h"
21 #include "MitAna/DataTree/interface/SuperCluster.h"
22 #include "MitAna/DataTree/interface/Conversion.h"
23
24 namespace mithep
25 {
26 class Photon;
27 class PFCandidate : public CompositeParticle
28 {
29 public:
30 enum EPFType {
31 eX = 0, //unidentified
32 eHadron, //charged hadron
33 eElectron, //electron
34 eMuon, //muon
35 eGamma, //photon
36 eNeutralHadron, //neutral hadron
37 eHadronHF, //hadron in HF
38 eEGammaHF //EM object in HF
39 };
40
41 enum EPFFlags {
42 eNormal = 0,
43 eEMPhiSModules,
44 eEMEta0,
45 eEMEtaModules,
46 eEMBarrelEndcap,
47 eEMPreshowerEdge,
48 eEMPreshower,
49 eEMEndCapEdge,
50 eHEta0,
51 eHBarrelEndcap,
52 eHEndcapVFCal,
53 eHVFCalEdge,
54 eToDispVtx,
55 eFromDispVtx,
56 eFromV0,
57 eFromGammaConv,
58 eToConversion,
59 ePFNoPileup
60 };
61
62 PFCandidate() : fCharge(0), fEECal(0), fEHCal(0), fEECalRaw(0), fEHCalRaw(0),
63 fEPS1(0), fEPS2(0), fPError(0),fMvaEPi(0), fMvaEMu(0),
64 fMvaPiMu(0), fMvaGamma(0), fMvaNeutralH(0), fMvaGammaNeutralH(0),
65 fEtaECal(0), fPhiECal(0), fPFType(eX) {}
66 PFCandidate(Double_t px, Double_t py, Double_t pz, Double_t e) :
67 fMom(FourVector(px,py,pz,e)),
68 fCharge(0), fEECal(0), fEHCal(0), fEECalRaw(0), fEHCalRaw(0),
69 fEPS1(0), fEPS2(0), fPError(0),fMvaEPi(0), fMvaEMu(0),
70 fMvaPiMu(0), fMvaGamma(0), fMvaNeutralH(0), fMvaGammaNeutralH(0),
71 fEtaECal(0), fPhiECal(0), fPFType(eX) {}
72
73 void AddDaughter(const PFCandidate *p) { fDaughters.Add(p); }
74 void ClearFlag(EPFFlags f) { fPFFlags.ClearBit(f); }
75 void ClearFlags() { fPFFlags.Clear(); }
76 const Conversion *Conv() const { return fConversion.Obj(); }
77 const PFCandidate *Daughter(UInt_t i) const;
78 Double_t EECal() const { return fEECal; }
79 Double_t EHCal() const { return fEHCal; }
80 Double_t EECalRaw() const { return fEECalRaw; }
81 Double_t EHCalRaw() const { return fEHCalRaw; }
82 Double_t EPS1() const { return fEPS1; }
83 Double_t EPS2() const { return fEPS2; }
84 Double_t PError() const { return fPError; }
85 Double_t MvaEPi() const { return fMvaEPi; }
86 Double_t MvaEMu() const { return fMvaEMu; }
87 Double_t MvaPiMu() const { return fMvaPiMu; }
88 Double_t MvaGamma() const { return fMvaGamma; }
89 Double_t MvaNeutralH() const { return fMvaNeutralH; }
90 Double_t MvaGammaNeutralH() const { return fMvaGammaNeutralH; }
91 Double_t EtaECal() const { return fEtaECal; }
92 Double_t PhiECal() const { return fPhiECal; }
93 Bool_t Flag(EPFFlags f) const { return fPFFlags.TestBit(f); }
94 Bool_t HasConversion() const { return fConversion.IsValid(); }
95 Bool_t HasMother() const { return fMother.IsValid(); }
96 Bool_t HasMother(const PFCandidate *m) const;
97 Bool_t HasTrackerTrk() const { return fTrackerTrack.IsValid(); }
98 Bool_t HasGsfTrk() const { return fGsfTrack.IsValid(); }
99 Bool_t HasTrk() const
100 { return (HasTrackerTrk() || HasGsfTrk()); }
101 Bool_t HasSCluster() const { return fSCluster.IsValid(); }
102 const PFCandidate *Mother() const { return fMother.Obj(); }
103 const Muon *Mu() const { return fMuon.Obj(); }
104 const Electron *Ele() const { return fElectron.Obj(); }
105 const Photon *Pho() const { return fPhoton.Obj(); }
106 EObjType ObjType() const { return kPFCandidate; }
107 EPFType PFType() const { return fPFType; }
108 const SuperCluster *SCluster() const { return fSCluster.Obj(); }
109 void SetCharge(Double_t c) { fCharge = c; ClearCharge(); }
110 void SetEECal(Double_t e) { fEECal = e; }
111 void SetEHCal(Double_t e) { fEHCal = e; }
112 void SetEECalRaw(Double_t e) { fEECalRaw = e; }
113 void SetEHCalRaw(Double_t e) { fEHCalRaw = e; }
114 void SetEPS1(Double_t e) { fEPS1 = e; }
115 void SetEPS2(Double_t e) { fEPS2 = e; }
116 void SetPError(Double_t err) { fPError = err; }
117 void SetMvaEPi(Double_t d) { fMvaEPi = d; }
118 void SetMvaEMu(Double_t d) { fMvaEMu = d; }
119 void SetMvaPiMu(Double_t d) { fMvaPiMu = d; }
120 void SetMvaGamma(Double_t d) { fMvaGamma = d; }
121 void SetMvaNeutralH(Double_t d) { fMvaNeutralH = d; }
122 void SetMvaGammaNeutralH(Double_t d) { fMvaGammaNeutralH = d; }
123 void SetEtaECal(Double_t eta) { fEtaECal = eta; }
124 void SetPhiECal(Double_t phi) { fPhiECal = phi; }
125 void SetPFType(EPFType t) { fPFType = t; }
126 void SetFlag(EPFFlags f, Bool_t b=1) { fPFFlags.SetBit(f,b); }
127 void SetMom(Double_t px, Double_t py, Double_t pz, Double_t e);
128 void SetMother(const PFCandidate *p) { fMother = p; }
129 void SetTrackerTrk(const Track *t) { fTrackerTrack = t; }
130 void SetGsfTrk(const Track *t) { fGsfTrack = t; }
131 void SetMuon(const Muon *m) { fMuon = m; }
132 void SetElectron(const Electron *e) { fElectron = e; }
133 void SetPhoton(const Photon *p) { fPhoton = p; }
134 void SetConversion(const Conversion *c)
135 { fConversion = c; }
136 void SetSCluster(const SuperCluster *s) { fSCluster = s; }
137 void SetVertex(Double_t x, Double_t y, Double_t z);
138 const ThreeVector SourceVertex() const { return fSourceVertex.V(); }
139 const Track *TrackerTrk() const { return fTrackerTrack.Obj(); }
140 const Track *GsfTrk() const { return fGsfTrack.Obj(); }
141 const Track *BestTrk() const;
142 const Track *Trk() const { return BestTrk(); }
143
144 // Some structural tools
145 void Mark(UInt_t i=1) const;
146
147 protected:
148 Double_t GetCharge() const;
149 void GetMom() const;
150
151 Vect4M fMom; //four momentum vector
152 Vect3 fSourceVertex; //pflow source vertex
153 Double32_t fCharge; //[-1,1,2]charge
154 Double32_t fEECal; //[0,0,14]corrected Ecal energy
155 Double32_t fEHCal; //[0,0,14]corrected Hcal energy
156 Double32_t fEECalRaw; //[0,0,14]uncorrected Ecal energy
157 Double32_t fEHCalRaw; //[0,0,14]uncorrected Hcal energy
158 Double32_t fEPS1; //[0,0,14]corrected PS1 energy
159 Double32_t fEPS2; //[0,0,14]corrected PS2 energy
160 Double32_t fPError; //[0,0,14]uncertainty on P (three-mom magnitude)
161 Double32_t fMvaEPi; //[0,0,14]electron-pion discriminant
162 Double32_t fMvaEMu; //[0,0,14]electron-muon discriminant
163 Double32_t fMvaPiMu; //[0,0,14]pion-muon discriminant
164 Double32_t fMvaGamma; //[0,0,14]photon id discriminant
165 Double32_t fMvaNeutralH; //[0,0,14]neutral hadron id discriminant
166 Double32_t fMvaGammaNeutralH; //[0,0,14]photon-neutralhadron discriminant
167 Double32_t fEtaECal; //[0,0,12]eta at ecal front face
168 Double32_t fPhiECal; //[0,0,12]phi at ecal front face
169 EPFType fPFType; //particle flow type
170 BitMask32 fPFFlags; //various PF flags
171 Ref<PFCandidate> fMother; //reference to mother
172 Ref<Track> fTrackerTrack; //reference to (standard) track
173 Ref<Track> fGsfTrack; //reference to gsf track (for electrons only)
174 Ref<Muon> fMuon; //reference to corresponding reco muon
175 Ref<Conversion> fConversion; //reference to corresponding reco conversion
176 Ref<SuperCluster> fSCluster; //reference to egamma supercluster
177 Ref<Electron> fElectron; //reference to electron
178 Ref<Photon> fPhoton; //reference to egamma photon
179
180 ClassDef(PFCandidate,2) // Particle-flow candidate class
181 };
182 }
183
184 //--------------------------------------------------------------------------------------------------
185 inline void mithep::PFCandidate::Mark(UInt_t ib) const
186 {
187 // mark myself
188 mithep::DataObject::Mark(ib);
189 // mark my dependencies if they are there
190 if (fMother.IsValid())
191 fMother.Obj()->Mark(ib);
192 if (fTrackerTrack.IsValid())
193 fTrackerTrack.Obj()->Mark(ib);
194 if (fGsfTrack.IsValid())
195 fGsfTrack.Obj()->Mark(ib);
196 if (fMuon.IsValid())
197 fMuon.Obj()->Mark(ib);
198 if (fConversion.IsValid())
199 fConversion.Obj()->Mark(ib);
200 if (fSCluster.IsValid())
201 fSCluster.Obj()->Mark(ib);
202 }
203
204 //--------------------------------------------------------------------------------------------------
205 inline const mithep::Track *mithep::PFCandidate::BestTrk() const
206 {
207 // Return gsf track if present, or else tracker track if present
208
209 if (HasGsfTrk())
210 return GsfTrk();
211
212 if (HasTrackerTrk())
213 return TrackerTrk();
214
215 return 0;
216
217 }
218
219 //--------------------------------------------------------------------------------------------------
220 inline const mithep::PFCandidate *mithep::PFCandidate::Daughter(UInt_t i) const
221 {
222 // Return daughter corresponding to given index.
223
224 return static_cast<const PFCandidate*>(fDaughters.At(i));
225 }
226
227 //--------------------------------------------------------------------------------------------------
228 inline Double_t mithep::PFCandidate::GetCharge() const
229 {
230 // Get stored charge
231
232 return fCharge;
233 }
234
235 //--------------------------------------------------------------------------------------------------
236 inline void mithep::PFCandidate::GetMom() const
237 {
238 // Get momentum values from stored values.
239
240 fCachedMom.SetCoordinates(fMom.Pt(),fMom.Eta(),fMom.Phi(),fMom.M());
241 }
242
243 //--------------------------------------------------------------------------------------------------
244 inline Bool_t mithep::PFCandidate::HasMother(const PFCandidate *m) const
245 {
246 // Return true if the given particle is among mothers. (Note the comparison
247 // is made on pointers and therefore will fail if you work on copies.)
248
249 if (!m)
250 return kFALSE;
251
252 const mithep::PFCandidate *mother = Mother();
253 while (mother && mother!=m)
254 mother = mother->Mother();
255
256 if (mother)
257 return kTRUE;
258 return kFALSE;
259 }
260
261 //--------------------------------------------------------------------------------------------------
262 inline void mithep::PFCandidate::SetMom(Double_t px, Double_t py, Double_t pz, Double_t e)
263 {
264 // Set four vector.
265
266 fMom.SetXYZT(px, py, pz, e);
267 ClearMom();
268 }
269
270 //--------------------------------------------------------------------------------------------------
271 inline void mithep::PFCandidate::SetVertex(Double_t x, Double_t y, Double_t z)
272 {
273 // Set decay vertex.
274
275 fSourceVertex.SetXYZ(x,y,z);
276 }
277 #endif