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