PandaRoot
PndFtsHoughTrackCand.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 
34 #ifndef PNDFTSHOUGHTRACKCAND_H
35 #define PNDFTSHOUGHTRACKCAND_H
36 
38 
39 // Root Class Headers ----------------
40 #include "PndTrackCand.h"
41 #include "PndFtsHoughTracklet.h"
42 #include "Rtypes.h" // for Double_t, Int_t, etc
43 #include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN
44 
45 // For error reporting
46 #include "TString.h"
47 #include <stdexcept>
48 
49 #include <cmath>
50 
51 class PndFtsHit;
52 class PndTrack;
53 class FairTrackParP;
54 class TVector3;
55 class TClonesArray;
56 
57 class PndFtsHoughTrackCand : public TObject {
58  public:
59  // Constructors/Destructors ---------
60  PndFtsHoughTrackCand(PndFtsHoughTrackerTask *trackerTask = nullptr);
62 
63  // operators
64  // PndFtsHoughTrackCand are the same if they contain the same hits, that means if the PndTrackCand are the same, therefore no need to implement that operator here
65 
66  // Accessors -----------------------
67  void Print();
68  // isComplete() is kTRUE iif data from all Hough transforms have been entered
69  Bool_t isComplete() const { return (fZxLineBeforeDipole.isSet() && fZxParabola.isSet() && fZxLineBehindDipole.isSet() && fZyLine.isSet()); };
70 
71  PndTrackCand getPndTrackCand(); // convert *this to a PndTrackCand, cannot be const
72  PndTrack getPndTrack(); // convert *this to a PndTrack, cannot be const // calculates first and last parameter, but uses an empty PndTrackCand which has to be set lateron using
73  // SetTrackCandRef
74 
75  FairTrackParP getTrackParPForHit(const UInt_t i); // get the track parameters (needed for conversion to PndTrack) for hit with index i, cannot be const
76 
77  inline Int_t getCharge() const; // gets charge of track candidate // TODO only charge sign is implemented
78  TVector3 getP(const Double_t zLabSys) const; // gets the momentum calculated at some z coordinate in laboratory system
79  TVector3 getPos(const Double_t zLabSys) const; // gets the position calculated at some z coordinate in laboratory system
80  Double_t getXLabSys(const Double_t zLabSys) const;
81 
82  Double_t getThetaZxRad(const Double_t zLabSys) const; // gets the angle to the z axis in the zx plane calculated at some z coordinate (in laboratory system)
83  // gets the angle to the z axis in the zy plane calculated at some z coordinate (in laboratory system)
84  Double_t getThetaZyRad(const Double_t) const { return fZyLine.getThetaRadVal(); }; // zLabSys //[R.K.03/2017] unused variable(s)
85 
86  Double_t getZLineParabola()
87  {
88  return fZCoordLineParabola;
89  }; // gets z coordinate in laboratory system where I switch from line before dipole to parabola within dipole (in zx plane)
90  Double_t getZParabolaLine()
91  {
92  return fZCoordParabolaLine;
93  }; // gets z coordinate in laboratory system where I switch from parabola within dipole to line behind dipole (in zx plane)
94 
95  // Modifiers -----------------------
96  // add results from Hough transforms
97  void SetZxLineBeforeDipole(const PndFtsHoughTracklet zxLineParabola);
98  void SetZxParabola(const PndFtsHoughTracklet zxParabola);
99  void SetZxLineBehindDipole(const PndFtsHoughTracklet zxParabolaLine);
100  void SetZyLine(const PndFtsHoughTracklet zyLine);
101 
102  private:
103  // for PandaRoot input/output
104  PndFtsHoughTrackerTask *fTrackerTask;
105 
107  void throwError(const TString s) const { throw std::runtime_error(s.Data()); };
108  void throwIfZOutOfRange(const Double_t &zLabSys) const
109  {
110  if (zLabSys <= 100)
111  throwError("zLabSys is too small, track model is not valid in that region.");
112  if (zLabSys >= 1000)
113  throwError("zLabSys is too big, track model is not valid in that region.");
114  };
115 
116  void addUniqueTrackletHits(const PndFtsHoughTracklet inTracklet);
117 
118  Double_t getQdivPzx() const { return fZxParabola.getSecondVal(); };
119 
120  inline Double_t getPYLab() const;
121  inline std::pair<Double_t, Double_t> getPZPXLabLine(const Double_t &zLabSys, const PndFtsHoughTracklet *const lineTracklet) const;
122  inline std::pair<Double_t, Double_t> getPZPXLabParabola(const Double_t &zLabSys) const;
123 
124  inline Double_t getXOrYLabForLine(const Double_t &zLabSys, const PndFtsHoughTracklet *const lineTracklet) const;
125  Double_t getXLabForParabola(const Double_t &zLabSys) const; // TODO: Check this!
126 
127  // Private Data Members ------------
128  Int_t fVerbose;
129 
130  // zx plane
131  // straight line Hough transform in zx plane (stations before dipole field)
132  PndFtsHoughTracklet fZxLineBeforeDipole;
133  // theta in zx plane
134  // vs
135  // x intercept
136 
137  // parabola Hough transform in zx plane (stations inside dipole field)
138  PndFtsHoughTracklet fZxParabola;
139  // theta in zx plane
140  // vs
141  // charge divided by momentum projected into zx plane
142 
143  // straight line Hough transform in zx plane (stations after dipole field)
144  PndFtsHoughTracklet fZxLineBehindDipole;
145  // theta in zx plane
146  // vs
147  // x intercept
148 
149  // zy plane
150  // straight line Hough transform in zy plane (all stations)
151  PndFtsHoughTracklet fZyLine;
152  // theta in zy plane
153  // vs
154  // y intercept
155 
156  // internal track candidate for storing of hits belonging to this track candidate
157  PndTrackCand fIntTrackCand;
158 
159  // at which z value the transition in the bending zx plane is done from a line (before dipole field) to a parabola (within dipole field)
160  Double_t fZCoordLineParabola;
161  // at which z value the transition in the bending zx plane is done from a parabola (within dipole field) to a line (before dipole field)
162  Double_t fZCoordParabolaLine;
163 
164  public:
166 };
167 
168 // inline functions
170 {
171  if (0 < getQdivPzx()) {
172  return 1;
173  } else {
174  return -1;
175  }
176 }
177 
178 Double_t PndFtsHoughTrackCand::getXOrYLabForLine(const Double_t &zLabSys, const PndFtsHoughTracklet *const lineTracklet) const
179 {
180  // calculate x or y in lab sys for a given z position in lab sys for which the line assumption holds
181  // theta in radian in zx plane given at z = zRefLabSys
182  const Double_t thetaRad = lineTracklet->getThetaRadVal();
183  const Double_t intercept = lineTracklet->getSecondVal();
184  const Double_t zRefLabSys = lineTracklet->getZRefLabSys();
185  const Double_t zshifted = zLabSys - zRefLabSys;
186 
187  Double_t xOrYLabSys = tan(thetaRad) * zshifted + intercept;
188 
189  return xOrYLabSys;
190 }
191 
192 std::pair<Double_t, Double_t> PndFtsHoughTrackCand::getPZPXLabParabola(const Double_t &zLabSys) const
193 {
194 
195  const Double_t currentThetaRad = getThetaZxRad(zLabSys);
196 
197  const Double_t qDivPzx = getQdivPzx(); // Q/pzx
198  const Double_t pZx = getCharge() / qDivPzx;
199 
200  const Double_t pZLabSys = pZx * cos(currentThetaRad);
201  const Double_t pXLabSys = pZx * sin(currentThetaRad);
202  std::pair<Double_t, Double_t> pZPXLabSys(pZLabSys, pXLabSys);
203 
204  return pZPXLabSys;
205 }
206 
207 std::pair<Double_t, Double_t> PndFtsHoughTrackCand::getPZPXLabLine(const Double_t &, const PndFtsHoughTracklet *const lineTracklet) const
208 { // zLabSys //[R.K.03/2017] unused variable(s)
209  // theta in radian in zx plane given at z = zRefLabSys
210  const Double_t thetaRad = lineTracklet->getThetaRadVal();
211  const Double_t qDivPzx = fZxParabola.getSecondVal(); // Q/pzx
212  const Double_t pZx = getCharge() / qDivPzx;
213 
214  const Double_t pZLabSys = pZx * cos(thetaRad);
215  const Double_t pXLabSys = pZx * sin(thetaRad);
216  std::pair<Double_t, Double_t> pZPXLabSys(pZLabSys, pXLabSys);
217 
218  return pZPXLabSys;
219 }
220 
221 Double_t PndFtsHoughTrackCand::getPYLab() const
222 {
223  // theta in radian in zy plane given at z where first zx line meets the parabola
224  const Double_t zRefLabSys = fZxParabola.getZRefLabSys();
225  const Double_t thetaZyRad = fZyLine.getThetaRadVal();
226  std::pair<Double_t, Double_t> pZPXLabSys = getPZPXLabLine(zRefLabSys, &fZxLineBeforeDipole);
227  const Double_t pZLabSys = pZPXLabSys.first;
228  Double_t pYLabSys = tan(thetaZyRad) * pZLabSys;
229  return pYLabSys;
230 }
231 
232 #endif
PndTrackCand getPndTrackCand()
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:131
void SetZxParabola(const PndFtsHoughTracklet zxParabola)
FairTrackParP getTrackParPForHit(const UInt_t i)
void SetZyLine(const PndFtsHoughTracklet zyLine)
ClassDef(PndFtsHoughTrackCand, 1)
Interface between PandaRoot (data input and output) and PndFtsHoughTrackFinder (implementation of PR ...
Double_t getZRefLabSys() const
TVector3 getP(const Double_t zLabSys) const
friend F32vec4 sin(const F32vec4 &a)
Definition: P4_F32vec4.h:130
void SetZxLineBeforeDipole(const PndFtsHoughTracklet zxLineParabola)
Double_t getThetaZyRad(const Double_t) const
PndFtsHoughTrackCand(PndFtsHoughTrackerTask *trackerTask=nullptr)
Set pointer to tracker task (super important as it provides an I/O interface to PandaRoot) ...
unsigned int i
Definition: P4_F32vec4.h:33
Double_t getThetaZxRad(const Double_t zLabSys) const
Class for saving the result of one Hough transform for FTS PR.
TVector3 getPos(const Double_t zLabSys) const
Double_t getThetaRadVal() const
Double_t getXLabSys(const Double_t zLabSys) const
void SetZxLineBehindDipole(const PndFtsHoughTracklet zxParabolaLine)
Class for saving a FTS track cand. for Hough transform based FTS PR.
Double_t getSecondVal() const
PndTrack getPndTrack()