9#include <top/dbobjects/TOPGeoBarSegment.h>
10#include <framework/gearbox/Unit.h>
11#include <framework/logging/Logger.h>
57 typedef std::pair<double, double>
Pair;
62 std::vector<Pair> contour;
71 std::vector<Pair>& contour)
const
77 contour.push_back(
Pair(-A, B));
78 contour.push_back(
Pair(A, B));
79 contour.push_back(
Pair(A, -B));
80 contour.push_back(
Pair(-A, -B));
84 double alpha0 =
atan(B / A);
85 double halfPi = alpha0 > 0 ? M_PI / 2 : -M_PI / 2;
87 while (fabs(angle) > alpha0) {
89 alpha0 = M_PI / 2 - alpha0;
95 quadrant = quadrant % 4;
96 if (halfPi < 0) quadrant = (4 - quadrant) % 4;
98 double tanAngle = tan(fabs(angle));
99 double S0 = A / B * tanAngle / 2;
100 if (fraction <= S0) {
101 double x =
sqrt(8 * A * B * fraction / tanAngle);
102 double y = x * tanAngle;
104 contour.push_back(
Pair(-A, B - y));
105 contour.push_back(
Pair(-A, B));
106 contour.push_back(
Pair(-A + x, B));
108 contour.push_back(
Pair(A, B - y));
109 contour.push_back(
Pair(A - x, B));
110 contour.push_back(
Pair(A, B));
112 }
else if (1 - fraction <= S0) {
113 double x =
sqrt(8 * A * B * (1 - fraction) / tanAngle);
114 double y = x * tanAngle;
116 contour.push_back(
Pair(A, -B + y));
117 contour.push_back(
Pair(A - x, -B));
118 contour.push_back(
Pair(-A, -B));
119 contour.push_back(
Pair(-A, B));
120 contour.push_back(
Pair(A, B));
122 contour.push_back(
Pair(-A + x, -B));
123 contour.push_back(
Pair(-A, -B + y));
124 contour.push_back(
Pair(-A, B));
125 contour.push_back(
Pair(A, B));
126 contour.push_back(
Pair(A, -B));
129 double y = (1 - 2 * fraction) * B;
130 double dy = angle > 0 ? A * tanAngle : -A * tanAngle;
131 contour.push_back(
Pair(-A, y - dy));
132 contour.push_back(
Pair(-A, B));
133 contour.push_back(
Pair(A, B));
134 contour.push_back(
Pair(A, y + dy));
141 for (
auto& point : contour) {
142 double x = -point.second;
143 double y = point.first;
149 for (
auto& point : contour) {
150 double x = -point.first;
151 double y = -point.second;
157 for (
auto& point : contour) {
158 double x = point.second;
159 double y = -point.first;
165 B2ERROR(
"TOPGeoBarSegment::constructContour: bug!");
const std::string & getName() const
get name of the optical surface
bool hasProperties() const
check if the material has at least one property
double getWidth() const
Returns bar segment width.
float m_glueThickness
glue thickness
std::string m_material
bar segment material name
double getBrokenGlueAngle() const
Returns angle of the delaminated surface.
std::string m_brokenGlueMaterial
broken glue material name
const std::string & getGlueMaterial() const
Returns glue material name (glue on -z side)
GeoOpticalSurface m_surface
optical surface
double getThickness() const
Returns bar segment thickness.
float m_brokenFraction
fraction of broken (delaminated) glue
float m_thickness
bar segment thickness
std::string m_glueMaterial
glue material name
double getSigmaAlpha() const
Returns geant4 parameter describing surface roughness.
double getBrokenGlueFraction() const
Returns fraction of the delaminated surface.
const std::string & getMaterial() const
Returns bar segment material name.
const std::string & getVendor() const
Returns vendor's name.
float m_sigmaAlpha
geant4 parameter for surface roughness
float m_length
bar segment length
double getLength() const
Returns bar segment length.
float m_width
bar segment width
virtual double getGlueThickness() const
Returns glue thickness (glue on -z side)
const std::string & getBrokenGlueMaterial() const
Returns material name which represents broken glue.
const std::string & getSerialNumber() const
Returns serial number.
float m_brokenAngle
angle of broken (delaminated) glue
static const double deg
degree to radians
double atan(double a)
atan for double
double sqrt(double a)
sqrt for double
virtual bool isConsistent() const override
Check for consistency of data members.
virtual void print(const std::string &title="Bar segment geometry parameters") const override
Print the content of the class.
virtual void printSurface(const GeoOpticalSurface &surface) const
Print the content of optical surface.
void constructContour(double A, double B, double fraction, double angle, std::vector< std::pair< double, double > > &contour) const
Construct a 2D contour.
virtual void print(const std::string &title) const
Print the content of the class.
std::vector< std::pair< double, double > > getBrokenGlueContour() const
Returns the x-y contour of broken glue.
std::pair< double, double > Pair
Shorthand for std::pair<double, double>
static std::string s_unitName
conversion unit name
Abstract base class for different kinds of events.