22 m_nMaxTensorToolRepeats(1000),
23 m_slidingFitWindow(20),
24 m_ignoreUnavailableClusters(true),
25 m_minClusterCaloHits(5),
26 m_minClusterLengthSquared(3.f * 3.f),
27 m_minShowerMatchedFraction(0.2f),
28 m_minShowerMatchedPoints(20),
55 if (STATUS_CODE_FAILURE == statusCodeException.
GetStatusCode())
56 throw statusCodeException;
76 for (ClusterList::const_iterator iter = pInputClusterList->begin(), iterEnd = pInputClusterList->end(); iter != iterEnd; ++iter)
78 const Cluster *
const pCluster = *iter;
89 selectedClusterList.push_back(pCluster);
102 for (ClusterList::iterator iter = preparedClusterList.begin(), iterEnd = preparedClusterList.end(); iter != iterEnd;)
104 const Cluster *
const pCluster(*iter);
113 preparedClusterList.erase(iter++);
115 if (STATUS_CODE_FAILURE == statusCodeException.
GetStatusCode())
116 throw statusCodeException;
141 if (!
m_slidingFitResultMap.insert(TwoDSlidingShowerFitResultMap::value_type(pCluster, slidingShowerFitResult)).second)
161 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, this->
CalculateOverlapResult(pClusterU, pClusterV, pClusterW, overlapResult));
178 if (xSampling.
m_xOverlapSpan < std::numeric_limits<float>::epsilon())
179 return STATUS_CODE_NOT_FOUND;
182 this->
GetShowerPositionMaps(fitResultU, fitResultV, fitResultW, xSampling, positionMapsU, positionMapsV, positionMapsW);
184 unsigned int nSampledHitsU(0), nMatchedHitsU(0);
187 unsigned int nSampledHitsV(0), nMatchedHitsV(0);
190 unsigned int nSampledHitsW(0), nMatchedHitsW(0);
193 const unsigned int nMatchedHits(nMatchedHitsU + nMatchedHitsV + nMatchedHitsW);
194 const unsigned int nSampledHits(nSampledHitsU + nSampledHitsV + nSampledHitsW);
196 if (0 == nSampledHits)
197 return STATUS_CODE_NOT_FOUND;
204 return STATUS_CODE_NOT_FOUND;
208 ClusterList clusterList{pClusterU, pClusterV, pClusterW};
213 overlapResult = showerOverlapResult;
214 return STATUS_CODE_SUCCESS;
223 const unsigned int nPoints(
static_cast<unsigned int>(xSampling.
m_nPoints));
225 for (
unsigned n = 0; n <= nPoints; ++n)
227 const float x(xSampling.
m_minX + (xSampling.
m_maxX - xSampling.
m_minX) *
static_cast<float>(n) /
static_cast<float>(nPoints));
230 if (STATUS_CODE_SUCCESS != xSampling.
GetBin(x, xBin))
238 std::sort(uValues.begin(), uValues.end());
239 std::sort(vValues.begin(), vValues.end());
240 std::sort(wValues.begin(), wValues.end());
242 if ((uValues.size() > 1) && (vValues.size() > 1))
244 const float uMin(uValues.front()), uMax(uValues.back());
245 const float vMin(vValues.front()), vMax(vValues.back());
250 positionMapsW.first.insert(ShowerPositionMap::value_type(xBin,
ShowerExtent(x, uv2wMinMin, uv2wMaxMax)));
251 positionMapsW.second.insert(ShowerPositionMap::value_type(xBin,
ShowerExtent(x, uv2wMinMax, uv2wMaxMin)));
254 if ((uValues.size() > 1) && (wValues.size() > 1))
256 const float uMin(uValues.front()), uMax(uValues.back());
257 const float wMin(wValues.front()), wMax(wValues.back());
262 positionMapsV.first.insert(ShowerPositionMap::value_type(xBin,
ShowerExtent(x, uw2vMinMin, uw2vMaxMax)));
263 positionMapsV.second.insert(ShowerPositionMap::value_type(xBin,
ShowerExtent(x, uw2vMinMax, uw2vMaxMin)));
266 if ((vValues.size() > 1) && (wValues.size() > 1))
268 const float vMin(vValues.front()), vMax(vValues.back());
269 const float wMin(wValues.front()), wMax(wValues.back());
274 positionMapsU.first.insert(ShowerPositionMap::value_type(xBin,
ShowerExtent(x, vw2uMinMin, vw2uMaxMax)));
275 positionMapsU.second.insert(ShowerPositionMap::value_type(xBin,
ShowerExtent(x, vw2uMinMax, vw2uMaxMin)));
283 const ShowerPositionMapPair &positionMaps,
unsigned int &nSampledHits,
unsigned int &nMatchedHits)
const
285 if ((xSampling.
m_maxX - xSampling.
m_minX) < std::numeric_limits<float>::epsilon())
290 unsigned int nMatchedHits1(0), nMatchedHits2(0);
295 for (CaloHitList::const_iterator hIter = iter->second->begin(), hIterEnd = iter->second->end(); hIter != hIterEnd; ++hIter)
297 const CaloHit *
const pCaloHit = *hIter;
302 if (STATUS_CODE_SUCCESS != xSampling.
GetBin(x, xBin))
307 ShowerPositionMap::const_iterator positionIter1 = positionMaps.first.find(xBin);
308 ShowerPositionMap::const_iterator positionIter2 = positionMaps.second.find(xBin);
310 if ((positionMaps.first.end() != positionIter1) && (z > positionIter1->second.GetLowEdgeZ()) && (z < positionIter1->second.GetHighEdgeZ()))
313 if ((positionMaps.second.end() != positionIter2) && (z > positionIter2->second.GetLowEdgeZ()) && (z < positionIter2->second.GetHighEdgeZ()))
318 nMatchedHits = std::max(nMatchedHits1, nMatchedHits2);
325 unsigned int repeatCounter(0);
329 if ((*iter)->Run(
this, this->GetMatchingControl().GetOverlapTensor()))
359 const float nPointsU(
361 const float nPointsV(
363 const float nPointsW(
365 m_nPoints = 1.f + ((nPointsU + nPointsV + nPointsW) / 3.f);
373 if (((x - m_minX) < -std::numeric_limits<float>::epsilon()) || ((x - m_maxX) > +std::numeric_limits<float>::epsilon()))
374 return STATUS_CODE_NOT_FOUND;
376 xBin =
static_cast<int>(0.5f + m_nPoints * (x - m_minX) / (m_maxX - m_minX));
377 return STATUS_CODE_SUCCESS;
388 for (AlgorithmToolVector::const_iterator iter = algorithmToolVector.begin(), iterEnd = algorithmToolVector.end(); iter != iterEnd; ++iter)
392 if (!pShowerTensorTool)
393 return STATUS_CODE_INVALID_PARAMETER;
Header file for the cluster helper class.
Header file for the geometry helper class.
#define PANDORA_THROW_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Header file for the three view showers algorithm class.
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
static float MergeTwoPositions(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const float position1, const float position2)
Merge two views (U,V) to give a third view (Z).
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
void UpdateUponDeletion(const pandora::Cluster *const pDeletedCluster)
void UpdateForNewCluster(const pandora::Cluster *const pNewCluster)
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
MatchingType & GetMatchingControl()
Get the matching control.
void SetOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW, const OverlapResult &overlapResult)
Set overlap result.
ShowerOverlapResult class.
unsigned int GetNMatchedSamplingPoints() const
Get the number of matched sampling points.
float GetMatchedFraction() const
Get the fraction of sampling points resulting in a match.
bool IsInitialized() const
Whether the track overlap result has been initialized.
TensorType & GetOverlapTensor()
Get the overlap tensor.
float m_minX
The min x value of the common x-overlap range.
float m_nPoints
The number of sampling points to be used.
float m_wMaxX
The max x value in the w view.
float m_uMinX
The min x value in the u view.
float m_maxX
The max x value of the common x-overlap range.
float m_vMinX
The min x value in the v view.
float m_uMaxX
The max x value in the u view.
XSampling(const TwoDSlidingFitResult &fitResultU, const TwoDSlidingFitResult &fitResultV, const TwoDSlidingFitResult &fitResultW)
Constructor.
float m_xOverlapSpan
The x-overlap span.
float m_vMaxX
The max x value in the v view.
pandora::StatusCode GetBin(const float x, int &xBin) const
Convert an x position into a sampling bin.
float m_wMinX
The min x value in the w view.
float m_minClusterLengthSquared
The min length (squared) in base cluster selection method.
void UpdateUponDeletion(const pandora::Cluster *const pDeletedCluster)
Update to reflect cluster deletion.
void CalculateOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW)
Calculate cluster overlap result and store in container.
void PrepareInputClusters(pandora::ClusterList &preparedClusterList)
Perform any preparatory steps required on the input clusters, e.g. caching expensive fit results.
void RemoveFromSlidingFitCache(const pandora::Cluster *const pCluster)
Remova an existing sliding fit result, for the specified cluster, from the algorithm cache.
TwoDSlidingShowerFitResultMap m_slidingFitResultMap
The sliding shower fit result map.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
void ExamineOverlapContainer()
Examine contents of overlap container, collect together best-matching 2D particles and modify cluster...
std::pair< ShowerPositionMap, ShowerPositionMap > ShowerPositionMapPair
TensorToolVector m_algorithmToolVector
The algorithm tool vector.
float m_minShowerMatchedFraction
The minimum shower matched sampling fraction to allow shower grouping.
unsigned int m_nMaxTensorToolRepeats
The maximum number of repeat loops over tensor tools.
unsigned int m_minClusterCaloHits
The min number of hits in base cluster selection method.
void GetShowerPositionMaps(const TwoDSlidingShowerFitResult &fitResultU, const TwoDSlidingShowerFitResult &fitResultV, const TwoDSlidingShowerFitResult &fitResultW, const XSampling &xSampling, ShowerPositionMapPair &positionMapsU, ShowerPositionMapPair &positionMapsV, ShowerPositionMapPair &positionMapsW) const
Get the shower position maps.
void TidyUp()
Tidy member variables in derived class.
ThreeViewShowersAlgorithm()
Default constructor.
void UpdateForNewCluster(const pandora::Cluster *const pNewCluster)
Update to reflect addition of a new cluster to the problem space.
bool m_ignoreUnavailableClusters
Whether to ignore (skip-over) unavailable clusters.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
void AddToSlidingFitCache(const pandora::Cluster *const pCluster)
Add a new sliding fit result, for the specified cluster, to the algorithm cache.
const TwoDSlidingShowerFitResult & GetCachedSlidingFitResult(const pandora::Cluster *const pCluster) const
Get a sliding shower fit result from the algorithm cache.
void GetBestHitOverlapFraction(const pandora::Cluster *const pCluster, const XSampling &xSampling, const ShowerPositionMapPair &positionMaps, unsigned int &nSampledHits, unsigned int &nMatchedHits) const
Get the best fraction of hits, in the common x-overlap range, contained within the provided pair of s...
unsigned int m_minShowerMatchedPoints
The minimum number of matched shower sampling points to allow shower grouping.
void SelectInputClusters(const pandora::ClusterList *const pInputClusterList, pandora::ClusterList &selectedClusterList) const
Select a subset of input clusters for processing in this algorithm.
bool m_visualize
Visualize cluster matching procedure.
TwoDSlidingFitResult class.
int GetMaxLayer() const
Get the maximum occupied layer in the sliding fit.
int GetMinLayer() const
Get the minimum occupied layer in the sliding fit.
void GetMinAndMaxX(float &minX, float &maxX) const
Get the minimum and maximum x coordinates associated with the sliding fit.
TwoDSlidingShowerFitResult class.
void GetShowerEdges(const float x, const bool widenIfAmbiguity, pandora::FloatVector &edgePositions) const
Get the most appropriate shower edges at a given x coordinate.
const TwoDSlidingFitResult & GetShowerFitResult() const
Get the sliding fit result for the full shower cluster.
const CartesianVector & GetPositionVector() const
Get the position vector of center of calorimeter cell, units mm.
float GetX() const
Get the cartesian x coordinate.
float GetZ() const
Get the cartesian z coordinate.
bool IsAvailable() const
Whether the cluster is available to be added to a particle flow object.
unsigned int GetNCaloHits() const
Get the number of calo hits in the cluster.
const OrderedCaloHitList & GetOrderedCaloHitList() const
Get the ordered calo hit list.
Calo hit lists arranged by pseudo layer.
const_iterator end() const
Returns a const iterator referring to the past-the-end element in the ordered calo hit list.
const_iterator begin() const
Returns a const iterator referring to the first element in the ordered calo hit list.
TheList::const_iterator const_iterator
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.
static StatusCode ProcessAlgorithmToolList(const Algorithm &algorithm, const TiXmlHandle &xmlHandle, const std::string &listName, AlgorithmToolVector &algorithmToolVector)
Process a list of algorithms tools in an xml file.
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< AlgorithmTool * > AlgorithmToolVector
std::vector< float > FloatVector
StatusCode
The StatusCode enum.