Belle II Software  release-08-01-10
TOPGeoBase.cc
1 
2 /**************************************************************************
3  * basf2 (Belle II Analysis Software Framework) *
4  * Author: The Belle II Collaboration *
5  * *
6  * See git log for contributors and copyright holders. *
7  * This file is licensed under LGPL-3.0, see LICENSE.md. *
8  **************************************************************************/
9 
10 #include <top/dbobjects/TOPGeoBase.h>
11 #include <framework/gearbox/Unit.h>
12 #include <framework/logging/Logger.h>
13 #include <TSpline.h>
14 #include <iostream>
15 
16 using namespace std;
17 
18 namespace Belle2 {
24  double TOPGeoBase::s_unit = Unit::cm;
25  std::string TOPGeoBase::s_unitName("cm");
26 
27 
28  void TOPGeoBase::print(const std::string& title) const
29  {
30  cout << title << ":" << endl;
31  cout << " name: " << m_name << endl;
32  }
33 
34 
35  void TOPGeoBase::printUnderlined(const std::string& title) const
36  {
37  cout << title << ":" << endl;
38  for (size_t i = 0; i <= title.length(); i++) cout << "-";
39  cout << endl;
40  cout << " name: " << m_name << endl;
41  }
42 
43 
44  void TOPGeoBase::printSurface(const GeoOpticalSurface& surface) const
45  {
46  cout << " Optical surface: ";
47  if (surface.getName().empty() and !surface.hasProperties()) {
48  cout << "not defined" << endl;
49  return;
50  }
51  cout << surface.getName();
52  cout << ", model: " << surface.getModel();
53  cout << ", finish: " << surface.getFinish();
54  cout << ", type: " << surface.getType();
55  cout << ", value: " << surface.getValue();
56  cout << endl;
57  if (surface.hasProperties()) {
58  for (const auto& property : surface.getProperties()) {
59  cout << " - property: ";
60  cout << property.getName() << " [";
61  for (const auto& value : property.getValues()) cout << value << ", ";
62  cout << "], @[";
63  for (const auto& value : property.getEnergies()) cout << value / Unit::eV << ", ";
64  cout << "] eV" << endl;
65  }
66  } else {
67  cout << " - properties: None" << endl;
68  }
69 
70  }
71 
72  double TOPGeoBase::getReflectivity(const GeoOpticalSurface& surface, double energy) const
73  {
74  energy *= Unit::eV;
75  if (surface.hasProperties()) {
76  for (const auto& property : surface.getProperties()) {
77  if (property.getName() == "REFLECTIVITY") {
78  auto energies = property.getEnergies();
79  auto values = property.getValues();
80  if (energies.size() < 2) return 0;
81  if (energy < energies[0] or energy > energies.back()) {
82  B2WARNING("TOPGeoBase::getReflectivity: photon energy out of range - return value not reliable");
83  }
84  auto spline = TSpline3("tmp", energies.data(), values.data(), energies.size());
85  return spline.Eval(energy);
86  }
87  }
88  }
89 
90  B2ERROR("Optical surface " << surface.getName() << " has no property REFLECTIVITY");
91  return 0;
92  }
93 
94 
96 } // end Belle2 namespace
Represent an optical finish of a surface.
int getFinish() const
get finish of the surface
const std::string & getName() const
get name of the optical surface
double getValue() const
get value for the surface condition
const std::vector< GeoMaterialProperty > & getProperties() const
get all properties
int getType() const
get type of the surface
bool hasProperties() const
check if the material has at least one property
int getModel() const
get model for the surface
Abstract base class for different kinds of events.