Public Member Functions | Private Member Functions | Private Attributes | List of all members
evgen::GENIEGen Class Reference

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

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

Public Member Functions

 GENIEGen (fhicl::ParameterSet const &pset)
 
virtual ~GENIEGen ()
 
void produce (art::Event &evt)
 
void beginJob ()
 
void beginRun (art::Run &run)
 
void beginSubRun (art::SubRun &sr)
 
void endSubRun (art::SubRun &sr)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
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)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
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)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

std::string ParticleStatus (int StatusCode)
 
std::string ReactionChannel (int ccnc, int mode)
 
void FillHistograms (simb::MCTruth mc)
 

Private Attributes

evgb::GENIEHelper * fGENIEHelp
 GENIEHelper object. More...
 
bool fDefinedVtxHistRange
 
std::vector< double > fVtxPosHistRange
 use defined hist range; it is useful to have for asymmetric ranges like in DP FD. More...
 
int fPassEmptySpills
 whether or not to kill evnets with no interactions More...
 
TStopwatch fStopwatch
 
double fGlobalTimeOffset
 keep track of how long it takes to run the job More...
 
double fRandomTimeOffset
 The start of a simulated "beam gate". More...
 
::sim::BeamType_t fBeamType
 The width of a simulated "beam gate". More...
 
double fPrevTotPOT
 The type of beam. More...
 
double fPrevTotGoodPOT
 Total good POT from subruns previous to current subrun. 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 * fDeltaE
 difference in neutrino energy from MCTruth::Enu() vs TParticle More...
 
TH1F * fECons
 histogram to determine if energy is conserved in the event More...
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
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 ()
 

Detailed Description

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

Note on random number generator

GENIE uses a TRandom generator for its purposes. Since art's RandomNumberGenerator service only provides CLHEP::HepRandomEngine, the standard LArSoft/art mechanism for handling the random stream can't be used. GENIEHelper, interface to GENIE provided by nugen, creates a TRandom that GENIE can use. It initializes it with a random seed read from RandomSeed configuration parameter. This and all the other parameters are inherited from the art module (that is, GENIEGen) configuration. LArSoft meddles with this mechanism to provide support for the standard "Seed" parameter and NuRandomService service.

Configuration parameters

As custom, if the random seed is not provided by the configuration, one is fetched from NuRandomService (if available), with the behaviour in lar::util::FetchRandomSeed().

Definition at line 81 of file GENIEGen_module.cc.

Constructor & Destructor Documentation

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

Definition at line 149 of file GENIEGen_module.cc.

150  : EDProducer{pset}
151  , fGENIEHelp(0)
152  , fDefinedVtxHistRange (pset.get< bool >("DefinedVtxHistRange"))
153  , fVtxPosHistRange (pset.get< std::vector<double> >("VtxPosHistRange"))
154  , fPassEmptySpills (pset.get< bool >("PassEmptySpills"))
155  , fGlobalTimeOffset(pset.get< double >("GlobalTimeOffset",0))
156  , fRandomTimeOffset(pset.get< double >("RandomTimeOffset",1600.)) // BNB default value
157  , fBeamType(::sim::kBNB)
158  {
159  fStopwatch.Start();
160 
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> >();
169 
170  std::string beam_type_name = pset.get<std::string>("BeamName");
171 
172  if(beam_type_name == "numi")
173 
175 
176  else if(beam_type_name == "booster")
177 
179 
180  else
181 
183 
185 
186  signed int temp_seed; // the seed read by GENIEHelper is a signed integer...
187  fhicl::ParameterSet GENIEconfig(pset);
188  if (!GENIEconfig.get_if_present("RandomSeed", temp_seed)) { // TODO use has_key() when it becomes available
189  // no RandomSeed specified; check for the LArSoft-style "Seed" instead:
190  // obtain the random seed from a service,
191  // unless overridden in configuration with key "Seed"
192  unsigned int seed;
193  if (!GENIEconfig.get_if_present("Seed", seed))
194  seed = art::ServiceHandle<rndm::NuRandomService>()->getSeed();
195 
196  // The seed is not passed to RandomNumberGenerator,
197  // since GENIE uses a TRandom generator that is owned by the GENIEHelper.
198  // Instead, we explicitly configure the random seed for GENIEHelper:
199  GENIEconfig.put("RandomSeed", seed);
200  } // if no RandomSeed present
201 
202  fGENIEHelp = new evgb::GENIEHelper(GENIEconfig,
203  geo->ROOTGeoManager(),
204  geo->ROOTFile(),
205  geo->TotalMass(pset.get< std::string>("TopVolume").c_str()));
206 
207  }
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
TGeoManager * ROOTGeoManager() const
Access to the ROOT geometry description manager.
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).
int fPassEmptySpills
whether or not to kill evnets with no interactions
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
double fGlobalTimeOffset
keep track of how long it takes to run the job
BNB.
Definition: BeamTypes.h:11
TStopwatch fStopwatch
LArSoft geometry interface.
Definition: ChannelGeo.h:16
std::vector< double > fVtxPosHistRange
use defined hist range; it is useful to have for asymmetric ranges like in DP FD. ...
double fRandomTimeOffset
The start of a simulated "beam gate".
evgen::GENIEGen::~GENIEGen ( )
virtual

Definition at line 210 of file GENIEGen_module.cc.

211  {
212  if(fGENIEHelp) delete fGENIEHelp;
213  fStopwatch.Stop();
214  mf::LogInfo("GENIEProductionTime") << "real time to produce file: " << fStopwatch.RealTime();
215  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
TStopwatch fStopwatch

Member Function Documentation

void evgen::GENIEGen::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 218 of file GENIEGen_module.cc.

218  {
219  fGENIEHelp->Initialize();
220 
221  fPrevTotPOT = 0.;
222  fPrevTotGoodPOT = 0.;
223 
224  // Get access to the TFile service.
226 
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);
233 
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.);
237 
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.);
242 
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.);
247 
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();
254 
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();
261 
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.);
264 
266  double x = 2.1*geo->DetHalfWidth();
267  double y = 2.1*geo->DetHalfHeight();
268  double z = 2.*geo->DetLength();
269  int xdiv = TMath::Nint(2*x/5.);
270  int ydiv = TMath::Nint(2*y/5.);
271  int zdiv = TMath::Nint(2*z/5.);
272 
273  if (fDefinedVtxHistRange == false)
274  {
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);
278 
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);
282  }
283  else
284  {
285  fVertexX = tfs->make<TH1F>("fVertexX", ";x (cm)", xdiv, fVtxPosHistRange[0], fVtxPosHistRange[1]);
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]);
288 
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]);
292  }
293 
294  }
TH1F * fVertexX
vertex location of generated events in x
TH1F * fMuDCosZ
direction cosine of outgoing mu in z
TH2F * fVertexXZ
vertex location in xz
geo::Length_t DetHalfWidth(geo::TPCID const &tpcid) const
Returns the half width of the active volume of the specified TPC.
TH1F * fDeltaE
difference in neutrino energy from MCTruth::Enu() vs TParticle
TH2F * fVertexXY
vertex location in xy
TH1F * fMuDCosY
direction cosine of outgoing mu in y
TH1F * fNCMode
CC interaction mode.
TH1F * fDCosZ
direction cosine in z
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
TH1F * fCCMode
CC interaction mode.
double fPrevTotGoodPOT
Total good POT from subruns previous to current subrun.
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
TH1F * fEDCosX
direction cosine of outgoing e in x
TH1F * fMuDCosX
direction cosine of outgoing mu in x
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.
double fPrevTotPOT
The type of beam.
TH1F * fDCosY
direction cosine in y
TH1F * fEMomentum
momentum of outgoing electrons
TH2F * fVertexYZ
vertex location in yz
TH1F * fECons
histogram to determine if energy is conserved in the event
TH1F * fEDCosZ
direction cosine of outgoing e in z
TH1F * fDCosX
direction cosine in x
list x
Definition: train.py:276
LArSoft geometry interface.
Definition: ChannelGeo.h:16
TH1F * fMuMomentum
momentum of outgoing muons
TH1F * fVertexY
vertex location of generated events in y
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
void evgen::GENIEGen::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 297 of file GENIEGen_module.cc.

298  {
300  run.put(std::make_unique<sumdata::RunData>(geo->DetectorName()));
301  }
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
LArSoft geometry interface.
Definition: ChannelGeo.h:16
void evgen::GENIEGen::beginSubRun ( art::SubRun sr)
virtual

Reimplemented from art::EDProducer.

Definition at line 304 of file GENIEGen_module.cc.

305  {
306 
307  fPrevTotPOT = fGENIEHelp->TotalExposure();
308  fPrevTotGoodPOT = fGENIEHelp->TotalExposure();
309 
310  return;
311  }
double fPrevTotGoodPOT
Total good POT from subruns previous to current subrun.
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
double fPrevTotPOT
The type of beam.
void evgen::GENIEGen::endSubRun ( art::SubRun sr)
virtual

Reimplemented from art::EDProducer.

Definition at line 314 of file GENIEGen_module.cc.

315  {
316 
317  auto p = std::make_unique<sumdata::POTSummary>();
318 
319  p->totpot = fGENIEHelp->TotalExposure() - fPrevTotPOT;
320  p->totgoodpot = fGENIEHelp->TotalExposure() - fPrevTotGoodPOT;
321 
322  sr.put(std::move(p));
323 
324  return;
325  }
double fPrevTotGoodPOT
Total good POT from subruns previous to current subrun.
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
def move(depos, offset)
Definition: depos.py:107
p
Definition: test.py:223
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
double fPrevTotPOT
The type of beam.
void evgen::GENIEGen::FillHistograms ( simb::MCTruth  mc)
private

< fill the vertex histograms from the neutrino - that is always particle 0 in the list

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

Definition at line 478 of file GENIEGen_module.cc.

479  {
480  // Decide which histograms to put the spectrum in
481  int id = -1;
482  if (mc.GetNeutrino().CCNC()==simb::kCC) {
483  fCCMode->Fill(mc.GetNeutrino().Mode());
484  if (mc.GetNeutrino().Nu().PdgCode() == 12) id = 0;
485  else if (mc.GetNeutrino().Nu().PdgCode() == -12) id = 1;
486  else if (mc.GetNeutrino().Nu().PdgCode() == 14) id = 2;
487  else if (mc.GetNeutrino().Nu().PdgCode() == -14) id = 3;
488  else return;
489  }
490  else {
491  fNCMode->Fill(mc.GetNeutrino().Mode());
492  if (mc.GetNeutrino().Nu().PdgCode() > 0) id = 4;
493  else id = 5;
494  }
495  if (id==-1) abort();
496 
497  // Fill the specta histograms
498  fGenerated[id]->Fill(mc.GetNeutrino().Nu().E() );
499 
500  ///< fill the vertex histograms from the neutrino - that is always
501  ///< particle 0 in the list
502  simb::MCNeutrino mcnu = mc.GetNeutrino();
503  const simb::MCParticle nu = mcnu.Nu();
504 
505  fVertexX->Fill(nu.Vx());
506  fVertexY->Fill(nu.Vy());
507  fVertexZ->Fill(nu.Vz());
508 
509  fVertexXY->Fill(nu.Vx(), nu.Vy());
510  fVertexXZ->Fill(nu.Vz(), nu.Vx());
511  fVertexYZ->Fill(nu.Vz(), nu.Vy());
512 
513  double mom = nu.P();
514  if(std::abs(mom) > 0.){
515  fDCosX->Fill(nu.Px()/mom);
516  fDCosY->Fill(nu.Py()/mom);
517  fDCosZ->Fill(nu.Pz()/mom);
518  }
519 
520 
521  MF_LOG_DEBUG("GENIEInteractionInformation")
522  << std::endl
523  << "REACTION: " << ReactionChannel(mc.GetNeutrino().CCNC(),mc.GetNeutrino().Mode())
524  << std::endl
525  << "-----------> Particles in the Stack = " << mc.NParticles() << std::endl
526  << std::setiosflags(std::ios::left)
527  << std::setw(20) << "PARTICLE"
528  << std::setiosflags(std::ios::left)
529  << std::setw(32) << "STATUS"
530  << std::setw(18) << "E (GeV)"
531  << std::setw(18) << "m (GeV/c2)"
532  << std::setw(18) << "Ek (GeV)"
533  << std::endl << std::endl;
534 
535  const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
536 
537  // Loop over the particle stack for this event
538  for(int i = 0; i < mc.NParticles(); ++i){
539  simb::MCParticle part(mc.GetParticle(i));
540  std::string name = databasePDG->GetParticle(part.PdgCode())->GetName();
541  int code = part.StatusCode();
543  double mass = part.Mass();
544  double energy = part.E();
545  double Ek = (energy-mass); // Kinetic Energy (GeV)
546  if(status=="kIStStableFinalState"||status=="kIStHadronInTheNucleus")
547  MF_LOG_DEBUG("GENIEFinalState")
548  << std::setiosflags(std::ios::left) << std::setw(20) << name
549  << std::setiosflags(std::ios::left) << std::setw(32) <<status
550  << std::setw(18)<< energy
551  << std::setw(18)<< mass
552  << std::setw(18)<< Ek <<std::endl;
553  else
554  MF_LOG_DEBUG("GENIEFinalState")
555  << std::setiosflags(std::ios::left) << std::setw(20) << name
556  << std::setiosflags(std::ios::left) << std::setw(32) << status
557  << std::setw(18) << energy
558  << std::setw(18) << mass <<std::endl;
559  }
560 
561 
562  if(mc.GetNeutrino().CCNC() == simb::kCC){
563 
564  ///look for the outgoing lepton in the particle stack
565  ///just interested in the first one
566  for(int i = 0; i < mc.NParticles(); ++i){
567  simb::MCParticle part(mc.GetParticle(i));
568  if(abs(part.PdgCode()) == 11){
569  fEMomentum->Fill(part.P());
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());
574  break;
575  }
576  else if(abs(part.PdgCode()) == 13){
577  fMuMomentum->Fill(part.P());
578  fMuDCosX->Fill(part.Px()/part.P());
579  fMuDCosY->Fill(part.Py()/part.P());
580  fMuDCosZ->Fill(part.Pz()/part.P());
581  fECons->Fill(nu.E() - part.E());
582  break;
583  }
584  }// end loop over particles
585  }//end if CC interaction
586 
587  return;
588  }
TH1F * fVertexX
vertex location of generated events in x
std::string ParticleStatus(int StatusCode)
static QCString name
Definition: declinfo.cpp:673
double E(const int i=0) const
Definition: MCParticle.h:233
TH1F * fMuDCosZ
direction cosine of outgoing mu in z
TH2F * fVertexXZ
vertex location in xz
int PdgCode() const
Definition: MCParticle.h:212
int CCNC() const
Definition: MCNeutrino.h:148
const simb::MCNeutrino & GetNeutrino() const
Definition: MCTruth.h:77
double Py(const int i=0) const
Definition: MCParticle.h:231
TH2F * fVertexXY
vertex location in xy
std::string ReactionChannel(int ccnc, int mode)
std::string string
Definition: nybbler.cc:12
TH1F * fMuDCosY
direction cosine of outgoing mu in y
const simb::MCParticle & Nu() const
Definition: MCNeutrino.h:146
double Px(const int i=0) const
Definition: MCParticle.h:230
int NParticles() const
Definition: MCTruth.h:75
TH1F * fNCMode
CC interaction mode.
TH1F * fDCosZ
direction cosine in z
T abs(T value)
TH1F * fEDCosY
direction cosine of outgoing e in y
TH1F * fCCMode
CC interaction mode.
double P(const int i=0) const
Definition: MCParticle.h:234
TH1F * fEDCosX
direction cosine of outgoing e in x
TH1F * fMuDCosX
direction cosine of outgoing mu in x
TH1F * fGenerated[6]
Spectra as generated.
CodeOutputInterface * code
TH1F * fDCosY
direction cosine in y
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
const simb::MCParticle & GetParticle(int i) const
Definition: MCTruth.h:76
double Vx(const int i=0) const
Definition: MCParticle.h:221
TH1F * fEMomentum
momentum of outgoing electrons
TH2F * fVertexYZ
vertex location in yz
TH1F * fECons
histogram to determine if energy is conserved in the event
#define MF_LOG_DEBUG(id)
double Pz(const int i=0) const
Definition: MCParticle.h:232
double Vz(const int i=0) const
Definition: MCParticle.h:223
TH1F * fEDCosZ
direction cosine of outgoing e in z
TH1F * fDCosX
direction cosine in x
Event generator information.
Definition: MCNeutrino.h:18
TH1F * fMuMomentum
momentum of outgoing muons
int Mode() const
Definition: MCNeutrino.h:149
TH1F * fVertexY
vertex location of generated events in y
TH1F * fVertexZ
vertex location of generated events in z
double Vy(const int i=0) const
Definition: MCParticle.h:222
QTextStream & endl(QTextStream &s)
std::string evgen::GENIEGen::ParticleStatus ( int  StatusCode)
private

Definition at line 407 of file GENIEGen_module.cc.

408  {
409  int code = StatusCode;
411 
412  switch(code)
413  {
414  case -1:
415  ParticleStatusName = "kIStUndefined";
416  break;
417  case 0:
418  ParticleStatusName = "kIStInitialState";
419  break;
420  case 1:
421  ParticleStatusName = "kIStStableFinalState";
422  break;
423  case 2:
424  ParticleStatusName = "kIStIntermediateState";
425  break;
426  case 3:
427  ParticleStatusName = "kIStDecayedState";
428  break;
429  case 11:
430  ParticleStatusName = "kIStNucleonTarget";
431  break;
432  case 12:
433  ParticleStatusName = "kIStDISPreFragmHadronicState";
434  break;
435  case 13:
436  ParticleStatusName = "kIStPreDecayResonantState";
437  break;
438  case 14:
439  ParticleStatusName = "kIStHadronInTheNucleus";
440  break;
441  case 15:
442  ParticleStatusName = "kIStFinalStateNuclearRemnant";
443  break;
444  case 16:
445  ParticleStatusName = "kIStNucleonClusterTarget";
446  break;
447  default:
448  ParticleStatusName = "Status Unknown";
449  }
450  return ParticleStatusName;
451  }
std::string string
Definition: nybbler.cc:12
CodeOutputInterface * code
std::string ParticleStatusName(int code)
Describes the status of a particle (simb::MCParticle::StatusCode()).
void evgen::GENIEGen::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 328 of file GENIEGen_module.cc.

329  {
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 >);
333  std::unique_ptr< art::Assns<simb::MCTruth, simb::MCFlux> > tfassn(new art::Assns<simb::MCTruth, simb::MCFlux>);
334  std::unique_ptr< art::Assns<simb::MCTruth, simb::GTruth> > tgtassn(new art::Assns<simb::MCTruth, simb::GTruth>);
335  std::unique_ptr< std::vector<sim::BeamGateInfo> > gateCollection(new std::vector<sim::BeamGateInfo>);
336 
337  while(truthcol->size() < 1){
338  while(!fGENIEHelp->Stop()){
339 
340  simb::MCTruth truth;
341  simb::MCFlux flux;
342  simb::GTruth gTruth;
343 
344  // GENIEHelper returns a false in the sample method if
345  // either no neutrino was generated, or the interaction
346  // occurred beyond the detector's z extent - ie something we
347  // would never see anyway.
348  if(fGENIEHelp->Sample(truth, flux, gTruth)){
349 
350  truthcol ->push_back(truth);
351  fluxcol ->push_back(flux);
352  gtruthcol->push_back(gTruth);
353  auto const truthPtr = art::PtrMaker<simb::MCTruth>{evt}(truthcol->size() - 1);
354  tfassn->addSingle(truthPtr, art::PtrMaker<simb::MCFlux>{evt}(fluxcol->size() - 1));
355  tgtassn->addSingle(truthPtr, art::PtrMaker<simb::GTruth>{evt}(gtruthcol->size() - 1));
356 
357  FillHistograms(truth);
358 
359  // check that the process code is not unsupported by GENIE
360  // (see issue #18025 for reference);
361  // if it is, print all the information we can about this truth record
362  if (truth.NeutrinoSet() && (truth.GetNeutrino().InteractionType() == simb::kNuanceOffset)) {
363  mf::LogWarning log("GENIEmissingProcessMapping");
364  log << "Found an interaction that is not represented by the interaction type code in GENIE:"
365  "\nMCTruth record:"
366  "\n"
367  ;
368  sim::dump::DumpMCTruth(log, truth, 2U); // 2 trajectory points per line
369  log <<
370  "\nGENIE truth record:"
371  "\n"
372  ;
373  sim::dump::DumpGTruth(log, gTruth);
374  } // if
375 
376  }// end if genie was able to make an event
377 
378  }// end event generation loop
379 
380  // check to see if we are to pass empty spills
381  if(truthcol->size() < 1 && fPassEmptySpills){
382  MF_LOG_DEBUG("GENIEGen") << "no events made for this spill but "
383  << "passing it on and ending the event anyway";
384  break;
385  }
386 
387  }// end loop while no interactions are made
388 
389  // Create a simulated "beam gate" for these neutrino events.
390  // We're creating a vector of these because, in a
391  // distant-but-possible future, we may be generating more than one
392  // beam gate within a simulated time window.
393  gateCollection->push_back(sim::BeamGateInfo( fGlobalTimeOffset, fRandomTimeOffset, fBeamType ));
394 
395  // put the collections in the event
396  evt.put(std::move(truthcol));
397  evt.put(std::move(fluxcol));
398  evt.put(std::move(gtruthcol));
399  evt.put(std::move(tfassn));
400  evt.put(std::move(tgtassn));
401  evt.put(std::move(gateCollection));
402 
403  return;
404  }
const simb::MCNeutrino & GetNeutrino() const
Definition: MCTruth.h:77
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.
Definition: MCDumpers.h:378
offset to account for adding in Nuance codes to this enum
Definition: MCNeutrino.h:95
::sim::BeamType_t fBeamType
The width of a simulated "beam gate".
int InteractionType() const
Definition: MCNeutrino.h:150
int fPassEmptySpills
whether or not to kill evnets with no interactions
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
def move(depos, offset)
Definition: depos.py:107
double fGlobalTimeOffset
keep track of how long it takes to run the job
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.
Definition: MCDumpers.h:345
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
#define MF_LOG_DEBUG(id)
bool NeutrinoSet() const
Definition: MCTruth.h:78
Event generator information.
Definition: MCTruth.h:32
void FillHistograms(simb::MCTruth mc)
double fRandomTimeOffset
The start of a simulated "beam gate".
std::string evgen::GENIEGen::ReactionChannel ( int  ccnc,
int  mode 
)
private

Definition at line 454 of file GENIEGen_module.cc.

455  {
456  std::string ReactionChannelName=" ";
457 
458  if(ccnc==0)
459  ReactionChannelName = "kCC";
460  else if(ccnc==1)
461  ReactionChannelName = "kNC";
462  else std::cout<<"Current mode unknown!! "<<std::endl;
463 
464  if(mode==0)
465  ReactionChannelName += "_kQE";
466  else if(mode==1)
467  ReactionChannelName += "_kRes";
468  else if(mode==2)
469  ReactionChannelName += "_kDIS";
470  else if(mode==3)
471  ReactionChannelName += "_kCoh";
472  else std::cout<<"interaction mode unknown!! "<<std::endl;
473 
474  return ReactionChannelName;
475  }
std::string string
Definition: nybbler.cc:12
QTextStream & endl(QTextStream &s)

Member Data Documentation

::sim::BeamType_t evgen::GENIEGen::fBeamType
private

The width of a simulated "beam gate".

Definition at line 108 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fCCMode
private

CC interaction mode.

Definition at line 137 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fDCosX
private

direction cosine in x

Definition at line 123 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fDCosY
private

direction cosine in y

Definition at line 124 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fDCosZ
private

direction cosine in z

Definition at line 125 of file GENIEGen_module.cc.

bool evgen::GENIEGen::fDefinedVtxHistRange
private

Definition at line 100 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fDeltaE
private

difference in neutrino energy from MCTruth::Enu() vs TParticle

Definition at line 140 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fECons
private

histogram to determine if energy is conserved in the event

Definition at line 141 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fEDCosX
private

direction cosine of outgoing e in x

Definition at line 133 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fEDCosY
private

direction cosine of outgoing e in y

Definition at line 134 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fEDCosZ
private

direction cosine of outgoing e in z

Definition at line 135 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fEMomentum
private

momentum of outgoing electrons

Definition at line 132 of file GENIEGen_module.cc.

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

Spectra as generated.

Definition at line 113 of file GENIEGen_module.cc.

evgb::GENIEHelper* evgen::GENIEGen::fGENIEHelp
private

GENIEHelper object.

Definition at line 99 of file GENIEGen_module.cc.

double evgen::GENIEGen::fGlobalTimeOffset
private

keep track of how long it takes to run the job

Definition at line 106 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fMuDCosX
private

direction cosine of outgoing mu in x

Definition at line 128 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fMuDCosY
private

direction cosine of outgoing mu in y

Definition at line 129 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fMuDCosZ
private

direction cosine of outgoing mu in z

Definition at line 130 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fMuMomentum
private

momentum of outgoing muons

Definition at line 127 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fNCMode
private

CC interaction mode.

Definition at line 138 of file GENIEGen_module.cc.

int evgen::GENIEGen::fPassEmptySpills
private

whether or not to kill evnets with no interactions

Definition at line 103 of file GENIEGen_module.cc.

double evgen::GENIEGen::fPrevTotGoodPOT
private

Total good POT from subruns previous to current subrun.

Definition at line 111 of file GENIEGen_module.cc.

double evgen::GENIEGen::fPrevTotPOT
private

The type of beam.

Total POT from subruns previous to current subrun

Definition at line 110 of file GENIEGen_module.cc.

double evgen::GENIEGen::fRandomTimeOffset
private

The start of a simulated "beam gate".

Definition at line 107 of file GENIEGen_module.cc.

TStopwatch evgen::GENIEGen::fStopwatch
private

Definition at line 104 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fVertexX
private

vertex location of generated events in x

Definition at line 115 of file GENIEGen_module.cc.

TH2F* evgen::GENIEGen::fVertexXY
private

vertex location in xy

Definition at line 119 of file GENIEGen_module.cc.

TH2F* evgen::GENIEGen::fVertexXZ
private

vertex location in xz

Definition at line 120 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fVertexY
private

vertex location of generated events in y

Definition at line 116 of file GENIEGen_module.cc.

TH2F* evgen::GENIEGen::fVertexYZ
private

vertex location in yz

Definition at line 121 of file GENIEGen_module.cc.

TH1F* evgen::GENIEGen::fVertexZ
private

vertex location of generated events in z

Definition at line 117 of file GENIEGen_module.cc.

std::vector< double > evgen::GENIEGen::fVtxPosHistRange
private

use defined hist range; it is useful to have for asymmetric ranges like in DP FD.

Definition at line 101 of file GENIEGen_module.cc.


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