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"))
160 , m_pandoraTag(
art::InputTag(m_inputProducerLabel))
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")
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);
230 const art::Event& evt,
234 art::Handle<std::vector<recob::PFParticle>> pfParticleHandle;
237 art::FindManyP<larpandoraobj::PFParticleMetadata> pfParticleMetadataAssoc(
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()));
244 particles.push_back(part);
246 if (metadata.size() != 1)
247 throw cet::exception(
"LArPandora")
248 <<
" LArPandoraExternalEventBuilding::CollectPFParticles -- Found a PFParticle without "
249 "exactly 1 metadata associated."
252 if (!particlesToMetadata.insert(PFParticleToMetadata::value_type(part, metadata.front()))
254 throw cet::exception(
"LArPandoraExternalEventBuilding")
255 <<
"Repeated PFParticles" << std::endl;
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())
318 throw cet::exception(
"LArPandoraExternalEventBuilding")
319 <<
"Found PFParticle without metadata" << std::endl;
323 if (
static_cast<bool>(
327 catch (
const cet::exception&) {
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())
360 throw cet::exception(
"LArPandoraExternalEventBuilding")
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);
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);