PDGLibrary.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2019, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5  or see $GENIE/LICENSE
6 
7  Author: Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
8  University of Liverpool & STFC Rutherford Appleton Lab
9 
10  Changes required to implement the GENIE Boosted Dark Matter module
11  were installed by Josh Berger (Univ. of Wisconsin)
12 */
13 //____________________________________________________________________________
14 
15 #include <iostream>
16 #include <string>
17 
18 #include <TSystem.h>
19 
23 
24 using std::string;
25 
26 using namespace genie;
27 
28 //____________________________________________________________________________
30 //____________________________________________________________________________
32 {
33  if( ! LoadDBase() ) LOG("PDG", pERROR) << "Could not load PDG data";
34 
35  fInstance = 0;
36 }
37 //____________________________________________________________________________
39 {
40  fInstance = 0;
41 }
42 //____________________________________________________________________________
44 {
45  if(fInstance == 0) {
46  LOG("PDG", pINFO) << "PDGLibrary late initialization";
47 
48  static PDGLibrary::Cleaner cleaner;
50 
51  fInstance = new PDGLibrary;
52  }
53  return fInstance;
54 }
55 //____________________________________________________________________________
56 TDatabasePDG * PDGLibrary::DBase(void)
57 {
58  return fDatabasePDG;
59 }
60 //____________________________________________________________________________
61 TParticlePDG * PDGLibrary::Find(int pdgc)
62 {
63 // save some typing in the most frequently typed TDatabasePDG method
64 
65  return fDatabasePDG->GetParticle(pdgc);
66 }
67 
68 //____________________________________________________________________________
70 {
71  fDatabasePDG = TDatabasePDG::Instance();
72 
73  // loading PDG data from $GENIE/config/
74  const char* altpdgtable = gSystem->Getenv("GENIE_PDG_TABLE");
75  if ( altpdgtable ) {
76  if ( ! (gSystem->AccessPathName(altpdgtable) ) ) {
77  LOG("PDG", pINFO) << "Load PDG data from $GENIE_PDG_TABLE: "
78  << altpdgtable;
79  fDatabasePDG->ReadPDGTable( altpdgtable );
80  return true;
81  }
82  }
83 
84  if ( gSystem->Getenv("GENIE") ) {
85  string base_dir = string( gSystem->Getenv("GENIE") );
86  string path = base_dir +
87  string("/data/evgen/catalogues/pdg/genie_pdg_table.txt");
88 
89  if ( ! (gSystem->AccessPathName(path.c_str()) ) ) {
90  LOG("PDG", pINFO) << "Load PDG data from: " << path;
91  fDatabasePDG->ReadPDGTable( path.c_str() );
92  return true;
93  }
94  }
95 
96  // no PDG data in $GENIE/config/ - Try $ROOTSYS/etc/
97 
98  if(gSystem->Getenv("ROOTSYS")) {
99  string base_dir = string( gSystem->Getenv("ROOTSYS") );
100  string path = base_dir + string("/etc/pdg_table.txt");
101 
102  if ( !(gSystem->AccessPathName(path.c_str())) ) {
103  LOG("PDG", pINFO) << "Load PDG data from: " << path;
104  fDatabasePDG->ReadPDGTable( path.c_str() );
105  return true;
106  }
107  }
108 
109  LOG("PDG", pERROR) << " *** The PDG extensions will not be loaded!! ***";
110  return false;
111 };
112 //____________________________________________________________________________
113 void PDGLibrary::AddDarkMatter(double mass, double med_ratio)
114 {
115 // Add dark matter particle to PDG database
116 
117  double med_mass = mass*med_ratio;
118  TParticlePDG * dm_particle = fDatabasePDG->GetParticle(kPdgDarkMatter);
119  TParticlePDG * med_particle = fDatabasePDG->GetParticle(kPdgMediator);
120  if (!dm_particle) {
121  // Name Title Mass Stable Width Charge Class PDG
122  fDatabasePDG->AddParticle("chi_dm","chi_dm",mass,true,0.,0,"DarkMatter",kPdgDarkMatter);
123  }
124  else {
125  assert(dm_particle->Mass() == mass);
126  }
127  if (!med_particle) {
128  // Name Title Mass Stable Width Charge Class PDG
129  fDatabasePDG->AddParticle("Z_prime","Z_prime",med_mass,true,0.,0,"DarkMatter",kPdgMediator);
130  }
131  else {
132  assert(med_particle->Mass() == med_mass);
133  }
134 }
135 //____________________________________________________________________________
136 // EDIT: need a way to clear and then reload the PDG database
138 {
139  if(fDatabasePDG) {
140  delete fDatabasePDG;
141  }
142 
143  if( ! LoadDBase() ) LOG("PDG", pERROR) << "Could not load PDG data";
144 }
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
#define pERROR
Definition: Messenger.h:60
void AddDarkMatter(double mass, double med_ratio)
Definition: PDGLibrary.cxx:113
const int kPdgMediator
Definition: PDGCodes.h:196
TDatabasePDG * DBase(void)
Definition: PDGLibrary.cxx:56
const int kPdgDarkMatter
Definition: PDGCodes.h:195
TDatabasePDG * fDatabasePDG
Definition: PDGLibrary.h:54
static PDGLibrary * fInstance
Definition: PDGLibrary.h:53
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
bool LoadDBase(void)
Definition: PDGLibrary.cxx:69
#define pINFO
Definition: Messenger.h:63
virtual ~PDGLibrary()
Definition: PDGLibrary.cxx:38
const std::string path
Definition: plot_BEN.C:43
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:43
Singleton class to load & serve a TDatabasePDG.
Definition: PDGLibrary.h:30
TParticlePDG * Find(int pdgc)
Definition: PDGLibrary.cxx:61
assert(nhit_max >=nhit_nbins)
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
void ReloadDBase(void)
Definition: PDGLibrary.cxx:137