GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions | Variables
gEvGen.cxx File Reference
#include <cstdlib>
#include <cassert>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <TFile.h>
#include <TTree.h>
#include <TSystem.h>
#include <TVector3.h>
#include <TH1.h>
#include <TF1.h>
#include "Framework/Conventions/XmlParserStatus.h"
#include "Framework/Conventions/GBuild.h"
#include "Framework/Conventions/Controls.h"
#include "Framework/EventGen/EventRecord.h"
#include "Framework/EventGen/GFluxI.h"
#include "Framework/EventGen/GEVGDriver.h"
#include "Framework/EventGen/GMCJDriver.h"
#include "Framework/EventGen/GMCJMonitor.h"
#include "Framework/Interaction/Interaction.h"
#include "Framework/Messenger/Messenger.h"
#include "Framework/Ntuple/NtpWriter.h"
#include "Framework/Ntuple/NtpMCFormat.h"
#include "Framework/Numerical/RandomGen.h"
#include "Framework/Numerical/Spline.h"
#include "Framework/ParticleData/PDGCodes.h"
#include "Framework/ParticleData/PDGUtils.h"
#include "Framework/Utils/AppInit.h"
#include "Framework/Utils/RunOpt.h"
#include "Framework/Utils/XSecSplineList.h"
#include "Framework/Utils/StringUtils.h"
#include "Framework/Utils/PrintUtils.h"
#include "Framework/Utils/SystemUtils.h"
#include "Framework/Utils/CmdLnArgParser.h"
Include dependency graph for gEvGen.cxx:

Go to the source code of this file.

Functions

void GetCommandLineArgs (int argc, char **argv)
 
void Initialize (void)
 
void PrintSyntax (void)
 
void GenerateEventsAtFixedInitState (void)
 
int main (int argc, char **argv)
 

Variables

int kDefOptNevents = 0
 
NtpMCFormat_t kDefOptNtpFormat = kNFGHEP
 
Long_t kDefOptRunNu = 0
 
int gOptNevents
 
double gOptNuEnergy
 
double gOptNuEnergyRange
 
int gOptNuPdgCode
 
map< int, double > gOptTgtMix
 
Long_t gOptRunNu
 
string gOptFlux
 
string gOptFluxFactors
 
bool gOptWeighted
 
bool gOptForceInt
 
bool gOptUsingFluxOrTgtMix = false
 
long int gOptRanSeed
 
string gOptInpXSecFile
 
string gOptOutFileName
 
string gOptStatFileName
 

Function Documentation

void GenerateEventsAtFixedInitState ( void  )

Definition at line 293 of file gEvGen.cxx.

References genie::NtpWriter::AddEventRecord(), genie::GEVGDriver::Configure(), genie::GMCJMonitor::CustomizeFilename(), genie::NtpWriter::CustomizeFilename(), genie::GEVGDriver::GenerateEvent(), gOptNevents, gOptNuEnergy, gOptNuPdgCode, gOptOutFileName, gOptRanSeed, gOptRunNu, gOptStatFileName, gOptTgtMix, genie::NtpWriter::Initialize(), genie::RunOpt::Instance(), kDefOptNtpFormat, LOG, pNOTICE, genie::NtpWriter::Save(), genie::GEVGDriver::SetEventGeneratorList(), genie::GMCJMonitor::SetRefreshRate(), genie::GEVGDriver::SetUnphysEventMask(), and genie::GMCJMonitor::Update().

Referenced by main().

294 {
295  int neutrino = gOptNuPdgCode;
296  int target = gOptTgtMix.begin()->first;
297  double Ev = gOptNuEnergy;
298  TLorentzVector nu_p4(0.,0.,Ev,Ev); // px,py,pz,E (GeV)
299 
300  // Create init state
301  InitialState init_state(target, neutrino);
302 
303  // Create/config event generation driver
304  GEVGDriver evg_driver;
305  evg_driver.SetEventGeneratorList(RunOpt::Instance()->EventGeneratorList());
306  evg_driver.SetUnphysEventMask(*RunOpt::Instance()->UnphysEventMask());
307  evg_driver.Configure(init_state);
308 
309  // Initialize an Ntuple Writer
311 
312  // If an output file name has been specified... use it
313  if (!gOptOutFileName.empty()){
314  ntpw.CustomizeFilename(gOptOutFileName);
315  }
316  ntpw.Initialize();
317 
318 
319  // Create an MC Job Monitor
320  GMCJMonitor mcjmonitor(gOptRunNu);
321  mcjmonitor.SetRefreshRate(RunOpt::Instance()->MCJobStatusRefreshRate());
322 
323  // If a status file name has been given... use it
324  if (!gOptStatFileName.empty()){
325  mcjmonitor.CustomizeFilename(gOptStatFileName);
326  }
327 
328 
329  LOG("gevgen", pNOTICE)
330  << "\n ** Will generate " << gOptNevents << " events for \n"
331  << init_state << " at Ev = " << Ev << " GeV";
332 
333  // Generate events / print the GHEP record / add it to the ntuple
334  int ievent = 0;
335  while (ievent < gOptNevents) {
336  LOG("gevgen", pNOTICE)
337  << " *** Generating event............ " << ievent;
338 
339  // generate a single event
340  EventRecord * event = evg_driver.GenerateEvent(nu_p4);
341 
342  if(!event) {
343  LOG("gevgen", pNOTICE)
344  << "Last attempt failed. Re-trying....";
345  continue;
346  }
347 
348  LOG("gevgen", pNOTICE)
349  << "Generated Event GHEP Record: " << *event;
350 
351  // add event at the output ntuple, refresh the mc job monitor & clean up
352  ntpw.AddEventRecord(ievent, event);
353  mcjmonitor.Update(ievent,event);
354  ievent++;
355  delete event;
356  }
357 
358  // Save the generated MC events
359  ntpw.Save();
360 }
int gOptNuPdgCode
Definition: gEvGen.cxx:231
int gOptNevents
Definition: gEvGen.cxx:228
string gOptStatFileName
Definition: gEvGen.cxx:242
map< int, double > gOptTgtMix
Definition: gAtmoEvGen.cxx:299
Simple class to create &amp; update MC job status files and env. vars. This is used to be able to keep tr...
Definition: GMCJMonitor.h:31
#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:229
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
Long_t gOptRunNu
Definition: gAtmoEvGen.cxx:295
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Definition: EventRecord.h:37
A utility class to facilitate creating the GENIE MC Ntuple from the output GENIE GHEP event records...
Definition: NtpWriter.h:39
string gOptOutFileName
Definition: gEvGen.cxx:241
void Configure(int nu_pdgc, int Z, int A)
Definition: GEVGDriver.cxx:137
NtpMCFormat_t kDefOptNtpFormat
Definition: gAtmoEvGen.cxx:319
A vector of EventGeneratorI objects.
#define pNOTICE
Definition: Messenger.h:61
void SetUnphysEventMask(const TBits &mask)
Definition: GEVGDriver.cxx:219
Initial State information.
Definition: InitialState.h:48
EventRecord * GenerateEvent(const TLorentzVector &nu4p)
Definition: GEVGDriver.cxx:228
long int gOptRanSeed
Definition: gAtmoEvGen.cxx:312
void GetCommandLineArgs ( int  argc,
char **  argv 
)
void Initialize ( void  )
int main ( int  argc,
char **  argv 
)

Definition at line 245 of file gEvGen.cxx.

References GenerateEventsAtFixedInitState(), GetCommandLineArgs(), gOptUsingFluxOrTgtMix, Initialize(), LOG, and pERROR.

246 {
247  GetCommandLineArgs(argc,argv);
248  Initialize();
249 
250  // throw on NaNs and Infs...
251 #if defined(HAVE_FENV_H) && defined(HAVE_FEENABLEEXCEPT)
252  feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
253 #endif
254  //
255  // Generate neutrino events
256  //
257 
259 #ifdef __CAN_GENERATE_EVENTS_USING_A_FLUX_OR_TGTMIX__
260  GenerateEventsUsingFluxOrTgtMix();
261 #else
262  LOG("gevgen", pERROR)
263  << "\n To be able to generate neutrino events from a flux and/or a target mix"
264  << "\n you need to add the following config options at your GENIE installation:"
265  << "\n --enable-flux-drivers --enable-geom-drivers \n" ;
266 #endif
267  } else {
269  }
270  return 0;
271 }
#define pERROR
Definition: Messenger.h:59
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
void Initialize(void)
bool gOptUsingFluxOrTgtMix
Definition: gEvGen.cxx:238
void GenerateEventsAtFixedInitState(void)
Definition: gEvGen.cxx:293
void GetCommandLineArgs(int argc, char **argv)
Definition: gAtmoEvGen.cxx:563
void PrintSyntax ( void  )

Variable Documentation

string gOptFlux

Definition at line 234 of file gEvGen.cxx.

Referenced by BuildSpectrum().

string gOptFluxFactors

Definition at line 235 of file gEvGen.cxx.

bool gOptForceInt

Definition at line 237 of file gEvGen.cxx.

string gOptInpXSecFile

Definition at line 240 of file gEvGen.cxx.

int gOptNevents

Definition at line 228 of file gEvGen.cxx.

Referenced by GenerateEventsAtFixedInitState(), and main().

double gOptNuEnergy

Definition at line 229 of file gEvGen.cxx.

Referenced by GenerateEventsAtFixedInitState().

double gOptNuEnergyRange

Definition at line 230 of file gEvGen.cxx.

int gOptNuPdgCode

Definition at line 231 of file gEvGen.cxx.

Referenced by GenerateEventsAtFixedInitState().

string gOptOutFileName
long int gOptRanSeed

Definition at line 239 of file gEvGen.cxx.

Long_t gOptRunNu

Definition at line 233 of file gEvGen.cxx.

string gOptStatFileName

Definition at line 242 of file gEvGen.cxx.

Referenced by GenerateEventsAtFixedInitState().

map<int,double> gOptTgtMix

Definition at line 232 of file gEvGen.cxx.

bool gOptUsingFluxOrTgtMix = false

Definition at line 238 of file gEvGen.cxx.

Referenced by main().

bool gOptWeighted

Definition at line 236 of file gEvGen.cxx.

int kDefOptNevents = 0

Definition at line 223 of file gEvGen.cxx.

NtpMCFormat_t kDefOptNtpFormat = kNFGHEP

Definition at line 224 of file gEvGen.cxx.

Long_t kDefOptRunNu = 0

Definition at line 225 of file gEvGen.cxx.