Functions
genie::utils::app_init Namespace Reference

Initialization code commonly occuring in GENIE apps, factored out from existing apps for convenience. Not generic GENIE initialization code. More...

Functions

void RandGen (long int seed)
 
void XSecTable (string inpfile, bool require_table)
 
void MesgThresholds (string inpfile)
 
void CacheFile (string inpfile)
 

Detailed Description

Initialization code commonly occuring in GENIE apps, factored out from existing apps for convenience. Not generic GENIE initialization code.

Author
Costas Andreopoulos <constantinos.andreopoulos cern.ch> University of Liverpool & STFC Rutherford Appleton Laboratory

January 31, 2013

Copyright (c) 2003-2020, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Function Documentation

void genie::utils::app_init::CacheFile ( string  inpfile)

Definition at line 117 of file AppInit.cxx.

118 {
119  if(inp_file.size() > 0) {
120  Cache::Instance()->OpenCacheFile(inp_file);
121  }
122 }
void genie::utils::app_init::MesgThresholds ( string  inpfile)

Definition at line 99 of file AppInit.cxx.

100 {
101  std::vector<std::string> files = genie::utils::str::Split(filelist,":;,");
102  for (size_t i=0; i < files.size(); ++i ) {
103  std::string inp_file = files[i];
104  if(inp_file.size() > 0) {
105  Messenger * m = Messenger::Instance();
106  bool ok = m->SetPrioritiesFromXmlFile(inp_file);
107  if(!ok) {
108  LOG("AppInit", pWARN)
109  << "Could not load customized mesg thresholds from: "
110  << inp_file;
111  }
112  }
113  }
114 
115 }
std::string string
Definition: nybbler.cc:12
list files
Definition: languages.py:9
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
bool SetPrioritiesFromXmlFile(string filename)
Definition: Messenger.cxx:114
#define pWARN
Definition: Messenger.h:60
A more convenient interface to the log4cpp Message Service.
Definition: Messenger.h:258
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
void genie::utils::app_init::RandGen ( long int  seed)

Definition at line 30 of file AppInit.cxx.

31 {
32  // Set random number seed, if a value was set at the command-line.
33  if(seed > 0) {
34  RandomGen::Instance()->SetSeed(seed);
35  }
36 }
void genie::utils::app_init::XSecTable ( string  inpfile,
bool  require_table 
)

Definition at line 38 of file AppInit.cxx.

39 {
40  // Load cross-section splines using file specified at the command-line.
41 
42  XSecSplineList * xspl = XSecSplineList::Instance();
43 
44  // don't try to expand if no filename actually given ...
45  string expandedinpfile = "";
46  string fullinpfile = "";
47  if ( inpfile != "" ) {
48  // expand in case of embedded env var or ~
49  expandedinpfile = gSystem->ExpandPathName(inpfile.c_str());
50  if (utils::system::FileExists(expandedinpfile)) {
51  // use the file as given if possible
52  fullinpfile = expandedinpfile;
53  } else {
54  // look for file in $GXMLPATH, then $GENIE/config
55  // return input name if not found any of those places (thus allowing CWD)
56  fullinpfile = genie::utils::xml::GetXMLFilePath(expandedinpfile);
57  }
58  }
59 
60  // file was specified & exists - load table
61  if (utils::system::FileExists(fullinpfile)) {
62  xspl = XSecSplineList::Instance();
63  XmlParserStatus_t status = xspl->LoadFromXml(fullinpfile);
64  if (status != kXmlOK) {
65  LOG("AppInit", pFATAL)
66  << "Problem reading file: " << expandedinpfile;
67  gAbortingInErr = true;
68  exit(1);
69  }
70  }
71 
72  // file doesn't exist
73  else {
74  // if one was specified, report & exit
75  if (inpfile.size() > 0) {
76  LOG("AppInit", pFATAL)
77  << "Input cross-section file [" << inpfile << "] does not exist!\n"
78  << "looked for " << expandedinpfile << " in $GXMLPATH locations ";
79  gAbortingInErr = true;
80  exit(1);
81  }
82  // if one was not specified, warn and decide whether to exit based on the
83  // input `require_table' flag
84  else {
85  if(!require_table) {
86  LOG("AppInit", pWARN) << "No cross-section file was specified in the application inputs";
87  LOG("AppInit", pWARN) << "If none is loaded, event generation might be inefficient";
88  } else {
89  LOG("AppInit", pFATAL) << "No cross-section file was specified in the application inputs";
90  LOG("AppInit", pFATAL) << "This is mandatory as, otherwise, event generation will be prohibitively inefficient";
91  gAbortingInErr = true;
92  exit(1);
93  }
94  }
95  }
96 
97 }
bool FileExists(string filename)
Definition: SystemUtils.cxx:80
#define pFATAL
Definition: Messenger.h:56
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
string GetXMLFilePath(string basename)
#define pWARN
Definition: Messenger.h:60
enum genie::EXmlParseStatus XmlParserStatus_t
bool gAbortingInErr
Definition: Messenger.cxx:34
List of cross section vs energy splines.
XmlParserStatus_t LoadFromXml(const string &filename, bool keep=false)