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 
4 
7 
8 #include "Math/GenVector/RotationX.h"
9 #include "Math/GenVector/RotationY.h"
10 #include "Math/GenVector/RotationZ.h"
11 #include "Math/GenVector/Rotation3D.h"
12 #include "Math/GenVector/AxisAngle.h"
13 #include "Math/GenVector/Boost.h"
14 
15 #include <string>
16 #include <iosfwd>
17 
18 #include<memory>
19 
20 
29 
30 class RawParticle;
31 
32 namespace rawparticle {
36  RawParticle makeMuon(bool isParticle, const XYZTLorentzVector& p,
37  const XYZTLorentzVector& xStart);
38 }
39 
40 class RawParticle {
41 public:
42 
44  friend RawParticle unchecked_makeParticle(int id, const math::XYZTLorentzVector& p, double mass, double charge);
45  friend RawParticle unchecked_makeParticle(int id, const math::XYZTLorentzVector& p, const math::XYZTLorentzVector& xStart, double mass, double charge);
46 
47  typedef ROOT::Math::AxisAngle Rotation;
48  typedef ROOT::Math::Rotation3D Rotation3D;
49  typedef ROOT::Math::RotationX RotationX;
50  typedef ROOT::Math::RotationY RotationY;
51  typedef ROOT::Math::RotationZ RotationZ;
52  typedef ROOT::Math::Boost Boost;
53 
54  RawParticle() = default;
55 
60 
65  const XYZTLorentzVector& xStart,
66  double charge = 0.);
67 
71  RawParticle(double px, double py, double pz, double e, double charge =0.);
72 
74  RawParticle(const RawParticle &p) = default;
75  RawParticle(RawParticle &&p) = default;
76 
78  RawParticle& operator = (const RawParticle & rhs ) = default;
79  RawParticle& operator = (RawParticle&& rhs ) = default;
80 
81 public:
82 
87  void setStatus(int istat);
88 
90  void setMass(float m);
91 
93  void setCharge(float q);
94 
96  void setT(const double t);
97 
99  void setVertex(const XYZTLorentzVector& vtx);
100  void setVertex(double xv, double yv, double zv, double tv);
101 
103  void setMomentum(const XYZTLorentzVector& vtx);
104  void setMomentum(double xv, double yv, double zv, double tv);
105 
106  void SetPx(double);
107  void SetPy(double);
108  void SetPz(double);
109  void SetE(double);
110 
111  /*** methods to be overloaded to include vertex ***/
112 
117  void boost(double bx, double by, double bz);
118  void boost(const Boost& b);
119 
120  // inline void boost(const Hep3Vector<double> &bv );
121 
127  void rotate(double rphi, const XYZVector& raxis);
128  void rotate(const Rotation& r);
129  void rotate(const Rotation3D& r);
130 
132  // void rotateUz(Hep3Vector &nuz);
133 
137  void rotateX(double rphi);
138  void rotate(const RotationX& r);
139 
144  void rotateY(double rphi);
145  void rotate(const RotationY& r);
150  void rotateZ(double rphi);
151  void rotate(const RotationZ& r);
152 
154  void translate(const XYZVector& t);
155 
156  // inline RawParticle & transform(const HepRotation &rot);
157  // inline RawParticle & transform(const HepLorentzRotation &rot);
158 
163  void chargeConjugate();
164 
165  int pid() const;
166 
167  int status() const;
168 
169  double charge() const;
170 
171  double mass() const;
172 
176  double eta() const;
177 
179  double cos2Theta() const;
180  double cos2ThetaV() const;
181 
182  double et() const;
183 
184  double x() const;
185  double X() const;
186 
187  double y() const;
188  double Y() const;
189 
190  double z() const;
191  double Z() const;
192 
193  double t() const;
194  double T() const;
195 
196  double r() const;
197  double R() const;
198 
199  double r2() const;
200  double R2() const;
201 
202  const XYZTLorentzVector& vertex() const;
203 
204  double px() const;
205  double Px() const;
206 
207  double py() const;
208  double Py() const;
209 
210  double pz() const;
211  double Pz() const;
212 
213  double e() const;
214  double E() const;
215 
216  double Pt() const;
217  double pt() const;
218 
219  double Perp2() const;
220 
221  double mag() const;
222 
223  double theta() const;
224  double phi() const;
225 
226  double M2() const;
227 
228  const XYZTLorentzVector& momentum() const;
229  XYZTLorentzVector& momentum();
230 
231  XYZVector Vect() const;
232 
238  void printName() const;
239 
244  void print() const;
245 
250  int isUsed() const {return myUsed;}
251 
254  void use() { myUsed = 1;}
255 
258  void reUse() { myUsed = 0;}
259 
260  private:
261 
265  RawParticle(const int id,
266  const XYZTLorentzVector& p,
267  double mass,
268  double charge);
269 
270 
274  RawParticle(const int id,
275  const XYZTLorentzVector& p,
276  const XYZTLorentzVector& xStart,
277  double mass,
278  double charge);
279 
280 
281  private:
282 
285  double myCharge= 0.;
286  double myMass = 0.;
287  int myId = 0;
288  int myStatus=99;
289  int myUsed = 0;
290 
291 };
292 
293 
294 std::ostream& operator <<(std::ostream& o , const RawParticle& p);
295 
296 inline int RawParticle::pid() const { return myId; }
297 inline int RawParticle::status() const { return myStatus; }
298 inline double RawParticle::eta() const { return -std::log(std::tan(this->theta()/2.)); }
299 inline double RawParticle::cos2Theta() const { return Pz()*Pz()/myMomentum.Vect().Mag2(); }
300 inline double RawParticle::cos2ThetaV() const { return Z()*Z()/myVertex.Vect().Mag2(); }
301 inline double RawParticle::x() const { return myVertex.Px(); }
302 inline double RawParticle::y() const { return myVertex.Py(); }
303 inline double RawParticle::z() const { return myVertex.Pz(); }
304 inline double RawParticle::t() const { return myVertex.E(); }
305 inline double RawParticle::X() const { return myVertex.Px(); }
306 inline double RawParticle::Y() const { return myVertex.Py(); }
307 inline double RawParticle::Z() const { return myVertex.Pz(); }
308 inline double RawParticle::T() const { return myVertex.E(); }
309 inline double RawParticle::R() const { return std::sqrt(R2()); }
310 inline double RawParticle::R2() const { return myVertex.Perp2(); }
311 inline double RawParticle::r() const { return std::sqrt(r2()); }
312 inline double RawParticle::r2() const { return myVertex.Perp2(); }
313 inline double RawParticle::charge() const { return myCharge; }
314 inline double RawParticle::mass() const { return myMass; }
315 inline double RawParticle::px() const { return myMomentum.px() ; }
316 inline double RawParticle::Px() const { return myMomentum.Px() ; }
317 
318 inline double RawParticle::py() const { return myMomentum.py() ; }
319 inline double RawParticle::Py() const { return myMomentum.Py() ; }
320 
321 inline double RawParticle::pz() const { return myMomentum.pz() ; }
322 inline double RawParticle::Pz() const { return myMomentum.Pz() ; }
323 
324 inline double RawParticle::e() const { return myMomentum.e() ; }
325 inline double RawParticle::E() const { return myMomentum.E() ; }
326 
327 inline double RawParticle::Pt() const { return myMomentum.Pt() ; }
328 inline double RawParticle::pt() const { return myMomentum.pt() ; }
329 
330 inline double RawParticle::Perp2() const { return myMomentum.Perp2(); }
331 
332 inline double RawParticle::mag() const { return myMomentum.mag(); }
333 
334 inline double RawParticle::theta() const { return myMomentum.theta(); }
335 inline double RawParticle::phi() const { return myMomentum.phi(); }
336 
337 inline double RawParticle::M2() const { return myMomentum.M2(); }
338 
339 inline const XYZTLorentzVector& RawParticle::vertex() const { return myVertex ; }
340 inline const XYZTLorentzVector& RawParticle::momentum() const { return myMomentum; }
341 inline XYZTLorentzVector& RawParticle::momentum() { return myMomentum; }
342 inline XYZVector RawParticle::Vect() const { return myMomentum.Vect(); }
343 
344 inline void RawParticle::setVertex(const XYZTLorentzVector& vtx) { myVertex = vtx; }
345 inline void RawParticle::setVertex(double a, double b, double c, double d) { myVertex.SetXYZT(a,b,c,d); }
346 
347 inline void RawParticle::setMomentum(const XYZTLorentzVector& p4) { myMomentum = p4; }
348 inline void RawParticle::setMomentum(double a, double b, double c, double d) { myMomentum.SetXYZT(a,b,c,d); }
349 
350 inline void RawParticle::SetPx(double px) {myMomentum.SetPx(px);}
351 inline void RawParticle::SetPy(double py) {myMomentum.SetPy(py);}
352 inline void RawParticle::SetPz(double pz) {myMomentum.SetPz(pz);}
353 inline void RawParticle::SetE(double e) {myMomentum.SetE(e);}
354 
355 
357  XYZVector v ( r(myMomentum.Vect()) ); setMomentum(v.X(),v.Y(),v.Z(),E());
358 }
359 
361  XYZVector v ( r(myMomentum.Vect()) ); setMomentum(v.X(),v.Y(),v.Z(),E());
362 }
363 
365  XYZVector v ( r(myMomentum.Vect()) ); setMomentum(v.X(),v.Y(),v.Z(),E());
366 }
367 
369  XYZVector v ( r(myMomentum.Vect()) ); setMomentum(v.X(),v.Y(),v.Z(),E());
370 }
371 
373  XYZVector v ( r(myMomentum.Vect()) ); setMomentum(v.X(),v.Y(),v.Z(),E());
374 }
375 
377  XYZTLorentzVector p ( b(momentum()) ); setMomentum(p.Px(),p.Py(),p.Pz(),p.E());
378 }
379 
380 inline void RawParticle::translate(const XYZVector& tr) {
381  myVertex.SetXYZT(X()+tr.X(),Y()+tr.Y(),Z()+tr.Z(),T());
382 }
383 
384 #endif
void setMomentum(const XYZTLorentzVector &vtx)
set the momentum
Definition: RawParticle.h:347
double pz() const
z of the momentum
Definition: RawParticle.h:321
void translate(const XYZVector &t)
Definition: RawParticle.h:380
void boost(double bx, double by, double bz)
Definition: RawParticle.cc:111
XYZVector Vect() const
the momentum threevector
Definition: RawParticle.h:342
void use()
Definition: RawParticle.h:254
XYZTLorentzVector myVertex
the four vector of the vertex
Definition: RawParticle.h:284
double pt() const
transverse momentum
Definition: RawParticle.h:328
int status() const
get the particle status
Definition: RawParticle.h:297
Definition: CLHEP.h:16
double y() const
y of vertex
Definition: RawParticle.h:302
ROOT::Math::Rotation3D Rotation3D
Definition: RawParticle.h:48
double Perp2() const
perpendicular momentum squared
Definition: RawParticle.h:330
std::ostream & operator<<(std::ostream &o, const RawParticle &p)
Definition: RawParticle.cc:118
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
double z() const
z of vertex
Definition: RawParticle.h:303
XYZTLorentzVector myMomentum
the four vector of the momentum
Definition: RawParticle.h:283
Geom::Theta< T > theta() const
#define X(str)
Definition: MuonsGrabber.cc:48
int pid() const
get the HEP particle ID number
Definition: RawParticle.h:296
void SetE(double)
Definition: RawParticle.h:353
RawParticle makeMuon(bool isParticle, const math::XYZTLorentzVector &p, const math::XYZTLorentzVector &xStart)
Definition: makeMuon.cc:20
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
double mass() const
get the MEASURED mass
Definition: RawParticle.h:314
ROOT::Math::Boost Boost
Definition: RawParticle.h:52
double x() const
x of vertex
Definition: RawParticle.h:301
ROOT::Math::RotationZ RotationZ
Definition: RawParticle.h:51
int isUsed() const
Definition: RawParticle.h:250
double R() const
vertex radius
Definition: RawParticle.h:309
double R2() const
vertex radius**2
Definition: RawParticle.h:310
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
ROOT::Math::RotationX RotationX
Definition: RawParticle.h:49
double phi() const
phi of momentum vector
Definition: RawParticle.h:335
const XYZTLorentzVector & momentum() const
the momentum fourvector
Definition: RawParticle.h:340
double t() const
vertex time
Definition: RawParticle.h:304
double e() const
energy of the momentum
Definition: RawParticle.h:324
double r2() const
vertex radius**2
Definition: RawParticle.h:312
T sqrt(T t)
Definition: SSEVec.h:18
double p4[4]
Definition: TauolaWrapper.h:92
double cos2ThetaV() const
Definition: RawParticle.h:300
double Y() const
y of vertex
Definition: RawParticle.h:306
double Py() const
y of the momentum
Definition: RawParticle.h:319
double Pt() const
transverse momentum
Definition: RawParticle.h:327
double Z() const
z of vertex
Definition: RawParticle.h:307
ROOT::Math::RotationY RotationY
Definition: RawParticle.h:50
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
void rotate(double rphi, const XYZVector &raxis)
Definition: RawParticle.cc:83
double Pz() const
z of the momentum
Definition: RawParticle.h:322
double charge() const
get the MEASURED charge
Definition: RawParticle.h:313
void SetPx(double)
Definition: RawParticle.h:350
double mag() const
the magnitude of the momentum
Definition: RawParticle.h:332
double M2() const
mass squared
Definition: RawParticle.h:337
void SetPy(double)
Definition: RawParticle.h:351
const XYZTLorentzVector & vertex() const
the vertex fourvector
Definition: RawParticle.h:339
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
double b
Definition: hdecay.h:120
et
define resolution functions of each parameter
double r() const
vertex radius
Definition: RawParticle.h:311
double X() const
x of vertex
Definition: RawParticle.h:305
void SetPz(double)
Definition: RawParticle.h:352
double theta() const
theta of momentum vector
Definition: RawParticle.h:334
double a
Definition: hdecay.h:121
double Px() const
x of the momentum
Definition: RawParticle.h:316
ROOT::Math::AxisAngle Rotation
Definition: RawParticle.h:47
double eta() const
Definition: RawParticle.h:298
double E() const
energy of the momentum
Definition: RawParticle.h:325
double px() const
x of the momentum
Definition: RawParticle.h:315
double T() const
vertex time
Definition: RawParticle.h:308
double py() const
y of the momentum
Definition: RawParticle.h:318
math::XYZVector XYZVector
Definition: RawParticle.h:28
long double T
def rotate(angle, cx=0, cy=0)
Definition: svgfig.py:705
void setVertex(const XYZTLorentzVector &vtx)
set the vertex
Definition: RawParticle.h:344
double cos2Theta() const
Cos**2(theta) is faster to determine than eta.
Definition: RawParticle.h:299
RawParticle unchecked_makeParticle(int id, const math::XYZTLorentzVector &p, double mass, double charge)
Definition: makeParticle.cc:20
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:27
void reUse()
Definition: RawParticle.h:258