10 #include "cetlib_except/exception.h" 25 #include "Objects/CaloHit.h" 26 #include "Objects/Cluster.h" 27 #include "Objects/ParticleFlowObject.h" 28 #include "Objects/Vertex.h" 47 const std::string instanceLabel(
49 const std::string testBeamInteractionVertexInstanceLabel(
58 new std::vector<larpandoraobj::PFParticleMetadata>);
93 const pandora::PfoVector pfoVector(
104 pfoToTestBeamInteractionVerticesMap,
109 const pandora::ClusterList clusterList(
113 const pandora::CaloHitList threeDHitList(
119 clusterList, threeDHitList, idToHitMap, pandoraHitToArtHitMap);
126 outputTestBeamInteractionVertices);
131 pandoraHitToArtHitMap,
133 outputSpacePointsToHits);
139 pandoraHitToArtHitMap,
142 outputClustersToHits,
143 pfoToArtClustersMap);
152 outputParticlesToVertices,
153 outputParticlesToSpacePoints,
154 outputParticlesToClusters);
157 evt, instanceLabel, pfoVector, outputParticleMetadata, outputParticlesToMetadata);
167 outputParticlesToSlices,
177 pfoToTestBeamInteractionVerticesMap,
178 outputParticlesToTestBeamInteractionVertices);
181 evt.
put(std::move(outputParticles), instanceLabel);
182 evt.
put(std::move(outputSpacePoints), instanceLabel);
183 evt.
put(std::move(outputClusters), instanceLabel);
184 evt.
put(std::move(outputVertices), instanceLabel);
185 evt.
put(std::move(outputParticleMetadata), instanceLabel);
187 evt.
put(std::move(outputParticlesToMetadata), instanceLabel);
188 evt.
put(std::move(outputParticlesToSpacePoints), instanceLabel);
189 evt.
put(std::move(outputParticlesToClusters), instanceLabel);
190 evt.
put(std::move(outputParticlesToVertices), instanceLabel);
191 evt.
put(std::move(outputParticlesToSlices), instanceLabel);
192 evt.
put(std::move(outputSpacePointsToHits), instanceLabel);
193 evt.
put(std::move(outputClustersToHits), instanceLabel);
196 evt.
put(std::move(outputTestBeamInteractionVertices), testBeamInteractionVertexInstanceLabel);
197 evt.
put(std::move(outputParticlesToTestBeamInteractionVertices),
198 testBeamInteractionVertexInstanceLabel);
202 evt.
put(std::move(outputT0s), instanceLabel);
203 evt.
put(std::move(outputParticlesToT0s), instanceLabel);
207 evt.
put(std::move(outputSlices), instanceLabel);
208 evt.
put(std::move(outputSlicesToHits), instanceLabel);
215 const std::string& name,
216 const pandora::Pandora*& pPandoraInstance)
218 if (!pPrimaryPandora)
219 throw cet::exception(
"LArPandora") <<
" LArPandoraOutput::GetPandoraInstance--- input " 220 "primary pandora instance address is invalid ";
222 if (pPandoraInstance)
223 throw cet::exception(
"LArPandora") <<
" LArPandoraOutput::GetPandoraInstance--- the input " 224 "pandora instance address is non-null ";
226 for (
const pandora::Pandora*
const pPandora :
228 if (pPandora->GetName() != name)
continue;
230 if (pPandoraInstance)
232 <<
" LArPandoraOutput::GetPandoraInstance--- found multiple pandora instances with name: " 235 pPandoraInstance = pPandora;
238 return static_cast<bool>(pPandoraInstance);
244 pandora::PfoVector& slicePfos)
246 if (!slicePfos.empty())
248 <<
" LArPandoraOutput::GetPandoraSlices--- Input slicePfo vector is not empty ";
251 const pandora::Pandora* pSlicingWorker(
nullptr);
256 const pandora::PfoList* pSlicePfoList(
nullptr);
257 PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS,
259 PandoraApi::GetCurrentPfoList(*pSlicingWorker, pSlicePfoList));
261 slicePfos.insert(slicePfos.end(), pSlicePfoList->begin(), pSlicePfoList->end());
267 const pandora::Pandora*
const pPrimaryPandora)
269 pandora::PfoList collectedPfos;
272 pandora::PfoVector slicePfos;
276 const pandora::Pandora* pSliceNuWorker(
nullptr);
279 <<
" LArPandoraOutput::CollectAllPfoOutcomes--- Can't find slice nu worker instance. ";
281 const pandora::Pandora* pSliceCRWorker(
nullptr);
284 <<
" LArPandoraOutput::CollectAllPfoOutcomes--- Can't find slice CR worker instance. ";
287 for (
unsigned int sliceIndex = 0; sliceIndex < slicePfos.size(); ++sliceIndex) {
288 const pandora::PfoList* pNuPfoList(
nullptr);
289 if (pandora::STATUS_CODE_SUCCESS ==
290 PandoraApi::GetPfoList(
291 *pSliceNuWorker,
"NeutrinoParticles3D" +
std::to_string(sliceIndex), pNuPfoList))
292 collectedPfos.insert(collectedPfos.end(), pNuPfoList->begin(), pNuPfoList->end());
294 const pandora::PfoList* pCRPfoList(
nullptr);
295 if (pandora::STATUS_CODE_SUCCESS ==
296 PandoraApi::GetPfoList(
297 *pSliceCRWorker,
"MuonParticles3D" +
std::to_string(sliceIndex), pCRPfoList))
298 collectedPfos.insert(collectedPfos.end(), pCRPfoList->begin(), pCRPfoList->end());
302 const pandora::PfoList* pParentPfoList(
nullptr);
303 PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS,
305 PandoraApi::GetCurrentPfoList(*pPrimaryPandora, pParentPfoList));
308 for (
const pandora::ParticleFlowObject*
const pPfo : *pParentPfoList) {
313 pandora::PfoVector pfoVector;
325 const auto& properties(pParent->GetPropertiesMap());
326 const auto it(properties.find(
"IsClearCosmic"));
328 if (it == properties.end())
return false;
330 return static_cast<bool>(std::round(it->second));
339 const auto& properties(pParent->GetPropertiesMap());
340 return (properties.find(
"SliceIndex") != properties.end());
349 const auto& properties(pParent->GetPropertiesMap());
350 const auto it(properties.find(
"SliceIndex"));
352 if (it == properties.end())
354 <<
" LArPandoraOutput::GetSliceIndex--- Input PFO was not from a slice ";
356 return static_cast<unsigned int>(std::round(it->second));
363 const pandora::PfoList* pParentPfoList(
nullptr);
364 PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS,
366 PandoraApi::GetCurrentPfoList(*pPrimaryPandora, pParentPfoList));
368 pandora::PfoVector pfoVector;
377 pandora::PfoVector& pfoVector)
379 if (!pfoVector.empty())
381 <<
" LArPandoraOutput::CollectPfos--- trying to collect pfos into a non-empty list ";
383 pandora::PfoList pfoList;
386 pfoVector.insert(pfoVector.end(), pfoList.begin(), pfoList.end());
393 const pandora::PfoVector& pfoVector,
395 std::function<
const pandora::Vertex*
const(
const pandora::ParticleFlowObject*
const)> fCriteria)
399 for (
unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId) {
400 const pandora::ParticleFlowObject*
const pPfo(pfoVector.at(pfoId));
402 if (pPfo->GetVertexList().empty())
continue;
408 const auto it(std::find(vertexVector.begin(), vertexVector.end(), pVertex));
409 const bool isInList(it != vertexVector.end());
410 const size_t vertexId(isInList ? std::distance(vertexVector.begin(), it) :
411 vertexVector.size());
413 if (!isInList) vertexVector.push_back(pVertex);
415 if (!pfoToVerticesMap.insert(IdToIdVectorMap::value_type(pfoId, {vertexId})).second)
417 <<
" LArPandoraOutput::CollectVertices --- repeated pfos in input list ";
419 catch (
const pandora::StatusCodeException&) {
432 pandora::ClusterList clusterList;
434 for (
unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId) {
435 const pandora::ParticleFlowObject*
const pPfo(pfoVector.at(pfoId));
438 pandora::ClusterList clusters;
443 IdVector clusterIds(clusters.size());
444 std::iota(clusterIds.begin(), clusterIds.end(), clusterList.size());
446 clusterList.insert(clusterList.end(), clusters.begin(), clusters.end());
448 if (!pfoToClustersMap.insert(IdToIdVectorMap::value_type(pfoId, clusterIds)).second)
450 <<
" LArPandoraOutput::CollectClusters --- repeated pfos in input list ";
461 pandora::CaloHitList caloHitList;
463 for (
unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId) {
464 const pandora::ParticleFlowObject*
const pPfo(pfoVector.at(pfoId));
466 if (!pfoToThreeDHitsMap.insert(IdToIdVectorMap::value_type(pfoId, {})).second)
468 <<
" LArPandoraOutput::Collect3DHits --- repeated pfos in input list ";
470 pandora::CaloHitVector sorted3DHits;
473 for (
const pandora::CaloHit*
const pCaloHit3D : sorted3DHits) {
474 if (pandora::TPC_3D !=
478 <<
" LArPandoraOutput::Collect3DHits --- found a 2D hit in a 3D cluster";
480 pfoToThreeDHitsMap.at(pfoId).push_back(caloHitList.size());
481 caloHitList.push_back(pCaloHit3D);
491 pandora::CaloHitVector& caloHits)
494 pandora::CaloHitList threeDHits;
497 caloHits.insert(caloHits.end(), threeDHits.begin(), threeDHits.end());
504 const pandora::CaloHitList& threeDHitList,
509 for (
const pandora::Cluster*
const pCluster : clusterList) {
512 <<
" LArPandoraOutput::GetPandoraToArtHitMap --- found a 3D input cluster ";
514 pandora::CaloHitVector sortedHits;
517 for (
const pandora::CaloHit*
const pCaloHit : sortedHits) {
518 if (!pandoraHitToArtHitMap
519 .insert(CaloHitToArtHitMap::value_type(
523 <<
" LArPandoraOutput::GetPandoraToArtHitMap --- found repeated input hits ";
527 for (
const pandora::CaloHit*
const pCaloHit : threeDHitList) {
528 if (pCaloHit->GetHitType() != pandora::TPC_3D)
530 <<
" LArPandoraOutput::GetPandoraToArtHitMap --- found a non-3D hit in the input list ";
533 if (!pandoraHitToArtHitMap
534 .insert(CaloHitToArtHitMap::value_type(
537 idToHitMap, static_cast<const pandora::CaloHit*>(pCaloHit->GetParentAddress()))))
540 <<
" LArPandoraOutput::GetPandoraToArtHitMap --- found repeated input hits ";
547 const pandora::CaloHit*
const pCaloHit)
553 for (
unsigned int depth = 0, maxDepth = 2; depth < maxDepth; ++depth) {
555 const pandora::CaloHit* pParentCaloHit = pCaloHit;
556 for (
unsigned int i = 0; i < depth; ++i)
557 pParentCaloHit = static_cast<const pandora::CaloHit*>(pCaloHit->GetParentAddress());
560 const void*
const pHitAddress(pParentCaloHit->GetParentAddress());
561 const intptr_t hitID_temp((intptr_t)(pHitAddress));
562 const int hitID((
int)(hitID_temp));
567 if (idToHitMap.end() == artIter)
continue;
569 return artIter->second;
573 <<
" LArPandoraOutput::GetHit --- found a Pandora hit without a parent ART hit ";
581 for (
size_t vertexId = 0; vertexId < vertexVector.size(); ++vertexId)
588 const std::string& instanceLabel,
589 const pandora::CaloHitList& threeDHitList,
594 pandora::CaloHitVector threeDHitVector;
595 threeDHitVector.insert(threeDHitVector.end(), threeDHitList.begin(), threeDHitList.end());
597 for (
unsigned int hitId = 0; hitId < threeDHitVector.size(); hitId++) {
598 const pandora::CaloHit*
const pCaloHit(threeDHitVector.at(hitId));
601 if (it == pandoraHitToArtHitMap.end())
602 throw cet::exception(
"LArPandora") <<
" LArPandoraOutput::BuildSpacePoints --- found a " 603 "pandora hit without a corresponding art hit ";
606 event, instanceLabel, hitId, {it->second}, outputSpacePointsToHits);
614 const std::string& instanceLabel,
615 const pandora::ClusterList& clusterList,
626 auto const clock_data =
628 auto const det_prop =
633 size_t nextClusterId(0);
635 for (
const pandora::Cluster*
const pCluster : clusterList) {
636 std::vector<HitVector> hitVectors;
637 const std::vector<recob::Cluster> clusters(
641 pandoraHitToArtHitMap,
642 pandoraClusterToArtClustersMap,
647 if (hitVectors.size() != clusters.size())
649 <<
" LArPandoraOutput::BuildClusters --- invalid hit vectors for clusters produced ";
651 for (
unsigned int i = 0; i < clusters.size(); ++i) {
653 event, instanceLabel, nextClusterId - 1, hitVectors.at(i), outputClustersToHits);
654 outputClusters->push_back(clusters.at(i));
660 it != pfoToClustersMap.end();
662 if (!pfoToArtClustersMap.insert(IdToIdVectorMap::value_type(it->first, {})).second)
664 <<
" LArPandoraOutput::BuildClusters --- repeated pfo ids ";
666 for (
const size_t pandoraClusterId : it->second) {
669 if (it2 == pandoraClusterToArtClustersMap.end())
670 throw cet::exception(
"LArPandora") <<
" LArPandoraOutput::BuildClusters --- found a " 671 "pandora cluster with no associated recob cluster ";
673 for (
const size_t recobClusterId : it2->second)
674 pfoToArtClustersMap.at(it->first).push_back(recobClusterId);
683 const std::string& instanceLabel,
684 const pandora::PfoVector& pfoVector,
693 for (
unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId) {
694 const pandora::ParticleFlowObject*
const pPfo(pfoVector.at(pfoId));
699 if (pfoToVerticesMap.find(pfoId) != pfoToVerticesMap.end())
701 event, instanceLabel, pfoId, pfoToVerticesMap, outputParticlesToVertices);
703 if (pfoToThreeDHitsMap.find(pfoId) != pfoToThreeDHitsMap.end())
705 event, instanceLabel, pfoId, pfoToThreeDHitsMap, outputParticlesToSpacePoints);
707 if (pfoToArtClustersMap.find(pfoId) != pfoToArtClustersMap.end())
709 event, instanceLabel, pfoId, pfoToArtClustersMap, outputParticlesToClusters);
717 const std::string& instanceLabel,
718 const pandora::PfoVector& pfoVector,
722 for (
unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId) {
723 if (pfoToVerticesMap.find(pfoId) != pfoToVerticesMap.end())
725 event, instanceLabel, pfoId, pfoToVerticesMap, outputParticlesToVertices);
733 const std::string& instanceLabel,
734 const pandora::PfoVector& pfoVector,
738 for (
unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId) {
739 const pandora::ParticleFlowObject*
const pPfo(pfoVector.at(pfoId));
742 event, instanceLabel, pfoId, outputParticleMetadata->size(), outputParticlesToMetadata);
745 outputParticleMetadata->push_back(pPFParticleMetadata);
752 const pandora::Pandora*
const pPrimaryPandora,
754 const std::string& instanceLabel,
755 const pandora::PfoVector& pfoVector,
769 outputParticlesToSlices,
775 pandora::PfoVector slicePfos;
779 for (
const pandora::ParticleFlowObject*
const pSlicePfo : slicePfos)
781 pSlicePfo, event, instanceLabel, idToHitMap, outputSlices, outputSlicesToHits);
784 std::unordered_map<const pandora::ParticleFlowObject*, unsigned int> parentPfoToSliceIndexMap;
785 for (
unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId) {
786 const pandora::ParticleFlowObject*
const pPfo(pfoVector.at(pfoId));
793 if (!parentPfoToSliceIndexMap
796 pPfo, event, instanceLabel, idToHitMap, outputSlices, outputSlicesToHits))
799 <<
" LArPandoraOutput::BuildSlices --- found repeated primary particles ";
803 for (
unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId) {
804 const pandora::ParticleFlowObject*
const pPfo(pfoVector.at(pfoId));
812 outputParticlesToSlices);
817 const pandora::ParticleFlowObject*
const pParent(
819 if (parentPfoToSliceIndexMap.find(pParent) == parentPfoToSliceIndexMap.end())
821 <<
" LArPandoraOutput::BuildSlices --- found pfo without a parent in the input list ";
825 event, instanceLabel, pfoId, parentPfoToSliceIndexMap.at(pParent), outputParticlesToSlices);
834 const float bogusFloat(std::numeric_limits<float>::max());
838 const unsigned int sliceIndex(outputSlices->size());
839 outputSlices->emplace_back(
840 sliceIndex, bogusPoint, bogusVector, bogusPoint, bogusPoint, bogusFloat, bogusFloat);
850 const std::string& instanceLabel,
851 const pandora::PfoVector& pfoVector,
866 mf::LogDebug(
"LArPandora") <<
" - Found " << hits.size() << std::endl;
867 mf::LogDebug(
"LArPandora") <<
" - Making associations " << outputSlicesToHits->size()
871 for (
unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId)
873 event, instanceLabel, pfoId, sliceIndex, outputParticlesToSlices);
880 const std::string& instanceLabel,
888 pandora::PfoList pfosInSlice;
893 pandora::CaloHitList
hits;
894 for (
const pandora::ParticleFlowObject*
const pPfo : pfosInSlice) {
896 {pandora::TPC_VIEW_U, pandora::TPC_VIEW_V, pandora::TPC_VIEW_W}) {
903 for (
const pandora::CaloHit*
const pCaloHit : hits)
916 const std::string& instanceLabel,
917 const pandora::PfoVector& pfoVector,
922 for (
unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId) {
923 const pandora::ParticleFlowObject*
const pPfo(pfoVector.at(pfoId));
929 event, instanceLabel, pfoId, nextT0Id - 1, outputParticlesToT0s);
930 outputT0s->push_back(t0);
938 const pandora::PfoVector& pfoVector)
941 const pandora::PfoList& parentList(pPfo->GetParentPfoList());
942 if (parentList.size() > 1)
944 <<
" LArPandoraOutput::BuildPFParticle --- this pfo has multiple parent particles ";
946 const size_t parentId(parentList.empty() ?
951 std::vector<size_t> daughterIds;
952 for (
const pandora::ParticleFlowObject*
const pDaughterPfo : pPfo->GetDaughterPfoList())
955 std::sort(daughterIds.begin(), daughterIds.end());
963 const size_t vertexId)
966 pVertex->GetPosition().GetX(), pVertex->GetPosition().GetY(), pVertex->GetPosition().GetZ()};
973 pandora::CaloHitVector& sortedHits)
975 if (!sortedHits.empty())
977 <<
" LArPandoraOutput::GetHitsInCluster --- vector to hold hits is not empty ";
979 pandora::CaloHitList hitList;
980 pCluster->GetOrderedCaloHitList().FillCaloHitList(hitList);
981 hitList.insert(hitList.end(),
982 pCluster->GetIsolatedCaloHitList().begin(),
983 pCluster->GetIsolatedCaloHitList().end());
985 sortedHits.insert(sortedHits.end(), hitList.begin(), hitList.end());
994 const pandora::Cluster*
const pCluster,
995 const pandora::ClusterList& clusterList,
998 std::vector<HitVector>& hitVectors,
1002 std::vector<recob::Cluster> clusters;
1006 if (!pandoraClusterToArtClustersMap.insert(IdToIdVectorMap::value_type(clusterId, {})).second)
1008 <<
" LArPandoraOutput::BuildClusters --- repeated clusters in input list ";
1010 pandora::CaloHitVector sortedHits;
1016 for (
const pandora::CaloHit*
const pCaloHit2D : sortedHits) {
1018 if (it == pandoraHitToArtHitMap.end())
1020 <<
" LArPandoraOutput::BuildClusters --- couldn't find art hit for input pandora hit ";
1025 const unsigned int volID(100000 * wireID.Cryostat + wireID.TPC);
1026 hitArray[volID].push_back(hit);
1028 if (pCaloHit2D->IsIsolated()) isolatedHits.insert(hit);
1031 if (hitArray.empty())
1033 <<
" LArPandoraOutput::BuildClusters --- found a cluster with no hits ";
1035 for (
const HitArray::value_type& hitArrayEntry : hitArray) {
1036 const HitVector& clusterHits(hitArrayEntry.second);
1040 hitVectors.push_back(clusterHits);
1041 pandoraClusterToArtClustersMap.at(clusterId).push_back(nextId);
1057 if (hitVector.empty())
1059 <<
" LArPandoraOutput::BuildCluster --- No input hits were provided ";
1065 double startWire(+std::numeric_limits<float>::max()), sigmaStartWire(0.0);
1066 double startTime(+std::numeric_limits<float>::max()), sigmaStartTime(0.0);
1067 double endWire(-std::numeric_limits<float>::max()), sigmaEndWire(0.0);
1068 double endTime(-std::numeric_limits<float>::max()), sigmaEndTime(0.0);
1070 std::vector<recob::Hit const*> hits_for_params;
1071 hits_for_params.reserve(hitVector.size());
1074 const double thisWire(
hit->WireID().Wire);
1075 const double thisWireSigma(0.5);
1076 const double thisTime(
hit->PeakTime());
1077 const double thisTimeSigma(
double(2. *
hit->RMS()));
1083 planeID = thisPlaneID;
1086 if (!(thisView == view && thisPlaneID == planeID)) {
1088 <<
" LArPandoraOutput::BuildCluster --- Input hits have inconsistent plane IDs ";
1091 hits_for_params.push_back(&*
hit);
1093 if (isolatedHits.count(
hit))
continue;
1095 if (thisWire < startWire || (thisWire == startWire && thisTime < startTime)) {
1096 startWire = thisWire;
1097 sigmaStartWire = thisWireSigma;
1098 startTime = thisTime;
1099 sigmaStartTime = thisTimeSigma;
1102 if (thisWire > endWire || (thisWire == endWire && thisTime > endTime)) {
1104 sigmaEndWire = thisWireSigma;
1106 sigmaEndTime = thisTimeSigma;
1135 const size_t spacePointId)
1137 if (pandora::TPC_3D != pCaloHit->GetHitType())
1139 <<
" LArPandoraOutput::BuildSpacePoint --- trying to build a space point from a 2D hit";
1141 const pandora::CartesianVector point(pCaloHit->GetPositionVector());
1142 double xyz[3] = {point.GetX(), point.GetY(), point.GetZ()};
1145 double dxdydz[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
1154 const pandora::ParticleFlowObject*
const pPfo,
1155 const pandora::PfoVector& pfoVector,
1160 const float x0(pParent->GetPropertiesMap().count(
"X0") ? pParent->GetPropertiesMap().at(
"X0") :
1164 auto const det_prop =
1166 const double cm_per_tick(det_prop.GetXTicksCoefficient());
1170 const double T0(x0 * ns_per_tick / cm_per_tick);
1172 if (std::fabs(T0) <= std::numeric_limits<double>::epsilon())
return false;
1184 : m_pPrimaryPandora(nullptr)
1185 , m_shouldRunStitching(false)
1186 , m_shouldProduceAllOutcomes(false)
1187 , m_shouldProduceTestBeamInteractionVertices(false)
1188 , m_isNeutrinoRecoOnlyNoSlicing(false)
1197 <<
" LArPandoraOutput::Settings::Validate --- primary Pandora instance does not exist ";
1203 <<
" LArPandoraOutput::Settings::Validate --- all outcomes instance label not set ";
code to link reconstructed objects back to the MC truth information
std::map< int, art::Ptr< recob::Hit > > IdToHitMap
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
static pandora::VertexVector CollectVertices(const pandora::PfoVector &pfoVector, IdToIdVectorMap &pfoToVerticesMap, std::function< const pandora::Vertex *const (const pandora::ParticleFlowObject *const)> fCriteria)
Collect all vertices contained in the input pfo list Order is guaranteed provided pfoVector is ordere...
static recob::SpacePoint BuildSpacePoint(const pandora::CaloHit *const pCaloHit, const size_t spacePointId)
Convert from a pandora 3D hit to an ART spacepoint.
void Validate() const
Check the parameters and throw an exception if they are not valid.
static void GetPandoraSlices(const pandora::Pandora *const pPrimaryPandora, pandora::PfoVector &slicePfos)
Get the slice pfos - one pfo per slice.
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
Header file for the pfo helper class.
static recob::Cluster BuildCluster(util::GeometryUtilities const &gser, const size_t id, const HitVector &hitVector, const HitList &isolatedHits, cluster::ClusterParamsAlgBase &algo)
Build an ART cluster from an input vector of ART hits.
Class managing the creation of a new recob::Cluster object.
const pandora::Pandora * m_pPrimaryPandora
static bool GetPandoraInstance(const pandora::Pandora *const pPrimaryPandora, const std::string &name, const pandora::Pandora *&pPandoraInstance)
Get the address of a pandora instance with a given name.
std::unique_ptr< std::vector< larpandoraobj::PFParticleMetadata > > PFParticleMetadataCollection
static void GetPandoraToArtHitMap(const pandora::ClusterList &clusterList, const pandora::CaloHitList &threeDHitList, const IdToHitMap &idToHitMap, CaloHitToArtHitMap &pandoraHitToArtHitMap)
Collect all 2D and 3D hits that were used / produced in the reconstruction and map them to their corr...
static constexpr size_t kPFParticlePrimary
Define index to signify primary particle.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
std::map< int, HitVector > HitArray
static void GetTwoDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 2D clusters from an input pfo.
std::unique_ptr< art::Assns< recob::PFParticle, recob::Slice > > PFParticleToSliceCollection
static void BuildClusters(const art::Event &event, const std::string &instanceLabel, const pandora::ClusterList &clusterList, const CaloHitToArtHitMap &pandoraHitToArtHitMap, const IdToIdVectorMap &pfoToClustersMap, ClusterCollection &outputClusters, ClusterToHitCollection &outputClustersToHits, IdToIdVectorMap &pfoToArtClustersMap)
Convert pandora 2D clusters to ART clusters and add them to the output vector Create the associations...
static void BuildSpacePoints(const art::Event &event, const std::string &instanceLabel, const pandora::CaloHitList &threeDHitList, const CaloHitToArtHitMap &pandoraHitToArtHitMap, SpacePointCollection &outputSpacePoints, SpacePointToHitCollection &outputSpacePointsToHits)
Convert pandora 3D hits to ART spacepoints and add them to the output vector Create the associations ...
Declaration of signal hit object.
static unsigned int BuildSlice(const pandora::ParticleFlowObject *const pParentPfo, const art::Event &event, const std::string &instanceLabel, const IdToHitMap &idToHitMap, SliceCollection &outputSlices, SliceToHitCollection &outputSlicesToHits)
Build a new slice object from a PFO, this can be a top-level parent in a hierarchy or a "slice PFO" f...
std::unique_ptr< std::vector< recob::Slice > > SliceCollection
static const pandora::Vertex * GetVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo vertex.
std::unique_ptr< std::vector< recob::PFParticle > > PFParticleCollection
The data type to uniquely identify a Plane.
static unsigned int BuildDummySlice(SliceCollection &outputSlices)
Build a new slice object with dummy information.
Settings()
Default constructor.
std::string m_testBeamInteractionVerticesInstanceLabel
The label for the test beam interaction vertices.
std::unique_ptr< std::vector< recob::Vertex > > VertexCollection
static const pandora::Vertex * GetTestBeamInteractionVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo test beam interaction vertex.
std::string m_allOutcomesInstanceLabel
The label for the instance producing all outcomes.
std::map< size_t, IdVector > IdToIdVectorMap
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Algorithm collection class computing cluster parameters.
static void GetHitsInCluster(const pandora::Cluster *const pCluster, pandora::CaloHitVector &sortedHits)
Collect a sorted list of all 2D hits in a cluster.
Set of hits with a 2D structure.
std::unique_ptr< art::Assns< recob::PFParticle, larpandoraobj::PFParticleMetadata > > PFParticleToMetadataCollection
static art::Ptr< recob::Hit > GetHit(const IdToHitMap &idToHitMap, const pandora::CaloHit *const pCaloHit)
Look up ART hit from an input Pandora hit.
geo::WireID const & WireID() const
Initial tdc tick for hit.
bool m_isNeutrinoRecoOnlyNoSlicing
If we are running the neutrino reconstruction only with no slicing.
static size_t GetId(const T *const pT, const std::list< const T * > &tList)
Find the index of an input object in an input list. Throw an exception if it doesn't exist...
Helper functions for processing outputs from pandora.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static bool IsFromSlice(const pandora::ParticleFlowObject *const pPfo)
Check if the input pfo is from a slice.
virtual void SetHitsFromPointers(util::GeometryUtilities const &gser, std::vector< recob::Hit const * > const &hits)=0
Sets the list of input hits.
Definition of vertex object for LArSoft.
static recob::Vertex BuildVertex(const pandora::Vertex *const pVertex, const size_t vertexId)
Convert from a pandora vertex to an ART vertex.
static const SentryArgument_t Sentry
An instance of the sentry object.
std::unique_ptr< art::Assns< recob::PFParticle, recob::Cluster > > PFParticleToClusterCollection
static void AssociateAdditionalVertices(const art::Event &event, const std::string &instanceLabel, const pandora::PfoVector &pfoVector, const IdToIdVectorMap &pfoToVerticesMap, PFParticleToVertexCollection &outputParticlesToVertices)
Convert Create the associations between pre-existing PFParticle and additional vertices.
std::string m_hitfinderModuleLabel
The hit finder module label.
Algorithm collection class computing cluster parameters.
std::unique_ptr< art::Assns< recob::Slice, recob::Hit > > SliceToHitCollection
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::vector< size_t > IdVector
Metadata associated to PFParticles.
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
static const pandora::ParticleFlowObject * GetParentPfo(const pandora::ParticleFlowObject *const pPfo)
Get the primary parent pfo.
Header file for the cluster helper class.
static unsigned int GetSliceIndex(const pandora::ParticleFlowObject *const pPfo)
Get the index of the slice from which this pfo was produced.
std::unique_ptr< art::Assns< recob::PFParticle, anab::T0 > > PFParticleToT0Collection
Helper functions to create a cluster.
static void BuildVertices(const pandora::VertexVector &vertexVector, VertexCollection &outputVertices)
Convert pandora vertices to ART vertices and add them to the output vector.
static bool BuildT0(const art::Event &event, const pandora::ParticleFlowObject *const pPfo, const pandora::PfoVector &pfoVector, size_t &nextId, anab::T0 &t0)
If required, build a T0 for the input pfo.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space. See recob::tracking::Coord_t for more details on the ...
std::unique_ptr< art::Assns< recob::SpacePoint, recob::Hit > > SpacePointToHitCollection
static pandora::PfoVector CollectPfos(const pandora::Pandora *const pPrimaryPandora)
Collect the current pfos (including all downstream pfos) from the master pandora instance.
static bool IsClearCosmic(const pandora::ParticleFlowObject *const pPfo)
Check if the input pfo is an unambiguous cosmic ray.
Wrapper for ClusterParamsAlgBase objects to accept arbitrary input.
static void ProduceArtOutput(const Settings &settings, const IdToHitMap &idToHitMap, art::Event &evt)
Convert the Pandora PFOs into ART clusters and write into ART event.
std::unique_ptr< std::vector< recob::Cluster > > ClusterCollection
std::map< const pandora::CaloHit *, art::Ptr< recob::Hit > > CaloHitToArtHitMap
std::unique_ptr< art::Assns< recob::PFParticle, recob::Vertex > > PFParticleToVertexCollection
Header file for the MultiPandoraApi class.
static const PandoraInstanceList & GetDaughterPandoraInstanceList(const pandora::Pandora *const pPrimaryPandora)
Get the list of daughter pandora instances associated with a given primary pandora instance...
static pandora::ClusterList CollectClusters(const pandora::PfoVector &pfoVector, IdToIdVectorMap &pfoToClustersMap)
Collect a sorted list of all 2D clusters contained in the input pfo list Order is guaranteed provided...
static void Collect3DHits(const pandora::ParticleFlowObject *const pPfo, pandora::CaloHitVector &caloHits)
Collect a sorted vector of all 3D hits in the input pfo.
static void BuildT0s(const art::Event &event, const std::string &instanceLabel, const pandora::PfoVector &pfoVector, T0Collection &outputT0s, PFParticleToT0Collection &outputParticlesToT0s)
Calculate the T0 of each pfos and add them to the output vector Create the associations between PFPar...
bool m_shouldProduceTestBeamInteractionVertices
Whether to write the test beam interaction vertices in a separate collection.
static void CollectHits(const art::Event &evt, const std::string &label, HitVector &hitVector)
Collect the reconstructed Hits from the ART event record.
Detector simulation of raw signals on wires.
static recob::PFParticle BuildPFParticle(const pandora::ParticleFlowObject *const pPfo, const size_t pfoId, const pandora::PfoVector &pfoVector)
Convert from a pfo to and ART PFParticle.
std::unique_ptr< art::Assns< recob::PFParticle, recob::SpacePoint > > PFParticleToSpacePointCollection
std::vector< art::Ptr< recob::Hit > > HitVector
Hierarchical representation of particle flow.
Utility object to perform functions of association.
bool m_shouldRunStitching
std::unique_ptr< std::vector< anab::T0 > > T0Collection
bool m_shouldProduceAllOutcomes
If all outcomes should be produced in separate collections (choose false if you only require the cons...
bool m_shouldProduceSlices
Whether to produce output slices e.g. may not want to do this if only (re)processing single slices...
static void GetIsolatedCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
Get a list of isolated calo hits of a particular hit type from a list of pfos.
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
static void BuildSlices(const Settings &settings, const pandora::Pandora *const pPrimaryPandora, const art::Event &event, const std::string &instanceLabel, const pandora::PfoVector &pfoVector, const IdToHitMap &idToHitMap, SliceCollection &outputSlices, PFParticleToSliceCollection &outputParticlesToSlices, SliceToHitCollection &outputSlicesToHits)
Build slices - collections of hits which each describe a single particle hierarchy.
static void CopyAllHitsToSingleSlice(const Settings &settings, const art::Event &event, const std::string &instanceLabel, const pandora::PfoVector &pfoVector, const IdToHitMap &idToHitMap, SliceCollection &outputSlices, PFParticleToSliceCollection &outputParticlesToSlices, SliceToHitCollection &outputSlicesToHits)
Ouput a single slice containing all of the input hits.
std::vector< art::Ptr< recob::Vertex > > VertexVector
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
static void BuildPFParticles(const art::Event &event, const std::string &instanceLabel, const pandora::PfoVector &pfoVector, const IdToIdVectorMap &pfoToVerticesMap, const IdToIdVectorMap &pfoToThreeDHitsMap, const IdToIdVectorMap &pfoToArtClustersMap, PFParticleCollection &outputParticles, PFParticleToVertexCollection &outputParticlesToVertices, PFParticleToSpacePointCollection &outputParticlesToSpacePoints, PFParticleToClusterCollection &outputParticlesToClusters)
Convert between pfos and PFParticles and add them to the output vector Create the associations betwee...
static void BuildParticleMetadata(const art::Event &event, const std::string &instanceLabel, const pandora::PfoVector &pfoVector, PFParticleMetadataCollection &outputParticleMetadata, PFParticleToMetadataCollection &outputParticlesToMetadata)
Build metadata objects from a list of input pfos.
std::unique_ptr< std::vector< recob::SpacePoint > > SpacePointCollection
Interface to class computing cluster parameters.
static void GetAllConnectedPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively including all daughters and parents associated with those pf...
second_as<> second
Type of time stored in seconds, in double precision.
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space. See recob::tracking::Coord_t for more detai...
static void GetCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
Get a list of calo hits of a particular hit type from a list of pfos.
std::set< art::Ptr< recob::Hit > > HitList
recob::Cluster && move()
Prepares the constructed hit to be moved away.
static pandora::PfoVector CollectAllPfoOutcomes(const pandora::Pandora *const pPrimaryPandora)
Collect the pfos (including all downstream pfos) from the master and daughter pandora instances...
static void AddAssociation(const art::Event &event, const std::string &instanceLabel, const size_t idA, const size_t idB, std::unique_ptr< art::Assns< A, B >> &association)
Add an association between objects with two given ids.
std::unique_ptr< art::Assns< recob::Cluster, recob::Hit > > ClusterToHitCollection
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception
static larpandoraobj::PFParticleMetadata GetPFParticleMetadata(const pandora::ParticleFlowObject *const pPfo)
Get metadata associated to a PFO.
Event finding and building.