LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::TwoDSlidingFitMultiSplitAlgorithm Class Referenceabstract

TwoDTrackSplittingAlgorithm class. More...

#include "TwoDSlidingFitMultiSplitAlgorithm.h"

Inheritance diagram for lar_content::TwoDSlidingFitMultiSplitAlgorithm:
lar_content::OvershootSplittingAlgorithm

Public Member Functions

 TwoDSlidingFitMultiSplitAlgorithm ()
 Default constructor. More...
 

Protected Types

typedef std::unordered_map< const pandora::Cluster *, pandora::CartesianPointVector > ClusterPositionMap
 

Protected Member Functions

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. More...
 
virtual void FindBestSplitPositions (const TwoDSlidingFitResultMap &slidingFitResultMap, ClusterPositionMap &clusterSplittingMap) const =0
 Determine best split positions based on sliding fit result. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Member Functions

pandora::StatusCode Run ()
 
void BuildSlidingFitResultMap (const pandora::ClusterVector &clusterVector, const unsigned int halfWindowLayers, TwoDSlidingFitResultMap &slidingFitResultMap) const
 Build the map of sliding fit results. More...
 
pandora::StatusCode SplitClusters (const TwoDSlidingFitResultMap &slidingFitResultMap, const ClusterPositionMap &clusterSplittingMap) const
 Split clusters. More...
 
pandora::StatusCode SplitCluster (const TwoDSlidingFitResult &slidingFitResult, const pandora::CartesianPointVector &splitPositionList) const
 Split cluster. More...
 

Private Attributes

unsigned int m_slidingFitHalfWindow
 
std::string m_inputClusterList
 

Detailed Description

TwoDTrackSplittingAlgorithm class.

Definition at line 21 of file TwoDSlidingFitMultiSplitAlgorithm.h.

Member Typedef Documentation

typedef std::unordered_map<const pandora::Cluster *, pandora::CartesianPointVector> lar_content::TwoDSlidingFitMultiSplitAlgorithm::ClusterPositionMap
protected

Definition at line 30 of file TwoDSlidingFitMultiSplitAlgorithm.h.

Constructor & Destructor Documentation

lar_content::TwoDSlidingFitMultiSplitAlgorithm::TwoDSlidingFitMultiSplitAlgorithm ( )

Member Function Documentation

void lar_content::TwoDSlidingFitMultiSplitAlgorithm::BuildSlidingFitResultMap ( const pandora::ClusterVector &  clusterVector,
const unsigned int  halfWindowLayers,
TwoDSlidingFitResultMap slidingFitResultMap 
) const
private

Build the map of sliding fit results.

Parameters
clusterVectorthe vector of selected clusters
halfWindowLayersthe half-window to use for the sliding fits
slidingFitResultMapthe sliding fit result map

Definition at line 74 of file TwoDSlidingFitMultiSplitAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), and lar_content::LArGeometryHelper::GetWirePitch().

Referenced by Run().

76 {
77  for (ClusterVector::const_iterator iter = clusterVector.begin(), iterEnd = clusterVector.end(); iter != iterEnd; ++iter)
78  {
79  if (slidingFitResultMap.end() == slidingFitResultMap.find(*iter))
80  {
81  try
82  {
83  const float slidingFitPitch(LArGeometryHelper::GetWirePitch(this->GetPandora(), LArClusterHelper::GetClusterHitType(*iter)));
84  const TwoDSlidingFitResult slidingFitResult(*iter, halfWindowLayers, slidingFitPitch);
85 
86  if (!slidingFitResultMap.insert(TwoDSlidingFitResultMap::value_type(*iter, slidingFitResult)).second)
87  throw StatusCodeException(STATUS_CODE_FAILURE);
88  }
89  catch (StatusCodeException &statusCodeException)
90  {
91  if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
92  throw statusCodeException;
93  }
94  }
95  }
96 }
intermediate_table::const_iterator const_iterator
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
virtual void lar_content::TwoDSlidingFitMultiSplitAlgorithm::FindBestSplitPositions ( const TwoDSlidingFitResultMap slidingFitResultMap,
ClusterPositionMap clusterSplittingMap 
) const
protectedpure virtual

Determine best split positions based on sliding fit result.

Parameters
slidingFitResultMapmapping from clusters to sliding fit results
clusterSplittingMapmapping from clusters to split positions

Implemented in lar_content::OvershootSplittingAlgorithm.

Referenced by Run().

virtual void lar_content::TwoDSlidingFitMultiSplitAlgorithm::GetListOfCleanClusters ( const pandora::ClusterList *const  pClusterList,
pandora::ClusterVector &  clusterVector 
) const
protectedpure virtual

Populate cluster vector with subset of cluster list, containing clusters judged to be clean.

Parameters
pClusterListaddress of the cluster list
clusterVectorto receive the populated cluster vector

Implemented in lar_content::OvershootSplittingAlgorithm.

Referenced by Run().

StatusCode lar_content::TwoDSlidingFitMultiSplitAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
protected

Definition at line 210 of file TwoDSlidingFitMultiSplitAlgorithm.cc.

References m_inputClusterList, and m_slidingFitHalfWindow.

Referenced by lar_content::OvershootSplittingAlgorithm::ReadSettings().

211 {
212  PANDORA_RETURN_RESULT_IF_AND_IF(
213  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListName", m_inputClusterList));
214 
215  PANDORA_RETURN_RESULT_IF_AND_IF(
216  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitHalfWindow", m_slidingFitHalfWindow));
217 
218  return STATUS_CODE_SUCCESS;
219 }
StatusCode lar_content::TwoDSlidingFitMultiSplitAlgorithm::Run ( )
private

Definition at line 29 of file TwoDSlidingFitMultiSplitAlgorithm.cc.

References BuildSlidingFitResultMap(), FindBestSplitPositions(), GetListOfCleanClusters(), m_inputClusterList, m_slidingFitHalfWindow, and SplitClusters().

30 {
31  std::string originalListName;
32  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentListName<Cluster>(*this, originalListName));
33 
34  if (!m_inputClusterList.empty())
35  {
36  const StatusCode statusCode(PandoraContentApi::ReplaceCurrentList<Cluster>(*this, m_inputClusterList));
37 
38  if (STATUS_CODE_NOT_FOUND == statusCode)
39  {
40  std::cout << "TwoDSlidingFitMultiSplitAlgorithm: cluster list not found " << m_inputClusterList << std::endl;
41  return STATUS_CODE_SUCCESS;
42  }
43 
44  if (STATUS_CODE_SUCCESS != statusCode)
45  return statusCode;
46  }
47 
48  const ClusterList *pClusterList = NULL;
49  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pClusterList));
50 
51  // Get ordered list of candidate clusters
52  ClusterVector clusterVector;
53  this->GetListOfCleanClusters(pClusterList, clusterVector);
54 
55  // Build a set of sliding fit results for clean clusters
56  TwoDSlidingFitResultMap slidingFitResultMap;
57  this->BuildSlidingFitResultMap(clusterVector, m_slidingFitHalfWindow, slidingFitResultMap);
58 
59  // Find best split positions for each cluster
60  ClusterPositionMap clusterSplittingMap;
61  this->FindBestSplitPositions(slidingFitResultMap, clusterSplittingMap);
62 
63  // Perform splits
64  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->SplitClusters(slidingFitResultMap, clusterSplittingMap));
65 
66  if (!m_inputClusterList.empty())
67  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Cluster>(*this, originalListName));
68 
69  return STATUS_CODE_SUCCESS;
70 }
virtual void FindBestSplitPositions(const TwoDSlidingFitResultMap &slidingFitResultMap, ClusterPositionMap &clusterSplittingMap) const =0
Determine best split positions based on sliding fit result.
pandora::StatusCode SplitClusters(const TwoDSlidingFitResultMap &slidingFitResultMap, const ClusterPositionMap &clusterSplittingMap) const
Split clusters.
void BuildSlidingFitResultMap(const pandora::ClusterVector &clusterVector, const unsigned int halfWindowLayers, TwoDSlidingFitResultMap &slidingFitResultMap) const
Build the map of sliding fit results.
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...
std::unordered_map< const pandora::Cluster *, pandora::CartesianPointVector > ClusterPositionMap
std::unordered_map< const pandora::Cluster *, TwoDSlidingFitResult > TwoDSlidingFitResultMap
std::vector< art::Ptr< recob::Cluster > > ClusterVector
StatusCode lar_content::TwoDSlidingFitMultiSplitAlgorithm::SplitCluster ( const TwoDSlidingFitResult slidingFitResult,
const pandora::CartesianPointVector &  splitPositionList 
) const
private

Split cluster.

Parameters
slidingFitResultinput sliding fit result
splitPositionListvector of split positions

Definition at line 132 of file TwoDSlidingFitMultiSplitAlgorithm.cc.

References f, lar_content::TwoDSlidingFitResult::GetCluster(), lar_content::TwoDSlidingFitResult::GetL(), lar_content::TwoDSlidingFitResult::GetLocalPosition(), and lar_content::TwoDSlidingFitResult::GetMaxLayer().

Referenced by SplitClusters().

133 {
134  const Cluster *const pCluster = slidingFitResult.GetCluster();
135 
136  // Get split positions for this cluster
137  FloatVector displacementVector;
138 
139  for (CartesianPointVector::const_iterator pIter = splitPositionVector.begin(), pIterEnd = splitPositionVector.end(); pIter != pIterEnd; ++pIter)
140  {
141  const CartesianVector &splitPosition = *pIter;
142 
143  float rL(0.f), rT(0.f);
144  slidingFitResult.GetLocalPosition(splitPosition, rL, rT);
145  displacementVector.push_back(rL);
146  }
147 
148  const float bigL(2.f * slidingFitResult.GetL(slidingFitResult.GetMaxLayer()));
149  displacementVector.push_back(-bigL);
150  displacementVector.push_back(+bigL);
151 
152  std::sort(displacementVector.begin(), displacementVector.end());
153 
154  // Begin cluster fragmentation operations
155  const ClusterList clusterList(1, pCluster);
156  std::string clusterListToSave, clusterListToDelete;
157 
158  PANDORA_RETURN_RESULT_IF(
159  STATUS_CODE_SUCCESS, !=, PandoraContentApi::InitializeFragmentation(*this, clusterList, clusterListToDelete, clusterListToSave));
160 
161  CaloHitList oldCaloHitList;
162  pCluster->GetOrderedCaloHitList().FillCaloHitList(oldCaloHitList);
163 
164  bool foundPreviousL(false);
165  float prevL(0.f);
166 
167  for (FloatVector::const_iterator fIter = displacementVector.begin(), fIterEnd = displacementVector.end(); fIter != fIterEnd; ++fIter)
168  {
169  const float nextL(*fIter);
170 
171  if (foundPreviousL)
172  {
173  // Select hits for new cluster
174  CaloHitList newCaloHitList;
175 
176  for (CaloHitList::const_iterator hIter = oldCaloHitList.begin(), hIterEnd = oldCaloHitList.end(); hIter != hIterEnd; ++hIter)
177  {
178  const CaloHit *const pCaloHit = *hIter;
179 
180  float rL(0.f), rT(0.f);
181  slidingFitResult.GetLocalPosition(pCaloHit->GetPositionVector(), rL, rT);
182 
183  if (rL >= prevL && rL < nextL)
184  newCaloHitList.push_back(pCaloHit);
185  }
186 
187  if (newCaloHitList.empty())
188  continue;
189 
190  // Create new cluster
191  PandoraContentApi::Cluster::Parameters newParameters;
192  newParameters.m_caloHitList = newCaloHitList;
193 
194  const Cluster *pNewCluster(NULL);
195  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*this, newParameters, pNewCluster));
196  }
197 
198  prevL = nextL;
199  foundPreviousL = true;
200  }
201 
202  // End cluster fragmentation operations
203  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::EndFragmentation(*this, clusterListToSave, clusterListToDelete));
204 
205  return STATUS_CODE_SUCCESS;
206 }
intermediate_table::const_iterator const_iterator
TFile f
Definition: plotHisto.C:6
StatusCode lar_content::TwoDSlidingFitMultiSplitAlgorithm::SplitClusters ( const TwoDSlidingFitResultMap slidingFitResultMap,
const ClusterPositionMap clusterSplittingMap 
) const
private

Split clusters.

Parameters
slidingFitResultMapmapping from clusters to sliding fit results
clusterSplittingMapmapping from clusters to split positions

Definition at line 100 of file TwoDSlidingFitMultiSplitAlgorithm.cc.

References lar_content::LArClusterHelper::SortByNHits(), and SplitCluster().

Referenced by Run().

102 {
103  ClusterList clusterList;
104  for (const auto &mapEntry : clusterSplittingMap)
105  clusterList.push_back(mapEntry.first);
106  clusterList.sort(LArClusterHelper::SortByNHits);
107 
108  for (const Cluster *const pCluster : clusterList)
109  {
110  const CartesianPointVector &splitPositionVector(clusterSplittingMap.at(pCluster));
111 
112  if (splitPositionVector.empty())
113  continue;
114 
115  TwoDSlidingFitResultMap::const_iterator sIter = slidingFitResultMap.find(pCluster);
116  if (slidingFitResultMap.end() == sIter)
117  throw StatusCodeException(STATUS_CODE_FAILURE);
118 
119  const TwoDSlidingFitResult &slidingFitResult = sIter->second;
120 
121  StatusCode statusCode(this->SplitCluster(slidingFitResult, splitPositionVector));
122 
123  if (STATUS_CODE_SUCCESS != statusCode)
124  return statusCode;
125  }
126 
127  return STATUS_CODE_SUCCESS;
128 }
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.
intermediate_table::const_iterator const_iterator
pandora::StatusCode SplitCluster(const TwoDSlidingFitResult &slidingFitResult, const pandora::CartesianPointVector &splitPositionList) const
Split cluster.

Member Data Documentation

std::string lar_content::TwoDSlidingFitMultiSplitAlgorithm::m_inputClusterList
private

Definition at line 80 of file TwoDSlidingFitMultiSplitAlgorithm.h.

Referenced by ReadSettings(), and Run().

unsigned int lar_content::TwoDSlidingFitMultiSplitAlgorithm::m_slidingFitHalfWindow
private

Definition at line 79 of file TwoDSlidingFitMultiSplitAlgorithm.h.

Referenced by ReadSettings(), and Run().


The documentation for this class was generated from the following files: