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

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

Inheritance diagram for evgen::CosmicsGen:
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

 CosmicsGen (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
 

Private Attributes

std::vector< double > fbuffbox
 
TH2F * fPhotonAngles
 Photon rate vs angle. More...
 
TH2F * fPhotonAnglesLo
 Photon rate vs angle, low momenta. More...
 
TH2F * fPhotonAnglesMi
 Photon rate vs angle, middle momenta. More...
 
TH2F * fPhotonAnglesHi
 Photon rate vs angle, high momenta. More...
 
TH1F * fPhotonCosQ
 Photon rate vs cos(Q) More...
 
TH1F * fPhotonEnergy
 Photon energy (GeV) More...
 
TH1F * fPhotonsPerSample
 number of photons in the sampled time window More...
 
TH1F * fPhotonsInCStat
 
TH1F * fPhotonsInTPC
 
TH2F * fElectronAngles
 Electron rate vs angle. More...
 
TH2F * fElectronAnglesLo
 Electron rate vs angle, low momenta. More...
 
TH2F * fElectronAnglesMi
 Electron rate vs angle, middle momenta. More...
 
TH2F * fElectronAnglesHi
 Electron rate vs angle, high momenta. More...
 
TH1F * fElectronCosQ
 Electron rate vs cos(Q) More...
 
TH1F * fElectronEnergy
 Electron energy (GeV) More...
 
TH1F * fElectronsPerSample
 number of electrons in the sampled time window More...
 
TH1F * fElectronsInCStat
 
TH1F * fElectronsInTPC
 
TH2F * fMuonAngles
 Muon rate vs angle. More...
 
TH2F * fMuonAnglesLo
 Muon rate vs angle, low momenta. More...
 
TH2F * fMuonAnglesMi
 Muon rate vs angle, middle momenta. More...
 
TH2F * fMuonAnglesHi
 Muon rate vs angle, high momenta. More...
 
TH1F * fMuonCosQ
 Muon rate vs cos(Q) More...
 
TH1F * fMuonEnergy
 Muon energy (GeV) More...
 
TH1F * fMuonsPerSample
 number of muons in the sampled time window More...
 
TH1F * fMuonsInCStat
 
TH1F * fMuonsInTPC
 
CLHEP::HepRandomEngine & fEngine
 art-managed random-number engine More...
 
evgb::CRYHelper fCRYHelp
 CRY generator object. More...
 

Detailed Description

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

Definition at line 37 of file CosmicsGen_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::CosmicsGen::CosmicsGen ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 91 of file CosmicsGen_module.cc.

References art::detail::EngineCreator::createEngine(), fbuffbox, fCRYHelp, and fEngine.

92  : art::EDProducer{pset}
93  , fbuffbox{pset.get<std::vector<double>>("BufferBox", {0.0, 0.0, 0.0, 0.0, 0.0, 0.0})}
94  // create a default random engine; obtain the random seed from NuRandomService,
95  // unless overridden in configuration with key "Seed"
97  pset,
98  "Seed"))
99  , fCRYHelp{pset, fEngine, art::ServiceHandle<geo::Geometry const>{} -> GetWorldVolumeName()}
100  {
101  produces<std::vector<simb::MCTruth>>();
102  produces<sumdata::RunData, art::InRun>();
103  }
base_engine_t & createEngine(seed_t seed)
CLHEP::HepRandomEngine & fEngine
art-managed random-number engine
evgb::CRYHelper fCRYHelp
CRY generator object.
std::vector< double > fbuffbox

Member Function Documentation

void evgen::CosmicsGen::beginJob ( )
overrideprivatevirtual

Reimplemented from art::EDProducer.

Definition at line 106 of file CosmicsGen_module.cc.

References fElectronAngles, fElectronAnglesHi, fElectronAnglesLo, fElectronAnglesMi, fElectronCosQ, fElectronEnergy, fElectronsInCStat, fElectronsInTPC, fElectronsPerSample, fMuonAngles, fMuonAnglesHi, fMuonAnglesLo, fMuonAnglesMi, fMuonCosQ, fMuonEnergy, fMuonsInCStat, fMuonsInTPC, fMuonsPerSample, fPhotonAngles, fPhotonAnglesHi, fPhotonAnglesLo, fPhotonAnglesMi, fPhotonCosQ, fPhotonEnergy, fPhotonsInCStat, fPhotonsInTPC, and fPhotonsPerSample.

107  {
109 
110  fPhotonAngles =
111  tfs->make<TH2F>("fPhotonAngles", ";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
113  tfs->make<TH2F>("fPhotonAnglesLo", ";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
115  tfs->make<TH2F>("fPhotonAnglesMi", ";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
117  tfs->make<TH2F>("fPhotonAnglesHi", ";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
118  fPhotonCosQ = tfs->make<TH1F>("fPhotonCosQ", ";cos#theta;tracks", 50, -1.0, 1.0);
119  fPhotonEnergy = tfs->make<TH1F>("fPhotonEnergy", ";E (GeV)", 5000, 0.0, 1000.0);
121  tfs->make<TH1F>("fPhotonsPerSample", ";Number Photons;Samples", 100, 0, 1000);
123  tfs->make<TH1F>("fPhotonsInCryostat", ";Number Photons;Samples", 100, 0, 1000);
124  fPhotonsInTPC = tfs->make<TH1F>("fPhotonsInTPC", ";Number Photons;Samples", 100, 0, 1000);
125 
127  tfs->make<TH2F>("fElectronAngles", ";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
129  tfs->make<TH2F>("fElectronAnglesLo", ";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
131  tfs->make<TH2F>("fElectronAnglesMi", ";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
133  tfs->make<TH2F>("fElectronAnglesHi", ";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
134  fElectronCosQ = tfs->make<TH1F>("fElectronCosQ", ";cos#theta;tracks", 50, -1.0, 1.0);
135  fElectronEnergy = tfs->make<TH1F>("fElectronEnergy", ";E (GeV)", 5000, 0.0, 1000.0);
137  tfs->make<TH1F>("fElectronsPerSample", ";Number Electrons;Samples", 100, 0, 1000);
139  tfs->make<TH1F>("fElectronsInCryotat", ";Number Electrons;Samples", 100, 0, 1000);
140  fElectronsInTPC = tfs->make<TH1F>("fElectronsInTPC", ";Number Electrons;Samples", 100, 0, 1000);
141 
142  fMuonAngles =
143  tfs->make<TH2F>("fMuonAngles", ";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
144  fMuonAnglesLo =
145  tfs->make<TH2F>("fMuonAnglesLo", ";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
146  fMuonAnglesMi =
147  tfs->make<TH2F>("fMuonAnglesMi", ";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
148  fMuonAnglesHi =
149  tfs->make<TH2F>("fMuonAnglesHi", ";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
150  fMuonCosQ = tfs->make<TH1F>("fMuonCosQ", ";cos#theta;tracks", 50, -1.0, 1.0);
151  fMuonEnergy = tfs->make<TH1F>("fMuonEnergy", ";E (GeV)", 5000, 0.0, 1000.0);
152  fMuonsPerSample = tfs->make<TH1F>("fMuonsPerSample", ";Number Muons;Samples", 100, 0, 1000);
153  fMuonsInCStat = tfs->make<TH1F>("fMuonsInCryostat", ";Number Muons;Samples", 100, 0, 1000);
154  fMuonsInTPC = tfs->make<TH1F>("fMuonsInTPC", ";Number Muons;Samples", 100, 0, 1000);
155  }
TH2F * fElectronAnglesHi
Electron rate vs angle, high momenta.
TH2F * fPhotonAngles
Photon rate vs angle.
TH2F * fMuonAnglesHi
Muon rate vs angle, high momenta.
TH1F * fElectronEnergy
Electron energy (GeV)
TH2F * fElectronAnglesLo
Electron rate vs angle, low momenta.
TH2F * fElectronAngles
Electron rate vs angle.
TH1F * fElectronCosQ
Electron rate vs cos(Q)
TH2F * fMuonAngles
Muon rate vs angle.
TH2F * fMuonAnglesLo
Muon rate vs angle, low momenta.
TH1F * fPhotonEnergy
Photon energy (GeV)
TH2F * fElectronAnglesMi
Electron rate vs angle, middle momenta.
TH1F * fMuonCosQ
Muon rate vs cos(Q)
TH1F * fElectronsPerSample
number of electrons in the sampled time window
TH1F * fPhotonsPerSample
number of photons in the sampled time window
TH1F * fPhotonCosQ
Photon rate vs cos(Q)
TH2F * fMuonAnglesMi
Muon rate vs angle, middle momenta.
TH2F * fPhotonAnglesMi
Photon rate vs angle, middle momenta.
TH2F * fPhotonAnglesLo
Photon rate vs angle, low momenta.
TH2F * fPhotonAnglesHi
Photon rate vs angle, high momenta.
TH1F * fMuonsPerSample
number of muons in the sampled time window
TH1F * fMuonEnergy
Muon energy (GeV)
void evgen::CosmicsGen::beginRun ( art::Run run)
overrideprivatevirtual

Reimplemented from art::EDProducer.

Definition at line 158 of file CosmicsGen_module.cc.

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

159  {
161  run.put(std::make_unique<sumdata::RunData>(geo->DetectorName()), art::fullRun());
162  }
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 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
void evgen::CosmicsGen::produce ( art::Event evt)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 165 of file CosmicsGen_module.cc.

References util::abs(), simb::MCTruth::Add(), DEFINE_ART_MODULE, geo::GeometryCore::DetLength(), fbuffbox, fCRYHelp, fElectronAngles, fElectronAnglesHi, fElectronAnglesLo, fElectronAnglesMi, fElectronCosQ, fElectronEnergy, fElectronsInCStat, fElectronsPerSample, fMuonAngles, fMuonAnglesHi, fMuonAnglesLo, fMuonAnglesMi, fMuonCosQ, fMuonEnergy, fMuonsInCStat, fMuonsPerSample, fPhotonAngles, fPhotonAnglesHi, fPhotonAnglesLo, fPhotonAnglesMi, fPhotonCosQ, fPhotonEnergy, fPhotonsInCStat, fPhotonsPerSample, simb::MCTruth::GetParticle(), geo::GeometryCore::Iterate(), simb::kCosmicRay, simb::MCParticle::Momentum(), simb::MCTruth::NParticles(), simb::MCParticle::PdgCode(), simb::MCParticle::Position(), art::Event::put(), evgb::CRYHelper::Sample(), simb::MCTruth::SetOrigin(), and geo::GeometryCore::SurfaceY().

166  {
167  std::unique_ptr<std::vector<simb::MCTruth>> truthcol(new std::vector<simb::MCTruth>);
168 
169  // fill some histograms about this event
171 
172  int nCrossCryostat = 0;
173 
174  simb::MCTruth truth;
175 
176  while (nCrossCryostat < 1) {
177 
178  simb::MCTruth pretruth;
180  fCRYHelp.Sample(pretruth, geom->SurfaceY(), geom->DetLength(), 0);
181 
182  int numPhotons = 0;
183  int numElectrons = 0;
184  int numMuons = 0;
185  int allPhotons = 0;
186  int allElectrons = 0;
187  int allMuons = 0;
188 
189  // loop over particles in the truth object
190  for (int i = 0; i < pretruth.NParticles(); ++i) {
191  simb::MCParticle particle = pretruth.GetParticle(i);
192  const TLorentzVector& v4 = particle.Position();
193  const TLorentzVector& p4 = particle.Momentum();
194  double x0[3] = {v4.X(), v4.Y(), v4.Z()};
195  double dx[3] = {p4.Px(), p4.Py(), p4.Pz()};
196 
197  if (std::abs(particle.PdgCode()) == 13)
198  ++allMuons;
199  else if (std::abs(particle.PdgCode()) == 22)
200  ++allPhotons;
201  else if (std::abs(particle.PdgCode()) == 11)
202  ++allElectrons;
203 
204  TH1F* hCosQ = nullptr;
205  TH2F* hAngles = nullptr;
206  TH2F* hAnglesLo = nullptr;
207  TH2F* hAnglesMi = nullptr;
208  TH2F* hAnglesHi = nullptr;
209  TH1F* hEnergy = nullptr;
210  if (std::abs(particle.PdgCode()) == 13) {
211  hCosQ = fMuonCosQ;
212  hAngles = fMuonAngles;
213  hAnglesLo = fMuonAnglesLo;
214  hAnglesMi = fMuonAnglesMi;
215  hAnglesHi = fMuonAnglesHi;
216  hEnergy = fMuonEnergy;
217  }
218  else if (std::abs(particle.PdgCode()) == 22) {
219  hCosQ = fPhotonCosQ;
220  hAngles = fPhotonAngles;
221  hAnglesLo = fPhotonAnglesLo;
222  hAnglesMi = fPhotonAnglesMi;
223  hAnglesHi = fPhotonAnglesHi;
224  hEnergy = fPhotonEnergy;
225  }
226  else if (std::abs(particle.PdgCode()) == 11) {
227  hCosQ = fElectronCosQ;
228  hAngles = fElectronAngles;
229  hAnglesLo = fElectronAnglesLo;
230  hAnglesMi = fElectronAnglesMi;
231  hAnglesHi = fElectronAnglesHi;
232  hEnergy = fElectronEnergy;
233  }
234 
235  // now check if the particle goes through any cryostat in the detector
236  // if so, add it to the truth object.
237  for (auto const& cryostat : geom->Iterate<geo::CryostatGeo>()) {
238 
239  double bounds[6] = {0.};
240  cryostat.Boundaries(bounds);
241 
242  //add a buffer box around the cryostat bounds to increase the acceptance
243  //(geometrically) at the CRY level to make up for particles we will loose
244  //due to multiple scattering effects that pitch in during GEANT4 tracking
245  //By default, the buffer box has zero size
246  for (unsigned int cb = 0; cb < 6; cb++)
247  bounds[cb] = bounds[cb] + fbuffbox[cb];
248 
249  //calculate the intersection point with each cryostat surface
250  bool intersects_cryo = false;
251  for (int bnd = 0; bnd != 6; ++bnd) {
252  if (bnd < 2) {
253  double p2[3] = {bounds[bnd],
254  x0[1] + (dx[1] / dx[0]) * (bounds[bnd] - x0[0]),
255  x0[2] + (dx[2] / dx[0]) * (bounds[bnd] - x0[0])};
256  if (p2[1] >= bounds[2] && p2[1] <= bounds[3] && p2[2] >= bounds[4] &&
257  p2[2] <= bounds[5]) {
258  intersects_cryo = true;
259  break;
260  }
261  }
262  else if (bnd >= 2 && bnd < 4) {
263  double p2[3] = {x0[0] + (dx[0] / dx[1]) * (bounds[bnd] - x0[1]),
264  bounds[bnd],
265  x0[2] + (dx[2] / dx[1]) * (bounds[bnd] - x0[1])};
266  if (p2[0] >= bounds[0] && p2[0] <= bounds[1] && p2[2] >= bounds[4] &&
267  p2[2] <= bounds[5]) {
268  intersects_cryo = true;
269  break;
270  }
271  }
272  else if (bnd >= 4) {
273  double p2[3] = {x0[0] + (dx[0] / dx[2]) * (bounds[bnd] - x0[2]),
274  x0[1] + (dx[1] / dx[2]) * (bounds[bnd] - x0[2]),
275  bounds[bnd]};
276  if (p2[0] >= bounds[0] && p2[0] <= bounds[1] && p2[1] >= bounds[2] &&
277  p2[1] <= bounds[3]) {
278  intersects_cryo = true;
279  break;
280  }
281  }
282  }
283 
284  if (intersects_cryo) {
285  truth.Add(particle);
286 
287  if (std::abs(particle.PdgCode()) == 13)
288  ++numMuons;
289  else if (std::abs(particle.PdgCode()) == 22)
290  ++numPhotons;
291  else if (std::abs(particle.PdgCode()) == 11)
292  ++numElectrons;
293 
294  if (hCosQ != 0) {
295  double cosq = -p4.Py() / p4.P();
296  double phi = std::atan2(p4.Pz(), p4.Px());
297  phi *= 180 / M_PI;
298  hCosQ->Fill(cosq);
299  hAngles->Fill(phi, cosq);
300  if (p4.E() < 1.0)
301  hAnglesLo->Fill(phi, cosq);
302  else if (p4.E() < 10.0)
303  hAnglesMi->Fill(phi, cosq);
304  else
305  hAnglesHi->Fill(phi, cosq);
306  hEnergy->Fill(p4.E());
307  } //end if there is a cos(theta) histogram
308  break; //leave loop over cryostats to avoid adding particle multiple times
309  } // end if particle goes into a cryostat
310  } // end loop over cryostats in the detector
311 
312  } // loop on particles
313 
314  nCrossCryostat = truth.NParticles();
315 
316  fPhotonsPerSample->Fill(allPhotons);
317  fElectronsPerSample->Fill(allElectrons);
318  fMuonsPerSample->Fill(allMuons);
319 
320  fPhotonsInCStat->Fill(numPhotons);
321  fElectronsInCStat->Fill(numElectrons);
322  fMuonsInCStat->Fill(numMuons);
323  }
324 
325  truthcol->push_back(truth);
326  evt.put(std::move(truthcol));
327  } // end produce
TH2F * fElectronAnglesHi
Electron rate vs angle, high momenta.
details::range_type< T > Iterate() const
Initializes the specified ID with the ID of the first cryostat.
Definition: GeometryCore.h:541
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:220
TH2F * fPhotonAngles
Photon rate vs angle.
int PdgCode() const
Definition: MCParticle.h:213
TH2F * fMuonAnglesHi
Muon rate vs angle, high momenta.
TH1F * fElectronEnergy
Electron energy (GeV)
TH2F * fElectronAnglesLo
Electron rate vs angle, low momenta.
TH2F * fElectronAngles
Electron rate vs angle.
TH1F * fElectronCosQ
Electron rate vs cos(Q)
void SetOrigin(simb::Origin_t origin)
Definition: MCTruth.h:82
TH2F * fMuonAngles
Muon rate vs angle.
TH2F * fMuonAnglesLo
Muon rate vs angle, low momenta.
TH1F * fPhotonEnergy
Photon energy (GeV)
constexpr auto abs(T v)
Returns the absolute value of the argument.
int NParticles() const
Definition: MCTruth.h:75
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
TH2F * fElectronAnglesMi
Electron rate vs angle, middle momenta.
TH1F * fMuonCosQ
Muon rate vs cos(Q)
Length_t DetLength(TPCID const &tpcid=tpc_zero) const
Returns the length of the active volume of the specified TPC.
Length_t SurfaceY() const
The position of the detector respect to earth surface.
Definition: GeometryCore.h:251
TH1F * fElectronsPerSample
number of electrons in the sampled time window
TH1F * fPhotonsPerSample
number of photons in the sampled time window
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
double Sample(simb::MCTruth &mctruth, double const &surfaceY, double const &detectorLength, double *w, double rantime=0)
Definition: CRYHelper.cxx:97
TH1F * fPhotonCosQ
Photon rate vs cos(Q)
evgb::CRYHelper fCRYHelp
CRY generator object.
TH2F * fMuonAnglesMi
Muon rate vs angle, middle momenta.
std::vector< double > fbuffbox
const simb::MCParticle & GetParticle(int i) const
Definition: MCTruth.h:76
TH2F * fPhotonAnglesMi
Photon rate vs angle, middle momenta.
TH2F * fPhotonAnglesLo
Photon rate vs angle, low momenta.
void Add(simb::MCParticle const &part)
Definition: MCTruth.h:80
const TLorentzVector & Momentum(const int i=0) const
Definition: MCParticle.h:221
TH2F * fPhotonAnglesHi
Photon rate vs angle, high momenta.
Event generator information.
Definition: MCTruth.h:32
TH1F * fMuonsPerSample
number of muons in the sampled time window
TH1F * fMuonEnergy
Muon energy (GeV)
Cosmic rays.
Definition: MCTruth.h:24
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<double> evgen::CosmicsGen::fbuffbox
private

Definition at line 46 of file CosmicsGen_module.cc.

Referenced by CosmicsGen(), and produce().

evgb::CRYHelper evgen::CosmicsGen::fCRYHelp
private

CRY generator object.

Definition at line 84 of file CosmicsGen_module.cc.

Referenced by CosmicsGen(), and produce().

TH2F* evgen::CosmicsGen::fElectronAngles
private

Electron rate vs angle.

Definition at line 60 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fElectronAnglesHi
private

Electron rate vs angle, high momenta.

Definition at line 63 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fElectronAnglesLo
private

Electron rate vs angle, low momenta.

Definition at line 61 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fElectronAnglesMi
private

Electron rate vs angle, middle momenta.

Definition at line 62 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fElectronCosQ
private

Electron rate vs cos(Q)

Definition at line 64 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fElectronEnergy
private

Electron energy (GeV)

Definition at line 65 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fElectronsInCStat
private

number of electrons in the cryostat during the sampled time window

Definition at line 67 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fElectronsInTPC
private

number of electrons in the tpc during the sampled time window

Definition at line 69 of file CosmicsGen_module.cc.

Referenced by beginJob().

TH1F* evgen::CosmicsGen::fElectronsPerSample
private

number of electrons in the sampled time window

Definition at line 66 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

CLHEP::HepRandomEngine& evgen::CosmicsGen::fEngine
private

art-managed random-number engine

Definition at line 83 of file CosmicsGen_module.cc.

Referenced by CosmicsGen().

TH2F* evgen::CosmicsGen::fMuonAngles
private

Muon rate vs angle.

Definition at line 72 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fMuonAnglesHi
private

Muon rate vs angle, high momenta.

Definition at line 75 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fMuonAnglesLo
private

Muon rate vs angle, low momenta.

Definition at line 73 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fMuonAnglesMi
private

Muon rate vs angle, middle momenta.

Definition at line 74 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fMuonCosQ
private

Muon rate vs cos(Q)

Definition at line 76 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fMuonEnergy
private

Muon energy (GeV)

Definition at line 77 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fMuonsInCStat
private

number of muons in the cryostat during the sampled time window

Definition at line 79 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fMuonsInTPC
private

number of muons in the tpc during the sampled time window

Definition at line 81 of file CosmicsGen_module.cc.

Referenced by beginJob().

TH1F* evgen::CosmicsGen::fMuonsPerSample
private

number of muons in the sampled time window

Definition at line 78 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fPhotonAngles
private

Photon rate vs angle.

Definition at line 48 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fPhotonAnglesHi
private

Photon rate vs angle, high momenta.

Definition at line 51 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fPhotonAnglesLo
private

Photon rate vs angle, low momenta.

Definition at line 49 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fPhotonAnglesMi
private

Photon rate vs angle, middle momenta.

Definition at line 50 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fPhotonCosQ
private

Photon rate vs cos(Q)

Definition at line 52 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fPhotonEnergy
private

Photon energy (GeV)

Definition at line 53 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fPhotonsInCStat
private

number of photons in the cryostat during the sampled time window

Definition at line 55 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fPhotonsInTPC
private

number of photons in the tpc during the sampled time window

Definition at line 57 of file CosmicsGen_module.cc.

Referenced by beginJob().

TH1F* evgen::CosmicsGen::fPhotonsPerSample
private

number of photons in the sampled time window

Definition at line 54 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().


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