23 #include "cetlib_except/exception.h" 34 #include "nutools/EventGeneratorBase/GENIE/GENIEHelper.h" 36 #include "TStopwatch.h" 37 #include "TGeoManager.h" 40 namespace simb {
class MCParticle; }
60 void GENIEHistogramFluxTest();
61 void GENIESimpleFluxTest();
62 void GENIEMonoFluxTest();
63 void GENIEAtmoFluxTest();
64 void GENIENtupleFluxTest();
69 void ProjectToSurface(TLorentzVector
pos,
95 , fTotalGENIEPOT ( pset.
get< double >(
"TotalGENIEPOT", 5e18))
96 , fTotalGENIEInteractions( pset.
get< double >(
"TotalGENIEInteractions", 100) )
97 , fTotalCRYSpills ( pset.
get< double >(
"TotalCRYSpills", 1000))
99 , fGeometryFile ( pset.
get<
std::
string >(
"GeometryFile" ))
100 , fCryDetLength (1000.)
101 , fCryDetWidth (500.)
102 , fCryDetHeight (500.)
113 <<
"\t simple flux...";
116 <<
"\t atmo flux...";
119 <<
"\t mono flux...";
122 <<
"GENIE tests done";
135 std::vector<double> beamCenter;
136 beamCenter.push_back(0.0); beamCenter.push_back(0.); beamCenter.push_back(0.0);
138 std::vector<double> beamDir;
139 beamDir.push_back(0.); beamDir.push_back(0.); beamDir.push_back(1.);
141 std::vector<int> flavors;
142 if(fluxType.compare(
"atmo_FLUKA") == 0){
143 flavors.push_back(14);
146 flavors.push_back(12); flavors.push_back(14); flavors.push_back(-12); flavors.push_back(-14);
150 std::vector<std::string> env;
151 env.push_back(
"GPRODMODE"); env.push_back(
"YES");
152 env.push_back(
"GEVGL"); env.push_back(
"Default");
154 double potPerSpill = 5.e13;
155 double eventsPerSpill = 0;
156 if(!usePOTPerSpill) eventsPerSpill = 1;
158 std::vector<std::string> fluxFiles;
159 fluxFiles.push_back(
"samples_for_geniehelper/L010z185i_lowthr_ipndshed.root");
160 if(fluxType.compare(
"simple_flux") == 0){
162 fluxFiles.push_back(
"samples_for_geniehelper/gsimple_NOvA-NDOS_le010z185i_20100521_RHC_lowth_s_00001.root");
164 else if(fluxType.compare(
"atmo_FLUKA") == 0){
167 fluxFiles.push_back(
"atmospheric/battistoni/sdave_numu07.dat");
170 else if(fluxType.compare(
"ntuple") == 0){
171 throw cet::exception(
"EventGeneratorTest") <<
"No ntuple flux file " 172 <<
"exists, bail ungracefully";
176 pset.
put(
"FluxType", fluxType);
177 pset.
put(
"FluxFiles", fluxFiles);
178 pset.
put(
"BeamName",
"numi");
180 pset.
put(
"EventsPerSpill", eventsPerSpill);
181 pset.
put(
"POTPerSpill", potPerSpill);
182 pset.
put(
"BeamCenter", beamCenter);
183 pset.
put(
"BeamDirection", beamDir);
184 pset.
put(
"GenFlavors", flavors);
185 pset.
put(
"Environment", env);
186 pset.
put(
"DetectorLocation",
"NOvA-ND");
200 throw cet::exception(
"EventGeneratorTest") <<
"cannot find geometry file:\n " 202 <<
"\n to test GENIE";
210 gGeoManager->FindVolumeFast(pset.
get<
std::string>(
"TopVolume").c_str())->Weight());
213 int interactionCount = 0;
219 double eps = pset.
get<
double>(
"EventsPerSpill");
221 else spillLimit = 1000;
223 while(nspill < spillLimit){
225 while( !
help.Stop() ){
231 if(
help.Sample(truth, flux, gTruth) )
239 mf::LogWarning(
"EventGeneratorTest") <<
"made " << interactionCount <<
" interactions with " 240 <<
help.TotalExposure() <<
" POTs";
243 double totalExp = 0.;
244 if(
help.FluxType().compare(
"histogram") == 0 && pset.
get<
double>(
"EventsPerSpill") == 0){
245 std::vector<TH1D*> fluxhist =
help.FluxHistograms();
247 if(fluxhist.size() < 1){
248 throw cet::exception(
"EventGeneratorTest") <<
"using histogram fluxes but no histograms provided!";
252 totalExp = 1.e-38*1.e-20*
help.TotalHistFlux();
253 totalExp *=
help.TotalExposure()*
help.TotalMass()/(1.67262158e-27);
255 mf::LogWarning(
"EventGeneratorTest") <<
"expected " << totalExp <<
" interactions";
256 if(
std::abs(interactionCount - totalExp) > 3.*std::sqrt(totalExp) ){
257 throw cet::exception(
"EventGeneratorTest") <<
"generated count is more than " 258 <<
"3 sigma off expectation";
272 mf::LogWarning(
"EventGeneratorTest") <<
"\t\t\t 1 event per spill...\n";
279 mf::LogWarning(
"EventGeneratorTest") <<
"\t\t\t events based on POT per spill...\n";
292 mf::LogWarning(
"EventGeneratorTest") <<
"testing GENIEHelper in simple_flux mode with \n" 293 <<
"\t 1 event per spill...\n";
298 mf::LogWarning(
"EventGeneratorTest") <<
"\t events based on POT per spill...\n";
313 mf::LogWarning(
"EventGeneratorTest") <<
"\t\t 1 event per spill...\n";
328 mf::LogWarning(
"EventGeneratorTest") <<
"\t\t 1 event per spill...\n";
343 pset.
put(
"SampleTime", 600
e-6 );
344 pset.
put(
"TimeOffset", -30
e-6 );
345 pset.
put(
"EnergyThreshold", 50
e-3 );
346 pset.
put(
"Latitude",
"latitude 41.8 " );
347 pset.
put(
"Altitude",
"altitude 0 " );
348 pset.
put(
"SubBoxLength",
"subboxLength 75 ");
365 double avPartPerSpill = 0.;
366 double avPartIntersectPerSpill = 0.;
367 double avMuonIntersectPerSpill = 0.;
368 double avEIntersectPerSpill = 0.;
384 avPartIntersectPerSpill += 1.;
386 avMuonIntersectPerSpill += 1.;
388 avEIntersectPerSpill += 1.;
397 mf::LogWarning(
"EventGeneratorTest") <<
"there are " << avPartPerSpill/(1.*nspill)
398 <<
" cosmic rays made per spill \n" 399 << avPartIntersectPerSpill/(1.*nspill)
400 <<
" intersect the detector per spill" 402 << avMuonIntersectPerSpill/(1.*nspill)
404 << avEIntersectPerSpill/(1.*nspill)
417 TLorentzVector mom = part.
Momentum();
419 if(TMath::Abs(mom.P()) == 0){
420 mf::LogWarning(
"EventGeneratorTest") <<
"particle has no momentum!!! bail";
424 double xyz[3] = {0.};
487 double ddS = (momDir/mom.P());
488 double length1Dim = (posDir - surfaceLoc);
490 if(TMath::Abs(ddS) > 0.){
492 xyz[0] = pos.X() + length1Dim*mom.Px()/mom.P();
493 xyz[1] = pos.Y() + length1Dim*mom.Py()/mom.P();
494 xyz[2] = pos.Z() + length1Dim*mom.Pz()/mom.P();
508 #endif // EVGEN_TEST_H def analyze(root, level, gtrees, gbranches, doprint)
base_engine_t & createEngine(seed_t seed)
Interface to the CRY cosmic-ray generator.
const TLorentzVector & Position(const int i=0) const
std::string fGeometryFile
location of Geometry GDML file to test
void analyze(art::Event const &evt)
fhicl::ParameterSet GENIEParameterSet(std::string fluxType, bool usePOTPerSpill)
void GENIESimpleFluxTest()
unsigned int GetRandomNumberSeed()
void GENIETest(fhicl::ParameterSet const &pset)
CLHEP::HepRandomEngine & fEngine
art-owned engine used in generation random numbers
fhicl::ParameterSet CRYParameterSet()
A module to check the results from the Monte Carlo generator.
double fCryDetLength
length of detector to test CRY, units of cm
object containing MC flux information
double fTotalCRYSpills
number of spills to use when testing CRY
double Sample(simb::MCTruth &mctruth, double const &surfaceY, double const &detectorLength, double *w, double rantime=0)
#define DEFINE_ART_MODULE(klass)
Interface to the CRY cosmic ray generator.
T get(std::string const &key) const
std::string fTopVolume
Top Volume used by GENIE.
double fCryDetHeight
height of detector to test CRY, units of cm
Base utilities and modules for event generation and detector simulation.
double fTotalGENIEInteractions
const simb::MCParticle & GetParticle(int i) const
const TLorentzVector & Momentum(const int i=0) const
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::string find_file(std::string const &filename) const
bool IntersectsDetector(simb::MCParticle const &part)
void ProjectToSurface(TLorentzVector pos, TLorentzVector mom, int axis, double surfaceLoc, double *xyz)
Event generator information.
auto const & get(AssnsNode< L, R, D > const &r)
double fCryDetWidth
width of detector to test CRY, units of cm
Event Generation using GENIE, cosmics or single particles.
void put(std::string const &key)
cet::coded_exception< error, detail::translate > exception
std::string to_string() const
void GENIEHistogramFluxTest()