2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 #ifndef MUONREADOUTGEOMETRYR4_TGCREADOUTELEMENT_ICC
5 #define MUONREADOUTGEOMETRYR4_TGCREADOUTELEMENT_ICC
9 template <> inline Amg::Transform3D
10 TransformCacheDetEle<MuonGMR4::TgcReadoutElement>::fetchTransform(const DetectorAlignStore* store) const{
11 return m_parent->toStation(store) * m_parent->fromGapToChamOrigin(hash());
13 template <> inline Identifier
14 TransformCacheDetEle<MuonGMR4::TgcReadoutElement>::identify() const {
15 using RE = MuonGMR4::TgcReadoutElement;
16 return m_parent->measurementId(RE::constructHash(1, RE::gasGapNumber(hash()), RE::isStrip(hash())));
21 inline double TgcReadoutElement::moduleWidthS() const { return 2.*m_pars.halfWidthShort; }
22 inline double TgcReadoutElement::moduleWidthL() const { return 2.*m_pars.halfWidthLong; }
23 inline double TgcReadoutElement::moduleHeight() const { return 2.*m_pars.halfHeight; }
24 inline double TgcReadoutElement::moduleThickness() const { return 2.*m_pars.halfThickness; }
25 inline double TgcReadoutElement::thickness() const { return moduleThickness(); }
26 inline double TgcReadoutElement::gasGapPitch() const {return m_gasThickness; }
28 inline IdentifierHash TgcReadoutElement::constructHash(unsigned int measCh,
31 /// Bit mask layout (measurment channel) | (gasGap [1-3]) | isStrip
32 constexpr unsigned gapShift = 1;
33 constexpr unsigned chanShift = 2 + gapShift;
34 return IdentifierHash{measCh << chanShift | (gasGap -1) << gapShift | isStrip};
36 inline IdentifierHash TgcReadoutElement::measurementHash(const Identifier& measId) const {
37 if (m_idHelper.elementID(measId) != m_idHelper.elementID(identify())) {
38 ATH_MSG_WARNING("The measurement " << idHelperSvc()->toString(measId)
39 << " picks the wrong readout element " << idHelperSvc()->toStringDetEl(identify()));
41 return constructHash(m_idHelper.channel(measId),
42 m_idHelper.gasGap(measId),
43 m_idHelper.isStrip(measId));
45 inline IdentifierHash TgcReadoutElement::layerHash(const Identifier& measId) const {
46 if (m_idHelper.elementID(measId) != m_idHelper.elementID(identify()) ) {
47 ATH_MSG_WARNING("The measurement " << idHelperSvc()->toString(measId)
48 << " picks the wrong readout element " << idHelperSvc()->toStringDetEl(identify()));
50 return constructHash(0, m_idHelper.gasGap(measId),
51 m_idHelper.isStrip(measId));
53 inline IdentifierHash TgcReadoutElement::layerHash(const IdentifierHash& measHash) const {
54 constexpr unsigned gapStripMask{(1<<2) | (1<<1) | 1};
55 return IdentifierHash{static_cast<unsigned int>(measHash) & gapStripMask};
57 inline unsigned int TgcReadoutElement::channelNumber(const IdentifierHash& measHash) {
58 constexpr unsigned int chanShift = 3;
59 return static_cast<unsigned>(measHash) >> chanShift;
61 inline unsigned int TgcReadoutElement::gasGapNumber(const IdentifierHash& measHash) {
62 /// The hash is (0/1/2/ | 0/1) -> 3 bits for the gasgap + 1 bit strip
63 constexpr unsigned gapMask{(1<<1) | 1};
64 constexpr unsigned stripBit{1};
65 unsigned int unstripped = static_cast<unsigned>(measHash) >> stripBit;
66 return (unstripped & gapMask) + 1;
68 inline bool TgcReadoutElement::isStrip(const IdentifierHash& measHash) {
69 constexpr unsigned stripBit{1};
70 return static_cast<unsigned>(measHash) & stripBit;
73 inline Identifier TgcReadoutElement::measurementId(const IdentifierHash& measHash) const {
74 return m_idHelper.channelID(identify(),
75 gasGapNumber(measHash),
77 channelNumber(measHash));
79 inline unsigned int TgcReadoutElement::nGasGaps() const { return m_pars.nGasGaps; }
81 inline unsigned int TgcReadoutElement::numChannels(const IdentifierHash& measHash) const {
82 return isStrip(measHash) ? numStrips(gasGapNumber(measHash))
83 : numWireGangs(gasGapNumber(measHash));
85 inline unsigned int TgcReadoutElement::numStrips(unsigned int gasGap) const {
86 const StripLayerPtr& sensor{sensorLayout(constructHash(0, gasGap, true))};
87 return sensor ? sensor->design().numStrips() : 0;
89 inline unsigned int TgcReadoutElement::numWireGangs(unsigned int gasGap) const {
90 const StripLayerPtr& sensor{sensorLayout(constructHash(0, gasGap, false))};
91 return sensor ? sensor->design().numStrips() : 0;
93 inline const StripLayerPtr& TgcReadoutElement::sensorLayout(const IdentifierHash& measHash) const {
94 return m_pars.sensorLayouts.at(layerHash(measHash));
96 inline const WireGroupDesign& TgcReadoutElement::wireGangLayout(unsigned int gasGap) const {
97 const StripLayerPtr& layerPtr = sensorLayout(constructHash(0, gasGap, false));
99 THROW_EXCEPTION(" Gas gap "<<gasGap<<" has no wire gangs in "<<idHelperSvc()->toStringDetEl(identify()));
101 return static_cast<const WireGroupDesign&>(layerPtr->design());
103 inline const RadialStripDesign& TgcReadoutElement::stripLayout(unsigned int gasGap) const {
104 const StripLayerPtr& layerPtr = sensorLayout(constructHash(0, gasGap, true));
106 THROW_EXCEPTION(" Gas gap "<<gasGap<<" has no strips in "<<idHelperSvc()->toStringDetEl(identify()));
108 return static_cast<const RadialStripDesign&>(layerPtr->design());
110 inline Amg::Vector3D TgcReadoutElement::channelPosition(const ActsGeometryContext& ctx, const Identifier& measId) const {
111 return channelPosition(ctx, measurementHash(measId));
114 } // namespace MuonGMR4