00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "RConfigure.h"
00013 #include "TROOT.h"
00014 #include "TEnv.h"
00015 #include "THashList.h"
00016 #include "TExMap.h"
00017 #include "TSystem.h"
00018 #include "TDatabasePDG.h"
00019 #include "TDecayChannel.h"
00020 #include "TParticlePDG.h"
00021 #include <stdlib.h>
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 ClassImp(TDatabasePDG)
00051
00052 TDatabasePDG* TDatabasePDG::fgInstance = 0;
00053
00054
00055 TDatabasePDG::TDatabasePDG(): TNamed("PDGDB","The PDG particle data base")
00056 {
00057
00058
00059
00060 fParticleList = 0;
00061 fPdgMap = 0;
00062 fListOfClasses = 0;
00063 if (fgInstance) {
00064 Warning("TDatabasePDG", "object already instantiated");
00065 } else {
00066 fgInstance = this;
00067 gROOT->GetListOfSpecials()->Add(this);
00068 }
00069 }
00070
00071
00072 TDatabasePDG::~TDatabasePDG()
00073 {
00074
00075
00076 if (fParticleList) {
00077 fParticleList->Delete();
00078 delete fParticleList;
00079 delete fPdgMap;
00080 }
00081
00082 if (fListOfClasses) delete fListOfClasses;
00083 gROOT->GetListOfSpecials()->Remove(this);
00084 fgInstance = 0;
00085 }
00086
00087
00088 TDatabasePDG* TDatabasePDG::Instance()
00089 {
00090
00091 return (fgInstance) ? (TDatabasePDG*) fgInstance : new TDatabasePDG();
00092 }
00093
00094
00095 void TDatabasePDG::BuildPdgMap() const
00096 {
00097
00098
00099
00100
00101
00102
00103 fPdgMap = new TExMap(4*TMath::Max(600, fParticleList->GetEntries())/3 + 3);
00104 TIter next(fParticleList);
00105 TParticlePDG *p;
00106 while ((p = (TParticlePDG*)next())) {
00107 fPdgMap->Add((Long_t)p->PdgCode(), (Long_t)p);
00108 }
00109 }
00110
00111
00112 TParticlePDG* TDatabasePDG::AddParticle(const char *name, const char *title,
00113 Double_t mass, Bool_t stable,
00114 Double_t width, Double_t charge,
00115 const char* ParticleClass,
00116 Int_t PDGcode,
00117 Int_t Anti,
00118 Int_t TrackingCode)
00119 {
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 TParticlePDG* old = GetParticle(PDGcode);
00130
00131 if (old) {
00132 printf(" *** TDatabasePDG::AddParticle: particle with PDGcode=%d already defined\n",PDGcode);
00133 return 0;
00134 }
00135
00136 TParticlePDG* p = new TParticlePDG(name, title, mass, stable, width,
00137 charge, ParticleClass, PDGcode, Anti,
00138 TrackingCode);
00139 fParticleList->Add(p);
00140 if (fPdgMap)
00141 fPdgMap->Add((Long_t)PDGcode, (Long_t)p);
00142
00143 TParticleClassPDG* pclass = GetParticleClass(ParticleClass);
00144
00145 if (!pclass) {
00146 pclass = new TParticleClassPDG(ParticleClass);
00147 fListOfClasses->Add(pclass);
00148 }
00149
00150 pclass->AddParticle(p);
00151
00152 return p;
00153 }
00154
00155
00156 TParticlePDG* TDatabasePDG::AddAntiParticle(const char* Name, Int_t PdgCode)
00157 {
00158
00159
00160 TParticlePDG* old = GetParticle(PdgCode);
00161
00162 if (old) {
00163 printf(" *** TDatabasePDG::AddAntiParticle: can't redefine parameters\n");
00164 return NULL;
00165 }
00166
00167 Int_t pdg_code = abs(PdgCode);
00168 TParticlePDG* p = GetParticle(pdg_code);
00169
00170 TParticlePDG* ap = AddParticle(Name,
00171 Name,
00172 p->Mass(),
00173 1,
00174 p->Width(),
00175 -p->Charge(),
00176 p->ParticleClass(),
00177 PdgCode,
00178 1,
00179 p->TrackingCode());
00180 return ap;
00181 }
00182
00183
00184
00185 TParticlePDG *TDatabasePDG::GetParticle(const char *name) const
00186 {
00187
00188
00189
00190
00191 if (fParticleList == 0) ((TDatabasePDG*)this)->ReadPDGTable();
00192
00193 TParticlePDG *def = (TParticlePDG *)fParticleList->FindObject(name);
00194
00195
00196
00197 return def;
00198 }
00199
00200
00201 TParticlePDG *TDatabasePDG::GetParticle(Int_t PDGcode) const
00202 {
00203
00204
00205
00206
00207 if (fParticleList == 0) ((TDatabasePDG*)this)->ReadPDGTable();
00208 if (fPdgMap == 0) BuildPdgMap();
00209
00210 return (TParticlePDG*) (Long_t)fPdgMap->GetValue((Long_t)PDGcode);
00211 }
00212
00213
00214 void TDatabasePDG::Print(Option_t *option) const
00215 {
00216
00217
00218 if (fParticleList == 0) ((TDatabasePDG*)this)->ReadPDGTable();
00219
00220 TIter next(fParticleList);
00221 TParticlePDG *p;
00222 while ((p = (TParticlePDG *)next())) {
00223 p->Print(option);
00224 }
00225 }
00226
00227
00228 Int_t TDatabasePDG::ConvertGeant3ToPdg(Int_t Geant3number) {
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243 switch(Geant3number) {
00244
00245 case 1 : return 22;
00246 case 25 : return -2112;
00247 case 2 : return -11;
00248 case 26 : return -3122;
00249 case 3 : return 11;
00250 case 27 : return -3222;
00251 case 4 : return 12;
00252 case 28 : return -3212;
00253 case 5 : return -13;
00254 case 29 : return -3112;
00255 case 6 : return 13;
00256 case 30 : return -3322;
00257 case 7 : return 111;
00258 case 31 : return -3312;
00259 case 8 : return 211;
00260 case 32 : return -3334;
00261 case 9 : return -211;
00262 case 33 : return -15;
00263 case 10 : return 130;
00264 case 34 : return 15;
00265 case 11 : return 321;
00266 case 35 : return 411;
00267 case 12 : return -321;
00268 case 36 : return -411;
00269 case 13 : return 2112;
00270 case 37 : return 421;
00271 case 14 : return 2212;
00272 case 38 : return -421;
00273 case 15 : return -2212;
00274 case 39 : return 431;
00275 case 16 : return 310;
00276 case 40 : return -431;
00277 case 17 : return 221;
00278 case 41 : return 4122;
00279 case 18 : return 3122;
00280 case 42 : return 24;
00281 case 19 : return 3222;
00282 case 43 : return -24;
00283 case 20 : return 3212;
00284 case 44 : return 23;
00285 case 21 : return 3112;
00286 case 45 : return 0;
00287 case 22 : return 3322;
00288 case 46 : return 0;
00289 case 23 : return 3312;
00290 case 47 : return 0;
00291 case 24 : return 3334;
00292 case 48 : return 0;
00293
00294 default : return 0;
00295
00296 }
00297 }
00298
00299
00300 Int_t TDatabasePDG::ConvertPdgToGeant3(Int_t pdgNumber) {
00301
00302
00303 switch(pdgNumber) {
00304
00305 case 22 : return 1;
00306 case -2112 : return 25;
00307 case -11 : return 2;
00308 case -3122 : return 26;
00309 case 11 : return 3;
00310 case -3222 : return 27;
00311 case 12 : return 4;
00312 case -3212 : return 28;
00313 case -13 : return 5;
00314 case -3112 : return 29;
00315 case 13 : return 6;
00316 case -3322 : return 30;
00317 case 111 : return 7;
00318 case -3312 : return 31;
00319 case 211 : return 8;
00320 case -3334 : return 32;
00321 case -211 : return 9;
00322 case -15 : return 33;
00323 case 130 : return 10;
00324 case 15 : return 34;
00325 case 321 : return 11;
00326 case 411 : return 35;
00327 case -321 : return 12;
00328 case -411 : return 36;
00329 case 2112 : return 13;
00330 case 421 : return 37;
00331 case 2212 : return 14;
00332 case -421 : return 38;
00333 case -2212 : return 15;
00334 case 431 : return 39;
00335 case 310 : return 16;
00336 case -431 : return 40;
00337 case 221 : return 17;
00338 case 4122 : return 41;
00339 case 3122 : return 18;
00340 case 24 : return 42;
00341 case 3222 : return 19;
00342 case -24 : return 43;
00343 case 3212 : return 20;
00344 case 23 : return 44;
00345 case 3112 : return 21;
00346 case 3322 : return 22;
00347 case 3312 : return 23;
00348 case 3334 : return 24;
00349
00350 default : return 0;
00351
00352 }
00353 }
00354
00355
00356 Int_t TDatabasePDG::ConvertIsajetToPdg(Int_t isaNumber)
00357 {
00358
00359
00360
00361 switch (isaNumber) {
00362 case 1 : return 2;
00363 case -1 : return -2;
00364 case 2 : return 1;
00365 case -2 : return -1;
00366 case 3 : return 3;
00367 case -3 : return -3;
00368 case 4 : return 4;
00369 case -4 : return -4;
00370 case 5 : return 5;
00371 case -5 : return -5;
00372 case 6 : return 6;
00373 case -6 : return -6;
00374 case 9 : return 21;
00375 case 80 : return 24;
00376 case -80 : return -24;
00377 case 90 : return 23;
00378 case 230 : return 311;
00379 case -230 : return -311;
00380 case 330 : return 331;
00381 case 340 : return 0;
00382 case -340 : return 0;
00383 case 440 : return 441;
00384 case 111 : return 113;
00385 case 121 : return 213;
00386 case -121 : return -213;
00387 case 221 : return 223;
00388 case 131 : return 323;
00389 case -131 : return -323;
00390 case 231 : return 313;
00391 case -231 : return -313;
00392 case 331 : return 333;
00393 case -140 : return 421;
00394 case 140 : return -421;
00395 case 141 : return -423;
00396 case -141 : return 423;
00397 case -240 : return -411;
00398 case 240 : return 411;
00399 case 241 : return -413;
00400 case -241 : return 413;
00401 case 341 : return 0;
00402 case -341 : return 0;
00403 case 441 : return 443;
00404
00405
00406 case 250 : return 511;
00407 case -250 : return -511;
00408 case 150 : return 521;
00409 case -150 : return -521;
00410 case 350 : return 531;
00411 case -350 : return -531;
00412 case 351 : return 533;
00413 case -351 : return -533;
00414 case 450 : return 541;
00415 case -450 : return -541;
00416
00417 case 1140 : return 4222;
00418 case -1140 : return -4222;
00419 case 1240 : return 4212;
00420 case -1240 : return -4212;
00421 case 2140 : return 4122;
00422 case -2140 : return -4122;
00423 case 2240 : return 4112;
00424 case -2240 : return -4112;
00425 case 1340 : return 0;
00426 case -1340 : return 0;
00427 case 3140 : return 0;
00428 case -3140 : return 0;
00429 case 2340 : return 0;
00430 case -2340 : return 0;
00431 case 3240 : return 0;
00432 case -3240 : return 0;
00433 case 3340 : return 0;
00434 case -3340 : return 0;
00435 case 1440 : return 0;
00436 case -1440 : return 0;
00437 case 2440 : return 0;
00438 case -2440 : return 0;
00439 case 3440 : return 0;
00440 case -3440 : return 0;
00441 case 1111 : return 2224;
00442 case -1111 : return -2224;
00443 case 1121 : return 2214;
00444 case -1121 : return -2214;
00445 case 1221 : return 2114;
00446 case -1221 : return -2114;
00447 case 2221 : return 1114;
00448 case -2221 : return -1114;
00449 case 1131 : return 3224;
00450 case -1131 : return -3224;
00451 case 1231 : return 3214;
00452 case -1231 : return -3214;
00453 case 2231 : return 3114;
00454 case -2231 : return -3114;
00455 case 1331 : return 3324;
00456 case -1331 : return -3324;
00457 case 2331 : return 3314;
00458 case -2331 : return -3314;
00459 case 3331 : return 3334;
00460 case -3331 : return -3334;
00461 case 1141 : return 0;
00462 case -1141 : return 0;
00463 case 1241 : return 0;
00464 case -1241 : return 0;
00465 case 2241 : return 0;
00466 case -2241 : return 0;
00467 case 1341 : return 0;
00468 case -1341 : return 0;
00469 case 2341 : return 0;
00470 case -2341 : return 0;
00471 case 3341 : return 0;
00472 case -3341 : return 0;
00473 case 1441 : return 0;
00474 case -1441 : return 0;
00475 case 2441 : return 0;
00476 case -2441 : return 0;
00477 case 3441 : return 0;
00478 case -3441 : return 0;
00479 case 4441 : return 0;
00480 case -4441 : return 0;
00481 case 10 : return 22;
00482 case 12 : return 11;
00483 case -12 : return -11;
00484 case 14 : return 13;
00485 case -14 : return -13;
00486 case 16 : return 15;
00487 case -16 : return -15;
00488 case 11 : return 12;
00489 case -11 : return -12;
00490 case 13 : return 14;
00491 case -13 : return -14;
00492 case 15 : return 16;
00493 case -15 : return -16;
00494 case 110 : return 111;
00495 case 120 : return 211;
00496 case -120 : return -211;
00497 case 220 : return 221;
00498 case 130 : return 321;
00499 case -130 : return -321;
00500 case -20 : return 130;
00501 case 20 : return 310;
00502
00503
00504 case 1120 : return 2212;
00505 case -1120 : return -2212;
00506 case 1220 : return 2112;
00507 case -1220 : return -2112;
00508 case 2130 : return 3122;
00509 case -2130 : return -3122;
00510 case 1130 : return 3222;
00511 case -1130 : return -3222;
00512 case 1230 : return 3212;
00513 case -1230 : return -3212;
00514 case 2230 : return 3112;
00515 case -2230 : return -3112;
00516 case 1330 : return 3322;
00517 case -1330 : return -3322;
00518 case 2330 : return 3312;
00519 case -2330 : return -3312;
00520 default : return 0;
00521 }
00522 }
00523
00524
00525 void TDatabasePDG::ReadPDGTable(const char *FileName)
00526 {
00527
00528
00529
00530
00531
00532 if (fParticleList == 0) {
00533 fParticleList = new THashList;
00534 fListOfClasses = new TObjArray;
00535 }
00536
00537 TString default_name;
00538 const char *fn;
00539
00540 if (strlen(FileName) == 0) {
00541 #ifdef ROOTETCDIR
00542 default_name.Form("%s/pdg_table.txt", ROOTETCDIR);
00543 #else
00544 default_name.Form("%s/etc/pdg_table.txt", gSystem->Getenv("ROOTSYS"));
00545 #endif
00546 fn = gEnv->GetValue("Root.DatabasePDG", default_name.Data());
00547 } else {
00548 fn = FileName;
00549 }
00550
00551 FILE* file = fopen(fn,"r");
00552 if (file == 0) {
00553 Error("ReadPDGTable","Could not open PDG particle file %s",fn);
00554 return;
00555 }
00556
00557 char c[512];
00558 Int_t class_number, anti, isospin, i3, spin, tracking_code;
00559 Int_t ich, kf, nch, charge;
00560 char name[30], class_name[30];
00561 Double_t mass, width, branching_ratio;
00562 Int_t dau[20];
00563
00564 Int_t idecay, decay_type, flavor, ndau, stable;
00565
00566 Int_t input;
00567 while ( (input=getc(file)) != EOF) {
00568 c[0] = input;
00569 if (c[0] != '#') {
00570 ungetc(c[0],file);
00571
00572
00573 if (fscanf(file,"%i",&ich)) {;}
00574
00575 if (fscanf(file,"%s",name )) {;}
00576
00577 if (fscanf(file,"%i",&kf )) {;}
00578
00579 if (fscanf(file,"%i",&anti )) {;}
00580
00581 if (kf < 0) {
00582 AddAntiParticle(name,kf);
00583
00584 if (fgets(c,200,file)) {;}
00585 } else {
00586
00587 if (fscanf(file,"%i",&class_number)) {;}
00588
00589 if (fscanf(file,"%s",class_name)) {;}
00590
00591 if (fscanf(file,"%i",&charge)) {;}
00592
00593 if (fscanf(file,"%le",&mass)) {;}
00594
00595 if (fscanf(file,"%le",&width)) {;}
00596
00597 if (fscanf(file,"%i",&isospin)) {;}
00598
00599 if (fscanf(file,"%i",&i3)) {;}
00600
00601 if (fscanf(file,"%i",&spin)) {;}
00602
00603 if (fscanf(file,"%i",&flavor)) {;}
00604
00605 if (fscanf(file,"%i",&tracking_code)) {;}
00606
00607 if (fscanf(file,"%i",&nch)) {;}
00608
00609 if (fgets(c,200,file)) {;}
00610 if (width > 1e-10) stable = 0;
00611 else stable = 1;
00612
00613
00614
00615 TParticlePDG* part = AddParticle(name,
00616 name,
00617 mass,
00618 stable,
00619 width,
00620 charge,
00621 class_name,
00622 kf,
00623 anti,
00624 tracking_code);
00625
00626 if (nch) {
00627
00628 ich = 0;
00629 Int_t c_input = 0;
00630 while ( ((c_input=getc(file)) != EOF) && (ich <nch)) {
00631 c[0] = c_input;
00632 if (c[0] != '#') {
00633 ungetc(c[0],file);
00634
00635
00636 if (fscanf(file,"%i",&idecay)) {;}
00637
00638 if (fscanf(file,"%i",&decay_type)) {;}
00639
00640 if (fscanf(file,"%le",&branching_ratio)) {;}
00641
00642 if (fscanf(file,"%i",&ndau)) {;}
00643 for (int idau=0; idau<ndau; idau++) {
00644
00645 if (fscanf(file,"%i",&dau[idau])) {;}
00646 }
00647
00648
00649 if (part) part->AddDecayChannel(decay_type,branching_ratio,ndau,dau);
00650 ich++;
00651 }
00652
00653 if (fgets(c,200,file)) {;}
00654 }
00655 }
00656 }
00657 } else {
00658
00659 if (fgets(c,200,file)) {;}
00660 }
00661 }
00662
00663
00664 TIter it(fParticleList);
00665
00666 Int_t code[20];
00667 TParticlePDG *ap, *p, *daughter;
00668 TDecayChannel *dc;
00669
00670 while ((p = (TParticlePDG*) it.Next())) {
00671
00672
00673 if (p->PdgCode() < 0) {
00674 ap = GetParticle(-p->PdgCode());
00675 nch = ap->NDecayChannels();
00676 for (ich=0; ich<nch; ich++) {
00677 dc = ap->DecayChannel(ich);
00678 ndau = dc->NDaughters();
00679 for (int i=0; i<ndau; i++) {
00680
00681
00682 code[i] = dc->DaughterPdgCode(i);
00683 daughter = GetParticle(code[i]);
00684 if (daughter->AntiParticle()) {
00685
00686
00687 code[i] = -code[i];
00688 }
00689 }
00690 p->AddDecayChannel(dc->MatrixElementCode(),
00691 dc->BranchingRatio(),
00692 dc->NDaughters(),
00693 code);
00694 }
00695 p->SetAntiParticle(ap);
00696 ap->SetAntiParticle(p);
00697 }
00698 }
00699
00700 fclose(file);
00701 return;
00702 }
00703
00704
00705
00706 void TDatabasePDG::Browse(TBrowser* b)
00707 {
00708
00709 if (fListOfClasses ) fListOfClasses->Browse(b);
00710 }
00711
00712
00713
00714 Int_t TDatabasePDG::WritePDGTable(const char *filename)
00715 {
00716
00717
00718 if (fParticleList == 0) {
00719 Error("WritePDGTable","Do not have a valid PDG particle list;"
00720 " consider loading it with ReadPDGTable first.");
00721 return -1;
00722 }
00723
00724 FILE *file = fopen(filename,"w");
00725 if (file == 0) {
00726 Error("WritePDGTable","Could not open PDG particle file %s",filename);
00727 return -1;
00728 }
00729
00730 fprintf(file,"#--------------------------------------------------------------------\n");
00731 fprintf(file,"# i NAME............. KF AP CLASS Q MASS WIDTH 2*I+1 I3 2*S+1 FLVR TrkCod N(dec)\n");
00732 fprintf(file,"#--------------------------------------------------------------------\n");
00733
00734 Int_t nparts=fParticleList->GetEntries();
00735 for(Int_t i=0;i<nparts;++i) {
00736 TParticlePDG *p = dynamic_cast<TParticlePDG*>(fParticleList->At(i));
00737 if(!p) continue;
00738
00739 Int_t ich=i+1;
00740 Int_t kf=p->PdgCode();
00741 fprintf(file,"%5i %-20s %- 6i ", ich, p->GetName(), kf);
00742
00743 Int_t anti=p->AntiParticle() ? 1:0;
00744 if(kf<0) {
00745 for(Int_t j=0;j<nparts;++j) {
00746 TParticlePDG *dummy = dynamic_cast<TParticlePDG*>(fParticleList->At(j));
00747 if(dummy==p->AntiParticle()) {
00748 anti=j+1;
00749 break;
00750 }
00751 }
00752 fprintf(file,"%i 0\n",anti);
00753 continue;
00754 }
00755
00756 fprintf(file,"%i ",anti);
00757 fprintf(file,"%i ",100);
00758 fprintf(file,"%s ",p->ParticleClass());
00759 fprintf(file,"% i ",(Int_t)p->Charge());
00760 fprintf(file,"%.5le ",p->Mass());
00761 fprintf(file,"%.5le ",p->Width());
00762 fprintf(file,"%i ",(Int_t)p->Isospin());
00763 fprintf(file,"%i ",(Int_t)p->I3());
00764 fprintf(file,"%i ",(Int_t)p->Spin());
00765 fprintf(file,"%i ",-1);
00766 fprintf(file,"%i ",p->TrackingCode());
00767 Int_t nch=p->NDecayChannels();
00768 fprintf(file,"%i\n",nch);
00769 if(nch==0) {
00770 continue;
00771 }
00772 fprintf(file,"#----------------------------------------------------------------------\n");
00773 fprintf(file,"# decay type(PY6) BR Nd daughters(codes, then names)\n");
00774 fprintf(file,"#----------------------------------------------------------------------\n");
00775 for(Int_t j=0;j<nch;++j) {
00776 TDecayChannel *dc=p->DecayChannel(j);
00777
00778 fprintf(file,"%9i ",dc->Number()+1);
00779 fprintf(file,"%3i ",dc->MatrixElementCode());
00780 fprintf(file,"%.5le ",dc->BranchingRatio());
00781 Int_t ndau=dc->NDaughters();
00782 fprintf(file,"%3i ",ndau);
00783 for (int idau=0; idau<ndau; idau++) {
00784 fprintf(file,"%- 6i ",dc->DaughterPdgCode(idau));
00785 }
00786 for (int idau=0; idau<ndau; idau++) {
00787 TParticlePDG *dummy=GetParticle(dc->DaughterPdgCode(idau));
00788 if(dummy)
00789 fprintf(file,"%-10s ",dummy->GetName());
00790 else
00791 fprintf(file,"%-10s ","???");
00792 }
00793 fprintf(file,"\n");
00794 }
00795 }
00796 fclose(file);
00797 return nparts;
00798 }