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