9 #ifndef EVGEN_GENIEGEN_H 10 #define EVGEN_GENIEGEN_H 25 #include "TDatabasePDG.h" 27 #include "TStopwatch.h" 169 produces< std::vector<simb::MCTruth> >();
170 produces< std::vector<simb::MCFlux> >();
171 produces< std::vector<simb::GTruth> >();
172 produces< sumdata::RunData, art::InRun >();
173 produces< sumdata::POTSummary, art::InSubRun >();
174 produces< art::Assns<simb::MCTruth, simb::MCFlux> >();
175 produces< art::Assns<simb::MCTruth, simb::GTruth> >();
176 produces< std::vector<sim::BeamGateInfo> >();
178 std::string beam_type_name = pset.
get<std::string>(
"BeamName");
180 if(beam_type_name ==
"numi")
184 else if(beam_type_name ==
"booster")
194 signed int temp_seed;
207 GENIEconfig.
put(
"RandomSeed", seed);
213 geo->
TotalMass(pset.
get< std::string>(
"TopVolume").c_str()));
235 fGenerated[0] = tfs->
make<TH1F>(
"fGenerated_necc",
"", 100, 0.0, 20.0);
236 fGenerated[1] = tfs->
make<TH1F>(
"fGenerated_nebcc",
"", 100, 0.0, 20.0);
237 fGenerated[2] = tfs->
make<TH1F>(
"fGenerated_nmcc",
"", 100, 0.0, 20.0);
238 fGenerated[3] = tfs->
make<TH1F>(
"fGenerated_nmbcc",
"", 100, 0.0, 20.0);
239 fGenerated[4] = tfs->
make<TH1F>(
"fGenerated_nnc",
"", 100, 0.0, 20.0);
240 fGenerated[5] = tfs->
make<TH1F>(
"fGenerated_nbnc",
"", 100, 0.0, 20.0);
242 fDCosX = tfs->
make<TH1F>(
"fDCosX",
";dx/ds", 200, -1., 1.);
243 fDCosY = tfs->
make<TH1F>(
"fDCosY",
";dy/ds", 200, -1., 1.);
244 fDCosZ = tfs->
make<TH1F>(
"fDCosZ",
";dz/ds", 200, -1., 1.);
246 fMuMomentum = tfs->
make<TH1F>(
"fMuMomentum",
";p_{#mu} (GeV/c)", 500, 0., 50.);
247 fMuDCosX = tfs->
make<TH1F>(
"fMuDCosX",
";dx/ds;", 200, -1., 1.);
248 fMuDCosY = tfs->
make<TH1F>(
"fMuDCosY",
";dy/ds;", 200, -1., 1.);
249 fMuDCosZ = tfs->
make<TH1F>(
"fMuDCosZ",
";dz/ds;", 200, -1., 1.);
251 fEMomentum = tfs->
make<TH1F>(
"fEMomentum",
";p_{e} (GeV/c)", 500, 0., 50.);
252 fEDCosX = tfs->
make<TH1F>(
"fEDCosX",
";dx/ds;", 200, -1., 1.);
253 fEDCosY = tfs->
make<TH1F>(
"fEDCosY",
";dy/ds;", 200, -1., 1.);
254 fEDCosZ = tfs->
make<TH1F>(
"fEDCosZ",
";dz/ds;", 200, -1., 1.);
256 fCCMode = tfs->
make<TH1F>(
"fCCMode",
";CC Interaction Mode;", 4, 0., 4.);
257 fCCMode->GetXaxis()->SetBinLabel(1,
"QE");
258 fCCMode->GetXaxis()->SetBinLabel(2,
"Res");
259 fCCMode->GetXaxis()->SetBinLabel(3,
"DIS");
260 fCCMode->GetXaxis()->SetBinLabel(4,
"Coh");
261 fCCMode->GetXaxis()->CenterLabels();
263 fNCMode = tfs->
make<TH1F>(
"fNCMode",
";NC Interaction Mode;", 4, 0., 4.);
264 fNCMode->GetXaxis()->SetBinLabel(1,
"QE");
265 fNCMode->GetXaxis()->SetBinLabel(2,
"Res");
266 fNCMode->GetXaxis()->SetBinLabel(3,
"DIS");
267 fNCMode->GetXaxis()->SetBinLabel(4,
"Coh");
268 fNCMode->GetXaxis()->CenterLabels();
270 fDeltaE = tfs->
make<TH1F>(
"fDeltaE",
";#Delta E_{#nu} (GeV);", 200, -1., 1.);
271 fECons = tfs->
make<TH1F>(
"fECons",
";#Delta E(#nu,lepton);", 500, -5., 5.);
277 int xdiv = TMath::Nint(2*x/5.);
278 int ydiv = TMath::Nint(2*y/5.);
279 int zdiv = TMath::Nint(2*z/5.);
283 fVertexX = tfs->
make<TH1F>(
"fVertexX",
";x (cm)", xdiv, -0.1*
x,
x);
285 fVertexZ = tfs->
make<TH1F>(
"fVertexZ",
";z (cm)", zdiv, -0.1*
z,
z);
287 fVertexXY = tfs->
make<TH2F>(
"fVertexXY",
";x (cm);y (cm)", xdiv, -0.1*
x,
x, ydiv, -
y,
y);
288 fVertexXZ = tfs->
make<TH2F>(
"fVertexXZ",
";z (cm);x (cm)", zdiv, -0.2*
z,
z, xdiv, -0.1*
x,
x);
289 fVertexYZ = tfs->
make<TH2F>(
"fVertexYZ",
";z (cm);y (cm)", zdiv, -0.2*
z,
z, ydiv, -
y,
y);
294 fVertexY = tfs->
make<TH1F>(
"fVertexY",
";y (cm)", ydiv, fVtxPosHistRange[2], fVtxPosHistRange[3]);
295 fVertexZ = tfs->
make<TH1F>(
"fVertexZ",
";z (cm)", zdiv, fVtxPosHistRange[4], fVtxPosHistRange[5]);
297 fVertexXY = tfs->
make<TH2F>(
"fVertexXY",
";x (cm);y (cm)", xdiv, fVtxPosHistRange[0], fVtxPosHistRange[1], ydiv, fVtxPosHistRange[2], fVtxPosHistRange[3]);
298 fVertexXZ = tfs->
make<TH2F>(
"fVertexXZ",
";z (cm);x (cm)", zdiv, fVtxPosHistRange[4], fVtxPosHistRange[5], xdiv, fVtxPosHistRange[0], fVtxPosHistRange[1]);
299 fVertexYZ = tfs->
make<TH2F>(
"fVertexYZ",
";z (cm);y (cm)", zdiv, fVtxPosHistRange[4], fVtxPosHistRange[5], ydiv, fVtxPosHistRange[2], fVtxPosHistRange[3]);
312 run.
put(std::move(runcol));
336 sr.
put(std::move(p));
344 std::unique_ptr< std::vector<simb::MCTruth> > truthcol (
new std::vector<simb::MCTruth>);
345 std::unique_ptr< std::vector<simb::MCFlux> > fluxcol (
new std::vector<simb::MCFlux >);
346 std::unique_ptr< std::vector<simb::GTruth> > gtruthcol (
new std::vector<simb::GTruth >);
349 std::unique_ptr< std::vector<sim::BeamGateInfo> > gateCollection(
new std::vector<sim::BeamGateInfo>);
351 while(truthcol->size() < 1){
364 truthcol ->push_back(truth);
365 fluxcol ->push_back(flux);
366 gtruthcol->push_back(gTruth);
367 util::CreateAssn(*
this, evt, *truthcol, *fluxcol, *tfassn, fluxcol->size()-1, fluxcol->size());
368 util::CreateAssn(*
this, evt, *truthcol, *gtruthcol, *tgtassn, gtruthcol->size()-1, gtruthcol->size());
377 log <<
"Found an interaction that is not represented by the interaction type code in GENIE:" 383 "\nGENIE truth record:" 395 LOG_DEBUG(
"GENIEGen") <<
"no events made for this spill but " 396 <<
"passing it on and ending the event anyway";
409 evt.
put(std::move(truthcol));
410 evt.
put(std::move(fluxcol));
411 evt.
put(std::move(gtruthcol));
412 evt.
put(std::move(tfassn));
413 evt.
put(std::move(tgtassn));
414 evt.
put(std::move(gateCollection));
422 int code = StatusCode;
428 ParticleStatusName =
"kIStUndefined";
431 ParticleStatusName =
"kIStInitialState";
434 ParticleStatusName =
"kIStStableFinalState";
437 ParticleStatusName =
"kIStIntermediateState";
440 ParticleStatusName =
"kIStDecayedState";
443 ParticleStatusName =
"kIStNucleonTarget";
446 ParticleStatusName =
"kIStDISPreFragmHadronicState";
449 ParticleStatusName =
"kIStPreDecayResonantState";
452 ParticleStatusName =
"kIStHadronInTheNucleus";
455 ParticleStatusName =
"kIStFinalStateNuclearRemnant";
458 ParticleStatusName =
"kIStNucleonClusterTarget";
461 ParticleStatusName =
"Status Unknown";
469 std::string ReactionChannelName=
" ";
472 ReactionChannelName =
"kCC";
474 ReactionChannelName =
"kNC";
475 else std::cout<<
"Current mode unknown!! "<<std::endl;
478 ReactionChannelName +=
"_kQE";
480 ReactionChannelName +=
"_kRes";
482 ReactionChannelName +=
"_kDIS";
484 ReactionChannelName +=
"_kCoh";
485 else std::cout<<
"interaction mode unknown!! "<<std::endl;
487 return ReactionChannelName;
527 if(std::abs(mom) > 0.){
538 <<
"-----------> Particles in the Stack = " << mc.
NParticles() << std::endl
540 << std::setw(20) <<
"PARTICLE" 542 << std::setw(32) <<
"STATUS" 543 << std::setw(18) <<
"E (GeV)" 544 << std::setw(18) <<
"m (GeV/c2)" 545 << std::setw(18) <<
"Ek (GeV)" 546 << std::endl << std::endl;
548 const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
553 std::string name = databasePDG->GetParticle(
part.PdgCode())->GetName();
554 int code =
part.StatusCode();
556 double mass =
part.Mass();
558 double Ek = (energy-mass);
559 if(status==
"kIStStableFinalState"||status==
"kIStHadronInTheNucleus")
563 << std::setw(18)<< energy
564 << std::setw(18)<< mass
565 << std::setw(18)<< Ek <<std::endl;
570 << std::setw(18) << energy
571 << std::setw(18) << mass <<std::endl;
581 if(abs(
part.PdgCode()) == 11){
589 else if(abs(
part.PdgCode()) == 13){
TH1F * fVertexX
vertex location of generated events in x
std::string ParticleStatus(int StatusCode)
double E(const int i=0) const
TH1F * fMuDCosZ
direction cosine of outgoing mu in z
TH2F * fVertexXZ
vertex location in xz
const simb::MCNeutrino & GetNeutrino() const
double Py(const int i=0) const
geo::Length_t DetHalfWidth(geo::TPCID const &tpcid) const
Returns the half width of the active volume of the specified TPC.
void DumpGTruth(Stream &&out, simb::GTruth const &truth, std::string indent, std::string firstIndent)
Dumps the content of the GENIE truth in the output stream.
TH1F * fDeltaE
difference in neutrino energy from MCTruth::Enu() vs TParticle
TH2F * fVertexXY
vertex location in xy
void beginSubRun(art::SubRun &sr)
std::string ReactionChannel(int ccnc, int mode)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void beginRun(art::Run &run)
TH1F * fMuDCosY
direction cosine of outgoing mu in y
const simb::MCParticle & Nu() const
bool Sample(simb::MCTruth &truth, simb::MCFlux &flux, simb::GTruth >ruth)
double Px(const int i=0) const
offset to account for adding in Nuance codes to this enum
void endSubRun(art::SubRun &sr)
art::ProductID put(std::unique_ptr< PROD > &&)
TGeoManager * ROOTGeoManager() const
Access to the ROOT geometry description manager.
TH1F * fNCMode
CC interaction mode.
object containing MC flux information
std::string ROOTFile() const
Returns the full directory path to the geometry file source.
::sim::BeamType_t fBeamType
The width of a simulated "beam gate".
double TotalMass() const
Returns the total mass [kg] of the specified volume (default: world).
ProductID put(std::unique_ptr< PROD > &&product)
TH1F * fDCosZ
direction cosine in z
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
int InteractionType() const
void produce(art::Event &evt)
geo::Length_t DetHalfHeight(geo::TPCID const &tpcid) const
Returns the half height of the active volume of the specified TPC.
TH1F * fEDCosY
direction cosine of outgoing e in y
Utility functions to print MC truth information.
#define DEFINE_ART_MODULE(klass)
GENIEGen(fhicl::ParameterSet const &pset)
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
int fPassEmptySpills
whether or not to kill evnets with no interactions
TH1F * fCCMode
CC interaction mode.
double fPrevTotGoodPOT
Total good POT from subruns previous to current subrun.
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
double P(const int i=0) const
T get(std::string const &key) const
double fGlobalTimeOffset
keep track of how long it takes to run the job
TH1F * fEDCosX
direction cosine of outgoing e in x
bool fDefinedVtxHistRange
TH1F * fMuDCosX
direction cosine of outgoing mu in x
void DumpMCTruth(Stream &&out, simb::MCTruth const &truth, unsigned int pointsPerLine, std::string indent, std::string firstIndent)
Dumps the content of the specified MC truth in the output stream.
TH1F * fGenerated[6]
Spectra as generated.
geo::Length_t DetLength(geo::TPCID const &tpcid) const
Returns the length of the active volume of the specified TPC.
bool get_if_present(std::string const &key, T &value) const
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
Wrapper for generating neutrino interactions with GENIE.
double fPrevTotPOT
The type of beam.
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
TH1F * fDCosY
direction cosine in y
const simb::MCParticle & GetParticle(int i) const
double Vx(const int i=0) const
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
TH1F * fEMomentum
momentum of outgoing electrons
T * make(ARGS...args) const
TH2F * fVertexYZ
vertex location in yz
Utility object to perform functions of association.
double TotalExposure() const
TH1F * fECons
histogram to determine if energy is conserved in the event
ProductID put(std::unique_ptr< PROD > &&)
double Pz(const int i=0) const
double Vz(const int i=0) const
TH1F * fEDCosZ
direction cosine of outgoing e in z
TH1F * fDCosX
direction cosine in x
Event generator information.
Event generator information.
Namespace collecting geometry-related classes utilities.
TH1F * fMuMomentum
momentum of outgoing muons
Event Generation using GENIE, cosmics or single particles.
std::string ParticleStatusName(int code)
Describes the status of a particle (simb::MCParticle::StatusCode()).
TH1F * fVertexY
vertex location of generated events in y
BeamType_t
Defines category of beams to be stored in sim::BeamGateInfo.
void FillHistograms(simb::MCTruth mc)
std::vector< double > fVtxPosHistRange
use defined hist range; it is useful to have for asymmetric ranges like in DP FD. ...
TH1F * fVertexZ
vertex location of generated events in z
double Vy(const int i=0) const
void put(std::string const &key)
art framework interface to geometry description
A module to check the results from the Monte Carlo generator.
double fRandomTimeOffset
The start of a simulated "beam gate".