9 #ifndef EVGEN_GENIEGEN_H 10 #define EVGEN_GENIEGEN_H 25 #include "TDatabasePDG.h" 27 #include "TStopwatch.h" 165 produces< std::vector<simb::MCTruth> >();
166 produces< std::vector<simb::MCFlux> >();
167 produces< std::vector<simb::GTruth> >();
168 produces< sumdata::RunData, art::InRun >();
169 produces< sumdata::POTSummary, art::InSubRun >();
170 produces< art::Assns<simb::MCTruth, simb::MCFlux> >();
171 produces< art::Assns<simb::MCTruth, simb::GTruth> >();
172 produces< std::vector<sim::BeamGateInfo> >();
174 std::string beam_type_name = pset.
get<std::string>(
"BeamName");
176 if(beam_type_name ==
"numi")
180 else if(beam_type_name ==
"booster")
190 signed int temp_seed;
203 GENIEconfig.
put(
"RandomSeed", seed);
209 geo->
TotalMass(pset.
get< std::string>(
"TopVolume").c_str()));
228 fGenerated[0] = tfs->
make<TH1F>(
"fGenerated_necc",
"", 100, 0.0, 20.0);
229 fGenerated[1] = tfs->
make<TH1F>(
"fGenerated_nebcc",
"", 100, 0.0, 20.0);
230 fGenerated[2] = tfs->
make<TH1F>(
"fGenerated_nmcc",
"", 100, 0.0, 20.0);
231 fGenerated[3] = tfs->
make<TH1F>(
"fGenerated_nmbcc",
"", 100, 0.0, 20.0);
232 fGenerated[4] = tfs->
make<TH1F>(
"fGenerated_nnc",
"", 100, 0.0, 20.0);
233 fGenerated[5] = tfs->
make<TH1F>(
"fGenerated_nbnc",
"", 100, 0.0, 20.0);
235 fDCosX = tfs->
make<TH1F>(
"fDCosX",
";dx/ds", 200, -1., 1.);
236 fDCosY = tfs->
make<TH1F>(
"fDCosY",
";dy/ds", 200, -1., 1.);
237 fDCosZ = tfs->
make<TH1F>(
"fDCosZ",
";dz/ds", 200, -1., 1.);
239 fMuMomentum = tfs->
make<TH1F>(
"fMuMomentum",
";p_{#mu} (GeV/c)", 500, 0., 50.);
240 fMuDCosX = tfs->
make<TH1F>(
"fMuDCosX",
";dx/ds;", 200, -1., 1.);
241 fMuDCosY = tfs->
make<TH1F>(
"fMuDCosY",
";dy/ds;", 200, -1., 1.);
242 fMuDCosZ = tfs->
make<TH1F>(
"fMuDCosZ",
";dz/ds;", 200, -1., 1.);
244 fEMomentum = tfs->
make<TH1F>(
"fEMomentum",
";p_{e} (GeV/c)", 500, 0., 50.);
245 fEDCosX = tfs->
make<TH1F>(
"fEDCosX",
";dx/ds;", 200, -1., 1.);
246 fEDCosY = tfs->
make<TH1F>(
"fEDCosY",
";dy/ds;", 200, -1., 1.);
247 fEDCosZ = tfs->
make<TH1F>(
"fEDCosZ",
";dz/ds;", 200, -1., 1.);
249 fCCMode = tfs->
make<TH1F>(
"fCCMode",
";CC Interaction Mode;", 4, 0., 4.);
250 fCCMode->GetXaxis()->SetBinLabel(1,
"QE");
251 fCCMode->GetXaxis()->SetBinLabel(2,
"Res");
252 fCCMode->GetXaxis()->SetBinLabel(3,
"DIS");
253 fCCMode->GetXaxis()->SetBinLabel(4,
"Coh");
254 fCCMode->GetXaxis()->CenterLabels();
256 fNCMode = tfs->
make<TH1F>(
"fNCMode",
";NC Interaction Mode;", 4, 0., 4.);
257 fNCMode->GetXaxis()->SetBinLabel(1,
"QE");
258 fNCMode->GetXaxis()->SetBinLabel(2,
"Res");
259 fNCMode->GetXaxis()->SetBinLabel(3,
"DIS");
260 fNCMode->GetXaxis()->SetBinLabel(4,
"Coh");
261 fNCMode->GetXaxis()->CenterLabels();
263 fDeltaE = tfs->
make<TH1F>(
"fDeltaE",
";#Delta E_{#nu} (GeV);", 200, -1., 1.);
264 fECons = tfs->
make<TH1F>(
"fECons",
";#Delta E(#nu,lepton);", 500, -5., 5.);
270 int xdiv = TMath::Nint(2*x/5.);
271 int ydiv = TMath::Nint(2*y/5.);
272 int zdiv = TMath::Nint(2*z/5.);
276 fVertexX = tfs->
make<TH1F>(
"fVertexX",
";x (cm)", xdiv, -0.1*
x,
x);
278 fVertexZ = tfs->
make<TH1F>(
"fVertexZ",
";z (cm)", zdiv, -0.1*
z,
z);
280 fVertexXY = tfs->
make<TH2F>(
"fVertexXY",
";x (cm);y (cm)", xdiv, -0.1*
x,
x, ydiv, -
y,
y);
281 fVertexXZ = tfs->
make<TH2F>(
"fVertexXZ",
";z (cm);x (cm)", zdiv, -0.2*
z,
z, xdiv, -0.1*
x,
x);
282 fVertexYZ = tfs->
make<TH2F>(
"fVertexYZ",
";z (cm);y (cm)", zdiv, -0.2*
z,
z, ydiv, -
y,
y);
287 fVertexY = tfs->
make<TH1F>(
"fVertexY",
";y (cm)", ydiv, fVtxPosHistRange[2], fVtxPosHistRange[3]);
288 fVertexZ = tfs->
make<TH1F>(
"fVertexZ",
";z (cm)", zdiv, fVtxPosHistRange[4], fVtxPosHistRange[5]);
290 fVertexXY = tfs->
make<TH2F>(
"fVertexXY",
";x (cm);y (cm)", xdiv, fVtxPosHistRange[0], fVtxPosHistRange[1], ydiv, fVtxPosHistRange[2], fVtxPosHistRange[3]);
291 fVertexXZ = tfs->
make<TH2F>(
"fVertexXZ",
";z (cm);x (cm)", zdiv, fVtxPosHistRange[4], fVtxPosHistRange[5], xdiv, fVtxPosHistRange[0], fVtxPosHistRange[1]);
292 fVertexYZ = tfs->
make<TH2F>(
"fVertexYZ",
";z (cm);y (cm)", zdiv, fVtxPosHistRange[4], fVtxPosHistRange[5], ydiv, fVtxPosHistRange[2], fVtxPosHistRange[3]);
305 run.
put(std::move(runcol));
319 sr.
put(std::move(p));
327 std::unique_ptr< std::vector<simb::MCTruth> > truthcol (
new std::vector<simb::MCTruth>);
328 std::unique_ptr< std::vector<simb::MCFlux> > fluxcol (
new std::vector<simb::MCFlux >);
329 std::unique_ptr< std::vector<simb::GTruth> > gtruthcol (
new std::vector<simb::GTruth >);
332 std::unique_ptr< std::vector<sim::BeamGateInfo> > gateCollection(
new std::vector<sim::BeamGateInfo>);
334 while(truthcol->size() < 1){
347 truthcol ->push_back(truth);
348 fluxcol ->push_back(flux);
349 gtruthcol->push_back(gTruth);
350 util::CreateAssn(*
this, evt, *truthcol, *fluxcol, *tfassn, fluxcol->size()-1, fluxcol->size());
351 util::CreateAssn(*
this, evt, *truthcol, *gtruthcol, *tgtassn, gtruthcol->size()-1, gtruthcol->size());
360 log <<
"Found an interaction that is not represented by the interaction type code in GENIE:" 366 "\nGENIE truth record:" 378 LOG_DEBUG(
"GENIEGen") <<
"no events made for this spill but " 379 <<
"passing it on and ending the event anyway";
392 evt.
put(std::move(truthcol));
393 evt.
put(std::move(fluxcol));
394 evt.
put(std::move(gtruthcol));
395 evt.
put(std::move(tfassn));
396 evt.
put(std::move(tgtassn));
397 evt.
put(std::move(gateCollection));
405 int code = StatusCode;
411 ParticleStatusName =
"kIStUndefined";
414 ParticleStatusName =
"kIStInitialState";
417 ParticleStatusName =
"kIStStableFinalState";
420 ParticleStatusName =
"kIStIntermediateState";
423 ParticleStatusName =
"kIStDecayedState";
426 ParticleStatusName =
"kIStNucleonTarget";
429 ParticleStatusName =
"kIStDISPreFragmHadronicState";
432 ParticleStatusName =
"kIStPreDecayResonantState";
435 ParticleStatusName =
"kIStHadronInTheNucleus";
438 ParticleStatusName =
"kIStFinalStateNuclearRemnant";
441 ParticleStatusName =
"kIStNucleonClusterTarget";
444 ParticleStatusName =
"Status Unknown";
452 std::string ReactionChannelName=
" ";
455 ReactionChannelName =
"kCC";
457 ReactionChannelName =
"kNC";
458 else std::cout<<
"Current mode unknown!! "<<std::endl;
461 ReactionChannelName +=
"_kQE";
463 ReactionChannelName +=
"_kRes";
465 ReactionChannelName +=
"_kDIS";
467 ReactionChannelName +=
"_kCoh";
468 else std::cout<<
"interaction mode unknown!! "<<std::endl;
470 return ReactionChannelName;
510 if(std::abs(mom) > 0.){
521 <<
"-----------> Particles in the Stack = " << mc.
NParticles() << std::endl
523 << std::setw(20) <<
"PARTICLE" 525 << std::setw(32) <<
"STATUS" 526 << std::setw(18) <<
"E (GeV)" 527 << std::setw(18) <<
"m (GeV/c2)" 528 << std::setw(18) <<
"Ek (GeV)" 529 << std::endl << std::endl;
531 const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
536 std::string name = databasePDG->GetParticle(
part.PdgCode())->GetName();
537 int code =
part.StatusCode();
539 double mass =
part.Mass();
541 double Ek = (energy-mass);
542 if(status==
"kIStStableFinalState"||status==
"kIStHadronInTheNucleus")
546 << std::setw(18)<< energy
547 << std::setw(18)<< mass
548 << std::setw(18)<< Ek <<std::endl;
553 << std::setw(18) << energy
554 << std::setw(18) << mass <<std::endl;
564 if(abs(
part.PdgCode()) == 11){
572 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
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.
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]
The type of beam.
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.
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".