9 #include "Pandora/AlgorithmHeaders.h" 26 m_pInputClusterListU(NULL),
27 m_pInputClusterListV(NULL),
28 m_pInputClusterListW(NULL)
44 bool particlesMade(
false);
45 const PfoList *pPfoList = NULL; std::string pfoListName;
46 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*
this, pPfoList, pfoListName));
50 PandoraContentApi::ParticleFlowObject::Parameters pfoParameters;
53 const ParticleFlowObject *pPfo(NULL);
54 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*
this, pfoParameters, pPfo));
58 if (!pPfoList->empty())
60 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Pfo>(*
this,
m_outputPfoListName));
61 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Pfo>(*
this,
m_outputPfoListName));
72 ClusterSet deletedClusters;
74 ClusterList parentClusters;
75 for (
const auto &mapEntry : clusterMergeMap) parentClusters.push_back(mapEntry.first);
78 for (
const Cluster *
const pParentCluster : parentClusters)
83 if (!((TPC_VIEW_U == hitType) || (TPC_VIEW_V == hitType) || (TPC_VIEW_W == hitType)))
84 throw StatusCodeException(STATUS_CODE_FAILURE);
86 ClusterList daughterClusters(clusterMergeMap.at(pParentCluster));
89 for (
const Cluster *
const pDaughterCluster : daughterClusters)
91 if (deletedClusters.count(pParentCluster) || deletedClusters.count(pDaughterCluster))
92 throw StatusCodeException(STATUS_CODE_FAILURE);
96 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::MergeAndDeleteClusters(*
this, pParentCluster, pDaughterCluster, clusterListName, clusterListName));
99 deletedClusters.insert(pDaughterCluster);
103 return !(deletedClusters.empty());
108 template <
typename T>
113 if (!((TPC_VIEW_U == hitType) || (TPC_VIEW_V == hitType) || (TPC_VIEW_W == hitType)))
114 throw StatusCodeException(STATUS_CODE_FAILURE);
118 if (clusterList.end() != std::find(clusterList.begin(), clusterList.end(), pNewCluster))
119 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
121 clusterList.push_back(pNewCluster);
124 const ClusterList &clusterList2((TPC_VIEW_W == hitType) ?
m_clusterListV : m_clusterListW);
126 ClusterVector clusterVector1(clusterList1.begin(), clusterList1.end());
127 ClusterVector clusterVector2(clusterList2.begin(), clusterList2.end());
131 for (
const Cluster *
const pCluster1 : clusterVector1)
133 for (
const Cluster *
const pCluster2 : clusterVector2)
135 if (TPC_VIEW_U == hitType)
139 else if (TPC_VIEW_V == hitType)
153 template <
typename T>
174 template <
typename T>
180 ClusterList usedClusters;
184 if (!(iter->first->IsAvailable()))
185 usedClusters.push_back(iter->first);
190 if (!(iter->first->IsAvailable()))
191 usedClusters.push_back(iter->first);
196 if (!(iter->first->IsAvailable()))
197 usedClusters.push_back(iter->first);
208 template <
typename T>
218 template <
typename T>
225 template <
typename T>
241 template <
typename T>
246 PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*
this,
248 PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*
this,
250 PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*
this,
255 if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
256 std::cout <<
"ThreeDBaseAlgorithm: one or more input cluster lists unavailable." << std::endl;
257 throw StatusCodeException(STATUS_CODE_SUCCESS);
266 catch (StatusCodeException &statusCodeException)
270 if (STATUS_CODE_SUCCESS != statusCodeException.GetStatusCode())
271 throw statusCodeException;
274 return STATUS_CODE_SUCCESS;
279 template <
typename T>
289 for (
const Cluster *
const pClusterU : clusterVectorU)
291 for (
const Cluster *
const pClusterV : clusterVectorV)
293 for (
const Cluster *
const pClusterW : clusterVectorW)
301 template <
typename T>
304 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"InputClusterListNameU",
m_inputClusterListNameU));
305 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"InputClusterListNameV",
m_inputClusterListNameV));
306 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"InputClusterListNameW",
m_inputClusterListNameW));
307 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"OutputPfoListName",
m_outputPfoListName));
309 return STATUS_CODE_SUCCESS;
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.
std::vector< ProtoParticle > ProtoParticleVector
ThreeDBaseAlgorithm class.
virtual void PerformMainLoop()
Main loop over cluster combinations in order to populate the tensor. Responsible for calling Calculat...
pandora::StatusCode Run()
virtual void CalculateOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW)=0
Calculate cluster overlap result and store in tensor.
virtual void SelectInputClusters(const pandora::ClusterList *const pInputClusterList, pandora::ClusterList &selectedClusterList) const =0
Select a subset of input clusters for processing in this algorithm.
const std::string & GetClusterListNameU() const
Get the name of the u cluster list.
std::string m_inputClusterListNameV
The name of the view V cluster list.
pandora::ClusterList m_clusterListW
The selected modified cluster list W.
const ClusterNavigationMap & GetClusterNavigationMapVW() const
Get the cluster navigation map V->W.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Header file for the lar overlap tensor class.
virtual bool CreateThreeDParticles(const ProtoParticleVector &protoParticleVector)
Create particles using findings from recent algorithm processing.
const std::string & GetClusterListNameV() const
Get the name of the v cluster list.
const ClusterNavigationMap & GetClusterNavigationMapUV() const
Get the cluster navigation map U->V.
const pandora::ClusterList * m_pInputClusterListV
Address of the input cluster list V.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
const pandora::ClusterList * m_pInputClusterListU
Address of the input cluster list U.
virtual void SelectAllInputClusters()
Select a subset of input clusters for processing in this algorithm.
const pandora::ClusterList * m_pInputClusterListW
Address of the input cluster list W.
pandora::ClusterList m_clusterListV
The selected modified cluster list V.
const std::string & GetClusterListNameW() const
Get the name of the w cluster list.
virtual void ExamineTensor()=0
Examine contents of tensor, collect together best-matching 2D particles and modify clusters as requir...
void Clear()
Clear overlap tensor.
Header file for the three dimension algorithm base class.
virtual ~ThreeDBaseAlgorithm()
Destructor.
Header file for the cluster helper class.
TensorType m_overlapTensor
The overlap tensor.
virtual void RemoveUnavailableTensorElements()
Update tensor to remove all elements that have been added to pfos and so are unavailable.
virtual void SetPfoParameters(const ProtoParticle &protoParticle, PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const =0
Calculate Pfo properties from proto particle.
virtual void TidyUp()
Tidy member variables in derived class.
Header file for the lar shower overlap result class.
std::string m_inputClusterListNameW
The name of the view W cluster list.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
Header file for the lar track overlap result class.
virtual void PreparationStep()
Perform any preparatory steps required, e.g. caching expensive fit results for clusters.
virtual void UpdateUponDeletion(const pandora::Cluster *const pDeletedCluster)
Update to reflect cluster deletion.
virtual void UpdateForNewCluster(const pandora::Cluster *const pNewCluster)
Update to reflect addition of a new cluster to the problem space.
pandora::ClusterList m_clusterListU
The selected modified cluster list U.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterNavigationMap
std::string m_inputClusterListNameU
The name of the view U cluster list.
void RemoveCluster(const pandora::Cluster *const pCluster)
Remove entries from tensor corresponding to specified cluster.
const ClusterNavigationMap & GetClusterNavigationMapWU() const
Get the cluster navigation map W->U.
std::string m_outputPfoListName
The output pfo list name.
TheTensor::const_iterator const_iterator
virtual bool MakeClusterMerges(const ClusterMergeMap &clusterMergeMap)
Merge clusters together.