Fork me on GitHub

source: svn/trunk/Utilities/HepMC/src/ParticleData.cc@ 408

Last change on this file since 408 was 349, checked in by severine ovyn, 16 years ago

first test

File size: 3.4 KB
Line 
1//////////////////////////////////////////////////////////////////////////
2// Matt.Dobbs@Cern.CH, September 1999
3//
4// particle properties common to all particles of a given PDG id
5//////////////////////////////////////////////////////////////////////////
6
7#include "ParticleData.h"
8#include <cstdio> // needed for formatted output using sprintf
9
10namespace HepMC {
11
12 ParticleData::ParticleData( std::string name, int id, double charge,
13 double mass, double clifetime, double spin ) :
14 m_name(name), m_pdg_id(id), m_mass(mass), m_clifetime(clifetime)
15 {
16 /// Units ID: defined by PDG group (particles are +ve, antipart are -ve)
17 /// also consistent with the Pythia definitions
18 /// charge: fraction of proton charge
19 /// mass
20 /// cLifetime: c*time
21 /// Default mass=0 and cLifetime is -1 which means stable (width= 0.)
22 /// These defaults exist because many very basic MC generators
23 /// may produce only massless stable particles in the event record.
24 //
25 set_charge(charge);
26 set_spin(spin);
27 s_counter++;
28 }
29
30 ParticleData::ParticleData( const char* name, int id, double charge,
31 double mass, double clifetime, double spin ):
32 m_name(name), m_pdg_id(id), m_mass(mass), m_clifetime(clifetime)
33 {
34 /// note, this constructor is redundant to the one above,
35 /// i.e. one could use:
36 /// new HepMC::ParticleData(string("electron"),11,-1,0.000511,-1,.5);
37 /// but we keep it because it is convenient.
38 //
39 set_charge(charge);
40 set_spin(spin);
41 s_counter++;
42 }
43
44 ParticleData::~ParticleData() {
45 s_counter--;
46 }
47
48 void ParticleData::print( std::ostream& ostr ) const {
49 ostr << "ParticleData: " << name() << "\t"
50 << " ID[pdg]:" << pdg_id()
51 << " Charge[e+]:" << charge()
52 << " Mass:" << mass()
53 << " Tau:" << clifetime()
54 << " J:" << spin() << std::endl;
55 }
56
57 ////////////////////
58 // access methods //
59 ////////////////////
60
61 int ParticleData::model_independent_pdg_id_() const {
62 /// returns the particle id with the seventh
63 /// digit removed for susy/excited/technicolor particles.
64 /// Thus en excited electron (40000011) would be returned as 11
65 /// Useful only internally for sorting particles!
66 int id = m_pdg_id;
67 if ( id/1000000 >=1 && id/1000000 <= 4 ) id %= 1000000;
68 return id;
69 }
70
71 double ParticleData::width() const {
72 double width;
73 if ( m_clifetime > 0 ) {
74 width = HepMC_hbarc/m_clifetime;
75 } else if ( m_clifetime == 0 ) {
76 width = -1;
77 } else {
78 width = 0;
79 }
80 return width;
81 }
82
83 /////////////
84 // Static //
85 /////////////
86 unsigned int ParticleData::counter() { return s_counter; }
87 unsigned int ParticleData::s_counter = 0;
88
89 /////////////
90 // Friends //
91 /////////////
92
93 /// write to ostr
94 std::ostream& operator<<( std::ostream& ostr, const ParticleData& pdata ) {
95 char outline[80];
96 sprintf( outline,"%+9d%21s%+6.2f%19.11e%19.11e%5.1f",
97 pdata.pdg_id(),
98 pdata.name().substr(0,21).c_str(),
99 pdata.charge(),
100 pdata.mass(),
101 pdata.clifetime(),
102 pdata.spin() );
103 return ostr << outline;
104 }
105
106 //////////////////////
107 // Related Methods //
108 //////////////////////
109
110 double clifetime_from_width( double width ) {
111 /// if you want to instantiate the particle lifetime from its width,
112 /// use this static method inside the constructor:
113 // i.e. new ParticleData(
114 if ( width > 0 ) return HepMC_hbarc/width;
115 if ( width == 0. ) return -1.;
116 return 0.;
117 }
118
119} // HepMC
120
121
122
123
124
125
126
Note: See TracBrowser for help on using the repository browser.