145 using std::ostringstream;
147 using namespace genie;
214 <<
" *** Generating event............ " << ievent;
220 event->AttachSummary(interaction);
226 <<
"Generated event: " << *
event;
247 LOG(
"gevgen_ndcy",
pFATAL) <<
"Not a valid decay mode and/or decayed nucleon...";
259 map<int,double> cprob;
263 for(iter = gOptTgtMix.begin(); iter != gOptTgtMix.end(); ++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";
389 string lunits, dunits;
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());
454 gOptTgtMix.insert(map<int, double>::value_type(pdg, wgt));
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));
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 - ";
519 for(iter = gOptTgtMix.begin(); iter != gOptTgtMix.end(); ++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)
string ArgAsString(char opt)
THE MAIN GENIE PROJECT NAMESPACE
virtual void ProcessEventRecord(GHepRecord *event_rec) const =0
static RandomGen * Instance()
Access instance.
Defines the EventRecordVisitorI interface. Concrete implementations of this interface use the 'Visito...
void ReadFromCommandLine(int argc, char **argv)
string kDefOptEvFilePrefix
int IonPdgCodeToA(int pdgc)
void Update(int iev, const EventRecord *event)
static Interaction * NDecay(int tgt, int decay_mode=-1, int decayed_nucleon=0)
int SelectInitState(void)
void GetCommandLineArgs(int argc, char **argv)
A singleton holding random number generator classes. All random number generation in GENIE should tak...
string gOptRootGeomTopVol
bool IsValidMode(NucleonDecayMode_t ndm, int npdg=0)
void SetRefreshRate(int rate)
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...
map< int, double > gOptTgtMix
double UnitFromString(string u)
const Algorithm * GetAlgorithm(const AlgId &algid)
int main(int argc, char **argv)
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)
Command line argument parser.
enum genie::ENtpMCFormat NtpMCFormat_t
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)
bool OptionExists(char opt)
was option set?
Event finding and building.
NucleonDecayMode_t gOptDecayMode