LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
lar_pandora::LArPandoraExternalEventBuilding Class Reference
Inheritance diagram for lar_pandora::LArPandoraExternalEventBuilding:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::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
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > mayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

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...
 

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< NeutrinoIdBaseToolm_neutrinoIdTool
 The neutrino id tool. More...
 

Detailed Description

Definition at line 30 of file LArPandoraExternalEventBuilding_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

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

Definition at line 123 of file LArPandoraExternalEventBuilding_module.cc.

References m_shouldProduceT0s.

123  :
124  m_inputProducerLabel(pset.get<std::string>("InputProducerLabel")),
125  m_trackProducerLabel(pset.get<std::string>("TrackProducerLabel")),
126  m_showerProducerLabel(pset.get<std::string>("ShowerProducerLabel")),
127  m_hitProducerLabel(pset.get<std::string>("HitProducerLabel")),
128  m_shouldProduceT0s(pset.get<bool>("ShouldProduceT0s")),
130  m_neutrinoIdTool(art::make_tool<NeutrinoIdBaseTool>(pset.get<fhicl::ParameterSet>("NeutrinoIdTool")))
131 {
132  produces< std::vector<recob::PFParticle> >();
133  produces< std::vector<recob::SpacePoint> >();
134  produces< std::vector<recob::Cluster> >();
135  produces< std::vector<recob::Vertex> >();
136  produces< std::vector<recob::Track> >();
137  produces< std::vector<recob::Shower> >();
138  produces< std::vector<recob::PCAxis> >();
139  produces< std::vector<larpandoraobj::PFParticleMetadata> >();
140 
141  produces< art::Assns<recob::PFParticle, recob::SpacePoint> >();
142  produces< art::Assns<recob::PFParticle, recob::Cluster> >();
143  produces< art::Assns<recob::PFParticle, recob::Vertex> >();
144  produces< art::Assns<recob::PFParticle, recob::Track> >();
145  produces< art::Assns<recob::PFParticle, recob::Shower> >();
146  produces< art::Assns<recob::PFParticle, recob::PCAxis> >();
147  produces< art::Assns<recob::PFParticle, larpandoraobj::PFParticleMetadata> >();
148  produces< art::Assns<recob::Track, recob::Hit> >();
149  produces< art::Assns<recob::Shower, recob::Hit> >();
150  produces< art::Assns<recob::Shower, recob::PCAxis> >();
151  produces< art::Assns<recob::SpacePoint, recob::Hit> >();
152  produces< art::Assns<recob::Cluster, recob::Hit> >();
153 
154  if (m_shouldProduceT0s)
155  {
156  produces< std::vector<anab::T0> >();
157  produces< art::Assns<recob::PFParticle, anab::T0> >();
158  }
159 }
std::unique_ptr< NeutrinoIdBaseTool > m_neutrinoIdTool
The neutrino id tool.
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.
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 215 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by produce().

216 {
217  for (const auto &entry : particlesToMetadata)
218  {
219  if (!particleMap.insert(PFParticleMap::value_type(entry.first->Self(), entry.first)).second)
220  throw cet::exception("LArPandoraExternalEventBuilding") << "Repeated PFParticles" << std::endl;
221  }
222 }
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 226 of file LArPandoraExternalEventBuilding_module.cc.

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

Referenced by produce().

227 {
228  for (const auto &part : allParticles)
229  {
230  // Get the parent of the particle
231  const auto parentIt(particlesToMetadata.find(LArPandoraHelper::GetParentPFParticle(particleMap, part)));
232  if (parentIt == particlesToMetadata.end())
233  throw cet::exception("LArPandoraExternalEventBuilding") << "Found PFParticle without metadata" << std::endl;
234 
235  // ATTN particles without the "IsClearCosmic" parameter are not clear cosmics
236  try
237  {
238  if (static_cast<bool>(std::round(this->GetMetadataValue(parentIt->second, "IsClearCosmic"))))
239  clearCosmics.push_back(part);
240  }
241  catch (const cet::exception &)
242  {
243  }
244  }
245 }
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 329 of file LArPandoraExternalEventBuilding_module.cc.

References part.

Referenced by produce().

330 {
331  PFParticleVector collectedParticles;
332  collectedParticles.insert(collectedParticles.end(), clearCosmics.begin(), clearCosmics.end());
333 
334  for (const auto &slice : slices)
335  {
336  const PFParticleVector &particles(slice.IsTaggedAsNeutrino() ? slice.GetNeutrinoHypothesis() : slice.GetCosmicRayHypothesis());
337  collectedParticles.insert(collectedParticles.end(), particles.begin(), particles.end());
338  }
339 
340  // ATTN the collected particles are the ones we want to output, but here we loop over all particles to ensure that the consolidated
341  // particles have the same ordering.
342  for (const auto &part : allParticles)
343  {
344  if (std::find(collectedParticles.begin(), collectedParticles.end(), part) != collectedParticles.end())
345  consolidatedParticles.push_back(part);
346  }
347 }
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
TString part[npart]
Definition: Style.C:32
std::vector< TCSlice > slices
Definition: DataStructs.cxx:10
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 191 of file LArPandoraExternalEventBuilding_module.cc.

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

Referenced by produce().

192 {
194  evt.getByLabel(m_pandoraTag, pfParticleHandle);
195 
196  art::FindManyP<larpandoraobj::PFParticleMetadata> pfParticleMetadataAssoc(pfParticleHandle, evt, m_pandoraTag);
197 
198  for (unsigned int i = 0; i < pfParticleHandle->size(); ++i)
199  {
200  const art::Ptr<recob::PFParticle> part(pfParticleHandle, i);
201  const auto &metadata(pfParticleMetadataAssoc.at(part.key()));
202 
203  particles.push_back(part);
204 
205  if (metadata.size() != 1)
206  throw cet::exception("LArPandora") << " LArPandoraExternalEventBuilding::CollectPFParticles -- Found a PFParticle without exactly 1 metadata associated." << std::endl;
207 
208  if (!particlesToMetadata.insert(PFParticleToMetadata::value_type(part, metadata.front())).second)
209  throw cet::exception("LArPandoraExternalEventBuilding") << "Repeated PFParticles" << std::endl;
210  }
211 }
TString part[npart]
Definition: Style.C:32
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
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 249 of file LArPandoraExternalEventBuilding_module.cc.

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

Referenced by produce().

250 {
251  std::map<unsigned int, float> nuScores;
252  std::map<unsigned int, PFParticleVector> crHypotheses;
253  std::map<unsigned int, PFParticleVector> nuHypotheses;
254 
255  // Collect the slice information
256  for (const auto &part : allParticles)
257  {
258  // Find the parent PFParticle
259  const auto parentIt(particlesToMetadata.find(LArPandoraHelper::GetParentPFParticle(particleMap, part)));
260  if (parentIt == particlesToMetadata.end())
261  throw cet::exception("LArPandoraExternalEventBuilding") << "Found PFParticle without metadata" << std::endl;
262 
263  // Skip PFParticles that are clear cosmics
264  try
265  {
266  if (static_cast<bool>(std::round(this->GetMetadataValue(parentIt->second, "IsClearCosmic"))))
267  continue;
268  }
269  catch (const cet::exception &)
270  {
271  }
272 
273  const unsigned int sliceId(static_cast<unsigned int>(std::round(this->GetMetadataValue(parentIt->second, "SliceIndex"))));
274  const float nuScore(this->GetMetadataValue(parentIt->second, "NuScore"));
275  // ATTN all PFParticles in the same slice will have the same nuScore
276  nuScores[sliceId] = nuScore;
277 
278  if (LArPandoraHelper::IsNeutrino(parentIt->first))
279  {
280  nuHypotheses[sliceId].push_back(part);
281  }
282  else
283  {
284  crHypotheses[sliceId].push_back(part);
285  }
286  }
287 
288  // ATTN: we need to ensure that for each slice there is a cosmic and neutrino hypothesis, even if the pass created no PFOs
289  // in such a case we add an empty vector of pfparticles
290  const PFParticleVector emptyPFParticleVector;
291 
292  // Produce the slices
293  // ATTN slice indices are enumerated from 1
294  for (unsigned int sliceId = 1; sliceId <= nuScores.size(); ++sliceId)
295  {
296  // Get the neutrino score
297  const auto nuScoresIter(nuScores.find(sliceId));
298  if (nuScoresIter == nuScores.end())
299  throw cet::exception("LArPandoraExternalEventBuilding") << "Scrambled slice information - can't find nuScore with id = " << sliceId << std::endl;
300 
301  PFParticleVector nuPFParticleVector, crPFParticleVector;
302  // Get the neutrino hypothesis
303  const auto nuHypothesisIter(nuHypotheses.find(sliceId));
304  nuPFParticleVector = ((nuHypothesisIter == nuHypotheses.end()) ? emptyPFParticleVector : nuHypothesisIter->second);
305 
306  // Get the cosmic hypothesis
307  const auto crHypothesisIter(crHypotheses.find(sliceId));
308  crPFParticleVector = ((crHypothesisIter == crHypotheses.end()) ? emptyPFParticleVector : crHypothesisIter->second);
309 
310  slices.emplace_back(nuScoresIter->second, nuPFParticleVector, crPFParticleVector);
311  }
312 }
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
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< TCSlice > slices
Definition: DataStructs.cxx:10
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
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDProducer::currentContext ( ) const
protectedinherited

Definition at line 120 of file EDProducer.cc.

References art::EDProducer::current_context_.

121  {
122  return current_context_.get();
123  }
CPC_exempt_ptr current_context_
Definition: EDProducer.h:116
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
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 316 of file LArPandoraExternalEventBuilding_module.cc.

References larpandoraobj::PFParticleMetadata::GetPropertiesMap().

Referenced by CollectClearCosmicRays(), and CollectSlices().

317 {
318  const auto &propertiesMap(metadata->GetPropertiesMap());
319  const auto &it(propertiesMap.find(key));
320 
321  if (it == propertiesMap.end())
322  throw cet::exception("LArPandoraExternalEventBuilding") << "No key \"" << key << "\" found in metadata properties map" << std::endl;
323 
324  return it->second;
325 }
const PropertiesMap & GetPropertiesMap() const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References B, and art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
Int_t B
Definition: plot.C:25
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID().

41  {
42  return true;
43  }
LArPandoraExternalEventBuilding& lar_pandora::LArPandoraExternalEventBuilding::operator= ( LArPandoraExternalEventBuilding const &  )
delete
LArPandoraExternalEventBuilding& lar_pandora::LArPandoraExternalEventBuilding::operator= ( LArPandoraExternalEventBuilding &&  )
delete
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void lar_pandora::LArPandoraExternalEventBuilding::produce ( art::Event evt)
overridevirtual

Implements art::EDProducer.

Definition at line 163 of file LArPandoraExternalEventBuilding_module.cc.

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

164 {
165  PFParticleVector particles;
166  PFParticleToMetadata particlesToMetadata;
167  this->CollectPFParticles(evt, particlesToMetadata, particles);
168 
169  PFParticleMap particleMap;
170  this->BuildPFParticleMap(particlesToMetadata, particleMap);
171 
172  PFParticleVector clearCosmics;
173  this->CollectClearCosmicRays(particles, particlesToMetadata, particleMap, clearCosmics);
174 
176  this->CollectSlices(particles, particlesToMetadata, particleMap, slices);
177 
178  m_neutrinoIdTool->ClassifySlices(slices, evt);
179 
180  PFParticleVector consolidatedParticles;
181  this->CollectConsolidatedParticles(particles, clearCosmics, slices, consolidatedParticles);
182 
183  const LArPandoraEvent::Labels labels(m_inputProducerLabel, m_trackProducerLabel, m_showerProducerLabel, m_hitProducerLabel);
184  const LArPandoraEvent consolidatedEvent(LArPandoraEvent(this, &evt, labels, m_shouldProduceT0s), consolidatedParticles);
185 
186  consolidatedEvent.WriteToEvent();
187 }
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::map< art::Ptr< recob::PFParticle >, art::Ptr< larpandoraobj::PFParticleMetadata > > PFParticleToMetadata
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
std::unique_ptr< NeutrinoIdBaseTool > m_neutrinoIdTool
The neutrino id tool.
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::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
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< TCSlice > slices
Definition: DataStructs.cxx:10
std::vector< Slice > SliceVector
Definition: Slice.h:68
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::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139

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 105 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by 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 102 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by produce().

std::unique_ptr<NeutrinoIdBaseTool> lar_pandora::LArPandoraExternalEventBuilding::m_neutrinoIdTool
private

The neutrino id tool.

Definition at line 108 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by produce().

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

The input tag for the pandora producer.

Definition at line 107 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by CollectPFParticles().

bool lar_pandora::LArPandoraExternalEventBuilding::m_shouldProduceT0s
private

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

Definition at line 106 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 104 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by produce().

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 103 of file LArPandoraExternalEventBuilding_module.cc.

Referenced by produce().


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