gEvGen.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \program gevgen
5 
6 \brief A simple 'generic' GENIE v+A event generation driver (gevgen).
7 
8  It handles:
9  a) event generation for a fixed init state (v+A) at fixed energy, or
10  b) event generation for simple fluxes (specified either via some
11  functional form, tabular text file or a ROOT histogram) and for
12  simple 'geometries' (a target mix with its corresponding weights)
13 
14  See the GENIE manual for other apps handling experiment-specific
15  event generation cases using the outputs of detailed neutrino flux
16  simulations and realistic detector geometry descriptions.
17 
18  Syntax :
19  gevgen [-h]
20  [-r run#]
21  -n nev
22  -e energy (or energy range)
23  -p neutrino_pdg
24  -t target_pdg
25  [-f flux_description]
26  [-o outfile_name]
27  [-w]
28  [--seed random_number_seed]
29  [--cross-sections xml_file]
30  [--event-generator-list list_name]
31  [--tune genie_tune]
32  [--message-thresholds xml_file]
33  [--unphysical-event-mask mask]
34  [--event-record-print-level level]
35  [--mc-job-status-refresh-rate rate]
36  [--cache-file root_file]
37  [--xml-path config_xml_dir]
38 
39  Options :
40  [] Denotes an optional argument.
41  -h
42  Prints-out help on using gevgen and exits.
43  -n
44  Specifies the number of events to generate.
45  -r
46  Specifies the MC run number.
47  -e
48  Specifies the neutrino energy.
49  If what follows the -e option is a comma separated pair of values
50  it will be interpreted as an energy range for the flux specified
51  via the -f option (see below).
52  -p
53  Specifies the neutrino PDG code.
54  -t
55  Specifies the target PDG code (pdg format: 10LZZZAAAI) _or_ a target
56  mix (pdg codes with corresponding weights) typed as a comma-separated
57  list of pdg codes with the corresponding weight fractions in brackets,
58  eg code1[fraction1],code2[fraction2],...
59  For example, to use a target mix of 95% O16 and 5% H type:
60  `-t 1000080160[0.95],1000010010[0.05]'.
61  -f
62  Specifies the neutrino flux spectrum.
63  It can be any of:
64  -- A function:
65  eg ` -f x*x+4*exp(-x)'
66  -- A vector file:
67  The vector file should contain 2 columns corresponding to
68  energy,flux (see $GENIE/data/flux/ for few examples).
69  -- A 1-D ROOT histogram (TH1D):
70  The general syntax is `-f /full/path/file.root,object_name'
71  -o
72  Specifies the name of the output file events will be saved in.
73  -w
74  Forces generation of weighted events.
75  This option is relevant only if a neutrino flux is specified.
76  Note that 'weighted' refers to the selection of the primary
77  flux neutrino + target that were forced to interact. A weighting
78  scheme for the generated kinematics of individual processes can
79  still be in effect if enabled..
80  ** Only use that option if you understand what it means **
81  --seed
82  Random number seed.
83  --cross-sections
84  Name (incl. full path) of an XML file with pre-computed
85  cross-section values used for constructing splines.
86  --event-generator-list
87  List of event generators to load in event generation drivers.
88  [default: "Default"].
89  --tune
90  Specifies a GENIE comprehensive neutrino interaction model tune.
91  [default: "Default"].
92  --message-thresholds
93  Allows users to customize the message stream thresholds.
94  The thresholds are specified using an XML file.
95  See $GENIE/config/Messenger.xml for the XML schema.
96  --unphysical-event-mask
97  Allows users to specify a 16-bit mask to allow certain types of
98  unphysical events to be written in the output file.
99  [default: all unphysical events are rejected]
100  --event-record-print-level
101  Allows users to set the level of information shown when the event
102  record is printed in the screen. See GHepRecord::Print().
103  --mc-job-status-refresh-rate
104  Allows users to customize the refresh rate of the status file.
105  --cache-file
106  Allows users to specify a cache file so that the cache can be
107  re-used in subsequent MC jobs.
108  --xml-path
109  A directory to load XML files from - overrides $GXMLPATH, and $GENIE/config
110 
111  *** See the User Manual for more details and examples. ***
112 
113 \author Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
114  University of Liverpool & STFC Rutherford Appleton Lab
115 
116 \created October 05, 2004
117 
118 \cpright Copyright (c) 2003-2019, The GENIE Collaboration
119  For the full text of the license visit http://copyright.genie-mc.org
120  or see $GENIE/LICENSE
121 */
122 //____________________________________________________________________________
123 
124 #include <cstdlib>
125 #include <cassert>
126 #include <sstream>
127 #include <string>
128 #include <vector>
129 #include <map>
130 
131 #if defined(HAVE_FENV_H) && defined(HAVE_FEENABLEEXCEPT)
132 #include <fenv.h> // for `feenableexcept`
133 #endif
134 
135 #include <TFile.h>
136 #include <TTree.h>
137 #include <TSystem.h>
138 #include <TVector3.h>
139 #include <TH1.h>
140 #include <TF1.h>
141 
158 #include "Framework/Utils/AppInit.h"
159 #include "Framework/Utils/RunOpt.h"
165 
166 #ifdef __GENIE_FLUX_DRIVERS_ENABLED__
167 #ifdef __GENIE_GEOM_DRIVERS_ENABLED__
168 #define __CAN_GENERATE_EVENTS_USING_A_FLUX_OR_TGTMIX__
172 #endif
173 #endif
174 
175 using std::string;
176 using std::vector;
177 using std::map;
178 using std::ostringstream;
179 
180 using namespace genie;
181 using namespace genie::controls;
182 
183 void GetCommandLineArgs (int argc, char ** argv);
184 void Initialize (void);
185 void PrintSyntax (void);
186 
187 #ifdef __CAN_GENERATE_EVENTS_USING_A_FLUX_OR_TGTMIX__
188 void GenerateEventsUsingFluxOrTgtMix();
189 GeomAnalyzerI * GeomDriver (void);
190 GFluxI * FluxDriver (void);
191 GFluxI * MonoEnergeticFluxDriver (void);
192 GFluxI * TH1FluxDriver (void);
193 #endif
194 
196 
197 //Default options (override them using the command line arguments):
198 int kDefOptNevents = 0; // n-events to generate
200 Long_t kDefOptRunNu = 0; // default run number
201 
202 //User-specified options:
203 int gOptNevents; // n-events to generate
204 double gOptNuEnergy; // neutrino E, or min neutrino energy in spectrum
205 double gOptNuEnergyRange;// energy range in input spectrum
206 int gOptNuPdgCode; // neutrino PDG code
207 map<int,double> gOptTgtMix; // target mix (each with its relative weight)
208 Long_t gOptRunNu; // run number
209 string gOptFlux; //
210 bool gOptWeighted; //
212 long int gOptRanSeed; // random number seed
213 string gOptInpXSecFile; // cross-section splines
214 string gOptOutFileName; // Optional outfile name
215 string gOptStatFileName; // Status file name, set if gOptOutFileName was set.
216 
217 //____________________________________________________________________________
218 int main(int argc, char ** argv)
219 {
220  GetCommandLineArgs(argc,argv);
221  Initialize();
222 
223  // throw on NaNs and Infs...
224 #if defined(HAVE_FENV_H) && defined(HAVE_FEENABLEEXCEPT)
225  feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
226 #endif
227  //
228  // Generate neutrino events
229  //
230 
232 #ifdef __CAN_GENERATE_EVENTS_USING_A_FLUX_OR_TGTMIX__
233  GenerateEventsUsingFluxOrTgtMix();
234 #else
235  LOG("gevgen", pERROR)
236  << "\n To be able to generate neutrino events from a flux and/or a target mix"
237  << "\n you need to add the following config options at your GENIE installation:"
238  << "\n --enable-flux-drivers --enable-geom-drivers \n" ;
239 #endif
240  } else {
242  }
243  return 0;
244 }
245 //____________________________________________________________________________
247 {
248 
249  if ( ! RunOpt::Instance()->Tune() ) {
250  LOG("gevgen", pFATAL) << " No TuneId in RunOption";
251  exit(-1);
252  }
254 
255  // Initialization of random number generators, cross-section table,
256  // messenger thresholds, cache file
257  utils::app_init::MesgThresholds(RunOpt::Instance()->MesgThresholdFiles());
261 
262  // Set GHEP print level
263  GHepRecord::SetPrintLevel(RunOpt::Instance()->EventRecordPrintLevel());
264 }
265 //____________________________________________________________________________
267 {
268  int neutrino = gOptNuPdgCode;
269  int target = gOptTgtMix.begin()->first;
270  double Ev = gOptNuEnergy;
271  TLorentzVector nu_p4(0.,0.,Ev,Ev); // px,py,pz,E (GeV)
272 
273  // Create init state
274  InitialState init_state(target, neutrino);
275 
276  // Create/config event generation driver
277  GEVGDriver evg_driver;
279  evg_driver.SetUnphysEventMask(*RunOpt::Instance()->UnphysEventMask());
280  evg_driver.Configure(init_state);
281 
282  // Initialize an Ntuple Writer
284 
285  // If an output file name has been specified... use it
286  if (!gOptOutFileName.empty()){
288  }
289  ntpw.Initialize();
290 
291 
292  // Create an MC Job Monitor
293  GMCJMonitor mcjmonitor(gOptRunNu);
294  mcjmonitor.SetRefreshRate(RunOpt::Instance()->MCJobStatusRefreshRate());
295 
296  // If a status file name has been given... use it
297  if (!gOptStatFileName.empty()){
299  }
300 
301 
302  LOG("gevgen", pNOTICE)
303  << "\n ** Will generate " << gOptNevents << " events for \n"
304  << init_state << " at Ev = " << Ev << " GeV";
305 
306  // Generate events / print the GHEP record / add it to the ntuple
307  int ievent = 0;
308  while (ievent < gOptNevents) {
309  LOG("gevgen", pNOTICE)
310  << " *** Generating event............ " << ievent;
311 
312  // generate a single event
313  EventRecord * event = evg_driver.GenerateEvent(nu_p4);
314 
315  if(!event) {
316  LOG("gevgen", pNOTICE)
317  << "Last attempt failed. Re-trying....";
318  continue;
319  }
320 
321  LOG("gevgen", pNOTICE)
322  << "Generated Event GHEP Record: " << *event;
323 
324  // add event at the output ntuple, refresh the mc job monitor & clean up
325  ntpw.AddEventRecord(ievent, event);
326  mcjmonitor.Update(ievent,event);
327  ievent++;
328  delete event;
329  }
330 
331  // Save the generated MC events
332  ntpw.Save();
333 }
334 //____________________________________________________________________________
335 
336 #ifdef __CAN_GENERATE_EVENTS_USING_A_FLUX_OR_TGTMIX__
337 //............................................................................
338 void GenerateEventsUsingFluxOrTgtMix(void)
339 {
340  // Get flux and geom drivers
341  GFluxI * flux_driver = FluxDriver();
342  GeomAnalyzerI * geom_driver = GeomDriver();
343 
344  // Create the monte carlo job driver
345  GMCJDriver * mcj_driver = new GMCJDriver;
347  mcj_driver->SetUnphysEventMask(*RunOpt::Instance()->UnphysEventMask());
348  mcj_driver->UseFluxDriver(flux_driver);
349  mcj_driver->UseGeomAnalyzer(geom_driver);
350  mcj_driver->Configure();
351  mcj_driver->UseSplines();
352  if(!gOptWeighted)
353  mcj_driver->ForceSingleProbScale();
354 
355  // Initialize an Ntuple Writer to save GHEP records into a TTree
357 
358  // If an output file name has been specified... use it
359  if (!gOptOutFileName.empty()){
361  }
362  ntpw.Initialize();
363 
364  // Create an MC Job Monitor
365  GMCJMonitor mcjmonitor(gOptRunNu);
366  mcjmonitor.SetRefreshRate(RunOpt::Instance()->MCJobStatusRefreshRate());
367 
368  // If a status file name has been given... use it
369  if (!gOptStatFileName.empty()){
371  }
372 
373 
374  // Generate events / print the GHEP record / add it to the ntuple
375  int ievent = 0;
376  while ( ievent < gOptNevents) {
377 
378  LOG("gevgen", pNOTICE) << " *** Generating event............ " << ievent;
379 
380  // generate a single event for neutrinos coming from the specified flux
381  EventRecord * event = mcj_driver->GenerateEvent();
382 
383  LOG("gevgen", pNOTICE) << "Generated Event GHEP Record: " << *event;
384 
385  // add event at the output ntuple, refresh the mc job monitor & clean-up
386  ntpw.AddEventRecord(ievent, event);
387  mcjmonitor.Update(ievent,event);
388  ievent++;
389  delete event;
390  }
391 
392  // Save the generated MC events
393  ntpw.Save();
394 
395  delete flux_driver;
396  delete geom_driver;
397  delete mcj_driver;;
398 }
399 //____________________________________________________________________________
400 GeomAnalyzerI * GeomDriver(void)
401 {
402 // create a trivial point geometry with the specified target or target mix
403 
405  return geom_driver;
406 }
407 //____________________________________________________________________________
408 GFluxI * FluxDriver(void)
409 {
410 // create & configure one of the generic flux drivers
411 //
412  GFluxI * flux_driver = 0;
413 
414  if(gOptNuEnergyRange<0) flux_driver = MonoEnergeticFluxDriver();
415  else flux_driver = TH1FluxDriver();
416 
417  return flux_driver;
418 }
419 //____________________________________________________________________________
420 GFluxI * MonoEnergeticFluxDriver(void)
421 {
422 //
423 //
426  GFluxI * flux_driver = dynamic_cast<GFluxI *>(flux);
427  return flux_driver;
428 }
429 //____________________________________________________________________________
430 GFluxI * TH1FluxDriver(void)
431 {
432 //
433 //
435  TH1D * spectrum = 0;
436 
437  int flux_entries = 100000;
438 
439  double emin = gOptNuEnergy;
441  double de = gOptNuEnergyRange;
442 
443  // check whether the input flux is a file or a functional form
444  //
445  bool input_is_text_file = ! gSystem->AccessPathName(gOptFlux.c_str());
446  bool input_is_root_file = gOptFlux.find(".root") != string::npos &&
447  gOptFlux.find(",") != string::npos;
448  if(input_is_text_file) {
449  //
450  // ** generate the flux histogram from the x,y pairs in the input text file
451  //
452  Spline * input_flux = new Spline(gOptFlux.c_str());
453  int n = 100;
454  double estep = (emax-emin)/(n-1);
455  double ymax = -1, ry = -1, gy = -1, e = -1;
456  for(int i=0; i<n; i++) {
457  e = emin + i*estep;
458  ymax = TMath::Max(ymax, input_flux->Evaluate(e));
459  }
460  ymax *= 1.3;
461 
463  spectrum = new TH1D("spectrum","neutrino flux", 300, emin, emax);
464  spectrum->SetDirectory(0);
465 
466  for(int ientry=0; ientry<flux_entries; ientry++) {
467  bool accept = false;
468  unsigned int iter=0;
469  while(!accept) {
470  iter++;
471  if(iter > kRjMaxIterations) {
472  LOG("gevgen", pFATAL) << "Couldn't generate a flux histogram";
473  exit(1);
474  }
475  e = emin + de * r->RndGen().Rndm();
476  gy = ymax * r->RndGen().Rndm();
477  ry = input_flux->Evaluate(e);
478  accept = gy < ry;
479  if(accept) spectrum->Fill(e);
480  }
481  }
482  delete input_flux;
483  }
484  else if(input_is_root_file) {
485  //
486  // ** extract specified flux histogram from the input root file
487  //
488  vector<string> fv = utils::str::Split(gOptFlux,",");
489  assert(fv.size()==2);
490  assert( !gSystem->AccessPathName(fv[0].c_str()) );
491 
492  LOG("gevgen", pNOTICE) << "Getting input flux from root file: " << fv[0];
493  TFile * flux_file = new TFile(fv[0].c_str(),"read");
494 
495  LOG("gevgen", pNOTICE) << "Flux name: " << fv[1];
496  TH1D * hst = (TH1D *)flux_file->Get(fv[1].c_str());
497  assert(hst);
498 
499  LOG("gevgen", pNOTICE) << hst->GetEntries();
500 
501  // Copy in the flux histogram from the root file and remove bins outside the emin,emax range
502  spectrum = (TH1D*)hst->Clone();
503  spectrum->SetNameTitle("spectrum","neutrino_flux");
504  spectrum->SetDirectory(0);
505  for(int ibin = 1; ibin <= hst->GetNbinsX(); ibin++) {
506  if(hst->GetBinLowEdge(ibin) + hst->GetBinWidth(ibin) > emax ||
507  hst->GetBinLowEdge(ibin) < emin) {
508  spectrum->SetBinContent(ibin, 0);
509  }
510  }
511 
512  LOG("gevgen", pNOTICE) << spectrum->GetEntries();
513 
514  flux_file->Close();
515  delete flux_file;
516 
517  LOG("gevgen", pNOTICE) << spectrum->GetEntries();
518 
519  } else {
520  //
521  // ** generate the flux histogram from the input functional form
522  //
523  TF1 * input_func = new TF1("input_func", gOptFlux.c_str(), emin, emax);
524  spectrum = new TH1D("spectrum","neutrino flux", 300, emin, emax);
525  spectrum->SetDirectory(0);
526  spectrum->FillRandom("input_func", flux_entries);
527  delete input_func;
528  }
529  // save input flux
530 
531  TFile f("./input-flux.root","recreate");
532  spectrum->Write();
533  f.Close();
534 
535  TVector3 bdir (0,0,1);
536  TVector3 bspot(0,0,0);
537 
538  flux->SetNuDirection (bdir);
539  flux->SetBeamSpot (bspot);
540  flux->SetTransverseRadius (-1);
541  flux->AddEnergySpectrum (gOptNuPdgCode, spectrum);
542 
543  GFluxI * flux_driver = dynamic_cast<GFluxI *>(flux);
544  return flux_driver;
545 }
546 //............................................................................
547 #endif
548 
549 //____________________________________________________________________________
550 void GetCommandLineArgs(int argc, char ** argv)
551 {
552  LOG("gevgen", pINFO) << "Parsing command line arguments";
553 
554  // Common run options. Set defaults and read.
557 
558  // Parse run options for this app
559 
560  CmdLnArgParser parser(argc,argv);
561 
562  // help?
563  bool help = parser.OptionExists('h');
564  if(help) {
565  PrintSyntax();
566  exit(0);
567  }
568 
569  // number of events
570  if( parser.OptionExists('n') ) {
571  LOG("gevgen", pINFO) << "Reading number of events to generate";
572  gOptNevents = parser.ArgAsInt('n');
573  } else {
574  LOG("gevgen", pINFO)
575  << "Unspecified number of events to generate - Using default";
577  }
578 
579  // run number
580  if( parser.OptionExists('r') ) {
581  LOG("gevgen", pINFO) << "Reading MC run number";
582  gOptRunNu = parser.ArgAsLong('r');
583  } else {
584  LOG("gevgen", pINFO) << "Unspecified run number - Using default";
586  }
587 
588  // Output file name
589  if( parser.OptionExists('o') ) {
590  LOG("gevgen", pINFO) << "Reading output file name";
591  gOptOutFileName = parser.ArgAsString('o');
592 
594  // strip the output file format and replace with .status
595  if (gOptOutFileName.find_last_of(".") != string::npos)
597  gOptStatFileName.substr(0, gOptOutFileName.find_last_of("."));
598  gOptStatFileName .append(".status");
599  }
600 
601  // flux functional form
602  bool using_flux = false;
603  if( parser.OptionExists('f') ) {
604  LOG("gevgen", pINFO) << "Reading flux function";
605  gOptFlux = parser.ArgAsString('f');
606  using_flux = true;
607  }
608 
609  if(parser.OptionExists('s')) {
610  LOG("gevgen", pWARN)
611  << "-s option no longer available. Please read the revised code documentation";
612  gAbortingInErr = true;
613  exit(1);
614  }
615 
616 
617  // generate weighted events option (only relevant if using a flux)
618  gOptWeighted = parser.OptionExists('w');
619 
620  // neutrino energy
621  if( parser.OptionExists('e') ) {
622  LOG("gevgen", pINFO) << "Reading neutrino energy";
623  string nue = parser.ArgAsString('e');
624 
625  // is it just a value or a range (comma separated set of values)
626  if(nue.find(",") != string::npos) {
627  // split the comma separated list
628  vector<string> nurange = utils::str::Split(nue, ",");
629  assert(nurange.size() == 2);
630  double emin = atof(nurange[0].c_str());
631  double emax = atof(nurange[1].c_str());
632  assert(emax>emin && emin>=0);
633  gOptNuEnergy = emin;
634  gOptNuEnergyRange = emax-emin;
635  if(!using_flux) {
636  LOG("gevgen", pWARN)
637  << "No flux was specified but an energy range was input!";
638  LOG("gevgen", pWARN)
639  << "Events will be generated at fixed E = " << gOptNuEnergy << " GeV";
640  gOptNuEnergyRange = -1;
641  }
642  } else {
643  gOptNuEnergy = atof(nue.c_str());
644  gOptNuEnergyRange = -1;
645  }
646  } else {
647  LOG("gevgen", pFATAL) << "Unspecified neutrino energy - Exiting";
648  PrintSyntax();
649  exit(1);
650  }
651 
652  // neutrino PDG code
653  if( parser.OptionExists('p') ) {
654  LOG("gevgen", pINFO) << "Reading neutrino PDG code";
655  gOptNuPdgCode = parser.ArgAsInt('p');
656  } else {
657  LOG("gevgen", pFATAL) << "Unspecified neutrino PDG code - Exiting";
658  PrintSyntax();
659  exit(1);
660  }
661 
662  // target mix (their PDG codes with their corresponding weights)
663  bool using_tgtmix = false;
664  if( parser.OptionExists('t') ) {
665  LOG("gevgen", pINFO) << "Reading target mix";
666  string stgtmix = parser.ArgAsString('t');
667  gOptTgtMix.clear();
668  vector<string> tgtmix = utils::str::Split(stgtmix,",");
669  if(tgtmix.size()==1) {
670  int pdg = atoi(tgtmix[0].c_str());
671  double wgt = 1.0;
672  gOptTgtMix.insert(map<int, double>::value_type(pdg, wgt));
673  } else {
674  using_tgtmix = true;
675  vector<string>::const_iterator tgtmix_iter = tgtmix.begin();
676  for( ; tgtmix_iter != tgtmix.end(); ++tgtmix_iter) {
677  string tgt_with_wgt = *tgtmix_iter;
678  string::size_type open_bracket = tgt_with_wgt.find("[");
679  string::size_type close_bracket = tgt_with_wgt.find("]");
680  string::size_type ibeg = 0;
681  string::size_type iend = open_bracket;
682  string::size_type jbeg = open_bracket+1;
683  string::size_type jend = close_bracket-1;
684  int pdg = atoi(tgt_with_wgt.substr(ibeg,iend).c_str());
685  double wgt = atof(tgt_with_wgt.substr(jbeg,jend).c_str());
686  LOG("Main", pNOTICE)
687  << "Adding to target mix: pdg = " << pdg << ", wgt = " << wgt;
688  gOptTgtMix.insert(map<int, double>::value_type(pdg, wgt));
689  }//tgtmix_iter
690  }//>1
691 
692  } else {
693  LOG("gevgen", pFATAL) << "Unspecified target PDG code - Exiting";
694  PrintSyntax();
695  exit(1);
696  }
697 
698  gOptUsingFluxOrTgtMix = using_flux || using_tgtmix;
699 
700  // random number seed
701  if( parser.OptionExists("seed") ) {
702  LOG("gevgen", pINFO) << "Reading random number seed";
703  gOptRanSeed = parser.ArgAsLong("seed");
704  } else {
705  LOG("gevgen", pINFO) << "Unspecified random number seed - Using default";
706  gOptRanSeed = -1;
707  }
708 
709  // input cross-section file
710  if( parser.OptionExists("cross-sections") ) {
711  LOG("gevgen", pINFO) << "Reading cross-section file";
712  gOptInpXSecFile = parser.ArgAsString("cross-sections");
713  } else {
714  LOG("gevgen", pINFO) << "Unspecified cross-section file";
715  gOptInpXSecFile = "";
716  }
717 
718  //
719  // print-out the command line options
720  //
721  LOG("gevgen", pNOTICE)
722  << "\n"
723  << utils::print::PrintFramedMesg("gevgen job configuration");
724  LOG("gevgen", pNOTICE)
725  << "MC Run Number: " << gOptRunNu;
726  if(gOptRanSeed != -1) {
727  LOG("gevgen", pNOTICE)
728  << "Random number seed: " << gOptRanSeed;
729  } else {
730  LOG("gevgen", pNOTICE)
731  << "Random number seed was not set, using default";
732  }
733  LOG("gevgen", pNOTICE)
734  << "Number of events requested: " << gOptNevents;
735  if(gOptInpXSecFile.size() > 0) {
736  LOG("gevgen", pNOTICE)
737  << "Using cross-section splines read from: " << gOptInpXSecFile;
738  } else {
739  LOG("gevgen", pNOTICE)
740  << "No input cross-section spline file";
741  }
742  LOG("gevgen", pNOTICE)
743  << "Flux: " << gOptFlux;
744  LOG("gevgen", pNOTICE)
745  << "Generate weighted events? " << gOptWeighted;
746  if(gOptNuEnergyRange>0) {
747  LOG("gevgen", pNOTICE)
748  << "Neutrino energy: ["
749  << gOptNuEnergy << ", " << gOptNuEnergy+gOptNuEnergyRange << "]";
750  } else {
751  LOG("gevgen", pNOTICE)
752  << "Neutrino energy: " << gOptNuEnergy;
753  }
754  LOG("gevgen", pNOTICE)
755  << "Neutrino code (PDG): " << gOptNuPdgCode;
756  LOG("gevgen", pNOTICE)
757  << "Target code (PDG) & weight fraction (in case of multiple targets): ";
758  map<int,double>::const_iterator iter;
759  for(iter = gOptTgtMix.begin(); iter != gOptTgtMix.end(); ++iter) {
760  int tgtpdgc = iter->first;
761  double wgt = iter->second;
762  LOG("gevgen", pNOTICE)
763  << " >> " << tgtpdgc << " (weight fraction = " << wgt << ")";
764  }
765  LOG("gevgen", pNOTICE) << "\n";
766 
767  LOG("gevgen", pNOTICE) << *RunOpt::Instance();
768 
769 }
770 //____________________________________________________________________________
771 void PrintSyntax(void)
772 {
773  LOG("gevgen", pNOTICE)
774  << "\n\n" << "Syntax:" << "\n"
775  << "\n gevgen [-h]"
776  << "\n [-r run#]"
777  << "\n -n nev"
778  << "\n -e energy (or energy range) "
779  << "\n -p neutrino_pdg"
780  << "\n -t target_pdg "
781  << "\n [-f flux_description]"
782  << "\n [-o outfile_name]"
783  << "\n [-w]"
784  << "\n [--seed random_number_seed]"
785  << "\n [--cross-sections xml_file]"
786  << "\n [--event-generator-list list_name]"
787  << "\n [--message-thresholds xml_file]"
788  << "\n [--unphysical-event-mask mask]"
789  << "\n [--event-record-print-level level]"
790  << "\n [--mc-job-status-refresh-rate rate]"
791  << "\n [--cache-file root_file]"
792  << "\n [--xml-path config_xml_dir]"
793  << "\n";
794 }
795 //____________________________________________________________________________
void RandGen(long int seed)
Definition: AppInit.cxx:31
static void SetPrintLevel(int print_level)
Definition: GHepRecord.cxx:992
void XSecTable(string inpfile, bool require_table)
Definition: AppInit.cxx:39
long int gOptRanSeed
Definition: gEvGen.cxx:212
long ArgAsLong(char opt)
void SetUnphysEventMask(const TBits &mask)
Definition: GMCJDriver.cxx:165
Long_t kDefOptRunNu
Definition: gEvGen.cxx:200
const XML_Char * target
Definition: expat.h:268
string ArgAsString(char opt)
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
#define pERROR
Definition: Messenger.h:60
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:79
void SetEventGeneratorList(string listname)
Definition: GMCJDriver.cxx:157
Long_t gOptRunNu
Definition: gEvGen.cxx:208
void CustomizeFilename(string filename)
Definition: NtpWriter.cxx:118
void ReadFromCommandLine(int argc, char **argv)
Definition: RunOpt.cxx:107
NtpMCFormat_t kDefOptNtpFormat
Definition: gEvGen.cxx:199
A numeric analysis tool class for interpolating 1-D functions.
Definition: Spline.h:47
#define pFATAL
Definition: Messenger.h:57
int gOptNuPdgCode
Definition: gEvGen.cxx:206
void Update(int iev, const EventRecord *event)
Definition: GMCJMonitor.cxx:58
void CustomizeFilename(string filename)
int gOptNevents
Definition: gEvGen.cxx:203
string gOptStatFileName
Definition: gEvGen.cxx:215
double Evaluate(double x) const
Definition: Spline.cxx:362
double gOptNuEnergyRange
Definition: gEvGen.cxx:205
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:30
Loaders::FluxType flux
const double emin
void SetRefreshRate(int rate)
Definition: GMCJMonitor.cxx:53
void UseFluxDriver(GFluxI *flux)
Definition: GMCJDriver.cxx:174
Double_t ymax
Definition: plot.C:25
Simple class to create & update MC job status files and env. vars. This is used to be able to keep tr...
Definition: GMCJMonitor.h:30
A GENIE `MC Job Driver&#39;. Can be used for setting up complicated event generation cases involving deta...
Definition: GMCJDriver.h:47
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
Definition: typedefs.hpp:11
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
double gOptNuEnergy
Definition: gEvGen.cxx:204
void SetEventGeneratorList(string listname)
Definition: GEVGDriver.cxx:349
const double emax
bool gOptWeighted
Definition: gEvGen.cxx:210
void ForceSingleProbScale(void)
Definition: GMCJDriver.cxx:219
A generic GENIE flux driver. Generates a &#39;cylindrical&#39; neutrino beam along the input direction...
A simple GENIE flux driver for monoenergetic neutrinos along the z direction. Can handle a mix of neu...
void Configure(bool calc_prob_scales=true)
Definition: GMCJDriver.cxx:446
void Save(void)
get the even tree
Definition: NtpWriter.cxx:214
GENIE Event Generation Driver. A minimalist user interface object for generating neutrino interaction...
Definition: GEVGDriver.h:55
#define pINFO
Definition: Messenger.h:63
string gOptInpXSecFile
Definition: gEvGen.cxx:213
void AddEventRecord(int ievent, const EventRecord *ev_rec)
save the event tree
Definition: NtpWriter.cxx:69
void SetTransverseRadius(double Rt)
const ana::Var wgt
Misc GENIE control constants.
void SetNuDirection(const TVector3 &direction)
void BuildTune()
build tune and inform XSecSplineList
Definition: RunOpt.cxx:100
#define pWARN
Definition: Messenger.h:61
EventRecord * GenerateEvent(void)
Definition: GMCJDriver.cxx:838
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Definition: EventRecord.h:38
int main(int argc, char **argv)
Definition: gEvGen.cxx:218
string gOptFlux
Definition: gEvGen.cxx:209
int kDefOptNevents
Definition: gEvGen.cxx:198
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
void Initialize(void)
add event
Definition: NtpWriter.cxx:95
static RunOpt * Instance(void)
Definition: RunOpt.cxx:62
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:42
A utility class to facilitate creating the GENIE MC Ntuple from the output GENIE GHEP event records...
Definition: NtpWriter.h:40
map< int, double > gOptTgtMix
Definition: gEvGen.cxx:207
bool gOptUsingFluxOrTgtMix
Definition: gEvGen.cxx:211
void GetCommandLineArgs(int argc, char **argv)
Definition: gEvGen.cxx:550
TRandom3 & RndGen(void) const
rnd number generator for generic usage
Definition: RandomGen.h:81
exit(0)
string gOptOutFileName
Definition: gEvGen.cxx:214
void Configure(int nu_pdgc, int Z, int A)
Definition: GEVGDriver.cxx:138
assert(nhit_max >=nhit_nbins)
TRandom3 r(0)
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f='*')
Definition: PrintUtils.cxx:171
A vector of EventGeneratorI objects.
void GenerateEventsAtFixedInitState(void)
Definition: gEvGen.cxx:266
void SetBeamSpot(const TVector3 &spot)
void MesgThresholds(string inpfile)
Definition: AppInit.cxx:100
void AddEnergySpectrum(int nu_pdgc, TH1D *spectrum)
Command line argument parser.
enum genie::ENtpMCFormat NtpMCFormat_t
#define pNOTICE
Definition: Messenger.h:62
void PrintSyntax(void)
Definition: gEvGen.cxx:771
Defines the GENIE Geometry Analyzer Interface.
Definition: GeomAnalyzerI.h:30
static const unsigned int kRjMaxIterations
Definition: Controls.h:27
Float_t e
Definition: plot.C:35
void SetUnphysEventMask(const TBits &mask)
Definition: GEVGDriver.cxx:220
void Initialize(void)
Definition: gEvGen.cxx:246
bool gAbortingInErr
Definition: Messenger.cxx:56
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
void UseGeomAnalyzer(GeomAnalyzerI *geom)
Definition: GMCJDriver.cxx:179
void UseSplines(bool useLogE=true)
Definition: GMCJDriver.cxx:184
The PointGeomAnalyzer class is the simplest implementation of the GeomAnalyserI interface and defines...
bool OptionExists(char opt)
was option set?
void CacheFile(string inpfile)
Definition: AppInit.cxx:118
void EnableBareXSecPreCalc(bool flag)
Definition: RunOpt.h:61
Initial State information.
Definition: InitialState.h:49
GENIE Interface for user-defined flux classes.
Definition: GFluxI.h:37
EventRecord * GenerateEvent(const TLorentzVector &nu4p)
Definition: GEVGDriver.cxx:229