LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
sim::MergeSimSources Class Reference
Inheritance diagram for sim::MergeSimSources:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Classes

struct  Config
 

Public Types

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

Public Member Functions

 MergeSimSources (Parameters const &config)
 
void produce (art::Event &e) override
 
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 dumpConfiguration () const
 

Private Attributes

std::vector< art::InputTag > const fInputSourcesLabels
 
std::vector< int > const fTrackIDOffsets
 
bool const fUseLitePhotons
 
bool const fStoreReflected
 
bool const fFillMCParticles
 
bool const fFillSimPhotons
 
bool const fFillSimChannels
 
bool const fFillAuxDetSimChannels
 
bool const fFillSimEnergyDeposits
 
std::vector< std::string > const fEnergyDepositionInstances
 
bool const fFillAuxDetHits
 
std::vector< std::string > const fAuxDetHitsInstanceLabels
 
bool const fFillParticleAncestryMaps
 

Static Private Attributes

static std::string const ReflectedLabel {"Reflected"}
 

Detailed Description

Definition at line 50 of file MergeSimSources_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

sim::MergeSimSources::MergeSimSources ( Parameters const &  config)
explicit

Definition at line 169 of file MergeSimSources_module.cc.

References art::errors::Configuration, dumpConfiguration(), fAuxDetHitsInstanceLabels, fEnergyDepositionInstances, fFillAuxDetHits, fFillAuxDetSimChannels, fFillMCParticles, fFillParticleAncestryMaps, fFillSimChannels, fFillSimEnergyDeposits, fFillSimPhotons, fInputSourcesLabels, fStoreReflected, fTrackIDOffsets, fUseLitePhotons, art::InputTag::label(), and ReflectedLabel.

170  : EDProducer{params}
171  , fInputSourcesLabels(params().InputSourcesLabels())
172  , fTrackIDOffsets(params().TrackIDOffsets())
174  , fStoreReflected(params().StoreReflected())
175  , fFillMCParticles(params().FillMCParticles())
176  , fFillSimPhotons(params().FillSimPhotons())
177  , fFillSimChannels(params().FillSimChannels())
178  , fFillAuxDetSimChannels(params().FillAuxDetSimChannels())
180  getOptionalValue(params().FillSimEnergyDeposits)
181  .value_or(art::ServiceHandle<sim::LArG4Parameters const>()->FillSimEnergyDeposits()))
182  , fEnergyDepositionInstances(params().EnergyDepositInstanceLabels())
183  , fFillAuxDetHits(params().FillAuxDetHits())
184  , fAuxDetHitsInstanceLabels(params().AuxDetHitsInstanceLabels())
185  , fFillParticleAncestryMaps(params().FillParticleAncestryMaps())
186 {
187 
188  if (fInputSourcesLabels.size() != fTrackIDOffsets.size()) {
190  << "Unequal input vector sizes: InputSourcesLabels and TrackIDOffsets.\n";
191  }
192 
193  for (art::InputTag const& tag : fInputSourcesLabels) {
194 
195  if (fFillMCParticles) {
196  consumes<std::vector<simb::MCParticle>>(tag);
197  consumes<art::Assns<simb::MCParticle, simb::MCTruth, sim::GeneratedParticleInfo>>(tag);
198  }
199 
200  if (fFillSimChannels) { consumes<std::vector<sim::SimChannel>>(tag); }
201 
202  if (fFillAuxDetSimChannels) { consumes<std::vector<sim::AuxDetSimChannel>>(tag); }
203 
204  if (fFillSimPhotons) {
205  if (!fUseLitePhotons)
206  consumes<std::vector<sim::SimPhotons>>(tag);
207  else
208  consumes<std::vector<sim::SimPhotonsLite>>(tag);
209 
210  if (fStoreReflected) {
211  art::InputTag const reflected_tag{tag.label(), ReflectedLabel};
212  if (!fUseLitePhotons)
213  consumes<std::vector<sim::SimPhotons>>(reflected_tag);
214  else
215  consumes<std::vector<sim::SimPhotonsLite>>(reflected_tag);
216  }
217  }
218 
220  for (std::string const& edep_inst : fEnergyDepositionInstances) {
221  art::InputTag const edep_tag{tag.label(), edep_inst};
222  consumes<std::vector<sim::SimEnergyDeposit>>(edep_tag);
223  }
224  } // if fill energy deposits
225 
226  if (fFillAuxDetHits) {
227  for (std::string const& auxdethit_inst : fAuxDetHitsInstanceLabels) {
228  art::InputTag const auxdethit_tag{tag.label(), auxdethit_inst};
229  consumes<std::vector<sim::AuxDetHit>>(auxdethit_tag);
230  }
231  }
232 
233  if (fFillParticleAncestryMaps) { consumes<sim::ParticleAncestryMap>(tag); }
234 
235  } // for input labels
236 
237  if (fFillMCParticles) {
238  produces<std::vector<simb::MCParticle>>();
239  produces<art::Assns<simb::MCTruth, simb::MCParticle, sim::GeneratedParticleInfo>>();
240  }
241  if (fFillSimChannels) { produces<std::vector<sim::SimChannel>>(); }
242  if (fFillAuxDetSimChannels) { produces<std::vector<sim::AuxDetSimChannel>>(); }
243 
244  if (fFillSimPhotons) {
245  if (!fUseLitePhotons)
246  produces<std::vector<sim::SimPhotons>>();
247  else
248  produces<std::vector<sim::SimPhotonsLite>>();
249 
250  if (fStoreReflected) {
251  if (!fUseLitePhotons)
252  produces<std::vector<sim::SimPhotons>>(ReflectedLabel);
253  else
254  produces<std::vector<sim::SimPhotonsLite>>(ReflectedLabel);
255  }
256  }
257 
259  for (std::string const& edep_inst : fEnergyDepositionInstances)
260  produces<std::vector<sim::SimEnergyDeposit>>(edep_inst);
261  } // if
262 
263  if (fFillAuxDetHits) {
264  for (std::string const& auxdethit_inst : fAuxDetHitsInstanceLabels)
265  produces<std::vector<sim::AuxDetHit>>(auxdethit_inst);
266  }
267 
268  if (fFillParticleAncestryMaps) { produces<std::vector<sim::ParticleAncestryMap>>(); }
269 
271 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
std::vector< art::InputTag > const fInputSourcesLabels
std::string const & label() const noexcept
Definition: InputTag.cc:79
std::vector< std::string > const fAuxDetHitsInstanceLabels
std::vector< int > const fTrackIDOffsets
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
static std::string const ReflectedLabel
std::vector< std::string > const fEnergyDepositionInstances

Member Function Documentation

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 sim::MergeSimSources::dumpConfiguration ( ) const
private

Definition at line 407 of file MergeSimSources_module.cc.

References DEFINE_ART_MODULE, util::enumerate(), fAuxDetHitsInstanceLabels, fEnergyDepositionInstances, fFillAuxDetHits, fFillAuxDetSimChannels, fFillMCParticles, fFillParticleAncestryMaps, fFillSimChannels, fFillSimEnergyDeposits, fFillSimPhotons, fInputSourcesLabels, fStoreReflected, fTrackIDOffsets, and fUseLitePhotons.

Referenced by MergeSimSources().

408 {
409 
410  mf::LogInfo log("MergeSimSources");
411  log << "Configuration:"
412  << "\n - " << fInputSourcesLabels.size() << " input sources:";
413  for (auto const& [i_source, tag, offset] :
415  log << "\n [" << i_source << "] '" << tag.encode() << "' (ID offset: " << offset << ")";
416  } // for
417  if (fFillMCParticles) log << "\n - filling MCParticles";
418 
419  if (fFillSimChannels) log << "\n - filling SimChannels";
420 
421  if (fFillAuxDetSimChannels) log << "\n - filling AuxDetSimChannels";
422 
423  if (fFillSimPhotons) {
424  log << "\n - filling Simulated Photons";
425  if (fUseLitePhotons)
426  log << "\n - using photon summary (`SimPhotonsLite`)";
427  else
428  log << "\n - using detailed photons (`SimPhotons`)";
429  if (fStoreReflected) log << "\n - also merging reflected light";
430  }
431 
433  log << "\n - filling simulated energy deposits (" << fEnergyDepositionInstances.size()
434  << " labels:";
435  for (std::string const& label : fEnergyDepositionInstances)
436  log << " '" << label << "'";
437  log << ")";
438  }
439 
440  if (fFillAuxDetHits) {
441  log << "\n - filling auxiliary detector hits (" << fAuxDetHitsInstanceLabels.size()
442  << " labels:";
443  for (std::string const& label : fAuxDetHitsInstanceLabels)
444  log << " '" << label << "'";
445  log << ")";
446  }
447 
448  if (fFillParticleAncestryMaps) log << "\n - filling ParticleAncestryMaps";
449 
450 } // sim::MergeSimSources::dumpConfiguration()
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:65
std::vector< art::InputTag > const fInputSourcesLabels
std::vector< std::string > const fAuxDetHitsInstanceLabels
std::vector< int > const fTrackIDOffsets
std::vector< std::string > const fEnergyDepositionInstances
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 sim::MergeSimSources::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 273 of file MergeSimSources_module.cc.

References util::counter(), art::FindOneP< ProdB, Data >::data(), util::enumerate(), fAuxDetHitsInstanceLabels, fEnergyDepositionInstances, fFillAuxDetHits, fFillAuxDetSimChannels, fFillMCParticles, fFillParticleAncestryMaps, fFillSimChannels, fFillSimEnergyDeposits, fFillSimPhotons, fInputSourcesLabels, fStoreReflected, fTrackIDOffsets, fUseLitePhotons, art::ProductRetriever::getProduct(), art::ProductRetriever::getValidHandle(), art::InputTag::label(), art::Event::put(), ReflectedLabel, and util::zip().

274 {
275 
276  auto partCol = std::make_unique<std::vector<simb::MCParticle>>();
277  auto scCol = std::make_unique<std::vector<sim::SimChannel>>();
278  auto PhotonCol = std::make_unique<std::vector<sim::SimPhotons>>();
279  auto LitePhotonCol = std::make_unique<std::vector<sim::SimPhotonsLite>>();
280  auto ReflPhotonCol = std::make_unique<std::vector<sim::SimPhotons>>();
281  auto ReflLitePhotonCol = std::make_unique<std::vector<sim::SimPhotonsLite>>();
282  auto tpassn =
283  std::make_unique<art::Assns<simb::MCTruth, simb::MCParticle, sim::GeneratedParticleInfo>>();
284  auto adCol = std::make_unique<std::vector<sim::AuxDetSimChannel>>();
285  auto pamCol = std::make_unique<std::vector<sim::ParticleAncestryMap>>();
286 
287  using edeps_t = std::vector<sim::SimEnergyDeposit>;
288  std::vector<edeps_t> edepCols;
289  if (fFillSimEnergyDeposits) edepCols.resize(fEnergyDepositionInstances.size());
290 
291  using aux_det_hits_t = std::vector<sim::AuxDetHit>;
292  std::vector<aux_det_hits_t> auxdethitCols;
293  if (fFillAuxDetHits) auxdethitCols.resize(fAuxDetHitsInstanceLabels.size());
294 
295  MergeSimSourcesUtility MergeUtility{fTrackIDOffsets};
296 
297  for (auto const& [i_source, input_label] : util::enumerate(fInputSourcesLabels)) {
298 
299  if (fFillMCParticles) {
300  art::PtrMaker<simb::MCParticle> const makePartPtr{e};
301  auto const input_partCol = e.getValidHandle<std::vector<simb::MCParticle>>(input_label);
302  MergeUtility.MergeMCParticles(*partCol, *input_partCol, i_source);
303 
304  //truth-->particle assoc stuff here
305  const std::vector<size_t>& assocVectorPrimitive =
306  MergeUtility.GetMCParticleListMap().at(i_source);
308  input_partCol, e, input_label);
309  for (auto const i_p : util::counter(mctAssn.size()))
310  tpassn->addSingle(
311  mctAssn.at(i_p), makePartPtr(assocVectorPrimitive[i_p]), mctAssn.data(i_p).ref());
312  }
313 
314  if (fFillSimChannels) {
315  auto const& input_scCol = e.getProduct<std::vector<sim::SimChannel>>(input_label);
316  MergeUtility.MergeSimChannels(*scCol, input_scCol, i_source);
317  }
318 
320  auto const& input_adCol = e.getProduct<std::vector<sim::AuxDetSimChannel>>(input_label);
321  MergeUtility.MergeAuxDetSimChannels(*adCol, input_adCol, i_source);
322  }
323 
324  if (fFillSimPhotons) {
325  if (!fUseLitePhotons) {
326  auto const& input_PhotonCol = e.getProduct<std::vector<sim::SimPhotons>>(input_label);
327  MergeUtility.MergeSimPhotons(*PhotonCol, input_PhotonCol);
328  }
329  else {
330  auto const& input_LitePhotonCol =
331  e.getProduct<std::vector<sim::SimPhotonsLite>>(input_label);
332  MergeUtility.MergeSimPhotonsLite(*LitePhotonCol, input_LitePhotonCol);
333  }
334 
335  if (fStoreReflected) {
336  art::InputTag const input_reflected_label{input_label.label(), ReflectedLabel};
337  if (!fUseLitePhotons) {
338  auto const& input_PhotonCol =
339  e.getProduct<std::vector<sim::SimPhotons>>(input_reflected_label);
340  MergeUtility.MergeSimPhotons(*ReflPhotonCol, input_PhotonCol);
341  }
342  else {
343  auto const& input_LitePhotonCol =
344  e.getProduct<std::vector<sim::SimPhotonsLite>>(input_reflected_label);
345  MergeUtility.MergeSimPhotonsLite(*ReflLitePhotonCol, input_LitePhotonCol);
346  }
347  }
348  }
349 
351  for (auto const& [edep_inst, edepCol] : util::zip(fEnergyDepositionInstances, edepCols)) {
352  art::InputTag const edep_tag{input_label.label(), edep_inst};
353  MergeUtility.MergeSimEnergyDeposits(edepCol, e.getProduct<edeps_t>(edep_tag), i_source);
354  } // for edep
355  } // if fill energy depositions
356 
357  if (fFillAuxDetHits) {
358  for (auto const& [auxdethit_inst, auxdethitCol] :
359  util::zip(fAuxDetHitsInstanceLabels, auxdethitCols)) {
360  art::InputTag const auxdethit_tag{input_label.label(), auxdethit_inst};
361  MergeUtility.MergeAuxDetHits(
362  auxdethitCol, e.getProduct<aux_det_hits_t>(auxdethit_tag), i_source);
363  }
364 
366  auto const& input_pamCol = e.getProduct<sim::ParticleAncestryMap>(input_label);
367  MergeUtility.MergeParticleAncestryMaps(*pamCol, input_pamCol, i_source);
368  }
369  }
370  }
371 
372  if (fFillMCParticles) {
373  e.put(std::move(partCol));
374  e.put(std::move(tpassn));
375  }
376  if (fFillSimChannels) { e.put(std::move(scCol)); }
377  if (fFillAuxDetSimChannels) { e.put(std::move(adCol)); }
378  if (fFillSimPhotons) {
379  if (!fUseLitePhotons)
380  e.put(std::move(PhotonCol));
381  else
382  e.put(std::move(LitePhotonCol));
383  if (fStoreReflected) {
384  if (!fUseLitePhotons)
385  e.put(std::move(ReflPhotonCol), ReflectedLabel);
386  else
387  e.put(std::move(ReflLitePhotonCol), ReflectedLabel);
388  }
389  }
390 
392  for (auto&& [edep_inst, edepCol] : util::zip(fEnergyDepositionInstances, edepCols)) {
393  e.put(std::make_unique<edeps_t>(move(edepCol)), edep_inst);
394  } // for
395  } // if fill energy deposits
396 
397  if (fFillAuxDetHits) {
398  for (auto&& [auxdethit_inst, auxdethitCol] :
399  util::zip(fAuxDetHitsInstanceLabels, auxdethitCols)) {
400  e.put(std::make_unique<aux_det_hits_t>(move(auxdethitCol)), auxdethit_inst);
401  }
402  }
403 
404  if (fFillParticleAncestryMaps) { e.put(std::move(pamCol)); }
405 }
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:65
std::vector< art::InputTag > const fInputSourcesLabels
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
std::string const & label() const noexcept
Definition: InputTag.cc:79
std::vector< std::string > const fAuxDetHitsInstanceLabels
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:295
std::vector< int > const fTrackIDOffsets
static std::string const ReflectedLabel
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
Definition: zip.h:293
PROD const & getProduct(InputTag const &tag) const
std::vector< std::string > const fEnergyDepositionInstances
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> const sim::MergeSimSources::fAuxDetHitsInstanceLabels
private

Definition at line 141 of file MergeSimSources_module.cc.

Referenced by dumpConfiguration(), MergeSimSources(), and produce().

std::vector<std::string> const sim::MergeSimSources::fEnergyDepositionInstances
private

Definition at line 139 of file MergeSimSources_module.cc.

Referenced by dumpConfiguration(), MergeSimSources(), and produce().

bool const sim::MergeSimSources::fFillAuxDetHits
private

Definition at line 140 of file MergeSimSources_module.cc.

Referenced by dumpConfiguration(), MergeSimSources(), and produce().

bool const sim::MergeSimSources::fFillAuxDetSimChannels
private

Definition at line 137 of file MergeSimSources_module.cc.

Referenced by dumpConfiguration(), MergeSimSources(), and produce().

bool const sim::MergeSimSources::fFillMCParticles
private

Definition at line 134 of file MergeSimSources_module.cc.

Referenced by dumpConfiguration(), MergeSimSources(), and produce().

bool const sim::MergeSimSources::fFillParticleAncestryMaps
private

Definition at line 142 of file MergeSimSources_module.cc.

Referenced by dumpConfiguration(), MergeSimSources(), and produce().

bool const sim::MergeSimSources::fFillSimChannels
private

Definition at line 136 of file MergeSimSources_module.cc.

Referenced by dumpConfiguration(), MergeSimSources(), and produce().

bool const sim::MergeSimSources::fFillSimEnergyDeposits
private

Definition at line 138 of file MergeSimSources_module.cc.

Referenced by dumpConfiguration(), MergeSimSources(), and produce().

bool const sim::MergeSimSources::fFillSimPhotons
private

Definition at line 135 of file MergeSimSources_module.cc.

Referenced by dumpConfiguration(), MergeSimSources(), and produce().

std::vector<art::InputTag> const sim::MergeSimSources::fInputSourcesLabels
private

Definition at line 130 of file MergeSimSources_module.cc.

Referenced by dumpConfiguration(), MergeSimSources(), and produce().

bool const sim::MergeSimSources::fStoreReflected
private

Definition at line 133 of file MergeSimSources_module.cc.

Referenced by dumpConfiguration(), MergeSimSources(), and produce().

std::vector<int> const sim::MergeSimSources::fTrackIDOffsets
private

Definition at line 131 of file MergeSimSources_module.cc.

Referenced by dumpConfiguration(), MergeSimSources(), and produce().

bool const sim::MergeSimSources::fUseLitePhotons
private

Definition at line 132 of file MergeSimSources_module.cc.

Referenced by dumpConfiguration(), MergeSimSources(), and produce().

std::string const sim::MergeSimSources::ReflectedLabel {"Reflected"}
staticprivate

Definition at line 144 of file MergeSimSources_module.cc.

Referenced by MergeSimSources(), and produce().


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