ATLAS Offline Software
StripBoxDesign.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "GeoModelKernel/Units.h"
8 #include "Identifier/Identifier.h"
9 
10 #include <stdexcept>
11 #include <cmath>
12 
13 namespace InDetDD {
15  const SiDetectorDesign::Axis thicknessDirection,
16  const double thickness,
17  const int readoutSide,
18  const InDetDD::CarrierType carrier,
19  const int nRows,
20  const int nStrips,
21  const double pitch,
22  const double length,
23  InDetDD::DetectorType detectorType,
24  const double zShift) :
25  SCT_ModuleSideDesign(thickness, true, true, true, 1, nRows * nStrips, nRows * nStrips, 0, false, carrier,readoutSide, stripDirection, thicknessDirection) {
26  if (nRows <= 0) {
27  throw std::runtime_error(
28  "ERROR: StripBoxDesign called with non-positive number of rows");
29  }
30 
31  m_nRows = nRows;
33  m_pitch = pitch;
34  m_length = length;
35  m_zShift = zShift;
36  m_detectorType = detectorType;
37 
38  double width = m_nStrips * m_pitch;
39  double fullLength = m_nRows * m_length;
40  m_bounds = Trk::RectangleBounds(width / 2.0, fullLength / 2.0);
41 }
42 
51 std::pair<int,int> StripBoxDesign::getStripRow(SiCellId cellId) const {
52  int strip1D = cellId.phiIndex();
53  int row = strip1D / m_nStrips;
54  int strip = strip1D % m_nStrips;
55  return {strip,row};
56 }
57 
58 int StripBoxDesign::strip1Dim(int strip, int row) const {
59  return m_nStrips * row + strip;
60 }
61 
63  std::vector<SiCellId> &neighbours) const {
64 
65 
66  neighbours.clear();
67 
68  if (!cellId.isValid()) {
69  return;
70  }
71 
72  auto [strip, row] = getStripRow(cellId);
73  int stripM = strip - 1;
74  int stripP = strip + 1;
75 
76  if (stripM >= 0) {
77  neighbours.emplace_back(stripM);
78  }
79  if (stripP < m_nStrips) {
80  neighbours.emplace_back(stripP);
81  }
82 
83 }
84 
86 // Return smallest rectangle that fully encompasses the active area.
87 
88  return m_bounds;
89 }
90 
92 //
93 // Find the row
94 //
95  int strip = static_cast<int>(std::floor(pos.xPhi() / m_pitch) + m_nStrips / 2);
96  if (strip < 0 || strip >= m_nStrips) {
97 
98  return {}; // return an invalid id
99  }
100  int row=0;
101  if(m_nRows>1){
102  row = static_cast<int>(std::floor(pos.xEta() / m_length) + m_nRows / 2);
103  if (row < 0 || row >= m_nRows) {
104 
105  return {}; // return an invalid id
106  }
107  }
108  int strip1D = strip1Dim(strip, row);
109 
110  return {strip1D, 0};
111 }
112 
114 
115  auto [strip, row] = getStripRow(cellId);
116  double eta = ((double) row - (double) m_nRows / 2. + 0.5) * m_length;
117 
118  double phi = ((double) strip - (double) m_nStrips / 2. + 0.5) * m_pitch;
119 
120 
121  return SiLocalPosition(eta, phi, 0.0);
122 }
123 
125  int clusterSize) const {
126 
128 
129  if (clusterSize <= 1) {
130  return pos;
131  }
132 
133  double clusterWidth = clusterSize * m_pitch;
134  pos.xPhi(pos.xPhi() + clusterWidth / 2.); // get then set xPhi
135 
136  return pos;
137 }
138 
140 std::pair<SiLocalPosition, SiLocalPosition> StripBoxDesign::endsOfStrip(
141  SiLocalPosition const &pos) const {
142 
143  SiCellId cellId = cellIdOfPosition(pos);
144 
145  auto [strip, row] = getStripRow(cellId);
146 
147  double etaStart = (row - m_nRows / 2.) * m_length;
148  double etaEnd = etaStart + m_length;
149 
150  double phi = (strip - m_nStrips / 2. + 0.5) * m_pitch;
151 // cout << "etaStart = " << etaStart << "; etaEnd = " << etaEnd << "; phi coord. = " << phi << endl;
152 
153  SiLocalPosition end1(etaStart, phi, 0.0);
154  SiLocalPosition end2(etaEnd, phi, 0.0);
155 
156  return std::pair<SiLocalPosition, SiLocalPosition>(end1, end2);
157 }
158 
160  bool /*checkBondGap*/) const {
161 
163 
164 
165  return id.isValid();
166 }
167 
168 // Used in surfaceChargesGenerator
170 
171  SiCellId cellId = cellIdOfPosition(pos);
172  SiLocalPosition posStrip = localPositionOfCell(cellId);
173 
174 
175  return std::abs(pos.xPhi() - posStrip.xPhi()) / m_pitch;
176 }
177 
180  throw std::runtime_error("Call to StripBoxDesign::parameters; not yet implemented");
181 }
182 
183 // Used in VP1 graphics. DEPRECATED.
185 // throw std::runtime_error("Deprecated positionFromStrip called.");
186  return localPositionOfCell(cellId);
187 }
188 
189 // DEPRECATED but pure virtual in base class; which row?? - assume row 0.
191  return localPositionOfCell(SiCellId(stripNumber, 0));
192 }
193 
196 // returns an invalid id.
198 
199  if (!cellId.isValid()) {
200  return {}; // Invalid
201  }
202  auto [strip, row] = getStripRow(cellId);
203  if (strip < 0 || row < 0 || row >= m_nRows || strip >= m_nStrips) {
204  return {}; // Invalid
205  }
206  return cellId;
207 }
208 
209 double StripBoxDesign::length() const {
210  return m_length*m_nRows;
211 }
212 
213 double StripBoxDesign::width() const {
214  return m_pitch * m_nStrips;
215 }
216 
217 double StripBoxDesign::minWidth() const {
218  return width();
219 }
220 
221 double StripBoxDesign::maxWidth() const {
222  return width();
223 }
224 
225 double StripBoxDesign::etaPitch() const {
226  return m_length;
227 }
228 
229 HepGeom::Vector3D<double> StripBoxDesign::phiMeasureSegment(const SiLocalPosition & /*position*/)
230 const {
231  throw std::runtime_error("Call to phiMeasureSegment, DEPRECATED, not implemented.");
232 }
233 
236  double & etaDist,
237  double & phiDist) const {
238 
239  // As the calculation is symmetric around 0,0 we only have to test it for one side.
240  double xEta = std::abs(pos.xEta()); //assuming centered around 0?!?
241  double xPhi = std::abs(pos.xPhi());
242 
243  double xEtaEdge = 0.5 * length();
244  double xPhiEdge = 0.5 * width();
245 
246  // Distance to top/bottom
247  etaDist = xEtaEdge - xEta;
248 
249  // Distance to right/left edge
250  phiDist = xPhiEdge - xPhi;
251 
252 
253 }
254 
256  //local x is global Z (along strip)
257  //This is defined by the detector geometry
258  //i.e. <param name="stripDirection" value="x"/>
259  //in Sensors.gmx
260  return Amg::Translation3D(m_zShift,0.0, 0.0) * Amg::RotationMatrix3D::Identity();
261  }
262 
263 } // namespace InDetDD
InDetDD::StripBoxDesign::positionFromStrip
SiLocalPosition positionFromStrip(const SiCellId &cellId) const
Definition: StripBoxDesign.cxx:184
query_example.row
row
Definition: query_example.py:24
Trk::RectangleBounds
Definition: RectangleBounds.h:38
InDetDD::StripBoxDesign::m_bounds
Trk::RectangleBounds m_bounds
Definition: StripBoxDesign.h:163
InDetDD::StripBoxDesign::scaledDistanceToNearestDiode
virtual double scaledDistanceToNearestDiode(const SiLocalPosition &chargePos) const override
give distance to the nearest diode in units of pitch, from 0.0 to 0.5, this method should be fast as ...
Definition: StripBoxDesign.cxx:169
StripBoxDesign.h
InDetDD::StripBoxDesign::parameters
virtual SiDiodesParameters parameters(const SiCellId &cellId) const override
Return strip width, centre, length etc. Hard to find if this is used or not.
Definition: StripBoxDesign.cxx:179
InDetDD::StripBoxDesign::cellIdOfPosition
virtual SiCellId cellIdOfPosition(const SiLocalPosition &localPos) const override
position -> id
Definition: StripBoxDesign.cxx:91
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
InDetDD::SCT_ModuleSideDesign
Definition: SCT_ModuleSideDesign.h:40
Trk::SurfaceBounds
Definition: SurfaceBounds.h:47
InDetDD::StripBoxDesign::m_nRows
int m_nRows
Definition: StripBoxDesign.h:158
InDetDD::StripBoxDesign::length
virtual double length() const override
Method to calculate length of a module.
Definition: StripBoxDesign.cxx:209
InDetDD::StripBoxDesign::minWidth
virtual double minWidth() const override
Method to calculate minimum width of a module.
Definition: StripBoxDesign.cxx:217
InDetDD::SiCellId::isValid
bool isValid() const
Test if its in a valid state.
Definition: SiCellId.h:136
InDetDD::StripBoxDesign::localPositionOfCell
virtual SiLocalPosition localPositionOfCell(const SiCellId &cellId) const override
id -> position
Definition: StripBoxDesign.cxx:113
InDetDD::StripBoxDesign::m_pitch
double m_pitch
Definition: StripBoxDesign.h:160
InDetDD::StripBoxDesign::StripBoxDesign
StripBoxDesign()
InDetDD::DetectorDesign::Axis
Axis
Definition: DetectorDesign.h:59
InDetDD::SiCellId::phiIndex
int phiIndex() const
Get phi index. Equivalent to strip().
Definition: SiCellId.h:122
InDetDD::StripBoxDesign::width
virtual double width() const override
Method to calculate average width of a module.
Definition: StripBoxDesign.cxx:213
InDetDD::SiLocalPosition
Definition: SiLocalPosition.h:31
InDetDD::SiLocalPosition::xPhi
double xPhi() const
position along phi direction:
Definition: SiLocalPosition.h:123
InDetDD::StripBoxDesign::etaPitch
virtual double etaPitch() const override
Definition: StripBoxDesign.cxx:225
InDetDD::StripBoxDesign::m_length
double m_length
Definition: StripBoxDesign.h:161
InDetDD::DetectorType
DetectorType
Definition: DetectorDesign.h:45
InDetDD::SCT_ModuleSideDesign::m_detectorType
InDetDD::DetectorType m_detectorType
Definition: SCT_ModuleSideDesign.h:197
InDetDD::StripBoxDesign::m_nStrips
int m_nStrips
Definition: StripBoxDesign.h:159
InDetDD::StripBoxDesign::phiMeasureSegment
virtual HepGeom::Vector3D< double > phiMeasureSegment(const SiLocalPosition &position) const override
Helper method for stereo angle computation, DEPRECATED.
Definition: StripBoxDesign.cxx:229
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
InDetDD::StripBoxDesign::getStripRow
std::pair< int, int > getStripRow(SiCellId id) const final
Get the strip and row number of the cell.
Definition: StripBoxDesign.cxx:51
InDetDD::StripBoxDesign::row
virtual int row(int stripId1Dim) const override
Definition: StripBoxDesign.h:216
InDetDD::StripBoxDesign::distanceToDetectorEdge
virtual void distanceToDetectorEdge(const SiLocalPosition &localPosition, double &etaDist, double &phiDist) const override
DEPRECATED: Unused (2014)
Definition: StripBoxDesign.cxx:235
MuonGM::nStrips
int nStrips(const MuonGM::TgcReadoutElement &readoutEle, int layer)
Definition: MuonDetDescr/MuonGeoModelTest/src/GeoModelTgcTest.cxx:46
InDetDD::StripBoxDesign::bounds
virtual const Trk::SurfaceBounds & bounds() const override
Element boundary.
Definition: StripBoxDesign.cxx:85
InDetDD::StripBoxDesign::localPositionOfCluster
virtual SiLocalPosition localPositionOfCluster(const SiCellId &cellId, int clusterSize) const override
Definition: StripBoxDesign.cxx:124
InDetDD::StripBoxDesign::m_zShift
double m_zShift
Definition: StripBoxDesign.h:162
InDetDD::StripBoxDesign::cellIdInRange
virtual SiCellId cellIdInRange(const SiCellId &) const override
DEPRECATED: only used in a stupid example (2014) Check if cell is in range.
Definition: StripBoxDesign.cxx:197
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
InDetDD::SiCellId
Definition: SiCellId.h:29
InDetDD::StripBoxDesign::pitch
double pitch(const SiCellId &cellId) const
InDetDD::StripBoxDesign::neighboursOfCell
virtual void neighboursOfCell(const SiCellId &cellId, std::vector< SiCellId > &neighbours) const override
Get the neighbouring diodes of a given diode: Cell for which the neighbours must be found List of cel...
Definition: StripBoxDesign.cxx:62
InDetDD::StripBoxDesign::maxWidth
virtual double maxWidth() const override
Method to calculate maximum width of a module.
Definition: StripBoxDesign.cxx:221
InDetDD::StripBoxDesign::inActiveArea
virtual bool inActiveArea(const SiLocalPosition &chargePos, bool checkBondGap=true) const override
check if the position is in active area
Definition: StripBoxDesign.cxx:159
InDetDD::CarrierType
CarrierType
Definition: InDetDD_Defs.h:17
InDetDD
Message Stream Member.
Definition: FakeTrackBuilder.h:8
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
InDetDD::StripBoxDesign::strip
virtual int strip(int stripId1Dim) const override
Definition: StripBoxDesign.h:220
InDetDD::StripBoxDesign::moduleShift
virtual const Amg::Transform3D moduleShift() const override final
Definition: StripBoxDesign.cxx:255
InDetDD::StripBoxDesign::strip1Dim
virtual int strip1Dim(int strip, int row) const override
only relevant for SCT.
Definition: StripBoxDesign.cxx:58
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
InDetDD::StripBoxDesign::endsOfStrip
virtual std::pair< SiLocalPosition, SiLocalPosition > endsOfStrip(const SiLocalPosition &position) const override
Give end points of the strip that covers the given position.
Definition: StripBoxDesign.cxx:140
InDetDD::SiDiodesParameters
Definition: SiDiodesParameters.h:25