StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StParticleDefinition.cc
1 /***************************************************************************
2  *
3  * $Id: StParticleDefinition.cc,v 1.4 2016/07/25 17:45:33 jwebb Exp $
4  *
5  * Author: Thomas Ullrich, May 99 (based on Geant4 code, see below)
6  ***************************************************************************
7  *
8  * The design of the StParticleDefinition class and all concrete
9  * classes derived from it is largely based on the design of the
10  * G4ParticleDefinition class from Geant4 (RD44).
11  * Although the code is in large parts different (modified or rewritten)
12  * and adapted to the STAR framework the basic idea stays the same.
13  *
14  ***************************************************************************
15  *
16  * $Log: StParticleDefinition.cc,v $
17  * Revision 1.4 2016/07/25 17:45:33 jwebb
18  * Init members in ctor / coverity
19  *
20  * Revision 1.3 2009/10/13 18:31:39 perev
21  * Unonimous update
22  *
23  * Revision 1.2 1999/12/07 23:43:04 ullrich
24  * Modified to get rid of warnings on Linux.
25  *
26  * Revision 1.1 1999/05/14 18:48:13 ullrich
27  * Initial Revision
28  *
29  **************************************************************************/
30 #include "StParticleDefinition.hh"
31 #include "StParticleTable.hh"
32 #include "PhysicalConstants.h"
33 // #include <typeinfo>
34 #ifdef __ROOT__
35 ClassImp(StParticleDefinition)
36 #endif
37 
38 StParticleDefinition::StParticleDefinition(
39  const string & aName,
40  double aMass,
41  double aWidth,
42  double aCharge,
43  int aISpin,
44  int aIParity,
45  int aIConjugation,
46  int aIIsospin,
47  int aIIsospin3,
48  int aGParity,
49  const string & aType,
50  int aLepton,
51  int aBaryon,
52  int aEncoding,
53  bool aIsStableFlag,
54  double aLifetime)
55  : mParticleName(aName),
56  mPDGMass(aMass),
57  mPDGWidth(aWidth),
58  mPDGCharge(aCharge),
59  mPDGiSpin(aISpin),
60  mPDGSpin(aISpin*0.5),
61  mPDGiParity(aIParity),
62  mPDGiConjugation(aIConjugation),
63  mPDGiIsospin(aIIsospin),
64  mPDGiIsospin3(aIIsospin3),
65  mPDGIsospin(aIIsospin*0.5),
66  mPDGIsospin3(aIIsospin3*0.5),
67  mPDGiGParity(aGParity),
68  mLeptonNumber(aLepton),
69  mBaryonNumber(aBaryon),
70  mParticleType(aType),
71  mPDGEncoding(aEncoding),
72  mAntiPDGEncoding(-1*aEncoding),
73  mPDGStable(aIsStableFlag),
74  mPDGLifeTime(aLifetime) ,
75  mParticleTable(0)
76 {
77  //
78  // check name and register this particle into ParticleTable
79  //
80  mParticleTable = StParticleTable::particleTable();
81  mParticleTable->insert(this);
82 }
83 
84 StParticleDefinition::StParticleDefinition(const StParticleDefinition&){/* private */}
85 
86 StParticleDefinition::StParticleDefinition() :
87  mParticleName(""),
88  mPDGMass(0),
89  mPDGWidth(0),
90  mPDGCharge(0),
91  mPDGiSpin(0),
92  mPDGSpin(0),
93  mPDGiParity(0),
94  mPDGiConjugation(0),
95  mPDGiIsospin(0),
96  mPDGiIsospin3(0),
97  mPDGIsospin(0),
98  mPDGIsospin3(0),
99  mPDGiGParity(0),
100  mLeptonNumber(0),
101  mBaryonNumber(0),
102  mParticleType(0),
103  mPDGEncoding(0),
104  mAntiPDGEncoding(0),
105  mPDGStable(0),
106  mPDGLifeTime(0) ,
107  mParticleTable(0)
108  {/* private */}
109 
110 StParticleDefinition::~StParticleDefinition() {/* noop */}
111 
113 StParticleDefinition::operator=(const StParticleDefinition& p) {/* private */ return p;}
114 
115 int StParticleDefinition::operator==(const StParticleDefinition &p) const
116 {
117  return (this->mParticleName == p.mParticleName);
118 }
119 
120 int StParticleDefinition::operator!=(const StParticleDefinition &right) const
121 {
122  return !(*this == right);
123 }
124 
125 ostream& operator<<(ostream& os, const StParticleDefinition& p)
126 {
127 // os << '<' << typeid(p).name() << '>' << endl; // needs RTTI
128  os << "Particle Name : " << p.name().c_str() << endl;
129  os << "PDG particle code : " << p.pdgEncoding() << endl;
130  os << "Mass [GeV/c2] : " << p.mass()/GeV << endl;
131  os << "Width [GeV/c2] : " << p.width()/GeV << endl;
132  os << "Lifetime [nsec] : ";
133  if (p.lifeTime() < 0)
134  os << "-";
135  else
136  os << p.lifeTime()/nanosecond;
137  os << endl;
138  os << "Charge [e] : " << p.charge()/eplus << endl;
139  os << "Spin : " << p.iSpin() << "/2" << endl;
140  os << "Parity : " << p.iParity() << endl;
141  os << "Charge conjugation : " << p.iConjugation() << endl;
142  os << "Isospin : (I,Iz): (" << p.iIsospin() <<"/2" << " , " << p.iIsospin3() << "/2 ) " << endl;
143  os << "GParity : " << p.iGParity() << endl;
144  os << "Lepton number : " << p.leptonNumber() << endl;
145  os << "Baryon number : " << p.baryonNumber() << endl;
146  os << "Particle type : " << p.type().c_str() << endl;
147  os << "Is stable : " << (p.stable() ? "yes" : "no") << endl;
148  return os;
149 }
150 
151 
152 
153 
154