LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
TwoDSlidingFitSplittingAlgorithm.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
13 
15 
16 using namespace pandora;
17 
18 namespace lar_content
19 {
20 
21 TwoDSlidingFitSplittingAlgorithm::TwoDSlidingFitSplittingAlgorithm() :
22  m_slidingFitHalfWindow(20),
23  m_minClusterLength(10.f)
24 {
25 }
26 
27 //------------------------------------------------------------------------------------------------------------------------------------------
28 
29 StatusCode TwoDSlidingFitSplittingAlgorithm::DivideCaloHits(const Cluster *const pCluster, CaloHitList &firstHitList, CaloHitList &secondHitList) const
30 {
32  return STATUS_CODE_NOT_FOUND;
33 
34  try
35  {
36  const float slidingFitPitch(LArGeometryHelper::GetWirePitch(this->GetPandora(), LArClusterHelper::GetClusterHitType(pCluster)));
37 
38  const TwoDSlidingFitResult slidingFitResult(pCluster, m_slidingFitHalfWindow, slidingFitPitch);
39  CartesianVector splitPosition(0.f, 0.f, 0.f);
40 
41  if (STATUS_CODE_SUCCESS == this->FindBestSplitPosition(slidingFitResult, splitPosition))
42  {
43  return this->DivideCaloHits(slidingFitResult, splitPosition, firstHitList, secondHitList);
44  }
45  }
46  catch (StatusCodeException &statusCodeException)
47  {
48  if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
49  throw statusCodeException;
50  }
51 
52  return STATUS_CODE_NOT_FOUND;
53 }
54 
55 //------------------------------------------------------------------------------------------------------------------------------------------
56 
58  const CartesianVector &splitPosition, CaloHitList &firstCaloHitList, CaloHitList &secondCaloHitList) const
59 {
60  float rL(0.f), rT(0.f);
61  slidingFitResult.GetLocalPosition(splitPosition, rL, rT);
62 
63  const Cluster *const pCluster(slidingFitResult.GetCluster());
64  const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
65 
66  for (OrderedCaloHitList::const_iterator iter = orderedCaloHitList.begin(); iter != orderedCaloHitList.end(); ++iter)
67  {
68  for (CaloHitList::const_iterator hitIter = iter->second->begin(), hitIterEnd = iter->second->end(); hitIter != hitIterEnd; ++hitIter)
69  {
70  const CaloHit *const pCaloHit = *hitIter;
71 
72  float thisL(0.f), thisT(0.f);
73  slidingFitResult.GetLocalPosition(pCaloHit->GetPositionVector(), thisL, thisT);
74 
75  if (thisL < rL)
76  {
77  firstCaloHitList.push_back(pCaloHit);
78  }
79  else
80  {
81  secondCaloHitList.push_back(pCaloHit);
82  }
83  }
84  }
85 
86  if (firstCaloHitList.empty() || secondCaloHitList.empty())
87  return STATUS_CODE_NOT_FOUND;
88 
89  return STATUS_CODE_SUCCESS;
90 }
91 
92 //------------------------------------------------------------------------------------------------------------------------------------------
93 
94 StatusCode TwoDSlidingFitSplittingAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
95 {
96  PANDORA_RETURN_RESULT_IF_AND_IF(
97  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitHalfWindow", m_slidingFitHalfWindow));
98 
99  PANDORA_RETURN_RESULT_IF_AND_IF(
100  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterLength", m_minClusterLength));
101 
102  return ClusterSplittingAlgorithm::ReadSettings(xmlHandle);
103 }
104 
105 } // namespace lar_content
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.
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.
TFile f
Definition: plotHisto.C:6
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.
static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
const pandora::Cluster * GetCluster() const
Get the address of the cluster, if originally provided.
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)
void GetLocalPosition(const pandora::CartesianVector &position, float &rL, float &rT) const
Get local sliding fit coordinates for a given global position.