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

 LArPandoraExternalEventBuilding (fhicl::ParameterSet const &pset)
 
 LArPandoraExternalEventBuilding (LArPandoraExternalEventBuilding const &)=delete
 
 LArPandoraExternalEventBuilding (LArPandoraExternalEventBuilding &&)=delete
 
LArPandoraExternalEventBuildingoperator= (LArPandoraExternalEventBuilding const &)=delete
 
LArPandoraExternalEventBuildingoperator= (LArPandoraExternalEventBuilding &&)=delete
 
void produce (art::Event &evt) 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 Types

typedef std::map< art::Ptr< recob::PFParticle >, art::Ptr< larpandoraobj::PFParticleMetadata > > PFParticleToMetadata
 

Private Member Functions

void CollectPFParticles (const art::Event &evt, PFParticleToMetadata &particlesToMetadata, PFParticleVector &particles) const
 Collect PFParticles from the ART event and their mapping to metadata objects. More...
 
void BuildPFParticleMap (const PFParticleToMetadata &particlesToMetadata, PFParticleMap &particleMap) const
 Build mapping from ID to PFParticle for fast navigation through the hierarchy. More...
 
void CollectClearCosmicRays (const PFParticleVector &allParticles, const PFParticleToMetadata &particlesToMetadata, const PFParticleMap &particleMap, PFParticleVector &clearCosmics) const
 Collect PFParticles that have been identified as clear cosmic ray muons by pandora. More...
 
void CollectSlices (const PFParticleVector &allParticles, const PFParticleToMetadata &particlesToMetadata, const PFParticleMap &particleMap, SliceVector &slices) const
 Collect slices. More...
 
void CollectConsolidatedParticles (const PFParticleVector &allParticles, const PFParticleVector &clearCosmics, const SliceVector &slices, PFParticleVector &consolidatedParticles) const
 Get the consolidated collection of particles based on the slice ids. More...
 
float GetMetadataValue (const art::Ptr< larpandoraobj::PFParticleMetadata > &metadata, const std::string &key) const
 Query a metadata object for a given key and return the corresponding value. More...
 
bool IsTarget (const art::Ptr< larpandoraobj::PFParticleMetadata > &metadata) const
 Query a metadata object to see if it is a target particle. More...
 

Private Attributes

std::string m_inputProducerLabel
 Label for the Pandora instance that produced the collections we want to consolidated. More...
 
std::string m_trackProducerLabel
 Label for the track producer using the Pandora instance that produced the collections we want to consolidate. More...
 
std::string m_showerProducerLabel
 Label for the shower producer using the Pandora instance that produced the collections we want to consolidate. More...
 
std::string m_hitProducerLabel
 Label for the hit producer that was used as input to the Pandora instance specified. More...
 
bool m_shouldProduceT0s
 If we should produce T0s (relevant when stitching over multiple drift volumes) More...
 
art::InputTag m_pandoraTag
 The input tag for the pandora producer. More...
 
std::unique_ptr< SliceIdBaseToolm_sliceIdTool
 The slice id tool. More...
 
bool m_useTestBeamMode
 If we should expect a test-beam (instead of a neutrino) slice. More...
 
std::string m_targetKey
 The metadata key for a PFParticle to determine if it is the target. More...
 
std::string m_scoreKey
 The metadata key for the score of the target slice from Pandora. More...
 

Detailed Description

Definition at line 31 of file LArPandoraExternalEventBuilding_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

lar_pandora::LArPandoraExternalEventBuilding::LArPandoraExternalEventBuilding ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 153 of file LArPandoraExternalEventBuilding_module.cc.

References m_hitProducerLabel, m_inputProducerLabel, m_pandoraTag, m_scoreKey, m_shouldProduceT0s, m_showerProducerLabel, m_sliceIdTool, m_targetKey, m_trackProducerLabel, and m_useTestBeamMode.

154  : EDProducer{pset}
155  , m_inputProducerLabel(pset.get<std::string>("InputProducerLabel"))
156  , m_trackProducerLabel(pset.get<std::string>("TrackProducerLabel"))
157  , m_showerProducerLabel(pset.get<std::string>("ShowerProducerLabel"))
158  , m_hitProducerLabel(pset.get<std::string>("HitProducerLabel"))
159  , m_shouldProduceT0s(pset.get<bool>("ShouldProduceT0s"))
161  , m_sliceIdTool(art::make_tool<SliceIdBaseTool>(pset.get<fhicl::ParameterSet>("SliceIdTool")))
162  , m_useTestBeamMode(pset.get<bool>("ShouldUseTestBeamMode", false))
163  , m_targetKey(m_useTestBeamMode ? "IsTestBeam" : "IsNeutrino")
164  , m_scoreKey(m_useTestBeamMode ? "TestBeamScore" : "NuScore")
165  {
166  produces<std::vector<recob::PFParticle>>();
167  produces<std::vector<recob::SpacePoint>>();
168  produces<std::vector<recob::Cluster>>();
169  produces<std::vector<recob::Vertex>>();
170  produces<std::vector<recob::Slice>>();
171  produces<std::vector<recob::Track>>();
172  produces<std::vector<recob::Shower>>();
173  produces<std::vector<recob::PCAxis>>();
174  produces<std::vector<larpandoraobj::PFParticleMetadata>>();
175 
176  produces<art::Assns<recob::PFParticle, recob::SpacePoint>>();
177  produces<art::Assns<recob::PFParticle, recob::Cluster>>();
178  produces<art::Assns<recob::PFParticle, recob::Vertex>>();
179  produces<art::Assns<recob::PFParticle, recob::Slice>>();
180  produces<art::Assns<recob::PFParticle, recob::Track>>();
181  produces<art::Assns<recob::PFParticle, recob::Shower>>();
182  produces<art::Assns<recob::PFParticle, recob::PCAxis>>();
183  produces<art::Assns<recob::PFParticle, larpandoraobj::PFParticleMetadata>>();
184  produces<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
185  produces<art::Assns<recob::Shower, recob::Hit>>();
186  produces<art::Assns<recob::Shower, recob::PCAxis>>();
187  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
188  produces<art::Assns<recob::Cluster, recob::Hit>>();
189  produces<art::Assns<recob::Slice, recob::Hit>>();
190 
191  if (m_shouldProduceT0s) {
192  produces<std::vector<anab::T0>>();
193  produces<art::Assns<recob::PFParticle, anab::T0>>();
194  }
195  }
std::unique_ptr< SliceIdBaseTool > m_sliceIdTool
The slice id tool.
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
std::string m_trackProducerLabel
Label for the track producer using the Pandora instance that produced the collections we want to cons...
std::string m_showerProducerLabel
Label for the shower producer using the Pandora instance that produced the collections we want to con...
std::string m_hitProducerLabel
Label for the hit producer that was used as input to the Pandora instance specified.
std::string m_targetKey
The metadata key for a PFParticle to determine if it is the target.
std::string m_scoreKey
The metadata key for the score of the target slice from Pandora.
bool m_useTestBeamMode
If we should expect a test-beam (instead of a neutrino) slice.
bool m_shouldProduceT0s
If we should produce T0s (relevant when stitching over multiple drift volumes)
art::InputTag m_pandoraTag
The input tag for the pandora producer.
std::string m_inputProducerLabel
Label for the Pandora instance that produced the collections we want to consolidated.
lar_pandora::LArPandoraExternalEventBuilding::LArPandoraExternalEventBuilding ( LArPandoraExternalEventBuilding const &  )
delete
lar_pandora::LArPandoraExternalEventBuilding::LArPandoraExternalEventBuilding ( LArPandoraExternalEventBuilding &&  )
delete

Member Function Documentation

void lar_pandora::LArPandoraExternalEventBuilding::BuildPFParticleMap ( const PFParticleToMetadata particlesToMetadata,
PFParticleMap particleMap 
) const
private

Build mapping from ID to PFParticle for fast navigation through the hierarchy.

Parameters
particlesToMetadatathe input mapping from PFParticles to their metadata
particleMapthe output mapping from ID to PFParticle

Definition at line 261 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by produce().

264  {
265  for (const auto& entry : particlesToMetadata) {
266  if (!particleMap.insert(PFParticleMap::value_type(entry.first->Self(), entry.first)).second)
267  throw cet::exception("LArPandoraExternalEventBuilding")
268  << "Repeated PFParticles" << std::endl;
269  }
270  }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void lar_pandora::LArPandoraExternalEventBuilding::CollectClearCosmicRays ( const PFParticleVector allParticles,
const PFParticleToMetadata particlesToMetadata,
const PFParticleMap particleMap,
PFParticleVector clearCosmics 
) const
private

Collect PFParticles that have been identified as clear cosmic ray muons by pandora.

Parameters
allParticlesinput vector of all particles
particlesToMetadatathe input mapping from PFParticles to their metadata
particleMapthe input mapping from ID to PFParticle
clearCosmicsthe output vector of clear cosmic rays

Definition at line 274 of file LArPandoraExternalEventBuilding_module.cc.

References GetMetadataValue(), lar_pandora::LArPandoraHelper::GetParentPFParticle(), and part.

Referenced by produce().

279  {
280  for (const auto& part : allParticles) {
281  // Get the parent of the particle
282  const auto parentIt(
283  particlesToMetadata.find(LArPandoraHelper::GetParentPFParticle(particleMap, part)));
284  if (parentIt == particlesToMetadata.end())
285  throw cet::exception("LArPandoraExternalEventBuilding")
286  << "Found PFParticle without metadata" << std::endl;
287 
288  // ATTN particles without the "IsClearCosmic" parameter are not clear cosmics
289  try {
290  if (static_cast<bool>(
291  std::round(this->GetMetadataValue(parentIt->second, "IsClearCosmic"))))
292  clearCosmics.push_back(part);
293  }
294  catch (const cet::exception&) {
295  }
296  }
297  }
static art::Ptr< recob::PFParticle > GetParentPFParticle(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Return the top-level parent particle by navigating up the chain of parent/daughter associations...
TString part[npart]
Definition: Style.C:32
float GetMetadataValue(const art::Ptr< larpandoraobj::PFParticleMetadata > &metadata, const std::string &key) const
Query a metadata object for a given key and return the corresponding value.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void lar_pandora::LArPandoraExternalEventBuilding::CollectConsolidatedParticles ( const PFParticleVector allParticles,
const PFParticleVector clearCosmics,
const SliceVector slices,
PFParticleVector consolidatedParticles 
) const
private

Get the consolidated collection of particles based on the slice ids.

Parameters
allParticlesinput vector of all particles
clearCosmicsthe input vector of clear cosmic ray muons
slicesthe input vector of slices
consolidatedParticlesthe output vector of particles to include in the consolidated output

Definition at line 398 of file LArPandoraExternalEventBuilding_module.cc.

References part.

Referenced by produce().

403  {
404  PFParticleVector collectedParticles;
405  collectedParticles.insert(collectedParticles.end(), clearCosmics.begin(), clearCosmics.end());
406 
407  for (const auto& slice : slices) {
408  const PFParticleVector& particles(slice.IsTaggedAsTarget() ? slice.GetTargetHypothesis() :
409  slice.GetCosmicRayHypothesis());
410  collectedParticles.insert(collectedParticles.end(), particles.begin(), particles.end());
411  }
412 
413  // ATTN the collected particles are the ones we want to output, but here we loop over all particles to ensure that the consolidated
414  // particles have the same ordering.
415  for (const auto& part : allParticles) {
416  if (std::find(collectedParticles.begin(), collectedParticles.end(), part) !=
417  collectedParticles.end())
418  consolidatedParticles.push_back(part);
419  }
420  }
TString part[npart]
Definition: Style.C:32
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
std::vector< TCSlice > slices
Definition: DataStructs.cxx:13
void lar_pandora::LArPandoraExternalEventBuilding::CollectPFParticles ( const art::Event evt,
PFParticleToMetadata particlesToMetadata,
PFParticleVector particles 
) const
private

Collect PFParticles from the ART event and their mapping to metadata objects.

Parameters
evtthe ART event
particlesToMetadatathe output mapping from PFParticles to their metadata
particlesthe output vector of particles

Definition at line 229 of file LArPandoraExternalEventBuilding_module.cc.

References art::ProductRetriever::getByLabel(), art::Ptr< T >::key(), m_pandoraTag, and part.

Referenced by produce().

233  {
235  evt.getByLabel(m_pandoraTag, pfParticleHandle);
236 
238  pfParticleHandle, evt, m_pandoraTag);
239 
240  for (unsigned int i = 0; i < pfParticleHandle->size(); ++i) {
241  const art::Ptr<recob::PFParticle> part(pfParticleHandle, i);
242  const auto& metadata(pfParticleMetadataAssoc.at(part.key()));
243 
244  particles.push_back(part);
245 
246  if (metadata.size() != 1)
247  throw cet::exception("LArPandora")
248  << " LArPandoraExternalEventBuilding::CollectPFParticles -- Found a PFParticle without "
249  "exactly 1 metadata associated."
250  << std::endl;
251 
252  if (!particlesToMetadata.insert(PFParticleToMetadata::value_type(part, metadata.front()))
253  .second)
254  throw cet::exception("LArPandoraExternalEventBuilding")
255  << "Repeated PFParticles" << std::endl;
256  }
257  }
TString part[npart]
Definition: Style.C:32
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
art::InputTag m_pandoraTag
The input tag for the pandora producer.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void lar_pandora::LArPandoraExternalEventBuilding::CollectSlices ( const PFParticleVector allParticles,
const PFParticleToMetadata particlesToMetadata,
const PFParticleMap particleMap,
SliceVector slices 
) const
private

Collect slices.

Parameters
allParticlesinput vector of all particles
particlesToMetadatathe input mapping from PFParticles to their metadata
particleMapthe input mapping from ID to PFParticle
slicesthe output vector of slices

Definition at line 301 of file LArPandoraExternalEventBuilding_module.cc.

References GetMetadataValue(), lar_pandora::LArPandoraHelper::GetParentPFParticle(), IsTarget(), m_scoreKey, and part.

Referenced by produce().

306  {
307  std::map<unsigned int, float> targetScores;
308  std::map<unsigned int, PFParticleVector> crHypotheses;
309  std::map<unsigned int, PFParticleVector> targetHypotheses;
310  std::vector<unsigned int> usedSliceIds;
311 
312  // Collect the slice information
313  for (const auto& part : allParticles) {
314  // Find the parent PFParticle
315  const auto parentIt(
316  particlesToMetadata.find(LArPandoraHelper::GetParentPFParticle(particleMap, part)));
317  if (parentIt == particlesToMetadata.end())
318  throw cet::exception("LArPandoraExternalEventBuilding")
319  << "Found PFParticle without metadata" << std::endl;
320 
321  // Skip PFParticles that are clear cosmics
322  try {
323  if (static_cast<bool>(
324  std::round(this->GetMetadataValue(parentIt->second, "IsClearCosmic"))))
325  continue;
326  }
327  catch (const cet::exception&) {
328  }
329 
330  const unsigned int sliceId(static_cast<unsigned int>(
331  std::round(this->GetMetadataValue(parentIt->second, "SliceIndex"))));
332  const float targetScore(this->GetMetadataValue(parentIt->second, m_scoreKey));
333 
334  // Keep track of the slice IDs we have used, and their corresponding score
335  if (std::find(usedSliceIds.begin(), usedSliceIds.end(), sliceId) == usedSliceIds.end()) {
336  usedSliceIds.push_back(sliceId);
337 
338  // ATTN all PFParticles in the same slice will have the same targetScore
339  targetScores[sliceId] = targetScore;
340  }
341 
342  if (this->IsTarget(parentIt->second)) { targetHypotheses[sliceId].push_back(part); }
343  else {
344  crHypotheses[sliceId].push_back(part);
345  }
346  }
347 
348  // Sort the slice IDs to ensure reproducibility
349  std::sort(usedSliceIds.begin(), usedSliceIds.end());
350 
351  // ATTN: we need to ensure that for each slice there is a cosmic and neutrino hypothesis, even if the pass created no PFOs
352  // in such a case we add an empty vector of pfparticles
353  const PFParticleVector emptyPFParticleVector;
354 
355  // Produce the slices
356  for (const unsigned int sliceId : usedSliceIds) {
357  // Get the target score
358  const auto targetScoresIter(targetScores.find(sliceId));
359  if (targetScoresIter == targetScores.end())
360  throw cet::exception("LArPandoraExternalEventBuilding")
361  << "Scrambled slice information - can't find target score with id = " << sliceId
362  << std::endl;
363 
364  PFParticleVector targetPFParticleVector, crPFParticleVector;
365 
366  // Get the target hypothesis
367  const auto targetHypothesisIter(targetHypotheses.find(sliceId));
368  targetPFParticleVector =
369  ((targetHypothesisIter == targetHypotheses.end()) ? emptyPFParticleVector :
370  targetHypothesisIter->second);
371 
372  // Get the cosmic hypothesis
373  const auto crHypothesisIter(crHypotheses.find(sliceId));
374  crPFParticleVector = ((crHypothesisIter == crHypotheses.end()) ? emptyPFParticleVector :
375  crHypothesisIter->second);
376  slices.emplace_back(targetScoresIter->second, targetPFParticleVector, crPFParticleVector);
377  }
378  }
static art::Ptr< recob::PFParticle > GetParentPFParticle(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Return the top-level parent particle by navigating up the chain of parent/daughter associations...
TString part[npart]
Definition: Style.C:32
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
std::string m_scoreKey
The metadata key for the score of the target slice from Pandora.
std::vector< TCSlice > slices
Definition: DataStructs.cxx:13
float GetMetadataValue(const art::Ptr< larpandoraobj::PFParticleMetadata > &metadata, const std::string &key) const
Query a metadata object for a given key and return the corresponding value.
bool IsTarget(const art::Ptr< larpandoraobj::PFParticleMetadata > &metadata) const
Query a metadata object to see if it is a target particle.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
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
float lar_pandora::LArPandoraExternalEventBuilding::GetMetadataValue ( const art::Ptr< larpandoraobj::PFParticleMetadata > &  metadata,
const std::string &  key 
) const
private

Query a metadata object for a given key and return the corresponding value.

Parameters
metadatathe metadata object to query
keythe key to search for
Returns
the value in the metadata corresponding to the input key

Definition at line 382 of file LArPandoraExternalEventBuilding_module.cc.

References larpandoraobj::PFParticleMetadata::GetPropertiesMap().

Referenced by CollectClearCosmicRays(), CollectSlices(), and IsTarget().

385  {
386  const auto& propertiesMap(metadata->GetPropertiesMap());
387  const auto& it(propertiesMap.find(key));
388 
389  if (it == propertiesMap.end())
390  throw cet::exception("LArPandoraExternalEventBuilding")
391  << "No key \"" << key << "\" found in metadata properties map" << std::endl;
392 
393  return it->second;
394  }
const PropertiesMap & GetPropertiesMap() const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool lar_pandora::LArPandoraExternalEventBuilding::IsTarget ( const art::Ptr< larpandoraobj::PFParticleMetadata > &  metadata) const
private

Query a metadata object to see if it is a target particle.

Parameters
metadatathe metadata object to query
Returns
boolean - if the particle is a target

Definition at line 424 of file LArPandoraExternalEventBuilding_module.cc.

References GetMetadataValue(), and m_targetKey.

Referenced by CollectSlices().

426  {
427  try {
428  return static_cast<bool>(std::round(this->GetMetadataValue(metadata, m_targetKey)));
429  }
430  catch (const cet::exception&) {
431  return false;
432  }
433  }
std::string m_targetKey
The metadata key for a PFParticle to determine if it is the target.
float GetMetadataValue(const art::Ptr< larpandoraobj::PFParticleMetadata > &metadata, const std::string &key) const
Query a metadata object for a given key and return the corresponding value.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
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
LArPandoraExternalEventBuilding& lar_pandora::LArPandoraExternalEventBuilding::operator= ( LArPandoraExternalEventBuilding const &  )
delete
LArPandoraExternalEventBuilding& lar_pandora::LArPandoraExternalEventBuilding::operator= ( LArPandoraExternalEventBuilding &&  )
delete
void lar_pandora::LArPandoraExternalEventBuilding::produce ( art::Event evt)
overridevirtual

Implements art::EDProducer.

Definition at line 199 of file LArPandoraExternalEventBuilding_module.cc.

References BuildPFParticleMap(), CollectClearCosmicRays(), CollectConsolidatedParticles(), CollectPFParticles(), CollectSlices(), m_hitProducerLabel, m_inputProducerLabel, m_shouldProduceT0s, m_showerProducerLabel, m_sliceIdTool, m_trackProducerLabel, tca::slices, and lar_pandora::LArPandoraEvent::WriteToEvent().

200  {
201  PFParticleVector particles;
202  PFParticleToMetadata particlesToMetadata;
203  this->CollectPFParticles(evt, particlesToMetadata, particles);
204 
205  PFParticleMap particleMap;
206  this->BuildPFParticleMap(particlesToMetadata, particleMap);
207 
208  PFParticleVector clearCosmics;
209  this->CollectClearCosmicRays(particles, particlesToMetadata, particleMap, clearCosmics);
210 
212  this->CollectSlices(particles, particlesToMetadata, particleMap, slices);
213 
214  m_sliceIdTool->ClassifySlices(slices, evt);
215 
216  PFParticleVector consolidatedParticles;
217  this->CollectConsolidatedParticles(particles, clearCosmics, slices, consolidatedParticles);
218 
219  const LArPandoraEvent::Labels labels(
221  const LArPandoraEvent consolidatedEvent(LArPandoraEvent(this, &evt, labels, m_shouldProduceT0s),
222  consolidatedParticles);
223 
224  consolidatedEvent.WriteToEvent();
225  }
void CollectSlices(const PFParticleVector &allParticles, const PFParticleToMetadata &particlesToMetadata, const PFParticleMap &particleMap, SliceVector &slices) const
Collect slices.
void CollectPFParticles(const art::Event &evt, PFParticleToMetadata &particlesToMetadata, PFParticleVector &particles) const
Collect PFParticles from the ART event and their mapping to metadata objects.
std::unique_ptr< SliceIdBaseTool > m_sliceIdTool
The slice id tool.
std::map< art::Ptr< recob::PFParticle >, art::Ptr< larpandoraobj::PFParticleMetadata > > PFParticleToMetadata
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
void CollectClearCosmicRays(const PFParticleVector &allParticles, const PFParticleToMetadata &particlesToMetadata, const PFParticleMap &particleMap, PFParticleVector &clearCosmics) const
Collect PFParticles that have been identified as clear cosmic ray muons by pandora.
std::string m_trackProducerLabel
Label for the track producer using the Pandora instance that produced the collections we want to cons...
std::string m_showerProducerLabel
Label for the shower producer using the Pandora instance that produced the collections we want to con...
std::string m_hitProducerLabel
Label for the hit producer that was used as input to the Pandora instance specified.
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
std::vector< TCSlice > slices
Definition: DataStructs.cxx:13
std::vector< Slice > SliceVector
Definition: Slice.h:70
bool m_shouldProduceT0s
If we should produce T0s (relevant when stitching over multiple drift volumes)
std::string m_inputProducerLabel
Label for the Pandora instance that produced the collections we want to consolidated.
void BuildPFParticleMap(const PFParticleToMetadata &particlesToMetadata, PFParticleMap &particleMap) const
Build mapping from ID to PFParticle for fast navigation through the hierarchy.
void CollectConsolidatedParticles(const PFParticleVector &allParticles, const PFParticleVector &clearCosmics, const SliceVector &slices, PFParticleVector &consolidatedParticles) const
Get the consolidated collection of particles based on the slice ids.
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::string lar_pandora::LArPandoraExternalEventBuilding::m_hitProducerLabel
private

Label for the hit producer that was used as input to the Pandora instance specified.

Definition at line 132 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by LArPandoraExternalEventBuilding(), and produce().

std::string lar_pandora::LArPandoraExternalEventBuilding::m_inputProducerLabel
private

Label for the Pandora instance that produced the collections we want to consolidated.

Definition at line 126 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by LArPandoraExternalEventBuilding(), and produce().

art::InputTag lar_pandora::LArPandoraExternalEventBuilding::m_pandoraTag
private

The input tag for the pandora producer.

Definition at line 135 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by CollectPFParticles(), and LArPandoraExternalEventBuilding().

std::string lar_pandora::LArPandoraExternalEventBuilding::m_scoreKey
private

The metadata key for the score of the target slice from Pandora.

Definition at line 139 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by CollectSlices(), and LArPandoraExternalEventBuilding().

bool lar_pandora::LArPandoraExternalEventBuilding::m_shouldProduceT0s
private

If we should produce T0s (relevant when stitching over multiple drift volumes)

Definition at line 134 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by LArPandoraExternalEventBuilding(), and produce().

std::string lar_pandora::LArPandoraExternalEventBuilding::m_showerProducerLabel
private

Label for the shower producer using the Pandora instance that produced the collections we want to consolidate.

Definition at line 130 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by LArPandoraExternalEventBuilding(), and produce().

std::unique_ptr<SliceIdBaseTool> lar_pandora::LArPandoraExternalEventBuilding::m_sliceIdTool
private

The slice id tool.

Definition at line 136 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by LArPandoraExternalEventBuilding(), and produce().

std::string lar_pandora::LArPandoraExternalEventBuilding::m_targetKey
private

The metadata key for a PFParticle to determine if it is the target.

Definition at line 138 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by IsTarget(), and LArPandoraExternalEventBuilding().

std::string lar_pandora::LArPandoraExternalEventBuilding::m_trackProducerLabel
private

Label for the track producer using the Pandora instance that produced the collections we want to consolidate.

Definition at line 128 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by LArPandoraExternalEventBuilding(), and produce().

bool lar_pandora::LArPandoraExternalEventBuilding::m_useTestBeamMode
private

If we should expect a test-beam (instead of a neutrino) slice.

Definition at line 137 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by LArPandoraExternalEventBuilding().


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