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