152using std::ostringstream;
154using namespace genie;
183int main(
int argc,
char ** argv)
214 <<
" *** Generating event............ " << ievent;
220 event->AttachSummary(interaction);
226 <<
"Generated event: " << *event;
230 mcjmonitor.
Update(ievent,event);
250 std::string pdg_string = std::to_string(
static_cast<long long>(pdg_code));
251 if (pdg_string.size() != 10) {
253 <<
"Expecting PDG code to be a 10-digit integer; instead, it's the following: " << pdg_string;
259 int n_nucleons = std::stoi(pdg_string.substr(6,3)) - 1;
260 int n_protons = std::stoi(pdg_string.substr(3,3));
263 double proton_frac = ((double)n_protons) / ((
double)n_nucleons);
264 double neutron_frac = 1 - proton_frac;
267 const int n_modes = 16;
268 double br [n_modes] = { 0.010, 0.080, 0.100, 0.220,
269 0.360, 0.160, 0.070, 0.020,
270 0.015, 0.065, 0.110, 0.280,
271 0.070, 0.240, 0.100, 0.100 };
273 for (
int i = 0; i < n_modes; i++) {
275 br[i] *= proton_frac;
277 br[i] *= neutron_frac;
283 double p = rnd->
RndNum().Rndm();
286 double threshold = 0;
287 for (
int i = 0; i < n_modes; i++) {
297 LOG(
"gevgen_nnbar_osc",
pFATAL) <<
"Random selection of final state failed!";
313 <<
"Target mix not currently supported. You must specify a single target nucleus!";
325 string sname =
"genie::EventGenerator";
326 string sconfig =
"NNBarOsc";
332 <<
"Couldn't instantiate the neutron oscillation generator";
341 LOG(
"gevgen_nnbar_osc",
pINFO) <<
"Parsing command line arguments";
359 LOG(
"gevgen_nnbar_osc",
pDEBUG) <<
"Reading MC run number";
362 LOG(
"gevgen_nnbar_osc",
pDEBUG) <<
"Unspecified run number - Using default";
370 <<
"Reading number of events to generate";
374 <<
"You need to specify the number of events";
383 <<
"Reading annihilation mode";
390 <<
"You need to specify a valid annihilation mode";
402 LOG(
"gevgen_nnbar_osc",
pDEBUG) <<
"Getting input geometry";
406 bool accessible_geom_file =
407 ! (gSystem->AccessPathName(
geom.c_str()));
408 if (accessible_geom_file) {
414 <<
"No geometry option specified - Exiting";
425 <<
"Checking for input geometry length units";
428 LOG(
"gevgen_nnbar_osc",
pDEBUG) <<
"Using default geometry length units";
434 <<
"Checking for input geometry density units";
437 LOG(
"gevgen_nnbar_osc",
pDEBUG) <<
"Using default geometry density units";
446 LOG(
"gevgen_nnbar_osc",
pDEBUG) <<
"Checking for input volume name";
449 LOG(
"gevgen_nnbar_osc",
pDEBUG) <<
"Using the <master volume>";
462 if(tgtmix.size()==1) {
463 int pdg = atoi(tgtmix[0].c_str());
467 vector<string>::const_iterator tgtmix_iter = tgtmix.begin();
468 for( ; tgtmix_iter != tgtmix.end(); ++tgtmix_iter) {
469 string tgt_with_wgt = *tgtmix_iter;
470 string::size_type open_bracket = tgt_with_wgt.find(
"[");
471 string::size_type close_bracket = tgt_with_wgt.find(
"]");
472 if (open_bracket ==string::npos ||
473 close_bracket==string::npos)
476 <<
"You made an error in specifying the target mix";
480 string::size_type ibeg = 0;
481 string::size_type iend = open_bracket;
482 string::size_type jbeg = open_bracket+1;
483 string::size_type jend = close_bracket;
484 int pdg = atoi(tgt_with_wgt.substr(ibeg,iend-ibeg).c_str());
485 double wgt = atof(tgt_with_wgt.substr(jbeg,jend-jbeg).c_str());
487 <<
"Adding to target mix: pdg = " <<
pdg <<
", wgt = " << wgt;
496 LOG(
"gevgen_nnbar_osc",
pDEBUG) <<
"Reading the event filename prefix";
500 <<
"Will set the default event filename prefix";
507 LOG(
"gevgen_nnbar_osc",
pINFO) <<
"Reading random number seed";
510 LOG(
"gevgen_nnbar_osc",
pINFO) <<
"Unspecified random number seed - Using default";
520 ostringstream gminfo;
522 gminfo <<
"Using ROOT geometry - file: " <<
gOptRootGeom
525 <<
", length units: " <<
lunits
526 <<
", density units: " << dunits;
528 gminfo <<
"Using target mix - ";
529 map<int,double>::const_iterator iter;
531 int pdg_code = iter->first;
532 double wgt = iter->second;
533 TParticlePDG * p = pdglib->
Find(pdg_code);
535 string name = p->GetName();
536 gminfo <<
"(" << name <<
") -> " << 100*wgt <<
"% / ";
549 <<
"\n @@ Geometry $ " << gminfo.str()
550 <<
"\n @@ Statistics $ " <<
gOptNev <<
" events";
557 <<
"\n ** ROOT geometries not supported yet in neutron oscillation mode"
558 <<
"\n ** (they will be in the very near future)"
559 <<
"\n ** Please specify a `target mix' instead.";
569 <<
"\n gevgen_nnbarosc [-h] "
571 <<
"\n -m decay_mode"
573 <<
"\n [-t top_volume_name_at_geom]"
574 <<
"\n [-L length_units_at_geom]"
575 <<
"\n [-D density_units_at_geom]"
576 <<
"\n -n n_of_events "
577 <<
"\n [-o output_event_file_prefix]"
578 <<
"\n [--seed random_number_seed]"
579 <<
"\n [--message-thresholds xml_file]"
580 <<
"\n [--event-record-print-level level]"
581 <<
"\n [--mc-job-status-refresh-rate rate]"
583 <<
" Please also read the detailed documentation at http://www.genie-mc.org"
584 <<
" or look at the source code: $GENIE/src/Apps/gNNBarOscEvGen.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 * NOsc(int tgt, int annihilation_mode=-1)
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...
static RandomGen * Instance()
Access instance.
void SetSeed(long int seed)
TRandom3 & RndNum(void) const
rnd number generator used by MC integrators & other numerical methods
void ReadFromCommandLine(int argc, char **argv)
static RunOpt * Instance(void)
string kDefOptEvFilePrefix
NtpMCFormat_t kDefOptNtpFormat
map< int, double > gOptTgtMix
string gOptRootGeomTopVol
HNLDecayMode_t gOptDecayMode
const EventRecordVisitorI * NeutronOscGenerator(void)
int SelectInitState(void)
void GetCommandLineArgs(int argc, char **argv)
int SelectAnnihilationMode(int pdg_code)
Utilities for improving the code readability when using PDG codes.
void RandGen(long int seed)
void MesgThresholds(string inpfile)
bool IsValidMode(NNBarOscMode_t ndm)
string AsString(NNBarOscMode_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::ENNBarOscMode NNBarOscMode_t
enum genie::ENtpMCFormat NtpMCFormat_t