ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/PFCandidate.h
Revision: 1.1
Committed: Wed Mar 11 18:10:34 2009 UTC (16 years, 1 month ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_008pre2
Log Message:
Add PFCandidate class

File Contents

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