29 std::string originalListName;
36 if (STATUS_CODE_NOT_FOUND == statusCode)
38 std::cout <<
"TwoDSlidingFitMultiSplitAlgorithm: cluster list not found " <<
m_inputClusterList << std::endl;
39 return STATUS_CODE_SUCCESS;
42 if (STATUS_CODE_SUCCESS != statusCode)
67 return STATUS_CODE_SUCCESS;
77 for (ClusterVector::const_iterator iter = clusterVector.begin(), iterEnd = clusterVector.end(); iter != iterEnd; ++iter)
79 if (slidingFitResultMap.end() == slidingFitResultMap.find(*iter))
85 if (!slidingFitResultMap.insert(TwoDSlidingFitResultMap::value_type(*iter, slidingFitResult)).second)
90 if (STATUS_CODE_FAILURE == statusCodeException.
GetStatusCode())
91 throw statusCodeException;
103 for (
const auto &mapEntry : clusterSplittingMap)
104 clusterList.push_back(mapEntry.first);
107 for (
const Cluster *
const pCluster : clusterList)
111 if (splitPositionVector.empty())
114 TwoDSlidingFitResultMap::const_iterator sIter = slidingFitResultMap.find(pCluster);
115 if (slidingFitResultMap.end() == sIter)
122 if (STATUS_CODE_SUCCESS != statusCode)
126 return STATUS_CODE_SUCCESS;
138 for (CartesianPointVector::const_iterator pIter = splitPositionVector.begin(), pIterEnd = splitPositionVector.end(); pIter != pIterEnd; ++pIter)
142 float rL(0.f), rT(0.f);
144 displacementVector.push_back(rL);
147 const float bigL(2.f * slidingFitResult.
GetL(slidingFitResult.
GetMaxLayer()));
148 displacementVector.push_back(-bigL);
149 displacementVector.push_back(+bigL);
151 std::sort(displacementVector.begin(), displacementVector.end());
155 std::string clusterListToSave, clusterListToDelete;
163 bool foundPreviousL(
false);
166 for (FloatVector::const_iterator fIter = displacementVector.begin(), fIterEnd = displacementVector.end(); fIter != fIterEnd; ++fIter)
168 const float nextL(*fIter);
175 for (CaloHitList::const_iterator hIter = oldCaloHitList.begin(), hIterEnd = oldCaloHitList.end(); hIter != hIterEnd; ++hIter)
177 const CaloHit *
const pCaloHit = *hIter;
179 float rL(0.f), rT(0.f);
182 if (rL >= prevL && rL < nextL)
183 newCaloHitList.push_back(pCaloHit);
186 if (newCaloHitList.empty())
190 PandoraContentApi::Cluster::Parameters newParameters;
191 newParameters.m_caloHitList = newCaloHitList;
193 const Cluster *pNewCluster(NULL);
194 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*
this, newParameters, pNewCluster));
198 foundPreviousL =
true;
204 return STATUS_CODE_SUCCESS;
217 return STATUS_CODE_SUCCESS;
Header file for the cluster helper class.
Header file for the geometry helper class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Header file for the 2D sliding fit multi-split algorithm 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 GetCurrentList(const pandora::Algorithm &algorithm, const T *&pT)
Get the current list.
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 GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
pandora::StatusCode Run()
Run the algorithm.
void BuildSlidingFitResultMap(const pandora::ClusterVector &clusterVector, const unsigned int halfWindowLayers, TwoDSlidingFitResultMap &slidingFitResultMap) const
Build the map of sliding fit results.
unsigned int m_slidingFitHalfWindow
std::string m_inputClusterList
std::unordered_map< const pandora::Cluster *, pandora::CartesianPointVector > ClusterPositionMap
virtual void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &clusterVector) const =0
Populate cluster vector with subset of cluster list, containing clusters judged to be clean.
pandora::StatusCode SplitCluster(const TwoDSlidingFitResult &slidingFitResult, const pandora::CartesianPointVector &splitPositionList) const
Split cluster.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
pandora::StatusCode SplitClusters(const TwoDSlidingFitResultMap &slidingFitResultMap, const ClusterPositionMap &clusterSplittingMap) const
Split clusters.
virtual void FindBestSplitPositions(const TwoDSlidingFitResultMap &slidingFitResultMap, ClusterPositionMap &clusterSplittingMap) const =0
Determine best split positions based on sliding fit result.
TwoDSlidingFitMultiSplitAlgorithm()
Default constructor.
TwoDSlidingFitResult class.
float GetL(const int layer) const
Get longitudinal coordinate for a given sliding linear fit layer number.
void GetLocalPosition(const pandora::CartesianVector &position, float &rL, float &rT) const
Get local sliding fit coordinates for a given global position.
int GetMaxLayer() const
Get the maximum occupied layer in the sliding fit.
const pandora::Cluster * GetCluster() const
Get the address of the cluster, if originally provided.
const CartesianVector & GetPositionVector() const
Get the position vector of center of calorimeter cell, units mm.
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.
const Pandora & GetPandora() const
Get the associated pandora instance.
StatusCodeException class.
StatusCode GetStatusCode() const
Get status code.
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 *, TwoDSlidingFitResult > TwoDSlidingFitResultMap
std::vector< const Cluster * > ClusterVector
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< CartesianVector > CartesianPointVector
MANAGED_CONTAINER< const CaloHit * > CaloHitList
std::vector< float > FloatVector
StatusCode
The StatusCode enum.