HerdSoftware  0.2.3
HoughFinder2DAlgo.h
Go to the documentation of this file.
1 /*
2  * HoughFinder2DAlgo.h
3  *
4  * Created on: 20 Nov 2018
5  * Author: Valerio Formato
6  */
7 
8 #ifndef HoughFinder2DAlgo_H_
9 #define HoughFinder2DAlgo_H_
10 
11 // HERD headers
18 #include "dataobjects/Track2D.h"
19 
20 // Event Analysis headers
21 #include "algorithm/Algorithm.h"
22 
23 // headers for debug only
24 // #include "TCanvas.h"
25 // #include "TH2D.h"
26 
27 // c++ headers
28 #include <tuple>
29 
30 using namespace EA;
31 
32 namespace Herd {
61 using HFClusters = std::vector<std::vector<HFCluster>>;
62 
63 class HoughFinder2DAlgo : public Algorithm {
64 public:
69  HoughFinder2DAlgo(const std::string &name);
70 
75  bool Initialize() override;
76 
81  bool Process() override;
82 
87  bool Finalize() override;
88 
95  int GetVotingIndex(float R, float Theta);
96 
101  std::pair<float, float> GetRTheta(int votingIndex);
102 
109  void FindTracks(RefFrame::View view, const HFClusters &clusters);
110 
111 private:
112  unsigned int _nThetaDiv;
113  unsigned int _nRDiv;
114  float _RMax;
115  unsigned int _nVotes;
116 
120 
121  // TH2D *_debugHist;
122  // TCanvas *_debugCanv;
123 
124  // handle both stk and scd hits and import them
125  void ImportSiliconDetectorHits(const SiliconDetectorClustersColl &clColl,
126  const SiliconDetectorGeoParamsColl &geoParamsColl, HFCluster::DetectorType detType);
127 
128  // handle fit hits and import them
129  void ImportFitHits(const FitClustersColl &clColl, const FitGeoParamsColl &geoParamsColl);
130 
131  // Pretty self explanatory...
132  inline void ClearVotingSpace() { _votingSpace.clear(); };
133 
134  // Fill voting space with clusters. Pass the normal axis to the view to
135  // determine which coordinates will be used.
136  void FillVotingSpace(RefFrame::View view, const HFClusters &clusters);
137 
138  // Remove a cluster votes from the voting space. Avoids a cluster partecipating
139  // in more than one track.
140  // void RemoveFromVotingSpace(HoughTrackStub trStub);
141  void RemoveFromVotingSpace(const Cluster &cluster);
142 
143  // Find out the voting space cell with highest number of votes
144  int FindCandidateTrack();
145 
146  // Aggregate all compatible votes around maximum
147  std::vector<HoughTrackStub> AccumulateVotes(int votingIndex);
148 
149  // Search around vote for compatible stubs
150  void SearchVotes(int votingIndex, std::vector<int> &vIndexes);
151 
152  // Find back a cluster given the seed ID
153  std::pair<bool, HFCluster> FindClusterFromSeedIndex(const HFClusters &clColl, unsigned int clID);
154 
155  // Get average direction from list of votes
156  std::pair<float, float> GetAvRTheta(const std::vector<HoughTrackStub> &votes);
157 
158  // Build a track from a set of votes and eventually add it to the collection
159  void BuildTrackFromVotes(std::vector<HoughTrackStub> &votes, const HFClusters &clusters);
160 
161  // Separate internal representation of clusters into separate detector collections, depending on a list
162  // of votes
163  std::tuple<StkClustersColl, ScdClustersColl, FitClustersColl>
164  FillClusterCollections(const std::vector<HoughTrackStub> &votes, const HFClusters &clColl);
165 
166  // int index -> list of track stubs that voted for that index
167  std::unordered_map<int, std::vector<HoughTrackStub>> _votingSpace;
168 
169  EA::observer_ptr<StkGeoParamsColl> _stkGeoParamsColl;
170  EA::observer_ptr<ScdGeoParamsColl> _scdGeoParamsColl;
171  EA::observer_ptr<FitGeoParamsColl> _fitGeoParamsColl;
172  std::vector<Track2D> _trackColl;
173  StorePtr _globStore; // Pointer to the global data store
174  StorePtr _evStore; // Pointer to the event data store
175 };
176 } // namespace Herd
177 #endif
std::vector< Track2D > _trackColl
Definition: HoughFinder2DAlgo.h:172
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:24
DetectorType
Definition: HFCluster.h:23
std::unordered_map< int, std::vector< HoughTrackStub > > _votingSpace
Definition: HoughFinder2DAlgo.h:167
Finds tracks from a collection of 2D hits.
Definition: HoughFinder2DAlgo.h:63
Tracker cluster object for transient data model.
Definition: Cluster.h:30
std::vector< std::vector< HFCluster > > HFClusters
Definition: HoughFinder2DAlgo.h:61
void ClearVotingSpace()
Definition: HoughFinder2DAlgo.h:132
HFClusters _clXY
Definition: HoughFinder2DAlgo.h:119
EA::observer_ptr< ScdGeoParamsColl > _scdGeoParamsColl
Definition: HoughFinder2DAlgo.h:170
EA::observer_ptr< FitGeoParamsColl > _fitGeoParamsColl
Definition: HoughFinder2DAlgo.h:171
float _RMax
Definition: HoughFinder2DAlgo.h:114
EA::observer_ptr< StkGeoParamsColl > _stkGeoParamsColl
Definition: HoughFinder2DAlgo.h:169
HFClusters _clYZ
Definition: HoughFinder2DAlgo.h:118
HFClusters _clXZ
Definition: HoughFinder2DAlgo.h:117
unsigned int _nRDiv
Definition: HoughFinder2DAlgo.h:113
Collection of containers for the clusters of all the FIT detectors.
Definition: FitClustersColl.h:23
View
Aliases for the three 2D projection planes. RefFrame.h common/RefFrame.h.
Definition: RefFrame.h:90
unsigned int _nThetaDiv
Definition: HoughFinder2DAlgo.h:112
unsigned int _nVotes
Definition: HoughFinder2DAlgo.h:115
StorePtr _globStore
Definition: HoughFinder2DAlgo.h:173
StorePtr _evStore
Definition: HoughFinder2DAlgo.h:174