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_nosc",
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 =
"NeutronOsc";
331 LOG(
"gevgen_nosc",
pFATAL) <<
"Couldn't instantiate the neutron oscillation generator";
340 LOG(
"gevgen_nosc",
pINFO) <<
"Parsing command line arguments";
358 LOG(
"gevgen_nosc",
pDEBUG) <<
"Reading MC run number";
361 LOG(
"gevgen_nosc",
pDEBUG) <<
"Unspecified run number - Using default";
369 <<
"Reading number of events to generate";
373 <<
"You need to specify the number of events";
382 <<
"Reading annihilation mode";
389 <<
"You need to specify a valid annihilation mode";
399 string lunits, dunits;
401 LOG(
"gevgen_nosc",
pDEBUG) <<
"Getting input geometry";
405 bool accessible_geom_file =
406 ! (gSystem->AccessPathName(geom.c_str()));
407 if (accessible_geom_file) {
413 <<
"No geometry option specified - Exiting";
424 <<
"Checking for input geometry length units";
427 LOG(
"gevgen_nosc",
pDEBUG) <<
"Using default geometry length units";
433 <<
"Checking for input geometry density units";
436 LOG(
"gevgen_nosc",
pDEBUG) <<
"Using default geometry density units";
445 LOG(
"gevgen_nosc",
pDEBUG) <<
"Checking for input volume name";
448 LOG(
"gevgen_nosc",
pDEBUG) <<
"Using the <master volume>";
461 if(tgtmix.size()==1) {
462 int pdg = atoi(tgtmix[0].c_str());
464 gOptTgtMix.insert(map<int, double>::value_type(pdg, wgt));
467 for( ; tgtmix_iter != tgtmix.end(); ++tgtmix_iter) {
468 string tgt_with_wgt = *tgtmix_iter;
469 string::size_type open_bracket = tgt_with_wgt.find(
"[");
470 string::size_type close_bracket = tgt_with_wgt.find(
"]");
471 if (open_bracket ==string::npos ||
472 close_bracket==string::npos)
475 <<
"You made an error in specifying the target mix";
479 string::size_type ibeg = 0;
480 string::size_type iend = open_bracket;
481 string::size_type jbeg = open_bracket+1;
482 string::size_type jend = close_bracket;
483 int pdg = atoi(tgt_with_wgt.substr(ibeg,iend-ibeg).c_str());
484 double wgt = atof(tgt_with_wgt.substr(jbeg,jend-jbeg).c_str());
486 <<
"Adding to target mix: pdg = " << pdg <<
", wgt = " << wgt;
487 gOptTgtMix.insert(map<int, double>::value_type(pdg, wgt));
495 LOG(
"gevgen_nosc",
pDEBUG) <<
"Reading the event filename prefix";
499 <<
"Will set the default event filename prefix";
506 LOG(
"gevgen_nosc",
pINFO) <<
"Reading random number seed";
509 LOG(
"gevgen_nosc",
pINFO) <<
"Unspecified random number seed - Using default";
519 ostringstream gminfo;
521 gminfo <<
"Using ROOT geometry - file: " <<
gOptRootGeom 524 <<
", length units: " << lunits
525 <<
", density units: " << dunits;
527 gminfo <<
"Using target mix - ";
529 for(iter = gOptTgtMix.begin(); iter != gOptTgtMix.end(); ++iter) {
530 int pdg_code = iter->first;
531 double wgt = iter->second;
532 TParticlePDG *
p = pdglib->
Find(pdg_code);
534 string name = p->GetName();
535 gminfo <<
"(" << name <<
") -> " << 100*wgt <<
"% / ";
548 <<
"\n @@ Geometry $ " << gminfo.str()
549 <<
"\n @@ Statistics $ " <<
gOptNev <<
" events";
556 <<
"\n ** ROOT geometries not supported yet in neutron oscillation mode" 557 <<
"\n ** (they will be in the very near future)" 558 <<
"\n ** Please specify a `target mix' instead.";
568 <<
"\n gevgen_nosc [-h] " 570 <<
"\n -m decay_mode" 572 <<
"\n [-t top_volume_name_at_geom]" 573 <<
"\n [-L length_units_at_geom]" 574 <<
"\n [-D density_units_at_geom]" 575 <<
"\n -n n_of_events " 576 <<
"\n [-o output_event_file_prefix]" 577 <<
"\n [--seed random_number_seed]" 578 <<
"\n [--message-thresholds xml_file]" 579 <<
"\n [--event-record-print-level level]" 580 <<
"\n [--mc-job-status-refresh-rate rate]" 582 <<
" Please also read the detailed documentation at http://www.genie-mc.org" 583 <<
" or look at the source code: $GENIE/src/support/ndcy/EvGen/gNeutronOscEvGen.cxx"
void RandGen(long int seed)
static void SetPrintLevel(int print_level)
int main(int argc, char **argv)
string ArgAsString(char opt)
#include "Numerical/GSFunc.h"
const EventRecordVisitorI * NeutronOscGenerator(void)
virtual void ProcessEventRecord(GHepRecord *event_rec) const =0
int SelectAnnihilationMode(int pdg_code)
static RandomGen * Instance()
Access instance.
Defines the EventRecordVisitorI interface. Concrete implementations of this interface use the 'Visito...
void ReadFromCommandLine(int argc, char **argv)
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)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
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...
NeutronOscMode_t gOptDecayMode
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
bool IsValidMode(NeutronOscMode_t ndm)
void GetCommandLineArgs(int argc, char **argv)
string kDefOptEvFilePrefix
double UnitFromString(string u)
const Algorithm * GetAlgorithm(const AlgId &algid)
NtpMCFormat_t kDefOptNtpFormat
void Save(void)
get the even tree
void AddEventRecord(int ievent, const EventRecord *ev_rec)
save the event tree
string gOptRootGeomTopVol
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
string AsString(NeutronOscMode_t ndm)
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.
TParticlePDG * Find(int pdgc)
int SelectInitState(void)
map< int, double > gOptTgtMix
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f='*')
void MesgThresholds(string inpfile)
Command line argument parser.
enum genie::ENtpMCFormat NtpMCFormat_t
The GENIE Algorithm Factory.
enum genie::ENeutronOscMode NeutronOscMode_t
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)