LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
LArGraph.h
Go to the documentation of this file.
1 
8 #ifndef LAR_GRAPH_H
9 #define LAR_GRAPH_H 1
10 
11 #include "Objects/Cluster.h"
12 
13 #include <Eigen/Dense>
14 
15 namespace lar_content
16 {
17 
21 class LArGraph
22 {
23 public:
24  class Edge
25  {
26  public:
33  Edge(const pandora::CaloHit *const pVertex0, const pandora::CaloHit *const pVertex1);
34 
40  float LengthSquared() const;
41 
49  inline bool operator==(const Edge &other) const
50  {
51  return (this->m_v0 == other.m_v0 && this->m_v1 == other.m_v1) || (this->m_v0 == other.m_v1 && this->m_v1 == other.m_v0);
52  };
53 
54  const pandora::CaloHit *const m_v0;
55  const pandora::CaloHit *const m_v1;
56  };
57  typedef std::vector<const Edge *> EdgeVector;
58 
59 private:
60  typedef std::map<const pandora::CaloHit *, EdgeVector> HitEdgeMap;
61  typedef std::map<const pandora::CaloHit *, pandora::CaloHitList> HitConnectionsMap;
62  typedef std::map<const pandora::CaloHit *, bool> HitUseMap;
63 
64 public:
73  LArGraph(const bool fullyConnect = true, const int nSourceEdges = 2, const float maxSecondaryCosine = 0.996f, const float maxSecondaryDistance = 3.f);
74 
78  ~LArGraph();
79 
85  const EdgeVector &GetEdges() const;
86 
92  void MakeGraph(const pandora::CaloHitList &caloHitList);
93 
102  void Walk(const pandora::CaloHit *const pCaloHit, const HitEdgeMap &hitToEdgesMap, pandora::CaloHitList &graph, HitUseMap &connectedHits) const;
103 
104 private:
111  void IdentifyDisconnectedRegions(const HitEdgeMap &hitToEdgesMap, HitConnectionsMap &graphs) const;
112 
119  void ConnectRegions(const HitConnectionsMap &graphs, HitEdgeMap &hitToEdgesMap);
120 
127  void Vectorize(const pandora::CaloHitList &caloHitList, Eigen::MatrixXf &hitMatrix) const;
128 
129  EdgeVector m_edges;
134 };
135 
136 } // namespace lar_content
137 
138 #endif // #ifndef LAR_GRAPH_H
int m_nSourceEdges
The number of edges to consider emerging from a source.
Definition: LArGraph.h:131
const EdgeVector & GetEdges() const
Retrieve the edges for this graph.
Definition: LArGraph.cc:38
const pandora::CaloHit *const m_v1
An endpoint of the edge.
Definition: LArGraph.h:55
~LArGraph()
Destructor.
Definition: LArGraph.cc:30
std::map< const pandora::CaloHit *, bool > HitUseMap
Definition: LArGraph.h:62
LArGraph class.
Definition: LArGraph.h:21
float m_maxSecondaryCosine
The number of edges to consider emerging from a source.
Definition: LArGraph.h:132
TFile f
Definition: plotHisto.C:6
std::vector< const Edge * > EdgeVector
Definition: LArGraph.h:57
void MakeGraph(const pandora::CaloHitList &caloHitList)
Construct a graph from a list of calo hits.
Definition: LArGraph.cc:45
bool operator==(const Edge &other) const
Check if another edge shares the same calo hit end points.
Definition: LArGraph.h:49
void ConnectRegions(const HitConnectionsMap &graphs, HitEdgeMap &hitToEdgesMap)
Identify the different disconnected sub graphs in a set of eges.
Definition: LArGraph.cc:174
float m_maxSecondaryDistance
The number of edges to consider emerging from a source.
Definition: LArGraph.h:133
Edge(const pandora::CaloHit *const pVertex0, const pandora::CaloHit *const pVertex1)
Constructor.
Definition: LArGraph.cc:242
EdgeVector m_edges
The edges defining the graph.
Definition: LArGraph.h:129
std::map< const pandora::CaloHit *, pandora::CaloHitList > HitConnectionsMap
Definition: LArGraph.h:61
const pandora::CaloHit *const m_v0
An endpoint of the edge.
Definition: LArGraph.h:52
void Walk(const pandora::CaloHit *const pCaloHit, const HitEdgeMap &hitToEdgesMap, pandora::CaloHitList &graph, HitUseMap &connectedHits) const
Walk along node edges to define a connected graph.
Definition: LArGraph.cc:135
void IdentifyDisconnectedRegions(const HitEdgeMap &hitToEdgesMap, HitConnectionsMap &graphs) const
Identify the different disconnected sub graphs in a set of eges.
Definition: LArGraph.cc:153
float LengthSquared() const
Compute the square of the length of this edge.
Definition: LArGraph.cc:250
void Vectorize(const pandora::CaloHitList &caloHitList, Eigen::MatrixXf &hitMatrix) const
Convert a list of calo hits into an Eigen matrix.
Definition: LArGraph.cc:227
std::map< const pandora::CaloHit *, EdgeVector > HitEdgeMap
Definition: LArGraph.h:60
bool m_fullyConnect
Whether or not to connect any disconnected regions.
Definition: LArGraph.h:130
LArGraph(const bool fullyConnect=true, const int nSourceEdges=2, const float maxSecondaryCosine=0.996f, const float maxSecondaryDistance=3.f)
Constructor.
Definition: LArGraph.cc:20