9#include <top/reconstruction_cpp/PhotonState.h>
10#include <top/reconstruction_cpp/func.h>
11#include <framework/logging/Logger.h>
27 m_x(position.X()), m_y(position.Y()), m_z(position.Z()),
28 m_kx(direction.X()), m_ky(direction.Y()), m_kz(direction.Z()),
34 m_x(position.X()), m_y(position.Y()), m_z(position.Z()),
35 m_kx(kx), m_ky(ky), m_kz(kz),
40 double thc,
double fic):
41 m_x(position.X()), m_y(position.Y()), m_z(position.Z()),
44 ROOT::Math::XYZVector dir(cos(fic) * sin(thc), sin(fic) * sin(thc), cos(thc));
53 if (std::abs(
m_x) > bar.
A / 2)
return false;
54 if (std::abs(
m_y) > bar.
B / 2)
return false;
55 if (m_z < bar.zL or m_z > bar.
zR)
return false;
62 if (std::abs(
m_x) > bar.
A / 2)
return false;
63 if (std::abs(
m_y) > bar.
B / 2)
return false;
64 if (
m_z < bar.
zL)
return false;
65 double Rsq = pow(
m_x - mirror.
xc, 2) + pow(
m_y - mirror.
yc, 2) + pow(
m_z - mirror.
zc, 2);
66 if (Rsq > pow(mirror.
R, 2))
return false;
73 if (std::abs(
m_x) > prism.
A / 2)
return false;
74 if (m_z < prism.zL or m_z > prism.
zR)
return false;
77 if (
m_y < y)
return false;
99 if (len < 0 or len >
s_maxLen)
return;
122 if (
m_kz < 0)
return;
125 if (
m_z < mirror.
zb) {
131 int nx = lround(xm / bar.
A);
138 double z =
m_z - mirror.
zc;
140 double rr = x * x + z * z;
141 double D = rdir * rdir + (mirror.
R * mirror.
R - rr) * ss;
144 len = (D - rdir) / ss;
145 if (len < 0 or len >
s_maxLen)
return;
147 int nxx = lround(xmm / bar.
A);
148 if (nxx == nx)
break;
151 if (std::abs(xmm - xm) < 0.001)
break;
152 B2DEBUG(20,
"TOP::PhotonState::propagateSemiLinear: not converging");
166 double normX = (
m_x - mirror.
xc) / mirror.
R;
167 double normZ = (
m_z - mirror.
zc) / mirror.
R;
168 double s = 2 * (
m_kx * normX +
m_kz * normZ);
188 if (
m_kz < 0)
return;
191 if (
m_z < mirror.
zb) {
197 int nx = lround(xm / bar.
A);
199 int ny = lround(ym / bar.
B);
206 double z =
m_z - mirror.
zc;
208 double rr = x * x + y * y + z * z;
209 double D = rdir * rdir + (mirror.
R * mirror.
R - rr);
213 if (len < 0 or len >
s_maxLen)
return;
215 int nxx = lround(xmm / bar.
A);
217 int nyy = lround(ymm / bar.
B);
218 if (nxx == nx and nyy == ny)
break;
221 if (std::abs(xmm - xm) < 0.001 and std::abs(ymm - ym) < 0.001)
break;
222 B2DEBUG(20,
"TOP::PhotonState::propagateExact: not converging");
235 double normX = (
m_x - mirror.
xc) / mirror.
R;
236 double normY = (
m_y - mirror.
yc) / mirror.
R;
237 double normZ = (
m_z - mirror.
zc) / mirror.
R;
238 double s = 2 * (
m_kx * normX +
m_ky * normY +
m_kz * normZ);
276 unsigned k = prism.
k0;
279 double s =
m_ky * win.sz -
m_kz * win.sy;
285 double len = ((win.y0 -
m_y) * win.sz - (win.z0 -
m_z) * win.sy) / s;
288 double yu =
m_yD - win.y0;
289 double zu =
m_zD - win.z0;
290 double y = yu * win.sy + zu * win.sz;
291 if (y >= prism.
yDown and y <= prism.
yUp) {
292 if (len < 0 or len >
s_maxLen)
return;
293 double ky =
m_ky * win.sy +
m_kz * win.sz;
294 double kz =
m_kz * win.sy -
m_ky * win.sz;
304 m_cosy = std::max(
m_cosy, std::abs(ky_in * win.nsy[ii] + kz_in * win.nsz[ii]));
308 B2DEBUG(20,
"TOP::PhotonState::propagate: unfolded prism window not found"
320 if (len < 0 or len >
s_maxLen)
return;
double m_y0
origin in y for unfolding
EType m_type
quartz segment type at last propagation step
double m_cosy
maximal cosine of impact angle to surface in y
int m_nx
signed number of reflections in x at last propagation step
double m_zD
unfolded prism detection position in z
void propagate(const RaytracerBase::BarSegment &bar)
Propagate photon to the exit of bar segment.
static double s_maxLen
maximal allowed propagation length
PhotonState()
Default constructor.
double m_ky
direction in y
double m_A
width of the quartz segment (dimension in x) for unfolding
double m_cosx
maximal cosine of impact angle to surface in x
int m_ny
signed number of reflections in y at last propagation step
double m_kx
direction in x
double m_yD
unfolded prism detection position in y
double m_B
thickness of the quartz segment (dimension in y) for unfolding
bool m_status
propagation status
void propagateSemiLinear(const RaytracerBase::BarSegment &bar, const RaytracerBase::Mirror &mirror)
Propagate photon to the mirror and reflect it using semi-linear mirror optics.
@ c_BarSegment
bar segment
@ c_MirrorSegment
mirror segment
double m_propLen
propagation length since initial position
void propagateExact(const RaytracerBase::BarSegment &bar, const RaytracerBase::Mirror &mirror)
Propagate photon to the mirror and reflect it using exact mirror optics.
bool isInside(const RaytracerBase::BarSegment &bar) const
Checks if photon is inside the bar segment (including surface).
double m_kz
direction in z
Class to store variables with their name which were sent to the logging service.
double sqrt(double a)
sqrt for double
double unfold(double x, int nx, double A)
unfold a coordinate.
void rotateUz(ROOT::Math::XYZVector &vec, const ROOT::Math::XYZVector &z_Axis)
Replacement for a function TVector3::RotateUz which is not implemented in GenVector classes.
void fold(double xu, double A, double &x, double &kx, int &nx)
fold a coordinate (inverse of unfold).
Abstract base class for different kinds of events.
bar segment data in module local frame.
double A
width (dimension in x)
double B
thickness (dimension in y)
spherical mirror data in module local frame.
double yc
center of curvature in y
double xc
center of curvature in x
double zb
minimum of mirror surface in z
double zc
center of curvature in z
prism data in module local frame.
double A
width (dimension in x)
std::vector< TOPGeoPrism::UnfoldedWindow > unfoldedWindows
unfolded prism exit windows
double yDown
minimal y of exit window
double slope
slope of slanted surface (dy/dz)
double yUp
maximal y of exit window
double zFlat
z where flat continues to slanted surface
double zR
maximal z, i.e position of prism-bar joint
double B
thickness at bar (dimension in y)
double zD
detector (photo-cathode) position
int k0
index of true prism in the vector 'unfoldedWindows'