26 #include "TDirectory.h" 28 #include "TLorentzVector.h" 29 #include "TCollection.h" 35 #include "TStopwatch.h" 36 #include "TRotation.h" 40 #include "GENIE/Messenger/Messenger.h" 41 #include "GENIE/Conventions/GVersion.h" 42 #include "GENIE/Conventions/Units.h" 43 #include "GENIE/EVGCore/EventRecord.h" 44 #include "GENIE/EVGDrivers/GMCJDriver.h" 45 #include "GENIE/GHEP/GHepUtils.h" 46 #include "GENIE/FluxDrivers/GCylindTH1Flux.h" 47 #include "GENIE/FluxDrivers/GMonoEnergeticFlux.h" 48 #include "GENIE/FluxDrivers/GNuMIFlux.h" 49 #include "GENIE/FluxDrivers/GSimpleNtpFlux.h" 50 #include "GENIE/FluxDrivers/GFluxDriverFactory.h" 51 #include "GENIE/FluxDrivers/GBGLRSAtmoFlux.h" 52 #include "GENIE/FluxDrivers/GFLUKAAtmoFlux.h" 53 #if __GENIE_RELEASE_CODE__ >= GRELCODE(2,12,2) 54 #include "GENIE/FluxDrivers/GHAKKMAtmoFlux.h" 56 #include "GENIE/FluxDrivers/GAtmoFlux.h" 58 #pragma GCC diagnostic push 59 #pragma GCC diagnostic ignored "-Wunused-variable" 60 #include "GENIE/Conventions/Constants.h" 61 #pragma GCC diagnostic pop 63 #include "GENIE/PDG/PDGLibrary.h" 64 #include "GENIE/PDG/PDGCodes.h" 65 #include "GENIE/Utils/AppInit.h" 66 #include "GENIE/Utils/RunOpt.h" 68 #include "GENIE/Geo/ROOTGeomAnalyzer.h" 69 #include "GENIE/Geo/GeomVolSelectorFiducial.h" 70 #include "GENIE/Geo/GeomVolSelectorRockBox.h" 71 #include "GENIE/Utils/StringUtils.h" 72 #include "GENIE/Utils/XmlParserUtils.h" 73 #include "GENIE/Interaction/InitialState.h" 74 #include "GENIE/Interaction/Interaction.h" 75 #include "GENIE/Interaction/Kinematics.h" 76 #include "GENIE/Interaction/KPhaseSpace.h" 77 #include "GENIE/Interaction/ProcessInfo.h" 78 #include "GENIE/Interaction/XclsTag.h" 79 #include "GENIE/GHEP/GHepParticle.h" 80 #include "GENIE/PDG/PDGCodeList.h" 82 #include "GENIE/FluxDrivers/GFluxBlender.h" 83 #include "GENIE/FluxDrivers/GFlavorMixerI.h" 84 #include "GENIE/FluxDrivers/GFlavorMap.h" 85 #include "GENIE/FluxDrivers/GFlavorMixerFactory.h" 89 #include "GENIE/Framework/Messenger/Messenger.h" 90 #include "GENIE/Framework/Conventions/GVersion.h" 91 #include "GENIE/Framework/Utils/StringUtils.h" 92 #include "GENIE/Framework/Utils/XmlParserUtils.h" 93 #include "GENIE/Framework/Messenger/Messenger.h" 95 #pragma GCC diagnostic push 96 #pragma GCC diagnostic ignored "-Wunused-variable" 98 #include "GENIE/Framework/Conventions/Constants.h" 99 #pragma GCC diagnostic pop 101 #include "GENIE/Framework/Conventions/Units.h" 102 #include "GENIE/Framework/ParticleData/PDGCodes.h" 103 #include "GENIE/Framework/ParticleData/PDGCodeList.h" 104 #include "GENIE/Framework/ParticleData/PDGLibrary.h" 106 #include "GENIE/Framework/GHEP/GHepParticle.h" 107 #include "GENIE/Framework/GHEP/GHepUtils.h" 109 #include "GENIE/Framework/Interaction/InitialState.h" 110 #include "GENIE/Framework/Interaction/Interaction.h" 111 #include "GENIE/Framework/Interaction/Kinematics.h" 112 #include "GENIE/Framework/Interaction/KPhaseSpace.h" 113 #include "GENIE/Framework/Interaction/ProcessInfo.h" 114 #include "GENIE/Framework/Interaction/XclsTag.h" 116 #include "GENIE/Framework/EventGen/GFluxI.h" 117 #include "GENIE/Framework/EventGen/EventRecord.h" 118 #include "GENIE/Framework/EventGen/GMCJDriver.h" 120 #include "GENIE/Framework/Utils/AppInit.h" 121 #include "GENIE/Framework/Utils/RunOpt.h" 123 #include "GENIE/Tools/Geometry/ROOTGeomAnalyzer.h" 124 #include "GENIE/Tools/Geometry/GeomVolSelectorFiducial.h" 125 #include "GENIE/Tools/Geometry/GeomVolSelectorRockBox.h" 127 #include "GENIE/Tools/Flux/GFluxBlender.h" 128 #include "GENIE/Tools/Flux/GFlavorMixerI.h" 129 #include "GENIE/Tools/Flux/GFlavorMap.h" 130 #include "GENIE/Tools/Flux/GFlavorMixerFactory.h" 131 #include "GENIE/Tools/Flux/GFluxDriverFactory.h" 133 #include "GENIE/Tools/Flux/GCylindTH1Flux.h" 134 #include "GENIE/Tools/Flux/GMonoEnergeticFlux.h" 135 #include "GENIE/Tools/Flux/GNuMIFlux.h" 136 #include "GENIE/Tools/Flux/GSimpleNtpFlux.h" 137 #include "GENIE/Tools/Flux/GAtmoFlux.h" 138 #include "GENIE/Tools/Flux/GBGLRSAtmoFlux.h" 139 #include "GENIE/Tools/Flux/GFLUKAAtmoFlux.h" 140 #include "GENIE/Tools/Flux/GHAKKMAtmoFlux.h" 146 #include "dk2nu/tree/dk2nu.h" 147 #include "dk2nu/tree/dkmeta.h" 148 #include "dk2nu/tree/NuChoice.h" 149 #include "dk2nu/genie/GDk2NuFlux.h" 170 #include "cetlib/search_path.h" 171 #include "cetlib/getenv.h" 172 #include "cetlib/split_path.h" 173 #include "cetlib_except/exception.h" 177 #include "cetlib_except/exception.h" 184 #define USE_IFDH_SERVICE 1 186 #ifdef USE_IFDH_SERVICE 187 #include "ifdh_art/IFDHService/IFDH_service.h" 193 #undef USE_IFDH_SERVICE 202 using genie::Messenger;
215 TGeoManager* geoManager,
216 std::string
const& rootFile,
217 double const& detectorMass)
218 : fGeoManager (geoManager)
219 , fGeoFile (rootFile)
220 , fGenieEventRecord (0)
227 , fUseHelperRndGen4GENIE(pset.
get< bool >(
"UseHelperRndGen4GENIE",true))
229 , fFluxType (pset.
get<
std::string >(
"FluxType") )
230 , fFluxSearchPaths (pset.
get<
std::string >(
"FluxSearchPaths",
"") )
231 , fFluxFilePatterns (pset.
get<
std::
vector<
std::string> >(
"FluxFiles") )
232 , fMaxFluxFileMB (pset.
get< int >(
"MaxFluxFileMB", 2000) )
233 , fMaxFluxFileNumber (pset.
get< int >(
"MaxFluxFileNumber",9999) )
234 , fFluxCopyMethod (pset.
get<
std::string >(
"FluxCopyMethod",
"DIRECT"))
235 , fFluxCleanup (pset.
get<
std::string >(
"FluxCleanup",
"/var/tmp") )
236 , fBeamName (pset.
get<
std::string >(
"BeamName") )
237 , fFluxRotCfg (pset.
get<
std::string >(
"FluxRotCfg",
"none") )
238 , fFluxRotValues (pset.
get<
std::
vector<double> >(
"FluxRotValues", {} ) )
240 ,
fTopVolume (pset.get< std::string >(
"TopVolume") )
242 ,
fDetLocation (pset.get< std::string >(
"DetectorLocation") )
245 ,
fPOTPerSpill (pset.get<
double >(
"POTPerSpill", 0.0) )
250 ,
fMonoEnergy (pset.get<
double >(
"MonoEnergy", 2.0) )
253 ,
fEmin (pset.get<
double >(
"FluxEmin", 0) )
254 ,
fEmax (pset.get<
double >(
"FluxEmax", 10) )
255 ,
fBeamRadius (pset.get<
double >(
"BeamRadius", 3.0) )
263 ,
fGenFlavors (pset.get< std::vector<int> >(
"GenFlavors") )
264 ,
fAtmoEmin (pset.get<
double >(
"AtmoEmin", 0.1) )
265 ,
fAtmoEmax (pset.get<
double >(
"AtmoEmax", 10.0) )
266 ,
fAtmoRl (pset.get<
double >(
"Rl", 20.0) )
267 ,
fAtmoRt (pset.get<
double >(
"Rt", 20.0) )
269 ,
fEnvironment (pset.get< std::vector<std::string> >(
"Environment") )
270 ,
fXSecTable (pset.get< std::string >(
"XSecTable",
"") )
271 ,
fTuneName (pset.get< std::string >(
"TuneName",
"${GENIE_XSEC_TUNE}") )
273 ,
fGXMLPATH (pset.get< std::string >(
"GXMLPATH",
"") )
274 ,
fGMSGLAYOUT (pset.get< std::string >(
"GMSGLAYOUT",
"") )
277 ,
fMixerConfig (pset.get< std::string >(
"MixerConfig",
"none") )
280 ,
fFiducialCut (pset.get< std::string >(
"FiducialCut",
"none") )
281 ,
fGeomScan (pset.get< std::string >(
"GeomScan",
"default") )
282 ,
fDebugFlags (pset.get<
unsigned int >(
"DebugFlags", 0) )
290 std::ostringstream fenvout, fenvfatal;
291 fenvout <<
" fEnviroment.size() = " <<
fEnvironment.size();
293 fenvout << std::endl <<
" [" << std::setw(20) <<
std::left 298 if ( fEnvironment[i] ==
"GEVGL" ||
299 fEnvironment[i] ==
"GSPLOAD" ) {
301 std::string altparam =
"";
302 if ( fEnvironment[i] ==
"GEVGL" ) altparam =
"EventGeneratorList";
303 if ( fEnvironment[i] ==
"GSPLOAD" ) altparam =
"XSecTable";
305 fenvfatal << std::endl <<
"use of \"" << fEnvironment[i] <<
"\"" 306 <<
" is no longer supported as a Environment fcl parameter pair key," 308 <<
" please remove it from from the list and use" 309 <<
" the appropriate direct fcl parameter \"" 310 << altparam <<
"\"" << std::endl;
314 <<
" Use of fEnvironment parameters is deprecated:\n" 319 <<
" bad use of Environment fcl parameter";
324 std::vector<double> beamCenter (pset.get< std::vector<double> >(
"BeamCenter") );
325 std::vector<double> beamDirection(pset.get< std::vector<double> >(
"BeamDirection"));
326 fBeamCenter.SetXYZ(beamCenter[0], beamCenter[1], beamCenter[2]);
327 fBeamDirection.SetXYZ(beamDirection[0], beamDirection[1], beamDirection[2]);
334 const char* gseedstr = std::getenv(
"GSEED");
336 dfltseed = strtol(gseedstr,NULL,0);
340 int seedval = pset.get<
int >(
"RandomSeed", dfltseed);
342 mf::LogInfo(
"GENIEHelper") <<
"Init HelperRandom with seed " << seedval;
392 <<
"Init genie::utils::app_init::RandGen() with seed " << seedval;
393 genie::utils::app_init::RandGen(seedval);
403 flvlist += Form(
" %d",*itr);
409 <<
" GeV) neutrinos with the following flavors: " 411 }
else if (
fFluxType.find(
"function") == 0 ) {
414 <<
"Generating neutrinos using the functional form: " 417 <<
"with the following flavors: " << flvlist;
418 }
else if (
fFluxType.find(
"PowerSpectrum") != std::string::npos) {
420 <<
"Generating neutrinos using the a power spectrum with Spectral index = " 422 <<
", with the following flavors: " << flvlist
423 <<
"\nThe energy range is between: " <<
fAtmoEmin <<
" GeV and " 426 <<
" Generation surface of: (" <<
fAtmoRl <<
"," 431 std::string fileliststr;
433 fileliststr =
"NO FLUX FILES FOUND!";
439 fileliststr +=
"\n\t";
440 fileliststr += *sitr;
444 <<
"Generating flux with the following flavors: " << flvlist
445 <<
"\nand these file patterns: " << fileliststr;
453 <<
"one or the other of EventsPerSpill (" 461 <<
" events for each spill";
465 <<
" pot for each spill";
475 <<
"Initialize spill time random generator with seed " << seedval;
480 timeShiftFactory.
Print();
492 genie::geometry::ROOTGeomAnalyzer* rgeom =
493 dynamic_cast<genie::geometry::ROOTGeomAnalyzer*
>(
fGeomD);
495 string filename =
"maxpathlength.xml";
497 <<
"Saving MaxPathLengths as: \"" << filename <<
"\"";
499 const genie::PathLengthList& maxpath = rgeom->GetMaxPathLengths();
501 maxpath.SaveAsXml(filename);
503 std::ofstream mpfile(filename.c_str(), std::ios_base::app);
506 <<
"<!-- this file is only relevant for a setup compatible with:" 519 <<
"~GENIEHelper called, but previously failed to construct " 520 << ( (
fDriver) ?
"":
" genie::GMCJDriver" )
521 << ( (
fFluxD) ?
"":
" genie::GFluxI" );
524 double probscale =
fDriver->GlobProbScale();
530 genie::flux::GFluxExposureI* fexposure =
531 dynamic_cast<genie::flux::GFluxExposureI*
>(
fFluxD);
533 rawpots = fexposure->GetTotalExposure();
535 genie::flux::GFluxFileConfigI* ffileconfig =
536 dynamic_cast<genie::flux::GFluxFileConfigI*
>(
fFluxD);
538 ffileconfig->PrintConfig();
543 <<
" GMCJDriver GlobProbScale " << probscale
544 <<
" FluxDriver base pots " << rawpots
545 <<
" corrected POTS " << rawpots/TMath::Max(probscale,1.0
e-100);
554 #ifdef USE_IFDH_SERVICE 561 std::string
ff = *ffitr;
562 if ( ff.find(
"/var/tmp") == 0 ) {
575 std::string
ff = *ffitr;
576 if ( ff.find(
"/var/tmp") == 0 ) {
611 genie::PDGLibrary::Instance();
620 (*genie::Messenger::Instance())(
"GENIE") << log4cpp::Priority::INFO
621 <<
"Trigger GENIE banner";
625 mf::LogInfo(
"GENIEHelper") <<
"GENIE EventGeneratorList using \"" 633 genie::RunOpt* grunopt = genie::RunOpt::Instance();
637 std::string currentEvtGenListName = grunopt->EventGeneratorList();
639 mf::LogInfo(
"GENIEHelper") <<
" EventGeneratorList name changed from \"" 641 << currentEvtGenListName <<
"\"" 642 <<
" by evgb::SetEventGeneratorListAndTune";
646 std::string currentTuneName = grunopt->Tune()->Name();
648 mf::LogInfo(
"GENIEHelper") <<
" TuneName name changed from \"" 650 << currentTuneName <<
"\"" 651 <<
" by evgb::SetEventGeneratorListAndTune";
657 fDriver =
new genie::GMCJDriver();
682 fDriver->ForceSingleProbScale();
695 mf::LogInfo(
"GENIEHelper") <<
"Number of events per spill will be based on poisson mean of " 711 fFluxD->Clear(
"CycleHistory");
724 size_t ftlead = tmpFluxType.find_first_not_of(
" \t\n");
725 if ( ftlead ) tmpFluxType.erase( 0, ftlead );
726 size_t ftlen = tmpFluxType.length();
727 size_t fttrail = tmpFluxType.find_last_not_of(
" \t\n");
728 if ( fttrail != ftlen ) tmpFluxType.erase( fttrail+1, ftlen );
732 if ( tmpFluxType.find(
"atmos_") == 0 ) tmpFluxType.erase(0,6);
733 if ( tmpFluxType.find(
"atmo_") == 0 ) tmpFluxType.erase(0,5);
734 if ( tmpFluxType.find(
"tree_") == 0 ) tmpFluxType.erase(0,5);
739 if ( tmpFluxType.find(
"hist") != std::string::npos ) tmpFluxType =
"histogram";
740 if ( tmpFluxType.find(
"func") != std::string::npos ) tmpFluxType =
"function";
741 if ( tmpFluxType.find(
"mono") != std::string::npos ) tmpFluxType =
"mono";
744 if ( tmpFluxType.find(
"FLUKA") != std::string::npos ) tmpFluxType =
"atmo_FLUKA";
745 if ( tmpFluxType.find(
"BARTOL") != std::string::npos ) tmpFluxType =
"atmo_BGLRS";
746 if ( tmpFluxType.find(
"BGLRS") != std::string::npos ) tmpFluxType =
"atmo_BGLRS";
747 if ( tmpFluxType.find(
"HONDA") != std::string::npos ) tmpFluxType =
"atmo_HAKKM";
748 if ( tmpFluxType.find(
"HAKKM") != std::string::npos ) tmpFluxType =
"atmo_HAKKM";
749 if ( tmpFluxType.find(
"POWER") != std::string::npos ) tmpFluxType =
"atmo_PowerSpectrum";
752 if ( tmpFluxType.find(
"simple") != std::string::npos ) tmpFluxType =
"tree_simple";
753 if ( tmpFluxType.find(
"ntuple") != std::string::npos ) tmpFluxType =
"tree_numi";
754 if ( tmpFluxType.find(
"numi") != std::string::npos ) tmpFluxType =
"tree_numi";
755 if ( tmpFluxType.find(
"dk2nu") != std::string::npos ) tmpFluxType =
"tree_dk2nu";
774 std::copy(fluxpattset.begin(),fluxpattset.end(),
785 <<
"ERROR: The number of generated neutrino flavors (" 787 <<
") doesn't correspond to the number of files (" 790 <<
"ERROR: atmo_ flavors != files";
792 std::ostringstream atmofluxmatch;
793 for (
size_t indx=0; indx <
fGenFlavors.size(); ++indx ) {
794 atmofluxmatch <<
" " << std::setw(3) <<
fGenFlavors[indx]
798 <<
"atmo flux assignment : \n" << atmofluxmatch.str();
803 <<
"ERROR: For Atmospheric Neutrino generation," 804 <<
" EventPerSpill need to be 1!!";
806 <<
"ERROR: " <<
fFluxType <<
" EventsPerSpill wasn't 1 (" 810 std::ostringstream atmofluxinfo;
812 if (
fFluxType.find(
"FLUKA") != std::string::npos ){
813 atmofluxinfo <<
" The fluxes are from FLUKA";
815 else if (
fFluxType.find(
"BARTOL") != std::string::npos ||
816 fFluxType.find(
"BGLRS") != std::string::npos ){
817 atmofluxinfo <<
" The fluxes are from BARTOL/BGLRS";
819 else if (
fFluxType.find(
"HONDA") != std::string::npos ||
820 fFluxType.find(
"HAKKM") != std::string::npos ){
821 atmofluxinfo <<
" The fluxes are from HONDA/HAKKM";
823 else if (
fFluxType.find(
"PowerSpectrum") != std::string::npos){
824 atmofluxinfo <<
" The fluxes are interpolated HONDA";
828 <<
"Unknown atmo_ flux simulation: " <<
fFluxType;
830 <<
"ERROR: bad atmo_ flux type " <<
fFluxType;
835 <<
" The energy range is between: " <<
fAtmoEmin <<
" GeV and " 838 <<
" Generation surface of: (" <<
fAtmoRl <<
"," 850 <<
"setting beam direction and center at " 857 TDirectory *savedir = gDirectory;
865 const char* histname =
"none";
867 case 12: histname =
"nue";
break;
868 case -12: histname =
"nuebar";
break;
869 case 14: histname =
"numu";
break;
870 case -14: histname =
"numubar";
break;
871 case 16: histname =
"nutau";
break;
872 case -16: histname =
"nutaubar";
break;
875 <<
"ERROR: no support for histogram flux with flavor PDG=" 888 <<
"total histogram flux over desired flavors = " 896 genie::geometry::ROOTGeomAnalyzer *rgeom =
897 new genie::geometry::ROOTGeomAnalyzer(
fGeoManager);
902 int keep = ( geomFlags >> 7 );
904 <<
"InitializeGeometry set debug 0x" 905 << std::hex << geomFlags << std::dec
906 <<
" keepSegPath " << keep;
907 rgeom->SetDebugFlags(geomFlags);
908 if ( keep ) rgeom->SetKeepSegPath(
true);
916 rgeom->SetDensityUnits(genie::units::gram_centimeter3);
918 rgeom->SetMixtureWeightsSum(1.);
920 <<
"GENIEHelper::InitializeGeometry using TopVolume '" 932 genie::GeomAnalyzerI* geom_driver =
fGeomD;
935 if( fidcut.find_first_not_of(
" \t\n") != 0)
936 fidcut.erase( 0, fidcut.find_first_not_of(
" \t\n") );
939 std::transform(fidcut.begin(),fidcut.end(),fidcut.begin(),::tolower);
941 if (
"" == fidcut ||
"none" == fidcut )
return;
943 if ( fidcut.find(
"rock") != string::npos ) {
978 genie::geometry::ROOTGeomAnalyzer * rgeom =
979 dynamic_cast<genie::geometry::ROOTGeomAnalyzer *
>(geom_driver);
982 <<
"Can not create GeomVolSelectorFiduction," 983 <<
" geometry driver is not ROOTGeomAnalyzer";
987 mf::LogInfo(
"GENIEHelper") <<
"fiducial cut: " << fidcut;
990 genie::geometry::GeomVolSelectorFiducial* fidsel =
991 new genie::geometry::GeomVolSelectorFiducial();
993 fidsel->SetRemoveEntries(
true);
995 vector<string> strtok = genie::utils::str::Split(fidcut,
":");
996 if ( strtok.size() != 2 ) {
998 <<
"Can not create GeomVolSelectorFiduction," 999 <<
" no \":\" separating type from values. nsplit=" << strtok.size();
1000 for (
unsigned int i=0; i < strtok.size(); ++i )
1002 <<
"strtok[" << i <<
"] = \"" << strtok[i] <<
"\"";
1007 string stype = strtok[0];
1008 bool reverse = ( stype.find(
"0") != string::npos );
1009 bool master = ( stype.find(
"m") != string::npos );
1012 vector<double> vals;
1013 vector<string> valstrs = genie::utils::str::Split(strtok[1],
" ,;(){}[]");
1015 for ( ; iter != valstrs.end(); ++iter ) {
1016 const string& valstr1 = *iter;
1017 if ( valstr1 !=
"" ) vals.push_back(atof(valstr1.c_str()));
1019 size_t nvals = vals.size();
1021 for (
size_t nadd = 0; nadd < 7-nvals; ++nadd ) vals.push_back(0);
1032 if ( stype.find(
"zcyl") != string::npos ) {
1035 mf::LogError(
"GENIEHelper") <<
"MakeZCylinder needs 5 values, not " << nvals
1036 <<
" fidcut=\"" << fidcut <<
"\"";
1037 fidsel->MakeZCylinder(vals[0],vals[1],vals[2],vals[3],vals[4]);
1039 }
else if ( stype.find(
"box") != string::npos ) {
1042 mf::LogError(
"GENIEHelper") <<
"MakeBox needs 6 values, not " << nvals
1043 <<
" fidcut=\"" << fidcut <<
"\"";
1044 double xyzmin[3] = { vals[0], vals[1], vals[2] };
1045 double xyzmax[3] = { vals[3], vals[4], vals[5] };
1046 fidsel->MakeBox(xyzmin,xyzmax);
1048 }
else if ( stype.find(
"zpoly") != string::npos ) {
1051 mf::LogError(
"GENIEHelper") <<
"MakeZPolygon needs 7 values, not " << nvals
1052 <<
" fidcut=\"" << fidcut <<
"\"";
1053 int nfaces = (int)vals[0];
1055 mf::LogError(
"GENIEHelper") <<
"MakeZPolygon needs nfaces>=3, not " << nfaces
1056 <<
" fidcut=\"" << fidcut <<
"\"";
1057 fidsel->MakeZPolygon(nfaces,vals[1],vals[2],vals[3],vals[4],vals[5],vals[6]);
1059 }
else if ( stype.find(
"sphere") != string::npos ) {
1062 mf::LogError(
"GENIEHelper") <<
"MakeZSphere needs 4 values, not " << nvals
1063 <<
" fidcut=\"" << fidcut <<
"\"";
1064 fidsel->MakeSphere(vals[0],vals[1],vals[2],vals[3]);
1068 <<
"Can not create GeomVolSelectorFiduction for shape \"" << stype <<
"\"";
1072 fidsel->ConvertShapeMaster2Top(rgeom);
1073 mf::LogInfo(
"GENIEHelper") <<
"Convert fiducial volume from master to topvol coords";
1076 fidsel->SetReverseFiducial(
true);
1077 mf::LogInfo(
"GENIEHelper") <<
"Reverse sense of fiducial volume cut";
1080 rgeom->AdoptGeomVolSelector(fidsel);
1087 genie::GeomAnalyzerI* geom_driver =
fGeomD;
1090 if( fidcut.find_first_not_of(
" \t\n") != 0)
1091 fidcut.erase( 0, fidcut.find_first_not_of(
" \t\n") );
1094 std::transform(fidcut.begin(),fidcut.end(),fidcut.begin(),::tolower);
1096 genie::geometry::ROOTGeomAnalyzer * rgeom =
1097 dynamic_cast<genie::geometry::ROOTGeomAnalyzer *
>(geom_driver);
1100 <<
"Can not create GeomVolSelectorRockBox," 1101 <<
" geometry driver is not ROOTGeomAnalyzer";
1105 mf::LogInfo(
"GENIEHelper") <<
"fiducial (rock) cut: " << fidcut;
1108 genie::geometry::GeomVolSelectorRockBox* rocksel =
1109 new genie::geometry::GeomVolSelectorRockBox();
1111 vector<string> strtok = genie::utils::str::Split(fidcut,
":");
1112 if ( strtok.size() != 2 ) {
1114 <<
"Can not create GeomVolSelectorRockBox," 1115 <<
" no \":\" separating type from values. nsplit=" << strtok.size();
1116 for (
unsigned int i=0; i < strtok.size(); ++i )
1118 <<
"strtok[" << i <<
"] = \"" << strtok[i] <<
"\"";
1122 string stype = strtok[0];
1125 vector<double> vals;
1126 vector<string> valstrs = genie::utils::str::Split(strtok[1],
" ,;(){}[]\t\n\r");
1128 for ( ; iter != valstrs.end(); ++iter ) {
1129 const string& valstr1 = *iter;
1130 if ( valstr1 !=
"" ) {
1131 double aval = atof(valstr1.c_str());
1132 mf::LogDebug(
"GENIEHelper") <<
"rock value [" << vals.size() <<
"] " 1134 vals.push_back(aval);
1137 size_t nvals = vals.size();
1139 rocksel->SetRemoveEntries(
true);
1148 <<
"least 6 values, found " 1150 << strtok[1] <<
"\"";
1153 double xyzmin[3] = { vals[0], vals[1], vals[2] };
1154 double xyzmax[3] = { vals[3], vals[4], vals[5] };
1156 bool rockonly =
true;
1157 double wallmin = 800.;
1158 double dedx = 2.5 * 1.7e-3;
1159 double fudge = 1.05;
1161 if ( nvals >= 7 ) rockonly = vals[6];
1162 if ( nvals >= 8 ) wallmin = vals[7];
1163 if ( nvals >= 9 ) dedx = vals[8];
1164 if ( nvals >= 10 ) fudge = vals[9];
1166 rocksel->SetRockBoxMinimal(xyzmin,xyzmax);
1167 rocksel->SetMinimumWall(wallmin);
1168 rocksel->SetDeDx(dedx/fudge);
1173 if ( ! rockonly ) rocksel->MakeSphere(0,0,0,1.0
e-10);
1174 else rocksel->MakeBox(xyzmin,xyzmax);
1176 rgeom->AdoptGeomVolSelector(rocksel);
1188 std::string fluxName =
"";
1194 if (
fFluxType.find(
"genie::flux::") != std::string::npos )
1196 else if (
fFluxType.find(
"tree_numi") == 0 )
1197 fluxName =
"genie::flux::GNuMIFlux";
1198 else if (
fFluxType.find(
"tree_simple") == 0 )
1199 fluxName =
"genie::flux::GSimpleNtpFlux";
1200 else if (
fFluxType.find(
"tree_dk2nu") == 0 )
1201 fluxName =
"genie::flux::GDk2NuFlux";
1203 if ( fluxName !=
"" ) {
1205 genie::flux::GFluxDriverFactory& fluxDFactory =
1206 genie::flux::GFluxDriverFactory::Instance();
1207 fFluxD = fluxDFactory.GetFluxDriver(fluxName);
1210 <<
"genie::flux::GFluxDriverFactory had not result for '" 1211 << fluxName <<
"' (fFluxType was '" <<
fFluxType <<
"'";
1217 genie::flux::GFluxFileConfigI* ffileconfig =
1218 dynamic_cast<genie::flux::GFluxFileConfigI*
>(
fFluxD);
1219 if ( ffileconfig ) {
1221 ffileconfig->PrintConfig();
1223 genie::PDGCodeList probes;
1225 probes.push_back(*flvitr);
1226 ffileconfig->SetFluxParticles(probes);
1232 if (
fFluxType.find(
"histogram") == 0 ) {
1234 genie::flux::GCylindTH1Flux* histFlux =
new genie::flux::GCylindTH1Flux();
1251 else if (
fFluxType.find(
"mono") == 0 ) {
1256 std::map<int, double> pdgwmap;
1258 pdgwmap[*i] = weight;
1260 genie::flux::GMonoEnergeticFlux *monoflux =
new genie::flux::GMonoEnergeticFlux(
fMonoEnergy, pdgwmap);
1266 else if (
fFluxType.find(
"function") == 0 ) {
1268 genie::flux::GCylindTH1Flux* histFlux =
new genie::flux::GCylindTH1Flux();
1271 spectrum->Add(input_func);
1274 histFlux->AddEnergySpectrum(*i, spectrum);
1285 else if(
fFluxType.find(
"PowerSpectrum") != std::string::npos){
1294 for (
size_t j = 0; j <
fGenFlavors.size(); ++j ) {
1303 std::ostringstream atmoCfgText;
1304 const int w=13, p=6;
1305 auto old_p = atmoCfgText.precision(p);
1306 atmoCfgText <<
"\n UserCoordSystem rotation:\n" 1319 atmoCfgText.precision(old_p);
1332 else if (
fFluxType.find(
"atmo_") == 0 ) {
1335 genie::flux::GAtmoFlux *atmo_flux_driver = 0;
1337 if (
fFluxType.find(
"FLUKA") != std::string::npos ) {
1338 genie::flux::GFLUKAAtmoFlux * fluka_flux =
1339 new genie::flux::GFLUKAAtmoFlux;
1340 atmo_flux_driver =
dynamic_cast<genie::flux::GAtmoFlux *
>(fluka_flux);
1342 if (
fFluxType.find(
"BARTOL") != std::string::npos ||
1343 fFluxType.find(
"BGLRS") != std::string::npos ) {
1344 genie::flux::GBGLRSAtmoFlux * bartol_flux =
1345 new genie::flux::GBGLRSAtmoFlux;
1346 atmo_flux_driver =
dynamic_cast<genie::flux::GAtmoFlux *
>(bartol_flux);
1348 #if __GENIE_RELEASE_CODE__ >= GRELCODE(2,12,2) 1349 if (
fFluxType.find(
"atmo_HONDA") != std::string::npos ||
1350 fFluxType.find(
"atmo_HAKKM") != std::string::npos ) {
1351 genie::flux::GHAKKMAtmoFlux * honda_flux =
1352 new genie::flux::GHAKKMAtmoFlux;
1353 atmo_flux_driver =
dynamic_cast<genie::flux::GAtmoFlux *
>(honda_flux);
1357 atmo_flux_driver->ForceMinEnergy(
fAtmoEmin);
1358 atmo_flux_driver->ForceMaxEnergy(
fAtmoEmax);
1361 std::ostringstream atmoCfgText;
1362 atmoCfgText <<
"Configuration for " <<
fFluxType 1364 for (
size_t j = 0; j <
fGenFlavors.size(); ++j ) {
1367 atmo_flux_driver->AddFluxFile(flavor,flxfile);
1368 atmoCfgText <<
"\n FLAVOR: " << std::setw(3) << flavor
1369 <<
" FLUX FILE: " << flxfile;
1372 const int w=13, p=6;
1373 auto old_p = atmoCfgText.precision(p);
1374 atmoCfgText <<
"\n UserCoordSystem rotation:\n" 1387 atmoCfgText.precision(old_p);
1391 atmo_flux_driver->LoadFluxData();
1394 atmo_flux_driver->SetRadii(
fAtmoRl, fAtmoRt);
1396 fFluxD = atmo_flux_driver;
1402 <<
"Failed to contruct base flux driver for FluxType '" 1405 <<
"Failed to contruct base flux driver for FluxType '" 1407 << __FILE__ <<
":" << __LINE__ <<
"\n";
1417 if ( keyword !=
"none" && keyword !=
"" ) {
1419 genie::flux::GFlavorMixerI* mixer = 0;
1422 if ( keyword ==
"map" || keyword ==
"swap" || keyword ==
"fixedfrac" )
1423 mixer =
new genie::flux::GFlavorMap();
1428 genie::flux::GFlavorMixerFactory& mixerFactory =
1429 genie::flux::GFlavorMixerFactory::Instance();
1430 mixer = mixerFactory.GetFlavorMixer(keyword);
1438 const std::vector<std::string>& knownMixers =
1439 mixerFactory.AvailableFlavorMixers();
1440 std::ostringstream mixers;
1441 for (
unsigned int j=0; j < knownMixers.size(); ++j ) {
1442 mixers <<
"\n [" << std::setw(2) << j <<
"] " << knownMixers[j];
1445 <<
" GFlavorMixerFactory known mixers: " << mixers.str();
1452 <<
"GENIEHelper MixerConfig keyword was \"" << keyword
1453 <<
"\" but that did not map to a class; " << std::endl
1454 <<
"GFluxBlender in use, but no mixer";
1457 genie::GFluxI* realFluxD =
fFluxD;
1458 genie::flux::GFluxBlender* blender =
new genie::flux::GFluxBlender();
1460 blender->AdoptFluxGenerator(realFluxD);
1461 blender->AdoptFlavorMixer(mixer);
1464 if ( mixer ) mixer->PrintConfig();
1465 blender->PrintConfig();
1466 std::cout << std::flush;
1478 if(
fGeomScan.find_first_not_of(
" \t\n") != 0)
1481 if (
fGeomScan.find(
"default") == 0 )
return;
1483 genie::geometry::ROOTGeomAnalyzer* rgeom =
1484 dynamic_cast<genie::geometry::ROOTGeomAnalyzer*
>(
fGeomD);
1488 <<
"genie::geometry::ROOTGeomAnalyzer*";
1494 vector<string> strtok = genie::utils::str::Split(
fGeomScan,
" ");
1496 string scanmethod = strtok[0];
1499 std::transform(scanmethod.begin(),scanmethod.end(),scanmethod.begin(),::tolower);
1501 if ( scanmethod.find(
"file") == 0 ) {
1503 string filename = strtok[1];
1504 string fullname = genie::utils::xml::GetXMLFilePath(filename);
1506 <<
"ConfigGeomScan getting MaxPathLengths from \"" << fullname <<
"\"";
1507 fDriver->UseMaxPathLengths(fullname);
1511 vector<double> vals;
1512 for (
size_t indx=1; indx < strtok.size(); ++indx ) {
1513 const string& valstr1 = strtok[indx];
1514 if ( valstr1 !=
"" ) vals.push_back(atof(valstr1.c_str()));
1516 size_t nvals = vals.size();
1518 for (
size_t nadd = 0; nadd < 4-nvals; ++nadd ) vals.push_back(0);
1520 double safetyfactor = 0;
1522 if ( scanmethod.find(
"box") == 0 ) {
1524 int np = (int)vals[0];
1525 int nr = (int)vals[1];
1526 if ( nvals >= 3 ) safetyfactor = vals[2];
1527 if ( nvals >= 4 ) writeout = vals[3];
1529 if ( np <= 10 ) np = rgeom->ScannerNPoints();
1530 if ( nr <= 10 ) nr = rgeom->ScannerNRays();
1532 <<
"ConfigGeomScan scan using box " << np <<
" points, " 1534 rgeom->SetScannerNPoints(np);
1535 rgeom->SetScannerNRays(nr);
1536 }
else if ( scanmethod.find(
"flux") == 0 ) {
1538 int np = (int)vals[0];
1539 if ( nvals >= 2 ) safetyfactor = vals[1];
1540 if ( nvals >= 3 ) writeout = vals[2];
1543 if (
abs(np) <= 100 ) {
1544 int npnew = rgeom->ScannerNParticles();
1545 if ( np < 0 ) npnew = -
abs(npnew);
1547 <<
"Too few rays requested for geometry scan: " << np
1548 <<
", use: " << npnew <<
"instead";
1552 <<
"ConfigGeomScan scan using " << np <<
" flux particles" 1553 << ( (np>0) ?
"" :
" with ray energy pushed to flux driver maximum" );
1554 rgeom->SetScannerFlux(
fFluxD);
1555 rgeom->SetScannerNParticles(np);
1559 throw cet::exception(
"GENIEHelper") <<
"fGeomScan unknown method: \"" 1562 if ( safetyfactor > 0 ) {
1564 <<
"ConfigGeomScan setting safety factor to " << safetyfactor;
1565 rgeom->SetMaxPlSafetyFactor(safetyfactor);
1576 mf::LogInfo(
"GENIEHelper") <<
"about to create MaxPathOutInfo";
1593 mf::LogInfo(
"GENIEHelper") <<
"MaxPathOutInfo: \"" 1618 else if (
fFluxType.find(
"histogram") == 0 ) {
1631 long int nNeutrinos;
1633 if(
fFluxType.find(
"PowerSpectrum") != std::string::npos){
1640 nNeutrinos =
dynamic_cast<genie::flux::GAtmoFlux *
>(
fFluxD)->NFluxNeutrinos();
1670 TRandom* old_gRandom = gRandom;
1681 double flxweight =
fFluxD->Weight();
1689 bool viableInteraction =
true;
1695 genie::flux::GFluxExposureI* fexposure =
1696 dynamic_cast<genie::flux::GFluxExposureI*
>(
fFluxD);
1705 if ( ! viableInteraction )
return false;
1712 double timeoffset = 0;
1721 std::unordered_map<std::string, std::string> genConfig;
1723 if(
fFluxType.find(
"PowerSpectrum") != std::string::npos){
1739 if (
fFluxType.find(
"histogram") == 0 ) {
1748 std::vector<double> fluxes(6, 0.);
1760 flux.
SetFluxGen(fluxes[kNue], fluxes[kNueBar],
1761 fluxes[kNuMu], fluxes[kNuMuBar],
1762 fluxes[kNuTau], fluxes[kNuTauBar]);
1766 else if (
fFluxType.find(
"mono") == 0 ||
1770 else if (
fFluxType.find(
"atmo_FLUKA") == 0 ||
1772 fFluxType.find(
"atmo_PowerSpectrum") == 0 ||
1784 TLorentzVector nuray_pos =
fFluxD->Position();
1785 TVector3 ray2vtx = nuray_pos.Vect() - vertex->Vect();
1786 flux.
fgenx = nuray_pos.X();
1787 flux.
fgeny = nuray_pos.Y();
1788 flux.
fgenz = nuray_pos.Z();
1791 genie::flux::GFluxBlender* blender =
1792 dynamic_cast<genie::flux::GFluxBlender*
>(
fFluxD2GMCJD);
1800 mf::LogInfo(
"GENIEHelper") <<
"vertex loc " << vertex->X() <<
"," 1801 << vertex->Y() <<
"," << vertex->Z() << std::endl
1802 <<
" flux ray start " << nuray_pos.X() <<
"," 1803 << nuray_pos.Y() <<
"," << nuray_pos.Z() << std::endl
1805 <<
" dk2ray = " << flux.
fdk2gen;
1823 (
fFluxRotCfg.find(
"none") != std::string::npos ) )
return;
1827 bool verbose = (
fFluxRotCfg.find(
"verbose") != std::string::npos );
1829 std::ostringstream indata;
1830 indata <<
"BuildFluxRotation: Cfg \"" <<
fFluxRotCfg <<
"\"\n" 1831 <<
" " << nval <<
" values\n";
1832 for (
size_t i=0; i<nval; ++i) {
1833 indata <<
" [" << std::setw(2) << i <<
"] " <<
fFluxRotValues[i] <<
"\n";
1839 if (
fFluxRotCfg.find(
"newxyz") != std::string::npos ||
1852 fTempRot.RotateAxes(newX,newY,newZ);
1859 <<
" but nval=" << nval <<
", need 9";
1864 if (
fFluxRotCfg.find(
"series") != std::string::npos ) {
1867 std::vector<std::string> strs = genie::utils::str::Split(
fFluxRotCfg,
" ,;(){}[]");
1869 for (
size_t j=0; j<strs.size(); ++j) {
1870 std::string what = strs[j];
1871 if ( what ==
"" )
continue;
1873 std::transform(what.begin(),what.end(),what.begin(),::tolower);
1874 if ( what ==
"series" )
continue;
1875 if ( what ==
"verbose" )
continue;
1876 if ( what.find(
"rot") != 0 ) {
1878 <<
"processing series rotation saw keyword \"" << what <<
"\" -- ignoring";
1881 char axis = what[3];
1883 if ( axis !=
'x' && axis !=
'y' && axis !=
'z' ) {
1886 <<
" keyword '" << what <<
"': bad axis '" << axis <<
"'";
1888 std::string units = what.substr(4);
1890 if (units.size() > 3) units.erase(3);
1891 if ( units !=
"" && units !=
"rad" && units !=
"deg" ) {
1894 <<
" keyword '" << what <<
"': bad units '" << units <<
"'";
1897 double scale = (( units ==
"rad" ) ? 1.0 : TMath::DegToRad() );
1900 if ( nrot >= nval ) {
1904 <<
" asking for rotation [" << nrot <<
"] " 1905 << what <<
" but nval=" << nval;
1908 if ( axis ==
'x' ) fTempRot.RotateX(rot);
1909 if ( axis ==
'y' ) fTempRot.RotateY(rot);
1910 if ( axis ==
'z' ) fTempRot.RotateZ(rot);
1917 if ( nrot+1 != nval ) {
1920 <<
"BuildFluxRotation only used " << nrot+1 <<
" of " 1921 << nval <<
" FluxRotValues";
1930 <<
" nval=" << nval <<
", but don't know how to interpret that";
1948 <<
"ExpandFluxPaths initially: \"" << initial <<
"\"\n" 1970 bool randomizeFiles =
false;
1971 if (
fFluxType.find(
"tree_") == 0 ) randomizeFiles =
true;
1973 std::vector<std::string> dirs;
1975 if ( dirs.empty() ) dirs.push_back(std::string());
1978 int flags = GLOB_TILDE;
1980 std::ostringstream patterntext;
1981 std::ostringstream dirstext;
1987 std::string userpattern = *uitr;
1988 patterntext <<
"\n\t" << userpattern;
1991 for ( ; ditr != dirs.end(); ++ditr ) {
1992 std::string dalt = *ditr;
1994 size_t len = dalt.size();
1995 if ( len > 0 && dalt.rfind(
'/') != len-1 ) dalt.append(
"/");
1998 std::string filepatt = dalt + userpattern;
2000 glob(filepatt.c_str(),flags,NULL,&g);
2001 if ( g.gl_pathc > 0 ) flags |= GLOB_APPEND;
2006 std::ostringstream paretext;
2007 std::ostringstream flisttext;
2009 int nfiles = g.gl_pathc;
2011 if ( nfiles == 0 ) {
2012 paretext <<
"\n expansion resulted in a null list for flux files";
2014 }
else if ( ! randomizeFiles ) {
2018 paretext <<
"\n list of files will be processed in order";
2019 for (
int i=0; i<nfiles; ++i) {
2020 std::string afile(g.gl_pathv[i]);
2023 flisttext <<
"[" << setw(3) << i <<
"] " 2032 paretext <<
"list of " << nfiles
2033 <<
" will be randomized and pared down to " 2037 double* order =
new double[nfiles];
2038 int*
indices =
new int[nfiles];
2042 TMath::Sort((
int)nfiles,order,indices,
false);
2044 long long int sumBytes = 0;
2045 long long int maxBytes = (
long long int)
fMaxFluxFileMB * 1024ll * 1024ll;
2048 for (
int i=0; i < TMath::Min(nfiles,fMaxFluxFileNumber); ++i) {
2049 int indx = indices[i];
2050 std::string afile(g.gl_pathv[indx]);
2053 gSystem->GetPathInfo(afile.c_str(),fstat);
2054 sumBytes += fstat.fSize;
2057 if ( sumBytes > maxBytes && i != 0 ) keep =
false;
2059 flisttext <<
"[" << setw(3) << i <<
"] " 2060 <<
"=> g[" << setw(3) << indx <<
"] " 2061 << ((keep)?
"keep":
"skip") <<
" " 2062 << setw(6) << (sumBytes/(1024ll*1024ll)) <<
" " 2075 <<
"ExpandFluxFilePatternsDirect initially found " << nfiles
2076 <<
" files for user patterns:" 2077 << patterntext.str() <<
"\n using FluxSearchPaths of: " 2078 << dirstext.str() <<
"\n" << paretext.str();
2081 mf::LogDebug(
"GENIEHelper") <<
"\n" << flisttext.str();
2089 if ( nfiles == 0 ) {
2092 <<
"(e.g. \"dk2nu\', \"ntuple\" (\"numi\") or \"simple\") " 2093 <<
" specification must resolve to at least one file" 2094 <<
"\n none were found. DIRECT user pattern(s): " 2095 << patterntext.str()
2096 <<
"\n using FluxSearchPaths of: " 2100 <<
"no flux files found for: " << patterntext.str() <<
"\n" 2101 <<
" in: " << dirstext.str();
2125 std::ostringstream fmesg;
2126 std::string marker =
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
2128 << __FILE__ <<
":" << __LINE__
2129 <<
"\nno IFDH implemented on this platform\n" 2132 std::cout << fmesg.str() << std::flush;
2133 std::cerr << fmesg.str();
2134 throw cet::exception(
"Attempt to use ifdh class") << fmesg.str();
2140 bool randomizeFiles =
false;
2141 if (
fFluxType.find(
"tree_") == 0 ) randomizeFiles =
true;
2143 #ifdef USE_IFDH_SERVICE 2151 const char* ifdh_debug_env = std::getenv(
"IFDH_DEBUG_LEVEL");
2152 if ( ifdh_debug_env ) {
2153 mf::LogInfo(
"GENIEHelper") <<
"IFDH_DEBUG_LEVEL: " << ifdh_debug_env;
2154 fIFDH->set_debug(ifdh_debug_env);
2158 std::vector<std::pair<std::string,long>>
2159 partiallist, fulllist, selectedlist, locallist;
2161 std::ostringstream patterntext;
2162 std::ostringstream fulltext;
2163 std::ostringstream selectedtext;
2164 std::ostringstream localtext;
2165 fulltext <<
"search paths: " << spaths;
2174 std::string userpattern = *uitr;
2175 patterntext <<
"\npattern [" << std::setw(3) << ipatt <<
"] " << userpattern;
2176 fulltext <<
"\npattern [" << std::setw(3) << ipatt <<
"] " << userpattern;
2178 #ifdef USE_IFDH_SERVICE 2179 partiallist = ifdhp->findMatchingFiles(spaths,userpattern);
2181 partiallist =
fIFDH->findMatchingFiles(spaths,userpattern);
2183 fulllist.insert(fulllist.end(),partiallist.begin(),partiallist.end());
2186 fulltext <<
" found " << partiallist.size() <<
" files";
2187 for (
auto pitr = partiallist.begin(); pitr != partiallist.end(); ++pitr) {
2188 fulltext <<
"\n " << std::setw(10) << pitr->second <<
" " << pitr->first;
2191 partiallist.clear();
2194 size_t nfiles = fulllist.size();
2197 <<
"ExpandFluxFilePatternsIFDH initially found " << nfiles <<
" files";
2201 if ( nfiles == 0 ) {
2202 selectedtext <<
"\n expansion resulted in a null list for flux files";
2203 }
else if ( ! randomizeFiles ) {
2207 selectedtext <<
"\n list of files will be processed in order";
2208 selectedlist.insert(selectedlist.end(),fulllist.begin(),fulllist.end());
2217 selectedtext <<
"list of " << nfiles
2218 <<
" will be randomized and pared down to " 2222 double* order =
new double[nfiles];
2223 int*
indices =
new int[nfiles];
2227 TMath::Sort((
int)nfiles,order,indices,
false);
2229 long long int sumBytes = 0;
2230 long long int maxBytes = (
long long int)
fMaxFluxFileMB * 1024ll * 1024ll;
2232 for (
size_t i=0; i < TMath::Min(nfiles,
size_t(fMaxFluxFileNumber)); ++i) {
2233 int indx = indices[i];
2236 auto p = fulllist[indx];
2237 sumBytes += p.second;
2240 if ( sumBytes > maxBytes && i != 0 ) keep =
false;
2242 selectedtext <<
"\n[" << setw(3) << i <<
"] " 2243 <<
"=> [" << setw(3) << indx <<
"] " 2244 << ((keep)?
"keep":
"SKIP") <<
" " 2245 << std::setw(6) << (sumBytes/(1024ll*1024ll)) <<
" MB " 2248 if ( keep ) selectedlist.push_back(p);
2257 << selectedtext.str();
2261 #ifdef USE_IFDH_SERVICE 2267 localtext <<
"final list of files:";
2269 for (
auto litr = locallist.begin(); litr != locallist.end(); ++litr, ++i) {
2271 localtext <<
"\n\t[" << std::setw(3) << i <<
"]\t" << litr->first;
2280 if ( nfiles == 0 ) {
2283 <<
"(e.g. \"dk2nu\', \"ntuple\" (\"numi\") or \"simple\") " 2284 <<
"specification must resolve to at least one file" 2285 <<
"\n none were found. IFDH user pattern(s): " 2286 << patterntext.str()
2287 <<
"\n using FluxSearchPaths of: " 2291 <<
"no flux files found for: " << patterntext.str() <<
"\n" 2292 <<
" in " << spaths;
2296 #endif // 'else' code only if NO_IFDH_LIB not defined 2315 int indxGXMLPATH = -1;
2331 const char* gxmlpath_env = std::getenv(
"GXMLPATH");
2332 if ( gxmlpath_env ) {
2336 const char* fwpath_env = std::getenv(
"FW_SEARCH_PATH");
2343 if ( indxGXMLPATH < 0 ) {
2354 gSystem->Setenv(
"GXMLPATH",
fGXMLPATH.c_str());
2378 gSystem->Setenv(
"GMSGLAYOUT",
fGMSGLAYOUT.c_str());
2393 int indxGPRODMODE = -1;
2394 int indxGMSGCONF = -1;
2407 if ( indxGMSGCONF >= 0 ) {
2418 if ( indxGPRODMODE >= 0 ) {
2427 std::string newval =
"Messenger_whisper.xml";
2436 if ( indxGMSGCONF >= 0 ) {
2441 <<
"StartGENIEMessenger ProdMode=" << ((prodmode)?
"yes":
"no")
2462 const char* gspload_alt = std::getenv(
"GSPLOAD");
2463 if ( ! gspload_alt ) {
2464 const char* gspload_dflt =
"gxspl-FNALsmall.xml";
2465 gspload_alt = gspload_dflt;
2468 <<
"using env variable $GSPLOAD: " << gspload_alt
2469 <<
", use fcl parameter 'XSecTable' instead.";
2475 int indxGSPLOAD = -1;
2480 <<
"using Environment fcl parameter GSPLOAD: " 2482 <<
", use fcl parameter 'XSecTable' instead. " 2483 << __FILE__ <<
":" << __LINE__ <<
"\n";
2488 if ( indxGSPLOAD < 0 ) {
2507 cet::search_path spGXML(
"/:" +
fGXMLPATH );
2508 std::string fullpath;
2511 if ( fullpath ==
"" ) {
2513 <<
"could not resolve full path for spline file XSecTable/GSPLOAD " 2517 <<
"can't find XSecTable/GSPLOAD file: " <<
fXSecTable;
2523 <<
"XSecTable/GSPLOAD full path \"" <<
fXSecTable <<
"\"";
2529 unsetenv(
"GSPLOAD");
2530 genie::utils::app_init::XSecTable(
fXSecTable,
true);
2534 <<
"Time to read GENIE XSecTable: " 2535 <<
" Real " << xtime.RealTime() <<
" s," 2536 <<
" CPU " << xtime.CpuTime() <<
" s" 2544 if (v ==
"true")
return true;
2545 if (v ==
"false")
return false;
2546 if (v ==
"kTRUE")
return true;
2547 if (v ==
"kFALSE")
return false;
2548 if (v ==
"TRUE")
return true;
2549 if (v ==
"FALSE")
return false;
2550 if (v ==
"True")
return true;
2551 if (v ==
"False")
return false;
2552 if (v ==
"on")
return true;
2553 if (v ==
"off")
return false;
2554 if (v ==
"On")
return true;
2555 if (v ==
"Off")
return false;
2556 if (v ==
"ON")
return true;
2557 if (v ==
"OFF")
return false;
2558 if (v ==
"YES")
return true;
2559 if (v ==
"NO")
return false;
2560 if (v ==
"Yes")
return true;
2561 if (v ==
"No")
return false;
2562 if (v ==
"yes")
return true;
2563 if (v ==
"no")
return false;
2564 if (v ==
"1")
return true;
2565 if (v ==
"0")
return false;
double E(const int i=0) const
std::vector< std::string > fFluxFilePatterns
wildcard patterns files containing histograms or ntuples, or txt
static const int kNuTauBar
bool fUseHelperRndGen4GENIE
use fHelperRandom for gRandom during Sample()
const simb::MCNeutrino & GetNeutrino() const
std::string fDetLocation
name of flux window location
double fAtmoEmax
atmo: Maximum energy of neutrinos in GeV
int fMaxFluxFileNumber
maximum # of flux files
double fMixerBaseline
baseline distance if genie flux can't calculate it
std::string fTuneName
GENIE R-3 Tune name (defines model configuration)
void FillMCTruth(const genie::EventRecord *grec, double spillTime, simb::MCTruth &mctruth, const std::string &genieVersion="unknown", const std::string &genieTune="unknown", bool addGenieVtxTime=false, const std::unordered_map< std::string, std::string > genConfig={})
void SetUserCoordSystem(TRotation &rotation)
double fTotalHistFlux
total flux of neutrinos from flux histograms for used flavors
double fgen2vtx
distance from ray origin to event vtx
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
ifdh_ns::ifdh * fIFDH
(optional) flux file handling
void FillMCFlux(genie::GFluxI *fdriver, simb::MCFlux &mcflux)
std::string fGXMLPATH
locations for GENIE XML files
std::string fFiducialCut
configuration for geometry selector
const simb::MCParticle & Nu() const
double fgenx
origin of ray from flux generator
bool Sample(simb::MCTruth &truth, simb::MCFlux &flux, simb::GTruth >ruth)
simb::flux_code_ fFluxType
unsigned int GetRandomNumberSeed()
double fRandomTimeOffset
additional random time shift (ns) added to every particle time
TVector3 fBeamCenter
center of beam for histogram fluxes - must be in meters
double fGlobalTimeOffset
overall time shift (ns) added to every particle time
std::string fSpillTimeConfig
alternative to flat spill distribution
std::string fEventGeneratorList
control over event topologies, was $GEVGL [Default]
TGeoManager * fGeoManager
pointer to ROOT TGeoManager
constexpr auto abs(T v)
Returns the absolute value of the argument.
Functions for transforming GENIE objects into ART objects (and back)
std::string fGENIEMsgThresholds
additional XML file setting Messager level thresholds (":" separated)
A driver for a power spectrum atmospheric neutrino flux. Elements extensively reused from GAtmoFlux...
std::vector< int > fGenFlavors
pdg codes for flavors to generate
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
evgb::EvtTimeShiftI * fTimeShifter
generator for time offset within a spill
double fdk2gen
distance from decay to ray origin
genie::GMCJDriver * fDriver
double fXSecMassPOT
product of cross section, mass and POT/spill for histogram fluxes
void SetSpectralIndex(double index)
void ExpandFluxFilePatternsDirect()
void SqueezeFilePatterns()
std::vector< std::string > fSelectedFluxFiles
flux files selected after wildcard expansion and subset selection
object containing MC flux information
genie::EventRecord * fGenieEventRecord
last generated event
std::string fXSecTable
cross section file (was $GSPLOAD)
double fFluxUpstreamZ
z where flux starts from (if non-default, simple/ntuple only)
std::vector< TH1D * > fFluxHistograms
histograms for each nu species
Flux for positive horn focus.
void SetFlavors(std::vector< int > flavors)
void SetMaxEnergy(double Emax)
void AddFluxFile(int neutrino_pdg, string filename)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
void HistogramFluxCheck()
int fGHepPrintLevel
GHepRecord::SetPrintLevel(), -1=no-print.
std::string fFluxRotCfg
how to interpret fFluxRotValues
TVector3 fBeamDirection
direction of the beam for histogram fluxes
std::string fBeamName
name of the beam we are simulating
std::string fWorldVolume
name of the world volume in the ROOT geometry
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
bool fForceApplyFlxWgt
apply GFluxI::Weight() before returning event
void InitializeFluxDriver()
double fTotalExposure
pot used from flux ntuple
TRandom3 * fHelperRandom
random # generator for GENIEHelper
std::string fTopVolume
top volume in the ROOT geometry in which to generate events
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
bool fUseBlenderDist
get neutrino's travel distance from blender (default: true)
virtual void PrintConfig(bool verbose=true)=0
provide a means of printing the configuration
void RegularizeFluxType()
bool IsRandomGeneratorSeeded() const
static const int kNuMuBar
void SetMinEnergy(double Emin)
genie::GeomAnalyzerI * fGeomD
std::string fFluxSearchPaths
colon separated set of path stems
Wrapper for generating neutrino interactions with GENIE.
std::string fGMSGLAYOUT
format for GENIE log message [BASIC]|SIMPLE (SIMPLE=no timestamps)
void InitializeGeometry()
double fBeamRadius
radius of cylindar for histogram fluxes - must be in meters
TRandom * GetRandomGenerator() const
std::string fMixerConfig
configuration string for genie GFlavorMixerI
bool StringToBool(std::string v)
genie::GFluxI * fFluxD
real flux driver
void StartGENIEMessenger(std::string prodmode)
void SetFluxGen(double nue, double nuebar, double numu, double numubar, double nutau, double nutaubar)
bool fAddGenieVtxTime
incorporate time from flux window to interaction point and (possibily) proton-on-target to flux windo...
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
double fMonoEnergy
energy of monoenergetic neutrinos
double fDetectorMass
mass of the detector in kg
std::vector< double > fFluxRotValues
parameters for rotation
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
double fAtmoSpectralIndex
atmo: Spectral index for power spectrum generation
void InitializeFiducialSelection()
void SetEventGeneratorListAndTune(const std::string &evtlistname="", const std::string &tunename="${GENIE_XSEC_TUNE}")
std::vector< std::string > fEnvironment
environmental variables and settings used by genie
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
std::string fMaxPathOutInfo
output info if writing PathLengthList from GeomScan
double fSpillExposure
total exposure (i.e. pot) for this spill
A class for generating concrete EvtTimeShiftI derived classes based on the factory pattern...
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
double fAtmoEmin
atmo: Minimum energy of neutrinos in GeV
static EvtTimeShiftFactory & Instance()
std::string fGeoFile
name of file containing the Geometry description
void InitializeRockBoxSelection()
double fAtmoRl
atmo: radius of the sphere on where the neutrinos are generated
void SetRadii(double Rlongitudinal, double Rtransverse)
void ExpandFluxFilePatternsIFDH()
unsigned int fDebugFlags
set bits to enable debug info
virtual double TimeOffset()=0
Physics generators for neutrinos, cosmic rays, and others.
std::string fFluxCopyMethod
"DIRECT" = old direct access method, otherwise = ifdh approach schema ("" okay)
void FillGTruth(const genie::EventRecord *grec, simb::GTruth >ruth)
std::string fFluxCleanup
"ALWAYS", "/var/tmp", "NEVER"
Event generator information.
double fHistEventsPerSpill
number of events per spill for histogram fluxes - changes each spill
TRotation * fFluxRotation
rotation for atmos / astro flux coord systems
std::string fGeomScan
configuration for geometry scan to determine max pathlengths
int fSpillEvents
total events for this spill
genie::GFluxI * fFluxD2GMCJD
flux driver passed to genie GMCJDriver, might be GFluxBlender
centimeter_as<> centimeter
Type of space stored in centimeters, in double precision.
std::string fFunctionalFlux
int fMaxFluxFileMB
maximum size of flux files (MB)
double fPOTPerSpill
number of pot per spill
cet::coded_exception< error, detail::translate > exception
GENIEHelper(fhicl::ParameterSet const &pset, TGeoManager *rootGeom, std::string const &rootFile, double const &detectorMass)
evgb::EvtTimeShiftI * GetEvtTimeShift(const std::string &name, const std::string &config="") const