96 #include "Framework/Conventions/GBuild.h"
123 using namespace genie;
124 using namespace genie::controls;
126 using namespace genie::utils::intranuke;
159 int main(
int argc,
char ** argv)
165 LOG(
"gmkspl",
pFATAL) <<
" No TuneId in RunOption";
179 LOG(
"gevgen_hadron",
pNOTICE) <<
"finish setup";
192 LOG(
"gevgen_hadron",
pNOTICE) <<
"ready to generate events";
201 <<
" *** Generating event............ " << ievent;
216 mcjmonitor.
Update(ievent,evrec);
242 if (
gOptMode.compare(
"hA") == 0 ) {
243 sname =
"genie::HAIntranuke";
245 }
else if (
gOptMode.compare(
"hN") == 0 ) {
246 sname =
"genie::HNIntranuke";
248 }
else if (
gOptMode.compare(
"hA2019") == 0 ) {
249 sname =
"genie::HAIntranuke2019";
251 }
else if (
gOptMode.compare(
"hN2019") == 0 ) {
252 sname =
"genie::HNIntranuke2019";
254 }
else if (
gOptMode.compare(
"hA2018") == 0 ) {
255 sname =
"genie::HAIntranuke2018";
257 }
else if (
gOptMode.compare(
"hN2018") == 0 ) {
258 sname =
"genie::HNIntranuke2018";
260 #ifdef __GENIE_INCL_ENABLED__
261 }
else if (
gOptMode.compare(
"HINCL") == 0 ) {
262 sname =
"genie::HINCLCascadeIntranuke";
265 #ifdef __GENIE_GEANT4_INTERFACE_ENABLED__
266 }
else if (
gOptMode.compare(
"HG4BertCasc") == 0 ) {
267 sname =
"genie::HG4BertCascIntranuke";
271 LOG(
"gevgen_hadron",
pFATAL) <<
"Invalid Intranuke mode - Exiting";
293 TLorentzVector x4null(0.,0.,0.,0.);
305 double pzh = TMath::Sqrt(TMath::Max(0.,Eh*Eh-mh*mh));
306 TLorentzVector p4h (0.,0.,pzh,Eh);
307 TLorentzVector p4tgt (0.,0.,0., M);
336 <<
"Generating a flux histogram ... ";
339 int flux_entries = 1000000;
342 double dke = ke_max - ke_min;
343 assert(dke>0 && ke_min>=0.);
347 "spectrum",
"hadron kinetic energy spectrum", flux_bins, ke_min, ke_max);
350 bool input_is_file = ! gSystem->AccessPathName(
gOptFlux.c_str());
356 double ke_step = (ke_max-ke_min)/(n-1);
357 double ymax = -1, ry = -1, gy = -1, ke = -1;
358 for(
int i=0; i<n; i++) {
359 ke = ke_min + i*ke_step;
360 ymax = TMath::Max(ymax, input_flux->
Evaluate(ke));
366 for(
int ientry=0; ientry<flux_entries; ientry++) {
373 <<
"Couldn't generate a flux histogram";
377 ke = ke_min + dke * r->
RndGen().Rndm();
378 gy = ymax * r->
RndGen().Rndm();
388 TF1 * input_func =
new TF1(
"input_func",
gOptFlux.c_str(), ke_min, ke_max);
389 gSpectrum->FillRandom(
"input_func", flux_entries);
392 TFile f(
"./input-hadron-flux.root",
"recreate");
399 LOG(
"gevgen_hadron",
pINFO) <<
"Parsing command line arguments";
409 if( parser.OptionExists(
'n') ) {
410 LOG(
"gevgen_hadron",
pINFO) <<
"Reading number of events to generate";
414 <<
"Unspecified number of events to generate - Using default";
419 if( parser.OptionExists(
'r') ) {
420 LOG(
"gevgen_hadron",
pINFO) <<
"Reading MC run number";
423 LOG(
"gevgen_hadron",
pINFO) <<
"Unspecified run number - Using default";
428 if( parser.OptionExists(
'p') ) {
429 LOG(
"gevgen_hadron",
pINFO) <<
"Reading rescattering particle PDG code";
432 LOG(
"gevgen_hadron",
pFATAL) <<
"Unspecified PDG code - Exiting";
439 if( parser.OptionExists(
't') ) {
440 LOG(
"gevgen_hadron",
pINFO) <<
"Reading target PDG code";
443 LOG(
"gevgen_hadron",
pFATAL) <<
"Unspecified target PDG code - Exiting";
450 if( parser.OptionExists(
'm') ) {
451 LOG(
"gevgen_hadron",
pINFO) <<
"Reading mode";
454 LOG(
"gevgen_hadron",
pFATAL) <<
"Unspecified mode - Using default";
459 if( parser.OptionExists(
'f') ) {
460 LOG(
"gevgen_hadron",
pINFO) <<
"Reading hadron's kinetic energy spectrum";
466 if( parser.OptionExists(
'k') ) {
467 LOG(
"gevgen_hadron",
pINFO) <<
"Reading probe kinetic energy";
468 string ke = parser.ArgAsString(
'k');
470 if(ke.find(
",") != string::npos) {
473 assert(kerange.size() == 2);
474 double kemin = atof(kerange[0].c_str());
475 double kemax = atof(kerange[1].c_str());
476 assert(kemax>kemin && kemin>0);
491 <<
"You specified an input flux without a kinetic energy range";
498 LOG(
"gevgen_hadron",
pFATAL) <<
"Unspecified kinetic energy - Exiting";
505 if( parser.OptionExists(
'o') ) {
506 LOG(
"gevgen_hadron",
pINFO) <<
"Reading the event filename prefix";
510 <<
"Will set the default event filename prefix";
515 if( parser.OptionExists(
'm') ) {
516 LOG(
"gevgen_hadron",
pINFO) <<
"Reading mode";
520 <<
"Unspecified mode - Using default";
525 if( parser.OptionExists(
"seed") ) {
526 LOG(
"gevgen_hadron",
pINFO) <<
"Reading random number seed";
529 LOG(
"gevgen_hadron",
pINFO) <<
"Unspecified random number seed - Using default";
549 <<
"Hadron input KE range = ["
567 <<
" gevgen_hadron [-r run] [-n nev] -p hadron_pdg -t tgt_pdg -k KE [-m mode] "
569 <<
" [--seed random_number_seed]"
570 <<
" [--message-thresholds xml_file]"
571 <<
" [--event-record-print-level level]"
572 <<
" [--mc-job-status-refresh-rate rate]"
void RandGen(long int seed)
static void SetPrintLevel(int print_level)
static RandomGen * Instance()
Access instance.
Defines the EventRecordVisitorI interface. Concrete implementations of this interface use the 'Visito...
void ReadFromCommandLine(int argc, char **argv)
A numeric analysis tool class for interpolating 1-D functions.
void Update(int iev, const EventRecord *event)
double GenProbeKineticEnergy(void)
double Mass(Resonance_t res)
resonance mass (GeV)
double Evaluate(double x) const
A singleton holding random number generator classes. All random number generation in GENIE should tak...
virtual void AttachSummary(Interaction *interaction)
int main(int argc, char **argv)
EventRecord * InitializeEvent(void)
string kDefOptEvFilePrefix
Summary information for an interaction.
Simple class to create & update MC job status files and env. vars. This is used to be able to keep tr...
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
virtual void ProcessEventRecord(GHepRecord *event_rec) const =0
const Algorithm * GetAlgorithm(const AlgId &algid)
void Save(void)
get the even tree
void AddEventRecord(int ievent, const EventRecord *ev_rec)
save the event tree
void BuildTune()
build tune and inform XSecSplineList
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
void CustomizeFilenamePrefix(string prefix)
void Initialize(void)
add event
static PDGLibrary * Instance(void)
static RunOpt * Instance(void)
vector< string > Split(string input, string delim)
static AlgFactory * Instance()
A utility class to facilitate creating the GENIE MC Ntuple from the output GENIE GHEP event records...
Singleton class to load & serve a TDatabasePDG.
TRandom3 & RndGen(void) const
rnd number generator for generic usage
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f='*')
virtual void AddParticle(const GHepParticle &p)
void MesgThresholds(string inpfile)
Command line argument parser.
void GetCommandLineArgs(int argc, char **argv)
The GENIE Algorithm Factory.
static const unsigned int kRjMaxIterations
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
const EventRecordVisitorI * GetIntranuke(void)
enum genie::EGHepStatus GHepStatus_t