AppInit.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 //____________________________________________________________________________
11 
12 // for exit()
13 #include <cstdlib>
14 
15 #include <TSystem.h>
16 
17 //#include "Framework/Conventions/XmlParserStatus.h"
20 #include "Framework/Utils/Cache.h"
26 
27 using namespace genie;
28 
29 //___________________________________________________________________________
30 
32 {
33  // Set random number seed, if a value was set at the command-line.
34  if(seed > 0) {
36  }
37 }
38 //___________________________________________________________________________
39 void genie::utils::app_init::XSecTable (string inpfile, bool require_table)
40 {
41  // Load cross-section splines using file specified at the command-line.
42 
44 
45  // don't try to expand if no filename actually given ...
46  string expandedinpfile = "";
47  string fullinpfile = "";
48  if ( inpfile != "" ) {
49  // expand in case of embedded env var or ~
50  expandedinpfile = gSystem->ExpandPathName(inpfile.c_str());
51  if (utils::system::FileExists(expandedinpfile)) {
52  // use the file as given if possible
53  fullinpfile = expandedinpfile;
54  } else {
55  // look for file in $GXMLPATH, then $GENIE/config
56  // return input name if not found any of those places (thus allowing CWD)
57  fullinpfile = genie::utils::xml::GetXMLFilePath(expandedinpfile);
58  }
59  }
60 
61  // file was specified & exists - load table
62  if (utils::system::FileExists(fullinpfile)) {
63  xspl = XSecSplineList::Instance();
64  XmlParserStatus_t status = xspl->LoadFromXml(fullinpfile);
65  if (status != kXmlOK) {
66  LOG("AppInit", pFATAL)
67  << "Problem reading file: " << expandedinpfile;
68  gAbortingInErr = true;
69  exit(1);
70  }
71  }
72 
73  // file doesn't exist
74  else {
75  // if one was specified, report & exit
76  if (inpfile.size() > 0) {
77  LOG("AppInit", pFATAL)
78  << "Input cross-section file [" << inpfile << "] does not exist!\n"
79  << "looked for " << expandedinpfile << " in $GXMLPATH locations ";
80  gAbortingInErr = true;
81  exit(1);
82  }
83  // if one was not specified, warn and decide whether to exit based on the
84  // input `require_table' flag
85  else {
86  if(!require_table) {
87  LOG("AppInit", pWARN) << "No cross-section file was specified in the application inputs";
88  LOG("AppInit", pWARN) << "If none is loaded, event generation might be inefficient";
89  } else {
90  LOG("AppInit", pFATAL) << "No cross-section file was specified in the application inputs";
91  LOG("AppInit", pFATAL) << "This is mandatory as, otherwise, event generation will be prohibitively inefficient";
92  gAbortingInErr = true;
93  exit(1);
94  }
95  }
96  }
97 
98 }
99 //___________________________________________________________________________
101 {
102  std::vector<std::string> files = genie::utils::str::Split(filelist,":;,");
103  for (size_t i=0; i < files.size(); ++i ) {
104  std::string inp_file = files[i];
105  if(inp_file.size() > 0) {
107  bool ok = m->SetPrioritiesFromXmlFile(inp_file);
108  if(!ok) {
109  LOG("AppInit", pWARN)
110  << "Could not load customized mesg thresholds from: "
111  << inp_file;
112  }
113  }
114  }
115 
116 }
117 //___________________________________________________________________________
119 {
120  if(inp_file.size() > 0) {
121  Cache::Instance()->OpenCacheFile(inp_file);
122  }
123 }
124 //___________________________________________________________________________
125 
void RandGen(long int seed)
Definition: AppInit.cxx:31
void XSecTable(string inpfile, bool require_table)
Definition: AppInit.cxx:39
int status
Definition: fabricate.py:1613
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:79
bool FileExists(string filename)
Definition: SystemUtils.cxx:90
#define pFATAL
Definition: Messenger.h:57
static XSecSplineList * Instance()
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
unsigned int seed
Definition: runWimpSim.h:102
void OpenCacheFile(string filename)
cache file
Definition: Cache.cxx:192
bool SetPrioritiesFromXmlFile(string filename)
Definition: Messenger.cxx:136
static Messenger * Instance(void)
Definition: Messenger.cxx:71
string GetXMLFilePath(string basename)
#define pWARN
Definition: Messenger.h:61
A more convenient interface to the log4cpp Message Service.
Definition: Messenger.h:261
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:42
exit(0)
void MesgThresholds(string inpfile)
Definition: AppInit.cxx:100
static Cache * Instance(void)
Definition: Cache.cxx:76
enum genie::EXmlParseStatus XmlParserStatus_t
bool gAbortingInErr
Definition: Messenger.cxx:56
List of cross section vs energy splines.
XmlParserStatus_t LoadFromXml(const string &filename, bool keep=false)
void CacheFile(string inpfile)
Definition: AppInit.cxx:118
void SetSeed(long int seed)
Definition: RandomGen.cxx:90