LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
TrackClusterCreationAlgorithm.h
Go to the documentation of this file.
1 
8 #ifndef LAR_TRACK_CLUSTER_CREATION_ALGORITHM_H
9 #define LAR_TRACK_CLUSTER_CREATION_ALGORITHM_H 1
10 
11 #include "Pandora/Algorithm.h"
12 
13 #include <unordered_map>
14 
15 namespace lar_content
16 {
17 
21 class TrackClusterCreationAlgorithm : public pandora::Algorithm
22 {
23 public:
28 
29 private:
34  {
35  public:
42  HitAssociation(const pandora::CaloHit *const pPrimaryTarget, const float primaryDistanceSquared);
43 
50  void SetSecondaryTarget(const pandora::CaloHit *const pSecondaryTarget, const float secondaryDistanceSquared);
51 
57  const pandora::CaloHit *GetPrimaryTarget() const;
58 
64  const pandora::CaloHit *GetSecondaryTarget() const;
65 
71  float GetPrimaryDistanceSquared() const;
72 
78  float GetSecondaryDistanceSquared() const;
79 
80  private:
81  const pandora::CaloHit *m_pPrimaryTarget;
82  const pandora::CaloHit *m_pSecondaryTarget;
85  };
86 
87  typedef std::unordered_map<const pandora::CaloHit *, HitAssociation> HitAssociationMap;
88  typedef std::unordered_map<const pandora::CaloHit *, const pandora::CaloHit *> HitJoinMap;
89  typedef std::unordered_map<const pandora::CaloHit *, const pandora::Cluster *> HitToClusterMap;
90 
91  pandora::StatusCode Run();
92  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
93 
101  pandora::StatusCode FilterCaloHits(const pandora::CaloHitList *const pCaloHitList, pandora::OrderedCaloHitList &selectedCaloHitList,
102  pandora::OrderedCaloHitList &rejectedCaloHitList) const;
103 
111  pandora::StatusCode AddFilteredCaloHits(const pandora::OrderedCaloHitList &selectedCaloHitList,
112  const pandora::OrderedCaloHitList &rejectedCaloHitList, HitToClusterMap &hitToClusterMap) const;
113 
121  void MakePrimaryAssociations(const pandora::OrderedCaloHitList &orderedCaloHitList, HitAssociationMap &forwardHitAssociationMap,
122  HitAssociationMap &backwardHitAssociationMap) const;
123 
131  void MakeSecondaryAssociations(const pandora::OrderedCaloHitList &orderedCaloHitList, HitAssociationMap &forwardHitAssociationMap,
132  HitAssociationMap &backwardHitAssociationMap) const;
133 
142  void IdentifyJoins(const pandora::OrderedCaloHitList &orderedCaloHitList, const HitAssociationMap &forwardHitAssociationMap,
143  const HitAssociationMap &backwardHitAssociationMap, HitJoinMap &hitJoinMap) const;
144 
152  void CreateClusters(const pandora::OrderedCaloHitList &orderedCaloHitList, const HitJoinMap &hitJoinMap, HitToClusterMap &hitToClusterMap) const;
153 
162  void CreatePrimaryAssociation(const pandora::CaloHit *const pCaloHitI, const pandora::CaloHit *const pCaloHitJ,
163  HitAssociationMap &forwardHitAssociationMap, HitAssociationMap &backwardHitAssociationMap) const;
164 
173  void CreateSecondaryAssociation(const pandora::CaloHit *const pCaloHitI, const pandora::CaloHit *const pCaloHitJ,
174  HitAssociationMap &forwardHitAssociationMap, HitAssociationMap &backwardHitAssociationMap) const;
175 
185  const pandora::CaloHit *GetJoinHit(const pandora::CaloHit *const pCaloHit, const HitAssociationMap &hitAssociationMapI,
186  const HitAssociationMap &hitAssociationMapJ) const;
187 
198  const pandora::CaloHit *TraceHitAssociation(const pandora::CaloHit *const pCaloHit, const HitAssociationMap &hitAssociationMapI,
199  const HitAssociationMap &hitAssociationMapJ, unsigned int &nSteps) const;
200 
202  unsigned int m_maxGapLayers;
207 };
208 
209 //------------------------------------------------------------------------------------------------------------------------------------------
210 
211 inline TrackClusterCreationAlgorithm::HitAssociation::HitAssociation(const pandora::CaloHit *const pPrimaryTarget, const float primaryDistanceSquared) :
212  m_pPrimaryTarget(pPrimaryTarget),
213  m_pSecondaryTarget(NULL),
214  m_primaryDistanceSquared(primaryDistanceSquared),
215  m_secondaryDistanceSquared(std::numeric_limits<float>::max())
216 {
217 }
218 
219 //------------------------------------------------------------------------------------------------------------------------------------------
220 
221 inline void TrackClusterCreationAlgorithm::HitAssociation::SetSecondaryTarget(const pandora::CaloHit *const pSecondaryTarget, const float secondaryDistanceSquared)
222 {
223  m_pSecondaryTarget = pSecondaryTarget;
224  m_secondaryDistanceSquared = secondaryDistanceSquared;
225 }
226 
227 //------------------------------------------------------------------------------------------------------------------------------------------
228 
230 {
231  return m_pPrimaryTarget;
232 }
233 
234 //------------------------------------------------------------------------------------------------------------------------------------------
235 
237 {
238  return m_pSecondaryTarget;
239 }
240 
241 //------------------------------------------------------------------------------------------------------------------------------------------
242 
244 {
246 }
247 
248 //------------------------------------------------------------------------------------------------------------------------------------------
249 
251 {
253 }
254 
255 } // namespace lar_content
256 
257 #endif // #ifndef LAR_TRACK_CLUSTER_CREATION_ALGORITHM_H
const pandora::CaloHit * m_pSecondaryTarget
the secondary target
std::unordered_map< const pandora::CaloHit *, const pandora::Cluster * > HitToClusterMap
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.
float m_maxCaloHitSeparationSquared
Square of maximum calo hit separation.
STL namespace.
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.
float m_minMipFraction
Minimum fraction of a MIP to consider a hit.
float GetSecondaryDistanceSquared() const
Get the secondary distance squared.
std::unordered_map< const pandora::CaloHit *, HitAssociation > HitAssociationMap
void MakePrimaryAssociations(const pandora::OrderedCaloHitList &orderedCaloHitList, HitAssociationMap &forwardHitAssociationMap, HitAssociationMap &backwardHitAssociationMap) const
Control primary association formation.
const pandora::CaloHit * GetPrimaryTarget() const
Get the primary target.
std::unordered_map< const pandora::CaloHit *, const pandora::CaloHit * > HitJoinMap
float GetPrimaryDistanceSquared() const
Get the primary distance squared.
void SetSecondaryTarget(const pandora::CaloHit *const pSecondaryTarget, const float secondaryDistanceSquared)
Set secondary target.
void CreateClusters(const pandora::OrderedCaloHitList &orderedCaloHitList, const HitJoinMap &hitJoinMap, HitToClusterMap &hitToClusterMap) const
Final cluster formation.
void CreatePrimaryAssociation(const pandora::CaloHit *const pCaloHitI, const pandora::CaloHit *const pCaloHitJ, HitAssociationMap &forwardHitAssociationMap, HitAssociationMap &backwardHitAssociationMap) const
Create primary association if appropriate, hitI<->hitJ.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
unsigned int m_maxGapLayers
Maximum number of layers for a gap.
const pandora::CaloHit * GetSecondaryTarget() const
Get the secondary target.
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.
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.
HitAssociation(const pandora::CaloHit *const pPrimaryTarget, const float primaryDistanceSquared)
Constructor.
void CreateSecondaryAssociation(const pandora::CaloHit *const pCaloHitI, const pandora::CaloHit *const pCaloHitJ, HitAssociationMap &forwardHitAssociationMap, HitAssociationMap &backwardHitAssociationMap) const
Create secondary association if appropriate, hitI<->hitJ.
float m_minCaloHitSeparationSquared
Square of minimum calo hit separation.
float m_closeSeparationSquared
Length scale (squared) for close hit separation.
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.