ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/PFCandidate.h
Revision: 1.3
Committed: Wed Mar 25 05:16:13 2009 UTC (16 years, 1 month ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_009c, Mit_009b, Mit_009a, Mit_009, Mit_008
Changes since 1.2: +3 -3 lines
Log Message:
Slightly increase precision.

File Contents

# User Rev Content
1 bendavid 1.1 //--------------------------------------------------------------------------------------------------
2 loizides 1.3 // $Id: PFCandidate.h,v 1.2 2009/03/18 15:44:32 loizides Exp $
3 bendavid 1.1 //
4     // PFCandidate
5     //
6 loizides 1.2 // Particle-flow candidate class, for now mostly mirroring the PFCandidate from CMSSW.
7 bendavid 1.1 //
8     // Authors: J.Bendavid
9     //--------------------------------------------------------------------------------------------------
10    
11     #ifndef MITANA_DATATREE_PFCandidate_H
12     #define MITANA_DATATREE_PFCandidate_H
13    
14 loizides 1.2 #include "MitCommon/DataFormats/interface/Vect3.h"
15     #include "MitCommon/DataFormats/interface/Vect4M.h"
16 bendavid 1.1 #include "MitAna/DataTree/interface/Types.h"
17     #include "MitAna/DataCont/interface/Ref.h"
18     #include "MitAna/DataTree/interface/CompositeParticle.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 loizides 1.2 eX = 0, //unidentified
30     eHadron, //charged hadron
31     eElectron, //electron
32     eMuon, //muon
33     eGamma, //photon
34 bendavid 1.1 eNeutralHadron, //neutral hadron
35 loizides 1.2 eHadronHF, //hadron in HF
36     eEGammaHF //EM object in HF
37 bendavid 1.1 };
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     PFCandidate() : fCharge(0), fEECal(0), fEHCal(0), fEECalRaw(0), fEHCalRaw(0),
60     fEPS1(0), fEPS2(0), fPError(0),fMvaEPi(0), fMvaEMu(0),
61     fMvaPiMu(0), fMvaGamma(0), fMvaNeutralH(0), fMvaGammaNeutralH(0),
62     fEtaECal(0), fPhiECal(0), fPFType(eX) {}
63     PFCandidate(Double_t px, Double_t py, Double_t pz, Double_t e) :
64     fMom(FourVector(px,py,pz,e)),
65     fCharge(0), fEECal(0), fEHCal(0), fEECalRaw(0), fEHCalRaw(0),
66     fEPS1(0), fEPS2(0), fPError(0),fMvaEPi(0), fMvaEMu(0),
67     fMvaPiMu(0), fMvaGamma(0), fMvaNeutralH(0), fMvaGammaNeutralH(0),
68     fEtaECal(0), fPhiECal(0), fPFType(eX) {}
69    
70 loizides 1.2 void AddDaughter(const PFCandidate *p) { fDaughters.Add(p); }
71     void ClearFlag(EPFFlags f) { fPFFlags.ClearBit(f); }
72     void ClearFlags() { fPFFlags.Clear(); }
73     const Conversion *Conv() const { return fConversion.Obj(); }
74 bendavid 1.1 const PFCandidate *Daughter(UInt_t i) const;
75 loizides 1.2 Double_t EECal() const { return fEECal; }
76     Double_t EHCal() const { return fEHCal; }
77     Double_t EECalRaw() const { return fEECalRaw; }
78     Double_t EHCalRaw() const { return fEHCalRaw; }
79     Double_t EPS1() const { return fEPS1; }
80     Double_t EPS2() const { return fEPS2; }
81     Double_t PError() const { return fPError; }
82     Double_t MvaEPi() const { return fMvaEPi; }
83     Double_t MvaEMu() const { return fMvaEMu; }
84     Double_t MvaPiMu() const { return fMvaPiMu; }
85     Double_t MvaGamma() const { return fMvaGamma; }
86     Double_t MvaNeutralH() const { return fMvaNeutralH; }
87     Double_t MvaGammaNeutralH() const { return fMvaGammaNeutralH; }
88     Double_t EtaECal() const { return fEtaECal; }
89     Double_t PhiECal() const { return fPhiECal; }
90     Bool_t Flag(EPFFlags f) const { return fPFFlags.TestBit(f); }
91     Bool_t HasConversion() const { return fConversion.IsValid(); }
92     Bool_t HasMother() const { return fMother.IsValid(); }
93     Bool_t HasMother(const PFCandidate *m) const;
94     Bool_t HasTrackerTrk() const { return fTrackerTrack.IsValid(); }
95     Bool_t HasGsfTrk() const { return fGsfTrack.IsValid(); }
96     Bool_t HasTrk() const
97     { 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(Double_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 bendavid 1.1 void SetMom(Double_t px, Double_t py, Double_t pz, Double_t e);
121 loizides 1.2 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)
126     { fConversion = c; }
127 bendavid 1.1 void SetVertex(Double_t x, Double_t y, Double_t z);
128 loizides 1.2 const ThreeVector SourceVertex() const { return fSourceVertex.V(); }
129     const Track *TrackerTrk() const { return fTrackerTrack.Obj(); }
130     const Track *GsfTrk() const { return fGsfTrack.Obj(); }
131 bendavid 1.1 const Track *BestTrk() const;
132 loizides 1.2 const Track *Trk() const { return BestTrk(); }
133 bendavid 1.1
134     protected:
135     Double_t GetCharge() const;
136     void GetMom() const;
137    
138 loizides 1.2 Vect4M fMom; //four momentum vector
139     Vect3 fSourceVertex; //pflow source vertex
140     Double32_t fCharge; //[-1,1,2]charge
141     Double32_t fEECal; //[0,0,14]corrected Ecal energy
142     Double32_t fEHCal; //[0,0,14]corrected Hcal energy
143     Double32_t fEECalRaw; //[0,0,14]uncorrected Ecal energy
144     Double32_t fEHCalRaw; //[0,0,14]uncorrected Hcal energy
145     Double32_t fEPS1; //[0,0,14]corrected PS1 energy
146     Double32_t fEPS2; //[0,0,14]corrected PS2 energy
147     Double32_t fPError; //[0,0,14]uncertainty on P (three-mom magnitude)
148     Double32_t fMvaEPi; //[0,0,14]electron-pion discriminant
149     Double32_t fMvaEMu; //[0,0,14]electron-muon discriminant
150     Double32_t fMvaPiMu; //[0,0,14]pion-muon discriminant
151     Double32_t fMvaGamma; //[0,0,14]photon id discriminant
152     Double32_t fMvaNeutralH; //[0,0,14]neutral hadron id discriminant
153     Double32_t fMvaGammaNeutralH; //[0,0,14]photon-neutralhadron discriminant
154 loizides 1.3 Double32_t fEtaECal; //[0,0,12]eta at ecal front face
155     Double32_t fPhiECal; //[0,0,12]phi at ecal front face
156 loizides 1.2 EPFType fPFType; //particle flow type
157     BitMask32 fPFFlags; //various PF flags
158     Ref<PFCandidate> fMother; //reference to mother
159     Ref<Track> fTrackerTrack; //reference to (standard) track
160     Ref<Track> fGsfTrack; //reference to gsf track (for electrons only)
161     Ref<Muon> fMuon; //reference to corresponding reco muon
162     Ref<Conversion> fConversion; //reference to corresponding reco conversion
163 bendavid 1.1
164 loizides 1.2 ClassDef(PFCandidate,1) // Particle-flow candidate class
165 bendavid 1.1 };
166     }
167    
168     //--------------------------------------------------------------------------------------------------
169     inline const mithep::Track *mithep::PFCandidate::BestTrk() const
170     {
171     // Return gsf track if present, or else tracker track if present
172    
173     if (HasGsfTrk())
174     return GsfTrk();
175    
176     if (HasTrackerTrk())
177     return TrackerTrk();
178    
179     return 0;
180    
181     }
182    
183     //--------------------------------------------------------------------------------------------------
184     inline const mithep::PFCandidate *mithep::PFCandidate::Daughter(UInt_t i) const
185     {
186     // Return daughter corresponding to given index.
187    
188     return static_cast<const PFCandidate*>(fDaughters.At(i));
189     }
190    
191     //--------------------------------------------------------------------------------------------------
192     inline Double_t mithep::PFCandidate::GetCharge() const
193     {
194     // Get stored charge
195    
196     return fCharge;
197     }
198    
199     //--------------------------------------------------------------------------------------------------
200     inline void mithep::PFCandidate::GetMom() const
201     {
202     // Get momentum values from stored values.
203    
204 loizides 1.2 fCachedMom.SetCoordinates(fMom.Pt(),fMom.Eta(),fMom.Phi(),fMom.M());
205 bendavid 1.1 }
206    
207     //--------------------------------------------------------------------------------------------------
208     inline Bool_t mithep::PFCandidate::HasMother(const PFCandidate *m) const
209     {
210     // Return true if the given particle is among mothers. (Note the comparison
211     // is made on pointers and therefore will fail if you work on copies.)
212    
213     if (!m)
214     return kFALSE;
215    
216     const mithep::PFCandidate *mother = Mother();
217     while (mother && mother!=m)
218     mother = mother->Mother();
219    
220     if (mother)
221     return kTRUE;
222     return kFALSE;
223     }
224    
225     //--------------------------------------------------------------------------------------------------
226     inline void mithep::PFCandidate::SetMom(Double_t px, Double_t py, Double_t pz, Double_t e)
227     {
228     // Set four vector.
229    
230     fMom.SetXYZT(px, py, pz, e);
231     ClearMom();
232     }
233    
234     //--------------------------------------------------------------------------------------------------
235     inline void mithep::PFCandidate::SetVertex(Double_t x, Double_t y, Double_t z)
236     {
237     // Set decay vertex.
238    
239     fSourceVertex.SetXYZ(x,y,z);
240     }
241     #endif