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

CosmicRayShowerMatchingAlgorithm class. More...

#include "CosmicRayShowerMatchingAlgorithm.h"

Inheritance diagram for lar_content::CosmicRayShowerMatchingAlgorithm:
lar_content::CosmicRayBaseMatchingAlgorithm

Public Member Functions

 CosmicRayShowerMatchingAlgorithm ()
 Default constructor. More...
 

Protected Types

typedef std::vector< ParticleParticleList
 
typedef std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterAssociationMap
 
typedef std::set< unsigned int > UIntSet
 

Protected Member Functions

pandora::StatusCode Run ()
 

Private Member Functions

void SelectCleanClusters (const pandora::ClusterVector &inputVector, pandora::ClusterVector &outputVector) const
 Select a set of clusters judged to be clean. More...
 
bool MatchClusters (const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2) const
 Match a pair of clusters from two views. More...
 
bool CheckMatchedClusters3D (const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3) const
 Check that three clusters have a consistent 3D position. More...
 
void SetPfoParameters (const Particle &particle, PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
 Calculate Pfo properties from proto particle. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

float m_minCaloHitsPerCluster
 minimum size of clusters for this algorithm More...
 
float m_minXOverlap
 requirement on minimum X overlap for associated clusters More...
 
float m_minXOverlapFraction
 requirement on minimum X overlap fraction for associated clusters More...
 
float m_pseudoChi2Cut
 The selection cut on the matched chi2. More...
 

Detailed Description

Member Typedef Documentation

typedef std::unordered_map<const pandora::Cluster *, pandora::ClusterList> lar_content::CosmicRayBaseMatchingAlgorithm::ClusterAssociationMap
protectedinherited

Definition at line 49 of file CosmicRayBaseMatchingAlgorithm.h.

Definition at line 48 of file CosmicRayBaseMatchingAlgorithm.h.

typedef std::set<unsigned int> lar_content::CosmicRayBaseMatchingAlgorithm::UIntSet
protectedinherited

Definition at line 50 of file CosmicRayBaseMatchingAlgorithm.h.

Constructor & Destructor Documentation

lar_content::CosmicRayShowerMatchingAlgorithm::CosmicRayShowerMatchingAlgorithm ( )

Default constructor.

Definition at line 21 of file CosmicRayShowerMatchingAlgorithm.cc.

21  :
23  m_minXOverlap(1.f),
26 {
27 }
TFile f
Definition: plotHisto.C:6
float m_pseudoChi2Cut
The selection cut on the matched chi2.
float m_minXOverlap
requirement on minimum X overlap for associated clusters
float m_minCaloHitsPerCluster
minimum size of clusters for this algorithm
float m_minXOverlapFraction
requirement on minimum X overlap fraction for associated clusters

Member Function Documentation

bool lar_content::CosmicRayShowerMatchingAlgorithm::CheckMatchedClusters3D ( const pandora::Cluster *const  pCluster1,
const pandora::Cluster *const  pCluster2,
const pandora::Cluster *const  pCluster3 
) const
privatevirtual

Check that three clusters have a consistent 3D position.

Parameters
pCluster1the cluster from the first view
pCluster2the cluster from the second view
pCluster3the cluster from the third view
Returns
boolean

Implements lar_content::CosmicRayBaseMatchingAlgorithm.

Definition at line 64 of file CosmicRayShowerMatchingAlgorithm.cc.

References f, lar_content::LArClusterHelper::GetAverageZ(), lar_content::LArClusterHelper::GetClusterHitType(), m_pseudoChi2Cut, and lar_content::LArGeometryHelper::MergeTwoPositions().

66 {
67  // Check that three clusters have a consistent 3D position
68  const HitType hitType1(LArClusterHelper::GetClusterHitType(pCluster1));
69  const HitType hitType2(LArClusterHelper::GetClusterHitType(pCluster2));
70  const HitType hitType3(LArClusterHelper::GetClusterHitType(pCluster3));
71 
72  if (hitType1 == hitType2 || hitType2 == hitType3 || hitType3 == hitType1)
73  throw StatusCodeException(STATUS_CODE_FAILURE);
74 
75  // Requirements on X matching
76  float xMin1(0.f), xMin2(0.f), xMin3(0.f), xMax1(0.f), xMax2(0.f), xMax3(0.f);
77  pCluster1->GetClusterSpanX(xMin1, xMax1);
78  pCluster2->GetClusterSpanX(xMin2, xMax2);
79  pCluster3->GetClusterSpanX(xMin3, xMax3);
80 
81  const float xMin(std::max(xMin1, std::max(xMin2, xMin3)));
82  const float xMax(std::min(xMax1, std::min(xMax2, xMax3)));
83  const float xOverlap(xMax - xMin);
84 
85  if (xOverlap < std::numeric_limits<float>::epsilon())
86  return false;
87 
88  float p1(std::numeric_limits<float>::max()), p2(std::numeric_limits<float>::max()), p3(std::numeric_limits<float>::max());
89 
90  if ((STATUS_CODE_SUCCESS != LArClusterHelper::GetAverageZ(pCluster1, xMin, xMax, p1)) ||
91  (STATUS_CODE_SUCCESS != LArClusterHelper::GetAverageZ(pCluster2, xMin, xMax, p2)) ||
92  (STATUS_CODE_SUCCESS != LArClusterHelper::GetAverageZ(pCluster3, xMin, xMax, p3)))
93  {
94  return false;
95  }
96 
97  const float q3(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), hitType1, hitType2, p1, p2));
98  const float q1(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), hitType2, hitType3, p2, p3));
99  const float q2(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), hitType3, hitType1, p3, p1));
100 
101  const float pseudoChi2(((q1 - p1) * (q1 - p1) + (q2 - p2) * (q2 - p2) + (q3 - p3) * (q3 - p3)) / 3.f);
102 
103  if (pseudoChi2 > m_pseudoChi2Cut)
104  return false;
105 
106  return true;
107 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static pandora::StatusCode GetAverageZ(const pandora::Cluster *const pCluster, const float xmin, const float xmax, float &averageZ)
Get average Z positions of the calo hits in a cluster in range xmin to xmax.
TFile f
Definition: plotHisto.C:6
static float MergeTwoPositions(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const float position1, const float position2)
Merge two views (U,V) to give a third view (Z).
float m_pseudoChi2Cut
The selection cut on the matched chi2.
HitType
Definition: HitType.h:12
bool lar_content::CosmicRayShowerMatchingAlgorithm::MatchClusters ( const pandora::Cluster *const  pCluster1,
const pandora::Cluster *const  pCluster2 
) const
privatevirtual

Match a pair of clusters from two views.

Parameters
pCluster1the first cluster
pCluster2the second cluster
Returns
boolean

Implements lar_content::CosmicRayBaseMatchingAlgorithm.

Definition at line 44 of file CosmicRayShowerMatchingAlgorithm.cc.

References f, m_minXOverlap, and m_minXOverlapFraction.

45 {
46  float xMin1(0.f), xMax1(0.f), xMin2(0.f), xMax2(0.f);
47  pCluster1->GetClusterSpanX(xMin1, xMax1);
48  pCluster2->GetClusterSpanX(xMin2, xMax2);
49 
50  const float xOverlap(std::min(xMax1, xMax2) - std::max(xMin1, xMin2));
51  const float xSpan(std::max(xMax1, xMax2) - std::min(xMin1, xMin2));
52 
53  if (xSpan < std::numeric_limits<float>::epsilon())
54  return false;
55 
56  if (xOverlap > m_minXOverlap && xOverlap / xSpan > m_minXOverlapFraction)
57  return true;
58 
59  return false;
60 }
TFile f
Definition: plotHisto.C:6
float m_minXOverlap
requirement on minimum X overlap for associated clusters
float m_minXOverlapFraction
requirement on minimum X overlap fraction for associated clusters
StatusCode lar_content::CosmicRayShowerMatchingAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 132 of file CosmicRayShowerMatchingAlgorithm.cc.

References m_minCaloHitsPerCluster, m_minXOverlap, m_minXOverlapFraction, m_pseudoChi2Cut, and lar_content::CosmicRayBaseMatchingAlgorithm::ReadSettings().

133 {
134  PANDORA_RETURN_RESULT_IF_AND_IF(
135  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinCaloHitsPerCluster", m_minCaloHitsPerCluster));
136 
137  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinXOverlap", m_minXOverlap));
138 
139  PANDORA_RETURN_RESULT_IF_AND_IF(
140  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinXOverlapFraction", m_minXOverlapFraction));
141 
142  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "PseudoChi2Cut", m_pseudoChi2Cut));
143 
145 }
float m_pseudoChi2Cut
The selection cut on the matched chi2.
float m_minXOverlap
requirement on minimum X overlap for associated clusters
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
float m_minCaloHitsPerCluster
minimum size of clusters for this algorithm
float m_minXOverlapFraction
requirement on minimum X overlap fraction for associated clusters
StatusCode lar_content::CosmicRayBaseMatchingAlgorithm::Run ( )
protectedinherited

Definition at line 21 of file CosmicRayBaseMatchingAlgorithm.cc.

22 {
23  // Get the available clusters for each view
24  ClusterVector availableClustersU, availableClustersV, availableClustersW;
25  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->GetAvailableClusters(m_inputClusterListNameU, availableClustersU));
26  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->GetAvailableClusters(m_inputClusterListNameV, availableClustersV));
27  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->GetAvailableClusters(m_inputClusterListNameW, availableClustersW));
28 
29  // Select clean clusters in each view
30  ClusterVector cleanClustersU, cleanClustersV, cleanClustersW;
31  this->SelectCleanClusters(availableClustersU, cleanClustersU);
32  this->SelectCleanClusters(availableClustersV, cleanClustersV);
33  this->SelectCleanClusters(availableClustersW, cleanClustersW);
34 
35  // Build associations between pairs of views
36  ClusterAssociationMap matchedClusterUV, matchedClusterVW, matchedClusterWU;
37  this->MatchClusters(cleanClustersU, cleanClustersV, matchedClusterUV);
38  this->MatchClusters(cleanClustersV, cleanClustersW, matchedClusterVW);
39  this->MatchClusters(cleanClustersW, cleanClustersU, matchedClusterWU);
40 
41  // Build particles from associations
42  ParticleList particleList;
43  this->MatchThreeViews(matchedClusterUV, matchedClusterVW, matchedClusterWU, particleList);
44  this->MatchTwoViews(matchedClusterUV, matchedClusterVW, matchedClusterWU, particleList);
45  this->BuildParticles(particleList);
46 
47  return STATUS_CODE_SUCCESS;
48 }
std::string m_inputClusterListNameV
The name of the view V cluster list.
void BuildParticles(const ParticleList &particleList)
Build PFO objects from candidate particles.
void MatchThreeViews(const CosmicRayBaseMatchingAlgorithm::ClusterAssociationMap &matchedClusters12, const CosmicRayBaseMatchingAlgorithm::ClusterAssociationMap &matchedClusters23, const CosmicRayBaseMatchingAlgorithm::ClusterAssociationMap &matchedClusters31, ParticleList &particleList) const
Match clusters from three views and form into particles.
virtual bool MatchClusters(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2) const =0
Match a pair of clusters from two views.
void MatchTwoViews(const CosmicRayBaseMatchingAlgorithm::ClusterAssociationMap &matchedClusters12, const CosmicRayBaseMatchingAlgorithm::ClusterAssociationMap &matchedClusters23, const CosmicRayBaseMatchingAlgorithm::ClusterAssociationMap &matchedClusters31, ParticleList &particleList) const
Match clusters from two views and form into particles.
pandora::StatusCode GetAvailableClusters(const std::string inputClusterListName, pandora::ClusterVector &clusterVector) const
Get a vector of available clusters.
std::string m_inputClusterListNameU
The name of the view U cluster list.
std::string m_inputClusterListNameW
The name of the view W cluster list.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterAssociationMap
virtual void SelectCleanClusters(const pandora::ClusterVector &inputVector, pandora::ClusterVector &outputVector) const =0
Select a set of clusters judged to be clean.
void lar_content::CosmicRayShowerMatchingAlgorithm::SelectCleanClusters ( const pandora::ClusterVector &  inputVector,
pandora::ClusterVector &  outputVector 
) const
privatevirtual

Select a set of clusters judged to be clean.

Parameters
inputVectorthe input vector of all available clusters
outputVectorthe output vector of clean clusters

Implements lar_content::CosmicRayBaseMatchingAlgorithm.

Definition at line 31 of file CosmicRayShowerMatchingAlgorithm.cc.

References m_minCaloHitsPerCluster.

32 {
33  for (const Cluster *const pCluster : inputVector)
34  {
35  if (pCluster->GetNCaloHits() < m_minCaloHitsPerCluster)
36  continue;
37 
38  outputVector.push_back(pCluster);
39  }
40 }
float m_minCaloHitsPerCluster
minimum size of clusters for this algorithm
void lar_content::CosmicRayShowerMatchingAlgorithm::SetPfoParameters ( const Particle protoParticle,
PandoraContentApi::ParticleFlowObject::Parameters &  pfoParameters 
) const
privatevirtual

Calculate Pfo properties from proto particle.

Parameters
protoParticlethe input proto particle
pfoParametersthe output pfo parameters

Implements lar_content::CosmicRayBaseMatchingAlgorithm.

Definition at line 111 of file CosmicRayShowerMatchingAlgorithm.cc.

References f, lar_content::CosmicRayBaseMatchingAlgorithm::Particle::m_pClusterU, lar_content::CosmicRayBaseMatchingAlgorithm::Particle::m_pClusterV, and lar_content::CosmicRayBaseMatchingAlgorithm::Particle::m_pClusterW.

112 {
113  ClusterList clusterList;
114  if (particle.m_pClusterU)
115  clusterList.push_back(particle.m_pClusterU);
116  if (particle.m_pClusterV)
117  clusterList.push_back(particle.m_pClusterV);
118  if (particle.m_pClusterW)
119  clusterList.push_back(particle.m_pClusterW);
120 
121  // TODO Correct these placeholder parameters
122  pfoParameters.m_particleId = E_MINUS; // SHOWER
123  pfoParameters.m_charge = PdgTable::GetParticleCharge(pfoParameters.m_particleId.Get());
124  pfoParameters.m_mass = PdgTable::GetParticleMass(pfoParameters.m_particleId.Get());
125  pfoParameters.m_energy = 0.f;
126  pfoParameters.m_momentum = CartesianVector(0.f, 0.f, 0.f);
127  pfoParameters.m_clusterList = clusterList;
128 }
TFile f
Definition: plotHisto.C:6

Member Data Documentation

float lar_content::CosmicRayShowerMatchingAlgorithm::m_minCaloHitsPerCluster
private

minimum size of clusters for this algorithm

Definition at line 36 of file CosmicRayShowerMatchingAlgorithm.h.

Referenced by ReadSettings(), and SelectCleanClusters().

float lar_content::CosmicRayShowerMatchingAlgorithm::m_minXOverlap
private

requirement on minimum X overlap for associated clusters

Definition at line 37 of file CosmicRayShowerMatchingAlgorithm.h.

Referenced by MatchClusters(), and ReadSettings().

float lar_content::CosmicRayShowerMatchingAlgorithm::m_minXOverlapFraction
private

requirement on minimum X overlap fraction for associated clusters

Definition at line 38 of file CosmicRayShowerMatchingAlgorithm.h.

Referenced by MatchClusters(), and ReadSettings().

float lar_content::CosmicRayShowerMatchingAlgorithm::m_pseudoChi2Cut
private

The selection cut on the matched chi2.

Definition at line 39 of file CosmicRayShowerMatchingAlgorithm.h.

Referenced by CheckMatchedClusters3D(), and ReadSettings().


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