9#include <top/reconstruction_cpp/InverseRaytracer.h>
10#include <top/reconstruction_cpp/func.h>
11#include <framework/logging/Logger.h>
24 cosThc(cosTheta), sinThc(
sqrt(1 - cosTheta * cosTheta))
29 cosFic(cfi), sinFic(sfi)
36 double b = cer.
sinThc * sinFic;
44 totRefl = (std::abs(kx) < cosTotal or std::abs(xD) < A / 2) and (std::abs(ky) < cosTotal or std::abs(yB) < B / 2);
49 bool beforeMirror = (std::abs(kx) < cosTotal or Nxm == 0) and (std::abs(ky) < cosTotal or Nym == 0);
50 bool afterMirror = (std::abs(Kx) < cosTotal or std::abs(xD) < A / 2) and (std::abs(Ky) < cosTotal or std::abs(yB) < B / 2);
51 totRefl = beforeMirror and afterMirror;
56 return (len > 0 and len <
s_maxLen and totRefl);
71 const auto& emiPoint = assumedEmission.
position;
80 double dx = xD - emiPoint.X();
81 double dz = zD - emiPoint.Z();
83 double dxdz = dx / dz;
86 for (
int i = 0; i < 2; i++) {
91 sol.len = dz / sol.kz;
92 double dydz = sol.ky / sol.kz;
93 sol.yD = emiPoint.Y() + dydz * dz;
94 sol.yB = emiPoint.Y() + dydz * (
m_prism.
zR - emiPoint.Z());
99 if (not sol.getStatus())
m_ok[i] =
false;
112 const auto& emiPoint = assumedEmission.
position;
129 double zE = emiPoint.Z();
134 double zE = emiPoint.Z();
140 bool ok =
solve(dxdz, cer, trk);
146 for (
int i = 0; i < 2; i++) {
153 double len = (zM - emiPoint.Z()) / sol.kz;
159 int Nym = lround((emiPoint.Y() + len * sol.ky) / B);
164 double s = 2 * (kx * normX + kz * normZ);
168 len = (zD - zM) / kz;
181 sol.setTotalReflStatus(A, B,
m_cosTotal, kx, ky);
183 if (not sol.getStatus())
m_ok[i] =
false;
196 const auto& emiPoint = assumedEmission.
position;
210 double dz = zM - emiPoint.Z();
211 double dxdz = dx / dz;
213 bool ok =
solve(dxdz, cer, trk);
220 for (
int i = 0; i < 2; i++) {
225 double len = (zM - emiPoint.Z()) / sol.kz;
231 int Nym = lround((emiPoint.Y() + len * sol.ky) / B);
236 double s = 2 * (kx * normX + kz * normZ);
240 len = (zD - zM) / kz;
247 sol.xD = xM + len * kx;
251 m_ok[i] = sol.getStatus();
261 for (
int i = 0; i < 2; i++) {
263 if (
m_ok[i] and solutions.back().Nym != solutions.front().Nym)
return true;
274 double B = b * b + d * d;
275 if (B == 0)
return false;
279 if (std::abs(cfic) > 1)
return false;
280 double sfic =
sqrt(1 - cfic * cfic);
284 double D = B - a * a;
285 if (D < 0)
return false;
288 double cfic = (ab + D) / B;
302 double z =
sqrt(1 - x * x);
303 double kx = (x - xd);
304 double kz = (z - zd);
305 double s = 2 * (kx * x + kz * z);
309 return x + (ze - z) * kx / kz - xe;
314 double xmMin,
double xmMax,
315 double& xM,
double& zM,
double& dxdz)
const
328 if (y1 * y2 > 0)
return false;
330 for (
int i = 0; i < 20; i++) {
331 double x = (x1 + x2) / 2;
340 double x = (x1 + x2) / 2;
341 double z =
sqrt(1 - x * x);
345 double kx = (x - xd);
346 double kz = (z - zd);
347 double s = 2 * (kx * x + kz * z);
361 double cosDFic = cos(DFic);
362 double sinDFic = sin(DFic);
363 double cosFic = sol.
cosFic * cosDFic - sol.
sinFic * sinDFic;
364 double sinFic = sol.
sinFic * cosDFic + sol.
cosFic * sinDFic;
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.
bool solve(double dxdz, const CerenkovAngle &cer, const TOPTrack::TrackAngles &trk) const
Solve inverse ray-tracing for unknown azimuthal Cerenkov angle.
@ 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
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.
std::vector< Solution > m_solutions[2]
storage for the two solutions
void clear() const
Clear the solutions to prepare for the new round.
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.
Mirror m_mirror
spherical mirror geometry data
Prism m_prism
prism geometry data
std::vector< BarSegment > m_bars
geometry data of bar segments
double sqrt(double a)
sqrt for double
double unfold(double x, int nx, double A)
unfold a coordinate.
Abstract base class for different kinds of events.
Sine and cosine of Cerenkov angle.
double cosThc
cosine of Cerenkov angle
double sinThc
sine of Cerenkov angle
CerenkovAngle()
Default constructor.
Solution of inverse ray-tracing.
void setDirection(const CerenkovAngle &cer, const TOPTrack::TrackAngles &trk)
Sets photon direction.
bool getStatus() const
Returns status.
Solution(double cfi, double sfi)
constructor
double cosFic
cosine of azimuthal Cerenkov angle
double ky
photon direction in y at emission
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 yc
center of curvature in y
double xc
center of curvature in x
double zc
center of curvature in z
double zR
maximal z, i.e position of prism-bar joint
double zD
detector (photo-cathode) position
assumed photon emission point in local frame
ROOT::Math::XYZPoint position
position
TrackAngles trackAngles
sine and cosine of track polar and azimuthal angles
Sine and cosine of track polar and azimuthal angles at assumed photon emission.
double sinFi
sine of azimuthal angle
double cosFi
cosine of azimuthal angle
double cosTh
cosine of polar angle
double sinTh
sine of polar angle