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...
 

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

 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 lenght 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.
 
const TablegetEnergyDistribution () const
 Returns photon energy distribution.
 
const std::map< int, TablegetQuasyEnergyDistributions () 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 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.
 

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).
 
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)
 
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
 

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

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

◆ 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 47 of file YScanner.cc.

48 m_pixelPositions(PixelPositions(moduleID)),
49 m_pixelMasks(PixelMasks(moduleID)),
50 m_pixelEfficiencies(PixelEfficiencies(moduleID))
51 {
52 if (N < 2) {
53 B2FATAL("TOP::YScanner: N must be > 1");
54 return;
55 }
56
57 // set the table of nominal photon detection efficiencies (incl. wavelength filter)
58
59 const auto* topgp = TOPGeometryPar::Instance();
60 const auto* geo = topgp->getGeometry();
61 auto qe = geo->getNominalQE(); // get a copy
62 qe.applyFilterTransmission(geo->getWavelengthFilter());
63
64 double minE = TOPGeometryPar::c_hc / qe.getMaxLambda();
65 double maxE = TOPGeometryPar::c_hc / qe.getMinLambda();
66 if (minE >= maxE) {
67 B2FATAL("TOP::YScanner: quantum efficiency found zero for all wavelengths");
68 return;
69 }
70 m_efficiency.set(minE, (maxE - minE) / (N - 1));
71
72 const auto& tdc = geo->getNominalTDC();
73 for (unsigned i = 0; i < N; i++) {
74 double e = m_efficiency.getX(i);
75 double lambda = TOPGeometryPar::c_hc / e;
76 double effi = qe.getEfficiency(lambda) * tdc.getEfficiency();
77 m_efficiency.entries.push_back(TableEntry(effi, e, e * e));
78 }
79
80 // set cosine of total reflection angle using photon mean energy for beta = 1
81
82 double s = 0;
83 double se = 0;
84 double see = 0;
85 for (const auto& entry : m_efficiency.entries) {
86 double e = entry.x;
87 double p = entry.y * (1 - 1 / pow(topgp->getPhaseIndex(e), 2));
88 s += p;
89 se += p * e;
90 see += p * e * e;
91 }
92 if (s == 0) return;
93 m_meanE0 = se / s;
94 m_rmsE0 = sqrt(see / s - m_meanE0 * m_meanE0);
95 m_cosTotal = sqrt(1 - 1 / pow(topgp->getPhaseIndex(m_meanE0), 2));
96 }
RaytracerBase(int moduleID, EGeometry geometry=c_Unified, EOptics optics=c_SemiLinear)
Constructor.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
static const double c_hc
Planck constant times speed of light in [eV*nm].
double m_cosTotal
cosine of total reflection angle
Definition: YScanner.h:459
PixelEfficiencies m_pixelEfficiencies
pixel relative efficiencies
Definition: YScanner.h:455
Table m_efficiency
nominal photon detection efficiencies (PDE)
Definition: YScanner.h:456
double m_meanE0
mean photon energy for beta = 1
Definition: YScanner.h:457
PixelMasks m_pixelMasks
pixel masks
Definition: YScanner.h:454
double m_rmsE0
r.m.s of photon energy for beta = 1
Definition: YScanner.h:458
PixelPositions m_pixelPositions
positions and sizes of pixels
Definition: YScanner.h:453
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
std::vector< TableEntry > entries
table entries
Definition: YScanner.h:121
double getX(int i) const
Returns x for a given index.
Definition: YScanner.h:532
void set(double X0, double Step)
Sets the first x and the step, and clears the entries.
Definition: YScanner.h:518

Member Function Documentation

◆ clear()

void clear ( ) const

Clear mutable variables.

Definition at line 99 of file YScanner.cc.

100 {
101 m_momentum = 0;
102 m_beta = 0;
103 m_length = 0;
104 m_numPhotons = 0;
105 m_meanE = 0;
106 m_rmsE = 0;
107 m_sigmaScat = 0;
108 m_sigmaAlpha = 0;
112 m_aboveThreshold = false;
113 m_results.clear();
114 m_scanDone = false;
115 }
Table m_energyDistribution
photon energy distribution
Definition: YScanner.h:470
double m_beta
particle beta
Definition: YScanner.h:463
bool m_scanDone
true if scan performed, false if reflections just merged
Definition: YScanner.h:478
double m_meanE
mean photon energy
Definition: YScanner.h:466
double m_rmsE
r.m.s of photon energy
Definition: YScanner.h:467
bool m_aboveThreshold
true if beta is above the Cerenkov threshold
Definition: YScanner.h:474
double m_sigmaScat
r.m.s.
Definition: YScanner.h:468
double m_momentum
particle momentum magnitude
Definition: YScanner.h:462
Table * m_quasyEnergyDistribution
a pointer to the element in m_quasyEnergyDistributions
Definition: YScanner.h:473
std::map< int, Table > m_quasyEnergyDistributions
photon energy distributions convoluted with Gaussian of different widths
Definition: YScanner.h:472
double m_length
length of particle trajectory inside quartz
Definition: YScanner.h:464
std::vector< Result > m_results
results of PDF expansion in y
Definition: YScanner.h:477
double m_numPhotons
number of photons per Cerenkov azimuthal angle per track length
Definition: YScanner.h:465
double m_sigmaAlpha
surface roughness parameter in photon energy units
Definition: YScanner.h:469
void clear()
Clear the content entirely.
Definition: YScanner.h:511

◆ 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 accessable 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 238 of file YScanner.cc.

239 {
240 m_results.clear();
241
242 if (D.dyB_de == 0) return;
243
244 double sigma = sqrt(pow(m_sigmaScat, 2) + pow(m_sigmaAlpha, 2) * std::abs(Ny));
246
247 double minE = m_quasyEnergyDistribution->getXmin();
248 double maxE = m_quasyEnergyDistribution->getXmax();
249 double pixDx = m_pixelPositions.get(col + 1).Dx;
250 double dely = (std::abs(D.dyB_dL) * m_length + std::abs(D.dyB_dx) * pixDx) / 2;
251 double y1 = yB - dely;
252 double y2 = yB + dely;
253 if (D.dyB_de > 0) {
254 y1 += D.dyB_de * (minE - m_meanE);
255 y2 += D.dyB_de * (maxE - m_meanE);
256 } else {
257 y1 += D.dyB_de * (maxE - m_meanE);
258 y2 += D.dyB_de * (minE - m_meanE);
259 }
260 double B = m_bars.front().B;
261 int j1 = lround(y1 / B);
262 int j2 = lround(y2 / B) + 1;
263
264 if (doScan and j2 - j1 <= s_maxReflections) {
265 scan(col, yB, dydz, D, j1, j2);
266 m_scanDone = true;
267 } else {
268 merge(col, dydz, j1, j2);
269 m_scanDone = false;
270 }
271 }
const PixelData & get(int pixelID) const
Returns pixel data for given pixelID.
std::vector< BarSegment > m_bars
geometry data of bar segments
static int s_maxReflections
maximal number of reflections to perform scan
Definition: YScanner.h:480
void merge(unsigned col, double dydz, int j1, int j2) const
Performs expansion by merging all reflections.
Definition: YScanner.cc:337
void scan(unsigned col, double yB, double dydz, const Derivatives &D, int j1, int j2) const
Performs expansion w/ the scan over reflections.
Definition: YScanner.cc:274
void setQuasyEnergyDistribution(double sigma) const
Sets photon energy distribution convoluted with a normalized Gaussian.
Definition: YScanner.cc:192
double getXmax() const
Returns x of the last entry.
Definition: YScanner.h:536
double getXmin() const
Returns x of the first entry.
Definition: YScanner.h:534

◆ 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 305 of file YScanner.h.

305{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 293 of file YScanner.h.

293{return m_cosTotal;}

◆ getEfficiencies()

const Table & getEfficiencies ( ) const
inline

Returns nominal photon detection efficiencies (PDE)

Returns
nominal photon detection efficiencies

Definition at line 287 of file YScanner.h.

287{return m_efficiency;}

◆ getEnergyDistribution()

const Table & getEnergyDistribution ( ) const
inline

Returns photon energy distribution.

Returns
photon energy distribution

Definition at line 365 of file YScanner.h.

365{return m_energyDistribution;}

◆ 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

◆ getMeanEnergy()

double getMeanEnergy ( ) const
inline

Returns mean photon energy.

Returns
mean photon energy

Definition at line 329 of file YScanner.h.

329{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 341 of file YScanner.h.

341{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;}
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;}

◆ getMomentum()

double getMomentum ( ) const
inline

Returns particle momentum.

Returns
particle momentum

Definition at line 299 of file YScanner.h.

299{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 323 of file YScanner.h.

323{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 317 of file YScanner.h.

317{return m_numPhotons;}

◆ 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

◆ getPixelEfficiencies()

const PixelEfficiencies & getPixelEfficiencies ( ) const
inline

Returns pixel relative efficiencies.

Returns
pixel relative efficiencies

Definition at line 281 of file YScanner.h.

281{return m_pixelEfficiencies;}

◆ getPixelMasks()

const PixelMasks & getPixelMasks ( ) const
inline

Returns pixel masks.

Returns
pixel masks

Definition at line 275 of file YScanner.h.

275{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 269 of file YScanner.h.

269{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;}
Prism m_prism
prism geometry data

◆ 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 372 of file YScanner.h.

◆ getResults()

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

Returns the results of PDF expansion in y.

Returns
results

Definition at line 378 of file YScanner.h.

378{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 335 of file YScanner.h.

335{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 347 of file YScanner.h.

347{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 359 of file YScanner.h.

359{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 353 of file YScanner.h.

353{return m_sigmaScat;}

◆ getTrackLengthInQuartz()

double getTrackLengthInQuartz ( ) const
inline

Returns particle trajectory lenght inside quartz.

Returns
particle trajectory lenght inside quartz

Definition at line 311 of file YScanner.h.

311{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 368 of file YScanner.cc.

369 {
370 const auto& mask = energyMask->getMask();
371
372 if (mask.empty()) {
373 // direct mask calculation
374 for (size_t i = 0; i < m_quasyEnergyDistribution->entries.size(); i++) {
375 double E = m_quasyEnergyDistribution->getX(i);
376 double m = energyMask->getMask(E - Ecp);
377 if (m > 0) {
378 const auto& entry = m_quasyEnergyDistribution->entries[i];
379 double s = entry.y * m;
380 result.sum += s;
381 result.e0 += entry.x * s;
382 result.sigsq += entry.xsq * s;
383 }
384 }
385 } else {
386 // pre-calculated discrete mask w/ linear interpolation
387 int i0 = m_quasyEnergyDistribution->getIndex(Ecp);
388 double fract = -(Ecp - m_quasyEnergyDistribution->getX(i0)) / m_quasyEnergyDistribution->step;
389 if (fract < 0) {
390 i0++;
391 fract += 1;
392 }
393 int N = m_quasyEnergyDistribution->entries.size() - 1;
394 int M = mask.size() - 1;
395 int i1 = std::max(i0 - M, 0);
396 int i2 = std::min(i0 + M - 1, N);
397 for (int i = i1; i <= i2; i++) {
398 const auto& entry = m_quasyEnergyDistribution->entries[i];
399 double m = mask[std::abs(i - i0)] * (1 - fract) + mask[std::abs(i - i0 + 1)] * fract;
400 double s = entry.y * m;
401 result.sum += s;
402 result.e0 += entry.x * s;
403 result.sigsq += entry.xsq * s;
404 }
405 }
406 }
R E
internal precision of FFTW codelets
double step
step size
Definition: YScanner.h:120
int getIndex(double x) const
Returns index.
Definition: YScanner.h:538

◆ 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 251 of file YScanner.h.

251{return m_aboveThreshold;}

◆ isScanDone()

bool isScanDone ( ) const
inline

Checks which expansion method was used.

Returns
true if scan, false if merge

Definition at line 384 of file YScanner.h.

384{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 337 of file YScanner.cc.

338 {
339 int Neven = func::getNumOfEven(j1, j2);
340 int Nodd = j2 - j1 - Neven;
341
342 for (unsigned row = 0; row < m_pixelPositions.getNumPixelRows(); row++) {
343
344 int pixelID = m_pixelPositions.pixelID(row, col);
345 if (not m_pixelMasks.isActive(pixelID)) continue;
346
347 const auto& pixel = m_pixelPositions.get(pixelID);
348 double Dy0 = 0;
349 double Dy1 = 0;
350 PixelProjection proj[2];
351 for (size_t k = 0; k < m_prism.unfoldedWindows.size(); k++) {
352 projectPixel(pixel.yc, pixel.Dy, k, dydz, proj);
353 if (proj[0].Dy > 0) Dy0 += proj[0].Dy;
354 if (proj[1].Dy > 0) Dy1 += proj[1].Dy;
355 }
356 if (Dy0 == 0 and Dy1 == 0) continue;
357
358 double Dy = (Dy0 * Neven + Dy1 * Nodd) / (Neven + Nodd);
359 Result result(pixelID);
360 result.sum = Dy / m_bars.front().B;
361 result.e0 = m_meanE;
362 result.sigsq = m_rmsE * m_rmsE;
363 m_results.push_back(result);
364 }
365 }
bool isActive(int pixelID) const
Checks if pixel is active.
Definition: PixelMasks.h:85
int pixelID(unsigned row, unsigned col) const
Transforms pixel row and column to pixel ID Note: for convenience pixel row and column numbering star...
unsigned getNumPixelRows() const
Returns the number of pixel rows.
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).
Definition: YScanner.cc:409
int getNumOfEven(int j1, int j2)
Returns number of even numbers in the range given by arguments.
Definition: func.h:92
std::vector< TOPGeoPrism::UnfoldedWindow > unfoldedWindows
unfolded prism exit windows

◆ pixelEfficiencies()

PixelEfficiencies & pixelEfficiencies ( )
inlineprivate

Returns non-const pixel relative efficiencies.

Returns
pixel relative efficiencies

Definition at line 450 of file YScanner.h.

450{return m_pixelEfficiencies;}

◆ pixelMasks()

PixelMasks & pixelMasks ( )
inlineprivate

Returns non-const pixel masks.

Returns
pixel masks

Definition at line 444 of file YScanner.h.

444{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 118 of file YScanner.cc.

119 {
120 clear();
121
122 m_momentum = momentum;
123 m_beta = beta;
124 m_length = length;
125
126 // check for Cherenkov threshold, return if below
127
128 const auto* topgp = TOPGeometryPar::Instance();
129 if (beta * topgp->getPhaseIndex(m_meanE0) < 1) return;
130
131 // set photon energy distribution, and the mean and r.m.s of photon energy
132
133 auto area = setEnergyDistribution(beta);
134 if (area == 0) return;
135
136 // set number of Cerenkov photons per azimuthal angle per centimeter
137
138 m_numPhotons = 370 * area / (2 * M_PI);
139
140 // set multiple scattering and surface roughness sigmas in photon energy units
141
142 const double radLength = 12.3; // quartz radiation length [cm]
143 double thetaScat = 13.6e-3 / beta / momentum * sqrt(length / 2 / radLength); // r.m.s of multiple scattering angle
144
145 double n = topgp->getPhaseIndex(m_meanE);
146 if (beta * n < 1) {
147 B2ERROR("TOP::YScanner::prepare: beta * n < 1 ==> must be a bug!");
148 return;
149 }
150 double dndE = topgp->getPhaseIndexDerivative(m_meanE);
151 double dEdTheta = n * sqrt(pow(beta * n, 2) - 1) / dndE;
152 m_sigmaScat = std::abs(thetaScat * dEdTheta); // r.m.s of multiple scattering angle converted to photon energy
153 m_sigmaAlpha = std::abs(m_bars.back().sigmaAlpha * dEdTheta); // surface roughness converted to photon energy
154
155 // set photon energy distribution convoluted with multiple scattering
156
158
159 m_aboveThreshold = true;
160 }
double setEnergyDistribution(double beta) const
Sets photon energy distribution and mean photon energy according to nominal PDE and particle beta.
Definition: YScanner.cc:163
void clear() const
Clear mutable variables.
Definition: YScanner.cc:99

◆ projectPixel()

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

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 409 of file YScanner.cc.

410 {
411 double halfSize = (k - m_prism.k0) % 2 == 0 ? size / 2 : -size / 2;
412 const double ypix[2] = {yc - halfSize, yc + halfSize}; // pixel edges in y
413 double yproj[2][2] = {{0}}; // pixel projections to prism entrance window (second index corresponds to pixel edges)
414
415 const auto& win = m_prism.unfoldedWindows[k];
416 double dz = std::abs(m_prism.zD - m_prism.zFlat);
417 double projectedY = win.y0 + win.ny * dz;
418 double projectedZ = win.z0 + win.nz * dz;
419
420 #pragma omp simd
421 for (int i = 0; i < 2; ++i) {
422 /* Formerly YScanner::prismEntranceY. */
423 double z = ypix[i] * win.sz + projectedZ;
424 double y = ypix[i] * win.sy + projectedY;
425 double dy = dydz * (m_prism.zR - z);
426 yproj[0][i] = y + dy; // even reflections
427 yproj[1][i] = y - dy; // odd reflections
428 }
429
430 double Bh = m_bars.front().B / 2;
431 for (int i = 0; i < 2; ++i) {
432 yproj[i][0] = std::max(yproj[i][0], -Bh);
433 yproj[i][1] = std::min(yproj[i][1], Bh);
434 proj[i].yc = (yproj[i][0] + yproj[i][1]) / 2;
435 proj[i].Dy = yproj[i][1] - yproj[i][0];
436 }
437 }
double zFlat
z where flat continues to slanted surface
double zR
maximal z, i.e position of prism-bar joint
double zD
detector (photo-cathode) position
int k0
index of true prism in the vector 'unfoldedWindows'

◆ 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 274 of file YScanner.cc.

275 {
276
277 std::map<int, EnergyMask*> masks;
278 for (unsigned row = 0; row < m_pixelPositions.getNumPixelRows(); row++) {
279
280 int pixelID = m_pixelPositions.pixelID(row, col);
281 if (not m_pixelMasks.isActive(pixelID)) continue;
282
283 const auto& pixel = m_pixelPositions.get(pixelID);
284 std::vector<PixelProjection> projections[2];
285 PixelProjection proj[2];
286 for (size_t k = 0; k < m_prism.unfoldedWindows.size(); k++) {
287 projectPixel(pixel.yc, pixel.Dy, k, dydz, proj);
288 if (proj[0].Dy > 0) projections[0].push_back(proj[0]);
289 proj[1].yc = -proj[1].yc;
290 if (proj[1].Dy > 0) projections[1].push_back(proj[1]);
291 }
292 if (projections[0].empty() and projections[1].empty()) continue;
293
294 for (unsigned k = 0; k < 2; k++) {
295 std::sort(projections[k].begin(), projections[k].end());
296 for (auto& projection : projections[k]) {
297 int iDy = lround(projection.Dy * 1000);
298 auto& mask = masks[iDy];
299 if (not mask) {
300 double Dy = projection.Dy;
301 double step = m_quasyEnergyDistribution->step;
302 mask = new EnergyMask(D.dyB_de, D.dyB_dL, D.dyB_dx, Dy, m_length, pixel.Dx, step);
303 }
304 projection.mask = mask;
305 }
306 }
307
308 double Ecp_old = 0;
309 double wid_old = 1000;
310 m_results.push_back(Result(pixelID));
311 for (int j = j1; j < j2; j++) {
312 double ybar = j * m_bars.front().B - yB;
313 for (const auto& projection : projections[std::abs(j) % 2]) {
314 double Ecp = (ybar + projection.yc) / D.dyB_de + m_meanE;
315 double wid = projection.mask->getFullWidth();
316 if (std::abs(Ecp - Ecp_old) > (wid + wid_old) / 2 and m_results.back().sum > 0) {
317 m_results.push_back(Result(pixelID));
318 }
319 integrate(projection.mask, Ecp, m_results.back());
320 Ecp_old = Ecp;
321 wid_old = wid;
322 }
323 }
324
325 if (m_results.back().sum == 0) m_results.pop_back();
326 }
327
328 for (auto& result : m_results) result.set();
329
330 for (auto& mask : masks) {
331 if (mask.second) delete mask.second;
332 }
333
334 }
void integrate(const EnergyMask *energyMask, double Ecp, Result &result) const
Integrates quasy energy distribution multiplied with energy mask.
Definition: YScanner.cc:368

◆ 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 163 of file YScanner.cc.

164 {
165 const auto* topgp = TOPGeometryPar::Instance();
166
168
169 double s = 0;
170 double se = 0;
171 double see = 0;
172 for (const auto& entry : m_efficiency.entries) {
173 double e = entry.x;
174 double p = std::max(entry.y * (1 - 1 / pow(beta * topgp->getPhaseIndex(e), 2)), 0.0);
175 double ee = entry.xsq;
176 m_energyDistribution.entries.push_back(TableEntry(p, e, ee));
177 s += p;
178 se += p * e;
179 see += p * ee;
180 }
181 if (s == 0) return 0;
182
183 for (auto& entry : m_energyDistribution.entries) entry.y /= s;
184
185 m_meanE = se / s;
186 m_rmsE = sqrt(std::max(see / s - m_meanE * m_meanE, 0.0));
187
188 return s * m_energyDistribution.step;
189 }

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

◆ 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 192 of file YScanner.cc.

193 {
194 if (m_quasyEnergyDistributions.size() > 1000) {
196 B2ERROR("TOP::YScanner:setQuasyEnergyDistribution: unexpectedly large size of the std::map found, map cleared");
197 }
198
199 double step = m_energyDistribution.step;
200 int ng = lround(3 * sigma / step);
201 auto& quasyEnergyDistribution = m_quasyEnergyDistributions[ng];
202
203 if (quasyEnergyDistribution.entries.empty()) {
204 std::vector<double> gaus;
205 for (int i = 0; i <= ng; i++) {
206 double x = step * i / sigma;
207 gaus.push_back(exp(-0.5 * x * x));
208 }
209
210 quasyEnergyDistribution.set(m_energyDistribution.getX(-ng), step);
211 int N = m_energyDistribution.entries.size();
212 double sum = 0;
213 for (int k = -ng; k < N + ng; k++) {
214 double s = 0;
215 double se = 0;
216 double see = 0;
217 for (int i = -ng; i <= ng; i++) {
218 double p = gaus[std::abs(i)] * m_energyDistribution.getY(k - i);
219 double e = m_energyDistribution.getX(k - i);
220 s += p;
221 se += p * e;
222 see += p * e * e;
223 }
224 if (s > 0) {
225 se /= s;
226 see /= s;
227 }
228 quasyEnergyDistribution.entries.push_back(TableEntry(s, se, see));
229 sum += s;
230 }
231 for (auto& entry : quasyEnergyDistribution.entries) entry.y /= sum;
232 }
233
234 m_quasyEnergyDistribution = &quasyEnergyDistribution;
235 }
double getY(int i) const
Returns y for a given index.
Definition: YScanner.h:540

◆ 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 227 of file YScanner.h.

228 {
229 s_maxReflections = maxReflections;
230 }

Friends And Related Function Documentation

◆ TOPRecoManager

friend class TOPRecoManager
friend

Definition at line 482 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 474 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 463 of file YScanner.h.

◆ m_cosTotal

double m_cosTotal = 0
private

cosine of total reflection angle

Definition at line 459 of file YScanner.h.

◆ m_efficiency

Table m_efficiency
private

nominal photon detection efficiencies (PDE)

Definition at line 456 of file YScanner.h.

◆ m_energyDistribution

Table m_energyDistribution
mutableprivate

photon energy distribution

Definition at line 470 of file YScanner.h.

◆ m_geometry

EGeometry m_geometry = c_Unified
protectedinherited

quartz geometry

Definition at line 185 of file RaytracerBase.h.

◆ m_length

double m_length = 0
mutableprivate

length of particle trajectory inside quartz

Definition at line 464 of file YScanner.h.

◆ m_meanE

double m_meanE = 0
mutableprivate

mean photon energy

Definition at line 466 of file YScanner.h.

◆ m_meanE0

double m_meanE0 = 0
private

mean photon energy for beta = 1

Definition at line 457 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 462 of file YScanner.h.

◆ m_numPhotons

double m_numPhotons = 0
mutableprivate

number of photons per Cerenkov azimuthal angle per track length

Definition at line 465 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 455 of file YScanner.h.

◆ m_pixelMasks

PixelMasks m_pixelMasks
private

pixel masks

Definition at line 454 of file YScanner.h.

◆ m_pixelPositions

PixelPositions m_pixelPositions
private

positions and sizes of pixels

Definition at line 453 of file YScanner.h.

◆ m_prism

Prism m_prism
protectedinherited

prism geometry data

Definition at line 190 of file RaytracerBase.h.

◆ m_quasyEnergyDistribution

Table* m_quasyEnergyDistribution = nullptr
mutableprivate

a pointer to the element in m_quasyEnergyDistributions

Definition at line 473 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 472 of file YScanner.h.

◆ m_results

std::vector<Result> m_results
mutableprivate

results of PDF expansion in y

Definition at line 477 of file YScanner.h.

◆ m_rmsE

double m_rmsE = 0
mutableprivate

r.m.s of photon energy

Definition at line 467 of file YScanner.h.

◆ m_rmsE0

double m_rmsE0 = 0
private

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

Definition at line 458 of file YScanner.h.

◆ m_scanDone

bool m_scanDone = false
mutableprivate

true if scan performed, false if reflections just merged

Definition at line 478 of file YScanner.h.

◆ m_sigmaAlpha

double m_sigmaAlpha = 0
mutableprivate

surface roughness parameter in photon energy units

Definition at line 469 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 468 of file YScanner.h.

◆ s_maxReflections

int s_maxReflections = 16
staticprivate

maximal number of reflections to perform scan

Definition at line 480 of file YScanner.h.


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