00001
00002 #ifndef HEPMC_PARTICLE_DATA_H
00003 #define HEPMC_PARTICLE_DATA_H
00004
00006
00007
00008
00009
00010
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #include <iostream>
00050 #include <string>
00051 #include <stdlib.h>
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
00060
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
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;
00128
00129 int m_pdg_id;
00130 int m_3charge;
00131 double m_mass;
00132 double m_clifetime;
00133 unsigned char m_2spin;
00134
00135 static unsigned int s_counter;
00136 };
00137
00139
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
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
00212
00213 inline bool ParticleData::operator==( const ParticleData& a ) const {
00214
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
00224 return ( a.pdg_id() != this->pdg_id() );
00225 }
00226
00227 }
00228
00229 #endif // HEPMC_PARTICLE_DATA_H
00230
00231
00232
00233