CMS 3D CMS Logo

RawParticle.h
Go to the documentation of this file.
1 #ifndef CommonTools_BaseParticlePropagator_RawParticle_h
2 #define CommonTools_BaseParticlePropagator_RawParticle_h
3 
6 
7 #include "Math/GenVector/RotationX.h"
8 #include "Math/GenVector/RotationY.h"
9 #include "Math/GenVector/RotationZ.h"
10 #include "Math/GenVector/Rotation3D.h"
11 #include "Math/GenVector/AxisAngle.h"
12 #include "Math/GenVector/Boost.h"
13 
14 #include <string>
15 #include <iosfwd>
16 
17 #include <memory>
18 
27 
28 class RawParticle;
29 
30 namespace rawparticle {
34  RawParticle makeMuon(bool isParticle, const XYZTLorentzVector& p, const XYZTLorentzVector& xStart);
35 } // namespace rawparticle
36 
37 class RawParticle {
38 public:
40  friend RawParticle unchecked_makeParticle(int id, const math::XYZTLorentzVector& p, double mass, double charge);
42  int id, const math::XYZTLorentzVector& p, const math::XYZTLorentzVector& xStart, double mass, double charge);
43 
44  typedef ROOT::Math::AxisAngle Rotation;
45  typedef ROOT::Math::Rotation3D Rotation3D;
46  typedef ROOT::Math::RotationX RotationX;
47  typedef ROOT::Math::RotationY RotationY;
48  typedef ROOT::Math::RotationZ RotationZ;
49  typedef ROOT::Math::Boost Boost;
50 
51  RawParticle() = default;
52 
57 
61  RawParticle(const XYZTLorentzVector& p, const XYZTLorentzVector& xStart, double charge = 0.);
62 
66  RawParticle(double px, double py, double pz, double e, double charge = 0.);
67 
69  RawParticle(const RawParticle& p) = default;
70  RawParticle(RawParticle&& p) = default;
71 
73  RawParticle& operator=(const RawParticle& rhs) = default;
74  RawParticle& operator=(RawParticle&& rhs) = default;
75 
76 public:
81  void setStatus(int istat);
82 
84  void setMass(float m);
85 
87  void setCharge(float q);
88 
90  void setT(const double t);
91 
93  void setVertex(const XYZTLorentzVector& vtx);
94  void setVertex(double xv, double yv, double zv, double tv);
95 
97  void setMomentum(const XYZTLorentzVector& vtx);
98  void setMomentum(double xv, double yv, double zv, double tv);
99 
100  void SetPx(double);
101  void SetPy(double);
102  void SetPz(double);
103  void SetE(double);
104 
105  /*** methods to be overloaded to include vertex ***/
106 
111  void boost(double bx, double by, double bz);
112  void boost(const Boost& b);
113 
114  // inline void boost(const Hep3Vector<double> &bv );
115 
121  void rotate(double rphi, const XYZVector& raxis);
122  void rotate(const Rotation& r);
123  void rotate(const Rotation3D& r);
124 
126  // void rotateUz(Hep3Vector &nuz);
127 
131  void rotateX(double rphi);
132  void rotate(const RotationX& r);
133 
138  void rotateY(double rphi);
139  void rotate(const RotationY& r);
144  void rotateZ(double rphi);
145  void rotate(const RotationZ& r);
146 
148  void translate(const XYZVector& t);
149 
150  // inline RawParticle & transform(const HepRotation &rot);
151  // inline RawParticle & transform(const HepLorentzRotation &rot);
152 
157  void chargeConjugate();
158 
159  int pid() const;
160 
161  int status() const;
162 
163  double charge() const;
164 
165  double mass() const;
166 
170  double eta() const;
171 
173  double cos2Theta() const;
174  double cos2ThetaV() const;
175 
176  double et() const;
177 
178  double x() const;
179  double X() const;
180 
181  double y() const;
182  double Y() const;
183 
184  double z() const;
185  double Z() const;
186 
187  double t() const;
188  double T() const;
189 
190  double r() const;
191  double R() const;
192 
193  double r2() const;
194  double R2() const;
195 
196  const XYZTLorentzVector& vertex() const;
197 
198  double px() const;
199  double Px() const;
200 
201  double py() const;
202  double Py() const;
203 
204  double pz() const;
205  double Pz() const;
206 
207  double e() const;
208  double E() const;
209 
210  double Pt() const;
211  double pt() const;
212 
213  double Perp2() const;
214 
215  double mag() const;
216 
217  double theta() const;
218  double phi() const;
219 
220  double M2() const;
221 
222  const XYZTLorentzVector& momentum() const;
224 
225  XYZVector Vect() const;
226 
232  void printName() const;
233 
238  void print() const;
239 
244  int isUsed() const { return myUsed; }
245 
248  void use() { myUsed = 1; }
249 
252  void reUse() { myUsed = 0; }
253 
254 private:
258  RawParticle(const int id, const XYZTLorentzVector& p, double mass, double charge);
259 
263  RawParticle(const int id, const XYZTLorentzVector& p, const XYZTLorentzVector& xStart, double mass, double charge);
264 
265 private:
268  double myCharge = 0.;
269  double myMass = 0.;
270  int myId = 0;
271  int myStatus = 99;
272  int myUsed = 0;
273 };
274 
275 std::ostream& operator<<(std::ostream& o, const RawParticle& p);
276 
277 inline int RawParticle::pid() const { return myId; }
278 inline int RawParticle::status() const { return myStatus; }
279 inline double RawParticle::eta() const { return -std::log(std::tan(this->theta() / 2.)); }
280 inline double RawParticle::cos2Theta() const { return Pz() * Pz() / myMomentum.Vect().Mag2(); }
281 inline double RawParticle::cos2ThetaV() const { return Z() * Z() / myVertex.Vect().Mag2(); }
282 inline double RawParticle::x() const { return myVertex.Px(); }
283 inline double RawParticle::y() const { return myVertex.Py(); }
284 inline double RawParticle::z() const { return myVertex.Pz(); }
285 inline double RawParticle::t() const { return myVertex.E(); }
286 inline double RawParticle::X() const { return myVertex.Px(); }
287 inline double RawParticle::Y() const { return myVertex.Py(); }
288 inline double RawParticle::Z() const { return myVertex.Pz(); }
289 inline double RawParticle::T() const { return myVertex.E(); }
290 inline double RawParticle::R() const { return std::sqrt(R2()); }
291 inline double RawParticle::R2() const { return myVertex.Perp2(); }
292 inline double RawParticle::r() const { return std::sqrt(r2()); }
293 inline double RawParticle::r2() const { return myVertex.Perp2(); }
294 inline double RawParticle::charge() const { return myCharge; }
295 inline double RawParticle::mass() const { return myMass; }
296 inline double RawParticle::px() const { return myMomentum.px(); }
297 inline double RawParticle::Px() const { return myMomentum.Px(); }
298 
299 inline double RawParticle::py() const { return myMomentum.py(); }
300 inline double RawParticle::Py() const { return myMomentum.Py(); }
301 
302 inline double RawParticle::pz() const { return myMomentum.pz(); }
303 inline double RawParticle::Pz() const { return myMomentum.Pz(); }
304 
305 inline double RawParticle::e() const { return myMomentum.e(); }
306 inline double RawParticle::E() const { return myMomentum.E(); }
307 
308 inline double RawParticle::Pt() const { return myMomentum.Pt(); }
309 inline double RawParticle::pt() const { return myMomentum.pt(); }
310 
311 inline double RawParticle::Perp2() const { return myMomentum.Perp2(); }
312 
313 inline double RawParticle::mag() const { return myMomentum.mag(); }
314 
315 inline double RawParticle::theta() const { return myMomentum.theta(); }
316 inline double RawParticle::phi() const { return myMomentum.phi(); }
317 
318 inline double RawParticle::M2() const { return myMomentum.M2(); }
319 
320 inline const XYZTLorentzVector& RawParticle::vertex() const { return myVertex; }
321 inline const XYZTLorentzVector& RawParticle::momentum() const { return myMomentum; }
323 inline XYZVector RawParticle::Vect() const { return myMomentum.Vect(); }
324 
326 inline void RawParticle::setVertex(double a, double b, double c, double d) { myVertex.SetXYZT(a, b, c, d); }
327 
328 inline void RawParticle::setMomentum(const XYZTLorentzVector& p4) { myMomentum = p4; }
329 inline void RawParticle::setMomentum(double a, double b, double c, double d) { myMomentum.SetXYZT(a, b, c, d); }
330 
331 inline void RawParticle::SetPx(double px) { myMomentum.SetPx(px); }
332 inline void RawParticle::SetPy(double py) { myMomentum.SetPy(py); }
333 inline void RawParticle::SetPz(double pz) { myMomentum.SetPz(pz); }
334 inline void RawParticle::SetE(double e) { myMomentum.SetE(e); }
335 
337  XYZVector v(r(myMomentum.Vect()));
338  setMomentum(v.X(), v.Y(), v.Z(), E());
339 }
340 
342  XYZVector v(r(myMomentum.Vect()));
343  setMomentum(v.X(), v.Y(), v.Z(), E());
344 }
345 
347  XYZVector v(r(myMomentum.Vect()));
348  setMomentum(v.X(), v.Y(), v.Z(), E());
349 }
350 
352  XYZVector v(r(myMomentum.Vect()));
353  setMomentum(v.X(), v.Y(), v.Z(), E());
354 }
355 
357  XYZVector v(r(myMomentum.Vect()));
358  setMomentum(v.X(), v.Y(), v.Z(), E());
359 }
360 
363  setMomentum(p.Px(), p.Py(), p.Pz(), p.E());
364 }
365 
366 inline void RawParticle::translate(const XYZVector& tr) {
367  myVertex.SetXYZT(X() + tr.X(), Y() + tr.Y(), Z() + tr.Z(), T());
368 }
369 
370 #endif
double R2() const
vertex radius**2
Definition: RawParticle.h:291
void setMomentum(const XYZTLorentzVector &vtx)
set the momentum
Definition: RawParticle.h:328
void setCharge(float q)
set the MEASURED charge
Definition: RawParticle.cc:32
void translate(const XYZVector &t)
Definition: RawParticle.h:366
void boost(double bx, double by, double bz)
Definition: RawParticle.cc:65
void rotateZ(double rphi)
Definition: RawParticle.cc:59
double x() const
x of vertex
Definition: RawParticle.h:282
void use()
Definition: RawParticle.h:248
XYZTLorentzVector myVertex
the four vector of the vertex
Definition: RawParticle.h:267
double Pz() const
z of the momentum
Definition: RawParticle.h:303
void rotateY(double rphi)
Definition: RawParticle.cc:53
void print() const
double et() const
get the transverse energy
Definition: RawParticle.cc:82
int myId
the particle id number HEP-PID
Definition: RawParticle.h:270
ROOT::Math::Rotation3D Rotation3D
Definition: RawParticle.h:45
friend RawParticle unchecked_makeParticle(int id, const math::XYZTLorentzVector &p, double mass, double charge)
Definition: makeParticle.cc:19
std::ostream & operator<<(std::ostream &o, const RawParticle &p)
Definition: RawParticle.cc:71
int pid() const
get the HEP particle ID number
Definition: RawParticle.h:277
double cos2Theta() const
Cos**2(theta) is faster to determine than eta.
Definition: RawParticle.h:280
double Z() const
z of vertex
Definition: RawParticle.h:288
double myMass
the RECONSTRUCTED mass
Definition: RawParticle.h:269
XYZTLorentzVector myMomentum
the four vector of the momentum
Definition: RawParticle.h:266
double r() const
vertex radius
Definition: RawParticle.h:292
void printName() const
void SetE(double)
Definition: RawParticle.h:334
double E() const
energy of the momentum
Definition: RawParticle.h:306
const XYZTLorentzVector & momentum() const
the momentum fourvector
Definition: RawParticle.h:321
void chargeConjugate()
Definition: RawParticle.cc:34
void setT(const double t)
set the time of creation
Definition: RawParticle.cc:39
RawParticle makeMuon(bool isParticle, const math::XYZTLorentzVector &p, const math::XYZTLorentzVector &xStart)
Definition: makeMuon.cc:20
double t() const
vertex time
Definition: RawParticle.h:285
ROOT::Math::Boost Boost
Definition: RawParticle.h:49
ROOT::Math::RotationZ RotationZ
Definition: RawParticle.h:48
double charge() const
get the MEASURED charge
Definition: RawParticle.h:294
double px() const
x of the momentum
Definition: RawParticle.h:296
void setMass(float m)
set the RECONSTRUCTED mass
Definition: RawParticle.cc:30
int myStatus
the status code according to PYTHIA
Definition: RawParticle.h:271
double pt() const
transverse momentum
Definition: RawParticle.h:309
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
double Pt() const
transverse momentum
Definition: RawParticle.h:308
ROOT::Math::RotationX RotationX
Definition: RawParticle.h:46
double cos2ThetaV() const
Definition: RawParticle.h:281
double eta() const
Definition: RawParticle.h:279
double myCharge
the MEASURED charge
Definition: RawParticle.h:268
T sqrt(T t)
Definition: SSEVec.h:19
double Py() const
y of the momentum
Definition: RawParticle.h:300
ROOT::Math::RotationY RotationY
Definition: RawParticle.h:47
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double z() const
z of vertex
Definition: RawParticle.h:284
void rotate(double rphi, const XYZVector &raxis)
Definition: RawParticle.cc:41
double py() const
y of the momentum
Definition: RawParticle.h:299
RawParticle & operator=(const RawParticle &rhs)=default
double y() const
y of vertex
Definition: RawParticle.h:283
void SetPx(double)
Definition: RawParticle.h:331
d
Definition: ztail.py:151
double Perp2() const
perpendicular momentum squared
Definition: RawParticle.h:311
double r2() const
vertex radius**2
Definition: RawParticle.h:293
int myUsed
status of the locking
Definition: RawParticle.h:272
double pz() const
z of the momentum
Definition: RawParticle.h:302
void SetPy(double)
Definition: RawParticle.h:332
XYZVector Vect() const
the momentum threevector
Definition: RawParticle.h:323
double T() const
vertex time
Definition: RawParticle.h:289
void setStatus(int istat)
Definition: RawParticle.cc:28
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
double mass() const
get the MEASURED mass
Definition: RawParticle.h:295
double M2() const
mass squared
Definition: RawParticle.h:318
double b
Definition: hdecay.h:120
void rotateX(double rphi)
Definition: RawParticle.cc:47
double Y() const
y of vertex
Definition: RawParticle.h:287
void SetPz(double)
Definition: RawParticle.h:333
double a
Definition: hdecay.h:121
int isUsed() const
Definition: RawParticle.h:244
double R() const
vertex radius
Definition: RawParticle.h:290
ROOT::Math::AxisAngle Rotation
Definition: RawParticle.h:44
double X() const
x of vertex
Definition: RawParticle.h:286
double theta() const
theta of momentum vector
Definition: RawParticle.h:315
math::XYZVector XYZVector
Definition: RawParticle.h:26
RawParticle()=default
double phi() const
phi of momentum vector
Definition: RawParticle.h:316
double e() const
energy of the momentum
Definition: RawParticle.h:305
void setVertex(const XYZTLorentzVector &vtx)
set the vertex
Definition: RawParticle.h:325
double mag() const
the magnitude of the momentum
Definition: RawParticle.h:313
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:25
void reUse()
Definition: RawParticle.h:252
const XYZTLorentzVector & vertex() const
the vertex fourvector
Definition: RawParticle.h:320
double Px() const
x of the momentum
Definition: RawParticle.h:297
int status() const
get the particle status
Definition: RawParticle.h:278