Belle II Software development
DeltaRayPDF.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <top/reconstruction_cpp/DeltaRayPDF.h>
10#include <top/reconstruction_cpp/TOPRecoManager.h>
11#include <top/geometry/TOPGeometryPar.h>
12#include <framework/logging/Logger.h>
13#include <cmath>
14
15using namespace std;
16
17namespace Belle2 {
22 namespace TOP {
23
25 m_moduleID(moduleID), m_background(TOPRecoManager::getBackgroundPDF(moduleID))
26 {
27 if (not m_background) {
28 B2ERROR("TOP::DeltaRayPDF: background PDF not found");
29 return;
30 }
31
32 const auto* yScanner = TOPRecoManager::getYScanner(moduleID);
33 if (not yScanner) {
34 B2ERROR("TOP::DeltaRayPDF: YScanner not found");
35 return;
36 }
37
38 m_pixelPositions = &(yScanner->getPixelPositions());
39
40 m_zD = yScanner->getPrism().zD;
41 m_zM = yScanner->getBars().back().zR;
42 double meanE = yScanner->getMeanEnergyBeta1();
43 double sigE = yScanner->getRMSEnergyBeta1();
46 double dng_de = TOPGeometryPar::Instance()->getGroupIndexDerivative(meanE);
47 m_dispersion = dng_de / m_groupIndex * sigE;
48
49 const int N = 1000;
50 double dkz = 1.0 / N;
51 m_norms.push_back(0);
52 for (int i = 0; i < N; i++) {
53 double kz = (i + 0.5) * dkz;
54 m_angularNorm += angularDistr(kz) * dkz;
55 m_norms.push_back(m_angularNorm);
56 }
57 for (auto& norm : m_norms) norm /= m_angularNorm;
58
59 const int Np = 101;
60 double dx = 6.0 / (Np - 1);
61 for (int i = 0; i < Np; i++) {
62 double x = i * dx - 3.0;
63 m_tableGaus.push_back(GausXY(x));
64 }
65 double sum = 0;
66 for (const auto& gaus : m_tableGaus) sum += gaus.y;
67 for (auto& gaus : m_tableGaus) gaus.y /= sum;
68 }
69
70 void DeltaRayPDF::prepare(const TOPTrack& track, const Const::ChargedStable& hypothesis)
71 {
72 const auto& emi = track.getEmissionPoint().position;
73 m_xE = emi.X();
74 m_yE = emi.Y();
75 m_zE = emi.Z();
79 m_TOF = track.getTOF(hypothesis);
80
81 if (m_dirT0 < 0) {
82 B2ERROR("TOP::DeltaRayPDF::prepare: T0 direct is negative -> set to 0");
83 m_dirT0 = 0;
84 }
85 if (m_reflT0 < 0) {
86 B2ERROR("TOP::DeltaRayPDF::prepare: T0 reflected is negative -> set to 0");
87 m_reflT0 = 0;
88 }
89
90 double beta = track.getBeta(hypothesis);
91 int PDGCode = std::abs(hypothesis.getPDGCode());
92 if (PDGCode < 20) PDGCode = -PDGCode;
93 if (track.getCharge() < 0) PDGCode = -PDGCode;
94 double tlen = track.getLengthInQuartz();
95 double tmin = TOPRecoManager::getMinTime();
96 double tmax = TOPRecoManager::getMaxTime();
97 double relEffi = m_background->getEfficiency();
98 m_fraction = totalFraction(tmin, tmax);
99 m_numPhotons = photonYield(beta, PDGCode) * tlen * m_fraction * relEffi;
100
101 for (const auto& pixel : m_pixelPositions->getPixels()) {
102 double dfi_dx = std::abs(m_zD - m_zE) / (pow(pixel.xc - m_xE, 2) + pow(pixel.yc - m_yE, 2) + pow(m_zD - m_zE, 2));
103 m_pixelAcceptances.push_back(dfi_dx * pixel.Dx);
104 }
105 double sum = 0;
106 const auto& pixelPDF = m_background->getPDF();
107 for (size_t k = 0; k < m_pixelAcceptances.size(); k++) {
108 sum += m_pixelAcceptances[k] * pixelPDF[k];
109 }
110 for (auto& x : m_pixelAcceptances) x /= sum;
111 }
112
113 double DeltaRayPDF::getPDFValue(int pixelID, double time) const
114 {
115 const auto& pixelPDF = m_background->getPDF();
116 unsigned k = pixelID - 1;
117 if (k < pixelPDF.size()) {
118 const auto& pixel = m_pixelPositions->get(pixelID);
119 double t0 = sqrt(pow(pixel.xc - m_xE, 2) + pow(pixel.yc - m_yE, 2) + pow(m_zD - m_zE, 2))
121 return getPDFValue(time, t0 - m_dirT0, m_pixelAcceptances[k]) * pixelPDF[k];
122 }
123 return 0;
124 }
125
126 double DeltaRayPDF::smearedTimeDistr(double t, double t0) const
127 {
128 const double sigma0 = 0.15;
129 double sigma = sqrt(pow(sigma0, 2) + pow(m_dispersion * t, 2));
130
131 if (sigma < 0.001) return timeDistr(t, t0);
132
133 double f = 0;
134 for (const auto& gaus : m_tableGaus) f += timeDistr(t - gaus.x * sigma, t0) * gaus.y;
135 return f;
136 }
137
138 double DeltaRayPDF::peakFraction(double tmin, double tmax, double t0) const
139 {
140 int nt = m_norms.size() - 1;
141 int i1 = nt;
142 if (tmax > t0) i1 = t0 / tmax * nt;
143 int i2 = nt;
144 if (tmin > t0) i2 = t0 / tmin * nt;
145 return std::abs(m_norms[i2] - m_norms[i1]);
146 }
147
148 double DeltaRayPDF::totalFraction(double tmin, double tmax) const
149 {
150 double dirPeak = peakFraction(tmin - m_TOF, tmax - m_TOF, m_dirT0);
151 double reflPeak = peakFraction(tmin - m_TOF, tmax - m_TOF, m_reflT0);
152 return m_dirFrac * dirPeak + (1 - m_dirFrac) * reflPeak;
153 }
154
155 double DeltaRayPDF::directFraction(double z) const
156 {
157 // coefficients of 5th order polynom (from fit to MC, see B2GM/TOP Software status, June 2020)
158 const double par[] = {0.332741, -0.00331502, 2.0801e-05, -3.43689e-09, -6.35849e-10, 3.54556e-12};
159
160 double x = 1;
161 double f = 0;
162 for (auto p : par) {
163 f += p * x;
164 x *= z;
165 }
166 return f;
167 }
168
169 double DeltaRayPDF::photonYield(double beta, int PDGCode) const
170 {
171 // for parametrizations see B2GM/TOP Software status, June 2020
172 const double averagePDE = 1.06404889; // relative to nominal PDE
173 const double scaleFactor = 0.79;
174
175 if (std::abs(PDGCode) == 11) { // electorns and positrons
176 return 5.30 * scaleFactor / averagePDE;
177 } else if (PDGCode == -2212) { // anti-protons
178 const double par[] = {13.5859, -28.0625, 17.2684};
179 double f = par[0] + par[1] * beta + par[2] * beta * beta;
180 return f * scaleFactor / averagePDE;
181 } else { // other charged particles
182 const double par[] = { -8.15871, 10.0082, -1.25140, -120.225, 120.210};
183 double f = exp(par[0] + par[1] * beta + par[2] * beta * beta) + exp(par[3] + par[4] * beta);
184 return f * scaleFactor / averagePDE;
185 }
186 }
187
188 } // namespace TOP
190} // namespace Belle2
Provides a type-safe way to pass members of the chargedStableSet set.
Definition Const.h:589
int getPDGCode() const
PDG code.
Definition Const.h:473
static const double speedOfLight
[cm/ns]
Definition Const.h:695
double m_dispersion
dispersion coefficient
double m_dirT0
minimal propagation time of direct photons
double m_reflT0
minimal propagation time of reflected photons
double totalFraction(double tmin, double tmax) const
Total fraction of delta-ray photons within given propagation time interval.
double directFraction(double z) const
Fraction of direct photons from delta-rays, e.g direct/(direct+reflected)
double m_zD
detector (photo-cathode) position in z
double m_dirFrac
fraction of direct photons
void prepare(const TOPTrack &track, const Const::ChargedStable &hypothesis)
Prepare the object.
double m_yE
average photon emission position in y
double m_TOF
time-of-flight of particle
double m_groupIndex
group refractive index
const BackgroundPDF * m_background
background PDF
double photonYield(double beta, int PDGCode) const
Photon yield from delta-rays per track length in quartz for nominal photon detection efficiency.
std::vector< double > m_norms
relative angular distribution normalization constants (cumulative)
std::vector< GausXY > m_tableGaus
table of normal (Gaussian) distribution
double m_zM
spherical mirror position in z
double m_angularNorm
angular distribution normalization constant
double peakFraction(double tmin, double tmax, double t0) const
Fraction of delta-ray photons within given propagation time interval for single peak at t0.
DeltaRayPDF(int moduleID)
Class constructor.
double m_fraction
fraction of delta-ray photons within time window
std::vector< double > m_pixelAcceptances
pixel angular acceptances for direct peak (index = pixelID - 1)
double m_phaseIndex
phase refractive index
double smearedTimeDistr(double t, double t0) const
Smeared time distribution of photons from delta rays (normalized).
const PixelPositions * m_pixelPositions
pixel positions
double angularDistr(double kz) const
Angular distribution of photons from delta rays w/ total reflection requirement.
double m_zE
average photon emission position in z
double m_numPhotons
number of photons
double getPDFValue(int pixelID, double time) const
Returns PDF value at given time and pixel.
double timeDistr(double t, double t0) const
Time distribution of photons from delta rays (normalized).
double m_xE
average photon emission position in x
double getGroupIndexDerivative(double energy) const
Returns the derivative (dn_g/dE) of group refractive index of quartz at given photon energy.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
double getPhaseIndex(double energy) const
Returns phase refractive index of quartz at given photon energy.
double getGroupIndex(double energy) const
Returns group refractive index of quartz at given photon energy.
Singleton class providing pre-constructed reconstruction objects.
static double getMaxTime()
Returns time window upper edge.
static const YScanner * getYScanner(int moduleID)
Returns y-scanner of a given module.
static double getMinTime()
Returns time window lower edge.
Reconstructed track at TOP.
Definition TOPTrack.h:39
double sqrt(double a)
sqrt for double
Definition beamHelpers.h:28
Abstract base class for different kinds of events.
STL namespace.
Normal (Gaussian) distribution: an entry for the table.
Definition DeltaRayPDF.h:92