10 #ifndef EVGEN_GENIEGEN_H 11 #define EVGEN_GENIEGEN_H 26 #include "TDatabasePDG.h" 28 #include "TStopwatch.h" 37 #include "art_root_io/TFileService.h" 38 #include "art_root_io/TFileDirectory.h" 43 #include "GENIE/Framework/Ntuple/NtpMCEventRecord.h" 44 #include "GENIE/Framework/Ntuple/NtpMCTreeHeader.h" 51 #include "nugen/EventGeneratorBase/GENIE/GENIEHelper.h" 52 #include "nurandom/RandomUtils/NuRandomService.h" 62 #include "Utilities/AssociationUtil.h" 63 #include "CoreUtils/ServiceUtil.h" 170 produces< std::vector<simb::MCTruth> >();
171 produces< std::vector<simb::MCFlux> >();
172 produces< std::vector<simb::GTruth> >();
173 produces< std::vector<sdp::GenieParticle> >();
174 produces< sumdata::RunData, ::art::InRun >();
175 produces< sumdata::POTSummary, ::art::InRun >();
176 produces< ::art::Assns<simb::MCTruth, simb::MCFlux> >();
177 produces< ::art::Assns<simb::MCTruth, simb::GTruth> >();
185 auto geo = gar::providerFrom<geo::GeometryGAr>();
188 if (!GENIEconfig.has_key(
"RandomSeed")) {
194 if (!GENIEconfig.has_key(
"Seed"))
200 GENIEconfig.put(
"RandomSeed", seed);
203 fGENIEHelp =
new evgb::GENIEHelper(GENIEconfig,
204 geo->ROOTGeoManager(),
225 fGenerated[0] = tfs->make<TH1F>(
"fGenerated_necc",
"", 100, 0.0, 20.0);
226 fGenerated[1] = tfs->make<TH1F>(
"fGenerated_nebcc",
"", 100, 0.0, 20.0);
227 fGenerated[2] = tfs->make<TH1F>(
"fGenerated_nmcc",
"", 100, 0.0, 20.0);
228 fGenerated[3] = tfs->make<TH1F>(
"fGenerated_nmbcc",
"", 100, 0.0, 20.0);
229 fGenerated[4] = tfs->make<TH1F>(
"fGenerated_nnc",
"", 100, 0.0, 20.0);
230 fGenerated[5] = tfs->make<TH1F>(
"fGenerated_nbnc",
"", 100, 0.0, 20.0);
232 fDCosX = tfs->make<TH1F>(
"fDCosX",
";dx/ds", 200, -1., 1.);
233 fDCosY = tfs->make<TH1F>(
"fDCosY",
";dy/ds", 200, -1., 1.);
234 fDCosZ = tfs->make<TH1F>(
"fDCosZ",
";dz/ds", 200, -1., 1.);
236 fMuMomentum = tfs->make<TH1F>(
"fMuMomentum",
";p_{#mu} (GeV/c)", 500, 0., 50.);
237 fMuDCosX = tfs->make<TH1F>(
"fMuDCosX",
";dx/ds;", 200, -1., 1.);
238 fMuDCosY = tfs->make<TH1F>(
"fMuDCosY",
";dy/ds;", 200, -1., 1.);
239 fMuDCosZ = tfs->make<TH1F>(
"fMuDCosZ",
";dz/ds;", 200, -1., 1.);
241 fEMomentum = tfs->make<TH1F>(
"fEMomentum",
";p_{e} (GeV/c)", 500, 0., 50.);
242 fEDCosX = tfs->make<TH1F>(
"fEDCosX",
";dx/ds;", 200, -1., 1.);
243 fEDCosY = tfs->make<TH1F>(
"fEDCosY",
";dy/ds;", 200, -1., 1.);
244 fEDCosZ = tfs->make<TH1F>(
"fEDCosZ",
";dz/ds;", 200, -1., 1.);
246 fCCMode = tfs->make<TH1F>(
"fCCMode",
";CC Interaction Mode;", 4, 0., 4.);
247 fCCMode->GetXaxis()->SetBinLabel(1,
"QE");
248 fCCMode->GetXaxis()->SetBinLabel(2,
"Res");
249 fCCMode->GetXaxis()->SetBinLabel(3,
"DIS");
250 fCCMode->GetXaxis()->SetBinLabel(4,
"Coh");
251 fCCMode->GetXaxis()->CenterLabels();
253 fNCMode = tfs->make<TH1F>(
"fNCMode",
";NC Interaction Mode;", 4, 0., 4.);
254 fNCMode->GetXaxis()->SetBinLabel(1,
"QE");
255 fNCMode->GetXaxis()->SetBinLabel(2,
"Res");
256 fNCMode->GetXaxis()->SetBinLabel(3,
"DIS");
257 fNCMode->GetXaxis()->SetBinLabel(4,
"Coh");
258 fNCMode->GetXaxis()->CenterLabels();
260 fDeltaE = tfs->make<TH1F>(
"fDeltaE",
";#Delta E_{#nu} (GeV);", 200, -1., 1.);
261 fECons = tfs->make<TH1F>(
"fECons",
";#Delta E(#nu,lepton);", 500, -5., 5.);
263 auto geo = gar::providerFrom<geo::GeometryGAr>();
264 double x = 2.1 *
geo->TPCRadius();
265 double y = 2.1 *
geo->TPCRadius();
266 double z = 2. *
geo->TPCLength();
267 int xdiv = TMath::Nint(2 * x / 5.);
268 int ydiv = TMath::Nint(2 * y / 5.);
269 int zdiv = TMath::Nint(2 * z / 5.);
271 fVertexX = tfs->make<TH1F>(
"fVertexX",
";x (cm)", xdiv, -
x,
x);
272 fVertexY = tfs->make<TH1F>(
"fVertexY",
";y (cm)", ydiv, -
y,
y);
273 fVertexZ = tfs->make<TH1F>(
"fVertexZ",
";z (cm)", zdiv, -
z,
z);
275 fVertexXY = tfs->make<TH2F>(
"fVertexXY",
";x (cm);y (cm)", xdiv, -
x,
x, ydiv, -
y,
y);
276 fVertexXZ = tfs->make<TH2F>(
"fVertexXZ",
";z (cm);x (cm)", zdiv, -
z,
z, xdiv, -
x,
x);
277 fVertexYZ = tfs->make<TH2F>(
"fVertexYZ",
";z (cm);y (cm)", zdiv, -
z,
z, ydiv, -
y,
y);
285 auto geo = gar::providerFrom<geo::GeometryGAr>();
304 std::unique_ptr< std::vector<simb::MCTruth> > truthcol (
new std::vector<simb::MCTruth>);
305 std::unique_ptr< std::vector<simb::MCFlux> > fluxcol (
new std::vector<simb::MCFlux >);
306 std::unique_ptr< std::vector<simb::GTruth> > gtruthcol(
new std::vector<simb::GTruth >);
307 std::unique_ptr< ::art::Assns<simb::MCTruth, simb::MCFlux> > tfassn (new ::art::Assns<simb::MCTruth, simb::MCFlux>);
308 std::unique_ptr< ::art::Assns<simb::MCTruth, simb::GTruth> > tgtassn (new ::art::Assns<simb::MCTruth, simb::GTruth>);
309 std::unique_ptr< std::vector<gar::sdp::GenieParticle> > geniepartcol(
new std::vector<gar::sdp::GenieParticle> );
311 while(truthcol->size() < 1)
313 unsigned int_idx = 0;
329 TObjArrayIter piter(
event);
330 unsigned int idx = 0;
333 geniepartcol->emplace_back(int_idx, idx, p->
Pdg(), p->
Status(), p->
Name(), p->
FirstMother(), p->
LastMother(), p->
FirstDaughter(), p->
LastDaughter(), p->
Px(), p->
Py(), p->
Pz(), p->
E(), p->
Mass(), p->
RescatterCode());
337 truthcol ->push_back(truth);
338 fluxcol ->push_back(flux);
339 gtruthcol->push_back(gTruth);
340 util::CreateAssn(*
this, evt, *truthcol, *fluxcol, *tfassn, fluxcol->size() - 1, fluxcol->size() );
341 util::CreateAssn(*
this, evt, *truthcol, *gtruthcol, *tgtassn, gtruthcol->size() - 1, gtruthcol->size());
350 MF_LOG_DEBUG(
"GENIEGen") <<
"no events made for this spill but " 351 <<
"passing it on and ending the event anyway";
371 int code = StatusCode;
377 ParticleStatusName =
"kIStUndefined";
380 ParticleStatusName =
"kIStInitialState";
383 ParticleStatusName =
"kIStStableFinalState";
386 ParticleStatusName =
"kIStIntermediateState";
389 ParticleStatusName =
"kIStDecayedState";
392 ParticleStatusName =
"kIStNucleonTarget";
395 ParticleStatusName =
"kIStDISPreFragmHadronicState";
398 ParticleStatusName =
"kIStPreDecayResonantState";
401 ParticleStatusName =
"kIStHadronInTheNucleus";
404 ParticleStatusName =
"kIStFinalStateNuclearRemnant";
407 ParticleStatusName =
"kIStNucleonClusterTarget";
410 ParticleStatusName =
"Status Unknown";
421 ReactionChannelName =
"kCC";
423 ReactionChannelName =
"kNC";
424 else std::cout<<
"Current mode unknown!! "<<
std::endl;
427 ReactionChannelName +=
"_kQE";
429 ReactionChannelName +=
"_kRes";
431 ReactionChannelName +=
"_kDIS";
433 ReactionChannelName +=
"_kCoh";
434 else std::cout<<
"interaction mode unknown!! "<<
std::endl;
436 return ReactionChannelName;
497 const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
502 std::string name = databasePDG->GetParticle(part.PdgCode())->GetName();
503 int code = part.StatusCode();
505 double mass = part.Mass();
507 double Ek = (energy-mass);
508 if(status ==
"kIStStableFinalState" ||
509 status ==
"kIStHadronInTheNucleus")
533 fEDCosX->Fill(part.Px()/part.P());
534 fEDCosY->Fill(part.Py()/part.P());
535 fEDCosZ->Fill(part.Pz()/part.P());
536 fECons->Fill(nu.
E() - part.E());
539 else if(
std::abs(part.PdgCode()) == 13){
544 fECons->Fill(nu.
E() - part.E());
double E(const int i=0) const
TH1F * fEDCosY
direction cosine of outgoing e in y
int RescatterCode(void) const
const simb::MCNeutrino & GetNeutrino() const
GENIEGen(fhicl::ParameterSet const &pset)
TH2F * fVertexXY
vertex location in xy
double Py(const int i=0) const
double E(void) const
Get energy.
TH1F * fMuDCosY
direction cosine of outgoing mu in y
TH1F * fMuDCosZ
direction cosine of outgoing mu in z
TH1F * fCCMode
CC interaction mode.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
int FirstDaughter(void) const
TH1F * fVertexZ
vertex location of generated events in z
const simb::MCParticle & Nu() const
EDProducer(fhicl::ParameterSet const &pset)
void produce(::art::Event &evt)
double Px(const int i=0) const
void endRun(::art::Run &run)
double Mass(void) const
Mass that corresponds to the PDG code.
TH1F * fMuMomentum
momentum of outgoing muons
double Pz(void) const
Get Pz.
GHepStatus_t Status(void) const
TH1F * fVertexY
vertex location of generated events in y
object containing MC flux information
BeamType_t
Defines category of beams to be stored in sdp::BeamGateInfo.
TH1F * fECons
histogram to determine if energy is conserved in the event
double Px(void) const
Get Px.
TH2F * fVertexXZ
vertex location in xz
TH2F * fVertexYZ
vertex location in yz
int LastMother(void) const
int FirstMother(void) const
string Name(void) const
Name that corresponds to the PDG code.
TH1F * fEMomentum
momentum of outgoing electrons
std::string ParticleStatus(int StatusCode)
gar::sdp::BeamType_t fBeamType
The width of a simulated "beam gate".
double fRandomTimeOffset
The start of a simulated "beam gate".
int LastDaughter(void) const
TH1F * fDeltaE
difference in neutrino energy from MCTruth::Enu() vs TParticle
#define DEFINE_ART_MODULE(klass)
void beginRun(::art::Run &run)
TH1F * fMuDCosX
direction cosine of outgoing mu in x
A module to check the results from the Monte Carlo generator.
double P(const int i=0) const
TH1F * fDCosX
direction cosine in x
TH1F * fGenerated[6]
The type of beam.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
TH1F * fDCosZ
direction cosine in z
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.
CodeOutputInterface * code
double fGlobalTimeOffset
keep track of how long it takes to run the job
int fPassEmptySpills
whether or not to kill evnets with no interactions
std::string ReactionChannel(int ccnc, int mode)
Q_EXPORT QTSManip setw(int w)
void FillHistograms(simb::MCTruth mc)
const simb::MCParticle & GetParticle(int i) const
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
General GArSoft Utilities.
double Vx(const int i=0) const
TH1F * fDCosY
direction cosine in y
TH1F * fEDCosX
direction cosine of outgoing e in x
double Pz(const int i=0) const
double Vz(const int i=0) const
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
Event generator information.
Event generator information.
LArSoft geometry interface.
art framework interface to geometry description
Event Generation using GENIE, cosmics or single particles.
std::string ParticleStatusName(int code)
Describes the status of a particle (simb::MCParticle::StatusCode()).
STDHEP-like event record entry that can fit a particle or a nucleus.
TH1F * fVertexX
vertex location of generated events in x
TH1F * fNCMode
CC interaction mode.
double Vy(const int i=0) const
QTextStream & endl(QTextStream &s)
Event finding and building.
double Py(void) const
Get Py.
TH1F * fEDCosZ
direction cosine of outgoing e in z