CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // -----------------------------------------------------------------------------
11 
12 #include <iostream>
13 #include <iomanip>
14 #include <cmath>
15 
16 //using namespace HepPDT;
17 
19  tab( ParticleTable::instance() ) {
20  init();
21 }
22 
24  : XYZTLorentzVector(p), tab( ParticleTable::instance() ) {
25  init();
26 }
27 
29  const XYZTLorentzVector& p)
30  : XYZTLorentzVector(p), tab( ParticleTable::instance() ) {
31  this->init();
32  this->setID(id);
33 }
34 
36  const XYZTLorentzVector& p)
37  : XYZTLorentzVector(p), tab( ParticleTable::instance() ) {
38  this->init();
39  this->setID(name);
40 }
41 
43  const XYZTLorentzVector& xStart) :
45 {
46  init();
47  myVertex = xStart;
48 }
49 
50 RawParticle::RawParticle(double px, double py, double pz, double e) :
51  XYZTLorentzVector(px,py,pz,e), tab( ParticleTable::instance() )
52 {
53  init();
54 }
55 
57  XYZTLorentzVector(right.Px(),right.Py(),right.Pz(),right.E()),
58  tab( ParticleTable::instance() )
59 {
60  myId = right.myId;
61  myStatus = right.myStatus;
62  myUsed = right.myUsed;
63  myCharge = right.myCharge;
64  myMass = right.myMass;
65  myVertex = (right.myVertex);
66  myInfo = (right.myInfo);
67 }
68 
70  // nParticles--;
71 }
72 
75  // cout << "Copy assignment " << endl;
76  if (this != &right) { // don't copy into yourself
77  this->SetXYZT(right.Px(),right.Py(),right.Pz(),right.E());
78  myId = right.myId;
79  myStatus = right.myStatus;
80  myUsed = right.myUsed;
81  myCharge = right.myCharge;
82  myMass = right.myMass;
83  myVertex = right.myVertex;
85  myInfo = right.myInfo;
86  }
87  return *this;
88 }
89 
90 void
92  myId=0;
93  myStatus=99;
94  myUsed=0;
95  myCharge=0.;
96  myMass=0.;
97  //tab = ParticleTable::instance();
98  myInfo=0;
99 }
100 
101 void
102 RawParticle::setID(const int id) {
103  myId = id;
104  if ( tab ) {
105  if ( !myInfo )
106  myInfo = tab->theTable()->particle(HepPDT::ParticleID(myId));
107  if ( myInfo ) {
108  myCharge = myInfo->charge();
109  myMass = myInfo->mass().value();
110  }
111  }
112 }
113 
114 void
116  if ( tab ) {
117  if ( !myInfo ) myInfo = tab->theTable()->particle(name);
118  if ( myInfo ) {
119  myId = myInfo->pid();
120  myCharge = myInfo->charge();
121  myMass = myInfo->mass().value();
122  } else {
123  myId = 0;
124  }
125  }
126 }
127 
128 void
130  myStatus = istat;
131 }
132 
133 void
135  myMass = m;
136 }
137 
138 void
140  myCharge = q;
141 }
142 
143 void
145  myId = -myId;
146  myCharge = -1*myCharge;
147 }
148 
149 void
150 RawParticle::setT(const double t) {
151  myVertex.SetE(t);
152 }
153 
154 void
155 RawParticle::rotate(double angle, const XYZVector& raxis) {
156  Rotation r(raxis,angle);
157  XYZVector v(r * Vect());
158  SetXYZT(v.X(),v.Y(),v.Z(),E());
159 }
160 
161 void
162 RawParticle::rotateX(double rphi) {
163  RotationX r(rphi);
164  XYZVector v(r * Vect());
165  SetXYZT(v.X(),v.Y(),v.Z(),E());
166 }
167 
168 void
169 RawParticle::rotateY(double rphi) {
170  RotationY r(rphi);
171  XYZVector v(r * Vect());
172  SetXYZT(v.X(),v.Y(),v.Z(),E());
173 }
174 
175 void
176 RawParticle::rotateZ(double rphi) {
177  RotationZ r(rphi);
178  XYZVector v(r * Vect());
179  SetXYZT(v.X(),v.Y(),v.Z(),E());
180 }
181 
182 void
183 RawParticle::boost(double betax, double betay, double betaz) {
184  Boost b(betax,betay,betaz);
185  XYZTLorentzVector p ( b * momentum() );
186  SetXYZT(p.X(),p.Y(),p.Z(),p.T());
187 }
188 
190  std::string MyParticleName;
191  if ( tab && myInfo ) {
192  MyParticleName = myInfo->name();
193  } else {
194  MyParticleName = "unknown ";
195  }
196  return (std::string) MyParticleName;}
197 
198 
199 void
201  std::string MyParticleName = PDGname();
202  if (MyParticleName.length() != 0) {
203  std::cout << MyParticleName;
204  for(unsigned int k=0;k<9-MyParticleName.length() && k<10; k++)
205  std::cout << " " ;
206  } else {
207  std::cout << "unknown ";
208  }
209 }
210 
211 void
213  printName();
214  std::cout << std::setw(3) << status();
215  std::cout.setf(std::ios::fixed, std::ios::floatfield);
216  std::cout.setf(std::ios::right, std::ios::adjustfield);
217  std::cout << std::setw(8) << std::setprecision(2) << Px();
218  std::cout << std::setw(8) << std::setprecision(2) << Py();
219  std::cout << std::setw(8) << std::setprecision(2) << Pz();
220  std::cout << std::setw(8) << std::setprecision(2) << E();
221  std::cout << std::setw(8) << std::setprecision(2) << M();
222  std::cout << std::setw(8) << std::setprecision(2) << mass();
223  std::cout << std::setw(8) << std::setprecision(2) << charge();
224  std::cout << std::setw(8) << std::setprecision(2) << X();
225  std::cout << std::setw(8) << std::setprecision(2) << Y();
226  std::cout << std::setw(8) << std::setprecision(2) << Z();
227  std::cout << std::setw(8) << std::setprecision(2) << T();
228  std::cout << std::setw(0) << std::endl;
229 }
230 
231 std::ostream& operator <<(std::ostream& o , const RawParticle& p) {
232 
233  o.setf(std::ios::fixed, std::ios::floatfield);
234  o.setf(std::ios::right, std::ios::adjustfield);
235 
236 
237  o << std::setw(4) << std::setprecision(2) << p.pid() << " (";
238  o << std::setw(2) << std::setprecision(2) << p.status() << "): ";
239  o << std::setw(10) << std::setprecision(4) << p.momentum() << " ";
240  o << std::setw(10) << std::setprecision(4) << p.vertex();
241  return o;
242 
243 }
244 
245 double
247  double q=-99999;
248  if ( myInfo ) {
249  q=myInfo->charge();
250  }
251  return q;
252 }
253 
254 double
256  double m=-99999;
257  if ( myInfo ) {
258  m = myInfo->mass().value();
259  }
260  return m;
261 }
262 
263 double
265  double ct=1E99;
266  if ( myInfo ) {
267 
268  // The lifetime is 0. in the Pythia Particle Data Table !
269  // ct=tab->theTable()->particle(ParticleID(myId))->lifetime().value();
270 
271  // Get it from the width (apparently Gamma/c!)
272  double w = myInfo->totalWidth().value();
273  if ( w != 0. && myId != 1000022 ) {
274  ct = 6.582119e-25 / w / 10.; // ctau in cm
275  } else {
276  // Temporary fix of a bug in the particle data table
277  unsigned amyId = abs(myId);
278  if ( amyId != 22 && // photon
279  amyId != 11 && // e+/-
280  amyId != 10 && // nu_e
281  amyId != 12 && // nu_mu
282  amyId != 14 && // nu_tau
283  amyId != 1000022 && // Neutralino
284  amyId != 1000039 && // Gravitino
285  amyId != 2112 && // neutron/anti-neutron
286  amyId != 2212 && // proton/anti-proton
287  amyId != 101 && // Deutreron etc..
288  amyId != 102 && // Deutreron etc..
289  amyId != 103 && // Deutreron etc..
290  amyId != 104 ) { // Deutreron etc..
291  ct = 0.;
292  /* */
293  }
294  }
295  }
296 
297  /*
298  std::cout << setw(20) << setprecision(18)
299  << "myId/ctau/width = " << myId << " "
300  << ct << " " << w << endl;
301  */
302 
303  return ct;
304 }
305 
306 double
307 RawParticle::et() const {
308  double mypp, tmpEt=-1.;
309 
310  mypp = std::sqrt(momentum().mag2());
311  if ( mypp != 0 ) {
312  tmpEt = E() * pt() / mypp;
313  }
314  return tmpEt;
315 }
void setCharge(float q)
set the MEASURED charge
Definition: RawParticle.cc:139
const ParticleTable * tab
Definition: RawParticle.h:259
tuple t
Definition: tree.py:139
void boost(double bx, double by, double bz)
Definition: RawParticle.cc:183
void rotateZ(double rphi)
Definition: RawParticle.cc:176
XYZTLorentzVector myVertex
the four vector of the vertex
Definition: RawParticle.h:250
int status() const
get the particle status
Definition: RawParticle.h:266
void rotateY(double rphi)
Definition: RawParticle.cc:169
const double w
Definition: UKUtility.cc:23
int myId
the particle id number HEP-PID
Definition: RawParticle.h:251
static PFTauRenderPlugin instance
void printName() const
Definition: RawParticle.cc:200
double PDGmass() const
get the THEORETICAL mass
Definition: RawParticle.cc:255
double PDGcTau() const
get the THEORETICAL lifetime
Definition: RawParticle.cc:264
double myMass
the RECONSTRUCTED mass
Definition: RawParticle.h:255
static ParticleTable *const instance()
Definition: ParticleTable.h:30
int pid() const
get the HEP particle ID number
Definition: RawParticle.h:265
void chargeConjugate()
Definition: RawParticle.cc:144
void setT(const double t)
set the time of creation
Definition: RawParticle.cc:150
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
double mass() const
get the MEASURED mass
Definition: RawParticle.h:283
ROOT::Math::Boost Boost
Definition: RawParticle.h:40
ROOT::Math::RotationZ RotationZ
Definition: RawParticle.h:39
void setMass(float m)
set the RECONSTRUCTED mass
Definition: RawParticle.cc:134
int myStatus
the status code according to PYTHIA
Definition: RawParticle.h:252
double PDGcharge() const
get the THEORETICAL charge
Definition: RawParticle.cc:246
ROOT::Math::RotationX RotationX
Definition: RawParticle.h:37
const XYZTLorentzVector & momentum() const
the momentum fourvector
Definition: RawParticle.h:286
virtual ~RawParticle()
Definition: RawParticle.cc:69
math::XYZVector XYZVector
double myCharge
the MEASURED charge
Definition: RawParticle.h:254
T sqrt(T t)
Definition: SSEVec.h:48
void print() const
Definition: RawParticle.cc:212
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
double Y() const
y of vertex
Definition: RawParticle.h:275
void setID(const int id)
Definition: RawParticle.cc:102
double Z() const
z of vertex
Definition: RawParticle.h:276
ROOT::Math::RotationY RotationY
Definition: RawParticle.h:38
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const HepPDT::ParticleDataTable * theTable() const
Get the pointer to the particle data table.
Definition: ParticleTable.h:26
void rotate(double rphi, const XYZVector &raxis)
Definition: RawParticle.cc:155
double charge() const
get the MEASURED charge
Definition: RawParticle.h:282
int myUsed
status of the locking
Definition: RawParticle.h:253
const XYZTLorentzVector & vertex() const
the vertex fourvector
Definition: RawParticle.h:285
void setStatus(int istat)
Definition: RawParticle.cc:129
double b
Definition: hdecay.h:120
void rotateX(double rphi)
Definition: RawParticle.cc:162
double r() const
vertex radius
Definition: RawParticle.h:280
double X() const
x of vertex
Definition: RawParticle.h:274
std::string PDGname() const
get the PDG name
Definition: RawParticle.cc:189
ROOT::Math::AxisAngle Rotation
Definition: RawParticle.h:35
tuple cout
Definition: gather_cfg.py:121
double T() const
vertex time
Definition: RawParticle.h:277
const ParticleData * myInfo
The pointer to the PDG info.
Definition: RawParticle.h:256
RawParticle & operator=(const RawParticle &rhs)
Definition: RawParticle.cc:74
void init()
Definition: RawParticle.cc:91
double et() const
get the transverse energy
Definition: RawParticle.cc:307
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:15
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11