8#include <ext/alloc_traits.h>
17 bool y_in_range = (pos.y() <= top_H1 and pos.y() >= bot_H2);
18 bool x_in_range = std::abs(pos.x()) <= max_x + 0.01;
19 return y_in_range and x_in_range;
32 return y * std::tan(half_openingAngle * CLHEP::degree) + 0.5 *
lPadWidth;
34 return (
y -
Size * 0.5) * std::tan(half_openingAngle * CLHEP::degree) + 0.5 *
lPadWidth;
46 std::pair<int, int>
result(-1, -1);
56 double locPhi = std::atan(-1.0 * pos.x() / (
radialDistance + pos.y())) / CLHEP::degree;
58 double fuzziedX = pos.x() - 1. *
PadPhiShift * std::cos(locPhi * CLHEP::degree);
59 double fuzziedlocPhi = std::atan(-1.0 * fuzziedX / (
radialDistance + pos.y())) / CLHEP::degree;
61 bool below_half_length = (y1 < 0);
62 bool outside_phi_range = (std::abs(locPhi) > maxlocPhi) || (std::abs(fuzziedlocPhi) > maxlocPhi);
68 padEta = padEtadouble;
75 if (outside_phi_range)
79 int padPhi = padPhidouble + 2;
82 if (padEta ==
nPadH + 1) { padEta -= 1; }
83 if (padPhi == 0) { padPhi = 1; }
87 bool ieta_out_of_range = (padEta >
nPadH + 1);
88 bool iphi_out_of_range = (padPhi < 0 || padPhi >
nPadColumns + 1);
89 bool index_out_of_range = ieta_out_of_range or iphi_out_of_range;
90 if (index_out_of_range) {
91 std::stringstream sstr{};
92 if (ieta_out_of_range){
93 sstr<<__FILE__<<
":"<<__LINE__<<
" "<<__func__<<
"() eta out of range "
94 <<
Amg::toString(pos, 2)<<
" (ieta, iphi) = ("<<padEta<<
","<<padPhi<<
").";
96 sstr<<__FILE__<<
":"<<__LINE__<<
" "<<__func__<<
"() phi out of range "
97 <<
Amg::toString(pos, 2)<<
" (ieta, iphi) = ("<<padEta<<
","<<padPhi<<
").";
99 throw std::runtime_error(sstr.str());
102 result = std::make_pair(padEta, padPhi);
123 const double lenLeft = std::hypot(leftEdge.x(), leftEdge.y());
126 corners[
botLeft], leftEdge).value_or(1.e9);
130 const double deltaX = pos.x() - leftPad.x();
131 const double lenX = rightPad.x() - leftPad.x();
134 if (leftIsect >= 0. && leftIsect <= lenLeft) {
136 if (deltaX >= 0. && deltaX < lenX) {
137 return Amg::Vector2D::Zero();
138 }
else if (deltaX < 0.) {
139 return deltaX * Amg::Vector2D::UnitX();
141 return (deltaX - lenX) * Amg::Vector2D::UnitX();
143 if (deltaX > 0. && deltaX < lenX) {
144 return (leftIsect < 0 ? corners[
botRight].
y() - pos.y()
145 : pos.y() - corners[
topRight].y())* Amg::Vector2D::UnitY();
147 return (leftIsect < 0 ? corners[
botRight].
y() - pos.y()
148 : pos.y() - corners[
topRight].y())* Amg::Vector2D::UnitY() +
149 (deltaX < 0. ? deltaX : (deltaX - lenX) )* Amg::Vector2D::UnitX();
159 int iEta = pad.first;
160 int iPhi = pad.second;
167 double yBot = 0., yTop = 0.;
171 }
else if (iEta > 1) {
184 if (yBot < minY) yBot = minY;
185 if (yTop > maxY) yTop = maxY;
192 const double tanRight = std::tan(phiRight *CLHEP::degree);
193 const double tanLeft = std::tan(phiLeft *CLHEP::degree);
210 double yCutoutOffset{0.};
212 yCutoutOffset = 24.74;
228 if (
yCutout && (yTop - yCutoutOffset) > 0) {
231 xTopRight = cutoutXpos;
232 if (yBot - yCutoutOffset > 0) xBotRight = cutoutXpos;
234 xTopLeft = -1.0 * cutoutXpos;
235 if (yBot - yCutoutOffset > 0) xBotLeft = -1.0 * cutoutXpos;
239 ATH_MSG_VERBOSE(
"Swap top and bottom side "<<pad.first<<
"/"<<pad.second);
242 if (xBotLeft > xBotRight) {
243 ATH_MSG_VERBOSE(
"Swap bottom left and right points "<<pad.first<<
"/"<<pad.second);
246 if (xTopLeft > xTopRight) {
247 ATH_MSG_VERBOSE(
"Swap top left and right points "<<pad.first<<
"/"<<pad.second);
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
constexpr std::array< T, N > make_array(const T &def_val)
Helper function to initialize in-place arrays with non-zero values.
#define ATH_MSG_VERBOSE(x)
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point B' along the line B that's closest to a second line A.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 2, 1 > Vector2D
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
Parameters defining the design of the readout sTGC pads.
double radialDistance
DT-2015-11-29 distance from the beamline to the center of the module.
bool channelPosition(const std::pair< int, int > &pad, Amg::Vector2D &pos) const
calculate local channel position for a given channel number
std::pair< int, int > etaPhiId(const int channel) const
bool withinSensitiveArea(const Amg::Vector2D &pos) const
whether pos is within the sensitive area of the module
double maxAbsSensitiveX(const double &y) const
largest (abs, local) x of the sensitive volume
bool channelCorners(const std::pair< int, int > &pad, CornerArray &corners) const
double sectorOpeningAngle
bool isConvertedFromPhaseII
std::pair< int, int > channelNumber(const Amg::Vector2D &pos) const
calculate local channel number, range 1=nstrips like identifiers.
Amg::Vector2D distanceToPad(const Amg::Vector2D &pos, int channel) const
std::array< Amg::Vector2D, 4 > CornerArray
calculate local channel corners for a given channel number
double maxSensitiveY() const
highest y (local) of the sensitive volume
double minSensitiveY() const
lowest y (local) of the sensitive volume