ROOT  6.06/09
Reference Guide
TDatabasePDG.cxx
Go to the documentation of this file.
1 // @(#)root/eg:$Id$
2 // Author: Pasha Murat 12/02/99
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "RConfigure.h"
13 #include "TROOT.h"
14 #include "TEnv.h"
15 #include "THashList.h"
16 #include "TExMap.h"
17 #include "TSystem.h"
18 #include "TDatabasePDG.h"
19 #include "TDecayChannel.h"
20 #include "TParticlePDG.h"
21 #include <stdlib.h>
22 
23 
24 ////////////////////////////////////////////////////////////////////////
25 //
26 // Particle database manager class
27 //
28 // This manager creates a list of particles which by default is
29 // initialised from with the constants used by PYTHIA6 (plus some
30 // other particles added). See definition and the format of the default
31 // particle list in $ROOTSYS/etc/pdg_table.txt
32 //
33 // there are 2 ways of redefining the name of the file containing the
34 // particle properties
35 //
36 // 1. one can define the name in .rootrc file:
37 //
38 // Root.DatabasePDG: $(HOME)/my_pdg_table.txt
39 //
40 // 2. one can use TDatabasePDG::ReadPDGTable method explicitly:
41 //
42 // - TDatabasePDG *pdg = new TDatabasePDG();
43 // - pdg->ReadPDGtable(filename)
44 //
45 // See TParticlePDG for the description of a static particle properties.
46 // See TParticle for the description of a dynamic particle particle.
47 //
48 ////////////////////////////////////////////////////////////////////////
49 
51 
52 TDatabasePDG* TDatabasePDG::fgInstance = 0;
53 
54 ////////////////////////////////////////////////////////////////////////////////
55 /// Create PDG database. Initialization of the DB has to be done via explicit
56 /// call to ReadDataBasePDG (also done by GetParticle methods)
57 
58 TDatabasePDG::TDatabasePDG(): TNamed("PDGDB","The PDG particle data base")
59 {
60  fParticleList = 0;
61  fPdgMap = 0;
62  fListOfClasses = 0;
63  if (fgInstance) {
64  Warning("TDatabasePDG", "object already instantiated");
65  } else {
66  fgInstance = this;
67  gROOT->GetListOfSpecials()->Add(this);
68  }
69 }
70 
71 ////////////////////////////////////////////////////////////////////////////////
72 /// Cleanup the PDG database.
73 
75 {
76  if (fParticleList) {
78  delete fParticleList; // this deletes all objects in the list
79  if (fPdgMap) delete fPdgMap;
80  }
81  // classes do not own particles...
82  if (fListOfClasses) {
84  delete fListOfClasses;
85  }
86  if (gROOT && !gROOT->TestBit(TObject::kInvalidObject))
87  gROOT->GetListOfSpecials()->Remove(this);
88  fgInstance = 0;
89 }
90 
91 ////////////////////////////////////////////////////////////////////////////////
92 ///static function
93 
95 {
96  return (fgInstance) ? (TDatabasePDG*) fgInstance : new TDatabasePDG();
97 }
98 
99 ////////////////////////////////////////////////////////////////////////////////
100 /// Build fPdgMap mapping pdg-code to particle.
101 ///
102 /// Initial size is set so as to be able to hold at least 600
103 /// particles: 521 in default table, ALICE adds 54 more.
104 /// To be revisited after LHC discovers SUSY.
105 
107 {
108  fPdgMap = new TExMap(4*TMath::Max(600, fParticleList->GetEntries())/3 + 3);
110  TParticlePDG *p;
111  while ((p = (TParticlePDG*)next())) {
112  fPdgMap->Add((Long_t)p->PdgCode(), (Long_t)p);
113  }
114 }
115 
116 ////////////////////////////////////////////////////////////////////////////////
117 ///
118 /// Particle definition normal constructor. If the particle is set to be
119 /// stable, the decay width parameter does have no meaning and can be set to
120 /// any value. The parameters granularity, LowerCutOff and HighCutOff are
121 /// used for the construction of the mean free path look up tables. The
122 /// granularity will be the number of logwise energy points for which the
123 /// mean free path will be calculated.
124 ///
125 
126 TParticlePDG* TDatabasePDG::AddParticle(const char *name, const char *title,
127  Double_t mass, Bool_t stable,
128  Double_t width, Double_t charge,
129  const char* ParticleClass,
130  Int_t PDGcode,
131  Int_t Anti,
132  Int_t TrackingCode)
133 {
134  TParticlePDG* old = GetParticle(PDGcode);
135 
136  if (old) {
137  printf(" *** TDatabasePDG::AddParticle: particle with PDGcode=%d already defined\n",PDGcode);
138  return 0;
139  }
140 
141  TParticlePDG* p = new TParticlePDG(name, title, mass, stable, width,
142  charge, ParticleClass, PDGcode, Anti,
143  TrackingCode);
144  fParticleList->Add(p);
145  if (fPdgMap)
146  fPdgMap->Add((Long_t)PDGcode, (Long_t)p);
147 
148  TParticleClassPDG* pclass = GetParticleClass(ParticleClass);
149 
150  if (!pclass) {
151  pclass = new TParticleClassPDG(ParticleClass);
152  fListOfClasses->Add(pclass);
153  }
154 
155  pclass->AddParticle(p);
156 
157  return p;
158 }
159 
160 ////////////////////////////////////////////////////////////////////////////////
161 /// assuming particle has already been defined
162 
164 {
165  TParticlePDG* old = GetParticle(PdgCode);
166 
167  if (old) {
168  printf(" *** TDatabasePDG::AddAntiParticle: can't redefine parameters\n");
169  return NULL;
170  }
171 
172  Int_t pdg_code = abs(PdgCode);
173  TParticlePDG* p = GetParticle(pdg_code);
174 
175  if (!p) {
176  printf(" *** TDatabasePDG::AddAntiParticle: particle with pdg code %d not known\n", pdg_code);
177  return NULL;
178  }
179 
180  TParticlePDG* ap = AddParticle(Name,
181  Name,
182  p->Mass(),
183  1,
184  p->Width(),
185  -p->Charge(),
186  p->ParticleClass(),
187  PdgCode,
188  1,
189  p->TrackingCode());
190  return ap;
191 }
192 
193 
194 ////////////////////////////////////////////////////////////////////////////////
195 ///
196 /// Get a pointer to the particle object according to the name given
197 ///
198 
200 {
201  if (fParticleList == 0) ((TDatabasePDG*)this)->ReadPDGTable();
202 
204 // if (!def) {
205 // Error("GetParticle","No match for %s exists!",name);
206 // }
207  return def;
208 }
209 
210 ////////////////////////////////////////////////////////////////////////////////
211 ///
212 /// Get a pointer to the particle object according to the MC code number
213 ///
214 
216 {
217  if (fParticleList == 0) ((TDatabasePDG*)this)->ReadPDGTable();
218  if (fPdgMap == 0) BuildPdgMap();
219 
220  return (TParticlePDG*) (Long_t)fPdgMap->GetValue((Long_t)PDGcode);
221 }
222 
223 ////////////////////////////////////////////////////////////////////////////////
224 /// Print contents of PDG database.
225 
226 void TDatabasePDG::Print(Option_t *option) const
227 {
228  if (fParticleList == 0) ((TDatabasePDG*)this)->ReadPDGTable();
229 
231  TParticlePDG *p;
232  while ((p = (TParticlePDG *)next())) {
233  p->Print(option);
234  }
235 }
236 
237 ////////////////////////////////////////////////////////////////////////////////
238 /// Converts Geant3 particle codes to PDG convention. (Geant4 uses
239 /// PDG convention already)
240 /// Source: BaBar User Guide, Neil I. Geddes,
241 ///
242 ///Begin_Html
243 
245 {
246  /*
247  see <A href="http://www.slac.stanford.edu/BFROOT/www/Computing/Environment/NewUser/htmlbug/node51.html"> Conversion table</A>
248  */
249  //End_Html
250  // with some fixes by PB, marked with (PB) below. Checked against
251  // PDG listings from 2000.
252  //
253  // Paul Balm, Nov 19, 2001
254 
255  switch(Geant3number) {
256 
257  case 1 : return 22; // photon
258  case 25 : return -2112; // anti-neutron
259  case 2 : return -11; // e+
260  case 26 : return -3122; // anti-Lambda
261  case 3 : return 11; // e-
262  case 27 : return -3222; // Sigma-
263  case 4 : return 12; // e-neutrino (NB: flavour undefined by Geant)
264  case 28 : return -3212; // Sigma0
265  case 5 : return -13; // mu+
266  case 29 : return -3112; // Sigma+ (PB)*/
267  case 6 : return 13; // mu-
268  case 30 : return -3322; // Xi0
269  case 7 : return 111; // pi0
270  case 31 : return -3312; // Xi+
271  case 8 : return 211; // pi+
272  case 32 : return -3334; // Omega+ (PB)
273  case 9 : return -211; // pi-
274  case 33 : return -15; // tau+
275  case 10 : return 130; // K long
276  case 34 : return 15; // tau-
277  case 11 : return 321; // K+
278  case 35 : return 411; // D+
279  case 12 : return -321; // K-
280  case 36 : return -411; // D-
281  case 13 : return 2112; // n
282  case 37 : return 421; // D0
283  case 14 : return 2212; // p
284  case 38 : return -421; // D0
285  case 15 : return -2212; // anti-proton
286  case 39 : return 431; // Ds+
287  case 16 : return 310; // K short
288  case 40 : return -431; // anti Ds-
289  case 17 : return 221; // eta
290  case 41 : return 4122; // Lamba_c+
291  case 18 : return 3122; // Lambda
292  case 42 : return 24; // W+
293  case 19 : return 3222; // Sigma+
294  case 43 : return -24; // W-
295  case 20 : return 3212; // Sigma0
296  case 44 : return 23; // Z
297  case 21 : return 3112; // Sigma-
298  case 45 : return 0; // deuteron
299  case 22 : return 3322; // Xi0
300  case 46 : return 0; // triton
301  case 23 : return 3312; // Xi-
302  case 47 : return 0; // alpha
303  case 24 : return 3334; // Omega- (PB)
304  case 48 : return 0; // G nu ? PDG ID 0 is undefined
305 
306  default : return 0;
307 
308  }
309 }
310 
311 ////////////////////////////////////////////////////////////////////////////////
312 /// Converts pdg code to geant3 id
313 
315 {
316  switch(pdgNumber) {
317 
318  case 22 : return 1; // photon
319  case -2112 : return 25; // anti-neutron
320  case -11 : return 2; // e+
321  case -3122 : return 26; // anti-Lambda
322  case 11 : return 3; // e-
323  case -3222 : return 27; // Sigma-
324  case 12 : return 4; // e-neutrino (NB: flavour undefined by Geant)
325  case -3212 : return 28; // Sigma0
326  case -13 : return 5; // mu+
327  case -3112 : return 29; // Sigma+ (PB)*/
328  case 13 : return 6; // mu-
329  case -3322 : return 30; // Xi0
330  case 111 : return 7; // pi0
331  case -3312 : return 31; // Xi+
332  case 211 : return 8; // pi+
333  case -3334 : return 32; // Omega+ (PB)
334  case -211 : return 9; // pi-
335  case -15 : return 33; // tau+
336  case 130 : return 10; // K long
337  case 15 : return 34; // tau-
338  case 321 : return 11; // K+
339  case 411 : return 35; // D+
340  case -321 : return 12; // K-
341  case -411 : return 36; // D-
342  case 2112 : return 13; // n
343  case 421 : return 37; // D0
344  case 2212 : return 14; // p
345  case -421 : return 38; // D0
346  case -2212 : return 15; // anti-proton
347  case 431 : return 39; // Ds+
348  case 310 : return 16; // K short
349  case -431 : return 40; // anti Ds-
350  case 221 : return 17; // eta
351  case 4122 : return 41; // Lamba_c+
352  case 3122 : return 18; // Lambda
353  case 24 : return 42; // W+
354  case 3222 : return 19; // Sigma+
355  case -24 : return 43; // W-
356  case 3212 : return 20; // Sigma0
357  case 23 : return 44; // Z
358  case 3112 : return 21; // Sigma-
359  case 3322 : return 22; // Xi0
360  case 3312 : return 23; // Xi-
361  case 3334 : return 24; // Omega- (PB)
362 
363  default : return 0;
364 
365  }
366 }
367 
368 ////////////////////////////////////////////////////////////////////////////////
369 ///
370 /// Converts the ISAJET Particle number into the PDG MC number
371 ///
372 
374 {
375  switch (isaNumber) {
376  case 1 : return 2; // UP .30000E+00 .67
377  case -1 : return -2; // UB .30000E+00 -.67
378  case 2 : return 1; // DN .30000E+00 -.33
379  case -2 : return -1; // DB .30000E+00 .33
380  case 3 : return 3; // ST .50000E+00 -.33
381  case -3 : return -3; // SB .50000E+00 .33
382  case 4 : return 4; // CH .16000E+01 .67
383  case -4 : return -4; // CB .16000E+01 -.67
384  case 5 : return 5; // BT .49000E+01 -.33
385  case -5 : return -5; // BB .49000E+01 .33
386  case 6 : return 6; // TP .17500E+03 .67
387  case -6 : return -6; // TB .17500E+03 -.67
388  case 9 : return 21; // GL 0. 0.00
389  case 80 : return 24; // W+ SIN2W=.23 1.00
390  case -80 : return -24; // W- SIN2W=.23 -1.00
391  case 90 : return 23; // Z0 SIN2W=.23 0.00
392  case 230 : return 311; // K0 .49767E+00 0.00
393  case -230 : return -311; // AK0 .49767E+00 0.00
394  case 330 : return 331; // ETAP .95760E+00 0.00
395  case 340 : return 0; // F- .20300E+01 -1.00
396  case -340 : return 0; // F+ .20300E+01 1.00
397  case 440 : return 441; // ETAC .29760E+01 0.00
398  case 111 : return 113; // RHO0 .77000E+00 0.00
399  case 121 : return 213; // RHO+ .77000E+00 1.00
400  case -121 : return -213; // RHO- .77000E+00 -1.00
401  case 221 : return 223; // OMEG .78260E+00 0.00
402  case 131 : return 323; // K*+ .88810E+00 1.00
403  case -131 : return -323; // K*- .88810E+00 -1.00
404  case 231 : return 313; // K*0 .89220E+00 0.00
405  case -231 : return -313; // AK*0 .89220E+00 0.00
406  case 331 : return 333; // PHI .10196E+01 0.00
407  case -140 : return 421; // D0
408  case 140 : return -421; // D0 bar
409  case 141 : return -423; // AD*0 .20060E+01 0.00
410  case -141 : return 423; // D*0 .20060E+01 0.00
411  case -240 : return -411; // D+
412  case 240 : return 411; // D-
413  case 241 : return -413; // D*- .20086E+01 -1.00
414  case -241 : return 413; // D*+ .20086E+01 1.00
415  case 341 : return 0; // F*- .21400E+01 -1.00
416  case -341 : return 0; // F*+ .21400E+01 1.00
417  case 441 : return 443; // JPSI .30970E+01 0.00
418 
419  // B-mesons, Bc still missing
420  case 250 : return 511; // B0
421  case -250 : return -511; // B0 bar
422  case 150 : return 521; // B+
423  case -150 : return -521; // B-
424  case 350 : return 531; // Bs 0
425  case -350 : return -531; // Bs bar
426  case 351 : return 533; // Bs* 0
427  case -351 : return -533; // Bs* bar
428  case 450 : return 541; // Bc +
429  case -450 : return -541; // Bc bar
430 
431  case 1140 : return 4222; // SC++ .24300E+01 2.00
432  case -1140 : return -4222; // ASC-- .24300E+01 -2.00
433  case 1240 : return 4212; // SC+ .24300E+01 1.00
434  case -1240 : return -4212; // ASC- .24300E+01 -1.00
435  case 2140 : return 4122; // LC+ .22600E+01 1.00
436  case -2140 : return -4122; // ALC- .22600E+01 -1.00
437  case 2240 : return 4112; // SC0 .24300E+01 0.00
438  case -2240 : return -4112; // ASC0 .24300E+01 0.00
439  case 1340 : return 0; // USC. .25000E+01 1.00
440  case -1340 : return 0; // AUSC. .25000E+01 -1.00
441  case 3140 : return 0; // SUC. .24000E+01 1.00
442  case -3140 : return 0; // ASUC. .24000E+01 -1.00
443  case 2340 : return 0; // DSC. .25000E+01 0.00
444  case -2340 : return 0; // ADSC. .25000E+01 0.00
445  case 3240 : return 0; // SDC. .24000E+01 0.00
446  case -3240 : return 0; // ASDC. .24000E+01 0.00
447  case 3340 : return 0; // SSC. .26000E+01 0.00
448  case -3340 : return 0; // ASSC. .26000E+01 0.00
449  case 1440 : return 0; // UCC. .35500E+01 2.00
450  case -1440 : return 0; // AUCC. .35500E+01 -2.00
451  case 2440 : return 0; // DCC. .35500E+01 1.00
452  case -2440 : return 0; // ADCC. .35500E+01 -1.00
453  case 3440 : return 0; // SCC. .37000E+01 1.00
454  case -3440 : return 0; // ASCC. .37000E+01 -1.00
455  case 1111 : return 2224; // DL++ .12320E+01 2.00
456  case -1111 : return -2224; // ADL-- .12320E+01 -2.00
457  case 1121 : return 2214; // DL+ .12320E+01 1.00
458  case -1121 : return -2214; // ADL- .12320E+01 -1.00
459  case 1221 : return 2114; // DL0 .12320E+01 0.00
460  case -1221 : return -2114; // ADL0 .12320E+01 0.00
461  case 2221 : return 1114; // DL- .12320E+01 -1.00
462  case -2221 : return -1114; // ADL+ .12320E+01 1.00
463  case 1131 : return 3224; // S*+ .13823E+01 1.00
464  case -1131 : return -3224; // AS*- .13823E+01 -1.00
465  case 1231 : return 3214; // S*0 .13820E+01 0.00
466  case -1231 : return -3214; // AS*0 .13820E+01 0.00
467  case 2231 : return 3114; // S*- .13875E+01 -1.00
468  case -2231 : return -3114; // AS*+ .13875E+01 1.00
469  case 1331 : return 3324; // XI*0 .15318E+01 0.00
470  case -1331 : return -3324; // AXI*0 .15318E+01 0.00
471  case 2331 : return 3314; // XI*- .15350E+01 -1.00
472  case -2331 : return -3314; // AXI*+ .15350E+01 1.00
473  case 3331 : return 3334; // OM- .16722E+01 -1.00
474  case -3331 : return -3334; // AOM+ .16722E+01 1.00
475  case 1141 : return 0; // UUC* .26300E+01 2.00
476  case -1141 : return 0; // AUUC* .26300E+01 -2.00
477  case 1241 : return 0; // UDC* .26300E+01 1.00
478  case -1241 : return 0; // AUDC* .26300E+01 -1.00
479  case 2241 : return 0; // DDC* .26300E+01 0.00
480  case -2241 : return 0; // ADDC* .26300E+01 0.00
481  case 1341 : return 0; // USC* .27000E+01 1.00
482  case -1341 : return 0; // AUSC* .27000E+01 -1.00
483  case 2341 : return 0; // DSC* .27000E+01 0.00
484  case -2341 : return 0; // ADSC* .27000E+01 0.00
485  case 3341 : return 0; // SSC* .28000E+01 0.00
486  case -3341 : return 0; // ASSC* .28000E+01 0.00
487  case 1441 : return 0; // UCC* .37500E+01 2.00
488  case -1441 : return 0; // AUCC* .37500E+01 -2.00
489  case 2441 : return 0; // DCC* .37500E+01 1.00
490  case -2441 : return 0; // ADCC* .37500E+01 -1.00
491  case 3441 : return 0; // SCC* .39000E+01 1.00
492  case -3441 : return 0; // ASCC* .39000E+01 -1.00
493  case 4441 : return 0; // CCC* .48000E+01 2.00
494  case -4441 : return 0; // ACCC* .48000E+01 -2.00
495  case 10 : return 22; // Photon
496  case 12 : return 11; // Electron
497  case -12 : return -11; // Positron
498  case 14 : return 13; // Muon-
499  case -14 : return -13; // Muon+
500  case 16 : return 15; // Tau-
501  case -16 : return -15; // Tau+
502  case 11 : return 12; // Neutrino e
503  case -11 : return -12; // Anti Neutrino e
504  case 13 : return 14; // Neutrino Muon
505  case -13 : return -14; // Anti Neutrino Muon
506  case 15 : return 16; // Neutrino Tau
507  case -15 : return -16; // Anti Neutrino Tau
508  case 110 : return 111; // Pion0
509  case 120 : return 211; // Pion+
510  case -120 : return -211; // Pion-
511  case 220 : return 221; // Eta
512  case 130 : return 321; // Kaon+
513  case -130 : return -321; // Kaon-
514  case -20 : return 130; // Kaon Long
515  case 20 : return 310; // Kaon Short
516 
517  // baryons
518  case 1120 : return 2212; // Proton
519  case -1120 : return -2212; // Anti Proton
520  case 1220 : return 2112; // Neutron
521  case -1220 : return -2112; // Anti Neutron
522  case 2130 : return 3122; // Lambda
523  case -2130 : return -3122; // Lambda bar
524  case 1130 : return 3222; // Sigma+
525  case -1130 : return -3222; // Sigma bar -
526  case 1230 : return 3212; // Sigma0
527  case -1230 : return -3212; // Sigma bar 0
528  case 2230 : return 3112; // Sigma-
529  case -2230 : return -3112; // Sigma bar +
530  case 1330 : return 3322; // Xi0
531  case -1330 : return -3322; // Xi bar 0
532  case 2330 : return 3312; // Xi-
533  case -2330 : return -3312; // Xi bar +
534  default : return 0; // isajet or pdg number does not exist
535  }
536 }
537 
538 ////////////////////////////////////////////////////////////////////////////////
539 /// read list of particles from a file
540 /// if the particle list does not exist, it is created, otherwise
541 /// particles are added to the existing list
542 /// See $ROOTSYS/etc/pdg_table.txt to see the file format
543 
544 void TDatabasePDG::ReadPDGTable(const char *FileName)
545 {
546  if (fParticleList == 0) {
547  fParticleList = new THashList;
549  }
550 
551  TString default_name;
552  const char *fn;
553 
554  if (!FileName[0]) {
555 #ifdef ROOTETCDIR
556  default_name.Form("%s/pdg_table.txt", ROOTETCDIR);
557 #else
558  default_name.Form("%s/etc/pdg_table.txt", gSystem->Getenv("ROOTSYS"));
559 #endif
560  fn = gEnv->GetValue("Root.DatabasePDG", default_name.Data());
561  } else {
562  fn = FileName;
563  }
564 
565  FILE* file = fopen(fn,"r");
566  if (file == 0) {
567  Error("ReadPDGTable","Could not open PDG particle file %s",fn);
568  return;
569  }
570 
571  char c[512];
572  Int_t class_number, anti, isospin, i3, spin, tracking_code;
573  Int_t ich, kf, nch, charge;
574  char name[30], class_name[30];
575  Double_t mass, width, branching_ratio;
576  Int_t dau[20];
577 
578  Int_t idecay, decay_type, flavor, ndau, stable;
579 
580  Int_t input;
581  while ( (input=getc(file)) != EOF) {
582  c[0] = input;
583  if (c[0] != '#') {
584  ungetc(c[0],file);
585  // read channel number
586  // coverity [secure_coding : FALSE]
587  if (fscanf(file,"%i",&ich)) {;}
588  // coverity [secure_coding : FALSE]
589  if (fscanf(file,"%s",name )) {;}
590  // coverity [secure_coding : FALSE]
591  if (fscanf(file,"%i",&kf )) {;}
592  // coverity [secure_coding : FALSE]
593  if (fscanf(file,"%i",&anti )) {;}
594 
595  if (kf < 0) {
596  AddAntiParticle(name,kf);
597  // nothing more on this line
598  if (fgets(c,200,file)) {;}
599  } else {
600  // coverity [secure_coding : FALSE]
601  if (fscanf(file,"%i",&class_number)) {;}
602  // coverity [secure_coding : FALSE]
603  if (fscanf(file,"%s",class_name)) {;}
604  // coverity [secure_coding : FALSE]
605  if (fscanf(file,"%i",&charge)) {;}
606  // coverity [secure_coding : FALSE]
607  if (fscanf(file,"%le",&mass)) {;}
608  // coverity [secure_coding : FALSE]
609  if (fscanf(file,"%le",&width)) {;}
610  // coverity [secure_coding : FALSE]
611  if (fscanf(file,"%i",&isospin)) {;}
612  // coverity [secure_coding : FALSE]
613  if (fscanf(file,"%i",&i3)) {;}
614  // coverity [secure_coding : FALSE]
615  if (fscanf(file,"%i",&spin)) {;}
616  // coverity [secure_coding : FALSE]
617  if (fscanf(file,"%i",&flavor)) {;}
618  // coverity [secure_coding : FALSE]
619  if (fscanf(file,"%i",&tracking_code)) {;}
620  // coverity [secure_coding : FALSE]
621  if (fscanf(file,"%i",&nch)) {;}
622  // nothing more on this line
623  if (fgets(c,200,file)) {;}
624  if (width > 1e-10) stable = 0;
625  else stable = 1;
626 
627  // create particle
628 
629  TParticlePDG* part = AddParticle(name,
630  name,
631  mass,
632  stable,
633  width,
634  charge,
635  class_name,
636  kf,
637  anti,
638  tracking_code);
639 
640  if (nch) {
641  // read in decay channels
642  ich = 0;
643  Int_t c_input = 0;
644  while ( ((c_input=getc(file)) != EOF) && (ich <nch)) {
645  c[0] = c_input;
646  if (c[0] != '#') {
647  ungetc(c[0],file);
648 
649  // coverity [secure_coding : FALSE]
650  if (fscanf(file,"%i",&idecay)) {;}
651  // coverity [secure_coding : FALSE]
652  if (fscanf(file,"%i",&decay_type)) {;}
653  // coverity [secure_coding : FALSE]
654  if (fscanf(file,"%le",&branching_ratio)) {;}
655  // coverity [secure_coding : FALSE]
656  if (fscanf(file,"%i",&ndau)) {;}
657  for (int idau=0; idau<ndau; idau++) {
658  // coverity [secure_coding : FALSE]
659  if (fscanf(file,"%i",&dau[idau])) {;}
660  }
661  // add decay channel
662 
663  if (part) part->AddDecayChannel(decay_type,branching_ratio,ndau,dau);
664  ich++;
665  }
666  // skip end of line
667  if (fgets(c,200,file)) {;}
668  }
669  }
670  }
671  } else {
672  // skip end of line
673  if (fgets(c,200,file)) {;}
674  }
675  }
676  // in the end loop over the antiparticles and
677  // define their decay lists
678  TIter it(fParticleList);
679 
680  Int_t code[20];
681  TParticlePDG *ap, *p, *daughter;
682  TDecayChannel *dc;
683 
684  while ((p = (TParticlePDG*) it.Next())) {
685 
686  // define decay channels for antiparticles
687  if (p->PdgCode() < 0) {
688  ap = GetParticle(-p->PdgCode());
689  if (!ap) continue;
690  nch = ap->NDecayChannels();
691  for (ich=0; ich<nch; ich++) {
692  dc = ap->DecayChannel(ich);
693  if (!dc) continue;
694  ndau = dc->NDaughters();
695  for (int i=0; i<ndau; i++) {
696  // conserve CPT
697 
698  code[i] = dc->DaughterPdgCode(i);
699  daughter = GetParticle(code[i]);
700  if (daughter && daughter->AntiParticle()) {
701  // this particle does have an
702  // antiparticle
703  code[i] = -code[i];
704  }
705  }
707  dc->BranchingRatio(),
708  dc->NDaughters(),
709  code);
710  }
711  p->SetAntiParticle(ap);
712  ap->SetAntiParticle(p);
713  }
714  }
715 
716  fclose(file);
717  return;
718 }
719 
720 
721 ////////////////////////////////////////////////////////////////////////////////
722 ///browse data base
723 
725 {
727 }
728 
729 
730 ////////////////////////////////////////////////////////////////////////////////
731 /// write contents of the particle DB into a file
732 
734 {
735  if (fParticleList == 0) {
736  Error("WritePDGTable","Do not have a valid PDG particle list;"
737  " consider loading it with ReadPDGTable first.");
738  return -1;
739  }
740 
741  FILE *file = fopen(filename,"w");
742  if (file == 0) {
743  Error("WritePDGTable","Could not open PDG particle file %s",filename);
744  return -1;
745  }
746 
747  fprintf(file,"#--------------------------------------------------------------------\n");
748  fprintf(file,"# i NAME............. KF AP CLASS Q MASS WIDTH 2*I+1 I3 2*S+1 FLVR TrkCod N(dec)\n");
749  fprintf(file,"#--------------------------------------------------------------------\n");
750 
751  Int_t nparts=fParticleList->GetEntries();
752  for(Int_t i=0;i<nparts;++i) {
753  TParticlePDG *p = dynamic_cast<TParticlePDG*>(fParticleList->At(i));
754  if(!p) continue;
755 
756  Int_t ich=i+1;
757  Int_t kf=p->PdgCode();
758  fprintf(file,"%5i %-20s %- 6i ", ich, p->GetName(), kf);
759 
760  Int_t anti=p->AntiParticle() ? 1:0;
761  if(kf<0) {
762  for(Int_t j=0;j<nparts;++j) {
763  TParticlePDG *dummy = dynamic_cast<TParticlePDG*>(fParticleList->At(j));
764  if(dummy==p->AntiParticle()) {
765  anti=j+1;
766  break;
767  }
768  }
769  fprintf(file,"%i 0\n",anti);
770  continue;
771  }
772 
773  fprintf(file,"%i ",anti);
774  fprintf(file,"%i ",100);
775  fprintf(file,"%s ",p->ParticleClass());
776  fprintf(file,"% i ",(Int_t)p->Charge());
777  fprintf(file,"%.5le ",p->Mass());
778  fprintf(file,"%.5le ",p->Width());
779  fprintf(file,"%i ",(Int_t)p->Isospin());
780  fprintf(file,"%i ",(Int_t)p->I3());
781  fprintf(file,"%i ",(Int_t)p->Spin());
782  fprintf(file,"%i ",-1);
783  fprintf(file,"%i ",p->TrackingCode());
784  Int_t nch=p->NDecayChannels();
785  fprintf(file,"%i\n",nch);
786  if(nch==0) {
787  continue;
788  }
789  fprintf(file,"#----------------------------------------------------------------------\n");
790  fprintf(file,"# decay type(PY6) BR Nd daughters(codes, then names)\n");
791  fprintf(file,"#----------------------------------------------------------------------\n");
792  for(Int_t j=0;j<nch;++j) {
793  TDecayChannel *dc=p->DecayChannel(j);
794  if (!dc) continue;
795  fprintf(file,"%9i ",dc->Number()+1);
796  fprintf(file,"%3i ",dc->MatrixElementCode());
797  fprintf(file,"%.5le ",dc->BranchingRatio());
798  Int_t ndau=dc->NDaughters();
799  fprintf(file,"%3i ",ndau);
800  for (int idau=0; idau<ndau; idau++) {
801  fprintf(file,"%- 6i ",dc->DaughterPdgCode(idau));
802  }
803  for (int idau=0; idau<ndau; idau++) {
805  if(dummy)
806  fprintf(file,"%-10s ",dummy->GetName());
807  else
808  fprintf(file,"%-10s ","???");
809  }
810  fprintf(file,"\n");
811  }
812  }
813  fclose(file);
814  return nparts;
815 }
Double_t Spin() const
Definition: TParticlePDG.h:76
Double_t Charge() const
Definition: TParticlePDG.h:72
virtual Int_t GetEntries() const
Definition: TCollection.h:92
void Add(ULong64_t hash, Long64_t key, Long64_t value)
Add an (key,value) pair to the table. The key should be unique.
Definition: TExMap.cxx:85
An array of TObjects.
Definition: TObjArray.h:39
Int_t NDaughters()
Definition: TDecayChannel.h:48
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
const char Option_t
Definition: RtypesCore.h:62
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:328
TObject * FindObject(const char *name) const
Find object using its name.
Definition: THashList.cxx:212
virtual ~TDatabasePDG()
Cleanup the PDG database.
virtual void Print(Option_t *opt="") const
Print the entire information of this kind of particle.
virtual Int_t ConvertPdgToGeant3(Int_t pdgNumber) const
Converts pdg code to geant3 id.
TParticlePDG * GetParticle(Int_t pdgCode) const
Get a pointer to the particle object according to the MC code number.
static const char * filename()
void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: THashList.cxx:183
#define gROOT
Definition: TROOT.h:340
Int_t TrackingCode() const
Definition: TParticlePDG.h:94
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TExMap * fPdgMap
Definition: TDatabasePDG.h:31
Double_t I3() const
Definition: TParticlePDG.h:78
const char * ParticleClass() const
Definition: TParticlePDG.h:86
TParticleClassPDG * GetParticleClass(const char *name)
Definition: TDatabasePDG.h:72
TDecayChannel * DecayChannel(Int_t i)
return pointer to decay channel object at index i
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:310
const char * Name
Definition: TXMLSetup.cxx:67
const char * Data() const
Definition: TString.h:349
virtual TParticlePDG * AddParticle(const char *Name, const char *Title, Double_t Mass, Bool_t Stable, Double_t DecayWidth, Double_t Charge, const char *ParticleClass, Int_t PdgCode, Int_t Anti=-1, Int_t TrackingCode=0)
Particle definition normal constructor.
static TDatabasePDG * Instance()
static function
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:36
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
virtual TParticlePDG * AddAntiParticle(const char *Name, Int_t PdgCode)
assuming particle has already been defined
TParticlePDG * AntiParticle()
Definition: TParticlePDG.h:98
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1627
Int_t DaughterPdgCode(Int_t i)
Definition: TDecayChannel.h:50
static Vc_ALWAYS_INLINE Vector< T > abs(const Vector< T > &x)
Definition: vector.h:450
Int_t MatrixElementCode()
Definition: TDecayChannel.h:47
Double_t Width() const
Definition: TParticlePDG.h:74
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
virtual void Browse(TBrowser *b)
browse data base
Int_t PdgCode() const
Definition: TParticlePDG.h:70
void SetAntiParticle(TParticlePDG *ap)
Definition: TParticlePDG.h:103
TObjArray * fListOfClasses
Definition: TDatabasePDG.h:30
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
Long64_t GetValue(ULong64_t hash, Long64_t key)
Return the value belonging to specified key and hash value.
Definition: TExMap.cxx:171
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
THashList * fParticleList
Definition: TDatabasePDG.h:29
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:494
virtual void Print(Option_t *opt="") const
Print contents of PDG database.
TObject * Next()
Definition: TCollection.h:158
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2321
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
virtual Int_t ConvertGeant3ToPdg(Int_t Geant3Number) const
Converts Geant3 particle codes to PDG convention.
Double_t Isospin() const
Definition: TParticlePDG.h:77
void Warning(const char *location, const char *msgfmt,...)
Int_t Number()
Definition: TDecayChannel.h:46
void BuildPdgMap() const
Build fPdgMap mapping pdg-code to particle.
Int_t NDecayChannels() const
Definition: TParticlePDG.h:90
void AddParticle(TObject *p)
long Long_t
Definition: RtypesCore.h:50
#define ClassImp(name)
Definition: Rtypes.h:279
double Double_t
Definition: RtypesCore.h:55
virtual void ReadPDGTable(const char *filename="")
read list of particles from a file if the particle list does not exist, it is created, otherwise particles are added to the existing list See $ROOTSYS/etc/pdg_table.txt to see the file format
R__EXTERN TEnv * gEnv
Definition: TEnv.h:174
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
static RooMathCoreReg dummy
void Browse(TBrowser *b)
Browse this collection (called by TBrowser).
virtual Int_t WritePDGTable(const char *filename)
write contents of the particle DB into a file
#define name(a, b)
Definition: linkTestLib0.cpp:5
virtual void Add(TObject *obj)
Definition: TList.h:81
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:202
#define NULL
Definition: Rtypes.h:82
virtual Int_t ConvertIsajetToPdg(Int_t isaNumber) const
Converts the ISAJET Particle number into the PDG MC number.
Double_t BranchingRatio()
Definition: TDecayChannel.h:49
void Add(TObject *obj)
Definition: TObjArray.h:75
Double_t Mass() const
Definition: TParticlePDG.h:71
This class stores a (key,value) pair using an external hash.
Definition: TExMap.h:35
Int_t AddDecayChannel(Int_t Type, Double_t BranchingRatio, Int_t NDaughters, Int_t *DaughterPdgCode)
add new decay channel, Particle owns those...