ATLAS Offline Software
StripDesign.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <GeoModelHelpers/TransformSorter.h>
7 #include <GaudiKernel/SystemOfUnits.h>
8 #include <climits>
9 namespace {
10  constexpr double tolerance = 0.001 * Gaudi::Units::mm;
11 }
13 #define ORDER_PROP(PROP) \
14  { \
15  if (std::abs(1.*PROP - 1.*other.PROP) > tolerance) { \
16  return PROP < other.PROP; \
17  } \
18  }
19 
20 namespace MuonGMR4{
22  AthMessaging{"MuonStripDesign"} {}
23  bool operator<(const StripDesignPtr&a, const StripDesignPtr& b) {
24  return (*a) < (*b);
25  }
36  static const GeoTrf::TransformSorter trfSorter{};
37  return trfSorter(m_firstStripPos, other.m_firstStripPos);
38  }
39  std::ostream& operator<<(std::ostream& ostr, const StripDesign& design) {
40  design.print(ostr);
41  return ostr;
42  }
43  void StripDesign::print(std::ostream& ostr) const {
44  ostr<<"Strip -- number: "<<numStrips()<<", ";
45  ostr<<"pitch: "<<stripPitch()<<", ";
46  ostr<<"width: "<<stripWidth()<<", ";
47  ostr<<"Dimension -- width x height [mm]: "<<halfWidth() * Gaudi::Units::mm<<" x ";
48  ostr<<shortHalfHeight()<<"/"<<longHalfHeight()<<" [mm], ";
49  if (hasStereoAngle()) ostr<<"stereo angle: "<<stereoAngle() / Gaudi::Units::deg<<", ";
50  ostr<<"position first strip "<<Amg::toString(center(firstStripNumber()).value_or(Amg::Vector2D::Zero()),1);
51  ostr<<" *** Trapezoid edges "<<Amg::toString(cornerBotLeft(),1)<<" - "<<Amg::toString(cornerBotRight(), 1)<<" --- ";
52  ostr<<Amg::toString(cornerTopLeft(), 1)<<" - "<<Amg::toString(cornerTopRight(), 1);
53  }
54  void StripDesign::defineTrapezoid(double HalfShortY, double HalfLongY, double HalfHeight, double sAngle){
55  defineTrapezoid(HalfShortY,HalfLongY, HalfHeight);
56  setStereoAngle(sAngle);
57  }
58 
59  void StripDesign::setStereoAngle(double sAngle) {
60  if (std::abs(sAngle) < std::numeric_limits<float>::epsilon()) return;
61  m_stereoAngle = sAngle;
62  m_hasStereo = true;
63  m_etaToStereo = Eigen::Rotation2D{sAngle};
64  m_stereoToEta = Eigen::Rotation2D{-sAngle};
65  m_stripDir = m_stereoToEta * m_stripDir;
66  m_stripNormal = m_stereoToEta * m_stripNormal;
67  }
68 
69  void StripDesign::defineTrapezoid(double HalfShortY, double HalfLongY, double HalfHeight) {
70  m_bottomLeft = Amg::Vector2D{-HalfHeight, -HalfShortY};
71  m_bottomRight = Amg::Vector2D{HalfHeight, -HalfLongY};
72  m_topLeft = Amg::Vector2D{-HalfHeight, HalfShortY};
73  m_topRight = Amg::Vector2D{HalfHeight, HalfLongY};
74 
75  m_shortHalfY = HalfShortY;
76  m_longHalfY = HalfLongY;
77  m_halfX = HalfHeight;
78  m_lenSlopEdge = std::hypot(2.*HalfHeight, HalfShortY - HalfLongY);
79  resetDirCache();
80  m_isFlipped = false;
81  }
82  void StripDesign::defineDiamond(double HalfShortY, double HalfLongY,
83  double HalfHeight, double yCutout) {
85  double HalfLongYuncut = HalfLongY + yCutout * (HalfLongY - HalfShortY)/(2*HalfHeight - yCutout);
86  defineTrapezoid(HalfShortY, HalfLongYuncut, HalfHeight);
88  m_longHalfY = HalfLongY;
90  }
92  if (m_isFlipped) {
93  ATH_MSG_WARNING("It's impossible to flip a trapezoid twice. Swap short and long lengths");
94  return;
95  }
96  m_isFlipped = true;
97 
104  resetDirCache();
105  }
106 
108  const double stripPitch,
109  const double stripWidth,
110  const int numStrips,
111  const int numFirst) {
112  m_channelShift = numFirst;
116  m_firstStripPos = std::move(posFirst);
117  }
119  m_dirTopEdge.release();
120  m_dirBotEdge.release();
121  m_dirLeftEdge.release();
122  m_dirRightEdge.release();
123  }
124 
125 }
126 #undef ORDER_PROP
MuonGMR4::StripDesign::cornerTopLeft
const Amg::Vector2D & cornerTopLeft() const
Returns the top left corner of the trapezoid.
MuonGMR4::StripDesign::m_cutLongEdge
double m_cutLongEdge
Lenght of the line segment that's cut from the long edge to make the trapezoid diamond shaped.
Definition: StripDesign.h:206
GeoModel::TransientConstSharedPtr< StripDesign >
MuonGMR4::StripDesign::stereoAngle
double stereoAngle() const
Returns the value of the stereo angle.
MuonGMR4::StripDesign::m_lenSlopEdge
double m_lenSlopEdge
Length of the edge connecting the short with the long egde.
Definition: StripDesign.h:196
MuonGMR4::StripDesign::m_channelShift
int m_channelShift
Shift between the 0-th readout channel and the first strip described by the panel.
Definition: StripDesign.h:152
MuonGMR4::StripDesign::isFlipped
bool isFlipped() const
Returns whether the trapezoid is flipped.
MuonGMR4::StripDesign
Definition: StripDesign.h:30
MuonGMR4::StripDesign::defineStripLayout
void defineStripLayout(Amg::Vector2D &&posFirst, const double stripPitch, const double stripWidth, const int numStrips, const int numFirst=1)
Defines the layout of the strip detector by specifing the position of the first strip w....
Definition: StripDesign.cxx:107
MuonGMR4::StripDesign::m_shortHalfY
double m_shortHalfY
Trapezoid dimensions.
Definition: StripDesign.h:198
MuonGMR4::StripDesign::cornerBotLeft
const Amg::Vector2D & cornerBotLeft() const
Returns the bottom left corner of the trapezoid.
MuonGMR4::StripDesign::setStereoAngle
void setStereoAngle(double stereo)
Definition: StripDesign.cxx:59
MuonGMR4::StripDesign::m_stereoAngle
double m_stereoAngle
Stereo angle of the strip design.
Definition: StripDesign.h:172
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
MuonGMR4::StripDesign::numStrips
virtual int numStrips() const
Number of strips on the panel.
MuonGMR4::StripDesign::defineDiamond
void defineDiamond(double HalfShortY, double HalfLongY, double HalfHeight, double yCutout)
Defines the edges of the sTGC diamond L3 sector.
Definition: StripDesign.cxx:82
MuonGMR4::StripDesign::m_dirRightEdge
CxxUtils::CachedUniquePtr< Amg::Vector2D > m_dirRightEdge
Vector describing the right edge of the trapezoid (bottom right -> top right)
Definition: StripDesign.h:194
deg
#define deg
Definition: SbPolyhedron.cxx:17
MuonGMR4::StripDesign::m_stripNormal
Amg::Vector2D m_stripNormal
Vector pointing from strip N to the next strip.
Definition: StripDesign.h:165
StripDesign.h
MuonGMR4::StripDesign::m_topLeft
Amg::Vector2D m_topLeft
Top right point of the trapezoid.
Definition: StripDesign.h:181
MuonGMR4::StripDesign::m_stripPitch
double m_stripPitch
Distance between 2 adjacent strip centers.
Definition: StripDesign.h:156
MuonGMR4::StripDesign::longHalfHeight
double longHalfHeight() const
Returns the longer half height of the panel.
MuonGMR4::StripDesign::StripDesign
StripDesign()
Definition: StripDesign.cxx:21
MuonGMR4::StripDesign::m_bottomRight
Amg::Vector2D m_bottomRight
Bottom right point of the trapezoid.
Definition: StripDesign.h:185
MuonGMR4::StripDesign::shortHalfHeight
double shortHalfHeight() const
Returns the shorter half height of the panel.
MuonGMR4::StripDesign::m_firstStripPos
Amg::Vector2D m_firstStripPos
First strip position.
Definition: StripDesign.h:160
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
MuonGMR4
A muon chamber is a collection of readout elements belonging to the same station.
Definition: ChamberAssembleTool.h:16
MuonGMR4::StripDesign::m_dirLeftEdge
CxxUtils::CachedUniquePtr< Amg::Vector2D > m_dirLeftEdge
Vector describing the left adge of the trapezoid (bottom left -> top left)
Definition: StripDesign.h:192
MuonGMR4::StripDesign::yCutout
double yCutout() const
Returns the cutout of the diamond.
MuonGMR4::StripDesign::m_yCutout
double m_yCutout
Stores the diamond cutout length from the SQLite DB file.
Definition: StripDesign.h:203
MuonGMR4::StripDesign::stripWidth
double stripWidth() const
Width of a strip.
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
MuonGMR4::StripDesign::defineTrapezoid
void defineTrapezoid(double HalfShortY, double HalfLongY, double HalfHeight)
Defines the edges of the trapezoid.
Definition: StripDesign.cxx:69
MuonGMR4::StripDesign::firstStripNumber
int firstStripNumber() const
Returns the number of the first strip.
MuonGMR4::StripDesign::cornerTopRight
const Amg::Vector2D & cornerTopRight() const
Returns the top right corner of the trapezoid.
tolerance
Definition: suep_shower.h:17
MuonGMR4::operator<
bool operator<(const StripDesignPtr &a, const StripDesignPtr &b)
Definition: StripDesign.cxx:23
MuonGMR4::StripDesign::flipTrapezoid
void flipTrapezoid()
Flips the edges of the trapezoid boundaries by 90 degrees clockwise.
Definition: StripDesign.cxx:91
MuonGMR4::StripDesign::center
CheckVector2D center(int stripNumb) const
Returns the bisector of the strip (Global numbering scheme)
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
MuonGMR4::StripDesign::m_dirBotEdge
CxxUtils::CachedUniquePtr< Amg::Vector2D > m_dirBotEdge
Vector describing the bottom edge of the trapezoid (bottom left -> bottom right)
Definition: StripDesign.h:190
MuonGMR4::StripDesign::m_hasStereo
bool m_hasStereo
Flag telling whether the strip design has a stereo angle or not.
Definition: StripDesign.h:170
MuonGMR4::StripDesign::print
virtual void print(std::ostream &ostr) const
Dump properties to the ostr.
Definition: StripDesign.cxx:43
MuonGMR4::StripDesign::m_stripWidth
double m_stripWidth
Width of each strip line.
Definition: StripDesign.h:158
MuonGMR4::StripDesign::m_longHalfY
double m_longHalfY
Definition: StripDesign.h:199
MuonGMR4::StripDesign::halfWidth
double halfWidth() const
Returns the half height of the strip panel.
MuonGMR4::StripDesign::m_isFlipped
bool m_isFlipped
Flag telling whether the trapezoid has been flipped.
Definition: StripDesign.h:168
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
MuonGMR4::StripDesign::m_dirTopEdge
CxxUtils::CachedUniquePtr< Amg::Vector2D > m_dirTopEdge
Vector describing the top edge of the trapzoid (top left -> top right)
Definition: StripDesign.h:188
MuonGMR4::StripDesign::cornerBotRight
const Amg::Vector2D & cornerBotRight() const
Returns the bottom right corner of the trapezoid.
a
TList * a
Definition: liststreamerinfos.cxx:10
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
MuonGMR4::StripDesign::resetDirCache
void resetDirCache()
Resets the cache of the directions.
Definition: StripDesign.cxx:118
MuonGMR4::StripDesign::m_bottomLeft
Amg::Vector2D m_bottomLeft
Bottom left point of the trapezoid.
Definition: StripDesign.h:179
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MuonGMR4::StripDesign::m_stripDir
Amg::Vector2D m_stripDir
Orientiation of the strips along the panel.
Definition: StripDesign.h:163
MuonGMR4::StripDesign::hasStereoAngle
bool hasStereoAngle() const
Returns whether a stereo angle is defined.
ORDER_PROP
#define ORDER_PROP(PROP)
Helper macro to facilliate the ordering.
Definition: StripDesign.cxx:13
MuonGMR4::StripDesign::stripPitch
double stripPitch() const
Distance between two adjacent strips.
MuonGMR4::StripDesign::m_halfX
double m_halfX
Definition: StripDesign.h:200
MuonGMR4::operator<<
std::ostream & operator<<(std::ostream &ostr, const CutOutArea &cut)
Definition: CutOutArea.h:23
MuonGMR4::StripDesign::m_topRight
Amg::Vector2D m_topRight
Bottom right point of the trapezoid.
Definition: StripDesign.h:183
MuonGMR4::StripDesign::m_numStrips
int m_numStrips
Number of all strips.
Definition: StripDesign.h:154
MuonGMR4::StripDesign::operator<
bool operator<(const StripDesign &other) const
Odering operator.
Definition: StripDesign.cxx:26
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32