2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 #ifndef MUONREADOUTGEOMETRY_TGCREADOUTELEMENT_ICC
5 #define MUONREADOUTGEOMETRY_TGCREADOUTELEMENT_ICC
8 inline std::string TgcReadoutElement::readOutName() const { return m_readout_name; }
11 inline bool TgcReadoutElement::isEndcap() const { return getStationType()[2] == 'E'; }
12 inline bool TgcReadoutElement::isForward() const { return getStationType()[2] == 'F'; }
13 inline bool TgcReadoutElement::isDoublet() const { return nGasGaps() == 2; }
14 inline bool TgcReadoutElement::isTriplet() const { return nGasGaps() == 3; }
16 inline double TgcReadoutElement::wirePitch() const { return m_readoutParams->wirePitch(); }
17 inline int TgcReadoutElement::nPhiChambers() const { return m_readoutParams->nPhiChambers(); }
18 inline int TgcReadoutElement::nPhiSectors() const { return m_stIdxT4E == getStationIndex() ? 36 : nPhiChambers(); }
20 inline double TgcReadoutElement::chamberLocPhiMin() const { return m_locMinPhi; }
21 inline double TgcReadoutElement::chamberLocPhiMax() const { return m_locMaxPhi; }
24 inline int TgcReadoutElement::nGasGaps() const { return m_readoutParams->nGaps(); }
25 inline int TgcReadoutElement::nStrips(int gasGap) const { return m_readoutParams->nStrips(gasGap); }
26 inline int TgcReadoutElement::nWires(int gasGap) const { return m_readoutParams->totalWires(gasGap); }
27 inline int TgcReadoutElement::nWires(int gasGap, int gang) const { return m_readoutParams->nWires(gasGap, gang); }
28 inline int TgcReadoutElement::nWireGangs(int gasGap) const { return m_readoutParams->nWireGangs(gasGap); }
29 inline double TgcReadoutElement::nPitchesToGang(int gasGap, int gang) const { return m_readoutParams->nPitchesToGang(gasGap, gang); }
30 inline double TgcReadoutElement::gangThickness() const { return m_readoutParams->gangThickness(); }
31 inline int TgcReadoutElement::chamberType() const { return m_readoutParams->chamberType(); }
33 inline double TgcReadoutElement::chamberWidth(double z) const {
34 return getSsize() + (0.5 *length() +z) * (getLongSsize() - getSsize()) / length();
36 inline double TgcReadoutElement::wireGangLocalX(const int gasGap, const int gang) const {
37 return wirePitch() * nPitchesToGang(gasGap, gang);
41 inline double TgcReadoutElement::stripLength() const { return m_Rsize; }
42 inline double TgcReadoutElement::physicalDistanceFromBase() const { return m_readoutParams->physicalDistanceFromBase(); }
43 inline double TgcReadoutElement::stripPosOnLargeBase(int strip) const { return m_readoutParams->stripPositionOnLargeBase(strip); }
44 inline double TgcReadoutElement::stripPosOnShortBase(int strip) const { return m_readoutParams->stripPositionOnShortBase(strip); }
46 inline double TgcReadoutElement::wireLength(int wire) const {
47 return m_Ssize + (wire - 1) * wirePitch() * (m_LongSsize - m_Ssize) / m_Rsize;
50 inline const TgcReadoutParams* TgcReadoutElement::getReadoutParams() const { return m_readoutParams.get(); }
52 inline std::pair<double, int> TgcReadoutElement::stripNumberToFetch(int gasGap, int inStrip) const {
53 const bool swapStrip{!((getStationEta() > 0 && gasGap == 1) || (getStationEta() < 0 && gasGap != 1))};
54 const bool flip = gasGap !=1;/// {!((getStationEta() > 0 && gasGap == 1) || (getStationEta() < 0 && gasGap != 1))};
55 const int pickStrip = swapStrip ? 33 - inStrip : inStrip;
56 return std::make_pair(-1. + 2.*flip, pickStrip);
59 /// Override of functions declared as interfaces in the parent classes
60 inline int TgcReadoutElement::layerHash(const Identifier& id) const { return m_idHelper.gasGap(id) - 1; }
62 inline int TgcReadoutElement::surfaceHash(const Identifier& id) const {
63 return surfaceHash(m_idHelper.gasGap(id) ,m_idHelper.isStrip(id));
65 inline int TgcReadoutElement::surfaceHash(int gasGap, bool isStrip) { return 2 * (gasGap -1) + isStrip; }
66 inline int TgcReadoutElement::boundaryHash(const Identifier& id) const { return (measuresPhi(id) ? 0 : 1); }
67 inline bool TgcReadoutElement::measuresPhi(const Identifier& id) const { return m_idHelper.isStrip(id); }
68 inline int TgcReadoutElement::numberOfLayers(bool) const { return nGasGaps(); }
69 inline int TgcReadoutElement::numberOfStrips(const Identifier& id) const { return numberOfStrips(m_idHelper.gasGap(id),
70 m_idHelper.isStrip(id));
72 inline int TgcReadoutElement::numberOfStrips(int layer, bool isStrip) const { return isStrip ? nStrips(layer) :
75 inline double TgcReadoutElement::stripLocalX(const int stripNum,
77 const double refPoint) const {
78 return refPoint + (locY != 0. ? locY * m_stripSlope * (stripPosOnLargeBase(stripNum) - stripPosOnShortBase(stripNum)) : 0.);
81 inline const Amg::Transform3D& TgcReadoutElement::localToGlobalTransf(const Identifier& id) const {
82 return transform(surfaceHash(id));
84 inline Amg::Transform3D TgcReadoutElement::globalToLocalTransf(const Identifier& id) const {
85 return transform(id).inverse();
88 inline Amg::Vector3D TgcReadoutElement::wireGangPos(int gasGap, int gang) const {
89 return transform(surfaceHash(gasGap, false)) * localWireGangPos(gasGap, gang);
92 inline Amg::Vector3D TgcReadoutElement::wireGangPos(const Identifier& id) const {
93 return wireGangPos(m_idHelper.gasGap(id),
94 m_idHelper.channel(id));
97 inline Amg::Vector3D TgcReadoutElement::localWireGangPos(const Identifier& id) const {
98 return localWireGangPos(m_idHelper.gasGap(id),
99 m_idHelper.channel(id));
101 inline Amg::Vector3D TgcReadoutElement::localWireGangPos(int gasGap, int gang) const {
102 return wireGangLocalX(gasGap, gang) * Amg::Vector3D::UnitX();
105 inline Amg::Vector3D TgcReadoutElement::stripPos(const Identifier& id) const {
106 return stripPos(m_idHelper.gasGap(id), m_idHelper.channel(id));
108 inline Amg::Vector3D TgcReadoutElement::stripPos(int gasGap, int strip) const {
109 return transform(surfaceHash(gasGap, true)) * localStripPos(gasGap, strip);
112 inline Amg::Vector3D TgcReadoutElement::localStripPos(int gasGap, int strip) const {
113 return stripCenterLocX(gasGap, strip, 0.) * Amg::Vector3D::UnitX();
115 inline Amg::Vector3D TgcReadoutElement::localStripPos(const Identifier& id) const {
116 return localStripPos(m_idHelper.gasGap(id), m_idHelper.channel(id));
118 inline Amg::Vector3D TgcReadoutElement::localStripDir(int gasGap, int strip) const{
119 const double halfeight = 0.5 *getRsize();
120 return (Amg::Vector3D{stripCenterLocX(gasGap,strip, halfeight), halfeight,0} -
121 Amg::Vector3D{stripCenterLocX(gasGap,strip, -halfeight), -halfeight,0}).unit();
124 inline Amg::Vector3D TgcReadoutElement::localStripDir(const Identifier& id) const{
125 return localStripDir(m_idHelper.gasGap(id), m_idHelper.channel(id));
127 inline Amg::Vector3D TgcReadoutElement::stripDir(int gasGap, int strip) const {
128 return transform(surfaceHash(gasGap, true)).linear() * localStripDir(gasGap, strip);
130 inline Amg::Vector3D TgcReadoutElement::stripDir(const Identifier& id) const {
131 return stripDir(m_idHelper.gasGap(id), m_idHelper.channel(id));
135 inline Amg::Vector3D TgcReadoutElement::channelPos(const Identifier& id) const {
136 return channelPos(m_idHelper.gasGap(id),
137 m_idHelper.isStrip(id),
138 m_idHelper.channel(id));
140 inline Amg::Vector3D TgcReadoutElement::channelPos(int gasGap, bool isStrip, int channel) const {
141 return transform(surfaceHash(gasGap, isStrip)) * localChannelPos(gasGap, isStrip, channel);
143 inline Amg::Vector3D TgcReadoutElement::localChannelPos(const Identifier& id) const {
144 return localChannelPos(m_idHelper.gasGap(id),
145 m_idHelper.isStrip(id),
146 m_idHelper.channel(id));
148 inline Amg::Vector3D TgcReadoutElement::localChannelPos(int gasGap, bool isStrip, int channel) const {
149 return isStrip ? localStripPos(gasGap, channel) : localWireGangPos(gasGap, channel);
155 } // namespace MuonGM