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 
13 RawParticle::RawParticle(const XYZTLorentzVector& p) : myMomentum(p) {}
14 
15 RawParticle::RawParticle(const int id, const XYZTLorentzVector& p, double mass, double charge)
16  : myMomentum(p), myCharge{charge}, myMass{mass}, myId{id} {}
17 
19  const int id, const XYZTLorentzVector& p, const XYZTLorentzVector& xStart, double mass, double charge)
20  : myMomentum(p), myVertex{xStart}, myCharge{charge}, myMass{mass}, myId{id} {}
21 
23  : myMomentum(p), myVertex{xStart}, myCharge{charge} {}
24 
25 RawParticle::RawParticle(double px, double py, double pz, double e, double charge)
26  : myMomentum(px, py, pz, e), myCharge{charge} {}
27 
28 void RawParticle::setStatus(int istat) { myStatus = istat; }
29 
30 void RawParticle::setMass(float m) { myMass = m; }
31 
32 void RawParticle::setCharge(float q) { myCharge = q; }
33 
35  myId = -myId;
36  myCharge = -1 * myCharge;
37 }
38 
39 void RawParticle::setT(const double t) { myVertex.SetE(t); }
40 
41 void RawParticle::rotate(double angle, const XYZVector& raxis) {
42  Rotation r(raxis, angle);
43  XYZVector v(r * myMomentum.Vect());
44  setMomentum(v.X(), v.Y(), v.Z(), E());
45 }
46 
47 void RawParticle::rotateX(double rphi) {
48  RotationX r(rphi);
49  XYZVector v(r * myMomentum.Vect());
50  setMomentum(v.X(), v.Y(), v.Z(), E());
51 }
52 
53 void RawParticle::rotateY(double rphi) {
54  RotationY r(rphi);
55  XYZVector v(r * myMomentum.Vect());
56  setMomentum(v.X(), v.Y(), v.Z(), E());
57 }
58 
59 void RawParticle::rotateZ(double rphi) {
60  RotationZ r(rphi);
61  XYZVector v(r * myMomentum.Vect());
62  setMomentum(v.X(), v.Y(), v.Z(), E());
63 }
64 
65 void RawParticle::boost(double betax, double betay, double betaz) {
66  Boost b(betax, betay, betaz);
68  setMomentum(p.X(), p.Y(), p.Z(), p.T());
69 }
70 
71 std::ostream& operator<<(std::ostream& o, const RawParticle& p) {
72  o.setf(std::ios::fixed, std::ios::floatfield);
73  o.setf(std::ios::right, std::ios::adjustfield);
74 
75  o << std::setw(4) << std::setprecision(2) << p.pid() << " (";
76  o << std::setw(2) << std::setprecision(2) << p.status() << "): ";
77  o << std::setw(10) << std::setprecision(4) << p.momentum() << " ";
78  o << std::setw(10) << std::setprecision(4) << p.vertex();
79  return o;
80 }
81 
82 double RawParticle::et() const {
83  double mypp, tmpEt = -1.;
84 
85  mypp = std::sqrt(momentum().mag2());
86  if (mypp != 0) {
87  tmpEt = E() * pt() / mypp;
88  }
89  return tmpEt;
90 }
void setMomentum(const XYZTLorentzVector &vtx)
set the momentum
Definition: RawParticle.h:328
double pz() const
z of the momentum
Definition: RawParticle.h:302
void setCharge(float q)
set the MEASURED charge
Definition: RawParticle.cc:32
void boost(double bx, double by, double bz)
Definition: RawParticle.cc:65
void rotateZ(double rphi)
Definition: RawParticle.cc:59
std::ostream & operator<<(std::ostream &o, const RawParticle &p)
Definition: RawParticle.cc:71
XYZTLorentzVector myVertex
the four vector of the vertex
Definition: RawParticle.h:267
double pt() const
transverse momentum
Definition: RawParticle.h:309
int status() const
get the particle status
Definition: RawParticle.h:278
void rotateY(double rphi)
Definition: RawParticle.cc:53
int myId
the particle id number HEP-PID
Definition: RawParticle.h:270
double myMass
the RECONSTRUCTED mass
Definition: RawParticle.h:269
XYZTLorentzVector myMomentum
the four vector of the momentum
Definition: RawParticle.h:266
int pid() const
get the HEP particle ID number
Definition: RawParticle.h:277
void chargeConjugate()
Definition: RawParticle.cc:34
void setT(const double t)
set the time of creation
Definition: RawParticle.cc:39
double mass() const
get the MEASURED mass
Definition: RawParticle.h:295
ROOT::Math::Boost Boost
Definition: RawParticle.h:49
ROOT::Math::RotationZ RotationZ
Definition: RawParticle.h:48
void setMass(float m)
set the RECONSTRUCTED mass
Definition: RawParticle.cc:30
int myStatus
the status code according to PYTHIA
Definition: RawParticle.h:271
ROOT::Math::RotationX RotationX
Definition: RawParticle.h:46
const XYZTLorentzVector & momentum() const
the momentum fourvector
Definition: RawParticle.h:321
double t() const
vertex time
Definition: RawParticle.h:285
double e() const
energy of the momentum
Definition: RawParticle.h:305
double myCharge
the MEASURED charge
Definition: RawParticle.h:268
T sqrt(T t)
Definition: SSEVec.h:19
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
ROOT::Math::RotationY RotationY
Definition: RawParticle.h:47
void rotate(double rphi, const XYZVector &raxis)
Definition: RawParticle.cc:41
double charge() const
get the MEASURED charge
Definition: RawParticle.h:294
const XYZTLorentzVector & vertex() const
the vertex fourvector
Definition: RawParticle.h:320
void setStatus(int istat)
Definition: RawParticle.cc:28
double b
Definition: hdecay.h:118
void rotateX(double rphi)
Definition: RawParticle.cc:47
double r() const
vertex radius
Definition: RawParticle.h:292
ROOT::Math::AxisAngle Rotation
Definition: RawParticle.h:44
double E() const
energy of the momentum
Definition: RawParticle.h:306
double px() const
x of the momentum
Definition: RawParticle.h:296
double py() const
y of the momentum
Definition: RawParticle.h:299
math::XYZVector XYZVector
Definition: RawParticle.h:26
RawParticle()=default
double et() const
get the transverse energy
Definition: RawParticle.cc:82
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:25
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11