Belle II Software  release-08-01-10
InverseRaytracer.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 #include <top/reconstruction_cpp/RaytracerBase.h>
12 #include <top/reconstruction_cpp/PhotonState.h>
13 #include <top/reconstruction_cpp/TOPTrack.h>
14 #include <vector>
15 #include <Math/Point3D.h>
16 #include <cmath>
17 
18 namespace Belle2 {
23  namespace TOP {
24 
29 
30  public:
31 
35  enum ErrorCodes {
39  };
40 
41 
45  struct CerenkovAngle {
46  double cosThc = 0;
47  double sinThc = 0;
53  {}
54 
59  explicit CerenkovAngle(double cosTheta);
60  };
61 
62 
66  struct Solution {
67  double cosFic = 0;
68  double sinFic = 0;
69  double kx = 0;
70  double ky = 0;
71  double kz = 0;
72  double len = 0;
73  double xD = 0;
74  double zD = 0;
75  double yD = 0;
76  double yB = 0;
77  int Nxm = 0;
78  int Nym = 0;
79  double step = 0;
80  bool totRefl = true;
87  Solution(double cfi, double sfi);
88 
94  void setDirection(const CerenkovAngle& cer, const TOPTrack::TrackAngles& trk);
95 
102  void setTotalReflStatus(double A, double B, double cosTotal);
103 
112  void setTotalReflStatus(double A, double B, double cosTotal, double Kx, double Ky);
113 
118  bool getStatus() const;
119 
124  double getFic() const {return atan2(sinFic, cosFic);}
125  };
126 
127 
133  InverseRaytracer(int moduleID, double cosTotal): RaytracerBase(moduleID, c_Unified, c_SemiLinear),
134  m_cosTotal(cosTotal)
135  {}
136 
141  static void setMaxPropagationLen(double maxLen) {s_maxLen = maxLen;}
142 
146  void clear() const;
147 
157  int solveDirect(double xD, double zD, const TOPTrack::AssumedEmission& assumedEmission,
158  const CerenkovAngle& cer, double step = 0) const;
159 
172  int solveReflected(double xD, double zD, int Nxm, double xmMin, double xmMax,
173  const TOPTrack::AssumedEmission& assumedEmission,
174  const CerenkovAngle& cer, double step = 0) const;
175 
184  int solveForReflectionPoint(double xM, int Nxm, const TOPTrack::AssumedEmission& assumedEmission,
185  const CerenkovAngle& cer) const;
186 
191  double getCosTotal() const {return m_cosTotal;}
192 
198  std::vector<Solution>& getSolutions(unsigned i) const {return m_solutions[i % 2];}
199 
204  bool getStatus() const {return (m_ok[0] or m_ok[1]);}
205 
211  bool getStatus(unsigned i) const {return m_ok[i % 2];}
212 
217  bool isNymDifferent() const;
218 
225  PhotonState getReconstructedPhoton(const Solution& sol, double DFic = 0) const;
226 
227  private:
228 
237  bool solve(double dxdz, const CerenkovAngle& cer, const TOPTrack::TrackAngles& trk) const;
238 
252  bool findReflectionPoint(double xE, double zE, double xD, double zD, double xmMin, double xmMax,
253  double& xM, double& zM, double& dxdz) const;
254 
266  double getDeltaXE(double x, double xe, double ze, double xd, double zd) const;
267 
268  double m_cosTotal = 0;
269  mutable std::vector<Solution> m_solutions[2];
270  mutable bool m_ok[2] = {false, false};
271  mutable ROOT::Math::XYZPoint m_emiPoint;
275  static double s_maxLen;
277  };
278 
279  } // namespace TOP
281 } // namespace Belle2
282 
Utility for solving inverse ray-tracing problem.
double m_cosTotal
cosine of total reflection angle
int solveReflected(double xD, double zD, int Nxm, double xmMin, double xmMax, const TOPTrack::AssumedEmission &assumedEmission, const CerenkovAngle &cer, double step=0) const
Solve inverse ray-tracing for reflected photon.
PhotonState getReconstructedPhoton(const Solution &sol, double DFic=0) const
Returns reconstructed photon at emission for a given solution of inverse raytracing.
int solveForReflectionPoint(double xM, int Nxm, const TOPTrack::AssumedEmission &assumedEmission, const CerenkovAngle &cer) const
Solve inverse ray-tracing for a given reflection point on the mirror.
InverseRaytracer(int moduleID, double cosTotal)
Class constructor.
bool getStatus() const
Returns status.
bool solve(double dxdz, const CerenkovAngle &cer, const TOPTrack::TrackAngles &trk) const
Solve inverse ray-tracing for unknown azimuthal Cerenkov angle.
ErrorCodes
Error codes returned by solveDirect or solveReflected.
@ c_NoEquationSolution
no solution of equation
@ c_NoReflectionPoint
position on the mirror not found
@ c_NoPhysicsSolution
no physics solution
double getDeltaXE(double x, double xe, double ze, double xd, double zd) const
Returns the difference between input xe and the reflected position at given x.
bool findReflectionPoint(double xE, double zE, double xD, double zD, double xmMin, double xmMax, double &xM, double &zM, double &dxdz) const
Finds reflection point on the mirror using semi-linear optics approximation.
bool isNymDifferent() const
Checks if Nym differs between solutions front and back in at least one of the vectors.
ROOT::Math::XYZPoint m_emiPoint
temporary storage of emission point
static double s_maxLen
maximal allowed propagation length
double getCosTotal() const
Returns cosine of total reflection angle.
CerenkovAngle m_cer
temporary storage of Cerenkov angle
int solveDirect(double xD, double zD, const TOPTrack::AssumedEmission &assumedEmission, const CerenkovAngle &cer, double step=0) const
Solve inverse ray-tracing for direct photon.
static void setMaxPropagationLen(double maxLen)
Sets maximal allowed propagation length.
std::vector< Solution > m_solutions[2]
storage for the two solutions
std::vector< Solution > & getSolutions(unsigned i) const
Returns the solutions of inverse ray-tracing.
void clear() const
Clear the solutions to prepare for the new round.
bool getStatus(unsigned i) const
Returns status.
bool m_ok[2]
status of solutions
TOPTrack::TrackAngles m_trk
temporary storage of track polar and azimuthal angles
State of the Cerenkov photon in the quartz optics.
Definition: PhotonState.h:27
Base class with geometry data.
Definition: RaytracerBase.h:27
@ c_Unified
single bar with average width and thickness
Definition: RaytracerBase.h:34
@ c_SemiLinear
semi-linear approximation
Definition: RaytracerBase.h:42
Abstract base class for different kinds of events.
Sine and cosine of Cerenkov angle.
double cosThc
cosine of Cerenkov angle
Solution of inverse ray-tracing.
int Nxm
number of reflections in x before mirror
double yB
unfolded coordinate y of photon at Bar exit plane
void setDirection(const CerenkovAngle &cer, const TOPTrack::TrackAngles &trk)
Sets photon direction.
bool getStatus() const
Returns status.
double xD
unfolded coordinate x of photon at Detector plane
double step
step for numerical derivative calculation
Solution(double cfi, double sfi)
constructor
double cosFic
cosine of azimuthal Cerenkov angle
double getFic() const
Returns Cerenkov azimuthal angle.
int Nym
number of reflections in y before mirror
double ky
photon direction in y at emission
bool totRefl
total reflection status
void setTotalReflStatus(double A, double B, double cosTotal)
Sets total reflection status for direct photon.
double sinFic
sine of azimuthal Cerenkov angle
double kz
photon direction in z at emission
double kx
photon direction in x at emission
double len
propagation length to detector plane
double yD
unfolded coordinate y of photon at Detector plane
double zD
coordinate z of Detector plane
assumed photon emission point in local frame
Definition: TOPTrack.h:74
Sine and cosine of track polar and azimuthal angles at assumed photon emission.
Definition: TOPTrack.h:46