114 const std::string& key)
const;
149 #include "Pandora/PdgTable.h" 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>>();
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>>();
192 produces<std::vector<anab::T0>>();
193 produces<art::Assns<recob::PFParticle, anab::T0>>();
212 this->
CollectSlices(particles, particlesToMetadata, particleMap, slices);
222 consolidatedParticles);
240 for (
unsigned int i = 0; i < pfParticleHandle->size(); ++i) {
242 const auto& metadata(pfParticleMetadataAssoc.at(part.
key()));
244 particles.push_back(part);
246 if (metadata.size() != 1)
248 <<
" LArPandoraExternalEventBuilding::CollectPFParticles -- Found a PFParticle without " 249 "exactly 1 metadata associated." 252 if (!particlesToMetadata.insert(PFParticleToMetadata::value_type(part, metadata.front()))
255 <<
"Repeated PFParticles" << std::endl;
265 for (
const auto& entry : particlesToMetadata) {
266 if (!particleMap.insert(PFParticleMap::value_type(entry.first->Self(), entry.first)).second)
268 <<
"Repeated PFParticles" << std::endl;
280 for (
const auto&
part : allParticles) {
284 if (parentIt == particlesToMetadata.end())
286 <<
"Found PFParticle without metadata" << std::endl;
290 if (static_cast<bool>(
292 clearCosmics.push_back(
part);
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;
313 for (
const auto&
part : allParticles) {
317 if (parentIt == particlesToMetadata.end())
319 <<
"Found PFParticle without metadata" << std::endl;
323 if (static_cast<bool>(
330 const unsigned int sliceId(static_cast<unsigned int>(
335 if (std::find(usedSliceIds.begin(), usedSliceIds.end(), sliceId) == usedSliceIds.end()) {
336 usedSliceIds.push_back(sliceId);
339 targetScores[sliceId] = targetScore;
342 if (this->
IsTarget(parentIt->second)) { targetHypotheses[sliceId].push_back(
part); }
344 crHypotheses[sliceId].push_back(
part);
349 std::sort(usedSliceIds.begin(), usedSliceIds.end());
356 for (
const unsigned int sliceId : usedSliceIds) {
358 const auto targetScoresIter(targetScores.find(sliceId));
359 if (targetScoresIter == targetScores.end())
361 <<
"Scrambled slice information - can't find target score with id = " << sliceId
367 const auto targetHypothesisIter(targetHypotheses.find(sliceId));
368 targetPFParticleVector =
369 ((targetHypothesisIter == targetHypotheses.end()) ? emptyPFParticleVector :
370 targetHypothesisIter->second);
373 const auto crHypothesisIter(crHypotheses.find(sliceId));
374 crPFParticleVector = ((crHypothesisIter == crHypotheses.end()) ? emptyPFParticleVector :
375 crHypothesisIter->second);
376 slices.emplace_back(targetScoresIter->second, targetPFParticleVector, crPFParticleVector);
384 const std::string& key)
const 387 const auto& it(propertiesMap.find(key));
389 if (it == propertiesMap.end())
391 <<
"No key \"" << key <<
"\" found in metadata properties map" << std::endl;
405 collectedParticles.insert(collectedParticles.end(), clearCosmics.begin(), clearCosmics.end());
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());
415 for (
const auto&
part : allParticles) {
416 if (std::find(collectedParticles.begin(), collectedParticles.end(),
part) !=
417 collectedParticles.end())
418 consolidatedParticles.push_back(
part);
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
EDProducer(fhicl::ParameterSet const &pset)
LArPandoraExternalEventBuilding & operator=(LArPandoraExternalEventBuilding const &)=delete
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...
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.
#define DEFINE_ART_MODULE(klass)
A description of all outputs from an instance of pandora with functionality to filter and merge multi...
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
key_type key() const noexcept
const PropertiesMap & GetPropertiesMap() const
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.
std::vector< TCSlice > slices
void produce(art::Event &evt) override
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.
std::vector< Slice > SliceVector
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Utility object to perform functions of association.
bool m_useTestBeamMode
If we should expect a test-beam (instead of a neutrino) slice.
header for the lar pandora slice class
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.
Class to handle the required producer labels.
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.
bool IsTarget(const art::Ptr< larpandoraobj::PFParticleMetadata > &metadata) const
Query a metadata object to see if it is a target particle.
helper function for LArPandoraInterface producer module
cet::coded_exception< error, detail::translate > exception
LArPandoraExternalEventBuilding(fhicl::ParameterSet const &pset)
void WriteToEvent() const
Write (put) the collections in this LArPandoraEvent to the art::Event.