152 using std::ostringstream;
154 using namespace genie;
214 <<
" *** Generating event............ " << ievent;
220 event->AttachSummary(interaction);
226 <<
"Generated event: " << *
event;
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!";
311 if (gOptTgtMix.size() > 1) {
313 <<
"Target mix not currently supported. You must specify a single target nucleus!";
318 int pdg_code = gOptTgtMix.begin()->first;
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";
400 string lunits, dunits;
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());
465 gOptTgtMix.insert(map<int, double>::value_type(pdg, wgt));
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;
488 gOptTgtMix.insert(map<int, double>::value_type(pdg, 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 - ";
530 for(iter = gOptTgtMix.begin(); iter != gOptTgtMix.end(); ++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"
void RandGen(long int seed)
static void SetPrintLevel(int print_level)
void GetCommandLineArgs(int argc, char **argv)
const EventRecordVisitorI * NeutronOscGenerator(void)
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)
int SelectAnnihilationMode(int pdg_code)
void Update(int iev, const EventRecord *event)
A singleton holding random number generator classes. All random number generation in GENIE should tak...
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...
enum genie::ENNBarOscMode NNBarOscMode_t
double UnitFromString(string u)
const Algorithm * GetAlgorithm(const AlgId &algid)
string AsString(NNBarOscMode_t ndm)
void Save(void)
get the even tree
int main(int argc, char **argv)
void AddEventRecord(int ievent, const EventRecord *ev_rec)
save the event tree
NNBarOscMode_t gOptDecayMode
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
TRandom3 & RndNum(void) const
rnd number generator used by MC integrators & other numerical methods
void CustomizeFilenamePrefix(string prefix)
void Initialize(void)
add event
NtpMCFormat_t kDefOptNtpFormat
static PDGLibrary * Instance(void)
string kDefOptEvFilePrefix
map< int, double > gOptTgtMix
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.
bool IsValidMode(NNBarOscMode_t ndm)
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f='*')
void MesgThresholds(string inpfile)
TParticlePDG * Find(int pdgc, bool must_exist=true)
int SelectInitState(void)
Command line argument parser.
enum genie::ENtpMCFormat NtpMCFormat_t
The GENIE Algorithm Factory.
string gOptRootGeomTopVol
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
std::string to_string(ModuleType const mt)
bool OptionExists(char opt)
was option set?
Event finding and building.
static Interaction * NOsc(int tgt, int annihilation_mode=-1)
void SetSeed(long int seed)