PandaRoot
PndHoughTrackFinder.h
Go to the documentation of this file.
1 // PndHoughTrackFinder
3 // Finds Track for one event
5 
16 #ifndef PndHoughTrackFinder_H_
17 #define PndHoughTrackFinder_H_
18 
19 #include <vector>
20 
21 #include "PndSttCA.h"
22 
23 #include "PndHoughData.h"
24 #include "PndHoughUtilities.h"
25 #include "PndHoughTransformation.h"
26 #include "PndHoughSegment.h"
28 #include "PndHoughPreprocessing.h"
29 #include "PndHoughMerge.h"
30 #include "PndApolloniusTriplet.h"
31 
33  public:
35 
36  PndHoughTrackFinder(TClonesArray *tubeArray) : fNbins1(450), fNbins2(450), fNBinsSeg(90.), fBz(2.), fCutMergeByHoughSpace(5.), fWithGPU(kFALSE), fWithGhostReduction(kTRUE)
37  {
38  // Generate TrackFinderData-Object
39  fData = new PndHoughData(tubeArray);
40  fCATrackFinder = new PndSttCA(tubeArray);
41  ioman = FairRootManager::Instance();
42  };
43 
46  {
47  delete fData;
48  delete fCATrackFinder;
49 
50  delete fPndHoughTransformation;
51  delete fPndHoughPreprocessing;
52  delete fPndHoughMerge;
53  delete fPndHoughSegment;
54  delete fPndHoughUtilities;
55  delete fPndHoughTrackCorrection;
56  }
57 
59  virtual void SetBinningX(double bin) { fNbins1 = bin; };
61  virtual void SetBinningY(double bin) { fNbins2 = bin; };
63  virtual void SetNBinsSeg(Int_t n) { fNBinsSeg = n; };
65  virtual void SetBz(double B) { fBz = B; };
67  virtual void SetCutMergeByHoughSpace(float cut){ fCutMergeByHoughSpace = cut; }
69  virtual void SetWithGPU(bool cuda) { fWithGPU = cuda; }
71  virtual void SetWithGhostReduction(bool ghostred) { fWithGhostReduction = ghostred; }
72  virtual void SetPreselectedTrackCands(std::vector<PndTrackCand> cands) { fPreselectedTrackCands = cands; };
73  virtual void UseDefaultPreselection(bool pres) { fUseDefaultPreselection = pres; };
74  virtual void SetCombinedSkewed(TClonesArray *skewed) { fCombinedSkewed = skewed; };
76  void Init()
77  {
78  fData->Init(fNbins1, fNbins2);
79  fCATrackFinder->SetUseGPU(fWithGPU);
80  }
81 
83  void Reset()
84  {
85  fData->clear();
86 
87  fCATrackFinder->SetUseGPU(fWithGPU);
88  fCATrackFinder->Reset();
89 
90  fPreselectedTrackCands.clear();
91  fPreselectedTrackCircles.clear();
92  }
93 
95  void AddHits(TClonesArray *hits, TString branchName);
96 
99  {
100  fData->CreateSTTNeighborhoodData();
101  fData->CreateGEMNeighborhoodData();
102  }
104  void FindTracks();
105 
107  void Preselection();
108 
110  void FindHoughMaxima();
111  TVector2 calcPhiRange(PndTrackCand &trackCand);
112  bool IsInPhiRange(FairHit *hit, double phiLow, double phiHigh);
113  void AddSkewedHits(int i);
114  void AddOtherDetectorHits(int i, TString type);
116  std::vector<PndApollonius::TripletSolution> CombineIdenticalSolutionsFinal(std::vector<PndApollonius::TripletSolution> &solutions, Double_t ratioOfSameHits);
124 
125  double CalcRatioSameHits(PndApollonius::TripletSolution &sol, std::vector<PndApollonius::TripletSolution> &AlreadyFoundSolutions);
126 
128  PndTrackCand GetPreselectedTrackCand(int i) { return fPreselectedTrackCands[i]; };
129 
131  int GetNumPreselectedTrackCands() { return fPreselectedTrackCands.size(); };
132 
134  TVector3 GetPreselectedTrackCircles(int i) { return fPreselectedTrackCircles[i]; };
135 
137  int GetNumPreselectedTrackCircles() { return fPreselectedTrackCircles.size(); };
138 
140  PndTrack GetMergedTrack(int i) { return fPndHoughMerge->GetMergedTrack(i); };
141 
143  int GetNumMergedTracks() { return fPndHoughMerge->GetNumMergedTracks(); };
144 
146  // PndTrackCand GetMergedTrackCand(int i) { return fPndHoughMerge->GetMergedTrackCand(i); };
147 
149  // int GetNumMergedTrackCands() { return fPndHoughMerge->GetNumMergedTrackCands(); };
150 
152  std::map<FairLink, FairHit *> GetMapFairLinktoFairHit() { return fData->GetMapFairLinktoFairHit(); };
153 
155  PndHoughData *GetData() { return fData; };
156 
157  private:
158  FairRootManager *ioman = nullptr;
159 
160  PndSttCA *fCATrackFinder = nullptr;
161 
162  PndHoughData *fData = nullptr;
163  PndHoughTransformation *fPndHoughTransformation = nullptr;
164  PndHoughPreprocessing *fPndHoughPreprocessing = nullptr;
165  PndHoughMerge *fPndHoughMerge = nullptr;
166  PndHoughSegment *fPndHoughSegment = nullptr;
167  PndHoughUtilities *fPndHoughUtilities = nullptr;
168  PndHoughTrackCorrection *fPndHoughTrackCorrection = nullptr;
169  TClonesArray *fCombinedSkewed = nullptr;
170  std::vector<std::vector<TVector3>> fHoughSpacesToTracks;
171  std::vector<PndTrackCand> fHoughSpacesToTrackCands;
172  std::vector<PndTrackCand> fHoughSpacesToTrackCandTots;
173 
174  std::vector<FairLink> fFoundHits;
175 
176  std::vector<PndTrackCand> fPreselectedTrackCands;
177  std::vector<TVector3> fPreselectedTrackCircles;
178  std::vector<PndTrack> fApolloniusMergedTracks;
179  std::vector<PndTrackCand> fApolloniusMergedTrackCands;
180 
181  Double_t fBz;
182  float fCutMergeByHoughSpace;
183  Int_t fNbins1;
184  Int_t fNbins2;
185  Int_t fNBinsSeg;
186  bool fWithGPU;
187  bool fWithGhostReduction;
188  bool fUseDefaultPreselection = kTRUE;
189  double fDistanceThresholdSTTCombinedSkewed = 1.;
190  double fDistanceThresholdSTT = 0.3;
191  double fDistanceThresholdMVD = 0.5;
192  double fDistanceThresholdGEM = 1.;
193  std::map<FairLink, FairHit *> fMapFairLinktoFairHit;
194  std::map<FairLink, double> fMapFairLinktoIsochrone;
195  ClassDef(PndHoughTrackFinder, 1);
196 };
197 
198 #endif /*PndHoughTrackFinder_H_*/
double CalcRatioSameHits(PndApollonius::TripletSolution &sol, std::vector< PndApollonius::TripletSolution > &AlreadyFoundSolutions)
virtual void SetWithGhostReduction(bool ghostred)
Sets a bool for deciding to use a ghost reduction.
PndTrack GetMergedTrack(int i)
Returns a specific found track.
int GetNumMergedTracks()
Returns the number of found tracks.
TVector2 calcPhiRange(PndTrackCand &trackCand)
void CreateSTTNeighborhoodData()
For all STT hits all other STT neighbors are counted and stored in a map.
int GetNumPreselectedTrackCircles()
Returns the number of preselected circles for track candidates.
int GetNumMergedTracks()
Returns a specific merged track candidate.
Definition: PndHoughMerge.h:70
void Reset()
Resets the data for a new event.
std::map< FairLink, FairHit * > GetMapFairLinktoFairHit() const
Returns the map linking FairLinks to FairHits.
Definition: PndHoughData.h:92
void Preselection()
Here all data are preselected in smaller tracklets.
void Init()
Initializes the data structure and the Hough space of the HoughtrackFinder.
virtual void SetCutMergeByHoughSpace(float cut)
Sets the cut value for the distance of two maxima in the Hough space which have to be merged...
virtual void SetPreselectedTrackCands(std::vector< PndTrackCand > cands)
void AddOtherDetectorHits(int i, TString type)
unsigned int i
Definition: P4_F32vec4.h:21
virtual void SetNBinsSeg(Int_t n)
Sets the number of bins used for the segmentation preselection algorithm.
bool IsInPhiRange(FairHit *hit, double phiLow, double phiHigh)
TVector3 GetPreselectedTrackCircles(int i)
Returns a the corresponding circle for a specific preselected track candidate.
virtual void SetWithGPU(bool cuda)
Sets a bool for deciding to use cuda.
virtual void SetBinningY(double bin)
Sets the number of bins in y direction for the Hough space.
void CreateNeighborhood()
Creates the neighborhood parameters for all investigated hits.
void Init(int NBins1=450, int NBins2=450)
Initializes the Hough space.
Definition: PndHoughData.h:53
int GetNumPreselectedTrackCands()
Returns the number of preselected track candidates.
virtual void SetCombinedSkewed(TClonesArray *skewed)
void clear()
Clears all data maps.
Definition: PndHoughData.h:62
std::vector< PndApollonius::TripletSolution > CombineIdenticalSolutionsFinal(std::vector< PndApollonius::TripletSolution > &solutions, Double_t ratioOfSameHits)
PndTrack FromTripletSolutionToPndTrack(PndApollonius::TripletSolution &sol, Double_t B)
Converts a TripletSolution to a PndTrack.
void AddSkewedHits(int i)
PndApollonius::TripletSolution FromPndTrackToTripletSolution(PndTrack &track, PndHoughData *fData)
std::map< FairLink, FairHit * > GetMapFairLinktoFairHit()
Returns a specific found track candidate.
void FindHoughMaxima()
Performs a Hough transformation for all preselected tracklets. The found track parameters are stored ...
A structure that defines a solution of a triplet (an Apollonius Circle and all hits close to the circ...
PndTrack GetMergedTrack(int i)
Returns a specific merged track.
Definition: PndHoughMerge.h:66
PndHoughData * GetData()
Returns the data class of the HoughTrackFinder.
void Reset()
Definition: PndSttCA.h:76
PndTrackCand GetPreselectedTrackCand(int i)
Returns a specific preselected track candidate.
PndHoughTrackFinder(TClonesArray *tubeArray)
virtual void SetBz(double B)
Sets the z component of the magnetic field.
void AddHits(TClonesArray *hits, TString branchName)
Adds hits to the data structure of the HoughTrackFinder.
void FindTracks()
Main function of the HoughTrackFinder, which finds the tracks.
virtual void SetBinningX(double bin)
Sets the number of bins in x direction for the Hough space.
void CreateGEMNeighborhoodData()
For all GEM hits all other GEM hits in a certain distance (hier 1.5 cm) are counted and stored as nei...
void SetUseGPU(Bool_t val)
Definition: PndSttCA.h:49
virtual void UseDefaultPreselection(bool pres)