PDGLibrary.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2020, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5 
6  Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
7  University of Liverpool & STFC Rutherford Appleton Laboratory
8 
9  Changes required to implement the GENIE Boosted Dark Matter module
10  were installed by Josh Berger (Univ. of Wisconsin)
11 
12  Changes required to implement the GENIE Dark Neutrino module
13  were installed by Iker de Icaza (Univ. of Sussex)
14 */
15 //____________________________________________________________________________
16 
17 #include <iostream>
18 #include <string>
19 
20 #include <TSystem.h>
21 
23 #include "Framework/Conventions/GBuild.h"
28 
29 
30 using std::string;
31 
32 using namespace genie;
33 
34 //____________________________________________________________________________
36 //____________________________________________________________________________
38 {
39  if( ! LoadDBase() ) LOG("PDG", pERROR) << "Could not load PDG data";
40 
41 #ifdef __GENIE_DARK_NEUTRINO_ENABLED__
42  LOG("PDG", pINFO) << "Loading Dark sector Info";
43  if ( ! AddDarkSector() ) {
44  LOG("PDG", pFATAL) << "Could not load Dark Neutrino data";
45  exit(78);
46  }
47 #endif // __GENIE_DARK_NEUTRINO_ENABLED__
48 
49  fInstance = 0;
50 }
51 //____________________________________________________________________________
53 {
54  fInstance = 0;
55 }
56 //____________________________________________________________________________
58 {
59  if(fInstance == 0) {
60  LOG("PDG", pINFO) << "PDGLibrary late initialization";
61 
62  static PDGLibrary::Cleaner cleaner;
64 
65  fInstance = new PDGLibrary;
66  }
67  return fInstance;
68 }
69 //____________________________________________________________________________
70 TDatabasePDG * PDGLibrary::DBase(void)
71 {
72  return fDatabasePDG;
73 }
74 //____________________________________________________________________________
75 TParticlePDG * PDGLibrary::Find(int pdgc, bool must_exist )
76 {
77 
78  TParticlePDG * ret = fDatabasePDG->GetParticle(pdgc);
79  if(ret) return ret;
80 
81  if ( must_exist ) {
82  LOG("PDG", pERROR) << "Requested missing particle with PDG: " << pdgc ;
83  }
84 
85  return ret ;
86 }
87 
88 //____________________________________________________________________________
90 {
91  fDatabasePDG = TDatabasePDG::Instance();
92 
93  // loading PDG data from $GENIE/config/
94  const char* altpdgtable = gSystem->Getenv("GENIE_PDG_TABLE");
95  if ( altpdgtable ) {
96  if ( ! (gSystem->AccessPathName(altpdgtable) ) ) {
97  LOG("PDG", pINFO) << "Load PDG data from $GENIE_PDG_TABLE: "
98  << altpdgtable;
99  fDatabasePDG->ReadPDGTable( altpdgtable );
100  return true;
101  }
102  }
103 
104  if ( gSystem->Getenv("GENIE") ) {
105  string base_dir = string( gSystem->Getenv("GENIE") );
106  base_dir += string("/data/evgen/catalogues/pdg/") ;
107 
108  string file_name = "genie_pdg_table.txt" ;
109  const Registry * reg = AlgConfigPool::Instance()->CommonList("Param", "PDG");
110  if( reg ) {
111  file_name = reg -> GetString("PDG-TableName") ;
112  LOG("PDG", pINFO) << "Found file name specification: " << file_name ;
113 
114  }
115 
116  string path = base_dir + file_name ;
117 
118  if ( ! (gSystem->AccessPathName(path.c_str()) ) ) {
119  LOG("PDG", pINFO) << "Load PDG data from: " << path;
120  fDatabasePDG->ReadPDGTable( path.c_str() );
121  return true;
122  }
123  }
124 
125  // no PDG data in $GENIE/config/ - Try $ROOTSYS/etc/
126 
127  if(gSystem->Getenv("ROOTSYS")) {
128  string base_dir = string( gSystem->Getenv("ROOTSYS") );
129  string path = base_dir + string("/etc/pdg_table.txt");
130 
131  if ( !(gSystem->AccessPathName(path.c_str())) ) {
132  LOG("PDG", pINFO) << "Load PDG data from: " << path;
133  fDatabasePDG->ReadPDGTable( path.c_str() );
134  return true;
135  }
136  }
137 
138  LOG("PDG", pERROR) << " *** The PDG extensions will not be loaded!! ***";
139  return false;
140 };
141 //____________________________________________________________________________
142 void PDGLibrary::AddDarkMatter(double mass, double med_ratio)
143 {
144 // Add dark matter particle to PDG database
145 
146  double med_mass = mass*med_ratio;
147  TParticlePDG * dm_particle = fDatabasePDG->GetParticle(kPdgDarkMatter);
148  TParticlePDG * med_particle = fDatabasePDG->GetParticle(kPdgMediator);
149  if (!dm_particle) {
150  // Name Title Mass Stable Width Charge Class PDG
151  fDatabasePDG->AddParticle("chi_dm","chi_dm",mass,true,0.,0,"DarkMatter",kPdgDarkMatter);
152  }
153  else {
154  assert(dm_particle->Mass() == mass);
155  }
156  if (!med_particle) {
157  // Name Title Mass Stable Width Charge Class PDG
158  fDatabasePDG->AddParticle("Z_prime","Z_prime",med_mass,true,0.,0,"DarkMatter",kPdgMediator);
159  }
160  else {
161  assert(med_particle->Mass() == med_mass);
162  }
163 }
164 //____________________________________________________________________________
165 void PDGLibrary::AddNHL(double mass)
166 {
167 // Add NHL to PDG database
168 
169  TParticlePDG * nhl = fDatabasePDG->GetParticle(kPdgNHL);
170  if (!nhl) {
171  // Name Title Mass Stable Width Charge Class PDG
172  fDatabasePDG->AddParticle("NHL","NHL",mass,true,0.,0,"NHL",kPdgNHL);
173  }
174  else {
175  assert(nhl->Mass() == mass);
176  }
177 }
178 //____________________________________________________________________________
180 {
181  // Add dark neutrino particles to PDG database
182 
183  const Registry * reg = AlgConfigPool::Instance()->CommonList("Dark", "Masses");
184  if(!reg) {
185  LOG("PDG", pERROR) << "The Dark Sector masses not available.";
186  return false;
187  }
188  TParticlePDG * dnu_particle = fDatabasePDG->GetParticle(kPdgDarkNeutrino);
189  TParticlePDG * anti_dnu_particle = fDatabasePDG->GetParticle(kPdgAntiDarkNeutrino);
190  TParticlePDG * med_particle = fDatabasePDG->GetParticle(kPdgDNuMediator);
191  if (!dnu_particle) {
192  // Name Title Mass Stable Width Charge Class PDG
193  fDatabasePDG->AddParticle("nu_D","#nu_{D}",reg->GetDouble("Dark-NeutrinoMass"),
194  true,0.,0,"DarkNeutrino",kPdgDarkNeutrino);
195  }
196  if (!anti_dnu_particle) {
197  // Name Title Mass Stable Width Charge Class PDG
198  fDatabasePDG->AddParticle("nu_D_bar","#bar{#nu}_{D}",reg->GetDouble("Dark-NeutrinoMass"),
199  true,0.,0,"DarkNeutrino",kPdgAntiDarkNeutrino);
200  }
201  if (!med_particle) {
202  // Name Title Mass Stable Width Charge Class PDG
203  fDatabasePDG->AddParticle("Z_D","Z_{D}",reg->GetDouble("Dark-MediatorMass"),
204  true,0.,0,"DarkNeutrino",kPdgDNuMediator);
205  }
206  return true;
207 }
208 //____________________________________________________________________________
209 // EDIT: need a way to clear and then reload the PDG database
211 {
212  if(fDatabasePDG) {
213  delete fDatabasePDG;
214  }
215 
216  if( ! LoadDBase() ) LOG("PDG", pERROR) << "Could not load PDG data";
217 }
218 //____________________________________________________________________________
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
#define pERROR
Definition: Messenger.h:59
void AddDarkMatter(double mass, double med_ratio)
Definition: PDGLibrary.cxx:142
#define GetString
Definition: config.cpp:1232
std::string string
Definition: nybbler.cc:12
const int kPdgMediator
Definition: PDGCodes.h:220
#define pFATAL
Definition: Messenger.h:56
TDatabasePDG * DBase(void)
Definition: PDGLibrary.cxx:70
const int kPdgDarkMatter
Definition: PDGCodes.h:218
RgDbl GetDouble(RgKey key) const
Definition: Registry.cxx:474
TDatabasePDG * fDatabasePDG
Definition: PDGLibrary.h:59
QCString file_name
const int kPdgAntiDarkNeutrino
Definition: PDGCodes.h:223
Registry * CommonList(const string &file_id, const string &set_name) const
static PDGLibrary * fInstance
Definition: PDGLibrary.h:58
const int kPdgNHL
Definition: PDGCodes.h:221
void AddNHL(double mass)
Definition: PDGLibrary.cxx:165
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
bool LoadDBase(void)
Definition: PDGLibrary.cxx:89
#define pINFO
Definition: Messenger.h:62
virtual ~PDGLibrary()
Definition: PDGLibrary.cxx:52
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:57
const int kPdgDNuMediator
Definition: PDGCodes.h:224
Singleton class to load & serve a TDatabasePDG.
Definition: PDGLibrary.h:32
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
TParticlePDG * Find(int pdgc, bool must_exist=true)
Definition: PDGLibrary.cxx:75
const int kPdgDarkNeutrino
Definition: PDGCodes.h:222
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
void ReloadDBase(void)
Definition: PDGLibrary.cxx:210
static AlgConfigPool * Instance()