LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
lar_content::TrackClusterCreationAlgorithm Class Reference

TrackClusterCreationAlgorithm class. More...

#include "TrackClusterCreationAlgorithm.h"

Inheritance diagram for lar_content::TrackClusterCreationAlgorithm:

Classes

class  HitAssociation
 HitAssociation class. More...
 

Public Member Functions

 TrackClusterCreationAlgorithm ()
 Default constructor. More...
 

Private Types

typedef std::unordered_map< const pandora::CaloHit *, HitAssociationHitAssociationMap
 
typedef std::unordered_map< const pandora::CaloHit *, const pandora::CaloHit * > HitJoinMap
 
typedef std::unordered_map< const pandora::CaloHit *, const pandora::Cluster * > HitToClusterMap
 

Private Member Functions

pandora::StatusCode Run ()
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
pandora::StatusCode FilterCaloHits (const pandora::CaloHitList *const pCaloHitList, pandora::OrderedCaloHitList &selectedCaloHitList, pandora::OrderedCaloHitList &rejectedCaloHitList) const
 Filter out low pulse height hits in close proximity to high pulse height hits. More...
 
pandora::StatusCode AddFilteredCaloHits (const pandora::OrderedCaloHitList &selectedCaloHitList, const pandora::OrderedCaloHitList &rejectedCaloHitList, HitToClusterMap &hitToClusterMap) const
 Merge previously filtered hits back into their associated clusters. More...
 
void MakePrimaryAssociations (const pandora::OrderedCaloHitList &orderedCaloHitList, HitAssociationMap &forwardHitAssociationMap, HitAssociationMap &backwardHitAssociationMap) const
 Control primary association formation. More...
 
void MakeSecondaryAssociations (const pandora::OrderedCaloHitList &orderedCaloHitList, HitAssociationMap &forwardHitAssociationMap, HitAssociationMap &backwardHitAssociationMap) const
 Control secondary association formation. More...
 
void IdentifyJoins (const pandora::OrderedCaloHitList &orderedCaloHitList, const HitAssociationMap &forwardHitAssociationMap, const HitAssociationMap &backwardHitAssociationMap, HitJoinMap &hitJoinMap) const
 Identify final hit joins for use in cluster formation. More...
 
void CreateClusters (const pandora::OrderedCaloHitList &orderedCaloHitList, const HitJoinMap &hitJoinMap, HitToClusterMap &hitToClusterMap) const
 Final cluster formation. More...
 
void CreatePrimaryAssociation (const pandora::CaloHit *const pCaloHitI, const pandora::CaloHit *const pCaloHitJ, HitAssociationMap &forwardHitAssociationMap, HitAssociationMap &backwardHitAssociationMap) const
 Create primary association if appropriate, hitI<->hitJ. More...
 
void CreateSecondaryAssociation (const pandora::CaloHit *const pCaloHitI, const pandora::CaloHit *const pCaloHitJ, HitAssociationMap &forwardHitAssociationMap, HitAssociationMap &backwardHitAssociationMap) const
 Create secondary association if appropriate, hitI<->hitJ. More...
 
const pandora::CaloHit * GetJoinHit (const pandora::CaloHit *const pCaloHit, const HitAssociationMap &hitAssociationMapI, const HitAssociationMap &hitAssociationMapJ) const
 Get hit to join by tracing associations via map I, checking via map J. More...
 
const pandora::CaloHit * TraceHitAssociation (const pandora::CaloHit *const pCaloHit, const HitAssociationMap &hitAssociationMapI, const HitAssociationMap &hitAssociationMapJ, unsigned int &nSteps) const
 Get last hit obtained by tracing associations via map I, checking via map J. More...
 

Private Attributes

bool m_mergeBackFilteredHits
 Merge rejected hits into their associated clusters. More...
 
unsigned int m_maxGapLayers
 Maximum number of layers for a gap. More...
 
float m_maxCaloHitSeparationSquared
 Square of maximum calo hit separation. More...
 
float m_minCaloHitSeparationSquared
 Square of minimum calo hit separation. More...
 
float m_closeSeparationSquared
 Length scale (squared) for close hit separation. More...
 

Detailed Description

Member Typedef Documentation

typedef std::unordered_map<const pandora::CaloHit*, HitAssociation> lar_content::TrackClusterCreationAlgorithm::HitAssociationMap
private

Definition at line 87 of file TrackClusterCreationAlgorithm.h.

typedef std::unordered_map<const pandora::CaloHit*, const pandora::CaloHit*> lar_content::TrackClusterCreationAlgorithm::HitJoinMap
private

Definition at line 88 of file TrackClusterCreationAlgorithm.h.

typedef std::unordered_map<const pandora::CaloHit*, const pandora::Cluster*> lar_content::TrackClusterCreationAlgorithm::HitToClusterMap
private

Definition at line 89 of file TrackClusterCreationAlgorithm.h.

Constructor & Destructor Documentation

lar_content::TrackClusterCreationAlgorithm::TrackClusterCreationAlgorithm ( )

Default constructor.

Definition at line 20 of file TrackClusterCreationAlgorithm.cc.

20  :
22  m_maxGapLayers(2),
26 {
27 }
float m_maxCaloHitSeparationSquared
Square of maximum calo hit separation.
TFile f
Definition: plotHisto.C:6
unsigned int m_maxGapLayers
Maximum number of layers for a gap.
bool m_mergeBackFilteredHits
Merge rejected hits into their associated clusters.
float m_minCaloHitSeparationSquared
Square of minimum calo hit separation.
float m_closeSeparationSquared
Length scale (squared) for close hit separation.

Member Function Documentation

StatusCode lar_content::TrackClusterCreationAlgorithm::AddFilteredCaloHits ( const pandora::OrderedCaloHitList &  selectedCaloHitList,
const pandora::OrderedCaloHitList &  rejectedCaloHitList,
HitToClusterMap hitToClusterMap 
) const
private

Merge previously filtered hits back into their associated clusters.

Parameters
selectedCaloHitListthe ordered list of selected hits
rejectedCaloHitListthe ordered list of rejected hits
hitToClusterMapthe mapping between hits and their clusters

Definition at line 106 of file TrackClusterCreationAlgorithm.cc.

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

Referenced by Run().

108 {
109  for (OrderedCaloHitList::const_iterator iter = rejectedCaloHitList.begin(), iterEnd = rejectedCaloHitList.end(); iter != iterEnd; ++iter)
110  {
111  CaloHitList *pCaloHitList = NULL;
112  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, selectedCaloHitList.GetCaloHitsInPseudoLayer(iter->first, pCaloHitList));
113 
114  CaloHitSet unavailableHits;
115 
116  CaloHitVector inputAvailableHits(iter->second->begin(), iter->second->end());
117  std::sort(inputAvailableHits.begin(), inputAvailableHits.end(), LArClusterHelper::SortHitsByPosition);
118 
119  CaloHitVector clusteredHits(pCaloHitList->begin(), pCaloHitList->end());
120  std::sort(clusteredHits.begin(), clusteredHits.end(), LArClusterHelper::SortHitsByPosition);
121 
122  bool carryOn(true);
123 
124  while (carryOn)
125  {
126  carryOn = false;
127  CaloHitVector newClusteredHits;
128 
129  for (const CaloHit *const pCaloHitI : inputAvailableHits)
130  {
131  if (unavailableHits.count(pCaloHitI))
132  continue;
133 
134  if (hitToClusterMap.end() != hitToClusterMap.find(pCaloHitI))
135  continue;
136 
137  const CaloHit *pClosestHit = NULL;
138  float closestSeparationSquared(m_minCaloHitSeparationSquared);
139 
140  for (const CaloHit *const pCaloHitJ : clusteredHits)
141  {
142  if (pCaloHitI->GetMipEquivalentEnergy() > pCaloHitJ->GetMipEquivalentEnergy())
143  continue;
144 
145  const float separationSquared((pCaloHitI->GetPositionVector() - pCaloHitJ->GetPositionVector()).GetMagnitudeSquared());
146 
147  if (separationSquared < closestSeparationSquared)
148  {
149  closestSeparationSquared = separationSquared;
150  pClosestHit = pCaloHitJ;
151  }
152  }
153 
154  if (!pClosestHit)
155  continue;
156 
157  HitToClusterMap::const_iterator mapIter = hitToClusterMap.find(pClosestHit);
158 
159  if (hitToClusterMap.end() == mapIter)
160  throw StatusCodeException(STATUS_CODE_FAILURE);
161 
162  const Cluster *const pCluster = mapIter->second;
163  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToCluster(*this, pCluster, pCaloHitI));
164  (void) hitToClusterMap.insert(HitToClusterMap::value_type(pCaloHitI, pCluster));
165 
166  newClusteredHits.push_back(pCaloHitI);
167  carryOn = true;
168  }
169 
170  for (const CaloHit *const pCaloHit : newClusteredHits)
171  {
172  clusteredHits.push_back(pCaloHit);
173  unavailableHits.insert(pCaloHit);
174  }
175  }
176  }
177 
178  return STATUS_CODE_SUCCESS;
179 }
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)
float m_minCaloHitSeparationSquared
Square of minimum calo hit separation.
void lar_content::TrackClusterCreationAlgorithm::CreateClusters ( const pandora::OrderedCaloHitList &  orderedCaloHitList,
const HitJoinMap hitJoinMap,
HitToClusterMap hitToClusterMap 
) const
private

Final cluster formation.

Parameters
orderedCaloHitListthe ordered calo hit list
hitJoinMapthe hit join map
hitToClusterMapthe mapping between hits and their clusters

Definition at line 274 of file TrackClusterCreationAlgorithm.cc.

References lar_content::LArClusterHelper::SortHitsByPosition().

Referenced by Run().

275 {
276  for (OrderedCaloHitList::const_iterator iter = orderedCaloHitList.begin(), iterEnd = orderedCaloHitList.end(); iter != iterEnd; ++iter)
277  {
278  CaloHitVector caloHits(iter->second->begin(), iter->second->end());
279  std::sort(caloHits.begin(), caloHits.end(), LArClusterHelper::SortHitsByPosition);
280 
281  for (const CaloHit *const pCaloHit : caloHits)
282  {
283  const Cluster *pCluster = NULL;
284 
285  HitToClusterMap::const_iterator mapIter = hitToClusterMap.find(pCaloHit);
286 
287  if (hitToClusterMap.end() == mapIter)
288  {
289  PandoraContentApi::Cluster::Parameters parameters;
290  parameters.m_caloHitList.push_back(pCaloHit);
291  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*this, parameters, pCluster));
292  hitToClusterMap.insert(HitToClusterMap::value_type(pCaloHit, pCluster));
293  }
294  else
295  {
296  pCluster = mapIter->second;
297  }
298 
299  HitJoinMap::const_iterator joinIter = hitJoinMap.find(pCaloHit);
300 
301  if (hitJoinMap.end() == joinIter)
302  continue;
303 
304  if (hitToClusterMap.end() != hitToClusterMap.find(joinIter->second))
305  throw StatusCodeException(STATUS_CODE_FAILURE);
306 
307  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToCluster(*this, pCluster, joinIter->second));
308  hitToClusterMap.insert(HitToClusterMap::value_type(joinIter->second, pCluster));
309  }
310  }
311 }
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 lar_content::TrackClusterCreationAlgorithm::CreatePrimaryAssociation ( const pandora::CaloHit *const  pCaloHitI,
const pandora::CaloHit *const  pCaloHitJ,
HitAssociationMap forwardHitAssociationMap,
HitAssociationMap backwardHitAssociationMap 
) const
private

Create primary association if appropriate, hitI<->hitJ.

Parameters
pCaloHitIaddress of calo hit I
pCaloHitJaddress of calo hit J
forwardHitAssociationMapthe forward hit association map
backwardHitAssociationMapthe backward hit association map

Definition at line 315 of file TrackClusterCreationAlgorithm.cc.

References m_maxCaloHitSeparationSquared.

Referenced by MakePrimaryAssociations().

317 {
318  const float distanceSquared((pCaloHitJ->GetPositionVector() - pCaloHitI->GetPositionVector()).GetMagnitudeSquared());
319 
320  if (distanceSquared > m_maxCaloHitSeparationSquared)
321  return;
322 
323  HitAssociationMap::iterator forwardIter = forwardHitAssociationMap.find(pCaloHitI);
324 
325  if (forwardHitAssociationMap.end() == forwardIter)
326  {
327  forwardHitAssociationMap.insert(HitAssociationMap::value_type(pCaloHitI, HitAssociation(pCaloHitJ, distanceSquared)));
328  }
329  else if (distanceSquared < forwardIter->second.GetPrimaryDistanceSquared())
330  {
331  forwardIter->second = HitAssociation(pCaloHitJ, distanceSquared);
332  }
333 
334  HitAssociationMap::iterator backwardIter = backwardHitAssociationMap.find(pCaloHitJ);
335 
336  if (backwardHitAssociationMap.end() == backwardIter)
337  {
338  backwardHitAssociationMap.insert(HitAssociationMap::value_type(pCaloHitJ, HitAssociation(pCaloHitI, distanceSquared)));
339  }
340  else if (distanceSquared < backwardIter->second.GetPrimaryDistanceSquared())
341  {
342  backwardIter->second = HitAssociation(pCaloHitI, distanceSquared);
343  }
344 }
intermediate_table::iterator iterator
float m_maxCaloHitSeparationSquared
Square of maximum calo hit separation.
void lar_content::TrackClusterCreationAlgorithm::CreateSecondaryAssociation ( const pandora::CaloHit *const  pCaloHitI,
const pandora::CaloHit *const  pCaloHitJ,
HitAssociationMap forwardHitAssociationMap,
HitAssociationMap backwardHitAssociationMap 
) const
private

Create secondary association if appropriate, hitI<->hitJ.

Parameters
pCaloHitIaddress of calo hit I
pCaloHitJaddress of calo hit J
forwardHitAssociationMapthe forward hit association map
backwardHitAssociationMapthe backward hit association map

Definition at line 348 of file TrackClusterCreationAlgorithm.cc.

References lar_content::TrackClusterCreationAlgorithm::HitAssociation::GetPrimaryDistanceSquared(), lar_content::TrackClusterCreationAlgorithm::HitAssociation::GetPrimaryTarget(), lar_content::TrackClusterCreationAlgorithm::HitAssociation::GetSecondaryDistanceSquared(), m_closeSeparationSquared, and lar_content::TrackClusterCreationAlgorithm::HitAssociation::SetSecondaryTarget().

Referenced by MakeSecondaryAssociations().

350 {
351  HitAssociationMap::iterator forwardIter = forwardHitAssociationMap.find(pCaloHitI);
352  HitAssociationMap::iterator backwardIter = backwardHitAssociationMap.find(pCaloHitJ);
353 
354  if ((forwardHitAssociationMap.end() == forwardIter) || (backwardHitAssociationMap.end() == backwardIter))
355  return;
356 
357  HitAssociation &forwardAssociation(forwardIter->second);
358  HitAssociation &backwardAssociation(backwardIter->second);
359 
360  if ((forwardAssociation.GetPrimaryTarget() != pCaloHitJ) && (backwardAssociation.GetPrimaryTarget() == pCaloHitI))
361  {
362  if ((backwardAssociation.GetPrimaryDistanceSquared() < forwardAssociation.GetSecondaryDistanceSquared()) &&
363  (backwardAssociation.GetPrimaryDistanceSquared() < m_closeSeparationSquared))
364  {
365  forwardAssociation.SetSecondaryTarget(pCaloHitJ, backwardAssociation.GetPrimaryDistanceSquared());
366  }
367  }
368 
369  if ((backwardAssociation.GetPrimaryTarget() != pCaloHitI) && (forwardAssociation.GetPrimaryTarget() == pCaloHitJ))
370  {
371  if ((forwardAssociation.GetPrimaryDistanceSquared() < backwardAssociation.GetSecondaryDistanceSquared()) &&
372  (forwardAssociation.GetPrimaryDistanceSquared() < m_closeSeparationSquared))
373  {
374  backwardAssociation.SetSecondaryTarget(pCaloHitI, forwardAssociation.GetPrimaryDistanceSquared());
375  }
376  }
377 }
intermediate_table::iterator iterator
float m_closeSeparationSquared
Length scale (squared) for close hit separation.
StatusCode lar_content::TrackClusterCreationAlgorithm::FilterCaloHits ( const pandora::CaloHitList *const  pCaloHitList,
pandora::OrderedCaloHitList &  selectedCaloHitList,
pandora::OrderedCaloHitList &  rejectedCaloHitList 
) const
private

Filter out low pulse height hits in close proximity to high pulse height hits.

Parameters
pCaloHitListinput hit list
selectedCaloHitListthe output selected list of selected hits
rejectedCaloHitListthe output rejected list of rejected hits

Definition at line 58 of file TrackClusterCreationAlgorithm.cc.

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

Referenced by Run().

59 {
60  CaloHitList availableHitList;
61 
62  for (const CaloHit *const pCaloHit : *pCaloHitList)
63  {
64  if (PandoraContentApi::IsAvailable(*this, pCaloHit))
65  availableHitList.push_back(pCaloHit);
66  }
67 
68  if (availableHitList.empty())
69  return STATUS_CODE_SUCCESS;
70 
71  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, selectedCaloHitList.Add(availableHitList));
72 
73  for (OrderedCaloHitList::const_iterator iter = selectedCaloHitList.begin(), iterEnd = selectedCaloHitList.end(); iter != iterEnd; ++iter)
74  {
75  CaloHitVector caloHits(iter->second->begin(), iter->second->end());
76  std::sort(caloHits.begin(), caloHits.end(), LArClusterHelper::SortHitsByPosition);
77 
78  for (const CaloHit *const pCaloHitI : caloHits)
79  {
80  bool useCaloHit(true);
81 
82  for (const CaloHit *const pCaloHitJ : caloHits)
83  {
84  if (pCaloHitI == pCaloHitJ)
85  continue;
86 
87  if ((pCaloHitI->GetMipEquivalentEnergy() < pCaloHitJ->GetMipEquivalentEnergy()) &&
88  ((pCaloHitI->GetPositionVector() - pCaloHitJ->GetPositionVector()).GetMagnitudeSquared() < m_minCaloHitSeparationSquared))
89  {
90  useCaloHit = false;
91  break;
92  }
93  }
94 
95  if (!useCaloHit)
96  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, rejectedCaloHitList.Add(pCaloHitI));
97  }
98  }
99 
100  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, selectedCaloHitList.Remove(rejectedCaloHitList));
101  return STATUS_CODE_SUCCESS;
102 }
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)
float m_minCaloHitSeparationSquared
Square of minimum calo hit separation.
const CaloHit * lar_content::TrackClusterCreationAlgorithm::GetJoinHit ( const pandora::CaloHit *const  pCaloHit,
const HitAssociationMap hitAssociationMapI,
const HitAssociationMap hitAssociationMapJ 
) const
private

Get hit to join by tracing associations via map I, checking via map J.

Parameters
pCaloHitthe initial calo hit
hitAssociationMapIhit association map I
hitAssociationMapJhit association map J
Returns
the hit to join

Definition at line 381 of file TrackClusterCreationAlgorithm.cc.

References TraceHitAssociation().

Referenced by IdentifyJoins().

383 {
384  HitAssociationMap::const_iterator iterI = hitAssociationMapI.find(pCaloHit);
385 
386  if (hitAssociationMapI.end() == iterI)
387  return NULL;
388 
389  const CaloHit *const pPrimaryTarget = iterI->second.GetPrimaryTarget();
390  const CaloHit *const pSecondaryTarget = iterI->second.GetSecondaryTarget();
391 
392  if (NULL == pSecondaryTarget)
393  return pPrimaryTarget;
394 
395  unsigned int primaryNSteps(0), secondaryNSteps(0);
396  const CaloHit *const pPrimaryTrace = this->TraceHitAssociation(pPrimaryTarget, hitAssociationMapI, hitAssociationMapJ, primaryNSteps);
397  const CaloHit *const pSecondaryTrace = this->TraceHitAssociation(pSecondaryTarget, hitAssociationMapI, hitAssociationMapJ, secondaryNSteps);
398 
399  if ((pPrimaryTrace == pSecondaryTrace) || (secondaryNSteps < 5))
400  return pPrimaryTarget;
401 
402  return NULL;
403 }
intermediate_table::const_iterator const_iterator
const pandora::CaloHit * TraceHitAssociation(const pandora::CaloHit *const pCaloHit, const HitAssociationMap &hitAssociationMapI, const HitAssociationMap &hitAssociationMapJ, unsigned int &nSteps) const
Get last hit obtained by tracing associations via map I, checking via map J.
void lar_content::TrackClusterCreationAlgorithm::IdentifyJoins ( const pandora::OrderedCaloHitList &  orderedCaloHitList,
const HitAssociationMap forwardHitAssociationMap,
const HitAssociationMap backwardHitAssociationMap,
HitJoinMap hitJoinMap 
) const
private

Identify final hit joins for use in cluster formation.

Parameters
orderedCaloHitListthe ordered calo hit list
forwardHitAssociationMapthe forward hit association map
backwardHitAssociationMapthe backward hit association map
hitJoinMapto receive the hit join map

Definition at line 245 of file TrackClusterCreationAlgorithm.cc.

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

Referenced by Run().

247 {
248  for (OrderedCaloHitList::const_iterator iter = orderedCaloHitList.begin(), iterEnd = orderedCaloHitList.end(); iter != iterEnd; ++iter)
249  {
250  CaloHitVector caloHits(iter->second->begin(), iter->second->end());
251  std::sort(caloHits.begin(), caloHits.end(), LArClusterHelper::SortHitsByPosition);
252 
253  for (const CaloHit *const pCaloHit : caloHits)
254  {
255  const CaloHit *const pForwardJoinHit = this->GetJoinHit(pCaloHit, forwardHitAssociationMap, backwardHitAssociationMap);
256  const CaloHit *const pBackwardJoinHit = this->GetJoinHit(pForwardJoinHit, backwardHitAssociationMap, forwardHitAssociationMap);
257 
258  if ((NULL == pForwardJoinHit) || (NULL == pBackwardJoinHit) || (pBackwardJoinHit != pCaloHit))
259  continue;
260 
261  HitJoinMap::const_iterator joinIter = hitJoinMap.find(pCaloHit);
262 
263  if (hitJoinMap.end() == joinIter)
264  hitJoinMap.insert(HitJoinMap::value_type(pCaloHit, pForwardJoinHit));
265 
266  if ((hitJoinMap.end() != joinIter) && (joinIter->second != pForwardJoinHit))
267  throw StatusCodeException(STATUS_CODE_FAILURE);
268  }
269  }
270 }
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)
const pandora::CaloHit * GetJoinHit(const pandora::CaloHit *const pCaloHit, const HitAssociationMap &hitAssociationMapI, const HitAssociationMap &hitAssociationMapJ) const
Get hit to join by tracing associations via map I, checking via map J.
void lar_content::TrackClusterCreationAlgorithm::MakePrimaryAssociations ( const pandora::OrderedCaloHitList &  orderedCaloHitList,
HitAssociationMap forwardHitAssociationMap,
HitAssociationMap backwardHitAssociationMap 
) const
private

Control primary association formation.

Parameters
orderedCaloHitListthe ordered calo hit list
forwardHitAssociationMapthe forward hit association map
backwardHitAssociationMapthe backward hit association map

Definition at line 183 of file TrackClusterCreationAlgorithm.cc.

References CreatePrimaryAssociation(), m_maxGapLayers, and lar_content::LArClusterHelper::SortHitsByPosition().

Referenced by Run().

185 {
186  for (OrderedCaloHitList::const_iterator iterI = orderedCaloHitList.begin(), iterIEnd = orderedCaloHitList.end(); iterI != iterIEnd; ++iterI)
187  {
188  unsigned int nLayersConsidered(0);
189 
190  CaloHitVector caloHitsI(iterI->second->begin(), iterI->second->end());
191  std::sort(caloHitsI.begin(), caloHitsI.end(), LArClusterHelper::SortHitsByPosition);
192 
193  for (OrderedCaloHitList::const_iterator iterJ = iterI, iterJEnd = orderedCaloHitList.end(); (nLayersConsidered++ <= m_maxGapLayers + 1) && (iterJ != iterJEnd); ++iterJ)
194  {
195  if (iterJ->first == iterI->first || iterJ->first > iterI->first + m_maxGapLayers + 1)
196  continue;
197 
198  CaloHitVector caloHitsJ(iterJ->second->begin(), iterJ->second->end());
199  std::sort(caloHitsJ.begin(), caloHitsJ.end(), LArClusterHelper::SortHitsByPosition);
200 
201  for (const CaloHit *const pCaloHitI : caloHitsI)
202  {
203  for (const CaloHit *const pCaloHitJ : caloHitsJ)
204  this->CreatePrimaryAssociation(pCaloHitI, pCaloHitJ, forwardHitAssociationMap, backwardHitAssociationMap);
205  }
206  }
207  }
208 }
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 CreatePrimaryAssociation(const pandora::CaloHit *const pCaloHitI, const pandora::CaloHit *const pCaloHitJ, HitAssociationMap &forwardHitAssociationMap, HitAssociationMap &backwardHitAssociationMap) const
Create primary association if appropriate, hitI<->hitJ.
unsigned int m_maxGapLayers
Maximum number of layers for a gap.
void lar_content::TrackClusterCreationAlgorithm::MakeSecondaryAssociations ( const pandora::OrderedCaloHitList &  orderedCaloHitList,
HitAssociationMap forwardHitAssociationMap,
HitAssociationMap backwardHitAssociationMap 
) const
private

Control secondary association formation.

Parameters
orderedCaloHitListthe ordered calo hit list
forwardHitAssociationMapthe forward hit association map
backwardHitAssociationMapthe backward hit association map

Definition at line 212 of file TrackClusterCreationAlgorithm.cc.

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

Referenced by Run().

214 {
215  for (OrderedCaloHitList::const_iterator iter = orderedCaloHitList.begin(), iterEnd = orderedCaloHitList.end(); iter != iterEnd; ++iter)
216  {
217  CaloHitVector caloHits(iter->second->begin(), iter->second->end());
218  std::sort(caloHits.begin(), caloHits.end(), LArClusterHelper::SortHitsByPosition);
219 
220  for (const CaloHit *const pCaloHit : caloHits)
221  {
222  HitAssociationMap::const_iterator fwdIter = forwardHitAssociationMap.find(pCaloHit);
223  const CaloHit *const pForwardHit((forwardHitAssociationMap.end() == fwdIter) ? NULL : fwdIter->second.GetPrimaryTarget());
224 
225  HitAssociationMap::const_iterator fwdCheckIter = backwardHitAssociationMap.find(pForwardHit);
226  const CaloHit *const pForwardHitCheck((backwardHitAssociationMap.end() == fwdCheckIter) ? NULL : fwdCheckIter->second.GetPrimaryTarget());
227 
228  if ((NULL != pForwardHit) && (pForwardHitCheck != pCaloHit))
229  this->CreateSecondaryAssociation(pCaloHit, pForwardHit, forwardHitAssociationMap, backwardHitAssociationMap);
230 
231  HitAssociationMap::const_iterator bwdIter = backwardHitAssociationMap.find(pCaloHit);
232  const CaloHit *const pBackwardHit((backwardHitAssociationMap.end() == bwdIter) ? NULL : bwdIter->second.GetPrimaryTarget());
233 
234  HitAssociationMap::const_iterator bwdCheckIter = forwardHitAssociationMap.find(pBackwardHit);
235  const CaloHit *const pBackwardHitCheck((forwardHitAssociationMap.end() == bwdCheckIter) ? NULL : bwdCheckIter->second.GetPrimaryTarget());
236 
237  if ((NULL != pBackwardHit) && (pBackwardHitCheck != pCaloHit))
238  this->CreateSecondaryAssociation(pBackwardHit, pCaloHit, forwardHitAssociationMap, backwardHitAssociationMap);
239  }
240  }
241 }
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 CreateSecondaryAssociation(const pandora::CaloHit *const pCaloHitI, const pandora::CaloHit *const pCaloHitJ, HitAssociationMap &forwardHitAssociationMap, HitAssociationMap &backwardHitAssociationMap) const
Create secondary association if appropriate, hitI<->hitJ.
StatusCode lar_content::TrackClusterCreationAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 438 of file TrackClusterCreationAlgorithm.cc.

References m_closeSeparationSquared, m_maxCaloHitSeparationSquared, m_maxGapLayers, m_mergeBackFilteredHits, and m_minCaloHitSeparationSquared.

439 {
440  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
441  "MergeBackFilteredHits", m_mergeBackFilteredHits));
442 
443  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
444  "MaxGapLayers", m_maxGapLayers));
445 
446  float maxCaloHitSeparation = std::sqrt(m_maxCaloHitSeparationSquared);
447  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
448  "MaxCaloHitSeparation", maxCaloHitSeparation));
449  m_maxCaloHitSeparationSquared = maxCaloHitSeparation * maxCaloHitSeparation;
450 
451  float minCaloHitSeparation = std::sqrt(m_minCaloHitSeparationSquared);
452  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
453  "MinCaloHitSeparation", minCaloHitSeparation));
454  m_minCaloHitSeparationSquared = minCaloHitSeparation * minCaloHitSeparation;
455 
456  float closeSeparation = std::sqrt(m_closeSeparationSquared);
457  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
458  "CloseSeparation", closeSeparation));
459  m_closeSeparationSquared = closeSeparation * closeSeparation;
460 
461  return STATUS_CODE_SUCCESS;
462 }
float m_maxCaloHitSeparationSquared
Square of maximum calo hit separation.
unsigned int m_maxGapLayers
Maximum number of layers for a gap.
bool m_mergeBackFilteredHits
Merge rejected hits into their associated clusters.
float m_minCaloHitSeparationSquared
Square of minimum calo hit separation.
float m_closeSeparationSquared
Length scale (squared) for close hit separation.
StatusCode lar_content::TrackClusterCreationAlgorithm::Run ( )
private

Definition at line 31 of file TrackClusterCreationAlgorithm.cc.

References AddFilteredCaloHits(), CreateClusters(), FilterCaloHits(), IdentifyJoins(), m_mergeBackFilteredHits, MakePrimaryAssociations(), and MakeSecondaryAssociations().

32 {
33  const CaloHitList *pCaloHitList = NULL;
34  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pCaloHitList));
35 
36  OrderedCaloHitList selectedCaloHitList, rejectedCaloHitList;
37  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->FilterCaloHits(pCaloHitList, selectedCaloHitList, rejectedCaloHitList));
38 
39  HitAssociationMap forwardHitAssociationMap, backwardHitAssociationMap;
40  this->MakePrimaryAssociations(selectedCaloHitList, forwardHitAssociationMap, backwardHitAssociationMap);
41  this->MakeSecondaryAssociations(selectedCaloHitList, forwardHitAssociationMap, backwardHitAssociationMap);
42 
43  HitJoinMap hitJoinMap;
44  HitToClusterMap hitToClusterMap;
45  this->IdentifyJoins(selectedCaloHitList, forwardHitAssociationMap, backwardHitAssociationMap, hitJoinMap);
46  this->CreateClusters(selectedCaloHitList, hitJoinMap, hitToClusterMap);
47 
49  this->CreateClusters(rejectedCaloHitList, hitJoinMap, hitToClusterMap);
50 
51  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->AddFilteredCaloHits(selectedCaloHitList, rejectedCaloHitList, hitToClusterMap));
52 
53  return STATUS_CODE_SUCCESS;
54 }
pandora::StatusCode FilterCaloHits(const pandora::CaloHitList *const pCaloHitList, pandora::OrderedCaloHitList &selectedCaloHitList, pandora::OrderedCaloHitList &rejectedCaloHitList) const
Filter out low pulse height hits in close proximity to high pulse height hits.
pandora::StatusCode AddFilteredCaloHits(const pandora::OrderedCaloHitList &selectedCaloHitList, const pandora::OrderedCaloHitList &rejectedCaloHitList, HitToClusterMap &hitToClusterMap) const
Merge previously filtered hits back into their associated clusters.
void IdentifyJoins(const pandora::OrderedCaloHitList &orderedCaloHitList, const HitAssociationMap &forwardHitAssociationMap, const HitAssociationMap &backwardHitAssociationMap, HitJoinMap &hitJoinMap) const
Identify final hit joins for use in cluster formation.
void MakePrimaryAssociations(const pandora::OrderedCaloHitList &orderedCaloHitList, HitAssociationMap &forwardHitAssociationMap, HitAssociationMap &backwardHitAssociationMap) const
Control primary association formation.
std::unordered_map< const pandora::CaloHit *, const pandora::CaloHit * > HitJoinMap
void CreateClusters(const pandora::OrderedCaloHitList &orderedCaloHitList, const HitJoinMap &hitJoinMap, HitToClusterMap &hitToClusterMap) const
Final cluster formation.
std::unordered_map< const pandora::CaloHit *, HitAssociation > HitAssociationMap
std::unordered_map< const pandora::CaloHit *, const pandora::Cluster * > HitToClusterMap
bool m_mergeBackFilteredHits
Merge rejected hits into their associated clusters.
void MakeSecondaryAssociations(const pandora::OrderedCaloHitList &orderedCaloHitList, HitAssociationMap &forwardHitAssociationMap, HitAssociationMap &backwardHitAssociationMap) const
Control secondary association formation.
const CaloHit * lar_content::TrackClusterCreationAlgorithm::TraceHitAssociation ( const pandora::CaloHit *const  pCaloHit,
const HitAssociationMap hitAssociationMapI,
const HitAssociationMap hitAssociationMapJ,
unsigned int &  nSteps 
) const
private

Get last hit obtained by tracing associations via map I, checking via map J.

Parameters
pCaloHitthe initial calo hit
hitAssociationMapIhit association map I
hitAssociationMapJhit association map J
nStepsto receive the number of association steps
Returns
the last hit obtained in the chain of associations

Definition at line 407 of file TrackClusterCreationAlgorithm.cc.

Referenced by GetJoinHit().

409 {
410  nSteps = 0;
411  const CaloHit *pThisHit = pCaloHit;
412  const CaloHit *pLastHit = pCaloHit;
413 
414  while (true)
415  {
416  ++nSteps;
417  pThisHit = pLastHit;
418  HitAssociationMap::const_iterator iterI = hitAssociationMapI.find(pThisHit);
419 
420  if (hitAssociationMapI.end() == iterI)
421  break;
422 
423  pLastHit = iterI->second.GetPrimaryTarget();
424  HitAssociationMap::const_iterator iterJ = hitAssociationMapJ.find(pLastHit);
425 
426  if (hitAssociationMapJ.end() == iterJ)
427  break;
428 
429  if (iterJ->second.GetPrimaryTarget() != pThisHit)
430  break;
431  }
432 
433  return pThisHit;
434 }
intermediate_table::const_iterator const_iterator

Member Data Documentation

float lar_content::TrackClusterCreationAlgorithm::m_closeSeparationSquared
private

Length scale (squared) for close hit separation.

Definition at line 202 of file TrackClusterCreationAlgorithm.h.

Referenced by CreateSecondaryAssociation(), and ReadSettings().

float lar_content::TrackClusterCreationAlgorithm::m_maxCaloHitSeparationSquared
private

Square of maximum calo hit separation.

Definition at line 200 of file TrackClusterCreationAlgorithm.h.

Referenced by CreatePrimaryAssociation(), and ReadSettings().

unsigned int lar_content::TrackClusterCreationAlgorithm::m_maxGapLayers
private

Maximum number of layers for a gap.

Definition at line 199 of file TrackClusterCreationAlgorithm.h.

Referenced by MakePrimaryAssociations(), and ReadSettings().

bool lar_content::TrackClusterCreationAlgorithm::m_mergeBackFilteredHits
private

Merge rejected hits into their associated clusters.

Definition at line 198 of file TrackClusterCreationAlgorithm.h.

Referenced by ReadSettings(), and Run().

float lar_content::TrackClusterCreationAlgorithm::m_minCaloHitSeparationSquared
private

Square of minimum calo hit separation.

Definition at line 201 of file TrackClusterCreationAlgorithm.h.

Referenced by AddFilteredCaloHits(), FilterCaloHits(), and ReadSettings().


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