ATLAS Offline Software
MuonPadDesign.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  properties of a plane based detector allowing for a stereo angle
7  ----------------------------------------------------------------------
8 ***************************************************************************/
9 
10 #ifndef MUONREADOUTGEOMETRY_MUONPADDESIGN_H
11 #define MUONREADOUTGEOMETRY_MUONPADDESIGN_H
12 
13 #include <cmath>
14 #include <utility>
15 #include <vector>
16 
18 #include "CLHEP/Units/SystemOfUnits.h"
19 #include "CxxUtils/ArrayHelper.h"
22 namespace MuonGM {
23 
25 
37  struct MuonPadDesign: public AthMessaging {
38  public:
39  MuonPadDesign();
40  int padEtaMin{0};
41  int padEtaMax{0};
42 
43  double inputRowPitch{0.};
44  double inputPhiPitch{0.};
45  double signY{0.};
46  double firstRowPos{0.};
47  double firstPhiPos{0.};
48 
49  double Length{0.};
50  double sWidth{0.};
51  double lWidth{0.};
52  double Size{0.};
53  double thickness{0.};
54  double radialDistance{0.};
55 
56  double sPadWidth{0.};
57  double lPadWidth{0.};
58  double xFrame{0.};
59  double ysFrame{0.};
60  double ylFrame{0.};
61  double yCutout{0.};
62  int nPadH{0};
63  int nPadColumns{0};
64  double PadPhiShift{0.};
65  int etasign{0};
66  int isLargeSector{0};
67  double sectorOpeningAngle{0.};
68 
69  static constexpr double largeSectorOpeningAngle{28.0};
70  static constexpr double smallSectorOpeningAngle{17.0};
71 
72  std::pair<int, int> etaPhiId(const int channel) const;
73  int channelId(const std::pair<int, int>& padId) const;
74 
75 
77  double distanceToChannel(const Amg::Vector2D& pos, bool measPhi, int channel = 0) const;
78 
80 
82  bool withinSensitiveArea(const Amg::Vector2D& pos) const;
84  double minSensitiveY() const;
86  double maxSensitiveY() const;
88  double maxAbsSensitiveX(const double& y) const;
89 
91  std::pair<int, int> channelNumber(const Amg::Vector2D& pos) const;
92 
94  bool channelPosition(const std::pair<int, int>& pad, Amg::Vector2D& pos) const;
95  bool channelPosition(const int channel, Amg::Vector2D& pos) const;
96 
98  using CornerArray = std::array<Amg::Vector2D, 4>;
100  bool channelCorners(const std::pair<int, int>& pad, CornerArray& corners) const;
101  bool channelCorners(const int channel, CornerArray& corners) const;
103  double channelWidth(const Amg::Vector2D& pos, bool measPhi, bool preciseMeas = false) const;
104 
106  double gasGapThickness() const;
107 
109  void setR(double R) { this->radialDistance = R; }
110  };
111 
112  inline std::pair<int, int> MuonPadDesign::etaPhiId(const int channel) const {
113  return std::make_pair( ((channel -1) % 18) + 1, ( (channel -1) / 18) + 1);
114  }
115  inline int MuonPadDesign::channelId(const std::pair<int, int>& padId) const {
116  return 1 + (padId.first - 1) + (padId.second - 1 ) * 18;
117  }
118 
119  inline double MuonPadDesign::distanceToChannel(const Amg::Vector2D& pos, bool measPhi, int channel) const {
120  // if channel number not provided, get the nearest channel ( mostly for validation purposes )
121 
122  std::pair<int, int> pad{};
123  if (channel < 1) { // retrieve nearest pad indices
124  pad = channelNumber(pos);
125  } else { // hardcode - or add a member saving idHelper max
126  pad = etaPhiId(channel);
127  }
128 
130  if (!channelPosition(pad, chPos)) return -10000.;
131 
132  if (!measPhi) return (pos.y() - chPos.y());
133 
134  // the "phi" distance to be compared with channel width (taking into account the stereo angle)
135 
136  return (pos.x() - chPos.x());
137  }
138 
139  inline double MuonPadDesign::channelWidth(const Amg::Vector2D& pos, bool measPhi, bool preciseMeas) const {
140  // get Eta and Phi indices, and corner positions of given pad
141  const std::pair<int, int>& pad = channelNumber(pos);
142  std::array<Amg::Vector2D,4> corners{make_array<Amg::Vector2D, 4>(Amg::Vector2D::Zero())};
143  channelCorners(pad, corners);
144 
145  // For eta pad measurement, return height of given pad
146  if (!measPhi) return corners.at(2)[1] - corners.at(0)[1];
147 
148  // Return the width at the top of the pads
149  /* This is used by default and allows for track/segment association to pads to work correctly
150  In these cases, the given position of the pad is always its centre so we can not know the
151  precise position where we want to compute the width so its best to give a larger value
152  */
153  if (!preciseMeas) return corners.at(3)[0] - corners.at(2)[0];
154 
155  // Return precise Phi width for a given precise position on the pad
156  /* This is only used when the precise position of a hit, track or segment is known on the pad
157  Only to be used in specific cases, like in the digitization when we need to know the exact
158  width along a certain point in the pad, e.g. for charge sharing.
159  */
160 
161  double WidthTop = corners.at(3)[0] - corners.at(2)[0];
162  double WidthBot = corners.at(1)[0] - corners.at(0)[0];
163  return WidthBot + (WidthTop - WidthBot) * (pos.y() - corners.at(0)[1]) / (corners.at(2)[1]-corners.at(0)[1]);
164  }
165 
166  inline double MuonPadDesign::gasGapThickness() const { return thickness; }
167 
168 } // namespace MuonGM
169 #endif // MUONREADOUTGEOMETRY_MUONPADDESIGN_H
MuonGM::MuonPadDesign::ysFrame
double ysFrame
Definition: MuonPadDesign.h:65
MuonGM::MuonPadDesign::topRight
@ topRight
Definition: MuonPadDesign.h:105
MuonGM::MuonPadDesign::firstPhiPos
double firstPhiPos
Definition: MuonPadDesign.h:53
MuonGM::MuonPadDesign::channelNumber
std::pair< int, int > channelNumber(const Amg::Vector2D &pos) const
calculate local channel number, range 1=nstrips like identifiers.
Definition: MuonPadDesign.cxx:39
MuonGM
Ensure that the Athena extensions are properly loaded.
Definition: GeoMuonHits.h:27
MuonGM::MuonPadDesign::CornerArray
std::array< Amg::Vector2D, 4 > CornerArray
calculate local channel corners for a given channel number
Definition: MuonPadDesign.h:104
MuonGM::MuonPadDesign::channelPosition
bool channelPosition(const std::pair< int, int > &pad, Amg::Vector2D &pos) const
calculate local channel position for a given channel number
Definition: MuonPadDesign.cxx:112
MuonGM::MuonPadDesign::lWidth
double lWidth
Definition: MuonPadDesign.h:57
MuonGM::MuonPadDesign::botLeft
@ botLeft
Definition: MuonPadDesign.h:105
sTgcIdHelper.h
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
MuonGM::MuonPadDesign::maxAbsSensitiveX
double maxAbsSensitiveX(const double &y) const
largest (abs, local) x of the sensitive volume
Definition: MuonPadDesign.cxx:26
CornerArray
MuonGM::MuonPadDesign::CornerArray CornerArray
Definition: sTgcPadPlottingAlg.cxx:19
MuonGM::MuonPadDesign::minSensitiveY
double minSensitiveY() const
lowest y (local) of the sensitive volume
Definition: MuonPadDesign.cxx:22
MuonGM::MuonPadDesign::MuonPadDesign
MuonPadDesign()
Definition: MuonPadDesign.cxx:12
MuonGM::MuonPadDesign::Size
double Size
Definition: MuonPadDesign.h:58
MuonGM::MuonPadDesign::radialDistance
double radialDistance
DT-2015-11-29 distance from the beamline to the center of the module.
Definition: MuonPadDesign.h:60
MuonGM::MuonPadDesign::lPadWidth
double lPadWidth
Definition: MuonPadDesign.h:63
MuonGM::MuonPadDesign::largeSectorOpeningAngle
static constexpr double largeSectorOpeningAngle
Definition: MuonPadDesign.h:75
MuonGM::MuonPadDesign::channelId
int channelId(const std::pair< int, int > &padId) const
Definition: MuonPadDesign.h:118
MuonGM::MuonPadDesign::sWidth
double sWidth
Definition: MuonPadDesign.h:56
MuonGM::MuonPadDesign::nPadH
int nPadH
Definition: MuonPadDesign.h:68
MuonGM::MuonPadDesign::maxSensitiveY
double maxSensitiveY() const
highest y (local) of the sensitive volume
Definition: MuonPadDesign.cxx:24
MuonGM::MuonPadDesign::etasign
int etasign
Definition: MuonPadDesign.h:71
MuonGM::MuonPadDesign::setR
void setR(double R)
access to cache
Definition: MuonPadDesign.h:115
GeoPrimitives.h
MuonGM::MuonPadDesign::botRight
@ botRight
Definition: MuonPadDesign.h:105
MuonGM::MuonPadDesign::thickness
double thickness
Definition: MuonPadDesign.h:59
MuonGM::MuonPadDesign::padEtaMax
int padEtaMax
Definition: MuonPadDesign.h:47
MuonGM::MuonPadDesign::gasGapThickness
double gasGapThickness() const
thickness of gas gap
Definition: MuonPadDesign.h:169
MuonGM::MuonPadDesign::inputRowPitch
double inputRowPitch
Definition: MuonPadDesign.h:49
ArrayHelper.h
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
MuonGM::MuonPadDesign::ylFrame
double ylFrame
Definition: MuonPadDesign.h:66
MuonGM::MuonPadDesign::channelWidth
double channelWidth(const Amg::Vector2D &pos, bool measPhi, bool preciseMeas=false) const
calculate local channel width
Definition: MuonPadDesign.h:142
MuonGM::MuonPadDesign::padCorners
padCorners
Definition: MuonPadDesign.h:105
MuonGM::MuonPadDesign::nPadColumns
int nPadColumns
Definition: MuonPadDesign.h:69
MuonGM::MuonPadDesign::signY
double signY
Definition: MuonPadDesign.h:51
MuonGM::MuonPadDesign::isLargeSector
int isLargeSector
Definition: MuonPadDesign.h:72
MuonGM::MuonPadDesign::firstRowPos
double firstRowPos
Definition: MuonPadDesign.h:52
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
MuonGM::MuonPadDesign::Length
double Length
Definition: MuonPadDesign.h:55
MuonGM::MuonPadDesign::channelCorners
bool channelCorners(const std::pair< int, int > &pad, CornerArray &corners) const
Definition: MuonPadDesign.cxx:157
y
#define y
AthMessaging.h
MuonGM::MuonPadDesign::distanceToChannel
double distanceToChannel(const Amg::Vector2D &pos, bool measPhi, int channel=0) const
distance to channel - residual
Definition: MuonPadDesign.h:122
MuonGM::MuonPadDesign::PadPhiShift
double PadPhiShift
Definition: MuonPadDesign.h:70
MuonGM::MuonPadDesign::yCutout
double yCutout
Definition: MuonPadDesign.h:67
MuonGM::MuonPadDesign::sectorOpeningAngle
double sectorOpeningAngle
Definition: MuonPadDesign.h:73
MuonGM::MuonPadDesign::sPadWidth
double sPadWidth
Definition: MuonPadDesign.h:62
MuonGM::MuonPadDesign::withinSensitiveArea
bool withinSensitiveArea(const Amg::Vector2D &pos) const
whether pos is within the sensitive area of the module
Definition: MuonPadDesign.cxx:13
MuonGM::MuonPadDesign::smallSectorOpeningAngle
static constexpr double smallSectorOpeningAngle
Definition: MuonPadDesign.h:76
MuonGM::MuonPadDesign::xFrame
double xFrame
Definition: MuonPadDesign.h:64
MuonGM::MuonPadDesign::distanceToPad
Amg::Vector2D distanceToPad(const Amg::Vector2D &pos, int channel) const
Definition: MuonPadDesign.cxx:118
MuonGM::MuonPadDesign::topLeft
@ topLeft
Definition: MuonPadDesign.h:105
MuonGM::MuonPadDesign::padEtaMin
int padEtaMin
Definition: MuonPadDesign.h:46
MuonGM::MuonPadDesign::inputPhiPitch
double inputPhiPitch
Definition: MuonPadDesign.h:50
MuonGM::MuonPadDesign::etaPhiId
std::pair< int, int > etaPhiId(const int channel) const
Definition: MuonPadDesign.h:115
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32