GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions | Variables
gMakeSplines.cxx File Reference
#include <cassert>
#include <cstdlib>
#include <string>
#include <vector>
#include <TSystem.h>
#include "Framework/Conventions/GBuild.h"
#include "Framework/EventGen/GEVGDriver.h"
#include "Framework/Interaction/Interaction.h"
#include "Framework/Messenger/Messenger.h"
#include "Framework/Numerical/RandomGen.h"
#include "Framework/ParticleData/PDGCodeList.h"
#include "Framework/Utils/RunOpt.h"
#include "Framework/Utils/AppInit.h"
#include "Framework/Utils/StringUtils.h"
#include "Framework/Utils/PrintUtils.h"
#include "Framework/Utils/XSecSplineList.h"
#include "Framework/Utils/CmdLnArgParser.h"
Include dependency graph for gMakeSplines.cxx:

Go to the source code of this file.

Functions

void GetCommandLineArgs (int argc, char **argv)
 
void PrintSyntax (void)
 
PDGCodeListGetNeutrinoCodes (void)
 
PDGCodeListGetTargetCodes (void)
 
int main (int argc, char **argv)
 

Variables

string gOptNuPdgCodeList = ""
 
string gOptTgtPdgCodeList = ""
 
string gOptGeomFilename = ""
 
int gOptNKnots = -1
 
double gOptMaxE = -1.
 
bool gOptNoCopy = false
 
long int gOptRanSeed = -1
 
string gOptInpXSecFile = ""
 
string gOptOutXSecFile = ""
 

Function Documentation

void GetCommandLineArgs ( int  argc,
char **  argv 
)
PDGCodeList * GetNeutrinoCodes ( void  )

Definition at line 366 of file gMakeSplines.cxx.

References gOptNuPdgCodeList, genie::PDGCodeList::push_back(), and genie::utils::str::Split().

Referenced by main().

367 {
368  // split the comma separated list
369  vector<string> nuvec = utils::str::Split(gOptNuPdgCodeList, ",");
370 
371  // fill in the PDG code list
372  PDGCodeList * list = new PDGCodeList;
373  vector<string>::const_iterator iter;
374  for(iter = nuvec.begin(); iter != nuvec.end(); ++iter) {
375  list->push_back( atoi(iter->c_str()) );
376  }
377  return list;
378 }
string gOptNuPdgCodeList
A list of PDG codes.
Definition: PDGCodeList.h:32
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
void push_back(int pdg_code)
Definition: PDGCodeList.cxx:58
PDGCodeList * GetTargetCodes ( void  )

Definition at line 380 of file gMakeSplines.cxx.

References genie::gAbortingInErr, geom, gOptGeomFilename, gOptTgtPdgCodeList, genie::geometry::ROOTGeomAnalyzer::ListOfTargetNuclei(), LOG, pFATAL, pINFO, genie::PDGCodeList::push_back(), and genie::utils::str::Split().

Referenced by main().

381 {
382  bool from_geom_file = ( gOptGeomFilename.size() > 0 );
383  bool from_cmd_line = ( gOptTgtPdgCodeList.size() > 0 );
384 
385  if (from_cmd_line) {
386  // split the comma separated list
387  vector<string> tgtvec = utils::str::Split(gOptTgtPdgCodeList, ",");
388 
389  // fill in the PDG code list
390  PDGCodeList * list = new PDGCodeList;
391  vector<string>::const_iterator iter;
392  for(iter = tgtvec.begin(); iter != tgtvec.end(); ++iter) {
393  list->push_back( atoi(iter->c_str()) );
394  }
395  return list;
396  }
397 
398  if (from_geom_file) {
399 #ifdef __GENIE_GEOM_DRIVERS_ENABLED__
400  // create/configure a geometry driver
401  LOG("gmkspl", pINFO) << "Creating/configuring a ROOT geom. driver";
403 
404  PDGCodeList * list = new PDGCodeList(geom->ListOfTargetNuclei());
405 
406  delete geom;
407  return list;
408 #else
409  LOG("gmkspl", pFATAL)
410  << "To read-in a ROOT geometry you need to enable the geometry drivers!";
411  gAbortingInErr = true;
412  exit(1);
413  return 0;
414 #endif
415 
416  }
417  return 0;
418 }
#define pFATAL
Definition: Messenger.h:56
virtual const PDGCodeList & ListOfTargetNuclei(void)
implement the GeomAnalyzerI interface
A list of PDG codes.
Definition: PDGCodeList.h:32
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
string geom
string gOptTgtPdgCodeList
A ROOT/GEANT4 geometry driver.
#define pINFO
Definition: Messenger.h:62
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
bool gAbortingInErr
Definition: Messenger.cxx:34
void push_back(int pdg_code)
Definition: PDGCodeList.cxx:58
string gOptGeomFilename
int main ( int  argc,
char **  argv 
)

Definition at line 145 of file gMakeSplines.cxx.

References genie::RunOpt::BuildTune(), genie::GEVGDriver::Configure(), genie::GEVGDriver::CreateSplines(), GetCommandLineArgs(), GetNeutrinoCodes(), GetTargetCodes(), gOptInpXSecFile, gOptMaxE, gOptNKnots, gOptNoCopy, gOptOutXSecFile, gOptRanSeed, genie::RunOpt::Instance(), genie::XSecSplineList::Instance(), LOG, genie::utils::app_init::MesgThresholds(), pFATAL, pINFO, PrintSyntax(), genie::utils::app_init::RandGen(), genie::XSecSplineList::SaveAsXml(), genie::GEVGDriver::SetEventGeneratorList(), and genie::utils::app_init::XSecTable().

146 {
147  // Parse command line arguments
148  GetCommandLineArgs(argc,argv);
149 
150  if ( ! RunOpt::Instance()->Tune() ) {
151  LOG("gmkspl", pFATAL) << " No TuneId in RunOption";
152  exit(-1);
153  }
154  RunOpt::Instance()->BuildTune();
155 
156  // throw on NaNs and Infs...
157 #if defined(HAVE_FENV_H) && defined(HAVE_FEENABLEEXCEPT)
158  feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
159 #endif
160 
161  // Init
162  utils::app_init::MesgThresholds(RunOpt::Instance()->MesgThresholdFiles());
165 
166  // Get list of neutrinos and nuclear targets
167 
168  PDGCodeList * neutrinos = GetNeutrinoCodes();
169  PDGCodeList * targets = GetTargetCodes();
170 
171  if(!neutrinos || neutrinos->size() == 0 ) {
172  LOG("gmkspl", pFATAL) << "Empty neutrino PDG code list";
173  PrintSyntax();
174  exit(2);
175  }
176  if(!targets || targets->size() == 0 ) {
177  LOG("gmkspl", pFATAL) << "Empty target PDG code list";
178  PrintSyntax();
179  exit(3);
180  }
181 
182  LOG("gmkspl", pINFO) << "Neutrinos: " << *neutrinos;
183  LOG("gmkspl", pINFO) << "Targets: " << *targets;
184 
185  // Loop over all possible input init states and ask the GEVGDriver
186  // to build splines for all the interactions that its loaded list
187  // of event generators can generate.
188 
189  PDGCodeList::const_iterator nuiter;
190  PDGCodeList::const_iterator tgtiter;
191  for(nuiter = neutrinos->begin(); nuiter != neutrinos->end(); ++nuiter) {
192  for(tgtiter = targets->begin(); tgtiter != targets->end(); ++tgtiter) {
193  int nupdgc = *nuiter;
194  int tgtpdgc = *tgtiter;
195  InitialState init_state(tgtpdgc, nupdgc);
196  GEVGDriver driver;
197  driver.SetEventGeneratorList(RunOpt::Instance()->EventGeneratorList());
198  driver.Configure(init_state);
200  }
201  }
202 
203  // Save the splines at the requested XML file
204  XSecSplineList * xspl = XSecSplineList::Instance();
205  bool save_init = !gOptNoCopy;
206  xspl->SaveAsXml(gOptOutXSecFile, save_init);
207 
208  delete neutrinos;
209  delete targets;
210 
211  return 0;
212 }
void RandGen(long int seed)
Definition: AppInit.cxx:30
PDGCodeList * GetTargetCodes(void)
void XSecTable(string inpfile, bool require_table)
Definition: AppInit.cxx:38
int gOptNKnots
PDGCodeList * GetNeutrinoCodes(void)
#define pFATAL
Definition: Messenger.h:56
A list of PDG codes.
Definition: PDGCodeList.h:32
string gOptOutXSecFile
string gOptInpXSecFile
Definition: gAtmoEvGen.cxx:313
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
void SetEventGeneratorList(string listname)
Definition: GEVGDriver.cxx:348
GENIE Event Generation Driver. A minimalist user interface object for generating neutrino interaction...
Definition: GEVGDriver.h:54
#define pINFO
Definition: Messenger.h:62
void SaveAsXml(const string &filename, bool save_init=true) const
void Configure(int nu_pdgc, int Z, int A)
Definition: GEVGDriver.cxx:137
double gOptMaxE
A vector of EventGeneratorI objects.
void CreateSplines(int nknots=-1, double emax=-1, bool inLogE=true)
Definition: GEVGDriver.cxx:577
void MesgThresholds(string inpfile)
Definition: AppInit.cxx:99
void GetCommandLineArgs(int argc, char **argv)
Definition: gAtmoEvGen.cxx:563
bool gOptNoCopy
List of cross section vs energy splines.
void PrintSyntax(void)
Initial State information.
Definition: InitialState.h:48
long int gOptRanSeed
Definition: gAtmoEvGen.cxx:312
void PrintSyntax ( void  )

Variable Documentation

string gOptGeomFilename = ""

Definition at line 136 of file gMakeSplines.cxx.

Referenced by GetTargetCodes(), and main().

string gOptInpXSecFile = ""

Definition at line 141 of file gMakeSplines.cxx.

double gOptMaxE = -1.

Definition at line 138 of file gMakeSplines.cxx.

Referenced by main().

int gOptNKnots = -1

Definition at line 137 of file gMakeSplines.cxx.

Referenced by main().

bool gOptNoCopy = false

Definition at line 139 of file gMakeSplines.cxx.

Referenced by main().

string gOptNuPdgCodeList = ""

Definition at line 134 of file gMakeSplines.cxx.

Referenced by GetNeutrinoCodes().

string gOptOutXSecFile = ""

Definition at line 142 of file gMakeSplines.cxx.

Referenced by main().

long int gOptRanSeed = -1

Definition at line 140 of file gMakeSplines.cxx.

string gOptTgtPdgCodeList = ""

Definition at line 135 of file gMakeSplines.cxx.

Referenced by GetTargetCodes().