Belle II Software development
TOPWavelengthFilter.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/dbobjects/TOPWavelengthFilter.h>
10#include <iostream>
11#include <iomanip>
12
13using namespace std;
14
15namespace Belle2 {
22 {
23 if (m_transmittances.empty()) return 1; // old payload from DB (filter included in QE)
24
25 double dlam = lambda - m_lambdaFirst;
26 if (dlam < 0) return 0;
27 if (dlam > (m_transmittances.size() - 1) * m_lambdaStep) return m_transmittances.back();
28 unsigned i = int(dlam / m_lambdaStep);
29 if (i > m_transmittances.size() - 2) return m_transmittances.back();
30 return m_transmittances[i] + (m_transmittances[i + 1] - m_transmittances[i]) / m_lambdaStep * (dlam - i * m_lambdaStep);
31 }
32
33
35 {
36 if (getName().empty()) return true; // old payload from DB (filter included in QE)
37
38 if (m_lambdaFirst <= 0) return false;
39 if (m_lambdaStep <= 0) return false;
40 if (m_transmittances.empty()) return false;
41 return true;
42 }
43
44
45 void TOPWavelengthFilter::print(const std::string& title) const
46 {
48 cout << " first point: " << getLambdaFirst() << " nm";
49 cout << ", step: " << getLambdaStep() << " nm" << endl;
50 cout << " bulk transmittances: [";
51 for (const auto& trE : m_transmittances) cout << setprecision(3) << trE << ", ";
52 cout << "]" << endl;
53 if (getName().empty()) {
54 cout << "(Old geometry payload, filter transmittance is included in QE)" << endl;
55 }
56
57 }
58
60} // end Belle2 namespace
const std::string & getName() const
Returns object name.
Definition: TOPGeoBase.h:51
float getLambdaStep() const
Returns wavelength step.
float getLambdaFirst() const
Returns wavelength of the first data point.
float m_lambdaStep
wavelength step [nm]
std::vector< float > m_transmittances
bulk transmittance data points
float m_lambdaFirst
wavelength of the first data point [nm]
bool isConsistent() const override
Check for consistency of data members.
void printUnderlined(const std::string &title) const
Print the content of the class.
Definition: TOPGeoBase.cc:35
void print(const std::string &title="Wavelength filter bulk transmittance") const override
Print the content of the class.
float getBulkTransmittance(double lambda) const
Returns bulk transmittance at given wavelength using linear interpolation.
Abstract base class for different kinds of events.
STL namespace.