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