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