Belle II Software development
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
16using namespace std;
17
18namespace Belle2 {
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
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.
const std::string & getName() const
get name of the optical surface
int getFinish() const
get finish of the surface
const std::vector< GeoMaterialProperty > & getProperties() const
get all properties
double getValue() const
get value for the surface condition
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
std::string m_name
geometry object name
Definition: TOPGeoBase.h:89
static const double eV
[electronvolt]
Definition: Unit.h:112
static const double cm
Standard units with the value = 1.
Definition: Unit.h:47
static double s_unit
conversion unit for length
Definition: TOPGeoBase.h:86
void printUnderlined(const std::string &title) const
Print the content of the class.
Definition: TOPGeoBase.cc:35
double getReflectivity(const GeoOpticalSurface &surface, double energy) const
Returns reflectivity of optical surface at given photon energy.
Definition: TOPGeoBase.cc:72
virtual void printSurface(const GeoOpticalSurface &surface) const
Print the content of optical surface.
Definition: TOPGeoBase.cc:44
virtual void print(const std::string &title) const
Print the content of the class.
Definition: TOPGeoBase.cc:28
static std::string s_unitName
conversion unit name
Definition: TOPGeoBase.h:87
Abstract base class for different kinds of events.
STL namespace.