Functions | Variables
gSplineAdd.cxx File Reference
#include <cassert>
#include <sstream>
#include <string>
#include <vector>
#include <TSystem.h>
#include "Framework/EventGen/XSecAlgorithmI.h"
#include "Framework/Conventions/XmlParserStatus.h"
#include "Framework/Messenger/Messenger.h"
#include "Framework/Utils/RunOpt.h"
#include "Framework/Utils/AppInit.h"
#include "Framework/Utils/XSecSplineList.h"
#include "Framework/Utils/StringUtils.h"
#include "Framework/Utils/SystemUtils.h"
#include "Framework/Utils/CmdLnArgParser.h"

Go to the source code of this file.

Functions

vector< stringGetAllInputFiles (void)
 
void GetCommandLineArgs (int argc, char **argv)
 
void PrintSyntax (void)
 
int main (int argc, char **argv)
 

Variables

string gOutFile
 output XML file More...
 
vector< stringgInpFiles
 list of input XML files More...
 
vector< stringgInpDirs
 list of input dirs (to look for XML files) More...
 
vector< stringgAllFiles
 list of all input files More...
 

Function Documentation

vector< string > GetAllInputFiles ( void  )

Definition at line 112 of file gSplineAdd.cxx.

113 {
114  vector<string> files;
115 
118 
119  // add all files that were input explictly
120  file_iter = gInpFiles.begin();
121  for( ; file_iter != gInpFiles.end(); ++file_iter) {
122  string filename = *file_iter;
123  files.push_back(filename);
124  } // file_iter
125 
126  // loop over input directories
127  dir_iter = gInpDirs.begin();
128  for( ; dir_iter != gInpDirs.end(); ++dir_iter) {
129  string path = *dir_iter;
130  // get all XML files in this dir
131  vector<string> path_files = utils::system::GetAllFilesInPath(path,"xml");
132  // add these files too
133  file_iter = path_files.begin();
134  for( ; file_iter != path_files.end(); ++file_iter) {
135  string filename = *file_iter;
136  files.push_back(filename);
137  }//file_iter
138  }//dir_iter
139 
140  return files;
141 }
vector< string > gInpFiles
list of input XML files
Definition: gSplineAdd.cxx:82
vector< string > GetAllFilesInPath(string path, string extension="")
Definition: SystemUtils.cxx:29
intermediate_table::const_iterator const_iterator
string filename
Definition: train.py:213
list files
Definition: languages.py:9
vector< string > gInpDirs
list of input dirs (to look for XML files)
Definition: gSplineAdd.cxx:83
void GetCommandLineArgs ( int  argc,
char **  argv 
)

Definition at line 143 of file gSplineAdd.cxx.

144 {
145  LOG("gspladd", pNOTICE) << "Parsing command line arguments";
146 
147  // Common run options.
148  RunOpt::Instance()->ReadFromCommandLine(argc,argv);
149 
150  // Parse run options for this app
151 
152  CmdLnArgParser parser(argc,argv);
153 
154  if( parser.OptionExists('f') ) {
155  LOG("gspladd", pINFO) << "Reading input files";
156  string inpfiles = parser.ArgAsString('f');
157  if(inpfiles.find(",") != string::npos) {
158  // split the comma separated list
159  gInpFiles = utils::str::Split(inpfiles, ",");
160  } else {
161  // there is just one file
162  gInpFiles.push_back(inpfiles);
163  }
164  }
165 
166  if( parser.OptionExists('d') ) {
167  LOG("gspladd", pINFO) << "Reading input directories";
168  string inpdirs = parser.ArgAsString('d');
169  if(inpdirs.find(",") != string::npos) {
170  // split the comma separated list
171  gInpDirs = utils::str::Split(inpdirs, ",");
172  } else {
173  // there is just one directory
174  gInpDirs.push_back(inpdirs);
175  }
176  }
177 
178  if( parser.OptionExists('o') ) {
179  LOG("gspladd", pINFO) << "Reading output file name";
180  gOutFile = parser.ArgAsString('o');
181  } else {
182  LOG("gspladd", pFATAL) << "You must specify an output file name";
183  PrintSyntax();
184  exit(1);
185  }
186 
188  if(gAllFiles.size() <= 1) {
189  LOG("gspladd", pFATAL) << "There must be at least 2 input files";
190  PrintSyntax();
191  exit(1);
192  }
193 }
vector< string > gInpFiles
list of input XML files
Definition: gSplineAdd.cxx:82
vector< string > GetAllInputFiles(void)
Definition: gSplineAdd.cxx:112
vector< string > gAllFiles
list of all input files
Definition: gSplineAdd.cxx:84
#define pFATAL
Definition: Messenger.h:56
void PrintSyntax(void)
Definition: gSplineAdd.cxx:195
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
vector< string > gInpDirs
list of input dirs (to look for XML files)
Definition: gSplineAdd.cxx:83
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
Command line argument parser.
#define pNOTICE
Definition: Messenger.h:61
string gOutFile
output XML file
Definition: gSplineAdd.cxx:81
int main ( int  argc,
char **  argv 
)

Definition at line 87 of file gSplineAdd.cxx.

88 {
90 
91  utils::app_init::MesgThresholds(RunOpt::Instance()->MesgThresholdFiles());
92 
93  XSecSplineList * xspl = XSecSplineList::Instance();
94 
95  vector<string>::const_iterator file_iter = gAllFiles.begin();
96  for( ; file_iter != gAllFiles.end(); ++file_iter) {
97  string filename = *file_iter;
98  LOG("gspladd", pNOTICE) << " ---- >> Loading file : " << filename;
99  XmlParserStatus_t ist = xspl->LoadFromXml(filename, true);
100  assert(ist==kXmlOK);
101  }
102 
103  LOG("gspladd",pDEBUG) << *xspl ;
104 
105  LOG("gspladd", pNOTICE)
106  << " ****** Saving all loaded splines into : " << gOutFile;
107  xspl->SaveAsXml(gOutFile);
108 
109  return 0;
110 }
vector< string > gAllFiles
list of all input files
Definition: gSplineAdd.cxx:84
intermediate_table::const_iterator const_iterator
string filename
Definition: train.py:213
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
void GetCommandLineArgs(int argc, char **argv)
Definition: gSplineAdd.cxx:143
void SaveAsXml(const string &filename, bool save_init=true) const
void MesgThresholds(string inpfile)
Definition: AppInit.cxx:99
#define pNOTICE
Definition: Messenger.h:61
enum genie::EXmlParseStatus XmlParserStatus_t
List of cross section vs energy splines.
XmlParserStatus_t LoadFromXml(const string &filename, bool keep=false)
string gOutFile
output XML file
Definition: gSplineAdd.cxx:81
#define pDEBUG
Definition: Messenger.h:63
void PrintSyntax ( void  )

Definition at line 195 of file gSplineAdd.cxx.

196 {
197  LOG("gspladd", pNOTICE)
198  << "\n\n" << "Syntax:" << "\n"
199  << " gspladd -f file_list -d directory_list -o output.xml\n"
200  << " [--message-thresholds xml_file]\n";
201 
202 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pNOTICE
Definition: Messenger.h:61

Variable Documentation

vector<string> gAllFiles

list of all input files

Definition at line 84 of file gSplineAdd.cxx.

vector<string> gInpDirs

list of input dirs (to look for XML files)

Definition at line 83 of file gSplineAdd.cxx.

vector<string> gInpFiles

list of input XML files

Definition at line 82 of file gSplineAdd.cxx.

string gOutFile

output XML file

Definition at line 81 of file gSplineAdd.cxx.