Belle II Software development
YScanner Class Reference

Utility for expanding the PDF in y direction. More...

#include <YScanner.h>

Inheritance diagram for YScanner:
RaytracerBase

Classes

struct  Derivatives
 Derivatives. More...
 
struct  PixelProjection
 Down-stream projection of a pixel to prism entrance window w/ a clip on bar exit thickness. More...
 
struct  Result
 Single PDF peak data. More...
 
struct  Table
 A table of equidistant entries. More...
 
struct  TableEntry
 Table entry. More...
 
struct  WindowProjection
 Geometry-only quantities needed to project a pixel to a given unfolded prism exit window. More...
 

Public Types

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

Public Member Functions

 YScanner (int moduleID, unsigned N=64)
 Class constructor.
 
void clear () const
 Clear mutable variables.
 
void prepare (double momentum, double beta, double length) const
 Prepare for the PDF expansion in y for a given track mass hypothesis.
 
bool isAboveThreshold () const
 Returns above Cerenkov threshold flag which is set in the prepare method.
 
void expand (unsigned col, double yB, double dydz, const Derivatives &D, int Ny, bool doScan) const
 Performs the PDF expansion in y for a given pixel column using scan or merge methods.
 
const PixelPositionsgetPixelPositions () const
 Returns pixel positions and their sizes.
 
const PixelMasksgetPixelMasks () const
 Returns pixel masks.
 
const PixelEfficienciesgetPixelEfficiencies () const
 Returns pixel relative efficiencies.
 
const TablegetEfficiencies () const
 Returns nominal photon detection efficiencies (PDE)
 
double getCosTotal () const
 Returns cosine of total reflection angle.
 
double getMomentum () const
 Returns particle momentum.
 
double getBeta () const
 Returns particle beta.
 
double getTrackLengthInQuartz () const
 Returns particle trajectory length inside quartz.
 
double getNumPhotonsPerLen () const
 Returns number of photons per Cerenkov azimuthal angle per track length.
 
double getNumPhotons () const
 Returns number of photons per Cerenkov azimuthal angle.
 
double getMeanEnergy () const
 Returns mean photon energy.
 
double getRMSEnergy () const
 Returns r.m.s of photon energy.
 
double getMeanEnergyBeta1 () const
 Returns mean photon energy for beta = 1.
 
double getRMSEnergyBeta1 () const
 Returns r.m.s of photon energy for beta = 1.
 
double getSigmaScattering () const
 Returns r.m.s of multiple scattering angle in quartz converted to photon energy.
 
double getSigmaAlpha () const
 Returns surface roughness parameter in units of photon energy.
 
double getSurfaceReflectivity (unsigned n) const
 Returns the reflectivity of the bar surface raised to the given power.
 
const TablegetEnergyDistribution () const
 Returns photon energy distribution.
 
const std::map< int, Table > & getQuasyEnergyDistributions () const
 Returns photon energy distributions convoluted with multiple scattering and surface roughness.
 
const std::vector< Result > & getResults () const
 Returns the results of PDF expansion in y.
 
bool isScanDone () const
 Checks which expansion method was used.
 
int getModuleID () const
 Returns slot ID.
 
EGeometry getGeometry () const
 Returns quartz geometry treatment.
 
EOptics getOptics () const
 Returns treatment 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.
 

Static Public Member Functions

static void setScanLimits (int maxReflections)
 Sets parameters for selection between expand methods.
 

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 Member Functions

double setEnergyDistribution (double beta) const
 Sets photon energy distribution and mean photon energy according to nominal PDE and particle beta.
 
void setQuasyEnergyDistribution (double sigma) const
 Sets photon energy distribution convoluted with a normalized Gaussian.
 
void integrate (const EnergyMask *energyMask, double Ecp, Result &result) const
 Integrates quasy energy distribution multiplied with energy mask.
 
void projectPixel (double yc, double size, int k, double dydz, PixelProjection proj[2]) const
 Calculates projections of a pixel to prism entrance window (going down-stream the photon).
 
double tabulateSurfaceReflectivity (unsigned n) const
 Extends the table of surface reflectivity powers up to n and returns the value.
 
void scan (unsigned col, double yB, double dydz, const Derivatives &D, int j1, int j2) const
 Performs expansion w/ the scan over reflections.
 
void merge (unsigned col, double dydz, int j1, int j2) const
 Performs expansion by merging all reflections.
 
PixelMaskspixelMasks ()
 Returns non-const pixel masks.
 
PixelEfficienciespixelEfficiencies ()
 Returns non-const pixel relative efficiencies.
 

Private Attributes

PixelPositions m_pixelPositions
 positions and sizes of pixels
 
PixelMasks m_pixelMasks
 pixel masks
 
PixelEfficiencies m_pixelEfficiencies
 pixel relative efficiencies
 
Table m_efficiency
 nominal photon detection efficiencies (PDE)
 
std::vector< WindowProjectionm_windowProjections
 pixel projection constants of unfolded prism exit windows
 
std::vector< double > m_surfaceReflectivities
 bar surface reflectivity to the power of the index; filled on demand, never cleared
 
double m_prismZR = 0
 z of the prism-bar joint (copy of m_prism.zR)
 
double m_halfBarThickness = 0
 half thickness of the bar at prism entrance
 
double m_meanE0 = 0
 mean photon energy for beta = 1
 
double m_rmsE0 = 0
 r.m.s of photon energy for beta = 1
 
double m_cosTotal = 0
 cosine of total reflection angle
 
double m_momentum = 0
 particle momentum magnitude
 
double m_beta = 0
 particle beta
 
double m_length = 0
 length of particle trajectory inside quartz
 
double m_numPhotons = 0
 number of photons per Cerenkov azimuthal angle per track length
 
double m_meanE = 0
 mean photon energy
 
double m_rmsE = 0
 r.m.s of photon energy
 
double m_sigmaScat = 0
 r.m.s.
 
double m_sigmaAlpha = 0
 surface roughness parameter in photon energy units
 
Table m_energyDistribution
 photon energy distribution
 
std::map< int, Tablem_quasyEnergyDistributions
 photon energy distributions convoluted with Gaussian of different widths
 
Tablem_quasyEnergyDistribution = nullptr
 a pointer to the element in m_quasyEnergyDistributions
 
bool m_aboveThreshold = false
 true if beta is above the Cerenkov threshold
 
std::vector< Resultm_results
 results of PDF expansion in y
 
bool m_scanDone = false
 true if scan performed, false if reflections just merged
 

Static Private Attributes

static int s_maxReflections = 16
 maximal number of reflections to perform scan
 
static unsigned s_maxTabulatedPower = 1024
 maximal power of the surface reflectivity that is tabulated
 

Friends

class TOPRecoManager
 

Detailed Description

Utility for expanding the PDF in y direction.

Definition at line 33 of file YScanner.h.

Member Enumeration Documentation

◆ EGeometry

enum EGeometry
inherited

Treatment 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 };

◆ EOptics

enum EOptics
inherited

Treatment 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 };

Constructor & Destructor Documentation

◆ YScanner()

YScanner ( int moduleID,
unsigned N = 64 )
explicit

Class constructor.

Sets pixel positions of a given module and nominal photon detection efficiency.

Parameters
moduleIDslot ID
Nsize of nominal photon detection efficiency table

Definition at line 48 of file YScanner.cc.

48 : RaytracerBase(moduleID, c_Unified, c_SemiLinear),
49 m_pixelPositions(PixelPositions(moduleID)),
50 m_pixelMasks(PixelMasks(moduleID)),
51 m_pixelEfficiencies(PixelEfficiencies(moduleID))
52 {
53 if (N < 2) {
54 B2FATAL("TOP::YScanner: N must be > 1");
55 return;
56 }
57
58 // set the pixel projection constants of the unfolded prism exit windows
59
60 m_prismZR = m_prism.zR;
61 m_halfBarThickness = m_bars.front().B / 2;
62 double dz = std::abs(m_prism.zD - m_prism.zFlat);
63 for (size_t k = 0; k < m_prism.unfoldedWindows.size(); k++) {
64 const auto& win = m_prism.unfoldedWindows[k];
65 WindowProjection projection;
66 projection.sy = win.sy;
67 projection.sz = win.sz;
68 projection.y0 = win.y0 + win.ny * dz;
69 projection.z0 = win.z0 + win.nz * dz;
70 projection.evenReflection = ((static_cast<int>(k) - m_prism.k0) % 2 == 0);
71 m_windowProjections.push_back(projection);
72 }
73
74 // set the table of nominal photon detection efficiencies (incl. wavelength filter)
75
76 const auto* topgp = TOPGeometryPar::Instance();
77 const auto* geo = topgp->getGeometry();
78 auto qe = geo->getNominalQE(); // get a copy
79 qe.applyFilterTransmission(geo->getWavelengthFilter());
80
81 double minE = TOPGeometryPar::c_hc / qe.getMaxLambda();
82 double maxE = TOPGeometryPar::c_hc / qe.getMinLambda();
83 if (minE >= maxE) {
84 B2FATAL("TOP::YScanner: quantum efficiency found zero for all wavelengths");
85 return;
86 }
87 m_efficiency.set(minE, (maxE - minE) / (N - 1));
88
89 const auto& tdc = geo->getNominalTDC();
90 for (unsigned i = 0; i < N; i++) {
91 double e = m_efficiency.getX(i);
92 double lambda = TOPGeometryPar::c_hc / e;
93 double effi = qe.getEfficiency(lambda) * tdc.getEfficiency();
94 m_efficiency.entries.push_back(TableEntry(effi, e, e * e));
95 }
96
97 // set cosine of total reflection angle using photon mean energy for beta = 1
98
99 double s = 0;
100 double se = 0;
101 double see = 0;
102 for (const auto& entry : m_efficiency.entries) {
103 double e = entry.x;
104 double p = entry.y * (1 - 1 / pow(topgp->getPhaseIndex(e), 2));
105 s += p;
106 se += p * e;
107 see += p * e * e;
108 }
109 if (s == 0) return;
110 m_meanE0 = se / s;
111 m_rmsE0 = sqrt(see / s - m_meanE0 * m_meanE0);
112 m_cosTotal = sqrt(1 - 1 / pow(topgp->getPhaseIndex(m_meanE0), 2));
113 }
double sqrt(double a)
sqrt for double
Definition beamHelpers.h:28

Member Function Documentation

◆ clear()

void clear ( ) const

Clear mutable variables.

Definition at line 130 of file YScanner.cc.

131 {
132 m_momentum = 0;
133 m_beta = 0;
134 m_length = 0;
135 m_numPhotons = 0;
136 m_meanE = 0;
137 m_rmsE = 0;
138 m_sigmaScat = 0;
139 m_sigmaAlpha = 0;
140 m_energyDistribution.clear();
141 m_quasyEnergyDistributions.clear();
142 m_quasyEnergyDistribution = nullptr;
143 m_aboveThreshold = false;
144 m_results.clear();
145 m_scanDone = false;
146 }

◆ expand()

void expand ( unsigned col,
double yB,
double dydz,
const Derivatives & D,
int Ny,
bool doScan ) const

Performs the PDF expansion in y for a given pixel column using scan or merge methods.

Results accessible with getResults() method.

Parameters
colpixel column number (0-based)
yBunfolded coordinate y of photon at prism entrance (= Bar exit) plane
dydzphoton slope in y-z projection at prism entrance (dy/dz)
Dthe derivatives
Nyeffective number of reflections
doScanif true decide between scan and merge methods, if false always use merge method

Definition at line 274 of file YScanner.cc.

275 {
276 m_results.clear();
277
278 if (D.dyB_de == 0) return;
279
280 double sigma = sqrt(pow(m_sigmaScat, 2) + pow(m_sigmaAlpha, 2) * std::abs(Ny));
281 setQuasyEnergyDistribution(sigma);
282
283 double minE = m_quasyEnergyDistribution->getXmin();
284 double maxE = m_quasyEnergyDistribution->getXmax();
285 double pixDx = m_pixelPositions.get(col + 1).Dx;
286 double dely = (std::abs(D.dyB_dL) * m_length + std::abs(D.dyB_dx) * pixDx) / 2;
287 double y1 = yB - dely;
288 double y2 = yB + dely;
289 if (D.dyB_de > 0) {
290 y1 += D.dyB_de * (minE - m_meanE);
291 y2 += D.dyB_de * (maxE - m_meanE);
292 } else {
293 y1 += D.dyB_de * (maxE - m_meanE);
294 y2 += D.dyB_de * (minE - m_meanE);
295 }
296 double B = m_bars.front().B;
297 int j1 = func::lround(y1 / B);
298 int j2 = func::lround(y2 / B) + 1;
299
300 if (doScan and j2 - j1 <= s_maxReflections) {
301 scan(col, yB, dydz, D, j1, j2);
302 m_scanDone = true;
303 } else {
304 merge(col, dydz, j1, j2);
305 m_scanDone = false;
306 }
307 }
std::vector< std::vector< double > > merge(const std::vector< std::vector< std::vector< double > > > &toMerge)
merge { vector<double> a, vector<double> b} into {a, b}
Definition tools.h:41

◆ 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;}

◆ getBeta()

double getBeta ( ) const
inline

Returns particle beta.

Returns
particle beta

Definition at line 318 of file YScanner.h.

318{return m_beta;}

◆ getCosTotal()

double getCosTotal ( ) const
inline

Returns cosine of total reflection angle.

Returns
cosine of total reflection angle at mean photon energy for beta = 1

Definition at line 306 of file YScanner.h.

306{return m_cosTotal;}

◆ getEfficiencies()

const Table & getEfficiencies ( ) const
inline

Returns nominal photon detection efficiencies (PDE)

Returns
nominal photon detection efficiencies

Definition at line 300 of file YScanner.h.

300{return m_efficiency;}

◆ getEnergyDistribution()

const Table & getEnergyDistribution ( ) const
inline

Returns photon energy distribution.

Returns
photon energy distribution

Definition at line 391 of file YScanner.h.

391{return m_energyDistribution;}

◆ getGeometry()

EGeometry getGeometry ( ) const
inlineinherited

Returns quartz geometry treatment.

Returns
quartz geometry treatment

Definition at line 149 of file RaytracerBase.h.

149{return m_geometry;}

◆ getMeanEnergy()

double getMeanEnergy ( ) const
inline

Returns mean photon energy.

Returns
mean photon energy

Definition at line 342 of file YScanner.h.

342{return m_meanE;}

◆ getMeanEnergyBeta1()

double getMeanEnergyBeta1 ( ) const
inline

Returns mean photon energy for beta = 1.

Returns
mean photon energy for beta = 1

Definition at line 354 of file YScanner.h.

354{return m_meanE0;}

◆ 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;}

◆ getModuleID()

int getModuleID ( ) const
inlineinherited

Returns slot ID.

Returns
slot ID

Definition at line 143 of file RaytracerBase.h.

143{return m_moduleID;}

◆ getMomentum()

double getMomentum ( ) const
inline

Returns particle momentum.

Returns
particle momentum

Definition at line 312 of file YScanner.h.

312{return m_momentum;}

◆ getNumPhotons()

double getNumPhotons ( ) const
inline

Returns number of photons per Cerenkov azimuthal angle.

Returns
number of photons per radian

Definition at line 336 of file YScanner.h.

336{return m_numPhotons * m_length;}

◆ getNumPhotonsPerLen()

double getNumPhotonsPerLen ( ) const
inline

Returns number of photons per Cerenkov azimuthal angle per track length.

Returns
number of photons per radian per centimeter

Definition at line 330 of file YScanner.h.

330{return m_numPhotons;}

◆ getOptics()

EOptics getOptics ( ) const
inlineinherited

Returns treatment of spherical mirror optics.

Returns
spherical mirror optics

Definition at line 155 of file RaytracerBase.h.

155{return m_optics;}

◆ getPixelEfficiencies()

const PixelEfficiencies & getPixelEfficiencies ( ) const
inline

Returns pixel relative efficiencies.

Returns
pixel relative efficiencies

Definition at line 294 of file YScanner.h.

294{return m_pixelEfficiencies;}

◆ getPixelMasks()

const PixelMasks & getPixelMasks ( ) const
inline

Returns pixel masks.

Returns
pixel masks

Definition at line 288 of file YScanner.h.

288{return m_pixelMasks;}

◆ getPixelPositions()

const PixelPositions & getPixelPositions ( ) const
inline

Returns pixel positions and their sizes.

Returns
pixel positions and their sizes in module local frame

Definition at line 282 of file YScanner.h.

282{return m_pixelPositions;}

◆ 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;}

◆ getQuasyEnergyDistributions()

const std::map< int, Table > & getQuasyEnergyDistributions ( ) const
inline

Returns photon energy distributions convoluted with multiple scattering and surface roughness.

Map entries correspond to different Gaussian widths due to different number of reflections.

Returns
photon energy distributions convoluted with multiple scattering and surface roughness

Definition at line 398 of file YScanner.h.

398{return m_quasyEnergyDistributions;}

◆ getResults()

const std::vector< Result > & getResults ( ) const
inline

Returns the results of PDF expansion in y.

Returns
results

Definition at line 404 of file YScanner.h.

404{return m_results;}

◆ getRMSEnergy()

double getRMSEnergy ( ) const
inline

Returns r.m.s of photon energy.

Returns
r.m.s of photon energy

Definition at line 348 of file YScanner.h.

348{return m_rmsE;}

◆ getRMSEnergyBeta1()

double getRMSEnergyBeta1 ( ) const
inline

Returns r.m.s of photon energy for beta = 1.

Returns
r.m.s of photon energy for beta = 1

Definition at line 360 of file YScanner.h.

360{return m_rmsE0;}

◆ getSigmaAlpha()

double getSigmaAlpha ( ) const
inline

Returns surface roughness parameter in units of photon energy.

Returns
surface roughness parameter [eV]

Definition at line 372 of file YScanner.h.

372{return m_sigmaAlpha;}

◆ getSigmaScattering()

double getSigmaScattering ( ) const
inline

Returns r.m.s of multiple scattering angle in quartz converted to photon energy.

Returns
r.m.s of multiple scattering angle in quartz [eV]

Definition at line 366 of file YScanner.h.

366{return m_sigmaScat;}

◆ getSurfaceReflectivity()

double getSurfaceReflectivity ( unsigned n) const
inline

Returns the reflectivity of the bar surface raised to the given power.

The reflectivity is a constant of the module, therefore the powers are tabulated on first use and kept for the whole job (they do not depend on the track or the hypothesis).

Parameters
npower, i.e. the number of reflections
Returns
reflectivity to the power of n

Definition at line 381 of file YScanner.h.

382 {
383 if (n < m_surfaceReflectivities.size()) return m_surfaceReflectivities[n];
384 return tabulateSurfaceReflectivity(n);
385 }

◆ getTrackLengthInQuartz()

double getTrackLengthInQuartz ( ) const
inline

Returns particle trajectory length inside quartz.

Returns
particle trajectory length inside quartz

Definition at line 324 of file YScanner.h.

324{return m_length;}

◆ integrate()

void integrate ( const EnergyMask * energyMask,
double Ecp,
Result & result ) const
private

Integrates quasy energy distribution multiplied with energy mask.

Parameters
energyMaskenergy mask (pointer must be valid)
Ecpposition of the mask
resultupdated result [in/out]

Definition at line 412 of file YScanner.cc.

413 {
414 const auto& mask = energyMask->getMask();
415
416 if (mask.empty()) {
417 // direct mask calculation
418 for (size_t i = 0; i < m_quasyEnergyDistribution->entries.size(); i++) {
419 double E = m_quasyEnergyDistribution->getX(i);
420 double m = energyMask->getMask(E - Ecp);
421 if (m > 0) {
422 const auto& entry = m_quasyEnergyDistribution->entries[i];
423 double s = entry.y * m;
424 result.sum += s;
425 result.e0 += entry.x * s;
426 result.sigsq += entry.xsq * s;
427 }
428 }
429 } else {
430 // pre-calculated discrete mask w/ linear interpolation
431 int i0 = m_quasyEnergyDistribution->getIndex(Ecp);
432 double fract = -(Ecp - m_quasyEnergyDistribution->getX(i0)) / m_quasyEnergyDistribution->step;
433 if (fract < 0) {
434 i0++;
435 fract += 1;
436 }
437 int N = m_quasyEnergyDistribution->entries.size() - 1;
438 int M = mask.size() - 1;
439 int i1 = std::max(i0 - M, 0);
440 int i2 = std::min(i0 + M - 1, N);
441 for (int i = i1; i <= i2; i++) {
442 const auto& entry = m_quasyEnergyDistribution->entries[i];
443 double m = mask[std::abs(i - i0)] * (1 - fract) + mask[std::abs(i - i0 + 1)] * fract;
444 double s = entry.y * m;
445 result.sum += s;
446 result.e0 += entry.x * s;
447 result.sigsq += entry.xsq * s;
448 }
449 }
450 }
R E
internal precision of FFTW codelets

◆ isAboveThreshold()

bool isAboveThreshold ( ) const
inline

Returns above Cerenkov threshold flag which is set in the prepare method.

Returns
true, if beta is above the Cherenkov threshold for at least one PDE data point

Definition at line 264 of file YScanner.h.

264{return m_aboveThreshold;}

◆ isScanDone()

bool isScanDone ( ) const
inline

Checks which expansion method was used.

Returns
true if scan, false if merge

Definition at line 410 of file YScanner.h.

410{return m_scanDone;}

◆ merge()

void merge ( unsigned col,
double dydz,
int j1,
int j2 ) const
private

Performs expansion by merging all reflections.

Parameters
colpixel column number (0-based)
dydzphoton slope in y-z projection at prism entrance (dy/dz)
j1first reflection number in y
j2last (exclusive) reflection number in y

Definition at line 377 of file YScanner.cc.

378 {
379 int Neven = func::getNumOfEven(j1, j2);
380 int Nodd = j2 - j1 - Neven;
381
382 const size_t numWindows = m_windowProjections.size();
383 const unsigned numRows = m_pixelPositions.getNumPixelRows();
384 const double barB = m_bars.front().B;
385
386 for (unsigned row = 0; row < numRows; row++) {
387
388 int pixelID = m_pixelPositions.pixelID(row, col);
389 if (not m_pixelMasks.isActive(pixelID)) continue;
390
391 const auto& pixel = m_pixelPositions.get(pixelID);
392 double Dy0 = 0;
393 double Dy1 = 0;
394 PixelProjection proj[2];
395 for (size_t k = 0; k < numWindows; k++) {
396 projectPixel(pixel.yc, pixel.Dy, k, dydz, proj);
397 if (proj[0].Dy > 0) Dy0 += proj[0].Dy;
398 if (proj[1].Dy > 0) Dy1 += proj[1].Dy;
399 }
400 if (Dy0 == 0 and Dy1 == 0) continue;
401
402 double Dy = (Dy0 * Neven + Dy1 * Nodd) / (Neven + Nodd);
403 Result result(pixelID);
404 result.sum = Dy / barB;
405 result.e0 = m_meanE;
406 result.sigsq = m_rmsE * m_rmsE;
407 m_results.push_back(result);
408 }
409 }

◆ pixelEfficiencies()

PixelEfficiencies & pixelEfficiencies ( )
inlineprivate

Returns non-const pixel relative efficiencies.

Returns
pixel relative efficiencies

Definition at line 508 of file YScanner.h.

508{return m_pixelEfficiencies;}

◆ pixelMasks()

PixelMasks & pixelMasks ( )
inlineprivate

Returns non-const pixel masks.

Returns
pixel masks

Definition at line 502 of file YScanner.h.

502{return m_pixelMasks;}

◆ prepare()

void prepare ( double momentum,
double beta,
double length ) const

Prepare for the PDF expansion in y for a given track mass hypothesis.

Sets photon energy and quasy-energy distributions, mean and r.m.s of photon energy, number of photons and aboveThreshold flag.

Parameters
momentumparticle momentum
betaparticle beta
lengthlength of particle trajectory within the quartz

Definition at line 149 of file YScanner.cc.

150 {
151 clear();
152
153 m_momentum = momentum;
154 m_beta = beta;
155 m_length = length;
156
157 // check for Cherenkov threshold, return if below
158
159 const auto* topgp = TOPGeometryPar::Instance();
160 if (beta * topgp->getPhaseIndex(m_meanE0) < 1) return;
161
162 // set photon energy distribution, and the mean and r.m.s of photon energy
163
164 auto area = setEnergyDistribution(beta);
165 if (area == 0) return;
166
167 // set number of Cerenkov photons per azimuthal angle per centimeter
168
169 m_numPhotons = 370 * area / (2 * M_PI);
170
171 // set multiple scattering and surface roughness sigmas in photon energy units
172
173 const double radLength = 12.3; // quartz radiation length [cm]
174 double thetaScat = 13.6e-3 / beta / momentum * sqrt(length / 2 / radLength); // r.m.s of multiple scattering angle
175
176 double n = topgp->getPhaseIndex(m_meanE);
177 if (beta * n < 1) {
178 B2ERROR("TOP::YScanner::prepare: beta * n < 1 ==> must be a bug!");
179 return;
180 }
181 double dndE = topgp->getPhaseIndexDerivative(m_meanE);
182 double dEdTheta = n * sqrt(pow(beta * n, 2) - 1) / dndE;
183 m_sigmaScat = std::abs(thetaScat * dEdTheta); // r.m.s of multiple scattering angle converted to photon energy
184 m_sigmaAlpha = std::abs(m_bars.back().sigmaAlpha * dEdTheta); // surface roughness converted to photon energy
185
186 // set photon energy distribution convoluted with multiple scattering
187
188 setQuasyEnergyDistribution(m_sigmaScat);
189
190 m_aboveThreshold = true;
191 }

◆ projectPixel()

void projectPixel ( double yc,
double size,
int k,
double dydz,
PixelProjection proj[2] ) const
inlineprivate

Calculates projections of a pixel to prism entrance window (going down-stream the photon).

Parameters
ycPixel center in y.
sizePixel size in y.
kValid index of vector of unfolded prism exit windows.
dydzPhoton slope at prism entrance; dydz is used for even projections and -dydz is used for odd projections.
projProjections of a pixel to prism entrance (results)

Definition at line 444 of file YScanner.h.

445 {
446 const auto& win = m_windowProjections[k];
447 double halfSize = win.evenReflection ? size / 2 : -size / 2;
448 const double ypix[2] = {yc - halfSize, yc + halfSize}; // pixel edges in y
449 double yproj[2][2] = {{0}}; // pixel projections to prism entrance window (second index corresponds to pixel edges)
450
451 #pragma omp simd
452 for (int i = 0; i < 2; ++i) {
453 /* Formerly YScanner::prismEntranceY. */
454 double z = ypix[i] * win.sz + win.z0;
455 double y = ypix[i] * win.sy + win.y0;
456 double dy = dydz * (m_prismZR - z);
457 yproj[0][i] = y + dy; // even reflections
458 yproj[1][i] = y - dy; // odd reflections
459 }
460
461 double Bh = m_halfBarThickness;
462 for (int i = 0; i < 2; ++i) {
463 yproj[i][0] = std::max(yproj[i][0], -Bh);
464 yproj[i][1] = std::min(yproj[i][1], Bh);
465 proj[i].yc = (yproj[i][0] + yproj[i][1]) / 2;
466 proj[i].Dy = yproj[i][1] - yproj[i][0];
467 }
468 }

◆ scan()

void scan ( unsigned col,
double yB,
double dydz,
const Derivatives & D,
int j1,
int j2 ) const
private

Performs expansion w/ the scan over reflections.

Parameters
colpixel column number (0-based)
yBunfolded coordinate y of photon at prism entrance (= Bar exit) plane
dydzphoton slope in y-z projection at prism entrance (dy/dz)
Dthe derivatives
j1first reflection number in y
j2last (exclusive) reflection number in y

Definition at line 310 of file YScanner.cc.

311 {
312
313 const size_t numWindows = m_windowProjections.size();
314 const unsigned numRows = m_pixelPositions.getNumPixelRows();
315 const double barB = m_bars.front().B;
316
317 std::map<int, EnergyMask*> masks;
318 for (unsigned row = 0; row < numRows; row++) {
319
320 int pixelID = m_pixelPositions.pixelID(row, col);
321 if (not m_pixelMasks.isActive(pixelID)) continue;
322
323 const auto& pixel = m_pixelPositions.get(pixelID);
324 std::vector<PixelProjection> projections[2];
325 PixelProjection proj[2];
326 for (size_t k = 0; k < numWindows; k++) {
327 projectPixel(pixel.yc, pixel.Dy, k, dydz, proj);
328 if (proj[0].Dy > 0) projections[0].push_back(proj[0]);
329 proj[1].yc = -proj[1].yc;
330 if (proj[1].Dy > 0) projections[1].push_back(proj[1]);
331 }
332 if (projections[0].empty() and projections[1].empty()) continue;
333
334 for (unsigned k = 0; k < 2; k++) {
335 std::sort(projections[k].begin(), projections[k].end());
336 for (auto& projection : projections[k]) {
337 int iDy = func::lround(projection.Dy * 1000);
338 auto& mask = masks[iDy];
339 if (not mask) {
340 double Dy = projection.Dy;
341 double step = m_quasyEnergyDistribution->step;
342 mask = new EnergyMask(D.dyB_de, D.dyB_dL, D.dyB_dx, Dy, m_length, pixel.Dx, step);
343 }
344 projection.mask = mask;
345 }
346 }
347
348 double Ecp_old = 0;
349 double wid_old = 1000;
350 m_results.push_back(Result(pixelID));
351 for (int j = j1; j < j2; j++) {
352 double ybar = j * barB - yB;
353 for (const auto& projection : projections[std::abs(j) % 2]) {
354 double Ecp = (ybar + projection.yc) / D.dyB_de + m_meanE;
355 double wid = projection.mask->getFullWidth();
356 if (std::abs(Ecp - Ecp_old) > (wid + wid_old) / 2 and m_results.back().sum > 0) {
357 m_results.push_back(Result(pixelID));
358 }
359 integrate(projection.mask, Ecp, m_results.back());
360 Ecp_old = Ecp;
361 wid_old = wid;
362 }
363 }
364
365 if (m_results.back().sum == 0) m_results.pop_back();
366 }
367
368 for (auto& result : m_results) result.set();
369
370 for (const auto& mask : masks) {
371 if (mask.second) delete mask.second;
372 }
373
374 }

◆ setEnergyDistribution()

double setEnergyDistribution ( double beta) const
private

Sets photon energy distribution and mean photon energy according to nominal PDE and particle beta.

Parameters
betaparticle beta
Returns
integral of distribution before normalization

Definition at line 194 of file YScanner.cc.

195 {
196 const auto* topgp = TOPGeometryPar::Instance();
197
198 m_energyDistribution.set(m_efficiency);
199
200 double s = 0;
201 double se = 0;
202 double see = 0;
203 for (const auto& entry : m_efficiency.entries) {
204 double e = entry.x;
205 double p = std::max(entry.y * (1 - 1 / pow(beta * topgp->getPhaseIndex(e), 2)), 0.0);
206 double ee = entry.xsq;
207 m_energyDistribution.entries.push_back(TableEntry(p, e, ee));
208 s += p;
209 se += p * e;
210 see += p * ee;
211 }
212 if (s == 0) return 0;
213
214 for (auto& entry : m_energyDistribution.entries) entry.y /= s;
215
216 m_meanE = se / s;
217 m_rmsE = sqrt(std::max(see / s - m_meanE * m_meanE, 0.0));
218
219 return s * m_energyDistribution.step;
220 }

◆ 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

◆ setQuasyEnergyDistribution()

void setQuasyEnergyDistribution ( double sigma) const
private

Sets photon energy distribution convoluted with a normalized Gaussian.

Parameters
sigmawidth of the Gaussian [eV]

Definition at line 223 of file YScanner.cc.

224 {
225 if (m_quasyEnergyDistributions.size() > 1000) {
226 m_quasyEnergyDistributions.clear();
227 B2ERROR("TOP::YScanner:setQuasyEnergyDistribution: unexpectedly large size of the std::map found, map cleared");
228 }
229
230 double step = m_energyDistribution.step;
231 int ng = func::lround(3 * sigma / step);
232 auto& quasyEnergyDistribution = m_quasyEnergyDistributions[ng];
233
234 if (quasyEnergyDistribution.entries.empty()) {
235 std::vector<double> gaus;
236 for (int i = 0; i <= ng; i++) {
237 double x = step * i / sigma;
238 gaus.push_back(exp(-0.5 * x * x));
239 }
240
241 quasyEnergyDistribution.set(m_energyDistribution.getX(-ng), step);
242 int N = m_energyDistribution.entries.size();
243 const auto* entries = m_energyDistribution.entries.data();
244 const double* gausTable = gaus.data();
245 double sum = 0;
246 for (int k = -ng; k < N + ng; k++) {
247 // outside of this range getY(k - i) is zero, so those terms contribute nothing
248 const int iMin = std::max(-ng, k - N + 1);
249 const int iMax = std::min(ng, k);
250 double s = 0;
251 double se = 0;
252 double see = 0;
253 for (int i = iMin; i <= iMax; i++) {
254 double p = gausTable[std::abs(i)] * entries[k - i].y;
255 double e = entries[k - i].x; // equals m_energyDistribution.getX(k - i)
256 s += p;
257 se += p * e;
258 see += p * e * e;
259 }
260 if (s > 0) {
261 se /= s;
262 see /= s;
263 }
264 quasyEnergyDistribution.entries.push_back(TableEntry(s, se, see));
265 sum += s;
266 }
267 for (auto& entry : quasyEnergyDistribution.entries) entry.y /= sum;
268 }
269
270 m_quasyEnergyDistribution = &quasyEnergyDistribution;
271 }

◆ setScanLimits()

static void setScanLimits ( int maxReflections)
inlinestatic

Sets parameters for selection between expand methods.

Parameters
maxReflectionsmaximal number of reflections in y to perform scan

Definition at line 240 of file YScanner.h.

241 {
242 s_maxReflections = maxReflections;
243 }

◆ tabulateSurfaceReflectivity()

double tabulateSurfaceReflectivity ( unsigned n) const
private

Extends the table of surface reflectivity powers up to n and returns the value.

Called by getSurfaceReflectivity only when the table is not long enough.

Parameters
npower, i.e. the number of reflections
Returns
reflectivity to the power of n

Definition at line 116 of file YScanner.cc.

117 {
118 double reflectivity = m_bars.front().reflectivity;
119
120 // an unreasonably large number of reflections must not blow up the table
121 if (n > s_maxTabulatedPower) return pow(reflectivity, n);
122
123 while (m_surfaceReflectivities.size() <= n) {
124 m_surfaceReflectivities.push_back(pow(reflectivity, m_surfaceReflectivities.size()));
125 }
126 return m_surfaceReflectivities[n];
127 }

Friends And Related Symbol Documentation

◆ TOPRecoManager

friend class TOPRecoManager
friend

Definition at line 547 of file YScanner.h.

Member Data Documentation

◆ m_aboveThreshold

bool m_aboveThreshold = false
mutableprivate

true if beta is above the Cerenkov threshold

Definition at line 538 of file YScanner.h.

◆ m_bars

std::vector<BarSegment> m_bars
protectedinherited

geometry data of bar segments

Definition at line 188 of file RaytracerBase.h.

◆ m_beta

double m_beta = 0
mutableprivate

particle beta

Definition at line 527 of file YScanner.h.

◆ m_cosTotal

double m_cosTotal = 0
private

cosine of total reflection angle

Definition at line 523 of file YScanner.h.

◆ m_efficiency

Table m_efficiency
private

nominal photon detection efficiencies (PDE)

Definition at line 515 of file YScanner.h.

◆ m_energyDistribution

Table m_energyDistribution
mutableprivate

photon energy distribution

Definition at line 534 of file YScanner.h.

◆ m_geometry

EGeometry m_geometry = c_Unified
protectedinherited

quartz geometry

Definition at line 185 of file RaytracerBase.h.

◆ m_halfBarThickness

double m_halfBarThickness = 0
private

half thickness of the bar at prism entrance

Definition at line 520 of file YScanner.h.

◆ m_length

double m_length = 0
mutableprivate

length of particle trajectory inside quartz

Definition at line 528 of file YScanner.h.

◆ m_meanE

double m_meanE = 0
mutableprivate

mean photon energy

Definition at line 530 of file YScanner.h.

◆ m_meanE0

double m_meanE0 = 0
private

mean photon energy for beta = 1

Definition at line 521 of file YScanner.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_momentum

double m_momentum = 0
mutableprivate

particle momentum magnitude

Definition at line 526 of file YScanner.h.

◆ m_numPhotons

double m_numPhotons = 0
mutableprivate

number of photons per Cerenkov azimuthal angle per track length

Definition at line 529 of file YScanner.h.

◆ m_optics

EOptics m_optics = c_SemiLinear
protectedinherited

spherical mirror optics

Definition at line 186 of file RaytracerBase.h.

◆ m_pixelEfficiencies

PixelEfficiencies m_pixelEfficiencies
private

pixel relative efficiencies

Definition at line 514 of file YScanner.h.

◆ m_pixelMasks

PixelMasks m_pixelMasks
private

pixel masks

Definition at line 513 of file YScanner.h.

◆ m_pixelPositions

PixelPositions m_pixelPositions
private

positions and sizes of pixels

Definition at line 512 of file YScanner.h.

◆ m_prism

Prism m_prism
protectedinherited

prism geometry data

Definition at line 190 of file RaytracerBase.h.

◆ m_prismZR

double m_prismZR = 0
private

z of the prism-bar joint (copy of m_prism.zR)

Definition at line 519 of file YScanner.h.

◆ m_quasyEnergyDistribution

Table* m_quasyEnergyDistribution = nullptr
mutableprivate

a pointer to the element in m_quasyEnergyDistributions

Definition at line 537 of file YScanner.h.

◆ m_quasyEnergyDistributions

std::map<int, Table> m_quasyEnergyDistributions
mutableprivate

photon energy distributions convoluted with Gaussian of different widths

Definition at line 536 of file YScanner.h.

◆ m_results

std::vector<Result> m_results
mutableprivate

results of PDF expansion in y

Definition at line 541 of file YScanner.h.

◆ m_rmsE

double m_rmsE = 0
mutableprivate

r.m.s of photon energy

Definition at line 531 of file YScanner.h.

◆ m_rmsE0

double m_rmsE0 = 0
private

r.m.s of photon energy for beta = 1

Definition at line 522 of file YScanner.h.

◆ m_scanDone

bool m_scanDone = false
mutableprivate

true if scan performed, false if reflections just merged

Definition at line 542 of file YScanner.h.

◆ m_sigmaAlpha

double m_sigmaAlpha = 0
mutableprivate

surface roughness parameter in photon energy units

Definition at line 533 of file YScanner.h.

◆ m_sigmaScat

double m_sigmaScat = 0
mutableprivate

r.m.s.

of multiple scattering angle in photon energy units

Definition at line 532 of file YScanner.h.

◆ m_surfaceReflectivities

std::vector<double> m_surfaceReflectivities
mutableprivate

bar surface reflectivity to the power of the index; filled on demand, never cleared

Definition at line 518 of file YScanner.h.

◆ m_windowProjections

std::vector<WindowProjection> m_windowProjections
private

pixel projection constants of unfolded prism exit windows

Definition at line 516 of file YScanner.h.

◆ s_maxReflections

int s_maxReflections = 16
staticprivate

maximal number of reflections to perform scan

Definition at line 544 of file YScanner.h.

◆ s_maxTabulatedPower

unsigned s_maxTabulatedPower = 1024
staticprivate

maximal power of the surface reflectivity that is tabulated

Definition at line 545 of file YScanner.h.


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