Belle II Software  release-05-01-25
TOPGeoPrism.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Marko Staric *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <top/dbobjects/TOPGeoPrism.h>
12 #include <framework/gearbox/Unit.h>
13 #include <framework/logging/Logger.h>
14 #include <math.h>
15 #include <iostream>
16 
17 using namespace std;
18 
19 namespace Belle2 {
25  bool TOPGeoPrism::isConsistent() const
26  {
27  if (m_exitThickness <= 0) return false;
28  if (m_flatLength < 0) return false;
29  if (m_width <= 0) return false;
30  if (m_thickness <= 0) return false;
31  if (m_length <= 0) return false;
32  if (m_material.empty()) return false;
33  if (m_surface.getName().empty() and !m_surface.hasProperties()) return false;
34  if (m_sigmaAlpha < 0) return false;
35  if (m_brokenFraction > 0 and m_brokenGlueMaterial.empty()) return false;
36  if (!m_peelOffRegions.empty()) {
37  if (m_peelOffSize <= 0) return false;
38  if (m_peelOffThickness <= 0) return false;
39  if (m_peelOffMaterial.empty()) return false;
40  double halfSize = (getWidth() - getPeelOffSize()) / 2;
41  for (const auto& region : m_peelOffRegions) {
42  if (fabs(getPeelOffCenter(region)) > halfSize) return false;
43  }
44  }
45  return true;
46  }
47 
48 
49  void TOPGeoPrism::print(const std::string& title) const
50  {
51  TOPGeoBase::print(title);
52  cout << " Vendor: " << getVendor() << ", serial number: " << getSerialNumber() << endl;
53  cout << " Dimensions: " << getWidth() << " X " << getThickness() << " X " << getLength()
54  << " " << s_unitName << endl;
55  cout << " Exit window dimensions: " << getWidth() << " X "
56  << getExitThickness() << " " << s_unitName << endl;
57  cout << " Prism angle: " << getAngle() / Unit::deg << " deg";
58  cout << ", flat surface length: " << getFlatLength() << " " << s_unitName << endl;
59  cout << " Material: " << getMaterial() << endl;
60  if (getFilterThickness() > 0) { // old payload
61  cout << " Wavelenght filter: " << getFilterMaterial()
62  << ", thickness: " << getFilterThickness() << " " << s_unitName << endl;
63  }
64  if (!m_peelOffRegions.empty()) {
65  cout << " Peel-off cookie regions: ";
66  cout << " size = " << getPeelOffSize() << " " << s_unitName;
67  cout << " thickness = " << getPeelOffThickness() << " " << s_unitName;
68  cout << " material = " << getPeelOffMaterial() << endl;
69  for (const auto& region : m_peelOffRegions) {
70  cout << " ID = " << region.ID << ", fraction = " << region.fraction
71  << ", angle = " << region.angle / Unit::deg << " deg"
72  << ", xc = " << getPeelOffCenter(region) << " " << s_unitName << endl;
73  }
74  } else {
75  cout << " Peel-off regions: None" << endl;
76  }
77  printSurface(m_surface);
78  cout << " - sigmaAlpha: " << getSigmaAlpha() << endl;
79 
80  }
81 
82 
83  void TOPGeoPrism::appendPeelOffRegion(unsigned ID, double fraction, double angle)
84  {
85  for (const auto& region : m_peelOffRegions) {
86  if (region.ID == ID) {
87  B2ERROR("TOPGeoPrism::appendPeelOffRegion: region already appended."
88  << LogVar("region ID", ID));
89  return;
90  }
91  }
92  PeelOffRegion region;
93  region.ID = ID;
94  region.fraction = fraction;
95  region.angle = angle;
96  double halfSize = (getWidth() - getPeelOffSize()) / 2;
97  if (fabs(getPeelOffCenter(region)) > halfSize) {
98  B2ERROR("TOPGeoPrism::appendPeelOffRegion: region doesn't fit into prism."
99  << LogVar("region ID", ID));
100  return;
101  }
102  m_peelOffRegions.push_back(region);
103  }
104 
105  typedef std::pair<double, double> Pair;
106 
107  std::vector<Pair> TOPGeoPrism::getPeelOffContour(const PeelOffRegion& region) const
108  {
109  std::vector<Pair> contour;
110  constructContour(getPeelOffSize() / 2, getExitThickness() / 2,
111  region.fraction, region.angle,
112  contour);
113 
114  return contour;
115  }
116 
118 } // end Belle2 namespace
Belle2::Pair
std::pair< double, double > Pair
Shorthand for std::pair<double, double>
Definition: TOPGeoBarSegment.cc:59
Belle2::TOPGeoPrism::PeelOffRegion
Parameters of peel-off cookie region (corresponds to 2x2 PMT's)
Definition: TOPGeoPrism.h:42
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
LogVar
Class to store variables with their name which were sent to the logging service.
Definition: LogVariableStream.h:24