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