LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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
 

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.

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(), lar_content::LArClusterHelper::GetClusterSpanX(), m_pseudoChi2Cut, max, lar_content::LArGeometryHelper::MergeTwoPositions(), and min.

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  LArClusterHelper::GetClusterSpanX(pCluster1, xMin1, xMax1);
78  LArClusterHelper::GetClusterSpanX(pCluster2, xMin2, xMax2);
79  LArClusterHelper::GetClusterSpanX(pCluster3, 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 
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
Int_t max
Definition: plot.C:27
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.
Int_t min
Definition: plot.C:26
static void GetClusterSpanX(const pandora::Cluster *const pCluster, float &xmin, float &xmax)
Get minimum and maximum X positions of the calo hits in a cluster.
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, lar_content::LArClusterHelper::GetClusterSpanX(), m_minXOverlap, m_minXOverlapFraction, max, and min.

45 {
46  float xMin1(0.f), xMax1(0.f), xMin2(0.f), xMax2(0.f);
47  LArClusterHelper::GetClusterSpanX(pCluster1, xMin1, xMax1);
48  LArClusterHelper::GetClusterSpanX(pCluster2, 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
Int_t max
Definition: plot.C:27
Int_t min
Definition: plot.C:26
float m_minXOverlap
requirement on minimum X overlap for associated clusters
static void GetClusterSpanX(const pandora::Cluster *const pCluster, float &xmin, float &xmax)
Get minimum and maximum X positions of the calo hits in a cluster.
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 129 of file CosmicRayShowerMatchingAlgorithm.cc.

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

130 {
131  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
132  "MinCaloHitsPerCluster", m_minCaloHitsPerCluster));
133 
134  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
135  "MinXOverlap", m_minXOverlap));
136 
137  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
138  "MinXOverlapFraction", m_minXOverlapFraction));
139 
140  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
141  "PseudoChi2Cut", m_pseudoChi2Cut));
142 
144 }
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 20 of file CosmicRayBaseMatchingAlgorithm.cc.

21 {
22  // Get the available clusters for each view
23  ClusterVector availableClustersU, availableClustersV, availableClustersW;
24  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->GetAvailableClusters(m_inputClusterListNameU, availableClustersU));
25  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->GetAvailableClusters(m_inputClusterListNameV, availableClustersV));
26  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->GetAvailableClusters(m_inputClusterListNameW, availableClustersW));
27 
28  // Select clean clusters in each view
29  ClusterVector cleanClustersU, cleanClustersV, cleanClustersW;
30  this->SelectCleanClusters(availableClustersU, cleanClustersU);
31  this->SelectCleanClusters(availableClustersV, cleanClustersV);
32  this->SelectCleanClusters(availableClustersW, cleanClustersW);
33 
34  // Build associations between pairs of views
35  ClusterAssociationMap matchedClusterUV, matchedClusterVW, matchedClusterWU;
36  this->MatchClusters(cleanClustersU, cleanClustersV, matchedClusterUV);
37  this->MatchClusters(cleanClustersV, cleanClustersW, matchedClusterVW);
38  this->MatchClusters(cleanClustersW, cleanClustersU, matchedClusterWU);
39 
40  // Build particles from associations
41  ParticleList particleList;
42  this->MatchThreeViews(matchedClusterUV, matchedClusterVW, matchedClusterWU, particleList);
43  this->MatchTwoViews(matchedClusterUV, matchedClusterVW, matchedClusterWU, particleList);
44  this->BuildParticles(particleList);
45 
46  return STATUS_CODE_SUCCESS;
47 }
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.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterAssociationMap
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.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
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.
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) clusterList.push_back(particle.m_pClusterU);
115  if (particle.m_pClusterV) clusterList.push_back(particle.m_pClusterV);
116  if (particle.m_pClusterW) clusterList.push_back(particle.m_pClusterW);
117 
118  // TODO Correct these placeholder parameters
119  pfoParameters.m_particleId = E_MINUS; // SHOWER
120  pfoParameters.m_charge = PdgTable::GetParticleCharge(pfoParameters.m_particleId.Get());
121  pfoParameters.m_mass = PdgTable::GetParticleMass(pfoParameters.m_particleId.Get());
122  pfoParameters.m_energy = 0.f;
123  pfoParameters.m_momentum = CartesianVector(0.f, 0.f, 0.f);
124  pfoParameters.m_clusterList = clusterList;
125 }
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 37 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 38 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 39 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 40 of file CosmicRayShowerMatchingAlgorithm.h.

Referenced by CheckMatchedClusters3D(), and ReadSettings().


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