LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
lar_content::LayerSplittingAlgorithm Class Reference

LayerSplittingAlgorithm class. More...

#include "LayerSplittingAlgorithm.h"

Inheritance diagram for lar_content::LayerSplittingAlgorithm:
lar_content::ClusterSplittingAlgorithm

Public Member Functions

 LayerSplittingAlgorithm ()
 Default constructor. More...
 

Protected Member Functions

virtual pandora::StatusCode Run ()
 
pandora::StatusCode RunUsingCurrentList () const
 Run the algorithm using the current cluster list as input. More...
 

Private Member Functions

pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
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. More...
 
pandora::StatusCode FindBestSplitLayer (const pandora::Cluster *const pCluster, unsigned int &splitLayer) const
 Find the best layer for splitting the cluster. More...
 
pandora::StatusCode DivideCaloHits (const pandora::Cluster *const pCluster, const unsigned int &splitLayer, pandora::CaloHitList &firstCaloHitList, pandora::CaloHitList &secondCaloHitList) const
 Split the cluster into two fragments at the input layer. More...
 
float CalculateRms (const pandora::Cluster *const pCluster, const unsigned int &firstLayer, const unsigned int &secondLayer) const
 Calculate rms deviation of cluster centroids between two extremal layers. More...
 

Private Attributes

unsigned int m_minClusterLayers
 
unsigned int m_layerWindow
 
float m_maxScatterRms
 
float m_maxScatterCosTheta
 
float m_maxSlidingCosTheta
 

Detailed Description

LayerSplittingAlgorithm class.

Definition at line 19 of file LayerSplittingAlgorithm.h.

Constructor & Destructor Documentation

lar_content::LayerSplittingAlgorithm::LayerSplittingAlgorithm ( )

Member Function Documentation

float lar_content::LayerSplittingAlgorithm::CalculateRms ( const pandora::Cluster *const  pCluster,
const unsigned int &  firstLayer,
const unsigned int &  secondLayer 
) const
private

Calculate rms deviation of cluster centroids between two extremal layers.

Parameters
pClusterthe input cluster
firstLayerthe first extremal layer
secondLayerthe second extremal layer

Definition at line 118 of file LayerSplittingAlgorithm.cc.

References DivideCaloHits(), f, max, and min.

Referenced by FindBestSplitLayer().

119 {
120  const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
121 
122  const unsigned int innerLayer(std::min(firstLayer, secondLayer));
123  const unsigned int outerLayer(std::max(firstLayer, secondLayer));
124 
125  const CartesianVector innerPosition(pCluster->GetCentroid(innerLayer));
126  const CartesianVector outerPosition(pCluster->GetCentroid(outerLayer));
127  const CartesianVector predictedDirection((outerPosition - innerPosition).GetUnitVector());
128 
129  float totalChi2(0.f);
130  float totalLayers(0.f);
131 
132  for (unsigned int iLayer = innerLayer + 1; iLayer + 1 < outerLayer; ++iLayer)
133  {
134  if (orderedCaloHitList.find(iLayer) == orderedCaloHitList.end())
135  continue;
136 
137  const CartesianVector hitPosition(pCluster->GetCentroid(iLayer));
138  const CartesianVector predictedPosition(innerPosition + predictedDirection * predictedDirection.GetDotProduct(hitPosition - innerPosition));
139 
140  totalChi2 += (predictedPosition - hitPosition).GetMagnitudeSquared();
141  totalLayers += 1.f;
142  }
143 
144  if (totalLayers > 0.f)
145  return std::sqrt(totalChi2/totalLayers);
146 
147  return 0.f;
148 }
TFile f
Definition: plotHisto.C:6
Int_t max
Definition: plot.C:27
Int_t min
Definition: plot.C:26
pandora::StatusCode lar_content::LayerSplittingAlgorithm::DivideCaloHits ( const pandora::Cluster *const  pCluster,
pandora::CaloHitList &  firstCaloHitList,
pandora::CaloHitList &  secondCaloHitList 
) const
privatevirtual

Divide calo hits in a cluster into two lists, each associated with a separate fragment cluster.

Parameters
pClusteraddress of the cluster
firstCaloHitListthe hits in the first fragment
secondCaloHitListthe hits in the second fragment

Implements lar_content::ClusterSplittingAlgorithm.

Referenced by CalculateRms(), and LayerSplittingAlgorithm().

pandora::StatusCode lar_content::LayerSplittingAlgorithm::DivideCaloHits ( const pandora::Cluster *const  pCluster,
const unsigned int &  splitLayer,
pandora::CaloHitList &  firstCaloHitList,
pandora::CaloHitList &  secondCaloHitList 
) const
private

Split the cluster into two fragments at the input layer.

Parameters
pClusterthe input cluster
splitLayerthe split layer
firstCaloHitListthe hits in the first cluster fragment
secondCaloHitListthe hits in the second cluster fragment
StatusCode lar_content::LayerSplittingAlgorithm::FindBestSplitLayer ( const pandora::Cluster *const  pCluster,
unsigned int &  splitLayer 
) const
private

Find the best layer for splitting the cluster.

Parameters
pClusterthe input cluster
splitLayerthe best layer

Definition at line 41 of file LayerSplittingAlgorithm.cc.

References CalculateRms(), f, m_layerWindow, m_maxScatterCosTheta, m_maxScatterRms, m_maxSlidingCosTheta, m_minClusterLayers, and max.

Referenced by LayerSplittingAlgorithm().

42 {
43  const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
44 
45  if (orderedCaloHitList.size() < m_minClusterLayers)
46  return STATUS_CODE_NOT_FOUND;
47 
48  bool foundSplit(false);
49 
50  float bestCosTheta(1.f);
51  CartesianVector bestPosition(0.f,0.f,0.f);
52 
53  for (unsigned int iLayer = pCluster->GetInnerPseudoLayer() + 4; iLayer + 4 <= pCluster->GetOuterPseudoLayer(); ++iLayer)
54  {
55  if (orderedCaloHitList.find(iLayer) == orderedCaloHitList.end())
56  continue;
57 
58  unsigned int innerLayer((pCluster->GetInnerPseudoLayer() + m_layerWindow > iLayer) ? pCluster->GetInnerPseudoLayer() : iLayer - m_layerWindow);
59  unsigned int outerLayer((iLayer + m_layerWindow > pCluster->GetOuterPseudoLayer()) ? pCluster->GetOuterPseudoLayer() : iLayer + m_layerWindow);
60 
61  for ( ; innerLayer >= pCluster->GetInnerPseudoLayer(); --innerLayer)
62  {
63  if (orderedCaloHitList.find(innerLayer) != orderedCaloHitList.end())
64  break;
65  }
66 
67  for ( ; outerLayer <= pCluster->GetOuterPseudoLayer(); ++outerLayer)
68  {
69  if (orderedCaloHitList.find(outerLayer) != orderedCaloHitList.end())
70  break;
71  }
72 
73  const CartesianVector splitPosition(pCluster->GetCentroid(iLayer));
74  const CartesianVector innerPosition(pCluster->GetCentroid(innerLayer));
75  const CartesianVector outerPosition(pCluster->GetCentroid(outerLayer));
76 
77  const CartesianVector r1(innerPosition - splitPosition);
78  const CartesianVector r2(outerPosition - splitPosition);
79  const CartesianVector p1(r1.GetUnitVector());
80  const CartesianVector p2(r2.GetUnitVector());
81 
82  const float cosTheta(-p1.GetDotProduct(p2));
83  const float rms1(this->CalculateRms(pCluster, innerLayer, iLayer));
84  const float rms2(this->CalculateRms(pCluster, outerLayer, iLayer));
85  const float rms(std::max(rms1, rms2));
86 
87  float rmsCut(std::numeric_limits<float>::max());
88 
89  if (cosTheta > 0.f)
90  {
91  rmsCut = m_maxScatterRms;
92 
93  if (cosTheta > m_maxScatterCosTheta)
94  {
95  rmsCut *= ((m_maxSlidingCosTheta > cosTheta) ? (m_maxSlidingCosTheta - cosTheta) /
97  }
98  }
99 
100  if (rms < rmsCut && cosTheta < bestCosTheta)
101  {
102  bestCosTheta = cosTheta;
103  bestPosition = splitPosition;
104 
105  splitLayer = iLayer;
106  foundSplit = true;
107  }
108  }
109 
110  if (!foundSplit)
111  return STATUS_CODE_NOT_FOUND;
112 
113  return STATUS_CODE_SUCCESS;
114 }
TFile f
Definition: plotHisto.C:6
Int_t max
Definition: plot.C:27
float CalculateRms(const pandora::Cluster *const pCluster, const unsigned int &firstLayer, const unsigned int &secondLayer) const
Calculate rms deviation of cluster centroids between two extremal layers.
StatusCode lar_content::LayerSplittingAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::ClusterSplittingAlgorithm.

Definition at line 183 of file LayerSplittingAlgorithm.cc.

References m_layerWindow, m_maxScatterCosTheta, m_maxScatterRms, m_maxSlidingCosTheta, m_minClusterLayers, and lar_content::ClusterSplittingAlgorithm::ReadSettings().

184 {
185  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
186  "MinClusterLayers", m_minClusterLayers));
187 
188  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
189  "LayerWindow", m_layerWindow));
190 
191  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
192  "MaxScatterRms", m_maxScatterRms));
193 
194  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
195  "MaxScatterCosTheta", m_maxScatterCosTheta));
196 
197  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
198  "MaxSlidingCosTheta", m_maxSlidingCosTheta));
199 
200  return ClusterSplittingAlgorithm::ReadSettings(xmlHandle);
201 }
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
StatusCode lar_content::ClusterSplittingAlgorithm::Run ( )
protectedvirtualinherited

Definition at line 20 of file ClusterSplittingAlgorithm.cc.

21 {
22  if (m_inputClusterListNames.empty())
23  return this->RunUsingCurrentList();
24 
25  std::string originalListName;
26  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentListName<Cluster>(*this, originalListName));
27 
28  for (const std::string &clusterListName : m_inputClusterListNames)
29  {
30  const StatusCode listChangeStatusCode(PandoraContentApi::ReplaceCurrentList<Cluster>(*this, clusterListName));
31 
32  if (STATUS_CODE_NOT_FOUND == listChangeStatusCode)
33  {
34  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
35  std::cout << "ClusterSplittingAlgorithm: cluster list not found " << clusterListName << std::endl;
36 
37  continue;
38  }
39 
40  if (STATUS_CODE_SUCCESS != listChangeStatusCode)
41  return listChangeStatusCode;
42 
43  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->RunUsingCurrentList());
44  }
45 
46  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Cluster>(*this, originalListName));
47  return STATUS_CODE_SUCCESS;
48 }
pandora::StatusCode RunUsingCurrentList() const
Run the algorithm using the current cluster list as input.
pandora::StringVector m_inputClusterListNames
The list of input cluster list names - if empty, use the current cluster list.
StatusCode lar_content::ClusterSplittingAlgorithm::RunUsingCurrentList ( ) const
protectedinherited

Run the algorithm using the current cluster list as input.

Definition at line 52 of file ClusterSplittingAlgorithm.cc.

53 {
54  const ClusterList *pClusterList = NULL;
55  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pClusterList));
56 
57  ClusterList internalClusterList(pClusterList->begin(), pClusterList->end());
58  internalClusterList.sort(LArClusterHelper::SortByNHits);
59 
60  for (ClusterList::iterator iter = internalClusterList.begin(); iter != internalClusterList.end(); ++iter)
61  {
62  const Cluster *const pCluster = *iter;
63  ClusterList clusterSplittingList;
64 
65  if (STATUS_CODE_SUCCESS != this->SplitCluster(pCluster, clusterSplittingList))
66  continue;
67 
68  internalClusterList.splice(internalClusterList.end(), clusterSplittingList);
69  *iter = NULL;
70  }
71 
72  return STATUS_CODE_SUCCESS;
73 }
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::iterator iterator
pandora::StatusCode SplitCluster(const pandora::Cluster *const pCluster, pandora::ClusterList &clusterSplittingList) const
Split cluster into two fragments.

Member Data Documentation

unsigned int lar_content::LayerSplittingAlgorithm::m_layerWindow
private

Definition at line 61 of file LayerSplittingAlgorithm.h.

Referenced by FindBestSplitLayer(), and ReadSettings().

float lar_content::LayerSplittingAlgorithm::m_maxScatterCosTheta
private

Definition at line 63 of file LayerSplittingAlgorithm.h.

Referenced by FindBestSplitLayer(), and ReadSettings().

float lar_content::LayerSplittingAlgorithm::m_maxScatterRms
private

Definition at line 62 of file LayerSplittingAlgorithm.h.

Referenced by FindBestSplitLayer(), and ReadSettings().

float lar_content::LayerSplittingAlgorithm::m_maxSlidingCosTheta
private

Definition at line 64 of file LayerSplittingAlgorithm.h.

Referenced by FindBestSplitLayer(), and ReadSettings().

unsigned int lar_content::LayerSplittingAlgorithm::m_minClusterLayers
private

Definition at line 60 of file LayerSplittingAlgorithm.h.

Referenced by FindBestSplitLayer(), and ReadSettings().


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