145using std::ostringstream;
147using namespace genie;
176int 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";
333 LOG(
"gevgen_ndcy",
pDEBUG) <<
"Reading MC run number";
336 LOG(
"gevgen_ndcy",
pDEBUG) <<
"Unspecified run number - Using default";
344 <<
"Reading number of events to generate";
348 <<
"You need to specify the number of events";
357 <<
"Reading decay mode";
361 <<
"You need to specify the decay mode";
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";
391 LOG(
"gevgen_ndcy",
pDEBUG) <<
"Getting input geometry";
395 bool accessible_geom_file =
396 ! (gSystem->AccessPathName(
geom.c_str()));
397 if (accessible_geom_file) {
403 <<
"No geometry option specified - Exiting";
414 <<
"Checking for input geometry length units";
417 LOG(
"gevgen_ndcy",
pDEBUG) <<
"Using default geometry length units";
423 <<
"Checking for input geometry density units";
426 LOG(
"gevgen_ndcy",
pDEBUG) <<
"Using default geometry density units";
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());
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;
485 LOG(
"gevgen_ndcy",
pDEBUG) <<
"Reading the event filename prefix";
489 <<
"Will set the default event filename prefix";
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"
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils.
The GENIE Algorithm Factory.
const Algorithm * GetAlgorithm(const AlgId &algid)
static AlgFactory * Instance()
Command line argument parser.
string ArgAsString(char opt)
bool OptionExists(char opt)
was option set?
Defines the EventRecordVisitorI interface. Concrete implementations of this interface use the 'Visito...
virtual void ProcessEventRecord(GHepRecord *event_rec) const =0
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
static void SetPrintLevel(int print_level)
Simple class to create & update MC job status files and env. vars. This is used to be able to keep tr...
void Update(int iev, const EventRecord *event)
void SetRefreshRate(int rate)
Summary information for an interaction.
static Interaction * NDecay(int tgt, int decay_mode=-1, int decayed_nucleon=0)
A utility class to facilitate creating the GENIE MC Ntuple from the output GENIE GHEP event records.
void Initialize(void)
add event
void Save(void)
get the even tree
void AddEventRecord(int ievent, const EventRecord *ev_rec)
save the event tree
void CustomizeFilenamePrefix(string prefix)
Singleton class to load & serve a TDatabasePDG.
static PDGLibrary * Instance(void)
TParticlePDG * Find(int pdgc, bool must_exist=true)
A singleton holding random number generator classes. All random number generation in GENIE should tak...
TRandom3 & RndEvg(void) const
rnd number generator used by the event generation drivers
static RandomGen * Instance()
Access instance.
void ReadFromCommandLine(int argc, char **argv)
static RunOpt * Instance(void)
string kDefOptEvFilePrefix
NtpMCFormat_t kDefOptNtpFormat
map< int, double > gOptTgtMix
string gOptRootGeomTopVol
HNLDecayMode_t gOptDecayMode
int SelectInitState(void)
void GetCommandLineArgs(int argc, char **argv)
const EventRecordVisitorI * NucleonDecayGenerator(void)
Utilities for improving the code readability when using PDG codes.
int IonPdgCodeToZ(int pdgc)
int IonPdgCodeToA(int pdgc)
void RandGen(long int seed)
void MesgThresholds(string inpfile)
bool IsValidMode(NucleonDecayMode_t ndm, int npdg=0)
string AsString(NucleonDecayMode_t ndm, int npdg=0)
int DecayedNucleonPdgCode(NucleonDecayMode_t ndm)
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f=' *')
vector< string > Split(string input, string delim)
double UnitFromString(string u)
THE MAIN GENIE PROJECT NAMESPACE
enum genie::ENucleonDecayMode NucleonDecayMode_t
enum genie::ENtpMCFormat NtpMCFormat_t