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