11 #include <top/dbobjects/TOPPmtQE.h>
12 #include <framework/logging/Logger.h>
23 const std::vector<float>& TOPPmtQE::getQE(
unsigned pmtPixel)
const
26 if (pmtPixel < c_NumPmtPixels)
return m_QE[pmtPixel];
28 B2ERROR(
"TOPPmtQE::getQE: invalid pixel ID, returning empty vector");
33 double TOPPmtQE::getQE(
unsigned pmtPixel,
double lambda)
const
36 if (pmtPixel < c_NumPmtPixels)
return interpolate(lambda, m_QE[pmtPixel]);
40 const std::vector<float>& TOPPmtQE::getEnvelopeQE()
const
46 double TOPPmtQE::getEnvelopeQE(
double lambda)
const
49 return interpolate(lambda, m_envelopeQE);
52 double TOPPmtQE::getEfficiency(
unsigned pmtPixel,
double lambda,
bool BfieldOn)
const
55 return getQE(pmtPixel, lambda) * m_CE_withB;
57 return getQE(pmtPixel, lambda) * m_CE_noB;
61 double TOPPmtQE::getCE(
bool BfieldOn)
const
70 double TOPPmtQE::getLambdaLast()
const
73 for (
unsigned pixel = 0; pixel < c_NumPmtPixels; pixel++) {
74 const auto& QE = m_QE[pixel];
75 size = std::max(size, QE.size());
77 return m_lambdaFirst + (size - 1) * m_lambdaStep;
80 double TOPPmtQE::getLambdaLast(
unsigned pmtPixel)
const
83 if (pmtPixel < c_NumPmtPixels) {
84 return m_lambdaFirst + (m_QE[pmtPixel].size() - 1) * m_lambdaStep;
89 void TOPPmtQE::setEnvelopeQE()
const
91 if (!m_envelopeQE.empty())
return;
94 for (
unsigned pixel = 0; pixel < c_NumPmtPixels; pixel++) {
95 const auto& QE = m_QE[pixel];
96 size = std::max(size, QE.size());
98 m_envelopeQE.resize(size, 0);
99 for (
unsigned pixel = 0; pixel < c_NumPmtPixels; pixel++) {
100 const auto& QE = m_QE[pixel];
101 for (
size_t i = 0; i < QE.size(); i++) {
102 m_envelopeQE[i] = std::max(m_envelopeQE[i], QE[i]);
107 double TOPPmtQE::interpolate(
double lambda,
const std::vector<float>& QE)
const
109 double dlam = lambda - m_lambdaFirst;
110 if (dlam < 0 or dlam > (QE.size() - 1) * m_lambdaStep)
return 0;
111 unsigned i = int(dlam / m_lambdaStep);
112 if (i > QE.size() - 2)
return QE.back();
113 return QE[i] + (QE[i + 1] - QE[i]) / m_lambdaStep * (dlam - i * m_lambdaStep);