145 using std::ostringstream;
147 using namespace genie;
176 int main(
int argc,
char ** argv)
214 <<
" *** Generating event............ " << ievent;
220 event->AttachSummary(interaction);
226 <<
"Generated event: " << *event;
230 mcjmonitor.
Update(ievent,event);
247 LOG(
"gevgen_ndcy",
pFATAL) <<
"Not a valid decay mode and/or decayed nucleon...";
259 map<int,double> cprob;
260 map<int,double>::const_iterator iter;
264 int pdg_code = iter->first;
268 double nucleon_decay_fraction = 0.;
269 if (dpdg ==
kPdgProton ) { nucleon_decay_fraction = (double)Z / (
double)
A; }
270 else if (dpdg ==
kPdgNeutron ) { nucleon_decay_fraction = (double)(A-Z) / (double)A; }
272 double wgt = iter->second;
273 double prob = wgt*nucleon_decay_fraction;
276 cprob.insert(map<int, double>::value_type(pdg_code, sum_prob));
279 assert(sum_prob > 0.);
282 double r = sum_prob * rnd->
RndEvg().Rndm();
284 for(iter = cprob.begin(); iter != cprob.end(); ++iter) {
285 int pdg_code = iter->first;
286 double prob = iter->second;
288 LOG(
"gevgen_ndcy",
pNOTICE) <<
"Selected initial state = " << pdg_code;
293 LOG(
"gevgen_ndcy",
pFATAL) <<
"Couldn't select an initial state...";
300 string sname =
"genie::EventGenerator";
301 string sconfig =
"NucleonDecay";
306 LOG(
"gevgen_ndcy",
pFATAL) <<
"Couldn't instantiate the nucleon decay generator";
315 LOG(
"gevgen_ndcy",
pINFO) <<
"Parsing command line arguments";
325 bool help = parser.OptionExists(
'h');
332 if( parser.OptionExists(
'r') ) {
333 LOG(
"gevgen_ndcy",
pDEBUG) <<
"Reading MC run number";
336 LOG(
"gevgen_ndcy",
pDEBUG) <<
"Unspecified run number - Using default";
342 if( parser.OptionExists(
'n') ) {
344 <<
"Reading number of events to generate";
345 gOptNev = parser.ArgAsInt(
'n');
348 <<
"You need to specify the number of events";
355 if( parser.OptionExists(
'm') ) {
357 <<
"Reading decay mode";
358 mode = parser.ArgAsInt(
'm');
361 <<
"You need to specify the decay mode";
368 if( parser.OptionExists(
'N') ) {
369 LOG(
"gevgen_ndcy",
pINFO) <<
"Reading decayed nucleon PDG";
372 LOG(
"gevgen_ndcy",
pINFO) <<
"Unspecified decayed nucleon PDG - Using default";
379 <<
"You need to specify a valid decay mode / decayed nucleon PDG combination";
390 if( parser.OptionExists(
'g') ) {
391 LOG(
"gevgen_ndcy",
pDEBUG) <<
"Getting input geometry";
392 geom = parser.ArgAsString(
'g');
395 bool accessible_geom_file =
396 ! (gSystem->AccessPathName(geom.c_str()));
397 if (accessible_geom_file) {
403 <<
"No geometry option specified - Exiting";
412 if( parser.OptionExists(
'L') ) {
414 <<
"Checking for input geometry length units";
415 lunits = parser.ArgAsString(
'L');
417 LOG(
"gevgen_ndcy",
pDEBUG) <<
"Using default geometry length units";
421 if( parser.OptionExists(
'D') ) {
423 <<
"Checking for input geometry density units";
424 dunits = parser.ArgAsString(
'D');
426 LOG(
"gevgen_ndcy",
pDEBUG) <<
"Using default geometry density units";
434 if( parser.OptionExists(
't') ) {
435 LOG(
"gevgen_ndcy",
pDEBUG) <<
"Checking for input volume name";
438 LOG(
"gevgen_ndcy",
pDEBUG) <<
"Using the <master volume>";
451 if(tgtmix.size()==1) {
452 int pdg = atoi(tgtmix[0].c_str());
454 gOptTgtMix.insert(map<int, double>::value_type(pdg, wgt));
456 vector<string>::const_iterator tgtmix_iter = tgtmix.begin();
457 for( ; tgtmix_iter != tgtmix.end(); ++tgtmix_iter) {
458 string tgt_with_wgt = *tgtmix_iter;
459 string::size_type open_bracket = tgt_with_wgt.find(
"[");
460 string::size_type close_bracket = tgt_with_wgt.find(
"]");
461 if (open_bracket ==string::npos ||
462 close_bracket==string::npos)
465 <<
"You made an error in specifying the target mix";
469 string::size_type ibeg = 0;
470 string::size_type iend = open_bracket;
471 string::size_type jbeg = open_bracket+1;
472 string::size_type jend = close_bracket;
473 int pdg = atoi(tgt_with_wgt.substr(ibeg,iend-ibeg).c_str());
474 double wgt = atof(tgt_with_wgt.substr(jbeg,jend-jbeg).c_str());
476 <<
"Adding to target mix: pdg = " << pdg <<
", wgt = " << wgt;
477 gOptTgtMix.insert(map<int, double>::value_type(pdg, wgt));
484 if( parser.OptionExists(
'o') ) {
485 LOG(
"gevgen_ndcy",
pDEBUG) <<
"Reading the event filename prefix";
489 <<
"Will set the default event filename prefix";
495 if( parser.OptionExists(
"seed") ) {
496 LOG(
"gevgen_ndcy",
pINFO) <<
"Reading random number seed";
499 LOG(
"gevgen_ndcy",
pINFO) <<
"Unspecified random number seed - Using default";
509 ostringstream gminfo;
511 gminfo <<
"Using ROOT geometry - file: " <<
gOptRootGeom
514 <<
", length units: " << lunits
515 <<
", density units: " << dunits;
517 gminfo <<
"Using target mix - ";
518 map<int,double>::const_iterator iter;
520 int pdg_code = iter->first;
521 double wgt = iter->second;
522 TParticlePDG * p = pdglib->
Find(pdg_code);
524 string name = p->GetName();
525 gminfo <<
"(" << name <<
") -> " << 100*wgt <<
"% / ";
538 <<
"\n @@ Geometry $ " << gminfo.str()
539 <<
"\n @@ Statistics $ " <<
gOptNev <<
" events";
546 <<
"\n ** ROOT geometries not supported yet in the nucleon decay mode"
547 <<
"\n ** (they will be in the very near future)"
548 <<
"\n ** Please specify a `target mix' instead.";
558 <<
"\n gevgen_ndcy [-h] "
560 <<
"\n -m decay_mode"
561 <<
"\n [-N decayed_nucleon]"
563 <<
"\n [-t top_volume_name_at_geom]"
564 <<
"\n [-L length_units_at_geom]"
565 <<
"\n [-D density_units_at_geom]"
566 <<
"\n -n n_of_events "
567 <<
"\n [-o output_event_file_prefix]"
568 <<
"\n [--seed random_number_seed]"
569 <<
"\n [--message-thresholds xml_file]"
570 <<
"\n [--event-record-print-level level]"
571 <<
"\n [--mc-job-status-refresh-rate rate]"
573 <<
" Please also read the detailed documentation at http://www.genie-mc.org"
574 <<
" or look at the source code: $GENIE/src/Apps/gNucleonDecayEvGen.cxx"
const EventRecordVisitorI * NucleonDecayGenerator(void)
void RandGen(long int seed)
static void SetPrintLevel(int print_level)
HNLDecayMode_t gOptDecayMode
static RandomGen * Instance()
Access instance.
Defines the EventRecordVisitorI interface. Concrete implementations of this interface use the 'Visito...
void ReadFromCommandLine(int argc, char **argv)
int IonPdgCodeToA(int pdgc)
void Update(int iev, const EventRecord *event)
static Interaction * NDecay(int tgt, int decay_mode=-1, int decayed_nucleon=0)
map< int, double > gOptTgtMix
A singleton holding random number generator classes. All random number generation in GENIE should tak...
int main(int argc, char **argv)
bool IsValidMode(NucleonDecayMode_t ndm, int npdg=0)
void SetRefreshRate(int rate)
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
string gOptRootGeomTopVol
static constexpr double A
double UnitFromString(string u)
const Algorithm * GetAlgorithm(const AlgId &algid)
void Save(void)
get the even tree
TRandom3 & RndEvg(void) const
rnd number generator used by the event generation drivers
void AddEventRecord(int ievent, const EventRecord *ev_rec)
save the event tree
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.
enum genie::ENucleonDecayMode NucleonDecayMode_t
string AsString(NucleonDecayMode_t ndm, int npdg=0)
NtpMCFormat_t kDefOptNtpFormat
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f='*')
int IonPdgCodeToZ(int pdgc)
void MesgThresholds(string inpfile)
TParticlePDG * Find(int pdgc, bool must_exist=true)
int SelectInitState(void)
Command line argument parser.
enum genie::ENtpMCFormat NtpMCFormat_t
void GetCommandLineArgs(int argc, char **argv)
The GENIE Algorithm Factory.
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
int DecayedNucleonPdgCode(NucleonDecayMode_t ndm)