CMS 3D CMS Logo

RawParticle.cc
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 // Prototype for a particle class
3 // -----------------------------------------------------------------------------
4 // $Date: 2007/09/07 16:46:22 $
5 // $Revision: 1.13 $
6 // -----------------------------------------------------------------------------
7 // Author: Stephan Wynhoff - RWTH-Aachen (Email: Stephan.Wynhoff@cern.ch)
8 // -----------------------------------------------------------------------------
10 
11 #include <cmath>
12 
14  : myMomentum(p) {
15 }
16 
18  const XYZTLorentzVector& p,
19  double mass,
20  double charge) :
21  myMomentum(p),
22  myCharge{charge},
23  myMass{mass},
24  myId{id}
25 {
26 }
27 
29  const XYZTLorentzVector& p,
30  const XYZTLorentzVector& xStart,
31  double mass,
32  double charge) :
33  myMomentum(p),
34  myVertex{xStart},
36  myMass{mass},
37  myId{id}
38 {
39 }
40 
42  const XYZTLorentzVector& xStart,
43  double charge) :
44  myMomentum(p),
45  myVertex{xStart},
47 {
48 }
49 
50 RawParticle::RawParticle(double px, double py, double pz, double e, double charge) :
51  myMomentum(px,py,pz,e),
52  myCharge{charge}
53 {
54 }
55 
56 void
58  myStatus = istat;
59 }
60 
61 void
63  myMass = m;
64 }
65 
66 void
68  myCharge = q;
69 }
70 
71 void
73  myId = -myId;
74  myCharge = -1*myCharge;
75 }
76 
77 void
78 RawParticle::setT(const double t) {
79  myVertex.SetE(t);
80 }
81 
82 void
83 RawParticle::rotate(double angle, const XYZVector& raxis) {
84  Rotation r(raxis,angle);
85  XYZVector v(r * myMomentum.Vect());
86  setMomentum(v.X(),v.Y(),v.Z(),E());
87 }
88 
89 void
90 RawParticle::rotateX(double rphi) {
91  RotationX r(rphi);
92  XYZVector v(r * myMomentum.Vect());
93  setMomentum(v.X(),v.Y(),v.Z(),E());
94 }
95 
96 void
97 RawParticle::rotateY(double rphi) {
98  RotationY r(rphi);
99  XYZVector v(r * myMomentum.Vect());
100  setMomentum(v.X(),v.Y(),v.Z(),E());
101 }
102 
103 void
104 RawParticle::rotateZ(double rphi) {
105  RotationZ r(rphi);
106  XYZVector v(r * myMomentum.Vect());
107  setMomentum(v.X(),v.Y(),v.Z(),E());
108 }
109 
110 void
111 RawParticle::boost(double betax, double betay, double betaz) {
112  Boost b(betax,betay,betaz);
113  XYZTLorentzVector p ( b * momentum() );
114  setMomentum(p.X(),p.Y(),p.Z(),p.T());
115 }
116 
117 
118 std::ostream& operator <<(std::ostream& o , const RawParticle& p) {
119 
120  o.setf(std::ios::fixed, std::ios::floatfield);
121  o.setf(std::ios::right, std::ios::adjustfield);
122 
123 
124  o << std::setw(4) << std::setprecision(2) << p.pid() << " (";
125  o << std::setw(2) << std::setprecision(2) << p.status() << "): ";
126  o << std::setw(10) << std::setprecision(4) << p.momentum() << " ";
127  o << std::setw(10) << std::setprecision(4) << p.vertex();
128  return o;
129 
130 }
131 
132 double
133 RawParticle::et() const {
134  double mypp, tmpEt=-1.;
135 
136  mypp = std::sqrt(momentum().mag2());
137  if ( mypp != 0 ) {
138  tmpEt = E() * pt() / mypp;
139  }
140  return tmpEt;
141 }
142 
void setMomentum(const XYZTLorentzVector &vtx)
set the momentum
Definition: RawParticle.h:347
double pz() const
z of the momentum
Definition: RawParticle.h:321
void setCharge(float q)
set the MEASURED charge
Definition: RawParticle.cc:67
void boost(double bx, double by, double bz)
Definition: RawParticle.cc:111
void rotateZ(double rphi)
Definition: RawParticle.cc:104
std::ostream & operator<<(std::ostream &o, const RawParticle &p)
Definition: RawParticle.cc:118
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
void rotateY(double rphi)
Definition: RawParticle.cc:97
int myId
the particle id number HEP-PID
Definition: RawParticle.h:287
double myMass
the RECONSTRUCTED mass
Definition: RawParticle.h:286
XYZTLorentzVector myMomentum
the four vector of the momentum
Definition: RawParticle.h:283
int pid() const
get the HEP particle ID number
Definition: RawParticle.h:296
void chargeConjugate()
Definition: RawParticle.cc:72
void setT(const double t)
set the time of creation
Definition: RawParticle.cc:78
double mass() const
get the MEASURED mass
Definition: RawParticle.h:314
ROOT::Math::Boost Boost
Definition: RawParticle.h:52
ROOT::Math::RotationZ RotationZ
Definition: RawParticle.h:51
void setMass(float m)
set the RECONSTRUCTED mass
Definition: RawParticle.cc:62
int myStatus
the status code according to PYTHIA
Definition: RawParticle.h:288
ROOT::Math::RotationX RotationX
Definition: RawParticle.h:49
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 myCharge
the MEASURED charge
Definition: RawParticle.h:285
T sqrt(T t)
Definition: SSEVec.h:18
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
ROOT::Math::RotationY RotationY
Definition: RawParticle.h:50
void rotate(double rphi, const XYZVector &raxis)
Definition: RawParticle.cc:83
double charge() const
get the MEASURED charge
Definition: RawParticle.h:313
const XYZTLorentzVector & vertex() const
the vertex fourvector
Definition: RawParticle.h:339
void setStatus(int istat)
Definition: RawParticle.cc:57
double b
Definition: hdecay.h:120
void rotateX(double rphi)
Definition: RawParticle.cc:90
double r() const
vertex radius
Definition: RawParticle.h:311
ROOT::Math::AxisAngle Rotation
Definition: RawParticle.h:47
double E() const
energy of the momentum
Definition: RawParticle.h:325
double px() const
x of the momentum
Definition: RawParticle.h:315
double py() const
y of the momentum
Definition: RawParticle.h:318
math::XYZVector XYZVector
Definition: RawParticle.h:28
RawParticle()=default
double et() const
get the transverse energy
Definition: RawParticle.cc:133
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:27
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11