12 #include "RConfigure.h"
53 ClassImp(TDatabasePDG);
58 TDatabasePDG** GetInstancePtr()
60 static TDatabasePDG* fgInstance =
nullptr;
68 TDatabasePDG::TDatabasePDG(): TNamed(
"PDGDB",
"The PDG particle data base")
73 auto fgInstance = GetInstancePtr();
74 if (*fgInstance !=
nullptr) {
75 Warning(
"TDatabasePDG",
"object already instantiated");
78 gROOT->GetListOfSpecials()->Add(
this);
85 TDatabasePDG::~TDatabasePDG()
88 fParticleList->Delete();
90 if (fPdgMap)
delete fPdgMap;
94 fListOfClasses->Delete();
95 delete fListOfClasses;
97 if (gROOT && !gROOT->TestBit(TObject::kInvalidObject))
98 gROOT->GetListOfSpecials()->Remove(
this);
99 auto fgInstance = GetInstancePtr();
100 *fgInstance =
nullptr;
106 TDatabasePDG* TDatabasePDG::Instance()
108 auto fgInstance = GetInstancePtr();
109 if (*fgInstance ==
nullptr) {
123 void TDatabasePDG::BuildPdgMap()
const
125 fPdgMap =
new TExMap(4*TMath::Max(600, fParticleList->GetEntries())/3 + 3);
126 TIter next(fParticleList);
128 while ((p = (TParticlePDG*)next())) {
129 fPdgMap->Add((Long_t)p->PdgCode(), (Long_t)p);
143 TParticlePDG* 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,
151 TParticlePDG* old = GetParticle(PDGcode);
154 printf(
" *** TDatabasePDG::AddParticle: particle with PDGcode=%d already defined\n",PDGcode);
158 TParticlePDG* p =
new TParticlePDG(name, title, mass, stable, width,
159 charge, ParticleClass, PDGcode, Anti,
161 fParticleList->Add(p);
163 fPdgMap->Add((Long_t)PDGcode, (Long_t)p);
165 TParticleClassPDG* pclass = GetParticleClass(ParticleClass);
168 pclass =
new TParticleClassPDG(ParticleClass);
169 fListOfClasses->Add(pclass);
172 pclass->AddParticle(p);
180 TParticlePDG* TDatabasePDG::AddAntiParticle(
const char* Name, Int_t PdgCode)
182 TParticlePDG* old = GetParticle(PdgCode);
185 printf(
" *** TDatabasePDG::AddAntiParticle: can't redefine parameters\n");
189 Int_t pdg_code = abs(PdgCode);
190 TParticlePDG* p = GetParticle(pdg_code);
193 printf(
" *** TDatabasePDG::AddAntiParticle: particle with pdg code %d not known\n", pdg_code);
197 TParticlePDG* ap = AddParticle(Name,
216 TParticlePDG *TDatabasePDG::GetParticle(
const char *name)
const
218 if (fParticleList == 0) ((TDatabasePDG*)
this)->ReadPDGTable();
220 TParticlePDG *def = (TParticlePDG *)fParticleList->FindObject(name);
232 TParticlePDG *TDatabasePDG::GetParticle(Int_t PDGcode)
const
234 if (fParticleList == 0) ((TDatabasePDG*)
this)->ReadPDGTable();
235 if (fPdgMap == 0) BuildPdgMap();
237 return (TParticlePDG*) (Long_t)fPdgMap->GetValue((Long_t)PDGcode);
243 void TDatabasePDG::Print(Option_t *option)
const
245 if (fParticleList == 0) ((TDatabasePDG*)
this)->ReadPDGTable();
247 TIter next(fParticleList);
249 while ((p = (TParticlePDG *)next())) {
266 Int_t TDatabasePDG::ConvertGeant3ToPdg(Int_t Geant3number)
const
270 switch(Geant3number) {
273 case 25 :
return -2112;
275 case 26 :
return -3122;
277 case 27 :
return -3222;
279 case 28 :
return -3212;
281 case 29 :
return -3112;
283 case 30 :
return -3322;
285 case 31 :
return -3312;
287 case 32 :
return -3334;
288 case 9 :
return -211;
289 case 33 :
return -15;
290 case 10 :
return 130;
292 case 11 :
return 321;
293 case 35 :
return 411;
294 case 12 :
return -321;
295 case 36 :
return -411;
296 case 13 :
return 2112;
297 case 37 :
return 421;
298 case 14 :
return 2212;
299 case 38 :
return -421;
300 case 15 :
return -2212;
301 case 39 :
return 431;
302 case 16 :
return 310;
303 case 40 :
return -431;
304 case 17 :
return 221;
305 case 41 :
return 4122;
306 case 18 :
return 3122;
308 case 19 :
return 3222;
309 case 43 :
return -24;
310 case 20 :
return 3212;
312 case 21 :
return 3112;
314 case 22 :
return 3322;
316 case 23 :
return 3312;
318 case 24 :
return 3334;
329 Int_t TDatabasePDG::ConvertPdgToGeant3(Int_t pdgNumber)
const
334 case -2112 :
return 25;
336 case -3122 :
return 26;
338 case -3222 :
return 27;
340 case -3212 :
return 28;
342 case -3112 :
return 29;
344 case -3322 :
return 30;
346 case -3312 :
return 31;
348 case -3334 :
return 32;
349 case -211 :
return 9;
350 case -15 :
return 33;
351 case 130 :
return 10;
353 case 321 :
return 11;
354 case 411 :
return 35;
355 case -321 :
return 12;
356 case -411 :
return 36;
357 case 2112 :
return 13;
358 case 421 :
return 37;
359 case 2212 :
return 14;
360 case -421 :
return 38;
361 case -2212 :
return 15;
362 case 431 :
return 39;
363 case 310 :
return 16;
364 case -431 :
return 40;
365 case 221 :
return 17;
366 case 4122 :
return 41;
367 case 3122 :
return 18;
369 case 3222 :
return 19;
370 case -24 :
return 43;
371 case 3212 :
return 20;
373 case 3112 :
return 21;
374 case 3322 :
return 22;
375 case 3312 :
return 23;
376 case 3334 :
return 24;
388 Int_t TDatabasePDG::ConvertIsajetToPdg(Int_t isaNumber)
const
405 case -80 :
return -24;
407 case 230 :
return 311;
408 case -230 :
return -311;
409 case 330 :
return 331;
411 case -340 :
return 0;
412 case 440 :
return 441;
413 case 111 :
return 113;
414 case 121 :
return 213;
415 case -121 :
return -213;
416 case 221 :
return 223;
417 case 131 :
return 323;
418 case -131 :
return -323;
419 case 231 :
return 313;
420 case -231 :
return -313;
421 case 331 :
return 333;
422 case -140 :
return 421;
423 case 140 :
return -421;
424 case 141 :
return -423;
425 case -141 :
return 423;
426 case -240 :
return -411;
427 case 240 :
return 411;
428 case 241 :
return -413;
429 case -241 :
return 413;
431 case -341 :
return 0;
432 case 441 :
return 443;
435 case 250 :
return 511;
436 case -250 :
return -511;
437 case 150 :
return 521;
438 case -150 :
return -521;
439 case 350 :
return 531;
440 case -350 :
return -531;
441 case 351 :
return 533;
442 case -351 :
return -533;
443 case 450 :
return 541;
444 case -450 :
return -541;
446 case 1140 :
return 4222;
447 case -1140 :
return -4222;
448 case 1240 :
return 4212;
449 case -1240 :
return -4212;
450 case 2140 :
return 4122;
451 case -2140 :
return -4122;
452 case 2240 :
return 4112;
453 case -2240 :
return -4112;
454 case 1340 :
return 0;
455 case -1340 :
return 0;
456 case 3140 :
return 0;
457 case -3140 :
return 0;
458 case 2340 :
return 0;
459 case -2340 :
return 0;
460 case 3240 :
return 0;
461 case -3240 :
return 0;
462 case 3340 :
return 0;
463 case -3340 :
return 0;
464 case 1440 :
return 0;
465 case -1440 :
return 0;
466 case 2440 :
return 0;
467 case -2440 :
return 0;
468 case 3440 :
return 0;
469 case -3440 :
return 0;
470 case 1111 :
return 2224;
471 case -1111 :
return -2224;
472 case 1121 :
return 2214;
473 case -1121 :
return -2214;
474 case 1221 :
return 2114;
475 case -1221 :
return -2114;
476 case 2221 :
return 1114;
477 case -2221 :
return -1114;
478 case 1131 :
return 3224;
479 case -1131 :
return -3224;
480 case 1231 :
return 3214;
481 case -1231 :
return -3214;
482 case 2231 :
return 3114;
483 case -2231 :
return -3114;
484 case 1331 :
return 3324;
485 case -1331 :
return -3324;
486 case 2331 :
return 3314;
487 case -2331 :
return -3314;
488 case 3331 :
return 3334;
489 case -3331 :
return -3334;
490 case 1141 :
return 0;
491 case -1141 :
return 0;
492 case 1241 :
return 0;
493 case -1241 :
return 0;
494 case 2241 :
return 0;
495 case -2241 :
return 0;
496 case 1341 :
return 0;
497 case -1341 :
return 0;
498 case 2341 :
return 0;
499 case -2341 :
return 0;
500 case 3341 :
return 0;
501 case -3341 :
return 0;
502 case 1441 :
return 0;
503 case -1441 :
return 0;
504 case 2441 :
return 0;
505 case -2441 :
return 0;
506 case 3441 :
return 0;
507 case -3441 :
return 0;
508 case 4441 :
return 0;
509 case -4441 :
return 0;
512 case -12 :
return -11;
514 case -14 :
return -13;
516 case -16 :
return -15;
518 case -11 :
return -12;
520 case -13 :
return -14;
522 case -15 :
return -16;
523 case 110 :
return 111;
524 case 120 :
return 211;
525 case -120 :
return -211;
526 case 220 :
return 221;
527 case 130 :
return 321;
528 case -130 :
return -321;
529 case -20 :
return 130;
530 case 20 :
return 310;
533 case 1120 :
return 2212;
534 case -1120 :
return -2212;
535 case 1220 :
return 2112;
536 case -1220 :
return -2112;
537 case 2130 :
return 3122;
538 case -2130 :
return -3122;
539 case 1130 :
return 3222;
540 case -1130 :
return -3222;
541 case 1230 :
return 3212;
542 case -1230 :
return -3212;
543 case 2230 :
return 3112;
544 case -2230 :
return -3112;
545 case 1330 :
return 3322;
546 case -1330 :
return -3322;
547 case 2330 :
return 3312;
548 case -2330 :
return -3312;
559 void TDatabasePDG::ReadPDGTable(
const char *FileName)
561 if (fParticleList == 0) {
562 fParticleList =
new THashList;
563 fListOfClasses =
new TObjArray;
566 TString default_name;
570 default_name =
"pdg_table.txt";
571 gSystem->PrependPathName(TROOT::GetEtcDir(), default_name);
572 fn = gEnv->GetValue(
"Root.DatabasePDG", default_name.Data());
577 FILE* file = fopen(fn,
"r");
579 Error(
"ReadPDGTable",
"Could not open PDG particle file %s",fn);
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;
590 Int_t idecay, decay_type, flavor, ndau, stable;
593 while ( (input=getc(file)) != EOF) {
599 if (fscanf(file,
"%i",&ich)) {;}
601 if (fscanf(file,
"%s",name )) {;}
603 if (fscanf(file,
"%i",&kf )) {;}
605 if (fscanf(file,
"%i",&anti )) {;}
608 AddAntiParticle(name,kf);
610 if (fgets(c,200,file)) {;}
613 if (fscanf(file,
"%i",&class_number)) {;}
615 if (fscanf(file,
"%s",class_name)) {;}
617 if (fscanf(file,
"%i",&charge)) {;}
619 if (fscanf(file,
"%le",&mass)) {;}
621 if (fscanf(file,
"%le",&width)) {;}
623 if (fscanf(file,
"%i",&isospin)) {;}
625 if (fscanf(file,
"%i",&i3)) {;}
627 if (fscanf(file,
"%i",&spin)) {;}
629 if (fscanf(file,
"%i",&flavor)) {;}
631 if (fscanf(file,
"%i",&tracking_code)) {;}
633 if (fscanf(file,
"%i",&nch)) {;}
635 if (fgets(c,200,file)) {;}
636 if (width > 1e-10) stable = 0;
641 TParticlePDG* part = AddParticle(name,
656 while ( ((c_input=getc(file)) != EOF) && (ich <nch)) {
662 if (fscanf(file,
"%i",&idecay)) {;}
664 if (fscanf(file,
"%i",&decay_type)) {;}
666 if (fscanf(file,
"%le",&branching_ratio)) {;}
668 if (fscanf(file,
"%i",&ndau)) {;}
669 for (
int idau=0; idau<ndau; idau++) {
671 if (fscanf(file,
"%i",&dau[idau])) {;}
675 if (part) part->AddDecayChannel(decay_type,branching_ratio,ndau,dau);
679 if (fgets(c,200,file)) {;}
685 if (fgets(c,200,file)) {;}
690 TIter it(fParticleList);
693 TParticlePDG *ap, *p, *daughter;
696 while ((p = (TParticlePDG*) it.Next())) {
699 if (p->PdgCode() < 0) {
700 ap = GetParticle(-p->PdgCode());
702 nch = ap->NDecayChannels();
703 for (ich=0; ich<nch; ich++) {
704 dc = ap->DecayChannel(ich);
706 ndau = dc->NDaughters();
707 for (
int i=0; i<ndau; i++) {
710 code[i] = dc->DaughterPdgCode(i);
711 daughter = GetParticle(code[i]);
712 if (daughter && daughter->AntiParticle()) {
718 p->AddDecayChannel(dc->MatrixElementCode(),
719 dc->BranchingRatio(),
723 p->SetAntiParticle(ap);
724 ap->SetAntiParticle(p);
736 void TDatabasePDG::Browse(TBrowser* b)
738 if (fListOfClasses ) fListOfClasses->Browse(b);
745 Int_t TDatabasePDG::WritePDGTable(
const char *filename)
747 if (fParticleList == 0) {
748 Error(
"WritePDGTable",
"Do not have a valid PDG particle list;"
749 " consider loading it with ReadPDGTable first.");
753 FILE *file = fopen(filename,
"w");
755 Error(
"WritePDGTable",
"Could not open PDG particle file %s",filename);
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");
763 Int_t nparts=fParticleList->GetEntries();
764 for(Int_t i=0;i<nparts;++i) {
765 TParticlePDG *p =
dynamic_cast<TParticlePDG*
>(fParticleList->At(i));
769 Int_t kf=p->PdgCode();
770 fprintf(file,
"%5i %-20s %- 6i ", ich, p->GetName(), kf);
772 Int_t anti=p->AntiParticle() ? 1:0;
774 for(Int_t j=0;j<nparts;++j) {
775 TParticlePDG *dummy =
dynamic_cast<TParticlePDG*
>(fParticleList->At(j));
776 if(dummy==p->AntiParticle()) {
781 fprintf(file,
"%i 0\n",anti);
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);
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);
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));
815 for (
int idau=0; idau<ndau; idau++) {
816 TParticlePDG *dummy=GetParticle(dc->DaughterPdgCode(idau));
818 fprintf(file,
"%-10s ",dummy->GetName());
820 fprintf(file,
"%-10s ",
"???");