Belle II Software development
EnergyMask Class Reference

A mask for energy masking. More...

#include <EnergyMask.h>

Public Member Functions

 EnergyMask (double dyde, double dydL, double dydx, double dy, double dL, double dx, double dE)
 Constructor.
 
double getStep () const
 Returns energy step size of the discrete mask.
 
double getFullWidth () const
 Returns mask full width.
 
const std::vector< double > & getMask () const
 Returns discrete mask (note: only half of the mask is stored)
 
double getMask (double E) const
 Returns mask value at given energy difference by calling direct calculation of the convolution.
 
double getMask (int i) const
 Returns mask value at given index from stored discrete mask.
 
double getMask (int i, double fract) const
 Returns mask value with linear interpolation between stored discrete mask elements.
 
double getEnergyDifference (int i)
 Returns energy difference w.r.t center of mask.
 

Static Public Member Functions

static void setNMin (unsigned Nmin)
 Sets minimal size of discrete mask.
 
static void setNMax (unsigned Nmax)
 Sets maximal size of discrete mask.
 

Private Member Functions

double twoSquareConvolution (double E) const
 Returns a value of convolution of two square distributions at given photon energy using the largest two of full widths (m_A, m_B).
 
double threeSquareConvolution (double E) const
 Returns a value of convolution of three square distributions at given photon energy.
 
double mask (int i) const
 Returns mask value at given index from stored discrete mask.
 

Private Attributes

double m_dE = 0
 energy step
 
double m_Wy = 0
 enegy full width of dy
 
double m_A = 0
 the largest energy full width
 
double m_B = 0
 the middle energy full width
 
double m_C = 0
 the smallset energy full width
 
std::vector< double > m_mask
 discrete mask (half of)
 

Static Private Attributes

static unsigned s_Nmin = 4
 minimal mask size
 
static unsigned s_Nmax = 256
 maximal mask size
 

Detailed Description

A mask for energy masking.

Definition at line 24 of file EnergyMask.h.

Constructor & Destructor Documentation

◆ EnergyMask()

EnergyMask ( double  dyde,
double  dydL,
double  dydx,
double  dy,
double  dL,
double  dx,
double  dE 
)

Constructor.

Parameters
dydederivative dy/de [cm/eV]
dydLderivative dy/dL
dydxderivative dy/dx
dyeffective PMT pad size in y [cm]
dLlength of particle trajectory within the quartz [cm]
dxPMT pad size in x [cm]
dEenergy step [eV]

Definition at line 25 of file EnergyMask.cc.

25 :
26 m_dE(dE), m_Wy(dy / std::abs(dyde))
27 {
28 if (dy <= 0) {
29 B2ERROR("TOP::EnergyMask: dy must be > 0");
30 return;
31 }
32
33 std::vector<double> x;
34 x.push_back(m_Wy);
35 x.push_back(std::abs(dL * dydL / dyde));
36 x.push_back(std::abs(dx * dydx / dyde));
37 std::sort(x.begin(), x.end());
38
39 m_A = x[2];
40 m_B = x[1];
41 m_C = x[0];
42
43 unsigned N = (m_A + m_B + m_C) / 2.0 / dE + 1;
44 if (N < s_Nmin or N > s_Nmax) return;
45
46 if (m_C / m_A > 0.001) {
47 for (unsigned i = 0; i <= N; i++) {
48 double E = i * dE;
49 double p = threeSquareConvolution(E);
50 m_mask.push_back(p);
51 }
52 } else {
53 for (unsigned i = 0; i <= N; i++) {
54 double E = i * dE;
55 double p = twoSquareConvolution(E);
56 m_mask.push_back(p);
57 }
58 }
59 }
R E
internal precision of FFTW codelets
double threeSquareConvolution(double E) const
Returns a value of convolution of three square distributions at given photon energy.
Definition: EnergyMask.cc:107
double m_C
the smallset energy full width
Definition: EnergyMask.h:129
double twoSquareConvolution(double E) const
Returns a value of convolution of two square distributions at given photon energy using the largest t...
Definition: EnergyMask.cc:91
double m_Wy
enegy full width of dy
Definition: EnergyMask.h:126
std::vector< double > m_mask
discrete mask (half of)
Definition: EnergyMask.h:130
double m_A
the largest energy full width
Definition: EnergyMask.h:127
double m_B
the middle energy full width
Definition: EnergyMask.h:128
double m_dE
energy step
Definition: EnergyMask.h:125
static unsigned s_Nmax
maximal mask size
Definition: EnergyMask.h:133

Member Function Documentation

◆ getEnergyDifference()

double getEnergyDifference ( int  i)
inline

Returns energy difference w.r.t center of mask.

Parameters
iindex (all values are valid)
Returns
energy difference w.r.t center of mask [eV]

Definition at line 99 of file EnergyMask.h.

99{return i * m_dE;}

◆ getFullWidth()

double getFullWidth ( ) const
inline

Returns mask full width.

Returns
full width [eV]

Definition at line 62 of file EnergyMask.h.

62{return m_A + m_B + m_C;}

◆ getMask() [1/4]

const std::vector< double > & getMask ( ) const
inline

Returns discrete mask (note: only half of the mask is stored)

Returns
discrete mask

Definition at line 68 of file EnergyMask.h.

68{return m_mask;}

◆ getMask() [2/4]

double getMask ( double  E) const

Returns mask value at given energy difference by calling direct calculation of the convolution.

Parameters
Ephoton energy difference w.r.t center of mask [eV]
Returns
mask value

Definition at line 62 of file EnergyMask.cc.

63 {
64 if (m_C / m_A > 0.001) {
66 } else {
67 return twoSquareConvolution(E);
68 }
69 }

◆ getMask() [3/4]

double getMask ( int  i) const

Returns mask value at given index from stored discrete mask.

If discrete mask is empty it calls direct calculation of convolution.

Parameters
iindex (all values are valid)
Returns
mask value

Definition at line 72 of file EnergyMask.cc.

73 {
74 if (m_mask.empty()) return getMask(i * m_dE);
75 return mask(i);
76 }
const std::vector< double > & getMask() const
Returns discrete mask (note: only half of the mask is stored)
Definition: EnergyMask.h:68
double mask(int i) const
Returns mask value at given index from stored discrete mask.
Definition: EnergyMask.h:138

◆ getMask() [4/4]

double getMask ( int  i,
double  fract 
) const

Returns mask value with linear interpolation between stored discrete mask elements.

If discrete mask is empty it calls direct calculation of convolution.

Parameters
iindex (all values are valid)
fractfractional part for linear interpolation (values btw. -0.5 and 0.5)
Returns
mask value

Definition at line 79 of file EnergyMask.cc.

80 {
81 if (m_mask.empty()) return getMask((i + fract) * m_dE);
82
83 if (fract < 0) {
84 i--;
85 fract += 1;
86 }
87 return mask(i) * (1 - fract) + mask(i + 1) * fract;
88 }

◆ getStep()

double getStep ( ) const
inline

Returns energy step size of the discrete mask.

Returns
step [eV]

Definition at line 56 of file EnergyMask.h.

56{return m_dE;}

◆ mask()

double mask ( int  i) const
inlineprivate

Returns mask value at given index from stored discrete mask.

Parameters
iindex (all values are valid)
Returns
mask value or 0 if index is out of array range

Definition at line 138 of file EnergyMask.h.

139 {
140 unsigned k = std::abs(i);
141 if (k < m_mask.size()) return m_mask[k];
142 return 0;
143 }

◆ setNMax()

static void setNMax ( unsigned  Nmax)
inlinestatic

Sets maximal size of discrete mask.

Parameters
Nmaxmaximal size

Definition at line 50 of file EnergyMask.h.

50{s_Nmax = Nmax;}

◆ setNMin()

static void setNMin ( unsigned  Nmin)
inlinestatic

Sets minimal size of discrete mask.

Parameters
Nminminimal size

Definition at line 44 of file EnergyMask.h.

44{s_Nmin = Nmin;}
static unsigned s_Nmin
minimal mask size
Definition: EnergyMask.h:132

◆ threeSquareConvolution()

double threeSquareConvolution ( double  E) const
private

Returns a value of convolution of three square distributions at given photon energy.

Parameters
Ephoton energy difference w.r.t center of mask [eV]
Returns
convolution value

Definition at line 107 of file EnergyMask.cc.

108 {
109 double halfWid = (m_A + m_B + m_C) / 2;
110 if (std::abs(E) >= halfWid) return 0;
111
112 double t1 = halfWid - E;
113 double t2 = halfWid + E;
114 double p = t1 * t1 + t2 * t2;
115
116 double t3 = t1 - m_A;
117 double t4 = t2 - m_A;
118 p -= copysign(t3 * t3, t3) + copysign(t4 * t4, t4);
119
120 t3 = t1 - m_B;
121 t4 = t2 - m_B;
122 p -= copysign(t3 * t3, t3) + copysign(t4 * t4, t4);
123
124 t3 = t1 - m_C;
125 t4 = t2 - m_C;
126 p -= copysign(t3 * t3, t3) + copysign(t4 * t4, t4);
127
128 return p / (4 * m_A * m_B * m_C) * m_Wy;
129 }

◆ twoSquareConvolution()

double twoSquareConvolution ( double  E) const
private

Returns a value of convolution of two square distributions at given photon energy using the largest two of full widths (m_A, m_B).

Parameters
Ephoton energy difference w.r.t center of mask [eV]
Returns
convolution value

Definition at line 91 of file EnergyMask.cc.

92 {
93 double x1 = (m_A - m_B) / 2;
94 double x2 = (m_A + m_B) / 2;
95 double x = std::abs(E);
96
97 if (x < x1) {
98 return 1 / m_A * m_Wy;
99 } else if (x < x2) {
100 return (x2 - x) / (x2 - x1) / m_A * m_Wy;
101 } else {
102 return 0;
103 }
104 }

Member Data Documentation

◆ m_A

double m_A = 0
private

the largest energy full width

Definition at line 127 of file EnergyMask.h.

◆ m_B

double m_B = 0
private

the middle energy full width

Definition at line 128 of file EnergyMask.h.

◆ m_C

double m_C = 0
private

the smallset energy full width

Definition at line 129 of file EnergyMask.h.

◆ m_dE

double m_dE = 0
private

energy step

Definition at line 125 of file EnergyMask.h.

◆ m_mask

std::vector<double> m_mask
private

discrete mask (half of)

Definition at line 130 of file EnergyMask.h.

◆ m_Wy

double m_Wy = 0
private

enegy full width of dy

Definition at line 126 of file EnergyMask.h.

◆ s_Nmax

unsigned s_Nmax = 256
staticprivate

maximal mask size

Definition at line 133 of file EnergyMask.h.

◆ s_Nmin

unsigned s_Nmin = 4
staticprivate

minimal mask size

Definition at line 132 of file EnergyMask.h.


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