1 #include "StarParticleData.h"
4 #include "TDatabasePDG.h"
5 #include "TCollection.h"
11 #include "AgStarParticle.h"
19 Int_t hid( Int_t z, Int_t a, Int_t l=0 )
39 virtual Int_t operator()(Int_t pdgcode)=0;
43 virtual Int_t operator()( Int_t ipdg )
45 int g3id = TDatabasePDG::Instance()->ConvertPdgToGeant3(ipdg);
46 if ( ipdg == 12 || ipdg == -12 ) g3id = 4;
47 if ( ipdg == 14 || ipdg == -14 ) g3id = 4;
48 if ( ipdg == 16 || ipdg == -16 ) g3id = 4;
57 StarParticleData::~StarParticleData()
62 StarParticleData::StarParticleData(
const Char_t *_name,
TDataSet *parent ) :
67 if ( parent ) Shunt(parent);
71 mParticleList.SetOwner();
76 TDatabasePDG *pdg = TDatabasePDG::Instance();
77 pdg -> ReadPDGTable();
85 TIter Next( pdg->ParticleList() );
89 TParticlePDG *particle = 0;
92 while( (particle=(TParticlePDG *)Next()) )
99 TString name = particle->GetName();
100 TString title = particle->GetTitle();
101 Double_t mass = particle->Mass();
102 Bool_t stable = particle->Stable();
103 Double_t width = particle->Width();
104 Double_t charge = particle->Charge();
105 TString class_ = particle->ParticleClass();
107 Int_t code = particle->PdgCode();
108 Int_t anti = 0;
if ( particle->AntiParticle() == particle ) anti = -code;
110 Int_t g3id = G3ID( code );
112 TParticlePDG *myparticle =
new TParticlePDG( name, title, mass, stable, width, charge, class_, code, anti, g3id );
114 mParticleList. Add( myparticle );
115 mParticleNameMap[ name ] = myparticle;
116 mParticleIdMap[ code ] = myparticle;
117 mParticleG3IdMap[ g3id ] = myparticle;
126 AddObject( &mParticleList,
false );
133 AddAlias(
"electron",
"e-");
134 AddAlias(
"positron",
"e+");
135 AddAlias(
"p",
"proton");
136 AddAlias(
"pbar",
"antiproton");
143 TParticlePDG *D =
new TParticlePDG(
"D",
"Deuteron", 0.0,
true, 0., 1.0,
"heavyion", hid(1,2,0), 0, 45 );
144 TParticlePDG *He3 =
new TParticlePDG(
"He3",
"Helium-3", 0.0,
true, 0., 2.0,
"heavyion", hid(2,1,0), 0, 49 );
145 TParticlePDG *Cu =
new TParticlePDG(
"Cu",
"Copper", 0.0,
true, 0., 29,
"heavyion", hid(29,64,0), 0, 0 );
146 TParticlePDG *Au =
new TParticlePDG(
"Au",
"Gold", 0.0,
true, 0., 79,
"heavyion", hid(79,197,0), 0, 0 );
147 TParticlePDG *U =
new TParticlePDG(
"U",
"Uranium", 0.0,
true, 0., 92,
"heavyion", hid(92,238,0), 0, 0 );
150 AddParticle(
"He3", He3);
151 AddParticle(
"Cu", Cu);
152 AddParticle(
"Au", Au);
169 return mParticleNameMap[ name ];
176 return mParticleIdMap[id];
180 return mParticleG3IdMap[id];
187 Int_t code = particle->PdgCode();
188 mParticleList.Add( particle );
189 if ( mParticleNameMap[ name ] ) { Warning(
"AddParticle()", Form(
"Overwriting entry %s",name) ); }
190 mParticleNameMap[ name ] = particle;
191 if ( mParticleIdMap[ code ] ) { Warning(
"AddParticle()", Form(
"Overwriting entry %i",code) ); }
192 mParticleIdMap[code] = particle;
194 mParticleG3IdMap[ G3ID(code) ] = particle;
205 Bool_t stable, Double_t width, Double_t charge3,
const char* particleClass, Int_t PdgCode, Int_t Anti, Int_t geantCode )
208 TParticlePDG *part =
new TParticlePDG(name,title,mass,stable,width,charge3,particleClass,PdgCode,Anti,geantCode);
219 TString name = part->GetName();
220 TString type = part->ParticleClass();
222 double mass = part->Mass();
223 double life = part->Lifetime();
224 double charge = part->Charge() / 3.0;
225 int pdgcode = part->PdgCode();
228 if ( type.Contains(
"meson") || type.Contains(
"baryon") || type.Contains(
"hadron") )
230 if ( charge == 0 ) tracktype = AgStarParticle::kGtNeut;
231 else tracktype = AgStarParticle::kGtHadr;
233 if ( type.Contains(
"photon") || type.Contains(
"gamma") )
235 tracktype = AgStarParticle::kGtGama;
237 if ( type.Contains(
"lepton") )
239 if ( charge == 0 ) tracktype = AgStarParticle::kGtNeut;
240 else tracktype = AgStarParticle::kGtHadr;
242 if ( name ==
"e-" || name ==
"e+" )
244 tracktype = AgStarParticle::kGtElec;
246 if ( name ==
"mu-" || name ==
"mu+" )
248 tracktype = AgStarParticle::kGtMuon;
250 if ( type.Contains(
"heavyion") )
252 tracktype = AgStarParticle::kGtHion;
255 return AddParticleToG3( name.Data(), mass, life, charge, tracktype, pdgcode, g3code );
264 const double lifetime,
269 const double *bratio,
276 static std::map< int, TString > ParticleClass =
289 const double kHbar = 6.58211889e-25;
290 double width = (lifetime > 0 )? kHbar / lifetime : 0.;
291 double charge3 = 3*charge;
293 bool stable = (lifetime<=0);
295 TParticlePDG *part =
AddParticle( name, Form(
"%s [geant3 id=%i]",name,g3code), mass, stable, width, charge3, ParticleClass[type], pdgcode, 0, g3code );
300 if ( bratio ) {
for (
int i=0;i<6;i++ ) fbratio[i] = bratio[i];
301 AgStarParticle::Add( name, g3code, type,
float(mass),
float(charge),
float(lifetime), fbratio, mode, pdgcode );
304 AgStarParticle::Add( name, g3code, type,
float(mass),
float(charge),
float(lifetime), 0, 0, pdgcode );
307 TParticlePDG *myparticle = part;
308 mParticleList. Add( myparticle );
309 mParticleNameMap[ name ] = myparticle;
310 mParticleIdMap[ pdgcode ] = myparticle;
311 mParticleG3IdMap[ g3code ] = myparticle;
332 TString name = particle->GetName();
333 TString title = particle->GetTitle();
334 double mass = particle->Mass();
335 bool stable = particle->Stable();
336 double width = particle->Width();
337 double charge = particle->Charge();
338 TString class_ = particle->ParticleClass();
340 int code = particle->PdgCode();
341 int anti = 0;
if ( particle->AntiParticle() == particle ) anti = -code;
343 TParticlePDG *myparticle =
new TParticlePDG( name, title, mass, stable, width, charge, class_, code, anti, g3id );
345 mParticleList. Add( myparticle );
346 mParticleNameMap[ name ] = myparticle;
347 mParticleIdMap[ code ] = myparticle;
348 mParticleG3IdMap[ g3id ] = myparticle;
357 TParticlePDG* StarParticleData::operator()(
const char* name){
return instance().
GetParticle(name); }
358 TParticlePDG* StarParticleData::operator()(
const int id ){
return instance().
GetParticle(
id ); }
TParticlePDG * GetParticleG3(const Int_t id)
Get a particle by G3 ID.
void AddAlias(const Char_t *alias, const Char_t *realname)
Add an alias to a particle in the database.
static StarParticleData & instance()
Returns a reference to the single instance of this class.
static void Add(const char *name, const int g3id, const int type, const float mass, const float charge, const float lifetime=0., const float *bratio=0, const int *mode=0, const int pdgid=0)
TParticlePDG * GetParticle(const Char_t *name)
Get a particle by name.
Interface to PDG information.
void AddParticle(const Char_t *name, TParticlePDG *particle)
Add a particle to the database.
TParticlePDG * SetTrackingCode(const int pdgid, const int g3id)
Maps the particle with the given PDG id to G3 tracking ID and returns pointer to the particle data...
TParticlePDG * AddParticleToG3(const char *name, const double mass, const double lifetime, const double charge, const int tracktype, const int pdgcode, const int g3code, const double *bratio=0, const int *mode=0)