Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
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 >
 
- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 

Public Member Functions

 MergeSimSources (Parameters const &config)
 
void produce (art::Event &e) override
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

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
 

Static Private Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 50 of file MergeSimSources_module.cc.

Member Typedef Documentation

Definition at line 122 of file MergeSimSources_module.cc.

Constructor & Destructor Documentation

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

Definition at line 173 of file MergeSimSources_module.cc.

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

void sim::MergeSimSources::dumpConfiguration ( ) const
private

Definition at line 422 of file MergeSimSources_module.cc.

422  {
423 
424  mf::LogInfo log("MergeSimSources");
425  log << "Configuration:"
426  << "\n - " << fInputSourcesLabels.size() << " input sources:";
427  for (auto const& [ i_source, tag, offset ]
429  ) {
430  log << "\n [" << i_source << "] '" << tag.encode()
431  << "' (ID offset: " << offset << ")";
432  } // for
433  if (fFillMCParticles) log << "\n - filling MCParticles";
434 
435  if (fFillSimChannels) log << "\n - filling SimChannels";
436 
437  if (fFillAuxDetSimChannels) log << "\n - filling AuxDetSimChannels";
438 
439  if (fFillSimPhotons) {
440  log << "\n - filling Simulated Photons";
441  if (fUseLitePhotons) log << "\n - using photon summary (`SimPhotonsLite`)";
442  else log << "\n - using detailed photons (`SimPhotons`)";
443  if (fStoreReflected) log << "\n - also merging reflected light";
444  }
445 
447  log << "\n - filling simulated energy deposits ("
448  << fEnergyDepositionInstances.size() << " labels:";
450  log << " '" << label << "'";
451  log << ")";
452  }
453 
454  if (fFillAuxDetHits) {
455  log << "\n - filling auxiliary detector hits ("
456  << fAuxDetHitsInstanceLabels.size() << " labels:";
458  log << " '" << label << "'";
459  log << ")";
460  }
461 
462 } // sim::MergeSimSources::dumpConfiguration()
std::string string
Definition: nybbler.cc:12
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
std::vector< art::InputTag > const fInputSourcesLabels
std::vector< std::string > const fAuxDetHitsInstanceLabels
std::vector< int > const fTrackIDOffsets
std::vector< std::string > const fEnergyDepositionInstances
void sim::MergeSimSources::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 277 of file MergeSimSources_module.cc.

278 {
279 
280  auto partCol = std::make_unique<std::vector<simb::MCParticle>>();
281  auto scCol = std::make_unique<std::vector<sim::SimChannel>>();
282  auto PhotonCol = std::make_unique<std::vector<sim::SimPhotons>>();
283  auto LitePhotonCol = std::make_unique<std::vector<sim::SimPhotonsLite>>();
284  auto ReflPhotonCol = std::make_unique<std::vector<sim::SimPhotons>>();
285  auto ReflLitePhotonCol = std::make_unique<std::vector<sim::SimPhotonsLite>>();
286  auto tpassn = std::make_unique<art::Assns<simb::MCTruth, simb::MCParticle, sim::GeneratedParticleInfo>>();
287  auto adCol = std::make_unique<std::vector<sim::AuxDetSimChannel>>();
288 
289  using edeps_t = std::vector<sim::SimEnergyDeposit>;
290  std::vector<edeps_t> edepCols;
292  edepCols.resize(fEnergyDepositionInstances.size());
293 
294  using aux_det_hits_t = std::vector<sim::AuxDetHit>;
295  std::vector<aux_det_hits_t> auxdethitCols;
296  if (fFillAuxDetHits)
297  auxdethitCols.resize(fAuxDetHitsInstanceLabels.size());
298 
299 
300  MergeSimSourcesUtility MergeUtility { fTrackIDOffsets };
301 
302  for(auto const& [ i_source, input_label ]: util::enumerate(fInputSourcesLabels)) {
303 
304  if (fFillMCParticles) {
305  art::PtrMaker<simb::MCParticle> const makePartPtr { e };
306  auto const input_partCol
307  = e.getValidHandle<std::vector<simb::MCParticle>>(input_label);
308  MergeUtility.MergeMCParticles(*partCol,*input_partCol,i_source);
309 
310  //truth-->particle assoc stuff here
311  const std::vector<size_t>& assocVectorPrimitive
312  = MergeUtility.GetMCParticleListMap().at(i_source);
313  art::FindOneP<simb::MCTruth, sim::GeneratedParticleInfo> mctAssn(input_partCol,e,input_label);
314  for(auto const i_p: util::counter(mctAssn.size()))
315  tpassn->addSingle(mctAssn.at(i_p), makePartPtr(assocVectorPrimitive[i_p]), mctAssn.data(i_p).ref());
316  }
317 
318  if (fFillSimChannels) {
319  auto const& input_scCol
320  = e.getProduct<std::vector<sim::SimChannel>>(input_label);
321  MergeUtility.MergeSimChannels(*scCol,input_scCol,i_source);
322  }
323 
325  auto const& input_adCol
326  = e.getProduct<std::vector<sim::AuxDetSimChannel>>(input_label);
327  MergeUtility.MergeAuxDetSimChannels(*adCol,input_adCol,i_source);
328  }
329 
330  if (fFillSimPhotons) {
331  if(!fUseLitePhotons){
332  auto const& input_PhotonCol
333  = e.getProduct<std::vector<sim::SimPhotons>>(input_label);
334  MergeUtility.MergeSimPhotons(*PhotonCol,input_PhotonCol);
335  }
336  else{
337  auto const& input_LitePhotonCol
338  = e.getProduct<std::vector<sim::SimPhotonsLite>>(input_label);
339  MergeUtility.MergeSimPhotonsLite(*LitePhotonCol,input_LitePhotonCol);
340  }
341 
342  if (fStoreReflected) {
343  art::InputTag const input_reflected_label
344  { input_label.label(), ReflectedLabel };
345  if(!fUseLitePhotons){
346  auto const& input_PhotonCol
347  = e.getProduct<std::vector<sim::SimPhotons>>(input_reflected_label);
348  MergeUtility.MergeSimPhotons(*ReflPhotonCol,input_PhotonCol);
349  }
350  else{
351  auto const& input_LitePhotonCol
352  = e.getProduct<std::vector<sim::SimPhotonsLite>>(input_reflected_label);
353  MergeUtility.MergeSimPhotonsLite(*ReflLitePhotonCol,input_LitePhotonCol);
354  }
355  }
356  }
357 
358 
360  for (auto const& [ edep_inst, edepCol ]
362  {
363  art::InputTag const edep_tag { input_label.label(), edep_inst };
364  MergeUtility.MergeSimEnergyDeposits(edepCol,
365  e.getProduct<edeps_t>(edep_tag),
366  i_source);
367  } // for edep
368  } // if fill energy depositions
369 
370 
371  if (fFillAuxDetHits) {
372  for (auto const& [ auxdethit_inst, auxdethitCol ]
373  : util::zip(fAuxDetHitsInstanceLabels, auxdethitCols))
374  {
375  art::InputTag const auxdethit_tag { input_label.label(), auxdethit_inst };
376  MergeUtility.MergeAuxDetHits(auxdethitCol,
377  e.getProduct<aux_det_hits_t>(auxdethit_tag),
378  i_source);
379  }
380  }
381 
382  }
383 
384  if (fFillMCParticles) {
385  e.put(std::move(partCol));
386  e.put(std::move(tpassn));
387  }
388  if (fFillSimChannels) {
389  e.put(std::move(scCol));
390  }
392  e.put(std::move(adCol));
393  }
394  if (fFillSimPhotons) {
395  if(!fUseLitePhotons) e.put(std::move(PhotonCol));
396  else e.put(std::move(LitePhotonCol));
397  if(fStoreReflected) {
398  if(!fUseLitePhotons) e.put(std::move(ReflPhotonCol), ReflectedLabel);
399  else e.put(std::move(ReflLitePhotonCol), ReflectedLabel);
400  }
401  }
402 
404  for (auto&& [ edep_inst, edepCol ]
406  {
407  e.put(std::make_unique<edeps_t>(move(edepCol)), edep_inst);
408  } // for
409  } // if fill energy deposits
410 
411  if(fFillAuxDetHits) {
412  for (auto&& [ auxdethit_inst, auxdethitCol ]
413  : util::zip(fAuxDetHitsInstanceLabels, auxdethitCols))
414  {
415  e.put(std::make_unique<aux_det_hits_t>(move(auxdethitCol)), auxdethit_inst);
416  }
417  }
418 
419 }
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
std::vector< art::InputTag > const fInputSourcesLabels
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:285
def move(depos, offset)
Definition: depos.py:107
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
std::vector< int > const fTrackIDOffsets
static std::string const ReflectedLabel
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
Definition: zip.h:295
PROD const & getProduct(InputTag const &tag) const
Definition: DataViewImpl.h:367
std::vector< std::string > const fEnergyDepositionInstances

Member Data Documentation

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

Definition at line 142 of file MergeSimSources_module.cc.

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

Definition at line 140 of file MergeSimSources_module.cc.

bool const sim::MergeSimSources::fFillAuxDetHits
private

Definition at line 141 of file MergeSimSources_module.cc.

bool const sim::MergeSimSources::fFillAuxDetSimChannels
private

Definition at line 138 of file MergeSimSources_module.cc.

bool const sim::MergeSimSources::fFillMCParticles
private

Definition at line 135 of file MergeSimSources_module.cc.

bool const sim::MergeSimSources::fFillSimChannels
private

Definition at line 137 of file MergeSimSources_module.cc.

bool const sim::MergeSimSources::fFillSimEnergyDeposits
private

Definition at line 139 of file MergeSimSources_module.cc.

bool const sim::MergeSimSources::fFillSimPhotons
private

Definition at line 136 of file MergeSimSources_module.cc.

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

Definition at line 131 of file MergeSimSources_module.cc.

bool const sim::MergeSimSources::fStoreReflected
private

Definition at line 134 of file MergeSimSources_module.cc.

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

Definition at line 132 of file MergeSimSources_module.cc.

bool const sim::MergeSimSources::fUseLitePhotons
private

Definition at line 133 of file MergeSimSources_module.cc.

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

Definition at line 144 of file MergeSimSources_module.cc.


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