1 |
grimes |
1.1 |
#ifndef SimDataFormats_ParticleBase_h
|
2 |
|
|
#define SimDataFormats_ParticleBase_h
|
3 |
|
|
/** \class reco::Particle
|
4 |
|
|
*
|
5 |
|
|
* Base class describing a generic reconstructed particle
|
6 |
|
|
* its main subclass is Candidate
|
7 |
|
|
*
|
8 |
|
|
* \author Luca Lista, INFN
|
9 |
|
|
*
|
10 |
|
|
* \version $Id: ParticleBase.h,v 1.4 2011/10/27 16:31:44 wmtan Exp $
|
11 |
|
|
*
|
12 |
|
|
*/
|
13 |
|
|
#include "DataFormats/Math/interface/Point3D.h"
|
14 |
|
|
#include "DataFormats/Math/interface/Vector3D.h"
|
15 |
|
|
#include "DataFormats/Math/interface/LorentzVector.h"
|
16 |
|
|
#include "Rtypes.h"
|
17 |
|
|
|
18 |
|
|
class ParticleBase
|
19 |
|
|
{
|
20 |
|
|
public:
|
21 |
|
|
/// electric charge type
|
22 |
|
|
typedef int Charge;
|
23 |
|
|
/// Lorentz vector
|
24 |
|
|
typedef math::XYZTLorentzVectorD LorentzVector;
|
25 |
|
|
/// Lorentz vector
|
26 |
|
|
typedef math::PtEtaPhiMLorentzVector PolarLorentzVector;
|
27 |
|
|
/// point in the space
|
28 |
|
|
typedef math::XYZPointD Point;
|
29 |
|
|
/// point in the space
|
30 |
|
|
typedef math::XYZVectorD Vector;
|
31 |
|
|
/// default constructor
|
32 |
|
|
ParticleBase() : cachePolarFixed_( false ), cacheCartesianFixed_( false ) { }
|
33 |
|
|
/// constructor from values
|
34 |
|
|
ParticleBase( Charge q, const LorentzVector & p4, const Point & vertex = Point( 0, 0, 0 ),
|
35 |
|
|
int pdgId = 0, int status = 0, bool integerCharge = true ) :
|
36 |
|
|
qx3_( q ), pt_( p4.pt() ), eta_( p4.eta() ), phi_( p4.phi() ), mass_( p4.mass() ),
|
37 |
|
|
vertex_( vertex ), pdgId_( pdgId ), status_( status ),
|
38 |
|
|
cachePolarFixed_( false ), cacheCartesianFixed_( false )
|
39 |
|
|
{
|
40 |
|
|
if ( integerCharge ) qx3_ *= 3;
|
41 |
|
|
}
|
42 |
|
|
/// constructor from values
|
43 |
|
|
ParticleBase( Charge q, const PolarLorentzVector & p4, const Point & vertex = Point( 0, 0, 0 ),
|
44 |
|
|
int pdgId = 0, int status = 0, bool integerCharge = true ) :
|
45 |
|
|
qx3_( q ), pt_( p4.pt() ), eta_( p4.eta() ), phi_( p4.phi() ), mass_( p4.mass() ),
|
46 |
|
|
vertex_( vertex ), pdgId_( pdgId ), status_( status ),
|
47 |
|
|
cachePolarFixed_( false ), cacheCartesianFixed_( false )
|
48 |
|
|
{
|
49 |
|
|
if ( integerCharge ) qx3_ *= 3;
|
50 |
|
|
}
|
51 |
|
|
/// destructor
|
52 |
|
|
virtual ~ParticleBase() { }
|
53 |
|
|
/// electric charge
|
54 |
|
|
int charge() const
|
55 |
|
|
{
|
56 |
|
|
return qx3_ / 3;
|
57 |
|
|
}
|
58 |
|
|
/// set electric charge
|
59 |
|
|
void setCharge( Charge q )
|
60 |
|
|
{
|
61 |
|
|
qx3_ = q * 3;
|
62 |
|
|
}
|
63 |
|
|
/// electric charge
|
64 |
|
|
int threeCharge() const
|
65 |
|
|
{
|
66 |
|
|
return qx3_;
|
67 |
|
|
}
|
68 |
|
|
/// set electric charge
|
69 |
|
|
void setThreeCharge( Charge qx3 )
|
70 |
|
|
{
|
71 |
|
|
qx3_ = qx3;
|
72 |
|
|
}
|
73 |
|
|
/// four-momentum Lorentz vector
|
74 |
|
|
const LorentzVector & p4() const
|
75 |
|
|
{
|
76 |
|
|
cacheCartesian();
|
77 |
|
|
return p4Cartesian_;
|
78 |
|
|
}
|
79 |
|
|
/// four-momentum Lorentz vector
|
80 |
|
|
const PolarLorentzVector & polarP4() const
|
81 |
|
|
{
|
82 |
|
|
cachePolar();
|
83 |
|
|
return p4Polar_;
|
84 |
|
|
}
|
85 |
|
|
/// spatial momentum vector
|
86 |
|
|
Vector momentum() const
|
87 |
|
|
{
|
88 |
|
|
cacheCartesian();
|
89 |
|
|
return p4Cartesian_.Vect();
|
90 |
|
|
}
|
91 |
|
|
/// boost vector to boost a Lorentz vector
|
92 |
|
|
/// to the particle center of mass system
|
93 |
|
|
Vector boostToCM() const
|
94 |
|
|
{
|
95 |
|
|
cacheCartesian();
|
96 |
|
|
return p4Cartesian_.BoostToCM();
|
97 |
|
|
}
|
98 |
|
|
/// magnitude of momentum vector
|
99 |
|
|
double p() const
|
100 |
|
|
{
|
101 |
|
|
cacheCartesian();
|
102 |
|
|
return p4Cartesian_.P();
|
103 |
|
|
}
|
104 |
|
|
/// energy
|
105 |
|
|
double energy() const
|
106 |
|
|
{
|
107 |
|
|
cacheCartesian();
|
108 |
|
|
return p4Cartesian_.E();
|
109 |
|
|
}
|
110 |
|
|
/// transverse energy
|
111 |
|
|
double et() const
|
112 |
|
|
{
|
113 |
|
|
cachePolar();
|
114 |
|
|
return p4Polar_.Et();
|
115 |
|
|
}
|
116 |
|
|
/// mass
|
117 |
|
|
double mass() const
|
118 |
|
|
{
|
119 |
|
|
return mass_;
|
120 |
|
|
}
|
121 |
|
|
/// mass squared
|
122 |
|
|
double massSqr() const
|
123 |
|
|
{
|
124 |
|
|
return mass_ * mass_;
|
125 |
|
|
}
|
126 |
|
|
/// transverse mass
|
127 |
|
|
double mt() const
|
128 |
|
|
{
|
129 |
|
|
cachePolar();
|
130 |
|
|
return p4Polar_.Mt();
|
131 |
|
|
}
|
132 |
|
|
/// transverse mass squared
|
133 |
|
|
double mtSqr() const
|
134 |
|
|
{
|
135 |
|
|
cachePolar();
|
136 |
|
|
return p4Polar_.Mt2();
|
137 |
|
|
}
|
138 |
|
|
/// x coordinate of momentum vector
|
139 |
|
|
double px() const
|
140 |
|
|
{
|
141 |
|
|
cacheCartesian();
|
142 |
|
|
return p4Cartesian_.Px();
|
143 |
|
|
}
|
144 |
|
|
/// y coordinate of momentum vector
|
145 |
|
|
double py() const
|
146 |
|
|
{
|
147 |
|
|
cacheCartesian();
|
148 |
|
|
return p4Cartesian_.Py();
|
149 |
|
|
}
|
150 |
|
|
/// z coordinate of momentum vector
|
151 |
|
|
double pz() const
|
152 |
|
|
{
|
153 |
|
|
cacheCartesian();
|
154 |
|
|
return p4Cartesian_.Pz();
|
155 |
|
|
}
|
156 |
|
|
/// transverse momentum
|
157 |
|
|
double pt() const
|
158 |
|
|
{
|
159 |
|
|
return pt_;
|
160 |
|
|
}
|
161 |
|
|
/// momentum azimuthal angle
|
162 |
|
|
double phi() const
|
163 |
|
|
{
|
164 |
|
|
return phi_;
|
165 |
|
|
}
|
166 |
|
|
/// momentum polar angle
|
167 |
|
|
double theta() const
|
168 |
|
|
{
|
169 |
|
|
cacheCartesian();
|
170 |
|
|
return p4Cartesian_.Theta();
|
171 |
|
|
}
|
172 |
|
|
/// momentum pseudorapidity
|
173 |
|
|
double eta() const
|
174 |
|
|
{
|
175 |
|
|
return eta_;
|
176 |
|
|
}
|
177 |
|
|
/// repidity
|
178 |
|
|
double rapidity() const
|
179 |
|
|
{
|
180 |
|
|
cachePolar();
|
181 |
|
|
return p4Polar_.Rapidity();
|
182 |
|
|
}
|
183 |
|
|
/// repidity
|
184 |
|
|
double y() const
|
185 |
|
|
{
|
186 |
|
|
return rapidity();
|
187 |
|
|
}
|
188 |
|
|
/// set 4-momentum
|
189 |
|
|
void setP4( const LorentzVector & p4 )
|
190 |
|
|
{
|
191 |
|
|
p4Cartesian_ = p4;
|
192 |
|
|
p4Polar_ = p4;
|
193 |
|
|
pt_ = p4Polar_.pt();
|
194 |
|
|
eta_ = p4Polar_.eta();
|
195 |
|
|
phi_ = p4Polar_.phi();
|
196 |
|
|
mass_ = p4Polar_.mass();
|
197 |
|
|
cachePolarFixed_ = true;
|
198 |
|
|
cacheCartesianFixed_ = true;
|
199 |
|
|
}
|
200 |
|
|
/// set 4-momentum
|
201 |
|
|
void setP4( const PolarLorentzVector & p4 )
|
202 |
|
|
{
|
203 |
|
|
p4Polar_ = p4;
|
204 |
|
|
pt_ = p4Polar_.pt();
|
205 |
|
|
eta_ = p4Polar_.eta();
|
206 |
|
|
phi_ = p4Polar_.phi();
|
207 |
|
|
mass_ = p4Polar_.mass();
|
208 |
|
|
cachePolarFixed_ = true;
|
209 |
|
|
cacheCartesianFixed_ = false;
|
210 |
|
|
}
|
211 |
|
|
/// set particle mass
|
212 |
|
|
void setMass( double m )
|
213 |
|
|
{
|
214 |
|
|
mass_ = m;
|
215 |
|
|
clearCache();
|
216 |
|
|
}
|
217 |
|
|
void setPz( double pz )
|
218 |
|
|
{
|
219 |
|
|
cacheCartesian();
|
220 |
|
|
p4Cartesian_.SetPz(pz);
|
221 |
|
|
p4Polar_ = p4Cartesian_;
|
222 |
|
|
pt_ = p4Polar_.pt();
|
223 |
|
|
eta_ = p4Polar_.eta();
|
224 |
|
|
phi_ = p4Polar_.phi();
|
225 |
|
|
mass_ = p4Polar_.mass();
|
226 |
|
|
}
|
227 |
|
|
/// vertex position
|
228 |
|
|
const Point & vertex() const
|
229 |
|
|
{
|
230 |
|
|
return vertex_;
|
231 |
|
|
}
|
232 |
|
|
/// x coordinate of vertex position
|
233 |
|
|
double vx() const
|
234 |
|
|
{
|
235 |
|
|
return vertex_.X();
|
236 |
|
|
}
|
237 |
|
|
/// y coordinate of vertex position
|
238 |
|
|
double vy() const
|
239 |
|
|
{
|
240 |
|
|
return vertex_.Y();
|
241 |
|
|
}
|
242 |
|
|
/// z coordinate of vertex position
|
243 |
|
|
double vz() const
|
244 |
|
|
{
|
245 |
|
|
return vertex_.Z();
|
246 |
|
|
}
|
247 |
|
|
/// set vertex
|
248 |
|
|
void setVertex( const Point & vertex )
|
249 |
|
|
{
|
250 |
|
|
vertex_ = vertex;
|
251 |
|
|
}
|
252 |
|
|
/// PDG identifier
|
253 |
|
|
int pdgId() const
|
254 |
|
|
{
|
255 |
|
|
return pdgId_;
|
256 |
|
|
}
|
257 |
|
|
// set PDG identifier
|
258 |
|
|
void setPdgId( int pdgId )
|
259 |
|
|
{
|
260 |
|
|
pdgId_ = pdgId;
|
261 |
|
|
}
|
262 |
|
|
/// status word
|
263 |
|
|
int status() const
|
264 |
|
|
{
|
265 |
|
|
return status_;
|
266 |
|
|
}
|
267 |
|
|
/// set status word
|
268 |
|
|
void setStatus( int status )
|
269 |
|
|
{
|
270 |
|
|
status_ = status;
|
271 |
|
|
}
|
272 |
|
|
/// long lived flag
|
273 |
|
|
static const unsigned int longLivedTag;
|
274 |
|
|
/// set long lived flag
|
275 |
|
|
void setLongLived()
|
276 |
|
|
{
|
277 |
|
|
status_ |= longLivedTag;
|
278 |
|
|
}
|
279 |
|
|
/// is long lived?
|
280 |
|
|
bool longLived() const
|
281 |
|
|
{
|
282 |
|
|
return status_ & longLivedTag;
|
283 |
|
|
}
|
284 |
|
|
|
285 |
|
|
protected:
|
286 |
|
|
/// electric charge
|
287 |
|
|
Charge qx3_;
|
288 |
|
|
/// four-momentum Lorentz vector
|
289 |
|
|
float pt_, eta_, phi_, mass_;
|
290 |
|
|
/// vertex position
|
291 |
|
|
Point vertex_;
|
292 |
|
|
/// PDG identifier
|
293 |
|
|
int pdgId_;
|
294 |
|
|
/// status word
|
295 |
|
|
int status_;
|
296 |
|
|
/// internal cache for p4
|
297 |
|
|
mutable PolarLorentzVector p4Polar_;
|
298 |
|
|
/// internal cache for p4
|
299 |
|
|
mutable LorentzVector p4Cartesian_;
|
300 |
|
|
/// has cache been set?
|
301 |
|
|
mutable bool cachePolarFixed_, cacheCartesianFixed_;
|
302 |
|
|
/// set internal cache
|
303 |
|
|
inline void cachePolar() const
|
304 |
|
|
{
|
305 |
|
|
if ( cachePolarFixed_ ) return;
|
306 |
|
|
p4Polar_ = PolarLorentzVector( pt_, eta_, phi_, mass_ );
|
307 |
|
|
cachePolarFixed_ = true;
|
308 |
|
|
}
|
309 |
|
|
/// set internal cache
|
310 |
|
|
inline void cacheCartesian() const
|
311 |
|
|
{
|
312 |
|
|
if ( cacheCartesianFixed_ ) return;
|
313 |
|
|
cachePolar();
|
314 |
|
|
p4Cartesian_ = p4Polar_;
|
315 |
|
|
cacheCartesianFixed_ = true;
|
316 |
|
|
}
|
317 |
|
|
/// clear internal cache
|
318 |
|
|
inline void clearCache() const
|
319 |
|
|
{
|
320 |
|
|
cachePolarFixed_ = false;
|
321 |
|
|
cacheCartesianFixed_ = false;
|
322 |
|
|
}
|
323 |
|
|
};
|
324 |
|
|
|
325 |
|
|
#endif
|