LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
evgen::NDKGen Class Reference

A module to check the results from the Monte Carlo generator. More...

Inheritance diagram for evgen::NDKGen:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 NDKGen (fhicl::ParameterSet const &pset)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
void fillProductDescriptions ()
 
void registerProducts (ProductDescriptions &productsToRegister)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Member Functions

void produce (art::Event &evt) override
 
void beginJob () override
 
void beginRun (art::Run &run) override
 
void endJob () override
 
std::string ParticleStatus (int StatusCode)
 
std::string ReactionChannel (int ccnc, int mode)
 
void FillHistograms (simb::MCTruth const &mc)
 

Private Attributes

std::string fNdkFile
 
std::ifstream fEventFile
 
std::string fNDKModuleLabel
 
CLHEP::HepRandomEngine & fEngine
 art-managed random-number engine More...
 
TH1F * fGenerated [6]
 Spectra as generated. More...
 
TH1F * fVertexX
 vertex location of generated events in x More...
 
TH1F * fVertexY
 vertex location of generated events in y More...
 
TH1F * fVertexZ
 vertex location of generated events in z More...
 
TH2F * fVertexXY
 vertex location in xy More...
 
TH2F * fVertexXZ
 vertex location in xz More...
 
TH2F * fVertexYZ
 vertex location in yz More...
 
TH1F * fDCosX
 direction cosine in x More...
 
TH1F * fDCosY
 direction cosine in y More...
 
TH1F * fDCosZ
 direction cosine in z More...
 
TH1F * fMuMomentum
 momentum of outgoing muons More...
 
TH1F * fMuDCosX
 direction cosine of outgoing mu in x More...
 
TH1F * fMuDCosY
 direction cosine of outgoing mu in y More...
 
TH1F * fMuDCosZ
 direction cosine of outgoing mu in z More...
 
TH1F * fEMomentum
 momentum of outgoing electrons More...
 
TH1F * fEDCosX
 direction cosine of outgoing e in x More...
 
TH1F * fEDCosY
 direction cosine of outgoing e in y More...
 
TH1F * fEDCosZ
 direction cosine of outgoing e in z More...
 
TH1F * fCCMode
 CC interaction mode. More...
 
TH1F * fNCMode
 CC interaction mode. More...
 
TH1F * fECons
 histogram to determine if energy is conserved in the event More...
 

Detailed Description

A module to check the results from the Monte Carlo generator.

Definition at line 48 of file NDKGen_module.cc.

Member Typedef Documentation

Definition at line 17 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::detail::Producer::Table = Modifier::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 26 of file Producer.h.

Constructor & Destructor Documentation

evgen::NDKGen::NDKGen ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 103 of file NDKGen_module.cc.

References art::detail::EngineCreator::createEngine(), fEngine, fEventFile, and fNdkFile.

104  : EDProducer{pset}
105  , fNdkFile{pset.get<std::string>("NdkFile")}
107  // create a default random engine; obtain the random seed from NuRandomService,
108  // unless overridden in configuration with key "Seed"
109  , fEngine(art::ServiceHandle<rndm::NuRandomService>()->registerAndSeedEngine(createEngine(0),
110  pset,
111  "Seed"))
112  {
113  produces<std::vector<simb::MCTruth>>();
114  produces<sumdata::RunData, art::InRun>();
115 
116  if (!fEventFile.good()) {
117  throw cet::exception("NDKGen") << "Could not open file: " << fNdkFile << '\n';
118  }
119  }
base_engine_t & createEngine(seed_t seed)
std::string fNdkFile
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
CLHEP::HepRandomEngine & fEngine
art-managed random-number engine
std::ifstream fEventFile
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Function Documentation

void evgen::NDKGen::beginJob ( )
overrideprivatevirtual

Reimplemented from art::EDProducer.

Definition at line 123 of file NDKGen_module.cc.

References geo::GeometryCore::DetHalfHeight(), geo::GeometryCore::DetHalfWidth(), geo::GeometryCore::DetLength(), fCCMode, fDCosX, fDCosY, fDCosZ, fECons, fEDCosX, fEDCosY, fEDCosZ, fEMomentum, fGenerated, fMuDCosX, fMuDCosY, fMuDCosZ, fMuMomentum, fNCMode, fVertexX, fVertexXY, fVertexXZ, fVertexY, fVertexYZ, fVertexZ, x, y, and z.

124  {
126 
127  fGenerated[0] = tfs->make<TH1F>("fGenerated_necc", "", 100, 0.0, 20.0);
128  fGenerated[1] = tfs->make<TH1F>("fGenerated_nebcc", "", 100, 0.0, 20.0);
129  fGenerated[2] = tfs->make<TH1F>("fGenerated_nmcc", "", 100, 0.0, 20.0);
130  fGenerated[3] = tfs->make<TH1F>("fGenerated_nmbcc", "", 100, 0.0, 20.0);
131  fGenerated[4] = tfs->make<TH1F>("fGenerated_nnc", "", 100, 0.0, 20.0);
132  fGenerated[5] = tfs->make<TH1F>("fGenerated_nbnc", "", 100, 0.0, 20.0);
133 
134  fDCosX = tfs->make<TH1F>("fDCosX", ";dx/ds", 200, -1., 1.);
135  fDCosY = tfs->make<TH1F>("fDCosY", ";dy/ds", 200, -1., 1.);
136  fDCosZ = tfs->make<TH1F>("fDCosZ", ";dz/ds", 200, -1., 1.);
137 
138  fMuMomentum = tfs->make<TH1F>("fMuMomentum", ";p_{#mu} (GeV/c)", 500, 0., 50.);
139  fMuDCosX = tfs->make<TH1F>("fMuDCosX", ";dx/ds;", 200, -1., 1.);
140  fMuDCosY = tfs->make<TH1F>("fMuDCosY", ";dy/ds;", 200, -1., 1.);
141  fMuDCosZ = tfs->make<TH1F>("fMuDCosZ", ";dz/ds;", 200, -1., 1.);
142 
143  fEMomentum = tfs->make<TH1F>("fEMomentum", ";p_{e} (GeV/c)", 500, 0., 50.);
144  fEDCosX = tfs->make<TH1F>("fEDCosX", ";dx/ds;", 200, -1., 1.);
145  fEDCosY = tfs->make<TH1F>("fEDCosY", ";dy/ds;", 200, -1., 1.);
146  fEDCosZ = tfs->make<TH1F>("fEDCosZ", ";dz/ds;", 200, -1., 1.);
147 
148  fCCMode = tfs->make<TH1F>("fCCMode", ";CC Interaction Mode;", 5, 0., 5.);
149  fCCMode->GetXaxis()->SetBinLabel(1, "QE");
150  fCCMode->GetXaxis()->SetBinLabel(2, "Res");
151  fCCMode->GetXaxis()->SetBinLabel(3, "DIS");
152  fCCMode->GetXaxis()->SetBinLabel(4, "Coh");
153  fCCMode->GetXaxis()->SetBinLabel(5, "kInverseMuDecay");
154  fCCMode->GetXaxis()->CenterLabels();
155 
156  fNCMode = tfs->make<TH1F>("fNCMode", ";NC Interaction Mode;", 5, 0., 5.);
157  fNCMode->GetXaxis()->SetBinLabel(1, "QE");
158  fNCMode->GetXaxis()->SetBinLabel(2, "Res");
159  fNCMode->GetXaxis()->SetBinLabel(3, "DIS");
160  fNCMode->GetXaxis()->SetBinLabel(4, "Coh");
161  fNCMode->GetXaxis()->SetBinLabel(5, "kNuElectronElastic");
162  fNCMode->GetXaxis()->CenterLabels();
163 
164  fECons = tfs->make<TH1F>("fECons", ";#Delta E(#nu,lepton);", 500, -5., 5.);
165 
167  double x = 2.1 * geo->DetHalfWidth();
168  double y = 2.1 * geo->DetHalfHeight();
169  double z = 2. * geo->DetLength();
170  int xdiv = TMath::Nint(2 * x / 5.);
171  int ydiv = TMath::Nint(2 * y / 5.);
172  int zdiv = TMath::Nint(2 * z / 5.);
173 
174  fVertexX = tfs->make<TH1F>("fVertexX", ";x (cm)", xdiv, -x, x);
175  fVertexY = tfs->make<TH1F>("fVertexY", ";y (cm)", ydiv, -y, y);
176  fVertexZ = tfs->make<TH1F>("fVertexZ", ";z (cm)", zdiv, -0.2 * z, z);
177 
178  fVertexXY = tfs->make<TH2F>("fVertexXY", ";x (cm);y (cm)", xdiv, -x, x, ydiv, -y, y);
179  fVertexXZ = tfs->make<TH2F>("fVertexXZ", ";z (cm);x (cm)", zdiv, -0.2 * z, z, xdiv, -x, x);
180  fVertexYZ = tfs->make<TH2F>("fVertexYZ", ";z (cm);y (cm)", zdiv, -0.2 * z, z, ydiv, -y, y);
181  }
Float_t x
Definition: compare.C:6
TH1F * fMuMomentum
momentum of outgoing muons
TH2F * fVertexXY
vertex location in xy
TH1F * fGenerated[6]
Spectra as generated.
TH1F * fMuDCosY
direction cosine of outgoing mu in y
TH1F * fMuDCosZ
direction cosine of outgoing mu in z
TH1F * fECons
histogram to determine if energy is conserved in the event
Float_t y
Definition: compare.C:6
TH1F * fEDCosZ
direction cosine of outgoing e in z
TH1F * fEMomentum
momentum of outgoing electrons
Length_t DetHalfWidth(TPCID const &tpcid=tpc_zero) const
Returns the half width of the active volume of the specified TPC.
Double_t z
Definition: plot.C:276
TH2F * fVertexXZ
vertex location in xz
TH1F * fVertexY
vertex location of generated events in y
TH1F * fCCMode
CC interaction mode.
Length_t DetLength(TPCID const &tpcid=tpc_zero) const
Returns the length of the active volume of the specified TPC.
TH1F * fEDCosY
direction cosine of outgoing e in y
TH1F * fMuDCosX
direction cosine of outgoing mu in x
TH2F * fVertexYZ
vertex location in yz
TH1F * fVertexZ
vertex location of generated events in z
TH1F * fDCosZ
direction cosine in z
TH1F * fEDCosX
direction cosine of outgoing e in x
Length_t DetHalfHeight(TPCID const &tpcid=tpc_zero) const
Returns the half height of the active volume of the specified TPC.
TH1F * fNCMode
CC interaction mode.
TH1F * fDCosY
direction cosine in y
Namespace collecting geometry-related classes utilities.
TH1F * fVertexX
vertex location of generated events in x
TH1F * fDCosX
direction cosine in x
void evgen::NDKGen::beginRun ( art::Run run)
overrideprivatevirtual

Reimplemented from art::EDProducer.

Definition at line 184 of file NDKGen_module.cc.

References geo::GeometryCore::DetectorName(), art::fullRun(), and art::Run::put().

185  {
187  run.put(std::make_unique<sumdata::RunData>(geo->DetectorName()), art::fullRun());
188  }
constexpr auto fullRun()
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Run.h:121
std::string const & DetectorName() const
Returns a string with the name of the detector, as configured.
Definition: GeometryCore.h:203
Namespace collecting geometry-related classes utilities.
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Producer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 22 of file Producer.cc.

References art::detail::Producer::beginJobWithFrame(), and art::detail::Producer::setupQueues().

23  {
24  setupQueues(resources);
25  ProcessingFrame const frame{ScheduleID{}};
26  beginJobWithFrame(frame);
27  }
virtual void setupQueues(SharedResources const &)=0
virtual void beginJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 65 of file Producer.cc.

References art::detail::Producer::beginRunWithFrame(), art::RangeSet::forRun(), art::RunPrincipal::makeRun(), r, art::RunPrincipal::runID(), and art::ModuleContext::scheduleID().

66  {
67  auto r = rp.makeRun(mc, RangeSet::forRun(rp.runID()));
68  ProcessingFrame const frame{mc.scheduleID()};
69  beginRunWithFrame(r, frame);
70  r.commitProducts();
71  return true;
72  }
TRandom r
Definition: spectrum.C:23
virtual void beginRunWithFrame(Run &, ProcessingFrame const &)=0
static RangeSet forRun(RunID)
Definition: RangeSet.cc:51
bool art::detail::Producer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 85 of file Producer.cc.

References art::detail::Producer::beginSubRunWithFrame(), art::RangeSet::forSubRun(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::SubRunPrincipal::subRunID().

86  {
87  auto sr = srp.makeSubRun(mc, RangeSet::forSubRun(srp.subRunID()));
88  ProcessingFrame const frame{mc.scheduleID()};
89  beginSubRunWithFrame(sr, frame);
90  sr.commitProducts();
91  return true;
92  }
virtual void beginSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:57
void art::detail::Producer::doEndJob ( )
inherited

Definition at line 30 of file Producer.cc.

References art::detail::Producer::endJobWithFrame().

31  {
32  ProcessingFrame const frame{ScheduleID{}};
33  endJobWithFrame(frame);
34  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 75 of file Producer.cc.

References art::detail::Producer::endRunWithFrame(), art::RunPrincipal::makeRun(), r, art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

76  {
77  auto r = rp.makeRun(mc, rp.seenRanges());
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(r, frame);
80  r.commitProducts();
81  return true;
82  }
TRandom r
Definition: spectrum.C:23
virtual void endRunWithFrame(Run &, ProcessingFrame const &)=0
bool art::detail::Producer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 95 of file Producer.cc.

References art::detail::Producer::endSubRunWithFrame(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

96  {
97  auto sr = srp.makeSubRun(mc, srp.seenRanges());
98  ProcessingFrame const frame{mc.scheduleID()};
99  endSubRunWithFrame(sr, frame);
100  sr.commitProducts();
101  return true;
102  }
virtual void endSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
bool art::detail::Producer::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited

Definition at line 105 of file Producer.cc.

References art::detail::Producer::checkPutProducts_, e, art::EventPrincipal::makeEvent(), art::detail::Producer::produceWithFrame(), and art::ModuleContext::scheduleID().

110  {
111  auto e = ep.makeEvent(mc);
112  ++counts_run;
113  ProcessingFrame const frame{mc.scheduleID()};
114  produceWithFrame(e, frame);
115  e.commitProducts(checkPutProducts_, &expectedProducts<InEvent>());
116  ++counts_passed;
117  return true;
118  }
bool const checkPutProducts_
Definition: Producer.h:70
Float_t e
Definition: plot.C:35
virtual void produceWithFrame(Event &, ProcessingFrame const &)=0
void art::detail::Producer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 44 of file Producer.cc.

References art::detail::Producer::respondToCloseInputFileWithFrame().

45  {
46  ProcessingFrame const frame{ScheduleID{}};
48  }
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 58 of file Producer.cc.

References art::detail::Producer::respondToCloseOutputFilesWithFrame().

59  {
60  ProcessingFrame const frame{ScheduleID{}};
62  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 37 of file Producer.cc.

References art::detail::Producer::respondToOpenInputFileWithFrame().

38  {
39  ProcessingFrame const frame{ScheduleID{}};
41  }
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 51 of file Producer.cc.

References art::detail::Producer::respondToOpenOutputFilesWithFrame().

52  {
53  ProcessingFrame const frame{ScheduleID{}};
55  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void evgen::NDKGen::endJob ( )
overrideprivatevirtual

Reimplemented from art::EDProducer.

Definition at line 191 of file NDKGen_module.cc.

References fEventFile.

192  {
193  fEventFile.close();
194  }
std::ifstream fEventFile
void evgen::NDKGen::FillHistograms ( simb::MCTruth const &  mc)
private

look for the outgoing lepton in the particle stack just interested in the first one

Definition at line 383 of file NDKGen_module.cc.

References util::abs(), simb::MCNeutrino::CCNC(), DEFINE_ART_MODULE, simb::MCParticle::E(), energy, fCCMode, fDCosX, fDCosY, fDCosZ, fECons, fEDCosX, fEDCosY, fEDCosZ, fEMomentum, fGenerated, fMuDCosX, fMuDCosY, fMuDCosZ, fMuMomentum, fNCMode, fVertexX, fVertexXY, fVertexXZ, fVertexY, fVertexYZ, fVertexZ, simb::MCTruth::GetNeutrino(), simb::MCTruth::GetParticle(), simb::kCC, art::left(), simb::MCNeutrino::Mode(), simb::MCTruth::NParticles(), simb::MCNeutrino::Nu(), simb::MCParticle::P(), part, ParticleStatus(), simb::MCParticle::PdgCode(), simb::MCParticle::Px(), simb::MCParticle::Py(), simb::MCParticle::Pz(), ReactionChannel(), simb::MCParticle::Vx(), simb::MCParticle::Vy(), and simb::MCParticle::Vz().

384  {
385  // Decide which histograms to put the spectrum in
386  int id = -1;
387  if (mc.GetNeutrino().CCNC() == simb::kCC) {
388  fCCMode->Fill(mc.GetNeutrino().Mode());
389  if (mc.GetNeutrino().Nu().PdgCode() == 12)
390  id = 0;
391  else if (mc.GetNeutrino().Nu().PdgCode() == -12)
392  id = 1;
393  else if (mc.GetNeutrino().Nu().PdgCode() == 14)
394  id = 2;
395  else if (mc.GetNeutrino().Nu().PdgCode() == -14)
396  id = 3;
397  else
398  return;
399  }
400  else {
401  fNCMode->Fill(mc.GetNeutrino().Mode());
402  if (mc.GetNeutrino().Nu().PdgCode() > 0)
403  id = 4;
404  else
405  id = 5;
406  }
407  if (id == -1) abort();
408 
409  // Fill the specta histograms
410  fGenerated[id]->Fill(mc.GetNeutrino().Nu().E());
411 
412  //< fill the vertex histograms from the neutrino - that is always
413  //< particle 0 in the list
414  simb::MCNeutrino mcnu = mc.GetNeutrino();
415  const simb::MCParticle nu = mcnu.Nu();
416 
417  fVertexX->Fill(nu.Vx());
418  fVertexY->Fill(nu.Vy());
419  fVertexZ->Fill(nu.Vz());
420 
421  fVertexXY->Fill(nu.Vx(), nu.Vy());
422  fVertexXZ->Fill(nu.Vz(), nu.Vx());
423  fVertexYZ->Fill(nu.Vz(), nu.Vy());
424 
425  double mom = nu.P();
426  if (std::abs(mom) > 0.) {
427  fDCosX->Fill(nu.Px() / mom);
428  fDCosY->Fill(nu.Py() / mom);
429  fDCosZ->Fill(nu.Pz() / mom);
430  }
431 
432  std::cout << "REACTION: " << ReactionChannel(mc.GetNeutrino().CCNC(), mc.GetNeutrino().Mode())
433  << std::endl;
434  std::cout << "-----------> Particles in the Stack = " << mc.NParticles() << std::endl;
435  std::cout << std::setiosflags(std::ios::left) << std::setw(20) << "PARTICLE"
436  << std::setiosflags(std::ios::left) << std::setw(32) << "STATUS" << std::setw(18)
437  << "E (GeV)" << std::setw(18) << "m (GeV/c2)" << std::setw(18) << "Ek (GeV)"
438  << std::endl
439  << std::endl;
440 
441  const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
442 
443  // Loop over the particle stack for this event
444  for (int i = 0; i < mc.NParticles(); ++i) {
445  simb::MCParticle part(mc.GetParticle(i));
446  std::string name;
447  if (part.PdgCode() == 18040)
448  name = "Ar40 18040";
449  else if (part.PdgCode() != -99999) {
450  name = databasePDG->GetParticle(part.PdgCode())->GetName();
451  }
452 
453  int code = part.StatusCode();
454  std::string status = ParticleStatus(code);
455  double mass = part.Mass();
456  double energy = part.E();
457  double Ek = (energy - mass); // Kinetic Energy (GeV)
458 
459  std::cout << std::setiosflags(std::ios::left) << std::setw(20) << name
460  << std::setiosflags(std::ios::left) << std::setw(32) << status << std::setw(18)
461  << energy << std::setw(18) << mass << std::setw(18) << Ek << std::endl;
462  }
463 
464  if (mc.GetNeutrino().CCNC() == simb::kCC) {
465 
468  for (int i = 0; i < mc.NParticles(); ++i) {
469  simb::MCParticle part(mc.GetParticle(i));
470  if (abs(part.PdgCode()) == 11) {
471  fEMomentum->Fill(part.P());
472  fEDCosX->Fill(part.Px() / part.P());
473  fEDCosY->Fill(part.Py() / part.P());
474  fEDCosZ->Fill(part.Pz() / part.P());
475  fECons->Fill(nu.E() - part.E());
476  break;
477  }
478  else if (abs(part.PdgCode()) == 13) {
479  fMuMomentum->Fill(part.P());
480  fMuDCosX->Fill(part.Px() / part.P());
481  fMuDCosY->Fill(part.Py() / part.P());
482  fMuDCosZ->Fill(part.Pz() / part.P());
483  fECons->Fill(nu.E() - part.E());
484  break;
485  }
486  } // end loop over particles
487  } //end if CC interaction
488  }
double E(const int i=0) const
Definition: MCParticle.h:234
TH1F * fMuMomentum
momentum of outgoing muons
TH2F * fVertexXY
vertex location in xy
TH1F * fGenerated[6]
Spectra as generated.
double Py(const int i=0) const
Definition: MCParticle.h:232
TH1F * fMuDCosY
direction cosine of outgoing mu in y
TH1F * fMuDCosZ
direction cosine of outgoing mu in z
TH1F * fECons
histogram to determine if energy is conserved in the event
TH1F * fEDCosZ
direction cosine of outgoing e in z
const simb::MCParticle & Nu() const
Definition: MCNeutrino.h:146
TH1F * fEMomentum
momentum of outgoing electrons
TH2F * fVertexXZ
vertex location in xz
double Px(const int i=0) const
Definition: MCParticle.h:231
constexpr auto abs(T v)
Returns the absolute value of the argument.
TH1F * fVertexY
vertex location of generated events in y
TH1F * fCCMode
CC interaction mode.
TH1F * fEDCosY
direction cosine of outgoing e in y
TString part[npart]
Definition: Style.C:32
double P(const int i=0) const
Definition: MCParticle.h:235
TH1F * fMuDCosX
direction cosine of outgoing mu in x
double energy
Definition: plottest35.C:25
TH2F * fVertexYZ
vertex location in yz
TH1F * fVertexZ
vertex location of generated events in z
TH1F * fDCosZ
direction cosine in z
std::string ReactionChannel(int ccnc, int mode)
TH1F * fEDCosX
direction cosine of outgoing e in x
double Vx(const int i=0) const
Definition: MCParticle.h:222
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:94
double Pz(const int i=0) const
Definition: MCParticle.h:233
double Vz(const int i=0) const
Definition: MCParticle.h:224
std::string ParticleStatus(int StatusCode)
TH1F * fNCMode
CC interaction mode.
TH1F * fDCosY
direction cosine in y
Event generator information.
Definition: MCNeutrino.h:18
TH1F * fVertexX
vertex location of generated events in x
TH1F * fDCosX
direction cosine in x
double Vy(const int i=0) const
Definition: MCParticle.h:223
void art::Modifier::fillProductDescriptions ( )
inherited

Definition at line 10 of file Modifier.cc.

References art::ProductRegistryHelper::fillDescriptions(), and art::ModuleBase::moduleDescription().

11  {
13  }
void fillDescriptions(ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
std::string evgen::NDKGen::ParticleStatus ( int  StatusCode)
private

Definition at line 342 of file NDKGen_module.cc.

Referenced by FillHistograms().

343  {
344  switch (StatusCode) {
345  case 0: return "kIStInitialState";
346  case 1: return "kIStFinalState";
347  case 11: return "kIStNucleonTarget";
348  default: return "Status Unknown";
349  }
350  }
void evgen::NDKGen::produce ( art::Event evt)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 197 of file NDKGen_module.cc.

References simb::MCTruth::Add(), simb::MCParticle::AddTrajectoryPoint(), E, art::EventID::event(), fEngine, fEventFile, art::Event::id(), in, geo::GeometryCore::Iterate(), simb::kUnknown, simb::MCTruth::NParticles(), art::Event::put(), and simb::MCTruth::SetOrigin().

198  {
199 
200  std::cout << std::endl;
201  std::cout << "------------------------------------------------------------------------------"
202  << std::endl;
203  std::cout << "event : " << evt.id().event() << std::endl;
204 
205  std::string name, k, dollar;
206 
207  // event dump format on file output by the two commands ....
208  // gevgen_ndcy -g 1000180400 -m 8 -n 400 -o ndk
209  // gevdump -f ndk.1000.ghep.root > ndk.out
210  std::string Name;
211  int Idx, Ist, PDG, Mother1, Mother2, Daughter1, Daughter2;
212  double Px, Py, Pz, E, m;
213  std::string p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14;
214 
215  int trackid = -1; // set track id to -i as these are all primary particles and have id <= 0
216  std::string primary("primary");
217  int FirstMother = -1;
218  double Mass = -9999;
219  int Status = -9999;
220 
221  double P; // momentum of MCParticle IN GeV/c
222 
223  TLorentzVector Neutrino;
224  TLorentzVector Lepton;
225  TLorentzVector Target;
226  TLorentzVector q;
227  TLorentzVector Hadron4mom;
228 
229  TLorentzVector Tpos;
230 
231  std::unique_ptr<std::vector<simb::MCTruth>> truthcol(new std::vector<simb::MCTruth>);
232  simb::MCTruth truth;
233 
235  CLHEP::RandFlat flat(fEngine);
236 
237  double const fvCut{5.0}; // force vtx to be this far from any wall.
238 
239  // Find boundary of active volume
240  double minx = 1e9;
241  double maxx = -1e9;
242  double miny = 1e9;
243  double maxy = -1e9;
244  double minz = 1e9;
245  double maxz = -1e9;
246  for (auto const& tpc : geo->Iterate<geo::TPCGeo>(geo::CryostatID{0})) {
247  auto const world = tpc.GetCenter();
248  if (minx > world.X() - tpc.HalfWidth()) minx = world.X() - tpc.HalfWidth();
249  if (maxx < world.X() + tpc.HalfWidth()) maxx = world.X() + tpc.HalfWidth();
250  if (miny > world.Y() - tpc.HalfHeight()) miny = world.Y() - tpc.HalfHeight();
251  if (maxy < world.Y() + tpc.HalfHeight()) maxy = world.Y() + tpc.HalfHeight();
252  if (minz > world.Z() - tpc.Length() / 2.) minz = world.Z() - tpc.Length() / 2.;
253  if (maxz < world.Z() + tpc.Length() / 2.) maxz = world.Z() + tpc.Length() / 2.;
254  }
255 
256  // Assign vertice position
257  double X0 = 0.0 + flat.fire(minx + fvCut, maxx - fvCut);
258  double Y0 = 0.0 + flat.fire(miny + fvCut, maxy - fvCut);
259  double Z0 = 0.0 + flat.fire(minz + fvCut, maxz - fvCut);
260 
261  std::cout << "NDKGen_module: X, Y, Z of vtx: " << X0 << ", " << Y0 << ", " << Z0 << std::endl;
262 
263  int GenieEvt = -999;
264 
265  if (!fEventFile.good()) std::cout << "NdkFile: Problem reading Ndk file" << std::endl;
266 
267  while (getline(fEventFile, k)) {
268 
269  if (k.find("** Event:") != std::string::npos) {
270  std::istringstream in;
271  in.clear();
272  in.str(k);
273  std::string dummy;
274  in >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >>
275  dummy >> GenieEvt;
276  std::cout << "Genie Evt " << GenieEvt << " art evt " << evt.id().event() << "\n";
277  }
278 
279  if (GenieEvt + 1 != static_cast<int>(evt.id().event()))
280  continue;
281  else {
282 
283  if (!k.compare(0, 25, "GENIE Interaction Summary")) // testing for new event.
284  break;
285  if (k.compare(0, 1, "|") || k.compare(1, 2, " "))
286  continue; // uninteresting line if it doesn't start with "|" and if second and third characters aren't spaces.
287  if (k.find("Fin-Init") != std::string::npos) continue; // Meh.
288  if (k.find("Ar") != std::string::npos) continue; // Meh.
289  if (k.find("Cl") != std::string::npos) continue; // ignore chlorine nucleus in nnbar events
290  if (k.find("HadrBlob") != std::string::npos) continue; // Meh.
291  if (k.find("NucBindE") != std::string::npos) continue; // Meh. atmo
292  if (k.find("FLAGS") != std::string::npos) break; // Event end. gevgen_ndcy
293  if (k.find("Vertex") != std::string::npos) break; // Event end. atmo
294 
295  if (!k.compare(26, 1, "1")) // New event or stable particles.
296  {
297 
298  std::istringstream in;
299  in.clear();
300  in.str(k);
301 
302  in >> p1 >> Idx >> p2 >> Name >> p3 >> Ist >> p4 >> PDG >> p5 >> Mother1 >> p6 >>
303  Mother2 >> p7 >> Daughter1 >> p8 >> Daughter2 >> p9 >> Px >> p10 >> Py >> p11 >> Pz >>
304  p12 >> E >> p13 >> m >> p14;
305  if (Ist != 1) continue;
306 
307  std::cout << "PDG = " << PDG << std::endl;
308 
309  const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
310  const TParticlePDG* definition = databasePDG->GetParticle(PDG);
311  Mass = definition->Mass(); // GeV
312  if (E - Mass < 0.001) continue; // KE is too low.
313 
314  Status = 1;
315 
316  simb::MCParticle mcpart(trackid, PDG, primary, FirstMother, Mass, Status);
317 
318  P = std::sqrt(pow(E, 2.) - pow(Mass, 2.)); // GeV/c
319  std::cout << "Momentum = " << P << std::endl;
320 
321  TLorentzVector pos(X0, Y0, Z0, 0);
322 
323  Tpos = pos; // for target
324 
325  TLorentzVector mom(Px, Py, Pz, E);
326 
327  mcpart.AddTrajectoryPoint(pos, mom);
328  truth.Add(mcpart);
329 
330  } // loop over particles in an event
331  truth.SetOrigin(simb::kUnknown);
332  }
333  } // end while loop
334 
336  std::cout << "NDKGen.cxx: Putting " << truth.NParticles() << " tracks on stack." << std::endl;
337  truthcol->push_back(truth);
338  evt.put(std::move(truthcol));
339  }
details::range_type< T > Iterate() const
Initializes the specified ID with the ID of the first cryostat.
Definition: GeometryCore.h:541
void SetOrigin(simb::Origin_t origin)
Definition: MCTruth.h:82
Geometry information for a single TPC.
Definition: TPCGeo.h:36
int NParticles() const
Definition: MCTruth.h:75
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
CLHEP::HepRandomEngine & fEngine
art-managed random-number engine
Float_t E
Definition: plot.C:20
std::ifstream fEventFile
ifstream in
Definition: comparison.C:7
void Add(simb::MCParticle const &part)
Definition: MCTruth.h:80
EventNumber_t event() const
Definition: EventID.h:116
Event generator information.
Definition: MCTruth.h:32
Namespace collecting geometry-related classes utilities.
EventID id() const
Definition: Event.cc:23
The data type to uniquely identify a cryostat.
Definition: geo_types.h:192
std::string evgen::NDKGen::ReactionChannel ( int  ccnc,
int  mode 
)
private

Definition at line 353 of file NDKGen_module.cc.

Referenced by FillHistograms().

354  {
355  std::string ReactionChannelName = " ";
356 
357  if (ccnc == 0)
358  ReactionChannelName = "kCC";
359  else if (ccnc == 1)
360  ReactionChannelName = "kNC";
361  else
362  std::cout << "Current mode unknown!! " << std::endl;
363 
364  if (mode == 0)
365  ReactionChannelName += "_kQE";
366  else if (mode == 1)
367  ReactionChannelName += "_kRes";
368  else if (mode == 2)
369  ReactionChannelName += "_kDIS";
370  else if (mode == 3)
371  ReactionChannelName += "_kCoh";
372  else if (mode == 4)
373  ReactionChannelName += "_kNuElectronElastic";
374  else if (mode == 5)
375  ReactionChannelName += "_kInverseMuDecay";
376  else
377  std::cout << "interaction mode unknown!! " << std::endl;
378 
379  return ReactionChannelName;
380  }
void art::Modifier::registerProducts ( ProductDescriptions productsToRegister)
inherited

Definition at line 16 of file Modifier.cc.

References art::ModuleBase::moduleDescription(), and art::ProductRegistryHelper::registerProducts().

17  {
18  ProductRegistryHelper::registerProducts(productsToRegister,
20  }
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)

Member Data Documentation

TH1F* evgen::NDKGen::fCCMode
private

CC interaction mode.

Definition at line 93 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH1F* evgen::NDKGen::fDCosX
private

direction cosine in x

Definition at line 79 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH1F* evgen::NDKGen::fDCosY
private

direction cosine in y

Definition at line 80 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH1F* evgen::NDKGen::fDCosZ
private

direction cosine in z

Definition at line 81 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH1F* evgen::NDKGen::fECons
private

histogram to determine if energy is conserved in the event

Definition at line 96 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH1F* evgen::NDKGen::fEDCosX
private

direction cosine of outgoing e in x

Definition at line 89 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH1F* evgen::NDKGen::fEDCosY
private

direction cosine of outgoing e in y

Definition at line 90 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH1F* evgen::NDKGen::fEDCosZ
private

direction cosine of outgoing e in z

Definition at line 91 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH1F* evgen::NDKGen::fEMomentum
private

momentum of outgoing electrons

Definition at line 88 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

CLHEP::HepRandomEngine& evgen::NDKGen::fEngine
private

art-managed random-number engine

Definition at line 67 of file NDKGen_module.cc.

Referenced by NDKGen(), and produce().

std::ifstream evgen::NDKGen::fEventFile
private

Definition at line 64 of file NDKGen_module.cc.

Referenced by endJob(), NDKGen(), and produce().

TH1F* evgen::NDKGen::fGenerated[6]
private

Spectra as generated.

Definition at line 69 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH1F* evgen::NDKGen::fMuDCosX
private

direction cosine of outgoing mu in x

Definition at line 84 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH1F* evgen::NDKGen::fMuDCosY
private

direction cosine of outgoing mu in y

Definition at line 85 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH1F* evgen::NDKGen::fMuDCosZ
private

direction cosine of outgoing mu in z

Definition at line 86 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH1F* evgen::NDKGen::fMuMomentum
private

momentum of outgoing muons

Definition at line 83 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH1F* evgen::NDKGen::fNCMode
private

CC interaction mode.

Definition at line 94 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

std::string evgen::NDKGen::fNdkFile
private

Definition at line 63 of file NDKGen_module.cc.

Referenced by NDKGen().

std::string evgen::NDKGen::fNDKModuleLabel
private

Definition at line 66 of file NDKGen_module.cc.

TH1F* evgen::NDKGen::fVertexX
private

vertex location of generated events in x

Definition at line 71 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH2F* evgen::NDKGen::fVertexXY
private

vertex location in xy

Definition at line 75 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH2F* evgen::NDKGen::fVertexXZ
private

vertex location in xz

Definition at line 76 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH1F* evgen::NDKGen::fVertexY
private

vertex location of generated events in y

Definition at line 72 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH2F* evgen::NDKGen::fVertexYZ
private

vertex location in yz

Definition at line 77 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().

TH1F* evgen::NDKGen::fVertexZ
private

vertex location of generated events in z

Definition at line 73 of file NDKGen_module.cc.

Referenced by beginJob(), and FillHistograms().


The documentation for this class was generated from the following file: