9 #include "Pandora/AlgorithmHeaders.h"
20 MatchingBaseAlgorithm::MatchingBaseAlgorithm()
26 MatchingBaseAlgorithm::~MatchingBaseAlgorithm()
32 void MatchingBaseAlgorithm::SelectInputClusters(
const ClusterList *
const pInputClusterList, ClusterList &selectedClusterList)
const
34 if (!pInputClusterList)
35 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
37 selectedClusterList = *pInputClusterList;
42 void MatchingBaseAlgorithm::PrepareInputClusters(ClusterList & )
48 bool MatchingBaseAlgorithm::MakeClusterMerges(
const ClusterMergeMap &clusterMergeMap)
50 ClusterSet deletedClusters;
52 ClusterList parentClusters;
53 for (
const auto &mapEntry : clusterMergeMap)
54 parentClusters.push_back(mapEntry.first);
55 parentClusters.sort(LArClusterHelper::SortByNHits);
57 for (
const Cluster *
const pParentCluster : parentClusters)
59 const HitType hitType(LArClusterHelper::GetClusterHitType(pParentCluster));
60 const std::string &clusterListName(this->GetClusterListName(hitType));
62 if (!((TPC_VIEW_U == hitType) || (TPC_VIEW_V == hitType) || (TPC_VIEW_W == hitType)))
63 throw StatusCodeException(STATUS_CODE_FAILURE);
65 ClusterList daughterClusters(clusterMergeMap.at(pParentCluster));
66 daughterClusters.sort(LArClusterHelper::SortByNHits);
68 for (
const Cluster *
const pDaughterCluster : daughterClusters)
70 if (deletedClusters.count(pParentCluster) || deletedClusters.count(pDaughterCluster))
71 throw StatusCodeException(STATUS_CODE_FAILURE);
73 this->UpdateUponDeletion(pDaughterCluster);
74 this->UpdateUponDeletion(pParentCluster);
75 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
76 PandoraContentApi::MergeAndDeleteClusters(*
this, pParentCluster, pDaughterCluster, clusterListName, clusterListName));
78 this->UpdateForNewCluster(pParentCluster);
79 deletedClusters.insert(pDaughterCluster);
83 return !(deletedClusters.empty());
90 bool particlesMade(
false);
91 const PfoList *pPfoList(
nullptr);
92 std::string pfoListName;
93 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*
this, pPfoList, pfoListName));
95 for (
const ProtoParticle &protoParticle : protoParticleVector)
98 this->SetPfoParameters(protoParticle, pfoParameters);
100 const ParticleFlowObject *pPfo(
nullptr);
101 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*
this, pfoParameters, pPfo));
102 particlesMade =
true;
105 if (!pPfoList->empty())
107 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Pfo>(*
this, m_outputPfoListName));
108 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Pfo>(*
this, m_outputPfoListName));
111 return particlesMade;
118 this->SetPfoParticleId(pfoParameters);
119 pfoParameters.m_charge = PdgTable::GetParticleCharge(pfoParameters.m_particleId.Get());
120 pfoParameters.m_mass = PdgTable::GetParticleMass(pfoParameters.m_particleId.Get());
121 pfoParameters.m_energy = 0.f;
122 pfoParameters.m_momentum = CartesianVector(0.f, 0.f, 0.f);
130 pfoParameters.m_particleId = E_MINUS;
135 StatusCode MatchingBaseAlgorithm::Run()
139 this->SelectAllInputClusters();
140 this->PrepareAllInputClusters();
141 this->PerformMainLoop();
142 this->ExamineOverlapContainer();
145 catch (StatusCodeException &statusCodeException)
149 if (STATUS_CODE_SUCCESS != statusCodeException.GetStatusCode())
150 throw statusCodeException;
153 return STATUS_CODE_SUCCESS;
158 StatusCode MatchingBaseAlgorithm::ReadSettings(
const TiXmlHandle xmlHandle)
160 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"OutputPfoListName", m_outputPfoListName));
162 return STATUS_CODE_SUCCESS;
std::vector< ProtoParticle > ProtoParticleVector
Header file for the cluster helper class.
pandora::ClusterList m_clusterList
List of 2D clusters in a 3D proto particle.
fhicl::Table< sbnd::crt::CRTDetSimParams > Parameters
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
Header file for the three dimension algorithm base class.