19 #include "TDatabasePDG.h" 20 #include "TStopwatch.h" 28 #include "art_root_io/TFileService.h" 35 #include "nurandom/RandomUtils/NuRandomService.h" 46 #include "nugen/EventGeneratorBase/GENIE/GENIEHelper.h" 161 produces< std::vector<simb::MCTruth> >();
162 produces< std::vector<simb::MCFlux> >();
163 produces< std::vector<simb::GTruth> >();
164 produces< sumdata::RunData, art::InRun >();
165 produces< sumdata::POTSummary, art::InSubRun >();
166 produces< art::Assns<simb::MCTruth, simb::MCFlux> >();
167 produces< art::Assns<simb::MCTruth, simb::GTruth> >();
168 produces< std::vector<sim::BeamGateInfo> >();
172 if(beam_type_name ==
"numi")
176 else if(beam_type_name ==
"booster")
186 signed int temp_seed;
199 GENIEconfig.
put(
"RandomSeed", seed);
202 fGENIEHelp =
new evgb::GENIEHelper(GENIEconfig,
227 fGenerated[0] = tfs->make<TH1F>(
"fGenerated_necc",
"", 100, 0.0, 20.0);
228 fGenerated[1] = tfs->make<TH1F>(
"fGenerated_nebcc",
"", 100, 0.0, 20.0);
229 fGenerated[2] = tfs->make<TH1F>(
"fGenerated_nmcc",
"", 100, 0.0, 20.0);
230 fGenerated[3] = tfs->make<TH1F>(
"fGenerated_nmbcc",
"", 100, 0.0, 20.0);
231 fGenerated[4] = tfs->make<TH1F>(
"fGenerated_nnc",
"", 100, 0.0, 20.0);
232 fGenerated[5] = tfs->make<TH1F>(
"fGenerated_nbnc",
"", 100, 0.0, 20.0);
234 fDCosX = tfs->make<TH1F>(
"fDCosX",
";dx/ds", 200, -1., 1.);
235 fDCosY = tfs->make<TH1F>(
"fDCosY",
";dy/ds", 200, -1., 1.);
236 fDCosZ = tfs->make<TH1F>(
"fDCosZ",
";dz/ds", 200, -1., 1.);
238 fMuMomentum = tfs->make<TH1F>(
"fMuMomentum",
";p_{#mu} (GeV/c)", 500, 0., 50.);
239 fMuDCosX = tfs->make<TH1F>(
"fMuDCosX",
";dx/ds;", 200, -1., 1.);
240 fMuDCosY = tfs->make<TH1F>(
"fMuDCosY",
";dy/ds;", 200, -1., 1.);
241 fMuDCosZ = tfs->make<TH1F>(
"fMuDCosZ",
";dz/ds;", 200, -1., 1.);
243 fEMomentum = tfs->make<TH1F>(
"fEMomentum",
";p_{e} (GeV/c)", 500, 0., 50.);
244 fEDCosX = tfs->make<TH1F>(
"fEDCosX",
";dx/ds;", 200, -1., 1.);
245 fEDCosY = tfs->make<TH1F>(
"fEDCosY",
";dy/ds;", 200, -1., 1.);
246 fEDCosZ = tfs->make<TH1F>(
"fEDCosZ",
";dz/ds;", 200, -1., 1.);
248 fCCMode = tfs->make<TH1F>(
"fCCMode",
";CC Interaction Mode;", 4, 0., 4.);
249 fCCMode->GetXaxis()->SetBinLabel(1,
"QE");
250 fCCMode->GetXaxis()->SetBinLabel(2,
"Res");
251 fCCMode->GetXaxis()->SetBinLabel(3,
"DIS");
252 fCCMode->GetXaxis()->SetBinLabel(4,
"Coh");
253 fCCMode->GetXaxis()->CenterLabels();
255 fNCMode = tfs->make<TH1F>(
"fNCMode",
";NC Interaction Mode;", 4, 0., 4.);
256 fNCMode->GetXaxis()->SetBinLabel(1,
"QE");
257 fNCMode->GetXaxis()->SetBinLabel(2,
"Res");
258 fNCMode->GetXaxis()->SetBinLabel(3,
"DIS");
259 fNCMode->GetXaxis()->SetBinLabel(4,
"Coh");
260 fNCMode->GetXaxis()->CenterLabels();
262 fDeltaE = tfs->make<TH1F>(
"fDeltaE",
";#Delta E_{#nu} (GeV);", 200, -1., 1.);
263 fECons = tfs->make<TH1F>(
"fECons",
";#Delta E(#nu,lepton);", 500, -5., 5.);
269 int xdiv = TMath::Nint(2*x/5.);
270 int ydiv = TMath::Nint(2*y/5.);
271 int zdiv = TMath::Nint(2*z/5.);
275 fVertexX = tfs->make<TH1F>(
"fVertexX",
";x (cm)", xdiv, -0.1*
x,
x);
276 fVertexY = tfs->make<TH1F>(
"fVertexY",
";y (cm)", ydiv, -
y,
y);
277 fVertexZ = tfs->make<TH1F>(
"fVertexZ",
";z (cm)", zdiv, -0.1*
z,
z);
279 fVertexXY = tfs->make<TH2F>(
"fVertexXY",
";x (cm);y (cm)", xdiv, -0.1*
x,
x, ydiv, -
y,
y);
280 fVertexXZ = tfs->make<TH2F>(
"fVertexXZ",
";z (cm);x (cm)", zdiv, -0.2*
z,
z, xdiv, -0.1*
x,
x);
281 fVertexYZ = tfs->make<TH2F>(
"fVertexYZ",
";z (cm);y (cm)", zdiv, -0.2*
z,
z, ydiv, -
y,
y);
286 fVertexY = tfs->make<TH1F>(
"fVertexY",
";y (cm)", ydiv, fVtxPosHistRange[2], fVtxPosHistRange[3]);
287 fVertexZ = tfs->make<TH1F>(
"fVertexZ",
";z (cm)", zdiv, fVtxPosHistRange[4], fVtxPosHistRange[5]);
289 fVertexXY = tfs->make<TH2F>(
"fVertexXY",
";x (cm);y (cm)", xdiv, fVtxPosHistRange[0], fVtxPosHistRange[1], ydiv, fVtxPosHistRange[2], fVtxPosHistRange[3]);
290 fVertexXZ = tfs->make<TH2F>(
"fVertexXZ",
";z (cm);x (cm)", zdiv, fVtxPosHistRange[4], fVtxPosHistRange[5], xdiv, fVtxPosHistRange[0], fVtxPosHistRange[1]);
291 fVertexYZ = tfs->make<TH2F>(
"fVertexYZ",
";z (cm);y (cm)", zdiv, fVtxPosHistRange[4], fVtxPosHistRange[5], ydiv, fVtxPosHistRange[2], fVtxPosHistRange[3]);
317 auto p = std::make_unique<sumdata::POTSummary>();
330 std::unique_ptr< std::vector<simb::MCTruth> > truthcol (
new std::vector<simb::MCTruth>);
331 std::unique_ptr< std::vector<simb::MCFlux> > fluxcol (
new std::vector<simb::MCFlux >);
332 std::unique_ptr< std::vector<simb::GTruth> > gtruthcol (
new std::vector<simb::GTruth >);
335 std::unique_ptr< std::vector<sim::BeamGateInfo> > gateCollection(
new std::vector<sim::BeamGateInfo>);
337 while(truthcol->size() < 1){
350 truthcol ->push_back(truth);
351 fluxcol ->push_back(flux);
352 gtruthcol->push_back(gTruth);
364 log <<
"Found an interaction that is not represented by the interaction type code in GENIE:" 370 "\nGENIE truth record:" 382 MF_LOG_DEBUG(
"GENIEGen") <<
"no events made for this spill but " 383 <<
"passing it on and ending the event anyway";
409 int code = StatusCode;
415 ParticleStatusName =
"kIStUndefined";
418 ParticleStatusName =
"kIStInitialState";
421 ParticleStatusName =
"kIStStableFinalState";
424 ParticleStatusName =
"kIStIntermediateState";
427 ParticleStatusName =
"kIStDecayedState";
430 ParticleStatusName =
"kIStNucleonTarget";
433 ParticleStatusName =
"kIStDISPreFragmHadronicState";
436 ParticleStatusName =
"kIStPreDecayResonantState";
439 ParticleStatusName =
"kIStHadronInTheNucleus";
442 ParticleStatusName =
"kIStFinalStateNuclearRemnant";
445 ParticleStatusName =
"kIStNucleonClusterTarget";
448 ParticleStatusName =
"Status Unknown";
459 ReactionChannelName =
"kCC";
461 ReactionChannelName =
"kNC";
462 else std::cout<<
"Current mode unknown!! "<<
std::endl;
465 ReactionChannelName +=
"_kQE";
467 ReactionChannelName +=
"_kRes";
469 ReactionChannelName +=
"_kDIS";
471 ReactionChannelName +=
"_kCoh";
472 else std::cout<<
"interaction mode unknown!! "<<
std::endl;
474 return ReactionChannelName;
535 const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
540 std::string name = databasePDG->GetParticle(part.PdgCode())->GetName();
541 int code = part.StatusCode();
543 double mass = part.Mass();
545 double Ek = (energy-mass);
546 if(status==
"kIStStableFinalState"||status==
"kIStHadronInTheNucleus")
568 if(
abs(part.PdgCode()) == 11){
570 fEDCosX->Fill(part.Px()/part.P());
571 fEDCosY->Fill(part.Py()/part.P());
572 fEDCosZ->Fill(part.Pz()/part.P());
573 fECons->Fill(nu.
E() - part.E());
576 else if(
abs(part.PdgCode()) == 13){
581 fECons->Fill(nu.
E() - part.E());
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
EDProducer(fhicl::ParameterSet const &pset)
double Px(const int i=0) const
offset to account for adding in Nuance codes to this enum
void endSubRun(art::SubRun &sr)
TGeoManager * ROOTGeoManager() const
Access to the ROOT geometry description manager.
Utility functions to print MC truth information.
TH1F * fNCMode
CC interaction mode.
object containing MC flux information
art framework interface to geometry description
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).
TH1F * fDCosZ
direction cosine in z
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
#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
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.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
CodeOutputInterface * code
double fPrevTotPOT
The type of beam.
TH1F * fDCosY
direction cosine in y
Q_EXPORT QTSManip setw(int w)
const simb::MCParticle & GetParticle(int i) const
double Vx(const int i=0) const
TH1F * fEMomentum
momentum of outgoing electrons
TH2F * fVertexYZ
vertex location in yz
TH1F * fECons
histogram to determine if energy is conserved in the event
std::optional< T > get_if_present(std::string const &key) const
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.
static constexpr double sr
Event generator information.
LArSoft geometry interface.
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)
A module to check the results from the Monte Carlo generator.
QTextStream & endl(QTextStream &s)
double fRandomTimeOffset
The start of a simulated "beam gate".