Fork me on GitHub

source: svn/trunk/Utilities/HepMC/interface/ParticleData.h@ 477

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

first test

File size: 8.5 KB
Line 
1//--------------------------------------------------------------------------
2#ifndef HEPMC_PARTICLE_DATA_H
3#define HEPMC_PARTICLE_DATA_H
4
5//////////////////////////////////////////////////////////////////////////
6// Matt.Dobbs@Cern.CH, September 1999, refer to:
7// M. Dobbs and J.B. Hansen, "The HepMC C++ Monte Carlo Event Record for
8// High Energy Physics", Computer Physics Communications (to be published).
9//
10// GenParticle Data common to all particles of a given PDG id
11//////////////////////////////////////////////////////////////////////////
12//
13// Units ID: defined by PDG group (particles are +ve, antiparticles are -ve)
14// also consistent with the Pythia definitions
15// See: http://d0lblt.lbl.gov/wwwpdg/mc_numbers.htm
16// charge: fraction of proton charge
17// mass in user defined energy units
18// width: ( stored as cLifetime = hbar / Width )
19// cLifetime: c*time
20// spin: fraction of photon spin (always a positive number)
21//
22// Default mass is 0.
23// Default cLifetime is -1 which means stable (setting width = 0 gives this)
24// (we define cLifetime = -1 --> width = 0 (i.e stable),
25// width = -1 --> cLifetime = 0 (i.e. prompt) )
26// These defaults exist because many very basic MC generators
27// may produce only massless stable particles in the event record.
28//
29// It is intended that a different ParticleData object is created for each
30// particle and its anti-particle - useful for CP violation studies.
31//
32// There are few set methods for this class, there should be no reason
33// to change anything after instantiating. If you need to, then
34// create a new object and kill the old one.
35//
36// Example:
37// HepMC::ParticleData* pd_electron =
38// new HepMC::ParticleData("electron",11,-1,0.000511,-1,.5);
39// A method is provided to allow you to set the lifetime from the
40// width in the constructor
41// Example: new HepMC::ParticleData("W+",24,+1,80.396,
42// HepMC::clifetime_from_width(2.06),1);
43// Example of finding a ParticleData object from its PDG ID
44// in ParticleDataTable pdt:
45// HepMC::ParticleData* electron = pdt.find(11);
46// or if you just wanted two know the electron mass, you could do:
47// pdt.find(11)->mass();
48
49#include <iostream>
50#include <string>
51#include <stdlib.h> // for integer abs()
52
53namespace HepMC {
54
55 /// hbar * c --> calculated with units of [mm*GeV]
56 static const double HepMC_hbarc = (6.6260755e-34 * (1.e-6/1.60217733e-19) / (2*3.14159265358979323846))
57 * (2.99792458e+8 * 1000.) * 1.e+3;
58
59 // if you want to instantiate the particle lifetime from its width,
60 // use this static method inside the constructor:
61 double clifetime_from_width( double width ); //!< set lifetime from width
62
63 //! an example ParticleData class
64
65 ///
66 /// \class ParticleData
67 /// Particle Data common to all particles of a given PDG id
68 ///
69 class ParticleData {
70
71 friend std::ostream& operator<<( std::ostream&, const ParticleData& );
72
73 public:
74 /// constructor requiring name, ID, and charge
75 ParticleData( std::string name, int id, double charge, double mass = 0,
76 double cLifetime = -1, double spin = 0 );
77 /// constructor requiring name, ID, and charge
78 ParticleData( const char* name, int id, double charge, double mass = 0,
79 double cLifetime = -1, double spin = 0 );
80 virtual ~ParticleData();
81
82 bool operator==( const ParticleData& ) const; //!< equality
83 bool operator!=( const ParticleData& ) const; //!< inequality
84
85 /// write particle data information to ostr
86 void print( std::ostream& ostr = std::cout ) const;
87
88 bool is_lepton() const; //!< true if charged lepton /neutrino
89 bool is_charged_lepton() const;//!< true if a charged lepton
90 bool is_em() const; //!< true if an electron or photon
91 bool is_neutrino() const; //!< true if a neutrino
92 bool is_hadron() const; //!< true if a hadron
93 bool is_boson() const; //!< true if a gauge or higgs boson
94
95 ////////////////////
96 // access methods //
97 ////////////////////
98
99 /// description of the particle according to PDG, i.e. "Delta(1900) S_31"
100 std::string name() const;
101 /// PDG ID number
102 int pdg_id() const;
103 /// charge
104 double charge() const;
105 /// nominal mass
106 double mass() const;
107 /// width as calculated from clifetime
108 double width() const;
109 /// lifetime in mm
110 double clifetime() const;
111 /// J spin
112 double spin() const;
113
114 void set_charge( double ); //!< set charge
115 void set_mass( double ); //!< set nominal mass
116 void set_width( double ); //!< set width
117 void set_clifetime( double ); //!< set lifetime in mm
118 void set_spin( double ); //!< set J spin
119
120 protected:
121 static unsigned int counter(); //!< num ParticleData objects in memory
122
123 /// omits susy/excited/technicolor digit from returned ID
124 int model_independent_pdg_id_() const;
125
126 private:
127 std::string m_name; // description of the particle according to PDG
128 // i.e. "Delta(1900) S_31"
129 int m_pdg_id; // PDG ID number (note we allow -ve)
130 int m_3charge;// 3*electric charge in units of proton charge
131 double m_mass; // nominal mass in user defined energy units
132 double m_clifetime; // [mm]
133 unsigned char m_2spin; // 2*spin (J) of particle
134
135 static unsigned int s_counter;
136 };
137
138 ///////////////////////////
139 // INLINES //
140 ///////////////////////////
141
142 inline bool ParticleData::is_lepton() const {
143 /// true if a charged lepton or neutrino --> | 11,13,15,12,14,16,17,18 |
144 return ( abs(pdg_id()) >=11 && abs(pdg_id()) <= 18 );
145 }
146 inline bool ParticleData::is_charged_lepton() const {
147 /// true if a charged lepton --> | 11,13,15 |
148 return ( is_lepton() && abs(pdg_id())%2==1 );
149 }
150 inline bool ParticleData::is_neutrino() const {
151 /// true if a neutrino --> | 12,14,16 |
152 return ( is_lepton() && abs(pdg_id())%2==0 );
153 }
154 inline bool ParticleData::is_em() const {
155 /// true if an electron or photon --> | 11, 22 |
156 return ( abs(pdg_id()) == 11 || abs(pdg_id()) == 22 );
157 }
158 inline bool ParticleData::is_hadron() const {
159 /// true if a hadron --> q,g,meson,baryon
160 return ( abs(pdg_id()) <= 9 || abs(pdg_id()) == 21
161 || abs(pdg_id()) >100 );
162 }
163 inline bool ParticleData::is_boson() const {
164 /// true if a gauge or higgs boson --> | 9, 21-39 |
165 return ( ( abs(pdg_id()) >20 && abs(pdg_id()) <=40 )
166 || abs(pdg_id()) == 9 );
167 }
168
169 ///////////////////////////
170 // INLINE Access Methods //
171 ///////////////////////////
172
173 inline std::string ParticleData::name() const { return m_name; }
174 inline int ParticleData::pdg_id() const { return m_pdg_id; }
175 inline double ParticleData::charge() const {
176 return ( (double)m_3charge )/3.;
177 }
178 inline double ParticleData::mass() const { return m_mass; }
179 inline double ParticleData::clifetime() const { return m_clifetime; }
180 inline double ParticleData::spin() const { return m_2spin/2.; }
181 inline void ParticleData::set_charge( double charge ) {
182 if ( charge > 0 ) {
183 m_3charge = (int)(3.*charge+.1);
184 } else if ( charge < 0. ) {
185 m_3charge = (int)(3.*charge-.1);
186 } else {
187 m_3charge = 0;
188 }
189 }
190 inline void ParticleData::set_mass( double its_mass ) {
191 m_mass = its_mass;
192 }
193 inline void ParticleData::set_width( double width ) {
194 if ( width > 0 ) {
195 m_clifetime = HepMC_hbarc/width;
196 } else if ( width == 0. ) {
197 m_clifetime = -1.;
198 } else {
199 m_clifetime = 0.;
200 }
201 }
202 inline void ParticleData::set_clifetime( double its_clifetime ) {
203 m_clifetime = its_clifetime;
204 }
205 inline void ParticleData::set_spin( double spin ) {
206 m_2spin = (unsigned char)(2.*spin+.1);
207 }
208
209 ///////////////////////////
210 // INLINE Operators //
211 ///////////////////////////
212
213 inline bool ParticleData::operator==( const ParticleData& a ) const {
214 // compares everything except the particle's name
215 return ( a.m_pdg_id != m_pdg_id ||
216 a.m_mass != m_mass ||
217 a.m_clifetime != m_clifetime ||
218 a.m_3charge != m_3charge ||
219 a.m_2spin != m_2spin ) ? 0 : 1;
220 }
221
222 inline bool ParticleData::operator!=( const ParticleData& a ) const {
223 // compares everything except the particle's name
224 return ( a.pdg_id() != this->pdg_id() );
225 }
226
227} // HepMC
228
229#endif // HEPMC_PARTICLE_DATA_H
230//--------------------------------------------------------------------------
231
232
233
Note: See TracBrowser for help on using the repository browser.