GENIEGenerator
Loading...
Searching...
No Matches
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 <c.andreopoulos \at cern.ch> University of Liverpool
Created:\n January 31, 2013
License:\n Copyright (c) 2003-2025, The GENIE Collaboration
For the full text of the license visit http://copyright.genie-mc.org

Function Documentation

◆ CacheFile()

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 OpenCacheFile(string filename)
cache file
Definition Cache.cxx:183
static Cache * Instance(void)
Definition Cache.cxx:67

References genie::Cache::Instance(), and genie::Cache::OpenCacheFile().

Referenced by Initialize(), and main().

◆ MesgThresholds()

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) {
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}
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
#define pWARN
Definition Messenger.h:60
A more convenient interface to the log4cpp Message Service.
Definition Messenger.h:259
bool SetPrioritiesFromXmlFile(string filename)
static Messenger * Instance(void)
Definition Messenger.cxx:49
vector< string > Split(string input, string delim)

References genie::Messenger::Instance(), LOG, pWARN, genie::Messenger::SetPrioritiesFromXmlFile(), and genie::utils::str::Split().

Referenced by Initialize(), and main().

◆ RandGen()

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) {
35 }
36}
static RandomGen * Instance()
Access instance.
Definition RandomGen.cxx:74
void SetSeed(long int seed)
Definition RandomGen.cxx:85

References genie::RandomGen::Instance(), and genie::RandomGen::SetSeed().

Referenced by Initialize(), and main().

◆ XSecTable()

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
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)) {
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}
#define pFATAL
Definition Messenger.h:56
List of cross section vs energy splines.
XmlParserStatus_t LoadFromXml(const string &filename, bool keep=false)
static XSecSplineList * Instance()
bool FileExists(string filename)
string GetXMLFilePath(string basename)
enum genie::EXmlParseStatus XmlParserStatus_t
bool gAbortingInErr
Definition Messenger.cxx:34

References genie::utils::system::FileExists(), genie::gAbortingInErr, genie::utils::xml::GetXMLFilePath(), genie::XSecSplineList::Instance(), genie::kXmlOK, genie::XSecSplineList::LoadFromXml(), LOG, pFATAL, and pWARN.

Referenced by Initialize(), and main().