29 m_slidingFitWindow(20),
30 m_minClusterCaloHits(5),
31 m_minClusterLengthSquared(3.f * 3.f)
47 TwoDSlidingFitResultMap::const_iterator iter = m_slidingFitResultMap.find(pCluster);
49 if (m_slidingFitResultMap.end() == iter)
60 bool changesMade(
false);
63 for (
const auto &mapEntry : splitPositionMap)
64 splitClusters.push_back(mapEntry.first);
67 for (
const Cluster *pCurrentCluster : splitClusters)
73 const std::string &clusterListName(this->GetClusterListName(hitType));
82 const Cluster *pLowXCluster(
nullptr), *pHighXCluster(
nullptr);
83 this->UpdateUponDeletion(pCurrentCluster);
85 if (this->MakeClusterSplit(splitPosition, pCurrentCluster, pLowXCluster, pHighXCluster))
88 this->UpdateForNewCluster(pLowXCluster);
89 this->UpdateForNewCluster(pHighXCluster);
90 pCurrentCluster = pHighXCluster;
94 this->UpdateForNewCluster(pCurrentCluster);
122 const CartesianVector lowXUnitVector((lowXEnd - splitPosition).GetUnitVector());
123 const CartesianVector highXUnitVector((highXEnd - splitPosition).GetUnitVector());
128 std::string originalListName, fragmentListName;
132 pLowXCluster =
nullptr;
133 pHighXCluster =
nullptr;
135 for (
const CaloHit *
const pCaloHit : caloHitList)
137 const CartesianVector unitVector((pCaloHit->GetPositionVector() - splitPosition).GetUnitVector());
138 const float dotProductLowX(unitVector.
GetDotProduct(lowXUnitVector));
139 const float dotProductHighX(unitVector.
GetDotProduct(highXUnitVector));
141 const Cluster *&pClusterToModify((dotProductLowX > dotProductHighX) ? pLowXCluster : pHighXCluster);
143 if (!pClusterToModify)
145 PandoraContentApi::Cluster::Parameters parameters;
146 parameters.m_caloHitList.push_back(pCaloHit);
147 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*
this, parameters, pClusterToModify));
155 if (!pLowXCluster || !pHighXCluster)
180 this->AddToSlidingFitCache(pNewCluster);
184 if (STATUS_CODE_FAILURE == statusCodeException.
GetStatusCode())
185 throw statusCodeException;
198 this->RemoveFromSlidingFitCache(pDeletedCluster);
207 for (
const Cluster *
const pCluster : *pInputClusterList)
209 if (!pCluster->IsAvailable())
212 if (pCluster->GetNCaloHits() < m_minClusterCaloHits)
218 selectedClusterList.push_back(pCluster);
227 for (ClusterList::iterator iter = preparedClusterList.begin(), iterEnd = preparedClusterList.end(); iter != iterEnd;)
231 this->AddToSlidingFitCache(*iter);
236 preparedClusterList.erase(iter++);
238 if (STATUS_CODE_FAILURE == statusCodeException.
GetStatusCode())
239 throw statusCodeException;
249 pfoParameters.m_particleId = MU_MINUS;
260 if (!m_slidingFitResultMap.insert(TwoDSlidingFitResultMap::value_type(pCluster, slidingFitResult)).second)
269 TwoDSlidingFitResultMap::iterator iter = m_slidingFitResultMap.find(pCluster);
271 if (m_slidingFitResultMap.end() != iter)
272 m_slidingFitResultMap.erase(iter);
280 m_slidingFitResultMap.clear();
290 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
XmlHelper::ReadValue(xmlHandle,
"SlidingFitWindow", m_slidingFitWindow));
293 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
XmlHelper::ReadValue(xmlHandle,
"MinClusterCaloHits", m_minClusterCaloHits));
295 float minClusterLength = std::sqrt(m_minClusterLengthSquared);
297 m_minClusterLengthSquared = minClusterLength * minClusterLength;
Header file for the cluster helper class.
Header file for the geometry helper class.
Header file for the lar pointing cluster class.
Header file for the lar track overlap result class.
Header file for the lar track two view overlap result class.
Header file for the n view track matching algorithm class.
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Header file for the three view matching control class.
Header file for the two view matching control class.
static pandora::StatusCode ReplaceCurrentList(const pandora::Algorithm &algorithm, const std::string &newListName)
Replace the current list with a pre-saved list; use this new list as a permanent replacement for the ...
static pandora::StatusCode InitializeFragmentation(const pandora::Algorithm &algorithm, const pandora::ClusterList &inputClusterList, std::string &originalClustersListName, std::string &fragmentClustersListName)
Initialize cluster fragmentation operations on clusters in the algorithm input list....
static pandora::StatusCode EndFragmentation(const pandora::Algorithm &algorithm, const std::string &clusterListToSaveName, const std::string &clusterListToDeleteName)
End cluster fragmentation operations on clusters in the algorithm input list.
static pandora::StatusCode AddToCluster(const pandora::Algorithm &algorithm, const pandora::Cluster *const pCluster, const T *const pT)
Add a calo hit, or a list of calo hits, to a cluster.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
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,...
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
LArPointingCluster class.
const Vertex & GetInnerVertex() const
Get the inner vertex.
const Vertex & GetOuterVertex() const
Get the outer vertex.
void UpdateUponDeletion(const pandora::Cluster *const pDeletedCluster)
Update to reflect cluster deletion.
void UpdateForNewCluster(const pandora::Cluster *const pNewCluster)
Update to reflect addition of a new cluster to the problem space.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
virtual void TidyUp()
Tidy member variables in derived class.
NViewTrackMatchingAlgorithm class.
virtual void SetPfoParticleId(PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
Set pfo particle id.
virtual void UpdateForNewCluster(const pandora::Cluster *const pNewCluster)
Update to reflect addition of a new cluster to the problem space.
virtual bool MakeClusterSplits(const SplitPositionMap &splitPositionMap)
Make cluster splits.
void AddToSlidingFitCache(const pandora::Cluster *const pCluster)
Add a new sliding fit result, for the specified cluster, to the algorithm cache.
virtual void UpdateUponDeletion(const pandora::Cluster *const pDeletedCluster)
Update to reflect cluster deletion.
virtual void TidyUp()
Tidy member variables in derived class.
static bool SortSplitPositions(const pandora::CartesianVector &lhs, const pandora::CartesianVector &rhs)
Sort split position cartesian vectors by increasing x coordinate.
virtual bool MakeClusterSplit(const pandora::CartesianVector &splitPosition, const pandora::Cluster *&pCurrentCluster, const pandora::Cluster *&pLowXCluster, const pandora::Cluster *&pHighXCluster) const
Make a cluster split.
void RemoveFromSlidingFitCache(const pandora::Cluster *const pCluster)
Remova an existing sliding fit result, for the specified cluster, from the algorithm cache.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
NViewTrackMatchingAlgorithm()
Default constructor.
virtual ~NViewTrackMatchingAlgorithm()
Destructor.
const TwoDSlidingFitResult & GetCachedSlidingFitResult(const pandora::Cluster *const pCluster) const
Get a sliding fit result from the algorithm cache.
virtual void PrepareInputClusters(pandora::ClusterList &preparedClusterList)
Perform any preparatory steps required on the input clusters, e.g. caching expensive fit results.
virtual void SelectInputClusters(const pandora::ClusterList *const pInputClusterList, pandora::ClusterList &selectedClusterList) const
Select a subset of input clusters for processing in this algorithm.
TwoDSlidingFitResult class.
float GetX() const
Get the cartesian x coordinate.
float GetDotProduct(const CartesianVector &rhs) const
Get the dot product of the cartesian vector with a second cartesian vector.
const OrderedCaloHitList & GetOrderedCaloHitList() const
Get the ordered calo hit list.
void FillCaloHitList(CaloHitList &caloHitList) const
Fill a provided calo hit list with all the calo hits in the ordered calo hit list.
StatusCodeException class.
StatusCode GetStatusCode() const
Get status code.
const CartesianVector & GetPosition() const
Get the vertex position.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
std::unordered_map< const pandora::Cluster *, pandora::CartesianPointVector > SplitPositionMap
HitType
Calorimeter hit type enum.
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< CartesianVector > CartesianPointVector
MANAGED_CONTAINER< const CaloHit * > CaloHitList
StatusCode
The StatusCode enum.