All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TwoDSlidingFitSplittingAlgorithm.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArTwoDReco/LArClusterSplitting/TwoDSlidingFitSplittingAlgorithm.cc
3  *
4  * @brief Implementation of the two dimensional sliding fit splitting algorithm class.
5  *
6  * $Log: $
7  */
8 
9 #include "Pandora/AlgorithmHeaders.h"
10 
13 
15 
16 using namespace pandora;
17 
18 namespace lar_content
19 {
20 
21 TwoDSlidingFitSplittingAlgorithm::TwoDSlidingFitSplittingAlgorithm() : m_slidingFitHalfWindow(20), m_minClusterLength(10.f)
22 {
23 }
24 
25 //------------------------------------------------------------------------------------------------------------------------------------------
26 
27 StatusCode TwoDSlidingFitSplittingAlgorithm::DivideCaloHits(const Cluster *const pCluster, CaloHitList &firstHitList, CaloHitList &secondHitList) const
28 {
30  return STATUS_CODE_NOT_FOUND;
31 
32  try
33  {
34  const float slidingFitPitch(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
35 
36  const TwoDSlidingFitResult slidingFitResult(pCluster, m_slidingFitHalfWindow, slidingFitPitch);
37  CartesianVector splitPosition(0.f, 0.f, 0.f);
38 
39  if (STATUS_CODE_SUCCESS == this->FindBestSplitPosition(slidingFitResult, splitPosition))
40  {
41  return this->DivideCaloHits(slidingFitResult, splitPosition, firstHitList, secondHitList);
42  }
43  }
44  catch (StatusCodeException &statusCodeException)
45  {
46  if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
47  throw statusCodeException;
48  }
49 
50  return STATUS_CODE_NOT_FOUND;
51 }
52 
53 //------------------------------------------------------------------------------------------------------------------------------------------
54 
55 StatusCode TwoDSlidingFitSplittingAlgorithm::DivideCaloHits(const TwoDSlidingFitResult &slidingFitResult,
56  const CartesianVector &splitPosition, CaloHitList &firstCaloHitList, CaloHitList &secondCaloHitList) const
57 {
58  float rL(0.f), rT(0.f);
59  slidingFitResult.GetLocalPosition(splitPosition, rL, rT);
60 
61  const Cluster *const pCluster(slidingFitResult.GetCluster());
62  const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
63 
64  for (OrderedCaloHitList::const_iterator iter = orderedCaloHitList.begin(); iter != orderedCaloHitList.end(); ++iter)
65  {
66  for (CaloHitList::const_iterator hitIter = iter->second->begin(), hitIterEnd = iter->second->end(); hitIter != hitIterEnd; ++hitIter)
67  {
68  const CaloHit *const pCaloHit = *hitIter;
69 
70  float thisL(0.f), thisT(0.f);
71  slidingFitResult.GetLocalPosition(pCaloHit->GetPositionVector(), thisL, thisT);
72 
73  if (thisL < rL)
74  {
75  firstCaloHitList.push_back(pCaloHit);
76  }
77  else
78  {
79  secondCaloHitList.push_back(pCaloHit);
80  }
81  }
82  }
83 
84  if (firstCaloHitList.empty() || secondCaloHitList.empty())
85  return STATUS_CODE_NOT_FOUND;
86 
87  return STATUS_CODE_SUCCESS;
88 }
89 
90 //------------------------------------------------------------------------------------------------------------------------------------------
91 
92 StatusCode TwoDSlidingFitSplittingAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
93 {
94  PANDORA_RETURN_RESULT_IF_AND_IF(
95  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitHalfWindow", m_slidingFitHalfWindow));
96 
97  PANDORA_RETURN_RESULT_IF_AND_IF(
98  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterLength", m_minClusterLength));
99 
100  return ClusterSplittingAlgorithm::ReadSettings(xmlHandle);
101 }
102 
103 } // namespace lar_content
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
Header file for the geometry helper class.
pandora::StatusCode DivideCaloHits(const pandora::Cluster *const pCluster, pandora::CaloHitList &firstCaloHitList, pandora::CaloHitList &secondCaloHitList) const
Divide calo hits in a cluster into two lists, each associated with a separate fragment cluster...
Header file for the cluster helper class.
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
Definition: reco_sbnd.fcl:182
Header file for the two dimensional sliding fit splitting algorithm class.
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
virtual pandora::StatusCode FindBestSplitPosition(const TwoDSlidingFitResult &slidingFitResult, pandora::CartesianVector &splitPosition) const =0
Use sliding linear fit to identify the best split position.