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

SimpleClusterCreationAlgorithm class. More...

#include "SimpleClusterCreationAlgorithm.h"

Inheritance diagram for lar_content::SimpleClusterCreationAlgorithm:

Public Member Functions

 SimpleClusterCreationAlgorithm ()
 Default constructor. More...
 

Private Types

typedef std::unordered_map< const pandora::CaloHit *, pandora::CaloHitList > HitAssociationMap
 

Private Member Functions

pandora::StatusCode Run ()
 
void SelectCaloHits (const pandora::CaloHitList *const pInputList, pandora::CaloHitList &outputList) const
 Select calo hits for clustering. More...
 
void BuildAssociationMap (const pandora::CaloHitList &caloHitList, HitAssociationMap &hitAssociationMap) const
 Create map of associations between calo hits. More...
 
void CreateClusters (const pandora::CaloHitList &caloHitList, const HitAssociationMap &hitAssociationMap) const
 Create clusters from selected calo hits and their associations. More...
 
void CollectAssociatedHits (const pandora::CaloHit *const pSeedCaloHit, const pandora::CaloHit *const pCurrentCaloHit, const HitAssociationMap &hitAssociationMap, const pandora::CaloHitSet &vetoList, pandora::CaloHitList &mergeList) const
 For a given seed calo hits, collect up all the associated calo hits. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

float m_clusteringWindowSquared
 Maximum distance (squared) for two hits to be joined. More...
 

Detailed Description

Member Typedef Documentation

typedef std::unordered_map<const pandora::CaloHit*, pandora::CaloHitList> lar_content::SimpleClusterCreationAlgorithm::HitAssociationMap
private

Definition at line 32 of file SimpleClusterCreationAlgorithm.h.

Constructor & Destructor Documentation

lar_content::SimpleClusterCreationAlgorithm::SimpleClusterCreationAlgorithm ( )

Default constructor.

Definition at line 20 of file SimpleClusterCreationAlgorithm.cc.

20  :
22 {
23 }
TFile f
Definition: plotHisto.C:6
float m_clusteringWindowSquared
Maximum distance (squared) for two hits to be joined.

Member Function Documentation

void lar_content::SimpleClusterCreationAlgorithm::BuildAssociationMap ( const pandora::CaloHitList &  caloHitList,
HitAssociationMap hitAssociationMap 
) const
private

Create map of associations between calo hits.

Parameters
caloHitListThe input list of calo hits
hitAssociationMapThe map of associations between calo hits

Definition at line 62 of file SimpleClusterCreationAlgorithm.cc.

References m_clusteringWindowSquared.

Referenced by Run().

63 {
64  for (const CaloHit *const pCaloHitI : caloHitList)
65  {
66  for (const CaloHit *const pCaloHitJ : caloHitList)
67  {
68  if (pCaloHitI == pCaloHitJ)
69  continue;
70 
71  if ((pCaloHitI->GetPositionVector() - pCaloHitJ->GetPositionVector()).GetMagnitudeSquared() < m_clusteringWindowSquared)
72  {
73  CaloHitList &caloHitListI(hitAssociationMap[pCaloHitI]);
74 
75  if (caloHitListI.end() == std::find(caloHitListI.begin(), caloHitListI.end(), pCaloHitJ))
76  caloHitListI.push_back(pCaloHitJ);
77 
78  CaloHitList &caloHitListJ(hitAssociationMap[pCaloHitI]);
79 
80  if (caloHitListJ.end() == std::find(caloHitListJ.begin(), caloHitListJ.end(), pCaloHitI))
81  caloHitListJ.push_back(pCaloHitI);
82  }
83  }
84  }
85 }
float m_clusteringWindowSquared
Maximum distance (squared) for two hits to be joined.
void lar_content::SimpleClusterCreationAlgorithm::CollectAssociatedHits ( const pandora::CaloHit *const  pSeedCaloHit,
const pandora::CaloHit *const  pCurrentCaloHit,
const HitAssociationMap hitAssociationMap,
const pandora::CaloHitSet &  vetoList,
pandora::CaloHitList &  mergeList 
) const
private

For a given seed calo hits, collect up all the associated calo hits.

Parameters
pSeedCaloHitthe seed calo hits
pCurrentCaloHita possible associated calo hit
hitAssociationMapthe map of associations between hits
vetoListthe list of used calo hits
mergeListthe list of hits associated with the seed hit

Definition at line 119 of file SimpleClusterCreationAlgorithm.cc.

References lar_content::LArClusterHelper::SortHitsByPosition().

Referenced by CreateClusters().

121 {
122  if (vetoList.count(pCurrentCaloHit))
123  return;
124 
125  HitAssociationMap::const_iterator iter1 = hitAssociationMap.find(pCurrentCaloHit);
126  if (iter1 == hitAssociationMap.end())
127  return;
128 
129  CaloHitVector caloHitVector(iter1->second.begin(), iter1->second.end());
130  std::sort(caloHitVector.begin(), caloHitVector.end(), LArClusterHelper::SortHitsByPosition);
131 
132  for (const CaloHit *const pAssociatedCaloHit : caloHitVector)
133  {
134  if (pAssociatedCaloHit == pSeedCaloHit)
135  continue;
136 
137  if (mergeList.end() != std::find(mergeList.begin(), mergeList.end(), pAssociatedCaloHit))
138  continue;
139 
140  mergeList.push_back(pAssociatedCaloHit);
141 
142  this->CollectAssociatedHits(pSeedCaloHit, pAssociatedCaloHit, hitAssociationMap, vetoList, mergeList);
143  }
144 }
intermediate_table::const_iterator const_iterator
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
void CollectAssociatedHits(const pandora::CaloHit *const pSeedCaloHit, const pandora::CaloHit *const pCurrentCaloHit, const HitAssociationMap &hitAssociationMap, const pandora::CaloHitSet &vetoList, pandora::CaloHitList &mergeList) const
For a given seed calo hits, collect up all the associated calo hits.
void lar_content::SimpleClusterCreationAlgorithm::CreateClusters ( const pandora::CaloHitList &  caloHitList,
const HitAssociationMap hitAssociationMap 
) const
private

Create clusters from selected calo hits and their associations.

Parameters
caloHitListThe input list of calo hits
hitAssociationMapThe map of associations between calo hits

Definition at line 89 of file SimpleClusterCreationAlgorithm.cc.

References CollectAssociatedHits(), and lar_content::LArClusterHelper::SortHitsByPosition().

Referenced by Run().

90 {
91  CaloHitSet vetoList;
92  CaloHitVector caloHitVector(caloHitList.begin(), caloHitList.end());
93  std::sort(caloHitVector.begin(), caloHitVector.end(), LArClusterHelper::SortHitsByPosition);
94 
95  for (const CaloHit *const pSeedCaloHit : caloHitVector)
96  {
97  if (vetoList.count(pSeedCaloHit))
98  continue;
99 
100  CaloHitList mergeList;
101  this->CollectAssociatedHits(pSeedCaloHit, pSeedCaloHit, hitAssociationMap, vetoList, mergeList);
102 
103  const Cluster *pCluster = NULL;
104  PandoraContentApi::Cluster::Parameters parameters;
105  parameters.m_caloHitList.push_back(pSeedCaloHit);
106  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*this, parameters, pCluster));
107  vetoList.insert(pSeedCaloHit);
108 
109  for (const CaloHit *const pAssociatedCaloHit : mergeList)
110  {
111  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToCluster(*this, pCluster, pAssociatedCaloHit));
112  vetoList.insert(pAssociatedCaloHit);
113  }
114  }
115 }
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
void CollectAssociatedHits(const pandora::CaloHit *const pSeedCaloHit, const pandora::CaloHit *const pCurrentCaloHit, const HitAssociationMap &hitAssociationMap, const pandora::CaloHitSet &vetoList, pandora::CaloHitList &mergeList) const
For a given seed calo hits, collect up all the associated calo hits.
StatusCode lar_content::SimpleClusterCreationAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 147 of file SimpleClusterCreationAlgorithm.cc.

References m_clusteringWindowSquared.

148 {
149  float clusteringWindow = std::sqrt(m_clusteringWindowSquared);
150  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
151  "ClusteringWindow", clusteringWindow));
152  m_clusteringWindowSquared = clusteringWindow * clusteringWindow;
153 
154  return STATUS_CODE_SUCCESS;
155 }
float m_clusteringWindowSquared
Maximum distance (squared) for two hits to be joined.
StatusCode lar_content::SimpleClusterCreationAlgorithm::Run ( )
private

Definition at line 27 of file SimpleClusterCreationAlgorithm.cc.

References BuildAssociationMap(), CreateClusters(), and SelectCaloHits().

28 {
29  const CaloHitList *pCaloHitList = NULL;
30  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pCaloHitList));
31 
32  // Select available calo hits for clustering
33  CaloHitList caloHitList;
34  this->SelectCaloHits(pCaloHitList, caloHitList);
35 
36  if (caloHitList.empty())
37  return STATUS_CODE_SUCCESS;
38 
39  // Build map of associations between selected calo hits
40  HitAssociationMap hitAssociationMap;
41  this->BuildAssociationMap(caloHitList, hitAssociationMap);
42 
43  // Create new clusters
44  this->CreateClusters(caloHitList, hitAssociationMap);
45 
46  return STATUS_CODE_SUCCESS;
47 }
void BuildAssociationMap(const pandora::CaloHitList &caloHitList, HitAssociationMap &hitAssociationMap) const
Create map of associations between calo hits.
void SelectCaloHits(const pandora::CaloHitList *const pInputList, pandora::CaloHitList &outputList) const
Select calo hits for clustering.
void CreateClusters(const pandora::CaloHitList &caloHitList, const HitAssociationMap &hitAssociationMap) const
Create clusters from selected calo hits and their associations.
std::unordered_map< const pandora::CaloHit *, pandora::CaloHitList > HitAssociationMap
void lar_content::SimpleClusterCreationAlgorithm::SelectCaloHits ( const pandora::CaloHitList *const  pInputList,
pandora::CaloHitList &  outputList 
) const
private

Select calo hits for clustering.

Parameters
pInputListThe input list of calo hits
outputListThe output list of selected calo hits

Definition at line 51 of file SimpleClusterCreationAlgorithm.cc.

Referenced by Run().

52 {
53  for (const CaloHit *const pCaloHit : *pInputList)
54  {
55  if (PandoraContentApi::IsAvailable(*this, pCaloHit))
56  outputList.push_back(pCaloHit);
57  }
58 }

Member Data Documentation

float lar_content::SimpleClusterCreationAlgorithm::m_clusteringWindowSquared
private

Maximum distance (squared) for two hits to be joined.

Definition at line 72 of file SimpleClusterCreationAlgorithm.h.

Referenced by BuildAssociationMap(), and ReadSettings().


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