PandaRoot
PndHoughTrackFinder.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
14 // PndHoughTrackFinder
15 // Finds Track for one event
17 
28 #ifndef PndHoughTrackFinder_H_
29 #define PndHoughTrackFinder_H_
30 
31 #include <vector>
32 
33 #include "PndSttCA.h"
34 
35 #include "PndHoughData.h"
36 #include "PndHoughUtilities.h"
37 #include "PndHoughTransformation.h"
38 #include "PndHoughSegment.h"
40 #include "PndHoughPreprocessing.h"
41 #include "PndHoughMerge.h"
42 #include "PndApolloniusTriplet.h"
43 
45  public:
47 
48  PndHoughTrackFinder(TClonesArray *tubeArray) : fNbins1(450), fNbins2(450), fNBinsSeg(90.), fBz(2.), fCutMergeByHoughSpace(5.), fWithGPU(kFALSE), fWithGhostReduction(kTRUE)
49  {
50  // Generate TrackFinderData-Object
51  fData = new PndHoughData(tubeArray);
52  fCATrackFinder = new PndSttCA(tubeArray);
53  ioman = FairRootManager::Instance();
54  };
55 
58  {
59  delete fData;
60  delete fCATrackFinder;
61 
62  delete fPndHoughTransformation;
63  delete fPndHoughPreprocessing;
64  delete fPndHoughMerge;
65  delete fPndHoughSegment;
66  delete fPndHoughUtilities;
67  delete fPndHoughTrackCorrection;
68  }
69 
71  virtual void SetBinningX(double bin) { fNbins1 = bin; };
73  virtual void SetBinningY(double bin) { fNbins2 = bin; };
75  virtual void SetNBinsSeg(Int_t n) { fNBinsSeg = n; };
77  virtual void SetBz(double B) { fBz = B; };
79  virtual void SetCutMergeByHoughSpace(float cut){ fCutMergeByHoughSpace = cut; }
81  virtual void SetWithGPU(bool cuda) { fWithGPU = cuda; }
83  virtual void SetWithGhostReduction(bool ghostred) { fWithGhostReduction = ghostred; }
84  virtual void SetPreselectedTrackCands(std::vector<PndTrackCand> cands) { fPreselectedTrackCands = cands; };
85  virtual void UseDefaultPreselection(bool pres) { fUseDefaultPreselection = pres; };
86  virtual void SetCombinedSkewed(TClonesArray *skewed) { fCombinedSkewed = skewed; };
88  void Init()
89  {
90  fData->Init(fNbins1, fNbins2);
91  fCATrackFinder->SetUseGPU(fWithGPU);
92  }
93 
95  void Reset()
96  {
97  fData->clear();
98 
99  fCATrackFinder->SetUseGPU(fWithGPU);
100  fCATrackFinder->Reset();
101 
102  fPreselectedTrackCands.clear();
103  fPreselectedTrackCircles.clear();
104  }
105 
107  void AddHits(TClonesArray *hits, TString branchName);
108 
111  {
112  fData->CreateSTTNeighborhoodData();
113  fData->CreateGEMNeighborhoodData();
114  }
116  void FindTracks();
117 
119  void Preselection();
120 
122  void FindHoughMaxima();
123  TVector2 calcPhiRange(PndTrackCand &trackCand);
124  bool IsInPhiRange(FairHit *hit, double phiLow, double phiHigh);
125  void AddSkewedHits(int i);
126  void AddOtherDetectorHits(int i, TString type);
128  std::vector<PndApollonius::TripletSolution> CombineIdenticalSolutionsFinal(std::vector<PndApollonius::TripletSolution> &solutions, Double_t ratioOfSameHits);
136 
137  double CalcRatioSameHits(PndApollonius::TripletSolution &sol, std::vector<PndApollonius::TripletSolution> &AlreadyFoundSolutions);
138 
140  PndTrackCand GetPreselectedTrackCand(int i) { return fPreselectedTrackCands[i]; };
141 
143  int GetNumPreselectedTrackCands() { return fPreselectedTrackCands.size(); };
144 
146  TVector3 GetPreselectedTrackCircles(int i) { return fPreselectedTrackCircles[i]; };
147 
149  int GetNumPreselectedTrackCircles() { return fPreselectedTrackCircles.size(); };
150 
152  PndTrack GetMergedTrack(int i) { return fPndHoughMerge->GetMergedTrack(i); };
153 
155  int GetNumMergedTracks() { return fPndHoughMerge->GetNumMergedTracks(); };
156 
158  // PndTrackCand GetMergedTrackCand(int i) { return fPndHoughMerge->GetMergedTrackCand(i); };
159 
161  // int GetNumMergedTrackCands() { return fPndHoughMerge->GetNumMergedTrackCands(); };
162 
164  std::map<FairLink, FairHit *> GetMapFairLinktoFairHit() { return fData->GetMapFairLinktoFairHit(); };
165 
167  PndHoughData *GetData() { return fData; };
168 
169  private:
170  FairRootManager *ioman = nullptr;
171 
172  PndSttCA *fCATrackFinder = nullptr;
173 
174  PndHoughData *fData = nullptr;
175  PndHoughTransformation *fPndHoughTransformation = nullptr;
176  PndHoughPreprocessing *fPndHoughPreprocessing = nullptr;
177  PndHoughMerge *fPndHoughMerge = nullptr;
178  PndHoughSegment *fPndHoughSegment = nullptr;
179  PndHoughUtilities *fPndHoughUtilities = nullptr;
180  PndHoughTrackCorrection *fPndHoughTrackCorrection = nullptr;
181  TClonesArray *fCombinedSkewed = nullptr;
182  std::vector<std::vector<TVector3>> fHoughSpacesToTracks;
183  std::vector<PndTrackCand> fHoughSpacesToTrackCands;
184  std::vector<PndTrackCand> fHoughSpacesToTrackCandTots;
185 
186  std::vector<FairLink> fFoundHits;
187 
188  std::vector<PndTrackCand> fPreselectedTrackCands;
189  std::vector<TVector3> fPreselectedTrackCircles;
190  std::vector<PndTrack> fApolloniusMergedTracks;
191  std::vector<PndTrackCand> fApolloniusMergedTrackCands;
192 
193  Double_t fBz;
194  float fCutMergeByHoughSpace;
195  Int_t fNbins1;
196  Int_t fNbins2;
197  Int_t fNBinsSeg;
198  bool fWithGPU;
199  bool fWithGhostReduction;
200  bool fUseDefaultPreselection = kTRUE;
201  double fDistanceThresholdSTTCombinedSkewed = 1.;
202  double fDistanceThresholdSTT = 0.3;
203  double fDistanceThresholdMVD = 0.5;
204  double fDistanceThresholdGEM = 1.;
205  std::map<FairLink, FairHit *> fMapFairLinktoFairHit;
206  std::map<FairLink, double> fMapFairLinktoIsochrone;
207  ClassDef(PndHoughTrackFinder, 1);
208 };
209 
210 #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:82
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:104
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:33
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:65
int GetNumPreselectedTrackCands()
Returns the number of preselected track candidates.
virtual void SetCombinedSkewed(TClonesArray *skewed)
void clear()
Clears all data maps.
Definition: PndHoughData.h:74
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:78
PndHoughData * GetData()
Returns the data class of the HoughTrackFinder.
void Reset()
Definition: PndSttCA.h:88
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:61
virtual void UseDefaultPreselection(bool pres)