ATLAS Offline Software
Loading...
Searching...
No Matches
MMReadoutElement.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef MUONREADOUTGEOMETRY_MMREADOUTELEMENT_H
6#define MUONREADOUTGEOMETRY_MMREADOUTELEMENT_H
7
13
14class BLinePar;
15namespace MuonGMR4{
17}
18
19namespace MuonGM {
24
26 public:
29 MMReadoutElement(GeoVFullPhysVol* pv, const std::string& stName, int zi, int fi, int mL,
31
34
36 virtual bool containsId(const Identifier& id) const override final;
37
40 virtual double distanceToReadout(const Amg::Vector2D& pos, const Identifier& id) const override final;
41
44 virtual int stripNumber(const Amg::Vector2D& pos, const Identifier& id) const override final;
45
48 virtual bool stripPosition(const Identifier& id, Amg::Vector2D& pos) const override final;
49 bool stripGlobalPosition(const Identifier& id, Amg::Vector3D& gpos) const;
50
52 double stereoAngle(const Identifier& id) const;
53
56 double stripLength(const Identifier& id) const;
57 double stripActiveLength(const Identifier& id) const;
58 double stripActiveLengthLeft(const Identifier& id) const;
59 double stripActiveLengthRight(const Identifier& id) const;
60
63 bool insideActiveBounds(const Identifier& id, const Amg::Vector2D& locpos, double tol1 = 0., double tol2 = 0.) const;
64
66 virtual int numberOfLayers(bool) const override;
67
69 virtual int numberOfStrips(const Identifier& layerId) const override final;
70 virtual int numberOfStrips(int, bool measuresPhi) const override final;
71
73 int numberOfMissingTopStrips(const Identifier& layerId) const;
74 int numberOfMissingBottomStrips(const Identifier& layerId) const;
75
79 virtual bool spacePointPosition(const Identifier& phiId, const Identifier& etaId, Amg::Vector2D& pos) const override final;
80
83 virtual bool spacePointPosition(const Identifier& phiId, const Identifier& etaId, Amg::Vector3D& pos) const override final;
86 Amg::Vector3D localToGlobalCoords(const Amg::Vector3D& locPos, const Identifier& id) const;
87
91 bool spacePointPosition(const Identifier& layerId, const Amg::Vector2D& localPos, Amg::Vector3D& pos) const;
92
94 virtual void fillCache() override final;
95
97 virtual int surfaceHash(const Identifier& id) const override final;
98
100 int surfaceHash(int gasGap, int measPhi) const;
101
103 virtual int layerHash(const Identifier& id) const override final;
105 int layerHash(int gasGap) const;
106
108 virtual int boundaryHash(const Identifier& id) const override final;
109
111 virtual bool measuresPhi(const Identifier& id) const override final;
112
114 void initDesign();
115
118
120 void setChamberLayer(int ml) { m_ml = ml; }
121
124 const Amg::Transform3D& getDelta() const { return m_delta; }
125 void setDelta(const ALinePar& aline);
126
128 void setBLinePar(const BLinePar& bLine);
129
131 void posOnDefChamber(Amg::Vector3D& locPosML) const;
132
133 bool has_ALines() const { return (m_ALinePar != nullptr); }
134 bool has_BLines() const { return (m_BLinePar != nullptr); }
135 const ALinePar* getALinePar() const { return m_ALinePar; }
136 const BLinePar* getBLinePar() const { return m_BLinePar; }
137 void clearALinePar();
138 void clearBLinePar() { m_BLinePar = nullptr; }
139 const std::array<int, 4> & getReadoutSide() const { return m_readoutSide; }
140
141 // Amdb local (szt) to global coord
142 virtual Amg::Vector3D AmdbLRSToGlobalCoords(const Amg::Vector3D& x) const override final { return AmdbLRSToGlobalTransform()*x; }
144 // Global to Amdb local (szt) coord
145 virtual Amg::Vector3D GlobalToAmdbLRSCoords(const Amg::Vector3D& x) const override final { return GlobalToAmdbLRSTransform()*x; }
146 virtual Amg::Transform3D GlobalToAmdbLRSTransform() const override final { return AmdbLRSToGlobalTransform().inverse(); }
147
148 private:
149
150 void initDesignSqLite();
151
153
155 static constexpr PCBPassivation s_dummy_passiv{};
156 // MuonChannelDesign m_phiDesign;
157 std::array<MuonChannelDesign, 4> m_etaDesign{};
158
159 int m_nlayers{0}; // #of gas gaps
160
161
162 int m_ml{0}; // multilayer (values: 1,2)
163
164 // surface dimensions
165 double m_halfX{100.}; // 0.5*radial_size (active area)
166 double m_minHalfY{1900.}; // 0.5*bottom length (active area)
167 double m_maxHalfY{2000.}; // 0.5*top length (active area)
168 double m_offset{0.}; // radial dist. of active area center w.r.t. chamber center
169
170 Amg::Transform3D m_delta{Amg::Transform3D::Identity()};
171 const ALinePar* m_ALinePar{nullptr};
172 const BLinePar* m_BLinePar{nullptr};
173 std::array<int, 4> m_readoutSide{};
174 // transforms (RE->layer)
175 std::array<Amg::Transform3D, 4> m_Xlg{make_array<Amg::Transform3D,4>(Amg::Transform3D::Identity())};
176 };
177
178 inline int MMReadoutElement::surfaceHash(const Identifier& id) const { return surfaceHash(m_idHelper.gasGap(id), 0); }
179
180 inline int MMReadoutElement::surfaceHash(int gasGap, int /*measPhi*/) const { return gasGap - 1; } // measPhi not used
181
182 inline int MMReadoutElement::layerHash(const Identifier& id) const { return layerHash(m_idHelper.gasGap(id)); }
183
184 inline int MMReadoutElement::layerHash(int gasGap) const { return gasGap - 1; }
185
186 inline int MMReadoutElement::boundaryHash(const Identifier& id) const { return layerHash(m_idHelper.gasGap(id)); }
187
188 inline bool MMReadoutElement::measuresPhi(const Identifier& /*id*/) const { return false; }
189
191 return &(m_etaDesign[layerHash(id)]);
192 }
193 inline double MMReadoutElement::distanceToReadout(const Amg::Vector2D& pos, const Identifier& id) const {
194 const MuonChannelDesign* design = getDesign(id);
195 if (!design) return -1.;
196 return design->distanceToReadout(pos);
197 }
198
199 inline int MMReadoutElement::stripNumber(const Amg::Vector2D& pos, const Identifier& id) const {
200 // returns the position of the strip at pos, assuming the nominal geometry (no as-built conditions)
201 const MuonChannelDesign* design = getDesign(id);
202 if (!design) return -1;
203 return design->channelNumber(pos);
204 }
205
206 inline bool MMReadoutElement::stripPosition(const Identifier& id, Amg::Vector2D& pos) const {
207 const MuonChannelDesign* design = getDesign(id);
208 if (!design) return false;
209 return design->center(m_idHelper.channel(id), pos);
210 }
211
212 inline double MMReadoutElement::stereoAngle(const Identifier& id) const {
213 const MuonChannelDesign* design = getDesign(id);
214 if (!design) return 0;
215 return design->stereoAngle();
216 }
217
218 inline double MMReadoutElement::stripLength(const Identifier& id) const {
219 const MuonChannelDesign* design = getDesign(id);
220 if (!design) return -1;
221 return design->channelLength(m_idHelper.channel(id));
222 }
223
224 inline double MMReadoutElement::stripActiveLength(const Identifier& id) const {
226 }
227
229 const MuonChannelDesign* design = getDesign(id);
230 if (!design) return -1;
231
232 const PCBPassivation& passiv = manager()->getMMPassivation() ?
234
235 double l = design->channelHalfLength(m_idHelper.channel(id), true);
236 if (l < 0) return -1;
237 return std::max(0., l - design->passivatedLength(passiv.left, true));
238 }
239
241 const MuonChannelDesign* design = getDesign(id);
242 if (!design) return -1;
243
244 const PCBPassivation& passiv = manager()->getMMPassivation() ?
246
247 double l = design->channelHalfLength(m_idHelper.channel(id), false);
248 if (l < 0) return -1;
249 return std::max(0., l - design->passivatedLength(passiv.right, false));
250 }
251
252 inline bool MMReadoutElement::insideActiveBounds(const Identifier& id, const Amg::Vector2D& locpos, double tol1, double tol2) const {
253 const MuonChannelDesign* design = getDesign(id);
254 if(!design) return false;
255 // Get the nearest strip number; not the time yet to check boundaries (in case of tolerance)
256 int stripNo = stripNumber(locpos, id);
257 if (stripNo < 0) stripNo = (locpos.x()<0) ? 1 : design->totalStrips;
258 Identifier channelId = m_idHelper.channelID(id, m_ml, m_idHelper.gasGap(id), stripNo);
259
260 // ** Horizontal passivation: mask entire strips
261 //==============================================
262 int pcb = (stripNo-1)/1024 + 1; // starts from 1
263 int pcbStrip = stripNo % 1024;// - 1024*(pcb - 1);
264 const PCBPassivation& pcbPassiv = manager()->getMMPassivation() ?
266 // the passivated width is constant along the PCB edge (not along y for stereo strips)
267 bool topPcb{pcb == 5 || (std::abs(getStationEta()) == 2 && pcb == 3)};
268 int pcbStripMin = 1 + (int)std::floor((design->passivatedHeight(pcbPassiv.bottom, pcb ==1) + 0.5*design->inputPitch - tol1)/design->inputPitch); // first pcb strip surviving passivation
269 int pcbStripMax = 1024 - (int)std::floor((design->passivatedHeight(pcbPassiv.top, topPcb) + 0.5*design->inputPitch - tol1)/design->inputPitch); // last pcb strip surviving passivation
270 if(pcbStrip < pcbStripMin || pcbStrip > pcbStripMax) return false;
271
272 // ** Vertical passivation: cut strips from left and right
273 //=======================================
274 return bounds(id).inside(locpos, tol1, tol2 - design->passivatedLength(locpos[1]<0 ? pcbPassiv.left : pcbPassiv.right , locpos[1] < 0));
275 }
276
278 Amg::Vector2D lpos{Amg::Vector2D::Zero()};
279 if (!stripPosition(id, lpos)) return false;
280 surface(id).localToGlobal(lpos, Amg::Vector3D::Zero(), gpos);
281 return true;
282 }
283
284 inline int MMReadoutElement::numberOfLayers(bool) const { return m_nlayers; }
285
286 inline int MMReadoutElement::numberOfStrips(const Identifier& layerId) const { return m_etaDesign[layerHash(layerId)].totalStrips; }
287
288 inline int MMReadoutElement::numberOfStrips(int lay, bool /*measPhi*/) const {
289 if (lay > -1 && lay < static_cast<int>(m_etaDesign.size()))
290 return m_etaDesign[lay].totalStrips;
291 else
292 return -1;
293 }
294
296 const MuonChannelDesign* design = getDesign(id);
297 if (!design) return -1;
298 return design->numberOfMissingTopStrips();
299 }
300
302 const MuonChannelDesign* design = getDesign(id);
303 if (!design) return -1;
304 return design->numberOfMissingBottomStrips();
305 }
306
307 inline bool MMReadoutElement::spacePointPosition(const Identifier& phiId, const Identifier& etaId, Amg::Vector2D& pos) const {
308 if (!stripPosition(etaId, pos)) return false;
309 const MuonChannelDesign* phi_design = getDesign(phiId);
310 const MuonChannelDesign* eta_design = getDesign(etaId);
311 if (!phi_design || !eta_design) return false;
312 pos = phi_design->rotation() * eta_design->rotation().inverse()*pos;
313 return true;
314 }
315
316 inline bool MMReadoutElement::spacePointPosition(const Identifier& phiId, const Identifier& etaId, Amg::Vector3D& pos) const {
317 Amg::Vector2D lpos{Amg::Vector2D::Zero()};
318 spacePointPosition(phiId, etaId, lpos);
319 surface(phiId).localToGlobal(lpos, pos, pos);
320 return true;
321 }
322
323} // namespace MuonGM
324
325#endif // MUONREADOUTGEOMETRY_MMREADOUTELEMENT_H
constexpr std::array< T, N > make_array(const T &def_val)
Helper function to initialize in-place arrays with non-zero values.
Definition ArrayHelper.h:10
#define x
const BLinePar * getBLinePar() const
const Amg::Transform3D & getDelta() const
read A-line parameters and include the chamber rotation/translation in the local-to-global (ATLAS) re...
int numberOfMissingTopStrips(const Identifier &layerId) const
Number of missing bottom and top strips (not read out)
virtual int boundaryHash(const Identifier &id) const override final
returns the hash function to be used to look up the surface boundary for a given identifier
void posOnDefChamber(Amg::Vector3D &locPosML) const
transform a position (in chamber-frame coordinates) to the deformed-chamber geometry
const std::array< int, 4 > & getReadoutSide() const
virtual Amg::Vector3D AmdbLRSToGlobalCoords(const Amg::Vector3D &x) const override final
virtual int layerHash(const Identifier &id) const override final
returns the hash to be used to look up the normal and center in the MuonClusterReadoutElement trackin...
virtual bool stripPosition(const Identifier &id, Amg::Vector2D &pos) const override final
strip position – local or global If the strip number is outside the range of valid strips,...
virtual int numberOfLayers(bool) const override
number of layers in phi/eta projection
virtual int numberOfStrips(const Identifier &layerId) const override final
number of strips per layer
double stripActiveLengthRight(const Identifier &id) const
double stereoAngle(const Identifier &id) const
Wrapper to MuonChannelDesign::stereoAngle()
virtual int surfaceHash(const Identifier &id) const override final
returns the hash to be used to look up the surface and transform in the MuonClusterReadoutElement tra...
virtual double distanceToReadout(const Amg::Vector2D &pos, const Identifier &id) const override final
distance to readout.
virtual Amg::Transform3D AmdbLRSToGlobalTransform() const override final
bool insideActiveBounds(const Identifier &id, const Amg::Vector2D &locpos, double tol1=0., double tol2=0.) const
boundary check Wrapper Trk::PlaneSurface::insideBounds() taking into account the passivated width
virtual bool containsId(const Identifier &id) const override final
function to be used to check whether a given Identifier is contained in the readout element
~MMReadoutElement()
destructor
virtual bool measuresPhi(const Identifier &id) const override final
returns whether the current identifier corresponds to a phi measurement
std::array< Amg::Transform3D, 4 > m_Xlg
void initDesign()
initialize the design classes for this readout element
MMReadoutElement(GeoVFullPhysVol *pv, const std::string &stName, int zi, int fi, int mL, MuonDetectorManager *mgr)
constructor
void setDelta(const ALinePar &aline)
int numberOfMissingBottomStrips(const Identifier &layerId) const
double stripActiveLength(const Identifier &id) const
Amg::Vector3D localToGlobalCoords(const Amg::Vector3D &locPos, const Identifier &id) const
simHit local (SD) To Global position - to be used by MuonGeoAdaprors only
virtual Amg::Transform3D GlobalToAmdbLRSTransform() const override final
virtual Amg::Vector3D GlobalToAmdbLRSCoords(const Amg::Vector3D &x) const override final
virtual void fillCache() override final
function to fill tracking cache
void setBLinePar(const BLinePar &bLine)
read B-line (chamber-deformation) parameters
virtual bool spacePointPosition(const Identifier &phiId, const Identifier &etaId, Amg::Vector2D &pos) const override final
space point position for a given pair of phi and eta identifiers The LocalPosition is expressed in th...
double stripActiveLengthLeft(const Identifier &id) const
const ALinePar * getALinePar() const
virtual int stripNumber(const Amg::Vector2D &pos, const Identifier &id) const override final
strip number corresponding to local position.
static constexpr PCBPassivation s_dummy_passiv
std::array< int, 4 > m_readoutSide
double stripLength(const Identifier &id) const
strip length Wrappers to MuonChannelDesign::channelLength() taking into account the passivated width
void setChamberLayer(int ml)
set methods only to be used by MuonGeoModel
const MuonChannelDesign * getDesign(const Identifier &id) const
returns the MuonChannelDesign class for the given identifier
bool stripGlobalPosition(const Identifier &id, Amg::Vector3D &gpos) const
const MmIdHelper & m_idHelper
std::array< MuonChannelDesign, 4 > m_etaDesign
NswPassivationDbData::PCBPassivation PCBPassivation
virtual const Trk::PlaneSurface & surface() const override
access to chamber surface (phi orientation), uses the first gas gap
MuonClusterReadoutElement(GeoVFullPhysVol *pv, MuonDetectorManager *mgr, Trk::DetectorElemType detType)
virtual const Trk::SurfaceBounds & bounds() const override
Return the boundaries of the element.
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
virtual const MmIdHelper & mmIdHelper() const =0
access to CscIdHelper
const PCBPassivation & getPassivation(const Identifier &id) const
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const override final
Specified for PlaneSurface: LocalToGlobal method without dynamic memory allocation.
virtual bool inside(const Amg::Vector2D &locpo, double tol1=0., double tol2=0.) const =0
Each Bounds has a method inside, which checks if a LocalPosition is inside the bounds.
Amg::Transform3D getTranslateZ3D(const double Z)
: Returns a shift transformation along the z-axis
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
Ensure that the Athena extensions are properly loaded.
Definition GeoMuonHits.h:27
double stereoAngle() const
returns the stereo angle
bool center(int channel, Amg::Vector2D &pos) const
STRIPS ONLY: Returns the center on the strip.
double channelHalfLength(int st, bool left) const
STRIPS ONLY: calculate channel length on the given side of the x axis (for MM stereo strips)
int numberOfMissingBottomStrips() const
Returns the number of missing bottom strips.
double distanceToReadout(const Amg::Vector2D &pos) const
distance to readout
double passivatedLength(double passivWidth, bool left) const
top edge -> left edge bottom edge -> right edge a rectangle with height H parallel to the inclined ed...
int numberOfMissingTopStrips() const
Returns the number of missing top strips.
double channelLength(int channel) const
STRIPS ONLY: calculate channel length for a given strip number.
double passivatedHeight(double passivHeight, bool edge) const
Passivation is applied parallel to.
int channelNumber(const Amg::Vector2D &pos) const
calculate local channel number, range 1=nstrips like identifiers. Returns -1 if out of range
Helper struct to save the four passivation values of each PCB.