PandaRoot
PndFtsHoughTrackFinder.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 
46 #ifndef PndFtsHoughTrackFinder_H
47 #define PndFtsHoughTrackFinder_H
48 
50 
51 //#include "TClonesArray.h"
52 #include "Rtypes.h" // for Double_t, Int_t, etc
53 #include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN
54 
55 #include <cmath>
56 #include "TMath.h"
57 #include <math.h>
58 #include <algorithm>
59 #include <set>
60 #include <vector>
61 #include <map>
62 #include <fstream>
63 #include <iostream>
64 
65 #include "PndFtsHit.h"
66 #include "PndFtsHoughTrackerTask.h"
67 #include "PndFtsHoughSpace.h"
68 #include "PndFtsHoughTracklet.h"
69 #include "PndFtsHoughTrackCand.h"
70 #include "PndTrackCand.h"
71 #include "PndTrack.h"
72 
73 // For error throwing
74 #include "TString.h"
75 #include <stdexcept>
76 
78  public:
80  virtual ~PndFtsHoughTrackFinder();
81 
82  // use this for parameter optimization
84 
85  virtual void FindTracks();
86 
87  // Output
88  Int_t NTracks() const { return fHoughTrackCandsComplete.size(); };
89 
95  PndTrack GetPndTrack(int i) { return fHoughTrackCandsComplete[i].getPndTrack(); };
102  PndTrackCand GetPndTrackCand(int i) { return fHoughTrackCandsComplete[i].getPndTrackCand(); };
110 
111  // Output event statistics
114  Int_t getNParabolasFound() const { return fNParabolasFound; };
115  Int_t getNTracksFound() const { return fNTracksFound; };
116 
117  protected:
121 
123  void throwError(const TString s) const { throw std::runtime_error(s.Data()); };
124 
125  // Int_t fFtsBranchId; // needed for saving and accessing hits
126  // TClonesArray *fFtsHitArray; ///< @brief Input array of all FTS hits.
127 
128  // for Hough
130 
131  //-----------
132  std::vector<PndFtsHoughTrackCand> fHoughTrackCandsComplete;
133  std::vector<PndFtsHoughTrackCand> fHoughTrackCandsZxPlaneOnly;
134  // std::vector<PndTrackCand> fTrackCand; // resulting track candidates, also used for returning PndTracks
135 
137 
140  const UInt_t fMinPeakHeightZxParabola;
142  const UInt_t fMinPeakHeightZxLineBehindDipole;
144  const UInt_t fMinPeakHeightZyLine;
146 
147  // event statistics
152 
153  // takes the heighest peak (according to peak finder)
154  // of all peaks that share > maxSameHits
162  Bool_t FilterTrackletsBasedOnSharedHits(UInt_t maxAcceptableSharedHits, std::vector<PndFtsHoughTracklet> &tracklets);
163  // helper functions for tracking algorithm
164  std::vector<PndFtsHoughTracklet> FindLinesBehindDipoleZx();
165  std::vector<PndFtsHoughTracklet> FindLinesBeforeDipoleZx();
166  void FindMatchingParabolaToLineBeforeDipoleZxAndAddLineBehindDipole(const std::vector<PndFtsHoughTracklet> &trackletsLineBeforeDipole,
167  const std::vector<PndFtsHoughTracklet> &trackletsLineBehindDipole);
168  // kTRUE iif angles of parabola and of line behind dipole match at z coordinate where I switch from parabola to line (in zx plane)
169  inline Bool_t LineBehindDipoleMatchesToLinePlusParabola(const PndFtsHoughTrackCand &lineParabola, const PndFtsHoughTracklet &lineBehindDipole) const;
171 
172  private:
173  ClassDef(PndFtsHoughTrackFinder, 1);
174 };
175 
176 // inline
178 {
179 
180  // the angles should be compared at the z coordinate where I switch from parabola to line behind dipole
181  Double_t zParabolaLine = lineBehindDipole.getZRefLabSys();
182  return fabs(lineParabola.getThetaZyRad(zParabolaLine) - lineBehindDipole.getThetaRadVal()) < fThetaRadLineBehindDipoleMatchesToParabolaIfBelow;
183 }
184 
185 #endif /*PndFtsHoughTrackFinder_H*/
std::vector< PndFtsHoughTracklet > FindLinesBeforeDipoleZx()
const UInt_t fMinPeakHeightZxLineBehindDipole
Minimum required height for peaks in Hough spaces.
void FindZyLineMatchingToLineParabolaLineInZx()
Int_t getNLinesBehindDipoleFound() const
Interface between PandaRoot (data input and output) and PndFtsHoughTrackFinder (implementation of PR ...
Double_t getZRefLabSys() const
PndFtsHoughTrackFinderParams fParams
Double_t getThetaZyRad(const Double_t) const
void throwError(const TString s) const
For error reporting.
Parameters for Hough space track finder. Created: 09.02.2015.
PndFtsHoughTrackerTask * fTrackerTask
Task which handles PandaRoot input/output and provides settings for FTS PR. Has to be set using the c...
Bool_t LineBehindDipoleMatchesToLinePlusParabola(const PndFtsHoughTrackCand &lineParabola, const PndFtsHoughTracklet &lineBehindDipole) const
Bool_t FilterTrackletsBasedOnSharedHits(UInt_t maxAcceptableSharedHits, std::vector< PndFtsHoughTracklet > &tracklets)
Filters a vector of tracklets based on the number of shared hits.
const UInt_t fMinPeakHeightZyLine
zy line
unsigned int i
Definition: P4_F32vec4.h:33
virtual void FindTracks()
Performs the track finding.
PndTrack GetPndTrack(int i)
Returns the number of found tracks.
Class for saving the result of one Hough transform for FTS PR.
PndTrackCand GetPndTrackCand(int i)
Returns the track cand. with index i.
const UInt_t fMinPeakHeightZxParabola
Minimum required height for peaks in Hough spaces.
std::vector< PndFtsHoughTrackCand > fHoughTrackCandsZxPlaneOnly
For internal storing of track cands. (zx plane track model only)
Double_t getThetaRadVal() const
Int_t getNLinesBeforeDipoleFound() const
Implementation of the Hough transform based FTS PR. Creates Hough spaces, finds peaks (=tracklets) an...
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:58
void OverwriteTrackFinderParams(PndFtsHoughTrackFinderParams newParams)
static const Double_t fThetaRadLineBehindDipoleMatchesToParabolaIfBelow
Minimum required height for peaks in Hough spaces.
const UInt_t fMinPeakHeightZxLineBeforeDipole
Minimum required height for peaks in Hough spaces.
PndFtsHoughTrackFinder(PndFtsHoughTrackerTask *trackerTask)
Set pointer to tracker task (super important as it provides an I/O interface to PandaRoot) ...
virtual ~PndFtsHoughTrackFinder()
Destructor.
std::vector< PndFtsHoughTracklet > FindLinesBehindDipoleZx()
Class for saving a FTS track cand. for Hough transform based FTS PR.
void FindMatchingParabolaToLineBeforeDipoleZxAndAddLineBehindDipole(const std::vector< PndFtsHoughTracklet > &trackletsLineBeforeDipole, const std::vector< PndFtsHoughTracklet > &trackletsLineBehindDipole)
PndFtsHoughTrackCand GetHoughTrack(int i) const
Returns the track cand. with index i.
std::vector< PndFtsHoughTrackCand > fHoughTrackCandsComplete
For internal storing of complete track cands.