LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::KinkSplittingAlgorithm Class Reference

KinkSplittingAlgorithm class. More...

#include "KinkSplittingAlgorithm.h"

Inheritance diagram for lar_content::KinkSplittingAlgorithm:
lar_content::TwoDSlidingFitSplittingAlgorithm lar_content::ClusterSplittingAlgorithm

Public Member Functions

 KinkSplittingAlgorithm ()
 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...
 

Protected Attributes

unsigned int m_slidingFitHalfWindow
 
float m_minClusterLength
 

Private Member Functions

pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
pandora::StatusCode FindBestSplitPosition (const TwoDSlidingFitResult &slidingFitResult, pandora::CartesianVector &splitPosition) const
 Use sliding linear fit to identify the best split position. More...
 

Private Attributes

float m_maxScatterRms
 
float m_maxScatterCosTheta
 
float m_maxSlidingCosTheta
 

Detailed Description

KinkSplittingAlgorithm class.

Definition at line 19 of file KinkSplittingAlgorithm.h.

Constructor & Destructor Documentation

lar_content::KinkSplittingAlgorithm::KinkSplittingAlgorithm ( )

Default constructor.

Definition at line 18 of file KinkSplittingAlgorithm.cc.

Member Function Documentation

StatusCode lar_content::KinkSplittingAlgorithm::FindBestSplitPosition ( const TwoDSlidingFitResult slidingFitResult,
pandora::CartesianVector &  splitPosition 
) const
privatevirtual

Use sliding linear fit to identify the best split position.

Parameters
slidingFitResultthe input sliding fit result
splitPositionthe best split position
Returns
pandora::StatusCode

Implements lar_content::TwoDSlidingFitSplittingAlgorithm.

Definition at line 27 of file KinkSplittingAlgorithm.cc.

References f, lar_content::TwoDSlidingFitResult::GetFitRms(), lar_content::TwoDSlidingFitResult::GetGlobalFitDirection(), lar_content::TwoDSlidingFitResult::GetGlobalFitPosition(), lar_content::TwoDSlidingFitResult::GetL(), lar_content::TwoDSlidingFitResult::GetLayerFitHalfWindow(), lar_content::TwoDSlidingFitResult::GetLayerFitResultMap(), m_maxScatterCosTheta, m_maxScatterRms, and m_maxSlidingCosTheta.

28 {
29  // Search for scatters by scanning over the layers in the sliding fit result
30  const LayerFitResultMap &layerFitResultMap(slidingFitResult.GetLayerFitResultMap());
31  const int minLayer(layerFitResultMap.begin()->first), maxLayer(layerFitResultMap.rbegin()->first);
32 
33  const int nLayersHalfWindow(slidingFitResult.GetLayerFitHalfWindow());
34  const int nLayersSpanned(1 + maxLayer - minLayer);
35 
36  if (nLayersSpanned <= 2 * nLayersHalfWindow)
37  return STATUS_CODE_NOT_FOUND;
38 
39  bool foundSplit(false);
40 
41  float bestCosTheta(1.f);
42 
43  for (LayerFitResultMap::const_iterator iter = layerFitResultMap.begin(), iterEnd = layerFitResultMap.end(); iter != iterEnd; ++iter)
44  {
45  const int iLayer(iter->first);
46 
47  const float rL(slidingFitResult.GetL(iLayer));
48  const float rL1(slidingFitResult.GetL(iLayer - nLayersHalfWindow));
49  const float rL2(slidingFitResult.GetL(iLayer + nLayersHalfWindow));
50 
51  CartesianVector centralPosition(0.f, 0.f, 0.f), firstDirection(0.f, 0.f, 0.f), secondDirection(0.f, 0.f, 0.f);
52 
53  if ((STATUS_CODE_SUCCESS != slidingFitResult.GetGlobalFitPosition(rL, centralPosition)) ||
54  (STATUS_CODE_SUCCESS != slidingFitResult.GetGlobalFitDirection(rL1, firstDirection)) ||
55  (STATUS_CODE_SUCCESS != slidingFitResult.GetGlobalFitDirection(rL2, secondDirection)))
56  {
57  continue;
58  }
59 
60  const float cosTheta(firstDirection.GetDotProduct(secondDirection));
61  const float rms1(slidingFitResult.GetFitRms(rL1));
62  const float rms2(slidingFitResult.GetFitRms(rL2));
63  const float rms(std::max(rms1, rms2));
64 
65  float rmsCut(m_maxScatterRms);
66 
67  if (cosTheta > m_maxScatterCosTheta)
68  {
69  rmsCut *= ((m_maxSlidingCosTheta > cosTheta) ? (m_maxSlidingCosTheta - cosTheta) / (m_maxSlidingCosTheta - m_maxScatterCosTheta) : 0.f);
70  }
71 
72  if (rms < rmsCut && cosTheta < bestCosTheta)
73  {
74  bestCosTheta = cosTheta;
75  splitPosition = centralPosition;
76  foundSplit = true;
77  }
78  }
79 
80  if (!foundSplit)
81  return STATUS_CODE_NOT_FOUND;
82 
83  return STATUS_CODE_SUCCESS;
84 }
intermediate_table::const_iterator const_iterator
TFile f
Definition: plotHisto.C:6
std::map< int, LayerFitResult > LayerFitResultMap
StatusCode lar_content::KinkSplittingAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::TwoDSlidingFitSplittingAlgorithm.

Definition at line 88 of file KinkSplittingAlgorithm.cc.

References m_maxScatterCosTheta, m_maxScatterRms, m_maxSlidingCosTheta, and lar_content::TwoDSlidingFitSplittingAlgorithm::ReadSettings().

89 {
90  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxScatterRms", m_maxScatterRms));
91 
92  PANDORA_RETURN_RESULT_IF_AND_IF(
93  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxScatterCosTheta", m_maxScatterCosTheta));
94 
95  PANDORA_RETURN_RESULT_IF_AND_IF(
96  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxSlidingCosTeta", m_maxSlidingCosTheta));
97 
99 }
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 }
intermediate_table::iterator iterator
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.
pandora::StatusCode SplitCluster(const pandora::Cluster *const pCluster, pandora::ClusterList &clusterSplittingList) const
Split cluster into two fragments.

Member Data Documentation

float lar_content::KinkSplittingAlgorithm::m_maxScatterCosTheta
private

Definition at line 41 of file KinkSplittingAlgorithm.h.

Referenced by FindBestSplitPosition(), and ReadSettings().

float lar_content::KinkSplittingAlgorithm::m_maxScatterRms
private

Definition at line 40 of file KinkSplittingAlgorithm.h.

Referenced by FindBestSplitPosition(), and ReadSettings().

float lar_content::KinkSplittingAlgorithm::m_maxSlidingCosTheta
private

Definition at line 42 of file KinkSplittingAlgorithm.h.

Referenced by FindBestSplitPosition(), and ReadSettings().

unsigned int lar_content::TwoDSlidingFitSplittingAlgorithm::m_slidingFitHalfWindow
protectedinherited

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