ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/PFCandidate.h
Revision: 1.7
Committed: Tue Mar 30 05:32:25 2010 UTC (15 years, 1 month ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_025c_branch1, Mit_025c_branch0, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c
Branch point for: Mit_025c_branch
Changes since 1.6: +3 -3 lines
Log Message:
Rerevert PFCandidate change for 356

File Contents

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