00001
00002
00003
00004
00006
00007 #include "HepMC/ParticleData.h"
00008 #include <cstdio>
00009
00010 namespace HepMC {
00011
00012 ParticleData::ParticleData( std::string name, int id, double charge,
00013 double mass, double clifetime, double spin ) :
00014 m_name(name), m_pdg_id(id), m_mass(mass), m_clifetime(clifetime)
00015 {
00024
00025 set_charge(charge);
00026 set_spin(spin);
00027 s_counter++;
00028 }
00029
00030 ParticleData::ParticleData( const char* name, int id, double charge,
00031 double mass, double clifetime, double spin ):
00032 m_name(name), m_pdg_id(id), m_mass(mass), m_clifetime(clifetime)
00033 {
00038
00039 set_charge(charge);
00040 set_spin(spin);
00041 s_counter++;
00042 }
00043
00044 ParticleData::~ParticleData() {
00045 s_counter--;
00046 }
00047
00048 void ParticleData::print( std::ostream& ostr ) const {
00049 ostr << "ParticleData: " << name() << "\t"
00050 << " ID[pdg]:" << pdg_id()
00051 << " Charge[e+]:" << charge()
00052 << " Mass:" << mass()
00053 << " Tau:" << clifetime()
00054 << " J:" << spin() << std::endl;
00055 }
00056
00058
00060
00061 int ParticleData::model_independent_pdg_id_() const {
00066 int id = m_pdg_id;
00067 if ( id/1000000 >=1 && id/1000000 <= 4 ) id %= 1000000;
00068 return id;
00069 }
00070
00071 double ParticleData::width() const {
00072 double width;
00073 if ( m_clifetime > 0 ) {
00074 width = HepMC_hbarc/m_clifetime;
00075 } else if ( m_clifetime == 0 ) {
00076 width = -1;
00077 } else {
00078 width = 0;
00079 }
00080 return width;
00081 }
00082
00084
00086 unsigned int ParticleData::counter() { return s_counter; }
00087 unsigned int ParticleData::s_counter = 0;
00088
00090
00092
00094 std::ostream& operator<<( std::ostream& ostr, const ParticleData& pdata ) {
00095 char outline[80];
00096 sprintf( outline,"%+9d%21s%+6.2f%19.11e%19.11e%5.1f",
00097 pdata.pdg_id(),
00098 pdata.name().substr(0,21).c_str(),
00099 pdata.charge(),
00100 pdata.mass(),
00101 pdata.clifetime(),
00102 pdata.spin() );
00103 return ostr << outline;
00104 }
00105
00107
00109
00110 double clifetime_from_width( double width ) {
00113
00114 if ( width > 0 ) return HepMC_hbarc/width;
00115 if ( width == 0. ) return -1.;
00116 return 0.;
00117 }
00118
00119 }
00120
00121
00122
00123
00124
00125
00126