Belle II Software development
FastRaytracer Class Reference

Fast photon propagation in quartz optics. More...

#include <FastRaytracer.h>

Inheritance diagram for FastRaytracer:
RaytracerBase

Public Types

enum  EGeometry {
  c_Unified = 0 ,
  c_Segmented = 1
}
 Treatement of quartz geometry. More...
 
enum  EOptics {
  c_SemiLinear = 0 ,
  c_Exact = 1
}
 Treatement of spherical mirror optics. More...
 

Public Member Functions

 FastRaytracer (int moduleID, EGeometry geometry=c_Unified, EOptics optics=c_SemiLinear)
 Constructor.
 
void clear () const
 Clear mutable variables.
 
void propagate (const PhotonState &photon, bool averaging=false) const
 Propagate photon to photo-detector plane.
 
const std::vector< PhotonState > & getPhotonStates () const
 Returns photon states (results of propagation).
 
const std::vector< PhotonState > & getExtraStates () const
 Returns extra states.
 
bool getPropagationStatus () const
 Returns propagation status.
 
bool getTotalReflStatus (double cosTotal) const
 Returns total internal reflection status.
 
double getPropagationLen () const
 Returns total propagation length since initial position.
 
double getPropagationLenDelta () const
 Returns total propagation length difference between true and flipped prism.
 
double getXD () const
 Returns unfolded position in x at virtual Detector plane.
 
double getYD () const
 Returns unfolded position in y at virtual Detector plane.
 
double getInPlaneYD () const
 Returns unfolded position in y such that the prism unfolded windows are turned over into the real Detector plane.
 
double getZD () const
 Returns unfolded position in z of virtual Detector plane.
 
double getYB () const
 Returns unfolded position in y at Bar-prism-connection plane.
 
int getNx () const
 Returns signed number of reflections in x.
 
int getNxm () const
 Returns signed number of reflections in x before mirror.
 
int getNxb () const
 Returns signed number of reflections in x after mirror and before prism.
 
int getNxe () const
 Returns signed number of reflections in x inside prism.
 
int getNy () const
 Returns signed number of reflections in y.
 
int getNym () const
 Returns signed number of reflections in y before mirror.
 
int getNyb () const
 Returns signed number of reflections in y after mirror and before prism.
 
int getNye () const
 Returns signed number of reflections in y inside prism.
 
int getNys () const
 Returns number of reflections on slanted prism surface.
 
int getModuleID () const
 Returns slot ID.
 
EGeometry getGeometry () const
 Returns quartz geometry treatement.
 
EOptics getOptics () const
 Returns treatement of spherical mirror optics.
 
const std::vector< BarSegment > & getBars () const
 Returns geometry data of bar segments.
 
const MirrorgetMirror () const
 Returns geometry data of spherical mirror.
 
const PrismgetPrism () const
 Returns geometry data of prism.
 
void setMirrorCenter (double xc, double yc)
 Sets the mirror center-of-curvature.
 

Protected Attributes

int m_moduleID = 0
 slot ID
 
EGeometry m_geometry = c_Unified
 quartz geometry
 
EOptics m_optics = c_SemiLinear
 spherical mirror optics
 
std::vector< BarSegmentm_bars
 geometry data of bar segments
 
Mirror m_mirror
 spherical mirror geometry data
 
Prism m_prism
 prism geometry data
 

Private Attributes

std::vector< PhotonStatem_photonStates
 photon states at propagation steps
 
std::vector< PhotonStatem_extraStates
 extra storage
 
bool m_status = false
 propagation status
 
int m_Nxm = 0
 number of reflections in x before mirror
 
int m_Nxb = 0
 number of reflections in x after mirror and before prism
 
int m_Nxe = 0
 number of reflections in x inside prism
 
int m_Nym = 0
 number of reflections in y before mirror
 
int m_Nyb = 0
 number of reflections in y after mirror and before prism
 
int m_Nye = 0
 number of reflections in y inside prism
 

Detailed Description

Fast photon propagation in quartz optics.

Definition at line 26 of file FastRaytracer.h.

Member Enumeration Documentation

◆ EGeometry

enum EGeometry
inherited

Treatement of quartz geometry.

Enumerator
c_Unified 

single bar with average width and thickness

c_Segmented 

segmented bars

Definition at line 33 of file RaytracerBase.h.

33 {
34 c_Unified = 0,
35 c_Segmented = 1
36 };
@ c_Unified
single bar with average width and thickness
Definition: RaytracerBase.h:34
@ c_Segmented
segmented bars
Definition: RaytracerBase.h:35

◆ EOptics

enum EOptics
inherited

Treatement of spherical mirror optics.

Enumerator
c_SemiLinear 

semi-linear approximation

c_Exact 

exact optics

Definition at line 41 of file RaytracerBase.h.

41 {
42 c_SemiLinear = 0,
43 c_Exact = 1
44 };
@ c_SemiLinear
semi-linear approximation
Definition: RaytracerBase.h:42

Constructor & Destructor Documentation

◆ FastRaytracer()

FastRaytracer ( int  moduleID,
EGeometry  geometry = c_Unified,
EOptics  optics = c_SemiLinear 
)
inlineexplicit

Constructor.

Parameters
moduleIDslot ID
geometrytreatement of quartz geometry
opticstreatement of spherical mirror optics

Definition at line 36 of file FastRaytracer.h.

36 :
37 RaytracerBase(moduleID, geometry, optics)
38 {};
RaytracerBase(int moduleID, EGeometry geometry=c_Unified, EOptics optics=c_SemiLinear)
Constructor.

Member Function Documentation

◆ clear()

void clear ( ) const

Clear mutable variables.

Definition at line 20 of file FastRaytracer.cc.

21 {
22 m_photonStates.clear();
23 m_extraStates.clear();
24 m_status = false;
25 m_Nxm = 0;
26 m_Nxb = 0;
27 m_Nxe = 0;
28 m_Nym = 0;
29 m_Nyb = 0;
30 m_Nye = 0;
31 }
int m_Nym
number of reflections in y before mirror
std::vector< PhotonState > m_photonStates
photon states at propagation steps
int m_Nxm
number of reflections in x before mirror
bool m_status
propagation status
int m_Nxe
number of reflections in x inside prism
int m_Nyb
number of reflections in y after mirror and before prism
int m_Nxb
number of reflections in x after mirror and before prism
int m_Nye
number of reflections in y inside prism
std::vector< PhotonState > m_extraStates
extra storage

◆ getBars()

const std::vector< BarSegment > & getBars ( ) const
inlineinherited

Returns geometry data of bar segments.

Returns
geometry data of bar segments

Definition at line 161 of file RaytracerBase.h.

161{return m_bars;}
std::vector< BarSegment > m_bars
geometry data of bar segments

◆ getExtraStates()

const std::vector< PhotonState > & getExtraStates ( ) const
inline

Returns extra states.

Returns
extra states

Definition at line 62 of file FastRaytracer.h.

62{return m_extraStates;}

◆ getGeometry()

EGeometry getGeometry ( ) const
inlineinherited

Returns quartz geometry treatement.

Returns
quartz geometry treatement

Definition at line 149 of file RaytracerBase.h.

149{return m_geometry;}
EGeometry m_geometry
quartz geometry

◆ getInPlaneYD()

double getInPlaneYD ( ) const

Returns unfolded position in y such that the prism unfolded windows are turned over into the real Detector plane.

Reliable only if propagation status is true. For reflected photons unfolding is done up to spherical mirror.

Returns
unfolded position in y at real Detector plane

Definition at line 143 of file FastRaytracer.cc.

144 {
145 if (m_photonStates.empty()) return 0;
146
147 double y = m_photonStates.back().getY();
148 for (int i = m_photonStates.size() - 1; i > 0; i--) {
149 const auto& photonState = m_photonStates[i];
150 if (photonState.getSegmentType() == PhotonState::c_MirrorSegment) break;
151 y = photonState.getUnfoldedY(y);
152 }
153 return y;
154 }
@ c_MirrorSegment
mirror segment
Definition: PhotonState.h:37

◆ getMirror()

const Mirror & getMirror ( ) const
inlineinherited

Returns geometry data of spherical mirror.

Returns
geometry data of spherical mirror

Definition at line 167 of file RaytracerBase.h.

167{return m_mirror;}
Mirror m_mirror
spherical mirror geometry data

◆ getModuleID()

int getModuleID ( ) const
inlineinherited

Returns slot ID.

Returns
slot ID

Definition at line 143 of file RaytracerBase.h.

143{return m_moduleID;}

◆ getNx()

int getNx ( ) const

Returns signed number of reflections in x.

Reliable only if propagation status is true.

Returns
number of reflections in x

Definition at line 180 of file FastRaytracer.cc.

181 {
182 int Nx = m_Nxm;
183 Nx += (Nx % 2 == 0) ? m_Nxb : -m_Nxb;
184 Nx += (Nx % 2 == 0) ? m_Nxe : -m_Nxe;
185 return Nx;
186 }

◆ getNxb()

int getNxb ( ) const
inline

Returns signed number of reflections in x after mirror and before prism.

Reliable only if propagation status is true.

Returns
number of reflections in x

Definition at line 152 of file FastRaytracer.h.

152{return m_Nxb;}

◆ getNxe()

int getNxe ( ) const
inline

Returns signed number of reflections in x inside prism.

Reliable only if propagation status is true.

Returns
number of reflections in x

Definition at line 159 of file FastRaytracer.h.

159{return m_Nxe;}

◆ getNxm()

int getNxm ( ) const
inline

Returns signed number of reflections in x before mirror.

Reliable only if propagation status is true.

Returns
number of reflections in x

Definition at line 145 of file FastRaytracer.h.

145{return m_Nxm;}

◆ getNy()

int getNy ( ) const

Returns signed number of reflections in y.

Reliable only if propagation status is true.

Returns
number of reflections in y

Definition at line 189 of file FastRaytracer.cc.

190 {
191 int Ny = m_Nym;
192 Ny += (Ny % 2 == 0) ? m_Nyb : -m_Nyb;
193 Ny += (Ny % 2 == 0) ? m_Nye : -m_Nye;
194 return Ny;
195 }

◆ getNyb()

int getNyb ( ) const
inline

Returns signed number of reflections in y after mirror and before prism.

Reliable only if propagation status is true.

Returns
number of reflections in y

Definition at line 180 of file FastRaytracer.h.

180{return m_Nyb;}

◆ getNye()

int getNye ( ) const
inline

Returns signed number of reflections in y inside prism.

Reliable only if propagation status is true.

Returns
number of reflections in y

Definition at line 187 of file FastRaytracer.h.

187{return m_Nye;}

◆ getNym()

int getNym ( ) const
inline

Returns signed number of reflections in y before mirror.

Reliable only if propagation status is true.

Returns
number of reflections in y

Definition at line 173 of file FastRaytracer.h.

173{return m_Nym;}

◆ getNys()

int getNys ( ) const

Returns number of reflections on slanted prism surface.

Reliable only if propagation status is true.

Returns
number of reflections on slanted prism surface

Definition at line 197 of file FastRaytracer.cc.

198 {
199 int N = (m_Nye > 0) ? m_Nye / 2 : (std::abs(m_Nye) + 1) / 2;
200 return N;
201 }

◆ getOptics()

EOptics getOptics ( ) const
inlineinherited

Returns treatement of spherical mirror optics.

Returns
spherical mirror optics

Definition at line 155 of file RaytracerBase.h.

155{return m_optics;}
EOptics m_optics
spherical mirror optics

◆ getPhotonStates()

const std::vector< PhotonState > & getPhotonStates ( ) const
inline

Returns photon states (results of propagation).

Returns
photon states

Definition at line 56 of file FastRaytracer.h.

56{return m_photonStates;}

◆ getPrism()

const Prism & getPrism ( ) const
inlineinherited

Returns geometry data of prism.

Returns
geometry data of prism

Definition at line 173 of file RaytracerBase.h.

173{return m_prism;}
Prism m_prism
prism geometry data

◆ getPropagationLen()

double getPropagationLen ( ) const

Returns total propagation length since initial position.

If averaging is ON the return value equals to arithmetic average of true and flipped prism.

Returns
propagation length

Definition at line 100 of file FastRaytracer.cc.

101 {
102 if (m_photonStates.empty()) return 0;
103 if (m_extraStates.empty()) return m_photonStates.back().getPropagationLen();
104 return (m_photonStates.back().getPropagationLen() + m_extraStates.back().getPropagationLen()) / 2;
105 }

◆ getPropagationLenDelta()

double getPropagationLenDelta ( ) const

Returns total propagation length difference between true and flipped prism.

Returns
propagation length difference (or 0 if averaging is OFF)

Definition at line 107 of file FastRaytracer.cc.

108 {
109 if (m_photonStates.empty() or m_extraStates.empty()) return 0;
110 return (m_photonStates.back().getPropagationLen() - m_extraStates.back().getPropagationLen());
111 }

◆ getPropagationStatus()

bool getPropagationStatus ( ) const
inline

Returns propagation status.

Returns
true on success

Definition at line 68 of file FastRaytracer.h.

68{return m_status;}

◆ getTotalReflStatus()

bool getTotalReflStatus ( double  cosTotal) const

Returns total internal reflection status.

Reliable only if propagation status is true.

Parameters
cosTotalcosine of total reflection angle
Returns
true if totally reflected

Definition at line 92 of file FastRaytracer.cc.

93 {
94 for (const auto& photonState : m_photonStates) {
95 if (not photonState.getTotalReflStatus(cosTotal)) return false;
96 }
97 return true;
98 }

◆ getXD()

double getXD ( ) const

Returns unfolded position in x at virtual Detector plane.

If averaging is ON the return value equals to arithmetic average of true and flipped prism. Reliable only if propagation status is true. For reflected photons unfolding is done up to spherical mirror.

Returns
unfolded position in x at virtual Detector plane

Definition at line 113 of file FastRaytracer.cc.

114 {
115 if (m_photonStates.empty()) return 0;
116
117 double x = m_extraStates.empty() ?
118 m_photonStates.back().getXD() : (m_photonStates.back().getXD() + m_extraStates.back().getXD()) / 2;
119
120 for (int i = m_photonStates.size() - 2; i > 0; i--) {
121 const auto& photonState = m_photonStates[i];
122 if (photonState.getSegmentType() == PhotonState::c_MirrorSegment) break;
123 x = photonState.getUnfoldedX(x);
124 }
125 return x;
126 }

◆ getYB()

double getYB ( ) const

Returns unfolded position in y at Bar-prism-connection plane.

Reliable only if propagation status is true. For reflected photons unfolding is done up to spherical mirror.

Returns
unfolded position in y at Bar-prism-connection plane

Definition at line 165 of file FastRaytracer.cc.

166 {
167 if (m_photonStates.size() < 2) return 0;
168
169 int i0 = m_photonStates.size() - 2;
170 double y = m_photonStates[i0].getY();
171 for (int i = i0; i > 0; i--) {
172 const auto& photonState = m_photonStates[i];
173 if (photonState.getSegmentType() == PhotonState::c_MirrorSegment) break;
174 y = photonState.getUnfoldedY(y);
175 }
176 return y;
177 }

◆ getYD()

double getYD ( ) const

Returns unfolded position in y at virtual Detector plane.

Reliable only if propagation status is true. For reflected photons unfolding is done up to spherical mirror.

Returns
unfolded position in y at virtual Detector plane

Definition at line 129 of file FastRaytracer.cc.

130 {
131 if (m_photonStates.empty()) return 0;
132
133 double y = m_photonStates.back().getYD();
134 for (int i = m_photonStates.size() - 2; i > 0; i--) {
135 const auto& photonState = m_photonStates[i];
136 if (photonState.getSegmentType() == PhotonState::c_MirrorSegment) break;
137 y = photonState.getUnfoldedY(y);
138 }
139 return y;
140 }

◆ getZD()

double getZD ( ) const

Returns unfolded position in z of virtual Detector plane.

If averaging is ON the return value equals to arithmetic average of true and flipped prism. Reliable only if propagation status is true.

Returns
unfolded position in z of virtual Detector plane

Definition at line 157 of file FastRaytracer.cc.

158 {
159 if (m_photonStates.empty()) return 0;
160 if (m_extraStates.empty()) return m_photonStates.back().getZD();
161 return (m_photonStates.back().getZD() + m_extraStates.back().getZD()) / 2;
162 }

◆ propagate()

void propagate ( const PhotonState photon,
bool  averaging = false 
) const

Propagate photon to photo-detector plane.

Parameters
photoninitial photon state
averagingif true, propagate photon also in upside-down flipped prism

Definition at line 33 of file FastRaytracer.cc.

34 {
35 clear();
36 m_photonStates.push_back(photon);
37
38 int nbars = m_bars.size();
39 if (photon.getKz() > 0 and photon.getZ() > m_prism.zR) {
40 for (int i = 0; i < nbars; i++) {
41 const auto& bar = m_bars[i];
42 const auto& lastState = m_photonStates.back();
43 if (lastState.getZ() >= bar.zR) continue;
44 m_photonStates.push_back(lastState);
45 auto& newState = m_photonStates.back();
46 if (i < nbars - 1) {
47 newState.propagate(bar);
48 } else if (m_optics == c_SemiLinear) {
49 newState.propagateSemiLinear(bar, m_mirror);
50 } else {
51 newState.propagateExact(bar, m_mirror);
52 }
53 if (not newState.getPropagationStatus()) return;
54
55 m_Nxm += (m_Nxm % 2 == 0) ? newState.getNx() : -newState.getNx();
56 m_Nym += (m_Nym % 2 == 0) ? newState.getNy() : -newState.getNy();
57 }
58 }
59
60 for (int i = nbars - 1; i >= 0; i--) {
61 const auto& bar = m_bars[i];
62 const auto& lastState = m_photonStates.back();
63 if (lastState.getZ() <= bar.zL) continue;
64 m_photonStates.push_back(lastState);
65 auto& newState = m_photonStates.back();
66 newState.propagate(bar);
67 if (not newState.getPropagationStatus()) return;
68
69 m_Nxb += (m_Nxb % 2 == 0) ? newState.getNx() : -newState.getNx();
70 m_Nyb += (m_Nyb % 2 == 0) ? newState.getNy() : -newState.getNy();
71 }
72
73 const auto& lastState = m_photonStates.back();
74 m_photonStates.push_back(lastState);
75 auto& newState = m_photonStates.back();
76 newState.propagate(m_prism);
77 if (not newState.getPropagationStatus()) return;
78
79 if (averaging) {
80 m_extraStates.push_back(lastState);
81 auto& flippedState = m_extraStates.back().flipKy();
82 flippedState.propagate(m_prism);
83 if (not flippedState.getPropagationStatus()) return;
84 }
85
86 m_Nxe = newState.getNx();
87 m_Nye = newState.getNy();
88
89 m_status = true;
90 }
void clear() const
Clear mutable variables.
double zR
maximal z, i.e position of prism-bar joint

◆ setMirrorCenter()

void setMirrorCenter ( double  xc,
double  yc 
)
inherited

Sets the mirror center-of-curvature.

Parameters
xccenter of curvature in x
yccenter of curvature in y

Definition at line 100 of file RaytracerBase.cc.

101 {
102 m_mirror.xc = xc;
103 m_mirror.yc = yc;
104
105 double zc = m_mirror.zc;
106 double R = m_mirror.R;
107 double zb = zc + R;
108 double Ah = m_bars.back().A / 2;
109 double Bh = m_bars.back().B / 2;
110 zb = std::min(zb, zc + sqrt(pow(R, 2) - pow(xc - Ah, 2) - pow(yc - Bh, 2)));
111 zb = std::min(zb, zc + sqrt(pow(R, 2) - pow(xc + Ah, 2) - pow(yc - Bh, 2)));
112 zb = std::min(zb, zc + sqrt(pow(R, 2) - pow(xc - Ah, 2) - pow(yc + Bh, 2)));
113 zb = std::min(zb, zc + sqrt(pow(R, 2) - pow(xc + Ah, 2) - pow(yc + Bh, 2)));
114 m_mirror.zb = zb;
115 }
double R
typedef autogenerated by FFTW
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
double yc
center of curvature in y
Definition: RaytracerBase.h:82
double xc
center of curvature in x
Definition: RaytracerBase.h:81
double zb
minimum of mirror surface in z
Definition: RaytracerBase.h:85
double zc
center of curvature in z
Definition: RaytracerBase.h:83

Member Data Documentation

◆ m_bars

std::vector<BarSegment> m_bars
protectedinherited

geometry data of bar segments

Definition at line 188 of file RaytracerBase.h.

◆ m_extraStates

std::vector<PhotonState> m_extraStates
mutableprivate

extra storage

Definition at line 200 of file FastRaytracer.h.

◆ m_geometry

EGeometry m_geometry = c_Unified
protectedinherited

quartz geometry

Definition at line 185 of file RaytracerBase.h.

◆ m_mirror

Mirror m_mirror
protectedinherited

spherical mirror geometry data

Definition at line 189 of file RaytracerBase.h.

◆ m_moduleID

int m_moduleID = 0
protectedinherited

slot ID

Definition at line 184 of file RaytracerBase.h.

◆ m_Nxb

int m_Nxb = 0
mutableprivate

number of reflections in x after mirror and before prism

Definition at line 203 of file FastRaytracer.h.

◆ m_Nxe

int m_Nxe = 0
mutableprivate

number of reflections in x inside prism

Definition at line 204 of file FastRaytracer.h.

◆ m_Nxm

int m_Nxm = 0
mutableprivate

number of reflections in x before mirror

Definition at line 202 of file FastRaytracer.h.

◆ m_Nyb

int m_Nyb = 0
mutableprivate

number of reflections in y after mirror and before prism

Definition at line 206 of file FastRaytracer.h.

◆ m_Nye

int m_Nye = 0
mutableprivate

number of reflections in y inside prism

Definition at line 207 of file FastRaytracer.h.

◆ m_Nym

int m_Nym = 0
mutableprivate

number of reflections in y before mirror

Definition at line 205 of file FastRaytracer.h.

◆ m_optics

EOptics m_optics = c_SemiLinear
protectedinherited

spherical mirror optics

Definition at line 186 of file RaytracerBase.h.

◆ m_photonStates

std::vector<PhotonState> m_photonStates
mutableprivate

photon states at propagation steps

Definition at line 199 of file FastRaytracer.h.

◆ m_prism

Prism m_prism
protectedinherited

prism geometry data

Definition at line 190 of file RaytracerBase.h.

◆ m_status

bool m_status = false
mutableprivate

propagation status

Definition at line 201 of file FastRaytracer.h.


The documentation for this class was generated from the following files: