GENIEGenerator
Loading...
Searching...
No Matches
AppInit.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, 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//____________________________________________________________________________
10
11// for exit()
12#include <cstdlib>
13
14#include <TSystem.h>
15
16//#include "Framework/Conventions/XmlParserStatus.h"
25
26using namespace genie;
27
28//___________________________________________________________________________
29
31{
32 // Set random number seed, if a value was set at the command-line.
33 if(seed > 0) {
35 }
36}
37//___________________________________________________________________________
38void genie::utils::app_init::XSecTable (string inpfile, bool require_table)
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}
98//___________________________________________________________________________
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}
116//___________________________________________________________________________
118{
119 if(inp_file.size() > 0) {
120 Cache::Instance()->OpenCacheFile(inp_file);
121 }
122}
123//___________________________________________________________________________
#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
#define pWARN
Definition Messenger.h:60
void OpenCacheFile(string filename)
cache file
Definition Cache.cxx:183
static Cache * Instance(void)
Definition Cache.cxx:67
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
static RandomGen * Instance()
Access instance.
Definition RandomGen.cxx:74
void SetSeed(long int seed)
Definition RandomGen.cxx:85
List of cross section vs energy splines.
XmlParserStatus_t LoadFromXml(const string &filename, bool keep=false)
static XSecSplineList * Instance()
void XSecTable(string inpfile, bool require_table)
Definition AppInit.cxx:38
void RandGen(long int seed)
Definition AppInit.cxx:30
void MesgThresholds(string inpfile)
Definition AppInit.cxx:99
void CacheFile(string inpfile)
Definition AppInit.cxx:117
vector< string > Split(string input, string delim)
bool FileExists(string filename)
string GetXMLFilePath(string basename)
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
enum genie::EXmlParseStatus XmlParserStatus_t
bool gAbortingInErr
Definition Messenger.cxx:34