426 #include <TGeoVolume.h> 427 #include <TGeoShape.h> 453 #ifdef __GENIE_FLUX_DRIVERS_ENABLED__ 458 #ifdef __GENIE_GEOM_DRIVERS_ENABLED__ 467 using std::ostringstream;
469 using namespace genie;
519 LOG(
"gmkspl",
pFATAL) <<
" No TuneId in RunOption";
538 double zmin=0, zmax=0;
553 TGeoVolume * topvol = rgeom->
GetGeometry()->GetTopVolume();
555 bounding_box->GetAxisRange(3, zmin, zmax);
562 LOG(
"gevgen_t2k",
pFATAL) <<
"Null top ROOT geometry volume!";
607 if(!beam_sim_data_success) {
609 <<
"The flux driver has not been properly configured. Exiting";
623 flux_driver =
dynamic_cast<GFluxI *
> (jparc_flux_driver);
631 TVector3 bdir (0,0,1);
632 TVector3 bspot(0,0,0);
638 for( ; it != gOptFluxHst.end(); ++it) {
639 int pdg_code = it->first;
640 TH1D * spectrum =
new TH1D(*(it->second));
644 flux_driver =
dynamic_cast<GFluxI *
> (hst_flux_driver);
668 bool success =
false;
674 string name = basename.substr(0, basename.rfind(
"."));
678 name +=
".master.flxprobs.root";
694 <<
"Successfully calculated/loaded flux interaction probabilities!";
699 double ntot_per_pot = 0.0;
700 double ntot_per_cycle = 0.0;
702 double pot_1cycle = jparc_flux_driver->
POT_1cycle();
704 "Expected event rates based on flux interaction probabilities:";
705 for(; sum_probs_it != sum_probs_map.end(); sum_probs_it++){
706 double sum_probs = sum_probs_it->second;
707 double nevts_per_cycle = sum_probs / pscale;
708 double nevts_per_pot = sum_probs/pot_1cycle;
709 ntot_per_pot += nevts_per_pot;
710 ntot_per_cycle += nevts_per_cycle;
712 " PDG "<< sum_probs_it->first <<
": " << nevts_per_cycle <<
713 " Events/Cycle, "<< nevts_per_pot <<
" Events/POT";
715 LOG(
"T2KProdInfo",
pNOTICE) <<
" -----------";
717 " All neutrino species: " << ntot_per_cycle <<
718 " Events/Cycle, "<< ntot_per_pot <<
" Events/POT";
720 "N.B. This assumes input flux file corresponds to "<< pot_1cycle <<
721 "POT, ensure this is correct if using these numbers!";
725 <<
"Failed to calculated/loaded flux interaction probabilities!";
732 <<
"Will not generate events - just pre-calculating flux interaction" 746 double fpot_1c = jparc_flux_driver->
POT_1cycle();
748 double pot_1c = fpot_1c / psc;
749 int ncycles = (
int) TMath::Max(1., TMath::Ceil(
gOptPOT/pot_1c));
752 <<
" *** POT/cycle: " << pot_1c;
754 <<
" *** Requested POT will be accumulated in: " 755 << ncycles <<
" flux ntuple cycles";
783 TBranch * flux = ntpw.
EventTree()->Branch(
"flux",
784 "genie::flux::GJPARCNuFluxPassThroughInfo", &flux_info, 32000, 1);
786 flux->SetAutoDelete(kFALSE);
801 <<
" *** Generating event............ " << ievent;
815 double pot = fpot / psc;
825 if(!
event && jparc_flux_driver->
End()) {
827 <<
"** The JPARC flux driver read all the input flux ntuple entries";
832 <<
"Got a null generated neutino event! Retrying ...";
836 <<
"Generated event: " << *
event;
847 <<
"Pass-through flux info associated with generated event: " 855 if(flux_info)
delete flux_info;
860 <<
"The GENIE MC job is done generaing events - Cleaning up & exiting...";
873 double pot = fpot / psc;
877 long int nflx_evg = mcj_driver -> NFluxNeutrinos();
878 long int nflx = jparc_flux_driver -> NFluxNeutrinos();
879 long int nev = ievent;
882 <<
"\n >> Actual JNUBEAM flux file normalization: " << fpot
884 <<
"\n >> Interaction probability scaling factor: " << psc
885 <<
"\n >> N of flux v read-in by flux driver: " << nflx
886 <<
"\n >> N of flux v thrown to event gen driver: " << nflx_evg
887 <<
"\n >> N of generated v interactions: " << nev
888 <<
"\n ** Normalization for generated sample: " << pot
889 <<
" POT * " << ((gOptDetectorLocation ==
"sk") ?
"cm^2" :
"det");
911 ntpw.
EventTree()->GetUserInfo()->Add(metadata);
925 for( ; it != gOptFluxHst.end(); ++it) {
926 TH1D * spectrum = it->second;
927 if(spectrum)
delete spectrum;
938 LOG(
"gevgen_t2k",
pINFO) <<
"Parsing command line arguments";
957 LOG(
"gevgen_t2k",
pDEBUG) <<
"Reading MC run number";
960 LOG(
"gevgen_t2k",
pDEBUG) <<
"Unspecified run number - Using default";
969 string lunits, dunits;
971 LOG(
"gevgen_t2k",
pDEBUG) <<
"Getting input geometry";
975 bool accessible_geom_file =
976 ! (gSystem->AccessPathName(geom.c_str()));
977 if (accessible_geom_file) {
983 <<
"No geometry option specified - Exiting";
994 <<
"Checking for input geometry length units";
997 LOG(
"gevgen_t2k",
pDEBUG) <<
"Using default geometry length units";
1003 <<
"Checking for input geometry density units";
1006 LOG(
"gevgen_t2k",
pDEBUG) <<
"Using default geometry density units";
1015 LOG(
"gevgen_t2k",
pDEBUG) <<
"Checking for input volume name";
1018 LOG(
"gevgen_t2k",
pDEBUG) <<
"Using the <master volume>";
1026 <<
"Checking for maximum path lengths XML file";
1030 <<
"Will compute the maximum path lengths at job init";
1043 if(tgtmix.size()==1) {
1044 int pdg = atoi(tgtmix[0].c_str());
1046 gOptTgtMix.insert(map<int, double>::value_type(pdg, wgt));
1049 for( ; tgtmix_iter != tgtmix.end(); ++tgtmix_iter) {
1050 string tgt_with_wgt = *tgtmix_iter;
1051 string::size_type open_bracket = tgt_with_wgt.find(
"[");
1052 string::size_type close_bracket = tgt_with_wgt.find(
"]");
1053 if (open_bracket ==string::npos ||
1054 close_bracket==string::npos)
1057 <<
"You made an error in specifying the target mix";
1061 string::size_type ibeg = 0;
1062 string::size_type iend = open_bracket;
1063 string::size_type jbeg = open_bracket+1;
1064 string::size_type jend = close_bracket;
1065 int pdg = atoi(tgt_with_wgt.substr(ibeg,iend-ibeg).c_str());
1066 double wgt = atof(tgt_with_wgt.substr(jbeg,jend-jbeg).c_str());
1068 <<
"Adding to target mix: pdg = " << pdg <<
", wgt = " << wgt;
1069 gOptTgtMix.insert(map<int, double>::value_type(pdg, wgt));
1080 LOG(
"gevgen_t2k",
pDEBUG) <<
"Getting input flux";
1091 if(fluxv.size()<2) {
1093 <<
"You need to specify both a flux ntuple ROOT file " 1094 <<
" _AND_ a detector location";
1103 for(
unsigned int inu = 2;
inu < fluxv.size();
inu++)
1115 if(fluxv.size()<2) {
1117 <<
"You need to specify both a flux ntuple ROOT file " 1118 <<
" _AND_ a detector location";
1123 bool accessible_flux_file =
1125 if (!accessible_flux_file) {
1133 for(
unsigned int inu=1;
inu<fluxv.size();
inu++) {
1134 string nutype_and_histo = fluxv[
inu];
1135 string::size_type open_bracket = nutype_and_histo.find(
"[");
1136 string::size_type close_bracket = nutype_and_histo.find(
"]");
1137 if (open_bracket ==string::npos ||
1138 close_bracket==string::npos)
1141 <<
"You made an error in specifying the flux histograms";
1145 string::size_type ibeg = 0;
1146 string::size_type iend = open_bracket;
1147 string::size_type jbeg = open_bracket+1;
1148 string::size_type jend = close_bracket;
1149 string nutype = nutype_and_histo.substr(ibeg,iend-ibeg);
1150 string histo = nutype_and_histo.substr(jbeg,jend-jbeg);
1152 TH1D * ihst = (TH1D*) flux_file.Get(histo.c_str());
1155 <<
"Can not find histogram: " << histo
1161 TString origname = ihst->GetName();
1162 TString tmpname; tmpname.Form(
"%s_", origname.Data());
1165 TH1D* spectrum = (TH1D*)ihst->Clone();
1166 spectrum->SetNameTitle(tmpname.Data(),ihst->GetName());
1167 spectrum->SetDirectory(0);
1172 spectrum->SetName(origname.Data());
1175 int pdg = atoi(nutype.c_str());
1178 <<
"Unknown neutrino type: " << nutype;
1184 <<
"Adding energy spectrum for flux neutrino: pdg = " <<
pdg;
1185 gOptFluxHst.insert(map<int, TH1D*>::value_type(pdg, spectrum));
1187 if(gOptFluxHst.size()<1) {
1189 <<
"You have not specified any flux histogram!";
1197 LOG(
"gevgen_t2k",
pFATAL) <<
"No flux info was specified - Exiting";
1225 <<
"No flux interaction probabilites were specified - exiting";
1240 <<
"Cannot specify both the -P and -S options at the same time!";
1247 <<
"Using pre-calculated flux interaction probabilities only makes " 1248 <<
"sense when using JNUBEAM flux option!";
1255 LOG(
"gevgen_t2k",
pDEBUG) <<
"Reading flux file normalization";
1259 <<
"Setting standard normalization for JNUBEAM flux ntuples";
1265 LOG(
"gevgen_t2k",
pDEBUG) <<
"Reading number of flux ntuple cycles";
1269 <<
"Setting standard number of cycles for JNUBEAM flux ntuples";
1276 <<
"Reading limit on number of events to generate";
1280 <<
"Will keep on generating events till the flux driver stops";
1286 char pot_args =
'e';
1287 bool pot_exit =
true;
1294 LOG(
"gevgen_t2k",
pDEBUG) <<
"Reading requested exposure in POT";
1297 LOG(
"gevgen_t2k",
pDEBUG) <<
"No POT exposure was requested";
1303 LOG(
"gevgen_t2k",
pDEBUG) <<
"Reading the event filename prefix";
1307 <<
"Will set the default event filename prefix";
1314 LOG(
"gevgen_t2k",
pINFO) <<
"Reading random number seed";
1317 LOG(
"gevgen_t2k",
pINFO) <<
"Unspecified random number seed - Using default";
1323 LOG(
"gevgen_t2k",
pINFO) <<
"Reading cross-section file";
1326 LOG(
"gevgen_t2k",
pINFO) <<
"Unspecified cross-section file";
1347 <<
"** To use a JNUBEAM flux ntuple you need to specify an exposure, " 1348 <<
"either via the -c, -e or -n options";
1350 <<
"** gevgen_t2k automatically sets the exposure via '-c 1'";
1355 <<
"You can not specify more than one of the -c, -e or -n options";
1365 <<
"If you're using flux from histograms you need to specify the -n option";
1376 <<
"You may not use the -e, -E options " 1377 <<
"without a detailed detector geometry description input";
1387 ostringstream gminfo;
1389 gminfo <<
"Using ROOT geometry - file: " <<
gOptRootGeom 1392 <<
", max{PL} file: " 1394 <<
", length units: " << lunits
1395 <<
", density units: " << dunits;
1397 gminfo <<
"Using target mix - ";
1399 for(iter = gOptTgtMix.begin(); iter != gOptTgtMix.end(); ++iter) {
1400 int pdg_code = iter->first;
1401 double wgt = iter->second;
1402 TParticlePDG *
p = pdglib->
Find(pdg_code);
1404 string name = p->GetName();
1405 gminfo <<
"(" << name <<
") -> " << 100*wgt <<
"% / ";
1410 ostringstream fluxinfo;
1412 fluxinfo <<
"Using flux histograms - ";
1414 for(iter = gOptFluxHst.begin(); iter != gOptFluxHst.end(); ++iter) {
1415 int pdg_code = iter->first;
1416 TH1D * spectrum = iter->second;
1417 TParticlePDG *
p = pdglib->
Find(pdg_code);
1419 string name = p->GetName();
1420 fluxinfo <<
"(" << name <<
") -> " << spectrum->GetName() <<
" / ";
1424 fluxinfo <<
"Using JNUBEAM flux ntuple - " 1430 fluxinfo <<
", ** this job is considering only: ";
1433 if(
inu < gOptFluxNtpNuList.size()-1) fluxinfo <<
",";
1439 ostringstream exposure;
1441 exposure <<
"Number of POTs = " <<
gOptPOT;
1445 exposure <<
"Number of events = " <<
gOptNev;
1455 <<
"\n - Flux @ " << fluxinfo.str()
1456 <<
"\n - Geometry @ " << gminfo.str()
1457 <<
"\n - Exposure @ " << exposure.str();
1466 <<
"\n gevgen_t2k [-h] " 1470 <<
"\n [-p pot_normalization_of_flux_file]" 1471 <<
"\n [-t top_volume_name_at_geom]" 1472 <<
"\n [-P pre_gen_prob_file]" 1473 <<
"\n [-S] [output_name]" 1474 <<
"\n [-m max_path_lengths_xml_file]" 1475 <<
"\n [-L length_units_at_geom]" 1476 <<
"\n [-D density_units_at_geom]" 1477 <<
"\n [-n n_of_events]" 1478 <<
"\n [-c flux_cycles]" 1479 <<
"\n [-e, -E exposure_in_POTs]" 1480 <<
"\n [-o output_event_file_prefix]" 1482 <<
"\n [--seed random_number_seed]" 1483 <<
"\n --cross-sections xml_file" 1484 <<
"\n [--event-generator-list list_name]" 1485 <<
"\n [--message-thresholds xml_file]" 1486 <<
"\n [--unphysical-event-mask mask]" 1487 <<
"\n [--event-record-print-level level]" 1488 <<
"\n [--mc-job-status-refresh-rate rate]" 1489 <<
"\n [--cache-file root_file]" 1491 <<
" Please also read the detailed documentation at http://www.genie-mc.org" 1492 <<
" or look at the source code: $GENIE/src/Apps/gT2KEvGen.cxx"
map< int, TH1D * > gOptFluxHst
string gOptRootGeomTopVol
void RandGen(long int seed)
static void SetPrintLevel(int print_level)
double POT_curravg(void)
current average POT
void XSecTable(string inpfile, bool require_table)
double ArgAsDouble(char opt)
bool PreCalcFluxProbabilities(void)
map< int, double > SumFluxIntProbs(void) const
bool IsNeutrino(int pdgc)
string ArgAsString(char opt)
bool LoadBeamSimData(string filename, string det_loc)
load a jnubeam root flux ntuple
THE MAIN GENIE PROJECT NAMESPACE
bool End(void)
true if no more flux nu's can be thrown (eg reaching end of beam sim ntuples)
void SetUpstreamZ(double z0)
set flux neutrino initial z position (upstream of the detector)
void SetEventGeneratorList(string listname)
double POT_1cycle(void)
flux POT per cycle
void ReadFromCommandLine(int argc, char **argv)
map< int, double > gOptTgtMix
string gOptDetectorLocation
NtpMCFormat_t kDefOptNtpFormat
void Update(int iev, const EventRecord *event)
void SetFluxParticles(const PDGCodeList &particles)
specify list of flux neutrino species
string gOptFluxProbFileName
A GENIE flux driver encapsulating the JPARC neutrino flux. It reads-in the official JPARC neutrino fl...
void SetRefreshRate(int rate)
void UseFluxDriver(GFluxI *flux)
bool gOptRandomFluxOffset
Simple class to create & update MC job status files and env. vars. This is used to be able to keep tr...
A GENIE `MC Job Driver'. Can be used for setting up complicated event generation cases involving deta...
double GlobProbScale(void) const
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
void ForceSingleProbScale(void)
void SetFilePOT(double pot)
flux file norm is in /N POT/det [ND] or /N POT/cm^2 [FD]. Specify N (typically 1E+21) ...
virtual double LengthUnits(void) const
A generic GENIE flux driver. Generates a 'cylindrical' neutrino beam along the input direction...
bool IsAntiNeutrino(int pdgc)
bool UseMaxPathLengths(string xml_filename)
double UnitFromString(string u)
int main(int argc, char **argv)
void Configure(bool calc_prob_scales=true)
string kDefOptEvFilePrefix
A ROOT/GEANT4 geometry driver.
void Save(void)
get the even tree
void GetCommandLineArgs(int argc, char **argv)
void AddEventRecord(int ievent, const EventRecord *ev_rec)
save the event tree
void SetTransverseRadius(double Rt)
void DisableOffset(void)
switch off random offset, must be called before LoadBeamSimData to have any effect ...
void SetNuDirection(const TVector3 &direction)
void BuildTune()
build tune and inform XSecSplineList
PDGCodeList gOptFluxNtpNuList(false)
string gOptSaveFluxProbsFileName
EventRecord * GenerateEvent(void)
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
void CustomizeFilenamePrefix(string prefix)
bool gOptSaveFluxProbsFile
void Initialize(void)
add event
static PDGLibrary * Instance(void)
static RunOpt * Instance(void)
vector< string > Split(string input, string delim)
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 LoadFluxProbabilities(string filename)
void SetNumOfCycles(int n)
set how many times to cycle through the ntuple (default: 1 / n=0 means 'infinite') ...
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f='*')
A vector of EventGeneratorI objects.
void SetBeamSpot(const TVector3 &spot)
void MesgThresholds(string inpfile)
void AddEnergySpectrum(int nu_pdgc, TH1D *spectrum)
TParticlePDG * Find(int pdgc, bool must_exist=true)
Command line argument parser.
enum genie::ENtpMCFormat NtpMCFormat_t
bool gOptExitAtEndOfFullFluxCycles
Defines the GENIE Geometry Analyzer Interface.
void RecursiveExhaust(TGeoVolume *topvol, string volnames, bool exhaust)
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
void UseGeomAnalyzer(GeomAnalyzerI *geom)
void UseSplines(bool useLogE=true)
The PointGeomAnalyzer class is the simplest implementation of the GeomAnalyserI interface and defines...
bool OptionExists(char opt)
was option set?
void CacheFile(string inpfile)
void SaveFluxProbabilities(string outfilename)
void EnableBareXSecPreCalc(bool flag)
const GJPARCNuFluxPassThroughInfo & PassThroughInfo(void)
GJPARCNuFluxPassThroughInfo.
void push_back(int pdg_code)
Event finding and building.
virtual TGeoManager * GetGeometry(void) const
GENIE Interface for user-defined flux classes.