1 |
//--------------------------------------------------------------------------------------------------
|
2 |
// $Id: PFCandidate.h,v 1.9 2012/03/28 12:15:34 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/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 |
ePFNoPileup
|
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 |
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 |
const PFCandidate *Daughter(UInt_t i) const;
|
75 |
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 |
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)
|
126 |
{ fConversion = c; }
|
127 |
void SetVertex(Double_t x, Double_t y, Double_t z);
|
128 |
const ThreeVector SourceVertex() const { return fSourceVertex.V(); }
|
129 |
const Track *TrackerTrk() const { return fTrackerTrack.Obj(); }
|
130 |
const Track *GsfTrk() const { return fGsfTrack.Obj(); }
|
131 |
const Track *BestTrk() const;
|
132 |
const Track *Trk() const { return BestTrk(); }
|
133 |
|
134 |
// Some structural tools
|
135 |
void Mark(UInt_t i=1) const;
|
136 |
|
137 |
protected:
|
138 |
Double_t GetCharge() const;
|
139 |
void GetMom() const;
|
140 |
|
141 |
Vect4M fMom; //four momentum vector
|
142 |
Vect3 fSourceVertex; //pflow source vertex
|
143 |
Double32_t fCharge; //[-1,1,2]charge
|
144 |
Double32_t fEECal; //[0,0,14]corrected Ecal energy
|
145 |
Double32_t fEHCal; //[0,0,14]corrected Hcal energy
|
146 |
Double32_t fEECalRaw; //[0,0,14]uncorrected Ecal energy
|
147 |
Double32_t fEHCalRaw; //[0,0,14]uncorrected Hcal energy
|
148 |
Double32_t fEPS1; //[0,0,14]corrected PS1 energy
|
149 |
Double32_t fEPS2; //[0,0,14]corrected PS2 energy
|
150 |
Double32_t fPError; //[0,0,14]uncertainty on P (three-mom magnitude)
|
151 |
Double32_t fMvaEPi; //[0,0,14]electron-pion discriminant
|
152 |
Double32_t fMvaEMu; //[0,0,14]electron-muon discriminant
|
153 |
Double32_t fMvaPiMu; //[0,0,14]pion-muon discriminant
|
154 |
Double32_t fMvaGamma; //[0,0,14]photon id discriminant
|
155 |
Double32_t fMvaNeutralH; //[0,0,14]neutral hadron id discriminant
|
156 |
Double32_t fMvaGammaNeutralH; //[0,0,14]photon-neutralhadron discriminant
|
157 |
Double32_t fEtaECal; //[0,0,12]eta at ecal front face
|
158 |
Double32_t fPhiECal; //[0,0,12]phi at ecal front face
|
159 |
EPFType fPFType; //particle flow type
|
160 |
BitMask32 fPFFlags; //various PF flags
|
161 |
Ref<PFCandidate> fMother; //reference to mother
|
162 |
Ref<Track> fTrackerTrack; //reference to (standard) track
|
163 |
Ref<Track> fGsfTrack; //reference to gsf track (for electrons only)
|
164 |
Ref<Muon> fMuon; //reference to corresponding reco muon
|
165 |
Ref<Conversion> fConversion; //reference to corresponding reco conversion
|
166 |
|
167 |
ClassDef(PFCandidate,1) // Particle-flow candidate class
|
168 |
};
|
169 |
}
|
170 |
|
171 |
//--------------------------------------------------------------------------------------------------
|
172 |
inline void mithep::PFCandidate::Mark(UInt_t ib) const
|
173 |
{
|
174 |
// mark myself
|
175 |
mithep::DataObject::Mark(ib);
|
176 |
// mark my dependencies if they are there
|
177 |
if (fMother.IsValid())
|
178 |
fMother.Obj()->Mark(ib);
|
179 |
if (fTrackerTrack.IsValid())
|
180 |
fTrackerTrack.Obj()->Mark(ib);
|
181 |
if (fGsfTrack.IsValid())
|
182 |
fGsfTrack.Obj()->Mark(ib);
|
183 |
if (fMuon.IsValid())
|
184 |
fMuon.Obj()->Mark(ib);
|
185 |
if (fConversion.IsValid())
|
186 |
fConversion.Obj()->Mark(ib);
|
187 |
}
|
188 |
|
189 |
//--------------------------------------------------------------------------------------------------
|
190 |
inline const mithep::Track *mithep::PFCandidate::BestTrk() const
|
191 |
{
|
192 |
// Return gsf track if present, or else tracker track if present
|
193 |
|
194 |
if (HasGsfTrk())
|
195 |
return GsfTrk();
|
196 |
|
197 |
if (HasTrackerTrk())
|
198 |
return TrackerTrk();
|
199 |
|
200 |
return 0;
|
201 |
|
202 |
}
|
203 |
|
204 |
//--------------------------------------------------------------------------------------------------
|
205 |
inline const mithep::PFCandidate *mithep::PFCandidate::Daughter(UInt_t i) const
|
206 |
{
|
207 |
// Return daughter corresponding to given index.
|
208 |
|
209 |
return static_cast<const PFCandidate*>(fDaughters.At(i));
|
210 |
}
|
211 |
|
212 |
//--------------------------------------------------------------------------------------------------
|
213 |
inline Double_t mithep::PFCandidate::GetCharge() const
|
214 |
{
|
215 |
// Get stored charge
|
216 |
|
217 |
return fCharge;
|
218 |
}
|
219 |
|
220 |
//--------------------------------------------------------------------------------------------------
|
221 |
inline void mithep::PFCandidate::GetMom() const
|
222 |
{
|
223 |
// Get momentum values from stored values.
|
224 |
|
225 |
fCachedMom.SetCoordinates(fMom.Pt(),fMom.Eta(),fMom.Phi(),fMom.M());
|
226 |
}
|
227 |
|
228 |
//--------------------------------------------------------------------------------------------------
|
229 |
inline Bool_t mithep::PFCandidate::HasMother(const PFCandidate *m) const
|
230 |
{
|
231 |
// Return true if the given particle is among mothers. (Note the comparison
|
232 |
// is made on pointers and therefore will fail if you work on copies.)
|
233 |
|
234 |
if (!m)
|
235 |
return kFALSE;
|
236 |
|
237 |
const mithep::PFCandidate *mother = Mother();
|
238 |
while (mother && mother!=m)
|
239 |
mother = mother->Mother();
|
240 |
|
241 |
if (mother)
|
242 |
return kTRUE;
|
243 |
return kFALSE;
|
244 |
}
|
245 |
|
246 |
//--------------------------------------------------------------------------------------------------
|
247 |
inline void mithep::PFCandidate::SetMom(Double_t px, Double_t py, Double_t pz, Double_t e)
|
248 |
{
|
249 |
// Set four vector.
|
250 |
|
251 |
fMom.SetXYZT(px, py, pz, e);
|
252 |
ClearMom();
|
253 |
}
|
254 |
|
255 |
//--------------------------------------------------------------------------------------------------
|
256 |
inline void mithep::PFCandidate::SetVertex(Double_t x, Double_t y, Double_t z)
|
257 |
{
|
258 |
// Set decay vertex.
|
259 |
|
260 |
fSourceVertex.SetXYZ(x,y,z);
|
261 |
}
|
262 |
#endif
|