![]() |
HepMC Reference DocumentationHepMC |
00001 //-------------------------------------------------------------------------- 00002 #ifndef HEPMC_PARTICLE_DATA_H 00003 #define HEPMC_PARTICLE_DATA_H 00004 00006 // Matt.Dobbs@Cern.CH, September 1999, refer to: 00007 // M. Dobbs and J.B. Hansen, "The HepMC C++ Monte Carlo Event Record for 00008 // High Energy Physics", Computer Physics Communications (to be published). 00009 // 00010 // GenParticle Data common to all particles of a given PDG id 00012 // 00013 // Units ID: defined by PDG group (particles are +ve, antiparticles are -ve) 00014 // also consistent with the Pythia definitions 00015 // See: http://d0lblt.lbl.gov/wwwpdg/mc_numbers.htm 00016 // charge: fraction of proton charge 00017 // mass in user defined energy units 00018 // width: ( stored as cLifetime = hbar / Width ) 00019 // cLifetime: c*time 00020 // spin: fraction of photon spin (always a positive number) 00021 // 00022 // Default mass is 0. 00023 // Default cLifetime is -1 which means stable (setting width = 0 gives this) 00024 // (we define cLifetime = -1 --> width = 0 (i.e stable), 00025 // width = -1 --> cLifetime = 0 (i.e. prompt) ) 00026 // These defaults exist because many very basic MC generators 00027 // may produce only massless stable particles in the event record. 00028 // 00029 // It is intended that a different ParticleData object is created for each 00030 // particle and its anti-particle - useful for CP violation studies. 00031 // 00032 // There are few set methods for this class, there should be no reason 00033 // to change anything after instantiating. If you need to, then 00034 // create a new object and kill the old one. 00035 // 00036 // Example: 00037 // HepMC::ParticleData* pd_electron = 00038 // new HepMC::ParticleData("electron",11,-1,0.000511,-1,.5); 00039 // A method is provided to allow you to set the lifetime from the 00040 // width in the constructor 00041 // Example: new HepMC::ParticleData("W+",24,+1,80.396, 00042 // HepMC::clifetime_from_width(2.06),1); 00043 // Example of finding a ParticleData object from its PDG ID 00044 // in ParticleDataTable pdt: 00045 // HepMC::ParticleData* electron = pdt.find(11); 00046 // or if you just wanted two know the electron mass, you could do: 00047 // pdt.find(11)->mass(); 00048 00049 #include <iostream> 00050 #include <string> 00051 #include <stdlib.h> // for integer abs() 00052 00053 namespace HepMC { 00054 00056 static const double HepMC_hbarc = (6.6260755e-34 * (1.e-6/1.60217733e-19) / (2*3.14159265358979323846)) 00057 * (2.99792458e+8 * 1000.) * 1.e+3; 00058 00059 // if you want to instantiate the particle lifetime from its width, 00060 // use this static method inside the constructor: 00061 double clifetime_from_width( double width ); 00062 00064 00069 class ParticleData { 00070 00071 friend std::ostream& operator<<( std::ostream&, const ParticleData& ); 00072 00073 public: 00075 ParticleData( std::string name, int id, double charge, double mass = 0, 00076 double cLifetime = -1, double spin = 0 ); 00078 ParticleData( const char* name, int id, double charge, double mass = 0, 00079 double cLifetime = -1, double spin = 0 ); 00080 virtual ~ParticleData(); 00081 00082 bool operator==( const ParticleData& ) const; 00083 bool operator!=( const ParticleData& ) const; 00084 00086 void print( std::ostream& ostr = std::cout ) const; 00087 00088 bool is_lepton() const; 00089 bool is_charged_lepton() const; 00090 bool is_em() const; 00091 bool is_neutrino() const; 00092 bool is_hadron() const; 00093 bool is_boson() const; 00094 00096 // access methods // 00098 00100 std::string name() const; 00102 int pdg_id() const; 00104 double charge() const; 00106 double mass() const; 00108 double width() const; 00110 double clifetime() const; 00112 double spin() const; 00113 00114 void set_charge( double ); 00115 void set_mass( double ); 00116 void set_width( double ); 00117 void set_clifetime( double ); 00118 void set_spin( double ); 00119 00120 protected: 00121 static unsigned int counter(); 00122 00124 int model_independent_pdg_id_() const; 00125 00126 private: 00127 std::string m_name; // description of the particle according to PDG 00128 // i.e. "Delta(1900) S_31" 00129 int m_pdg_id; // PDG ID number (note we allow -ve) 00130 int m_3charge;// 3*electric charge in units of proton charge 00131 double m_mass; // nominal mass in user defined energy units 00132 double m_clifetime; // [mm] 00133 unsigned char m_2spin; // 2*spin (J) of particle 00134 00135 static unsigned int s_counter; 00136 }; 00137 00139 // INLINES // 00141 00142 inline bool ParticleData::is_lepton() const { 00144 return ( abs(pdg_id()) >=11 && abs(pdg_id()) <= 18 ); 00145 } 00146 inline bool ParticleData::is_charged_lepton() const { 00148 return ( is_lepton() && abs(pdg_id())%2==1 ); 00149 } 00150 inline bool ParticleData::is_neutrino() const { 00152 return ( is_lepton() && abs(pdg_id())%2==0 ); 00153 } 00154 inline bool ParticleData::is_em() const { 00156 return ( abs(pdg_id()) == 11 || abs(pdg_id()) == 22 ); 00157 } 00158 inline bool ParticleData::is_hadron() const { 00160 return ( abs(pdg_id()) <= 9 || abs(pdg_id()) == 21 00161 || abs(pdg_id()) >100 ); 00162 } 00163 inline bool ParticleData::is_boson() const { 00165 return ( ( abs(pdg_id()) >20 && abs(pdg_id()) <=40 ) 00166 || abs(pdg_id()) == 9 ); 00167 } 00168 00170 // INLINE Access Methods // 00172 00173 inline std::string ParticleData::name() const { return m_name; } 00174 inline int ParticleData::pdg_id() const { return m_pdg_id; } 00175 inline double ParticleData::charge() const { 00176 return ( (double)m_3charge )/3.; 00177 } 00178 inline double ParticleData::mass() const { return m_mass; } 00179 inline double ParticleData::clifetime() const { return m_clifetime; } 00180 inline double ParticleData::spin() const { return m_2spin/2.; } 00181 inline void ParticleData::set_charge( double charge ) { 00182 if ( charge > 0 ) { 00183 m_3charge = (int)(3.*charge+.1); 00184 } else if ( charge < 0. ) { 00185 m_3charge = (int)(3.*charge-.1); 00186 } else { 00187 m_3charge = 0; 00188 } 00189 } 00190 inline void ParticleData::set_mass( double its_mass ) { 00191 m_mass = its_mass; 00192 } 00193 inline void ParticleData::set_width( double width ) { 00194 if ( width > 0 ) { 00195 m_clifetime = HepMC_hbarc/width; 00196 } else if ( width == 0. ) { 00197 m_clifetime = -1.; 00198 } else { 00199 m_clifetime = 0.; 00200 } 00201 } 00202 inline void ParticleData::set_clifetime( double its_clifetime ) { 00203 m_clifetime = its_clifetime; 00204 } 00205 inline void ParticleData::set_spin( double spin ) { 00206 m_2spin = (unsigned char)(2.*spin+.1); 00207 } 00208 00210 // INLINE Operators // 00212 00213 inline bool ParticleData::operator==( const ParticleData& a ) const { 00214 // compares everything except the particle's name 00215 return ( a.m_pdg_id != m_pdg_id || 00216 a.m_mass != m_mass || 00217 a.m_clifetime != m_clifetime || 00218 a.m_3charge != m_3charge || 00219 a.m_2spin != m_2spin ) ? 0 : 1; 00220 } 00221 00222 inline bool ParticleData::operator!=( const ParticleData& a ) const { 00223 // compares everything except the particle's name 00224 return ( a.pdg_id() != this->pdg_id() ); 00225 } 00226 00227 } // HepMC 00228 00229 #endif // HEPMC_PARTICLE_DATA_H 00230 //-------------------------------------------------------------------------- 00231 00232 00233