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

CutClusterCharacterisationAlgorithm class. More...

#include "CutClusterCharacterisationAlgorithm.h"

Inheritance diagram for lar_content::CutClusterCharacterisationAlgorithm:
lar_content::ClusterCharacterisationBaseAlgorithm

Public Member Functions

 CutClusterCharacterisationAlgorithm ()
 Default constructor. More...
 

Static Public Member Functions

static float GetVertexDistance (const pandora::Algorithm *const pAlgorithm, const pandora::Cluster *const pCluster)
 Get the distance between the interaction vertex (if present in the current vertex list) and a provided cluster. More...
 
static float GetShowerFitWidth (const pandora::Algorithm *const pAlgorithm, const pandora::Cluster *const pCluster, const unsigned int showerFitWindow)
 Get a measure of the width of a cluster, using a sliding shower fit result. More...
 

Protected Member Functions

pandora::StatusCode Run ()
 

Protected Attributes

pandora::StringVector m_inputClusterListNames
 The names of the input cluster lists. More...
 
bool m_zeroMode
 Whether to zero all existing cluster particle id, overrides all other parameters. More...
 
bool m_overwriteExistingId
 Whether to consider any clusters that already have an assigned particle id. More...
 
bool m_useUnavailableClusters
 Whether to consider clusters that are already constituents of a pfo. More...
 

Private Member Functions

virtual bool IsClearTrack (const pandora::Cluster *const pCluster) const
 Whether cluster is identified as a clear track. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

unsigned int m_slidingFitWindow
 The layer window for the sliding linear fits. More...
 
unsigned int m_slidingShowerFitWindow
 The layer window for the sliding shower fits. More...
 
unsigned int m_minCaloHitsCut
 The minimum number of calo hits to qualify as a track. More...
 
float m_maxShowerLengthCut
 The maximum cluster length to qualify as a shower. More...
 
float m_pathLengthRatioCut
 The maximum ratio of path length to straight line length to qualify as a track. More...
 
float m_rTWidthRatioCut
 The maximum ratio of transverse fit position width to straight line length to qualify as a track. More...
 
float m_vertexDistanceRatioCut
 The maximum ratio of vertex separation to straight line length to qualify as a track. More...
 
float m_showerWidthRatioCut
 The maximum ratio of shower fit width to straight line length to qualify as a track. More...
 

Detailed Description

Constructor & Destructor Documentation

lar_content::CutClusterCharacterisationAlgorithm::CutClusterCharacterisationAlgorithm ( )

Default constructor.

Definition at line 24 of file CutClusterCharacterisationAlgorithm.cc.

24  :
29  m_pathLengthRatioCut(1.005f),
30  m_rTWidthRatioCut(0.05f),
33 {
34 }
float m_rTWidthRatioCut
The maximum ratio of transverse fit position width to straight line length to qualify as a track...
float m_vertexDistanceRatioCut
The maximum ratio of vertex separation to straight line length to qualify as a track.
TFile f
Definition: plotHisto.C:6
float m_maxShowerLengthCut
The maximum cluster length to qualify as a shower.
unsigned int m_minCaloHitsCut
The minimum number of calo hits to qualify as a track.
unsigned int m_slidingShowerFitWindow
The layer window for the sliding shower fits.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
float m_showerWidthRatioCut
The maximum ratio of shower fit width to straight line length to qualify as a track.
float m_pathLengthRatioCut
The maximum ratio of path length to straight line length to qualify as a track.

Member Function Documentation

float lar_content::CutClusterCharacterisationAlgorithm::GetShowerFitWidth ( const pandora::Algorithm *const  pAlgorithm,
const pandora::Cluster *const  pCluster,
const unsigned int  showerFitWindow 
)
static

Get a measure of the width of a cluster, using a sliding shower fit result.

Parameters
pAlgorithmthe address of the calling algorithm
pClusteraddress of the cluster
showerFitWindowthe layer window used for the sliding shower fit
Returns
the shower fit width

Definition at line 55 of file CutClusterCharacterisationAlgorithm.cc.

References f, lar_content::TwoDSlidingFitResult::GetLayerFitResultMap(), lar_content::TwoDSlidingShowerFitResult::GetNegativeEdgeFitResult(), lar_content::TwoDSlidingShowerFitResult::GetPositiveEdgeFitResult(), lar_content::TwoDSlidingShowerFitResult::GetShowerFitResult(), and lar_content::LArGeometryHelper::GetWireZPitch().

Referenced by lar_content::CutPfoCharacterisationAlgorithm::CutPfoCharacterisationAlgorithm(), IsClearTrack(), and lar_content::TwoDShowerFitFeatureTool::Run().

57 {
58  try
59  {
60  const TwoDSlidingShowerFitResult showerFitResult(pCluster, showerFitWindow, LArGeometryHelper::GetWireZPitch(pAlgorithm->GetPandora()));
61  const LayerFitResultMap &layerFitResultMapS(showerFitResult.GetShowerFitResult().GetLayerFitResultMap());
62  const LayerFitResultMap &layerFitResultMapP(showerFitResult.GetPositiveEdgeFitResult().GetLayerFitResultMap());
63  const LayerFitResultMap &layerFitResultMapN(showerFitResult.GetNegativeEdgeFitResult().GetLayerFitResultMap());
64 
65  if (!layerFitResultMapS.empty())
66  {
67  float showerFitWidth(0.f);
68 
69  for (const auto &mapEntryS : layerFitResultMapS)
70  {
71  LayerFitResultMap::const_iterator iterP = layerFitResultMapP.find(mapEntryS.first);
72  LayerFitResultMap::const_iterator iterN = layerFitResultMapN.find(mapEntryS.first);
73 
74  if ((layerFitResultMapP.end() != iterP) && (layerFitResultMapN.end() != iterN))
75  showerFitWidth += std::fabs(iterP->second.GetFitT() - iterN->second.GetFitT());
76  }
77 
78  return showerFitWidth;
79  }
80  }
81  catch (const StatusCodeException &)
82  {
83  }
84 
85  return -1.f;
86 }
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
TFile f
Definition: plotHisto.C:6
intermediate_table::const_iterator const_iterator
std::map< int, LayerFitResult > LayerFitResultMap
float lar_content::CutClusterCharacterisationAlgorithm::GetVertexDistance ( const pandora::Algorithm *const  pAlgorithm,
const pandora::Cluster *const  pCluster 
)
static

Get the distance between the interaction vertex (if present in the current vertex list) and a provided cluster.

Parameters
pAlgorithmthe address of the calling algorithm
pClusteraddress of the cluster
Returns
the vertex distance

Definition at line 38 of file CutClusterCharacterisationAlgorithm.cc.

References lar_content::LArClusterHelper::GetClosestDistance(), lar_content::LArClusterHelper::GetClusterHitType(), and lar_content::LArGeometryHelper::ProjectPosition().

Referenced by lar_content::CutPfoCharacterisationAlgorithm::CutPfoCharacterisationAlgorithm(), IsClearTrack(), and lar_content::TwoDVertexDistanceFeatureTool::Run().

39 {
40  const VertexList *pVertexList = nullptr;
41  (void) PandoraContentApi::GetCurrentList(*pAlgorithm, pVertexList);
42 
43  if (!pVertexList || (pVertexList->size() != 1) || (VERTEX_3D != pVertexList->front()->GetVertexType()))
44  return -1.f;
45 
46  const Vertex *const pVertex(pVertexList->front());
47  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
48 
49  const CartesianVector vertexPosition2D(LArGeometryHelper::ProjectPosition(pAlgorithm->GetPandora(), pVertex->GetPosition(), hitType));
50  return LArClusterHelper::GetClosestDistance(vertexPosition2D, pCluster);
51 }
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
std::list< Vertex > VertexList
Definition: DCEL.h:178
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
bool lar_content::CutClusterCharacterisationAlgorithm::IsClearTrack ( const pandora::Cluster *const  pCluster) const
privatevirtual

Whether cluster is identified as a clear track.

Parameters
pClusteraddress of the relevant cluster
Returns
boolean

Implements lar_content::ClusterCharacterisationBaseAlgorithm.

Definition at line 90 of file CutClusterCharacterisationAlgorithm.cc.

References f, lar_content::TwoDSlidingFitResult::GetGlobalMaxLayerPosition(), lar_content::TwoDSlidingFitResult::GetGlobalMinLayerPosition(), lar_content::TwoDSlidingFitResult::GetGlobalPosition(), lar_content::TwoDSlidingFitResult::GetLayerFitResultMap(), GetShowerFitWidth(), GetVertexDistance(), lar_content::LArGeometryHelper::GetWireZPitch(), m_maxShowerLengthCut, m_minCaloHitsCut, m_pathLengthRatioCut, m_rTWidthRatioCut, m_showerWidthRatioCut, m_slidingFitWindow, m_slidingShowerFitWindow, m_vertexDistanceRatioCut, max, and min.

91 {
92  if (pCluster->GetNCaloHits() < m_minCaloHitsCut)
93  return false;
94 
95  float straightLineLength(-1.f), integratedPathLength(-1.f);
97 
98  try
99  {
100  const TwoDSlidingFitResult slidingFitResult(pCluster, m_slidingFitWindow, LArGeometryHelper::GetWireZPitch(this->GetPandora()));
101  const CartesianVector globalMinLayerPosition(slidingFitResult.GetGlobalMinLayerPosition());
102  straightLineLength = (slidingFitResult.GetGlobalMaxLayerPosition() - globalMinLayerPosition).GetMagnitude();
103 
104  integratedPathLength = 0.f;
105  CartesianVector previousFitPosition(globalMinLayerPosition);
106 
107  for (const auto &mapEntry : slidingFitResult.GetLayerFitResultMap())
108  {
109  rTMin = std::min(rTMin, static_cast<float>(mapEntry.second.GetFitT()));
110  rTMax = std::max(rTMax, static_cast<float>(mapEntry.second.GetFitT()));
111 
112  CartesianVector thisFitPosition(0.f, 0.f, 0.f);
113  slidingFitResult.GetGlobalPosition(mapEntry.second.GetL(), mapEntry.second.GetFitT(), thisFitPosition);
114  integratedPathLength += (thisFitPosition - previousFitPosition).GetMagnitude();
115  previousFitPosition = thisFitPosition;
116  }
117  }
118  catch (const StatusCodeException &)
119  {
120  }
121 
122  if (straightLineLength < std::numeric_limits<float>::epsilon())
123  return false;
124 
125  if (straightLineLength > m_maxShowerLengthCut)
126  return true;
127 
128  if ((integratedPathLength < std::numeric_limits<float>::epsilon()) || (integratedPathLength / straightLineLength > m_pathLengthRatioCut))
129  return false;
130 
131  if ((rTMax - rTMin) / straightLineLength > m_rTWidthRatioCut)
132  return false;
133 
134  const float vertexDistance(CutClusterCharacterisationAlgorithm::GetVertexDistance(this, pCluster));
135 
136  if ((vertexDistance > std::numeric_limits<float>::epsilon()) && ((vertexDistance / straightLineLength) > m_vertexDistanceRatioCut))
137  return false;
138 
139  const float showerFitWidth(CutClusterCharacterisationAlgorithm::GetShowerFitWidth(this, pCluster, m_slidingShowerFitWindow));
140 
141  if ((showerFitWidth < std::numeric_limits<float>::epsilon()) || ((showerFitWidth / straightLineLength) > m_showerWidthRatioCut))
142  return false;
143 
144  return true;
145 }
static float GetVertexDistance(const pandora::Algorithm *const pAlgorithm, const pandora::Cluster *const pCluster)
Get the distance between the interaction vertex (if present in the current vertex list) and a provide...
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
float m_rTWidthRatioCut
The maximum ratio of transverse fit position width to straight line length to qualify as a track...
float m_vertexDistanceRatioCut
The maximum ratio of vertex separation to straight line length to qualify as a track.
TFile f
Definition: plotHisto.C:6
float m_maxShowerLengthCut
The maximum cluster length to qualify as a shower.
Int_t max
Definition: plot.C:27
unsigned int m_minCaloHitsCut
The minimum number of calo hits to qualify as a track.
unsigned int m_slidingShowerFitWindow
The layer window for the sliding shower fits.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
Int_t min
Definition: plot.C:26
float m_showerWidthRatioCut
The maximum ratio of shower fit width to straight line length to qualify as a track.
static float GetShowerFitWidth(const pandora::Algorithm *const pAlgorithm, const pandora::Cluster *const pCluster, const unsigned int showerFitWindow)
Get a measure of the width of a cluster, using a sliding shower fit result.
float m_pathLengthRatioCut
The maximum ratio of path length to straight line length to qualify as a track.
StatusCode lar_content::CutClusterCharacterisationAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 149 of file CutClusterCharacterisationAlgorithm.cc.

References m_maxShowerLengthCut, m_minCaloHitsCut, m_pathLengthRatioCut, m_rTWidthRatioCut, m_showerWidthRatioCut, m_slidingFitWindow, m_slidingShowerFitWindow, m_vertexDistanceRatioCut, and lar_content::ClusterCharacterisationBaseAlgorithm::ReadSettings().

150 {
151  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
152  "SlidingFitWindow", m_slidingFitWindow));
153 
154  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
155  "SlidingShowerFitWindow", m_slidingShowerFitWindow));
156 
157  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
158  "MinCaloHitsCut", m_minCaloHitsCut));
159 
160  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
161  "MaxShowerLengthCut", m_maxShowerLengthCut));
162 
163  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
164  "PathLengthRatioCut", m_pathLengthRatioCut));
165 
166  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
167  "RTWidthRatioCut", m_rTWidthRatioCut));
168 
169  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
170  "VertexDistanceRatioCut", m_vertexDistanceRatioCut));
171 
172  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
173  "ShowerWidthRatioCut", m_showerWidthRatioCut));
174 
176 }
float m_rTWidthRatioCut
The maximum ratio of transverse fit position width to straight line length to qualify as a track...
float m_vertexDistanceRatioCut
The maximum ratio of vertex separation to straight line length to qualify as a track.
float m_maxShowerLengthCut
The maximum cluster length to qualify as a shower.
unsigned int m_minCaloHitsCut
The minimum number of calo hits to qualify as a track.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
unsigned int m_slidingShowerFitWindow
The layer window for the sliding shower fits.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
float m_showerWidthRatioCut
The maximum ratio of shower fit width to straight line length to qualify as a track.
float m_pathLengthRatioCut
The maximum ratio of path length to straight line length to qualify as a track.
StatusCode lar_content::ClusterCharacterisationBaseAlgorithm::Run ( )
protectedinherited

Definition at line 36 of file ClusterCharacterisationBaseAlgorithm.cc.

References lar_content::ClusterCharacterisationBaseAlgorithm::IsClearTrack(), lar_content::ClusterCharacterisationBaseAlgorithm::m_inputClusterListNames, lar_content::ClusterCharacterisationBaseAlgorithm::m_overwriteExistingId, lar_content::ClusterCharacterisationBaseAlgorithm::m_useUnavailableClusters, and lar_content::ClusterCharacterisationBaseAlgorithm::m_zeroMode.

37 {
38  for (const std::string &clusterListName : m_inputClusterListNames)
39  {
40  const ClusterList *pClusterList = NULL;
41  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, clusterListName, pClusterList));
42 
43  if (!pClusterList || pClusterList->empty())
44  {
45  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
46  std::cout << "ClusterCharacterisationBaseAlgorithm: unable to find cluster list " << clusterListName << std::endl;
47 
48  continue;
49  }
50 
51  if (m_zeroMode)
52  {
53  for (const Cluster *const pCluster : *pClusterList)
54  {
55  PandoraContentApi::Cluster::Metadata metadata;
56  metadata.m_particleId = UNKNOWN_PARTICLE_TYPE;
57  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::AlterMetadata(*this, pCluster, metadata));
58  }
59 
60  return STATUS_CODE_SUCCESS;
61  }
62 
63  for (const Cluster *const pCluster : *pClusterList)
64  {
65  if (!m_overwriteExistingId && (UNKNOWN_PARTICLE_TYPE != pCluster->GetParticleId()))
66  continue;
67 
68  if (!m_useUnavailableClusters && !PandoraContentApi::IsAvailable(*this, pCluster))
69  continue;
70 
71  PandoraContentApi::Cluster::Metadata metadata;
72 
73  if (this->IsClearTrack(pCluster))
74  {
75  metadata.m_particleId = MU_MINUS;
76  }
77  else
78  {
79  metadata.m_particleId = E_MINUS;
80  }
81 
82  if (pCluster->GetParticleId() != metadata.m_particleId.Get())
83  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::AlterMetadata(*this, pCluster, metadata));
84  }
85  }
86 
87  return STATUS_CODE_SUCCESS;
88 }
bool m_overwriteExistingId
Whether to consider any clusters that already have an assigned particle id.
bool m_useUnavailableClusters
Whether to consider clusters that are already constituents of a pfo.
pandora::StringVector m_inputClusterListNames
The names of the input cluster lists.
bool m_zeroMode
Whether to zero all existing cluster particle id, overrides all other parameters. ...
virtual bool IsClearTrack(const pandora::Cluster *const pCluster) const =0
Whether cluster is identified as a clear track.

Member Data Documentation

pandora::StringVector lar_content::ClusterCharacterisationBaseAlgorithm::m_inputClusterListNames
protectedinherited
float lar_content::CutClusterCharacterisationAlgorithm::m_maxShowerLengthCut
private

The maximum cluster length to qualify as a shower.

Definition at line 55 of file CutClusterCharacterisationAlgorithm.h.

Referenced by IsClearTrack(), and ReadSettings().

unsigned int lar_content::CutClusterCharacterisationAlgorithm::m_minCaloHitsCut
private

The minimum number of calo hits to qualify as a track.

Definition at line 54 of file CutClusterCharacterisationAlgorithm.h.

Referenced by IsClearTrack(), and ReadSettings().

bool lar_content::ClusterCharacterisationBaseAlgorithm::m_overwriteExistingId
protectedinherited

Whether to consider any clusters that already have an assigned particle id.

Definition at line 49 of file ClusterCharacterisationBaseAlgorithm.h.

Referenced by lar_content::ClusterCharacterisationBaseAlgorithm::ReadSettings(), and lar_content::ClusterCharacterisationBaseAlgorithm::Run().

float lar_content::CutClusterCharacterisationAlgorithm::m_pathLengthRatioCut
private

The maximum ratio of path length to straight line length to qualify as a track.

Definition at line 56 of file CutClusterCharacterisationAlgorithm.h.

Referenced by IsClearTrack(), and ReadSettings().

float lar_content::CutClusterCharacterisationAlgorithm::m_rTWidthRatioCut
private

The maximum ratio of transverse fit position width to straight line length to qualify as a track.

Definition at line 57 of file CutClusterCharacterisationAlgorithm.h.

Referenced by IsClearTrack(), and ReadSettings().

float lar_content::CutClusterCharacterisationAlgorithm::m_showerWidthRatioCut
private

The maximum ratio of shower fit width to straight line length to qualify as a track.

Definition at line 59 of file CutClusterCharacterisationAlgorithm.h.

Referenced by IsClearTrack(), and ReadSettings().

unsigned int lar_content::CutClusterCharacterisationAlgorithm::m_slidingFitWindow
private

The layer window for the sliding linear fits.

Definition at line 52 of file CutClusterCharacterisationAlgorithm.h.

Referenced by IsClearTrack(), and ReadSettings().

unsigned int lar_content::CutClusterCharacterisationAlgorithm::m_slidingShowerFitWindow
private

The layer window for the sliding shower fits.

Definition at line 53 of file CutClusterCharacterisationAlgorithm.h.

Referenced by IsClearTrack(), and ReadSettings().

bool lar_content::ClusterCharacterisationBaseAlgorithm::m_useUnavailableClusters
protectedinherited

Whether to consider clusters that are already constituents of a pfo.

Definition at line 50 of file ClusterCharacterisationBaseAlgorithm.h.

Referenced by lar_content::ClusterCharacterisationBaseAlgorithm::ReadSettings(), and lar_content::ClusterCharacterisationBaseAlgorithm::Run().

float lar_content::CutClusterCharacterisationAlgorithm::m_vertexDistanceRatioCut
private

The maximum ratio of vertex separation to straight line length to qualify as a track.

Definition at line 58 of file CutClusterCharacterisationAlgorithm.h.

Referenced by IsClearTrack(), and ReadSettings().

bool lar_content::ClusterCharacterisationBaseAlgorithm::m_zeroMode
protectedinherited

Whether to zero all existing cluster particle id, overrides all other parameters.

Definition at line 47 of file ClusterCharacterisationBaseAlgorithm.h.

Referenced by lar_content::ClusterCharacterisationBaseAlgorithm::ReadSettings(), and lar_content::ClusterCharacterisationBaseAlgorithm::Run().


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