Belle II Software  release-08-01-10
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 
13 using namespace std;
14 
15 namespace Belle2 {
21  float TOPWavelengthFilter::getBulkTransmittance(double lambda) const
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 
34  bool TOPWavelengthFilter::isConsistent() const
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  {
47  TOPGeoBase::printUnderlined(title);
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
Abstract base class for different kinds of events.