ATLAS Offline Software
Loading...
Searching...
No Matches
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
13namespace 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;
32 m_nStrips = nStrips;
33 m_pitch = pitch;
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
51std::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
58int 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);
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);
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
140std::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
162 SiCellId id = cellIdOfPosition(pos);
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
210 return m_length*m_nRows;
211}
212
213double StripBoxDesign::width() const {
214 return m_pitch * m_nStrips;
215}
216
218 return width();
219}
220
222 return width();
223}
224
226 return m_length;
227}
228
229HepGeom::Vector3D<double> StripBoxDesign::phiMeasureSegment(const SiLocalPosition & /*position*/)
230const {
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
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
double thickness() const
Method which returns thickness of the silicon wafer.
int readoutSide() const
ReadoutSide.
SCT_ModuleSideDesign(const double thickness, const bool phiSymmetric, const bool etaSymmetric, const bool depthSymmetric, const int crystals, const int diodes, const int cells, const int shift, const bool swapStripReadout, InDetDD::CarrierType carrierType, int readoutSide)
Constructor with parameters: local axis corresponding to eta direction local axis corresponding to ph...
Identifier for the strip or pixel cell.
Definition SiCellId.h:29
int phiIndex() const
Get phi index. Equivalent to strip().
Definition SiCellId.h:122
bool isValid() const
Test if its in a valid state.
Definition SiCellId.h:136
Class to handle the position of the centre and the width of a diode or a cluster of diodes Version 1....
Class to represent a position in the natural frame of a silicon sensor, for Pixel and SCT For Pixel: ...
double xPhi() const
position along phi direction:
Trk::RectangleBounds m_bounds
virtual double minWidth() const override
Method to calculate minimum width of a module.
virtual double maxWidth() const override
Method to calculate maximum width of a module.
virtual void distanceToDetectorEdge(const SiLocalPosition &localPosition, double &etaDist, double &phiDist) const override
DEPRECATED: Unused (2014)
virtual const Amg::Transform3D moduleShift() const override final
virtual SiCellId cellIdOfPosition(const SiLocalPosition &localPos) const override
position -> id
virtual bool inActiveArea(const SiLocalPosition &chargePos, bool checkBondGap=true) const override
check if the position is in active area
std::pair< int, int > getStripRow(SiCellId id) const final
Get the strip and row number of the cell.
virtual int strip(int stripId1Dim) const override
virtual int row(int stripId1Dim) const override
virtual std::pair< SiLocalPosition, SiLocalPosition > endsOfStrip(const SiLocalPosition &position) const override
Give end points of the strip that covers the given position.
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 ...
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...
virtual SiCellId cellIdInRange(const SiCellId &) const override
DEPRECATED: only used in a stupid example (2014) Check if cell is in range.
SiLocalPosition positionFromStrip(const SiCellId &cellId) const
virtual double length() const override
Method to calculate length of a module.
virtual double etaPitch() const override
double pitch(const SiCellId &cellId) const
virtual HepGeom::Vector3D< double > phiMeasureSegment(const SiLocalPosition &position) const override
Helper method for stereo angle computation, DEPRECATED.
virtual const Trk::SurfaceBounds & bounds() const override
Element boundary.
virtual double width() const override
Method to calculate average width of a module.
virtual SiLocalPosition localPositionOfCluster(const SiCellId &cellId, int clusterSize) const override
virtual int strip1Dim(int strip, int row) const override
only relevant for SCT.
virtual SiLocalPosition localPositionOfCell(const SiCellId &cellId) const override
id -> position
virtual SiDiodesParameters parameters(const SiCellId &cellId) const override
Return strip width, centre, length etc. Hard to find if this is used or not.
Bounds for a rectangular, planar surface.
Abstract base class for surface bounds to be specified.
Eigen::Affine3d Transform3D
Eigen::Translation< double, 3 > Translation3D
Message Stream Member.