CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ParticleBase.h
Go to the documentation of this file.
1 #ifndef SimDataFormats_ParticleBase_h
2 #define SimDataFormats_ParticleBase_h
3 
16 #include "Rtypes.h"
17 
19 {
20 public:
22  typedef int Charge;
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() ),
39  {
40  if ( integerCharge ) qx3_ *= 3;
41  }
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() ),
48  {
49  if ( integerCharge ) qx3_ *= 3;
50  }
52  virtual ~ParticleBase() { }
54  int charge() const
55  {
56  return qx3_ / 3;
57  }
59  void setCharge( Charge q )
60  {
61  qx3_ = q * 3;
62  }
64  int threeCharge() const
65  {
66  return qx3_;
67  }
69  void setThreeCharge( Charge qx3 )
70  {
71  qx3_ = qx3;
72  }
74  const LorentzVector & p4() const
75  {
77  return p4Cartesian_;
78  }
80  const PolarLorentzVector & polarP4() const
81  {
82  cachePolar();
83  return p4Polar_;
84  }
86  Vector momentum() const
87  {
89  return p4Cartesian_.Vect();
90  }
93  Vector boostToCM() const
94  {
96  return p4Cartesian_.BoostToCM();
97  }
99  double p() const
100  {
101  cacheCartesian();
102  return p4Cartesian_.P();
103  }
105  double energy() const
106  {
107  cacheCartesian();
108  return p4Cartesian_.E();
109  }
111  double et() const
112  {
113  cachePolar();
114  return p4Polar_.Et();
115  }
117  double mass() const
118  {
119  return mass_;
120  }
122  double massSqr() const
123  {
124  return mass_ * mass_;
125  }
127  double mt() const
128  {
129  cachePolar();
130  return p4Polar_.Mt();
131  }
133  double mtSqr() const
134  {
135  cachePolar();
136  return p4Polar_.Mt2();
137  }
139  double px() const
140  {
141  cacheCartesian();
142  return p4Cartesian_.Px();
143  }
145  double py() const
146  {
147  cacheCartesian();
148  return p4Cartesian_.Py();
149  }
151  double pz() const
152  {
153  cacheCartesian();
154  return p4Cartesian_.Pz();
155  }
157  double pt() const
158  {
159  return pt_;
160  }
162  double phi() const
163  {
164  return phi_;
165  }
167  double theta() const
168  {
169  cacheCartesian();
170  return p4Cartesian_.Theta();
171  }
173  double eta() const
174  {
175  return eta_;
176  }
178  double rapidity() const
179  {
180  cachePolar();
181  return p4Polar_.Rapidity();
182  }
184  double y() const
185  {
186  return rapidity();
187  }
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  }
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  }
212  void setMass( double m )
213  {
214  mass_ = m;
215  clearCache();
216  }
217  void setPz( double pz )
218  {
219  cacheCartesian();
220  p4Cartesian_.SetPz(pz);
222  pt_ = p4Polar_.pt();
223  eta_ = p4Polar_.eta();
224  phi_ = p4Polar_.phi();
225  mass_ = p4Polar_.mass();
226  }
228  const Point & vertex() const
229  {
230  return vertex_;
231  }
233  double vx() const
234  {
235  return vertex_.X();
236  }
238  double vy() const
239  {
240  return vertex_.Y();
241  }
243  double vz() const
244  {
245  return vertex_.Z();
246  }
248  void setVertex( const Point & vertex )
249  {
250  vertex_ = vertex;
251  }
253  int pdgId() const
254  {
255  return pdgId_;
256  }
257  // set PDG identifier
258  void setPdgId( int pdgId )
259  {
260  pdgId_ = pdgId;
261  }
263  int status() const
264  {
265  return status_;
266  }
268  void setStatus( int status )
269  {
270  status_ = status;
271  }
273  static const unsigned int longLivedTag;
276  {
278  }
280  bool longLived() const
281  {
282  return status_ & longLivedTag;
283  }
284 
285 protected:
289  float pt_, eta_, phi_, mass_;
293  int pdgId_;
295  int status_;
303  inline void cachePolar() const
304  {
305  if ( cachePolarFixed_ ) return;
307  cachePolarFixed_ = true;
308  }
310  inline void cacheCartesian() const
311  {
312  if ( cacheCartesianFixed_ ) return;
313  cachePolar();
315  cacheCartesianFixed_ = true;
316  }
318  inline void clearCache() const
319  {
320  cachePolarFixed_ = false;
321  cacheCartesianFixed_ = false;
322  }
323 };
324 
325 #endif
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: ParticleBase.h:26
PolarLorentzVector p4Polar_
internal cache for p4
Definition: ParticleBase.h:297
int status_
status word
Definition: ParticleBase.h:295
int pdgId() const
PDG identifier.
Definition: ParticleBase.h:253
int pdgId_
PDG identifier.
Definition: ParticleBase.h:293
double energy() const
energy
Definition: ParticleBase.h:105
bool longLived() const
is long lived?
Definition: ParticleBase.h:280
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:15
int charge() const
electric charge
Definition: ParticleBase.h:54
math::XYZTLorentzVectorD LorentzVector
Lorentz vector.
Definition: ParticleBase.h:24
double massSqr() const
mass squared
Definition: ParticleBase.h:122
double mtSqr() const
transverse mass squared
Definition: ParticleBase.h:133
math::XYZVectorD Vector
point in the space
Definition: ParticleBase.h:30
double pt() const
transverse momentum
Definition: ParticleBase.h:157
virtual ~ParticleBase()
destructor
Definition: ParticleBase.h:52
void cacheCartesian() const
set internal cache
Definition: ParticleBase.h:310
float pt_
four-momentum Lorentz vector
Definition: ParticleBase.h:289
double pz() const
z coordinate of momentum vector
Definition: ParticleBase.h:151
ParticleBase(Charge q, const PolarLorentzVector &p4, const Point &vertex=Point(0, 0, 0), int pdgId=0, int status=0, bool integerCharge=true)
constructor from values
Definition: ParticleBase.h:43
Vector boostToCM() const
Definition: ParticleBase.h:93
ParticleBase(Charge q, const LorentzVector &p4, const Point &vertex=Point(0, 0, 0), int pdgId=0, int status=0, bool integerCharge=true)
constructor from values
Definition: ParticleBase.h:34
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:26
double mt() const
transverse mass
Definition: ParticleBase.h:127
double px() const
x coordinate of momentum vector
Definition: ParticleBase.h:139
double theta() const
momentum polar angle
Definition: ParticleBase.h:167
math::XYZPointD Point
point in the space
Definition: ParticleBase.h:28
double phi() const
momentum azimuthal angle
Definition: ParticleBase.h:162
double p() const
magnitude of momentum vector
Definition: ParticleBase.h:99
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:9
double mass() const
mass
Definition: ParticleBase.h:117
void cachePolar() const
set internal cache
Definition: ParticleBase.h:303
Point vertex_
vertex position
Definition: ParticleBase.h:291
int threeCharge() const
electric charge
Definition: ParticleBase.h:64
bool cachePolarFixed_
has cache been set?
Definition: ParticleBase.h:301
void setStatus(int status)
set status word
Definition: ParticleBase.h:268
void setCharge(Charge q)
set electric charge
Definition: ParticleBase.h:59
void clearCache() const
clear internal cache
Definition: ParticleBase.h:318
void setLongLived()
set long lived flag
Definition: ParticleBase.h:275
double vz() const
z coordinate of vertex position
Definition: ParticleBase.h:243
void setPz(double pz)
Definition: ParticleBase.h:217
const PolarLorentzVector & polarP4() const
four-momentum Lorentz vector
Definition: ParticleBase.h:80
const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: ParticleBase.h:74
void setPdgId(int pdgId)
Definition: ParticleBase.h:258
Charge qx3_
electric charge
Definition: ParticleBase.h:287
double vx() const
x coordinate of vertex position
Definition: ParticleBase.h:233
int status() const
status word
Definition: ParticleBase.h:263
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double > > XYZPointD
point in space with cartesian internal representation
Definition: Point3D.h:9
int Charge
electric charge type
Definition: ParticleBase.h:22
ParticleBase()
default constructor
Definition: ParticleBase.h:32
Vector momentum() const
spatial momentum vector
Definition: ParticleBase.h:86
LorentzVector p4Cartesian_
internal cache for p4
Definition: ParticleBase.h:299
void setThreeCharge(Charge qx3)
set electric charge
Definition: ParticleBase.h:69
static const unsigned int longLivedTag
long lived flag
Definition: ParticleBase.h:273
void setMass(double m)
set particle mass
Definition: ParticleBase.h:212
double rapidity() const
repidity
Definition: ParticleBase.h:178
double y() const
repidity
Definition: ParticleBase.h:184
double py() const
y coordinate of momentum vector
Definition: ParticleBase.h:145
void setP4(const LorentzVector &p4)
set 4-momentum
Definition: ParticleBase.h:189
double et() const
transverse energy
Definition: ParticleBase.h:111
void setVertex(const Point &vertex)
set vertex
Definition: ParticleBase.h:248
const Point & vertex() const
vertex position
Definition: ParticleBase.h:228
void setP4(const PolarLorentzVector &p4)
set 4-momentum
Definition: ParticleBase.h:201
bool cacheCartesianFixed_
Definition: ParticleBase.h:301
double vy() const
y coordinate of vertex position
Definition: ParticleBase.h:238
double eta() const
momentum pseudorapidity
Definition: ParticleBase.h:173