LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
evgen::SpectrumVolumeGen Class Reference
Inheritance diagram for evgen::SpectrumVolumeGen:
evgen::BaseRadioGen 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

 SpectrumVolumeGen (fhicl::ParameterSet const &pset)
 
void produce (art::Event &evt)
 
void beginRun (art::Run &run)
 
void beginJob ()
 
void endJob ()
 
virtual void beginRun_radio (art::Run &)
 
virtual void beginJob_radio ()
 
virtual void endJob_radio ()
 
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

int GetNDecays ()
 
bool GetGoodPositionTime (TLorentzVector &position)
 
TLorentzVector dirCalc (double p, double m)
 
void FillHistos (simb::MCParticle &part)
 
CLHEP::HepRandomEngine & GetRandomEngine ()
 
int GetNEvents ()
 
void GetTs (double &T0, double &T1)
 
void GetXs (double &X0, double &X1)
 
void GetYs (double &Y0, double &Y1)
 
void GetZs (double &Z0, double &Z1)
 
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 ()
 

Protected Attributes

std::vector< std::string > m_isotope
 isotope to simulate. Example: "Ar39" More...
 

Private Member Functions

void produce_radio (art::Event &evt)
 

Private Attributes

int m_pdg
 
double m_mass
 
TH1D * m_spectrum
 

Detailed Description

Module to generate particles created by radiological decay, patterend off of SingleGen Currently it generates only in rectangular prisms oriented along the x,y,z axes

Definition at line 16 of file SpectrumVolumeGen_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::SpectrumVolumeGen::SpectrumVolumeGen ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 32 of file SpectrumVolumeGen_module.cc.

References fhicl::ParameterSet::get(), fhicl::ParameterSet::get_if_present(), evgen::BaseRadioGen::m_isotope, m_mass, m_pdg, m_spectrum, MF_LOG_WARNING, x, and y.

32  : BaseRadioGen(pset)
33  {
34  std::string isotope = "";
35  isotope = pset.get<std::string>("isotope");
36  m_pdg = pset.get<int>("isotope");
37 
38  bool mass_specified = pset.get_if_present<double>("mass", m_mass);
39  if (not mass_specified) {
40  const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
41  const TParticlePDG* definition = databasePDG->GetParticle(m_pdg);
42  // Check that the particle is known to ROOT. If not, this is
43  // not a major error; Geant4 has an internal particle coding
44  // scheme for nuclei that ROOT doesn't recognize.
45  if (definition != 0) { m_mass = definition->Mass(); }
46  else {
47  throw cet::exception("SpectrumVolumeGen") << "Cannot find the particle pdg " << m_pdg;
48  }
49  }
50 
51  m_isotope.push_back(isotope);
52 
53  double min_p = 0, max_p = 0;
54  std::vector<double> bins;
55  bool minmax_mode = pset.get_if_present<double>("spectrum_p_min", min_p);
56  if (minmax_mode) { max_p = pset.get<double>("spectrum_p_max"); }
57  else {
58  bins = pset.get<std::vector<double>>("bins");
59  }
60 
61  std::string function;
62  std::vector<double> parameters;
63  bool have_params;
64  std::vector<double> spectrum;
65  bool func_mode = pset.get_if_present<std::string>("function", function);
66 
67  if (func_mode) {
68  have_params = pset.get_if_present<std::vector<double>>("parameters", parameters);
69  }
70  else {
71  spectrum = pset.get<std::vector<double>>("spectrum");
72  }
73 
74  if (func_mode and minmax_mode) {
75  int nbins = pset.get<int>("nbins");
76  TF1 the_func("spect_func", function.c_str(), min_p, max_p);
77  if (have_params) the_func.SetParameters(parameters.data());
78 
79  m_spectrum = new TH1D("spectrum", ";p [GeV];PDF", nbins, min_p, max_p);
80 
81  for (int ibin = 1; ibin < nbins + 1; ++ibin) {
82  double x = m_spectrum->GetBinCenter(ibin);
83  double y = the_func.Eval(x);
84  if (y < 0) y = 0;
85  m_spectrum->SetBinContent(ibin, y);
86  }
87  }
88  else if (func_mode and not minmax_mode) {
89  if (bins.size() <= 1) {
90  throw cet::exception("SpectrumVolumeGen")
91  << "You need to specify more than 1 bin edge to use the \"bins\" option.";
92  }
93  MF_LOG_WARNING("SpectrumVolumeGen")
94  << "\033[31mYou are using a function and non constant binning...\n"
95  << "Please please please check spectrum and momentum distribution are what you actually "
96  "want!\033[0m\n";
97  int nbins = bins.size() - 1;
98 
99  TF1 the_func("spect_func", function.c_str(), *bins.begin(), *bins.rbegin());
100  if (have_params) the_func.SetParameters(parameters.data());
101 
102  m_spectrum = new TH1D("spectrum", ";p [GeV];PDF", nbins, bins.data());
103 
104  for (int ibin = 1; ibin < nbins + 1; ++ibin) {
105  double x = m_spectrum->GetBinCenter(ibin);
106  double y = the_func.Eval(x);
107  if (y < 0) y = 0;
108  m_spectrum->SetBinContent(ibin, y);
109  }
110  }
111  else if (not func_mode and minmax_mode) {
112  int nbins = spectrum.size();
113 
114  m_spectrum = new TH1D("spectrum", ";p [GeV];PDF", nbins, min_p, max_p);
115  for (int ibin = 1; ibin < nbins + 1; ++ibin) {
116  m_spectrum->SetBinContent(ibin, spectrum.at(ibin - 1));
117  }
118  }
119  else {
120  int nbins = spectrum.size();
121  if ((unsigned)nbins != spectrum.size())
122  throw cet::exception("SpectrumVolumeGen") << "spectrum and bins don't have coherent size!";
123 
124  m_spectrum = new TH1D("spectrum", ";p [GeV];PDF", nbins, bins.data());
125 
126  for (int ibin = 1; ibin < nbins + 1; ++ibin) {
127  m_spectrum->SetBinContent(ibin, spectrum.at(ibin - 1));
128  }
129  }
130 
131  m_spectrum->Scale(1. / m_spectrum->Integral());
132 
134  TH1D* sp = tfs->make<TH1D>(*m_spectrum);
135  (void)sp;
136  }
Float_t x
Definition: compare.C:6
Float_t y
Definition: compare.C:6
BaseRadioGen(fhicl::ParameterSet const &pset)
Definition: BaseRadioGen.h:269
std::vector< std::string > m_isotope
isotope to simulate. Example: "Ar39"
Definition: BaseRadioGen.h:90
#define MF_LOG_WARNING(category)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Function Documentation

void evgen::BaseRadioGen::beginJob ( )
inlinevirtualinherited

Reimplemented from art::EDProducer.

Definition at line 490 of file BaseRadioGen.h.

491  {
492  if (m_isotope.empty()) {
493  throw cet::exception("BaseRadioGen")
494  << "m_isotope is empty, you need to fill it yourself in the constructor of your module\n";
495  }
496 
498  beginJob_radio();
499  m_nevent = 0;
500  }
virtual void beginJob_radio()
Definition: BaseRadioGen.h:81
std::vector< std::string > m_isotope
isotope to simulate. Example: "Ar39"
Definition: BaseRadioGen.h:90
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
virtual void evgen::BaseRadioGen::beginJob_radio ( )
inlinevirtualinherited

Reimplemented in evgen::Decay0Gen.

Definition at line 81 of file BaseRadioGen.h.

81 {}
void evgen::BaseRadioGen::beginRun ( art::Run run)
inlinevirtualinherited

Reimplemented from art::EDProducer.

Definition at line 483 of file BaseRadioGen.h.

484  {
486  run.put(std::make_unique<sumdata::RunData>(m_geo_service->DetectorName()), art::fullRun());
487  beginRun_radio(run);
488  }
constexpr auto fullRun()
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Run.h:121
virtual void beginRun_radio(art::Run &)
Definition: BaseRadioGen.h:80
art::ServiceHandle< geo::Geometry const > m_geo_service
Definition: BaseRadioGen.h:157
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.
virtual void evgen::BaseRadioGen::beginRun_radio ( art::Run )
inlinevirtualinherited

Definition at line 80 of file BaseRadioGen.h.

80 {}
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 &)
TLorentzVector evgen::BaseRadioGen::dirCalc ( double  p,
double  m 
)
inlineprotectedinherited

Definition at line 810 of file BaseRadioGen.h.

Referenced by evgen::BaseRadioGen::endJob_radio(), and produce_radio().

811  {
812  // isotropic production angle for the decay product
813  double costheta = (2.0 * m_random_flat.fire() - 1.0);
814 
815  if (costheta < -1.0) costheta = -1.0;
816  if (costheta > 1.0) costheta = 1.0;
817 
818  double const sintheta = sqrt(1.0 - costheta * costheta);
819  double const phi = 2.0 * M_PI * m_random_flat.fire();
820 
821  return TLorentzVector{p * sintheta * std::cos(phi),
822  p * sintheta * std::sin(phi),
823  p * costheta,
824  std::sqrt(p * p + m * m)};
825  }
CLHEP::RandFlat m_random_flat
Definition: BaseRadioGen.h:161
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::BaseRadioGen::endJob ( )
inlinevirtualinherited

Reimplemented from art::EDProducer.

Definition at line 502 of file BaseRadioGen.h.

503  {
504  if (m_nevent) {
505  m_pdg_TH1D->Scale(1. / m_nevent);
506 
507  for (auto histo : m_pos_xy_TH2D) {
508  m_pos_xy_TH2D[histo.first]->Scale(1. / m_nevent);
509  m_pos_xz_TH2D[histo.first]->Scale(1. / m_nevent);
510  m_dir_x_TH1D[histo.first]->Scale(1. / m_nevent);
511  m_dir_y_TH1D[histo.first]->Scale(1. / m_nevent);
512  m_dir_z_TH1D[histo.first]->Scale(1. / m_nevent);
513  m_mom_TH1D[histo.first]->Scale(1. / m_nevent);
514  m_ke_TH1D[histo.first]->Scale(1. / m_nevent);
515  m_time_TH1D[histo.first]->Scale(1. / m_nevent);
516  }
517  }
518  endJob_radio();
519  }
std::map< int, TH1D * > m_dir_y_TH1D
Definition: BaseRadioGen.h:184
std::map< int, TH1D * > m_dir_x_TH1D
Definition: BaseRadioGen.h:183
virtual void endJob_radio()
Definition: BaseRadioGen.h:82
std::map< int, TH1D * > m_mom_TH1D
Definition: BaseRadioGen.h:186
std::map< int, TH1D * > m_ke_TH1D
Definition: BaseRadioGen.h:187
std::map< int, TH1D * > m_dir_z_TH1D
Definition: BaseRadioGen.h:185
std::map< int, TH2D * > m_pos_xz_TH2D
Definition: BaseRadioGen.h:182
std::map< int, TH1D * > m_time_TH1D
Definition: BaseRadioGen.h:188
std::map< int, TH2D * > m_pos_xy_TH2D
Definition: BaseRadioGen.h:181
virtual void evgen::BaseRadioGen::endJob_radio ( )
inlinevirtualinherited
void evgen::BaseRadioGen::FillHistos ( simb::MCParticle part)
inlineprotectedinherited

Definition at line 788 of file BaseRadioGen.h.

Referenced by evgen::BaseRadioGen::endJob_radio(), produce_radio(), and evgen::Decay0Gen::produce_radio().

789  {
790  int pdg = part.PdgCode();
791  int simple_pdg = 0;
792  std::string dummy = "";
793  SimplePDG(pdg, simple_pdg, dummy);
794 
795  TLorentzVector position = part.Position();
796  TLorentzVector mom = part.Momentum();
797  double mass = mom.M();
798  m_pos_xy_TH2D[simple_pdg]->Fill(position.X(), position.Y());
799  m_pos_xz_TH2D[simple_pdg]->Fill(position.X(), position.Z());
800  m_dir_x_TH1D[simple_pdg]->Fill(mom.Px() / mom.P());
801  m_dir_y_TH1D[simple_pdg]->Fill(mom.Py() / mom.P());
802  m_dir_z_TH1D[simple_pdg]->Fill(mom.Pz() / mom.P());
803  double ke = (sqrt(mom.P() * mom.P() + mass * mass) - mass) * 1000.;
804  m_ke_TH1D[simple_pdg]->Fill(ke);
805  m_mom_TH1D[simple_pdg]->Fill(mom.P() * 1000.);
806  m_time_TH1D[simple_pdg]->Fill(position.T());
807  m_pdg_TH1D->Fill(simple_pdg);
808  }
void SimplePDG(int pdg, int &simple, std::string &name)
Definition: BaseRadioGen.h:754
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:220
int PdgCode() const
Definition: MCParticle.h:213
std::map< int, TH1D * > m_dir_y_TH1D
Definition: BaseRadioGen.h:184
std::map< int, TH1D * > m_dir_x_TH1D
Definition: BaseRadioGen.h:183
std::map< int, TH1D * > m_mom_TH1D
Definition: BaseRadioGen.h:186
std::map< int, TH1D * > m_ke_TH1D
Definition: BaseRadioGen.h:187
std::map< int, TH1D * > m_dir_z_TH1D
Definition: BaseRadioGen.h:185
const TLorentzVector & Momentum(const int i=0) const
Definition: MCParticle.h:221
std::map< int, TH2D * > m_pos_xz_TH2D
Definition: BaseRadioGen.h:182
std::map< int, TH1D * > m_time_TH1D
Definition: BaseRadioGen.h:188
std::map< int, TH2D * > m_pos_xy_TH2D
Definition: BaseRadioGen.h:181
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
bool evgen::BaseRadioGen::GetGoodPositionTime ( TLorentzVector &  position)
inlineprotectedinherited

Deal with the time first

We use all the XYZ that have been set earlier, until we find the correct volume and material

We use the list of nodes

Definition at line 521 of file BaseRadioGen.h.

Referenced by evgen::BaseRadioGen::endJob_radio(), produce_radio(), and evgen::Decay0Gen::produce_radio().

522  {
523 
525  double time = m_T0 + m_random_flat.fire() * (m_T1 - m_T0);
526 
527  if (not m_geo_volume_mode) {
529 
530  size_t n_tries = 0;
531 
532  double xpos = std::numeric_limits<double>::signaling_NaN();
533  double ypos = std::numeric_limits<double>::signaling_NaN();
534  double zpos = std::numeric_limits<double>::signaling_NaN();
535 
536  while (n_tries++ < m_max_tries_event) {
537 
538  if (m_distrib_xpos)
539  xpos = m_distrib_xpos->GetRandom(m_X0, m_X1);
540  else
541  xpos = m_X0 + m_random_flat.fire() * (m_X1 - m_X0);
542 
543  if (m_distrib_ypos)
544  ypos = m_distrib_ypos->GetRandom(m_Y0, m_Y1);
545  else
546  ypos = m_Y0 + m_random_flat.fire() * (m_Y1 - m_Y0);
547 
548  if (m_distrib_zpos)
549  zpos = m_distrib_zpos->GetRandom(m_Z0, m_Z1);
550  else
551  zpos = m_Z0 + m_random_flat.fire() * (m_Z1 - m_Z0);
552 
553  auto node = gGeoManager->FindNode(xpos, ypos, zpos);
554 
555  if (NodeSupported(node)) break;
556  }
557 
558  if (std::isnan(xpos) or std::isnan(ypos) or std::isnan(zpos)) {
559  MF_LOG_ERROR("BaseRadioGen") << "Error in generation of random position!";
560  }
561 
562  position.SetXYZT(xpos, ypos, zpos, time);
563  return true;
564  }
565  else {
567 
568  if (m_good_nodes.empty() or m_volume_cc == 0)
569  MF_LOG_ERROR("BaseRadioGen") << "There is no node to throw events in!";
570 
571  double which_vol = m_random_flat.fire() * m_volume_cc;
572 
573  const TGeoNode* node = nullptr;
574  size_t i = 0;
575 
576  for (auto const& nd : m_good_nodes) {
577  if (which_vol < nd.second) {
578  node = nd.first;
579  break;
580  }
581  i++;
582  }
583 
584  const TGeoNode* world = gGeoManager->GetNode(0);
585  double x_min, x_max;
586  double y_min, y_max;
587  double z_min, z_max;
588  GetNodeXYZMinMax(node, world, x_min, x_max, y_min, y_max, z_min, z_max);
589 
590  size_t n_tries = 0;
591 
592  while (n_tries++ < m_max_tries_event) {
593  double xpos = std::numeric_limits<double>::signaling_NaN();
594  double ypos = std::numeric_limits<double>::signaling_NaN();
595  double zpos = std::numeric_limits<double>::signaling_NaN();
596 
597  if (m_distrib_xpos)
598  xpos = m_distrib_xpos->GetRandom(x_min, x_max);
599  else
600  xpos = x_min + m_random_flat.fire() * (x_max - x_min);
601 
602  if (m_distrib_ypos)
603  ypos = m_distrib_ypos->GetRandom(y_min, y_max);
604  else
605  ypos = y_min + m_random_flat.fire() * (y_max - y_min);
606 
607  if (m_distrib_zpos)
608  zpos = m_distrib_zpos->GetRandom(z_min, z_max);
609  else
610  zpos = z_min + m_random_flat.fire() * (z_max - z_min);
611 
612  if (std::isnan(xpos) or std::isnan(ypos) or std::isnan(zpos)) {
613  MF_LOG_ERROR("BaseRadioGen") << "Error in generation of random position!";
614  }
615  position.SetXYZT(xpos, ypos, zpos, time);
616 
617  const TGeoNode* node_generated = gGeoManager->FindNode(xpos, ypos, zpos);
618  if (node_generated == node) return true;
619 
620  if (node->GetNdaughters() and IsDaughterNode(node_generated, node)) return true;
621  }
622  }
623 
624  return false;
625  }
double m_X1
Top corner x position (cm) in world coordinates.
Definition: BaseRadioGen.h:152
std::map< const TGeoNode *, double > m_good_nodes
Definition: BaseRadioGen.h:172
bool NodeSupported(TGeoNode const *node) const
Definition: BaseRadioGen.h:192
#define MF_LOG_ERROR(category)
STL namespace.
double x_min
Definition: berger.C:15
double m_Y1
Top corner y position (cm) in world coordinates.
Definition: BaseRadioGen.h:153
double m_Z1
Top corner z position (cm) in world coordinates.
Definition: BaseRadioGen.h:154
double m_T0
Beginning of time window to simulate in ns.
Definition: BaseRadioGen.h:147
double x_max
Definition: berger.C:16
double m_Z0
Bottom corner z position (cm) in world coordinates.
Definition: BaseRadioGen.h:151
bool IsDaughterNode(const TGeoNode *daughter_node, const TGeoNode *mother_node)
Definition: BaseRadioGen.h:639
CLHEP::RandFlat m_random_flat
Definition: BaseRadioGen.h:161
double m_Y0
Bottom corner y position (cm) in world coordinates.
Definition: BaseRadioGen.h:150
double m_X0
Bottom corner x position (cm) in world coordinates.
Definition: BaseRadioGen.h:149
double m_T1
End of time window to simulate in ns.
Definition: BaseRadioGen.h:148
void GetNodeXYZMinMax(const TGeoNode *from, const TGeoNode *to, double &x_min, double &x_max, double &y_min, double &y_max, double &z_min, double &z_max)
Definition: BaseRadioGen.h:199
int evgen::BaseRadioGen::GetNDecays ( )
inlineprotectedinherited

Definition at line 629 of file BaseRadioGen.h.

Referenced by evgen::BaseRadioGen::endJob_radio(), produce_radio(), and evgen::Decay0Gen::produce_radio().

630  {
631 
632  if (m_rate_mode) { return m_random_poisson.fire(m_rate); }
633  else {
634  double rate = abs(m_Bq * (m_T1 - m_T0) * m_volume_cc / 1.0E9);
635  return m_random_poisson.fire(rate);
636  }
637  }
CLHEP::RandPoisson m_random_poisson
Definition: BaseRadioGen.h:162
constexpr auto abs(T v)
Returns the absolute value of the argument.
double m_rate
Radioactivity in Becquerels (decay per sec) use either of this of Bq.
Definition: BaseRadioGen.h:145
double m_T0
Beginning of time window to simulate in ns.
Definition: BaseRadioGen.h:147
double m_Bq
Radioactivity in Becquerels (decay per sec) per cubic cm.
Definition: BaseRadioGen.h:144
double m_T1
End of time window to simulate in ns.
Definition: BaseRadioGen.h:148
int evgen::BaseRadioGen::GetNEvents ( )
inlineprotectedinherited

Definition at line 93 of file BaseRadioGen.h.

References evgen::BaseRadioGen::m_nevent.

Referenced by evgen::Decay0Gen::endJob_radio().

93 { return m_nevent; }
CLHEP::HepRandomEngine& evgen::BaseRadioGen::GetRandomEngine ( )
inlineprotectedinherited

Definition at line 92 of file BaseRadioGen.h.

References evgen::BaseRadioGen::m_engine.

Referenced by evgen::Decay0Gen::Decay0Gen().

92 { return m_engine; }
CLHEP::HepRandomEngine & m_engine
Definition: BaseRadioGen.h:160
void evgen::BaseRadioGen::GetTs ( double &  T0,
double &  T1 
)
inlineprotectedinherited

Definition at line 94 of file BaseRadioGen.h.

References evgen::BaseRadioGen::m_T0, and evgen::BaseRadioGen::m_T1.

Referenced by evgen::Decay0Gen::beginJob_radio().

95  {
96  T0 = m_T0;
97  T1 = m_T1;
98  }
double m_T0
Beginning of time window to simulate in ns.
Definition: BaseRadioGen.h:147
double m_T1
End of time window to simulate in ns.
Definition: BaseRadioGen.h:148
void evgen::BaseRadioGen::GetXs ( double &  X0,
double &  X1 
)
inlineprotectedinherited

Definition at line 99 of file BaseRadioGen.h.

References evgen::BaseRadioGen::m_X0, and evgen::BaseRadioGen::m_X1.

100  {
101  X0 = m_X0;
102  X1 = m_X1;
103  }
double m_X1
Top corner x position (cm) in world coordinates.
Definition: BaseRadioGen.h:152
Double_t X1
Definition: plot.C:263
double m_X0
Bottom corner x position (cm) in world coordinates.
Definition: BaseRadioGen.h:149
void evgen::BaseRadioGen::GetYs ( double &  Y0,
double &  Y1 
)
inlineprotectedinherited

Definition at line 104 of file BaseRadioGen.h.

References evgen::BaseRadioGen::m_Y0, and evgen::BaseRadioGen::m_Y1.

105  {
106  Y0 = m_Y0;
107  Y1 = m_Y1;
108  }
double m_Y1
Top corner y position (cm) in world coordinates.
Definition: BaseRadioGen.h:153
Double_t Y1
Definition: plot.C:263
double m_Y0
Bottom corner y position (cm) in world coordinates.
Definition: BaseRadioGen.h:150
void evgen::BaseRadioGen::GetZs ( double &  Z0,
double &  Z1 
)
inlineprotectedinherited

Definition at line 109 of file BaseRadioGen.h.

References evgen::BaseRadioGen::CalculateActiveVolumeFromAllNodes(), evgen::BaseRadioGen::CalculateActiveVolumeFromXYZ(), evgen::BaseRadioGen::DeclareOutputHistos(), evgen::BaseRadioGen::m_Z0, evgen::BaseRadioGen::m_Z1, and evgen::BaseRadioGen::SimplePDG().

110  {
111  Z0 = m_Z0;
112  Z1 = m_Z1;
113  }
double m_Z1
Top corner z position (cm) in world coordinates.
Definition: BaseRadioGen.h:154
Double_t Z1
Definition: plot.C:263
double m_Z0
Bottom corner z position (cm) in world coordinates.
Definition: BaseRadioGen.h:151
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
void evgen::BaseRadioGen::produce ( art::Event evt)
inlinevirtualinherited

Implements art::EDProducer.

Definition at line 477 of file BaseRadioGen.h.

478  {
479  m_nevent++;
480  produce_radio(evt);
481  }
virtual void produce_radio(art::Event &evt)=0
void evgen::SpectrumVolumeGen::produce_radio ( art::Event evt)
privatevirtual

Implements evgen::BaseRadioGen.

Definition at line 139 of file SpectrumVolumeGen_module.cc.

References simb::MCTruth::Add(), simb::MCParticle::AddTrajectoryPoint(), DEFINE_ART_MODULE, evgen::BaseRadioGen::dirCalc(), evgen::BaseRadioGen::FillHistos(), evgen::BaseRadioGen::GetGoodPositionTime(), evgen::BaseRadioGen::GetNDecays(), simb::kSingleParticle, m_mass, m_pdg, m_spectrum, MF_LOG_DEBUG, part, art::Event::put(), and simb::MCTruth::SetOrigin().

140  {
141 
142  //unique_ptr allows ownership to be transferred to the art::Event after the put statement
143  std::unique_ptr<std::vector<simb::MCTruth>> truthcol(new std::vector<simb::MCTruth>);
144 
145  simb::MCTruth truth;
147  int track_id = -1;
148  const std::string primary_str("primary");
149 
150  int n_decay = GetNDecays();
151 
152  for (int iDecay = 0; iDecay < n_decay; ++iDecay) {
153  TLorentzVector position;
154 
155  if (GetGoodPositionTime(position)) {
156  simb::MCParticle part(track_id, m_pdg, primary_str);
157 
158  TLorentzVector momentum = dirCalc(m_spectrum->GetRandom(), m_mass);
159  part.AddTrajectoryPoint(position, momentum);
160 
161  truth.Add(part);
162  FillHistos(part);
163 
164  track_id--;
165  } // GetGoodPosition
166  } // idecay
167 
168  MF_LOG_DEBUG("SpectrumVolumeGen") << truth;
169  truthcol->push_back(truth);
170  evt.put(std::move(truthcol));
171  }
void SetOrigin(simb::Origin_t origin)
Definition: MCTruth.h:82
TLorentzVector dirCalc(double p, double m)
Definition: BaseRadioGen.h:810
void FillHistos(simb::MCParticle &part)
Definition: BaseRadioGen.h:788
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
TString part[npart]
Definition: Style.C:32
single particles thrown at the detector
Definition: MCTruth.h:26
bool GetGoodPositionTime(TLorentzVector &position)
Definition: BaseRadioGen.h:521
void Add(simb::MCParticle const &part)
Definition: MCTruth.h:80
#define MF_LOG_DEBUG(id)
Event generator information.
Definition: MCTruth.h:32
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

std::vector<std::string> evgen::BaseRadioGen::m_isotope
protectedinherited

isotope to simulate. Example: "Ar39"

Definition at line 90 of file BaseRadioGen.h.

Referenced by evgen::Decay0Gen::Decay0Gen(), and SpectrumVolumeGen().

double evgen::SpectrumVolumeGen::m_mass
private

Definition at line 24 of file SpectrumVolumeGen_module.cc.

Referenced by produce_radio(), and SpectrumVolumeGen().

int evgen::SpectrumVolumeGen::m_pdg
private

Definition at line 23 of file SpectrumVolumeGen_module.cc.

Referenced by produce_radio(), and SpectrumVolumeGen().

TH1D* evgen::SpectrumVolumeGen::m_spectrum
private

Definition at line 25 of file SpectrumVolumeGen_module.cc.

Referenced by produce_radio(), and SpectrumVolumeGen().


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