HerdSoftware  0.3.2
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
14 #include "common/ViewArray.h"
20 
21 // Event Analysis headers
22 #include "algorithm/Algorithm.h"
23 #include "dataobjects/Track.h"
24 
25 // headers for debug only
26 // #include "TCanvas.h"
27 // #include "TH2D.h"
28 
29 // c++ headers
30 #include <tuple>
31 
32 using namespace EA;
33 
34 namespace Herd {
35 // clang-format off
67 // clang-format on
68 
69 using HFClusters = std::vector<std::vector<HFCluster>>;
70 
71 class HoughFinder2DAlgo : public Algorithm {
72 public:
77  HoughFinder2DAlgo(const std::string &name);
78 
83  bool Initialize() override;
84 
89  bool Process() override;
90 
95  bool Finalize() override;
96 
103  int GetVotingIndex(float R, float Theta);
104 
109  std::pair<float, float> GetRTheta(int votingIndex);
110 
117  void FindTracks(RefFrame::View view, const HFClusters &clusters);
118 
119 private:
120  std::string _collName = "tracks2DColl_hough";
121  bool _publishAlias = true;
122 
123  bool _useSCD = true;
124  bool _useFIT = true;
125 
126  unsigned int _nThetaDiv;
127  unsigned int _nRDiv;
128  float _RMax;
129  unsigned int _nVotes;
130 
134 
135  // TH2D *_debugHist;
136  // TCanvas *_debugCanv;
137 
138  // handle both stk and scd hits and import them
139  void ImportSiliconDetectorHits(const SiliconDetectorClustersColl &clColl,
140  const SiliconDetectorGeoParamsColl &geoParamsColl, HFCluster::DetectorType detType);
141 
142  // handle fit hits and import them
143  void ImportFitHits(const FitClustersColl &clColl, const FitGeoParamsColl &geoParamsColl);
144 
145  // Pretty self explanatory...
146  inline void ClearVotingSpace() { _votingSpace.clear(); };
147 
148  // Fill voting space with clusters. Pass the normal axis to the view to
149  // determine which coordinates will be used.
150  void FillVotingSpace(RefFrame::View view, const HFClusters &clusters);
151 
152  // Remove a cluster votes from the voting space. Avoids a cluster partecipating
153  // in more than one track.
154  // void RemoveFromVotingSpace(HoughTrackStub trStub);
155  void RemoveFromVotingSpace(const Cluster &cluster);
156 
157  // Find out the voting space cell with highest number of votes
158  int FindCandidateTrack();
159 
160  // Aggregate all compatible votes around maximum
161  std::vector<HoughTrackStub> AccumulateVotes(int votingIndex);
162 
163  // Search around vote for compatible stubs
164  void SearchVotes(int votingIndex, std::vector<int> &vIndexes);
165 
166  // Find back a cluster given the seed ID
167  std::pair<bool, HFCluster> FindClusterFromSeedIndex(const HFClusters &clColl, unsigned int clID);
168 
169  // Get average direction from list of votes
170  std::pair<float, float> GetAvRTheta(const std::vector<HoughTrackStub> &votes);
171 
172  // Build a track from a set of votes and eventually add it to the collection
173  Track2D BuildTrackFromVotes(std::vector<HoughTrackStub> &votes, const HFClusters &clColl);
174 
175  // Separate internal representation of clusters into separate detector collections, depending on a list
176  // of votes
177  std::tuple<StkClustersColl, ScdClustersColl, FitClustersColl>
178  FillClusterCollections(const std::vector<HoughTrackStub> &votes, const HFClusters &clColl);
179 
180  // int index -> list of track stubs that voted for that index
181  std::unordered_map<int, std::vector<HoughTrackStub>> _votingSpace;
182 
183  EA::observer_ptr<StkGeoParamsColl> _stkGeoParamsColl;
184  EA::observer_ptr<ScdGeoParamsColl> _scdGeoParamsColl;
185  EA::observer_ptr<FitGeoParamsColl> _fitGeoParamsColl;
187  StorePtr _globStore; // Pointer to the global data store
188  StorePtr _evStore; // Pointer to the event data store
189 };
190 } // namespace Herd
191 #endif
Track2DColl _trackColl
Definition: HoughFinder2DAlgo.h:186
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:181
Finds tracks from a collection of 2D hits.
Definition: HoughFinder2DAlgo.h:71
Tracker cluster object for transient data model.
Definition: Cluster.h:30
std::vector< std::vector< HFCluster > > HFClusters
Definition: HoughFinder2DAlgo.h:69
void ClearVotingSpace()
Definition: HoughFinder2DAlgo.h:146
HFClusters _clXY
Definition: HoughFinder2DAlgo.h:133
EA::observer_ptr< ScdGeoParamsColl > _scdGeoParamsColl
Definition: HoughFinder2DAlgo.h:184
EA::observer_ptr< FitGeoParamsColl > _fitGeoParamsColl
Definition: HoughFinder2DAlgo.h:185
float _RMax
Definition: HoughFinder2DAlgo.h:128
EA::observer_ptr< StkGeoParamsColl > _stkGeoParamsColl
Definition: HoughFinder2DAlgo.h:183
HFClusters _clYZ
Definition: HoughFinder2DAlgo.h:132
HFClusters _clXZ
Definition: HoughFinder2DAlgo.h:131
Class describing a track.
Definition: Track2D.h:34
unsigned int _nRDiv
Definition: HoughFinder2DAlgo.h:127
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:93
unsigned int _nThetaDiv
Definition: HoughFinder2DAlgo.h:126
unsigned int _nVotes
Definition: HoughFinder2DAlgo.h:129
StorePtr _globStore
Definition: HoughFinder2DAlgo.h:187
StorePtr _evStore
Definition: HoughFinder2DAlgo.h:188