ATLAS Offline Software
Loading...
Searching...
No Matches
StgcRawDataUtils.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6// Utils for the main sTGCRawDataMonAlg.cxx
7// Part of StgcRawDataMonAlg.h
8// see StgcRawDataMonAlg.cxx
10
12
13int sTgcRawDataMonAlg::getFEBs(int eta, int layer) const {
14 int feb=-1;
15 if (std::abs(eta)==1) feb=layer-1;
16 else if(std::abs(eta)==2) feb=layer+7;
17 else if(std::abs(eta)==3) feb=layer+15;
18
19 //ATH_MSG_DEBUG("FEB: " << feb << " Eta: " << eta << " Layer: " << layer);
20 return feb;
21}
22
24 return m_idHelperSvc -> sector(id)*(m_idHelperSvc -> stationEta(id) > 0 ? 1. : -1.);
25}
26
27int sTgcRawDataMonAlg::getLayer(int multiplet, int gasGap) const {
28 return 4*(multiplet - 1) + gasGap;
29}
30
31int32_t sTgcRawDataMonAlg::sourceidToSector(uint32_t sourceid, bool isSideA) const {
32 uint32_t sectorNumber = sourceid & 0xf;
33 return (isSideA) ? sectorNumber + 1: -sectorNumber - 1;
34}
35
36int sTgcRawDataMonAlg::getSignedPhiId(const uint32_t phiid) const {
37 // 1 bit of sign (0 = positive) followed by 5 bits of phiid
38 constexpr size_t nbitsPhi{5};
39 constexpr size_t mask{(1 << nbitsPhi) - 1};
40 return std::pow(-1, phiid >> nbitsPhi) * (phiid & mask);
41}
42
43std::optional<Identifier> sTgcRawDataMonAlg::getPadId(uint32_t sourceid, uint32_t pfeb, uint32_t tdschan) const {
44 bool isValid = false;
45 const int side = (decoder::isA(sourceid)) ? 1 : -1;
46 const auto vmm = tdschan / NVMMCHAN + FIRSTPFEBVMM;
47 const auto vmmchan = tdschan % NVMMCHAN;
48 const auto sec = decoder::sector(sourceid);
49 const auto& help = m_idHelperSvc -> stgcIdHelper();
50 const auto pad_id = help.channelID(help.elementID(decoder::offlineStationName(sec),
56 decoder::offlineChannelNumber(sec, pfeb, vmm, vmmchan), isValid);
57
58 if (!isValid) {
59 ATH_MSG_WARNING("Pad Identifier not valid, skipping");
60 return std::nullopt;
61 }
62
63 return std::make_optional(pad_id);
64}
65
66std::optional<std::tuple<Identifier, const Trk::RIO_OnTrack*>> sTgcRawDataMonAlg::getRotIdAndRotObject(const Trk::TrackStateOnSurface* trkState) const {
67 if (!trkState->type(Trk::TrackStateOnSurface::Measurement)) return std::nullopt;
68
69 Identifier surfaceId = (trkState) -> surface().associatedDetectorElementIdentifier();
70 if(!m_idHelperSvc -> issTgc(surfaceId)) return std::nullopt;
71
72 const Trk::MeasurementBase* meas = trkState->measurementOnTrack();
73 if(!meas) return std::nullopt;
74
75 const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(meas);
76 if(!rot) return std::nullopt;
77
78 Identifier rot_id = rot -> identify();
79
80 if(!rot_id.is_valid()) {
81 ATH_MSG_WARNING("Invalid identifier found in Trk::RIO_OnTrack");
82 return std::nullopt;
83 }
84
85 return std::make_tuple(rot_id, rot);
86}
87
88std::optional<Identifier> sTgcRawDataMonAlg::getRotId(const Trk::TrackStateOnSurface* trkState) const {
89 std::optional<std::tuple<Identifier, const Trk::RIO_OnTrack*>> status = getRotIdAndRotObject(trkState);
90 if (!status.has_value()) return std::nullopt;
91 std::tuple<Identifier, const Trk::RIO_OnTrack*> rotIDtuple = status.value();
92
93 return std::make_optional(std::get<Identifier>(rotIDtuple));
94}
95
96std::optional<std::tuple<int, int, std::string, std::string, int>> sTgcRawDataMonAlg::getPadEtaPhiTuple(uint32_t sourceid, uint32_t pfeb, uint32_t tdschan) const {
97 bool isValid = false;
98 const int side = (decoder::isA(sourceid)) ? 1 : -1;
99 const auto vmm = tdschan / NVMMCHAN + FIRSTPFEBVMM;
100 const auto vmmchan = tdschan % NVMMCHAN;
101 const auto sec = decoder::sector(sourceid);
102
103 mapper mapperSTG;
104
105 int sector_type = decoder::isLarge(sec) ? 1 : 0;
106 int feb_radius = decoder::radius(pfeb);
107 int layer = decoder::layer(pfeb);
108 int channel_number = mapperSTG.channel_number(Muon::nsw::OFFLINE_CHANNEL_TYPE_PAD, sector_type, feb_radius, layer, vmm, vmmchan);
109
110 const auto& help = m_idHelperSvc -> stgcIdHelper();
111 const auto pad_id = help.channelID(help.elementID(decoder::offlineStationName(sec),
117 channel_number, isValid);
118
119
120 if (!isValid) {
121 ATH_MSG_WARNING("Pad Identifier not valid, skipping");
122 return std::nullopt;
123 }
124
125 int padPhi = help.padPhi(pad_id);
126 int padEta = help.padEta(pad_id);
127 int padPhiMax = help.padPhiMax();
128 int padEtaMax = help.padEtaMax();
129
130 int padPhiTotal = padPhi + (padPhiMax + 1)*(decoder::offlineStationPhi(sourceid) - 1);
131 int padEtaTotal = padEta + (padEtaMax + 1)*(decoder::offlineStationAbsEta(pfeb) - 1);
132 std::string sideName = (side == 1) ? "A" : "C";
133 std::string sizeName = (decoder::offlineStationName(sec) == "STS") ? "S" : "L";
134
135 return std::make_optional(std::make_tuple(padPhiTotal, padEtaTotal, sideName, sizeName, layer + 1));
136}
137
138std::optional<double> sTgcRawDataMonAlg::band2theta(double rPosAtNSW, const MuonGM::MuonDetectorManager* muonDetectorManagerObject) const {
139 const auto& help = m_idHelperSvc -> stgcIdHelper();
140 bool isValid = false;
141
142 const Identifier maxNSWZid = m_idHelperSvc -> stgcIdHelper().channelID("STL", 1, help.stationPhiMin(), help.multilayerMax(), help.gasGapMax(), sTgcIdHelper::sTgcChannelTypes::Pad, 1, isValid);
143
144 if (!isValid) {
145 ATH_MSG_WARNING("Identifier for maximum value of NSW global Z-coordinate is invalid!");
146 return std::nullopt;
147 }
148
149 Amg::Vector3D posNSW{Amg::Vector3D::Zero()};
150 (muonDetectorManagerObject -> getsTgcReadoutElement(maxNSWZid)) -> stripGlobalPosition(maxNSWZid, posNSW);
151 float posNSWZ = posNSW.z();
152
153 double theta = std::atan(rPosAtNSW/posNSWZ);
154 return std::make_optional(theta);
155}
156
157std::optional<double> sTgcRawDataMonAlg::band2eta(double rPosAtNSW, const MuonGM::MuonDetectorManager* muonDetectorManagerObject) const {
158 std::optional<double> status = band2theta(rPosAtNSW, muonDetectorManagerObject);
159 if (!status.has_value()) return std::nullopt;
160 double theta = status.value();
161 if (!std::isnormal(theta/2.)) return std::nullopt;
162 double eta = -std::log(std::tan(theta/2.));
163 return std::make_optional(eta);
164}
165
166std::optional<double> sTgcRawDataMonAlg::rPosAtNsw2eta(double rPosAtNSW, bool isA, const MuonGM::MuonDetectorManager* muonDetectorManagerObject) const {
167 std::optional<double> status = band2eta(rPosAtNSW, muonDetectorManagerObject);
168 if (!status.has_value()) return std::nullopt;
169 double band2eta = status.value();
170 if (isA) {
171 return std::make_optional(band2eta);
172 }
173 else {
174 return std::make_optional(-band2eta);
175 }
176}
177
178std::optional<double> sTgcRawDataMonAlg::bandId2eta(int bandid, bool isLarge, bool isA, const MuonGM::MuonDetectorManager* muonDetectorManagerObject) const {
179 double rPosAtNSW = MuonGM::sTgcReadoutElement::triggerBandIdToRadius(isLarge,bandid);
180 std::optional<double> status = rPosAtNsw2eta(rPosAtNSW, isA, muonDetectorManagerObject);
181 if (!status.has_value()) return std::nullopt;
182 double rPosAtNsw2eta = status.value();
183
184 return std::make_optional(rPosAtNsw2eta);
185}
186
187double sTgcRawDataMonAlg::triggersectorphiid2phi(uint32_t sourceid, int trigger_phiid) const {
188 MuonSectorMapping sectorMapping;
189 double trigger_sector_phicenter = sectorMapping.sectorPhi((sourceid & 0xf) + 1);
190 double trigger_phi = trigger_sector_phicenter + (trigger_phiid*9.)/1000.;
192 if((sourceid & 0xf) == 8 && trigger_phiid < 0) {
193 trigger_phi = -trigger_sector_phicenter + (trigger_phiid*9./1000.);
194 }
195 return trigger_phi;
196}
Scalar eta() const
pseudorapidity method
Scalar theta() const
theta method
#define ATH_MSG_WARNING(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition AtlasPID.h:878
bool is_valid() const
Check if id is in a valid state.
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
double sectorPhi(int sector) const
returns the centeral phi position of a sector in radians
uint16_t channel_number(uint8_t channel_type, uint8_t sector_type, uint8_t feb_radius, uint8_t layer, uint16_t vmm, uint16_t vmm_chan) const
Definition MapperSTG.cxx:9
static uint32_t offlineStationAbsEta(const uint32_t pfeb)
static uint32_t offlineGasgap(const uint32_t pfeb)
static uint32_t radius(const uint32_t pfeb)
static bool isLarge(const uint32_t sec)
static uint32_t layer(const uint32_t pfeb)
static uint32_t offlineChannelNumber(const uint32_t sec, const uint32_t pfeb, const uint32_t vmm, const uint32_t vmmchan)
static uint32_t offlineStationPhi(const uint32_t sourceid)
static std::string offlineStationName(const uint32_t sec)
static uint32_t sector(const uint32_t sourceid)
static bool isA(const uint32_t sourceid)
static uint32_t offlineMultilayer(const uint32_t pfeb)
This class is the pure abstract base class for all fittable tracking measurements.
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
represents the track state (measurement, material, fit parameters and quality) at a surface.
const MeasurementBase * measurementOnTrack() const
returns MeasurementBase const overload
bool type(const TrackStateOnSurfaceType type) const
Use this method to find out if the TSoS is of a certain type: i.e.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
std::optional< std::tuple< Identifier, const Trk::RIO_OnTrack * > > getRotIdAndRotObject(const Trk::TrackStateOnSurface *trkState) const
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
std::optional< double > band2eta(double rPosAtNSW, const MuonGM::MuonDetectorManager *muonDetectorManagerObject) const
int getLayer(const int multiplet, const int gasGap) const
int getSignedPhiId(const uint32_t phiid) const
std::optional< double > rPosAtNsw2eta(double rPosAtNSW, bool isA, const MuonGM::MuonDetectorManager *muonDetectorManagerObject) const
int32_t sourceidToSector(uint32_t sourceid, bool isSideA) const
Muon::nsw::MapperSTG mapper
static constexpr uint32_t NVMMCHAN
static constexpr uint32_t FIRSTPFEBVMM
double triggersectorphiid2phi(uint32_t sourceid, int trigger_phiid) const
std::optional< std::tuple< int, int, std::string, std::string, int > > getPadEtaPhiTuple(uint32_t sourceid, uint32_t pfeb, uint32_t tdschan) const
std::optional< Identifier > getPadId(uint32_t sourceid, uint32_t pfeb, uint32_t tdschan) const
Muon::MuonSectorMapping MuonSectorMapping
std::optional< Identifier > getRotId(const Trk::TrackStateOnSurface *trkState) const
std::optional< double > bandId2eta(int bandid, bool isLarge, bool isA, const MuonGM::MuonDetectorManager *muonDetectorManagerObject) const
int getSectors(const Identifier &id) const
std::optional< double > band2theta(double rPosAtNSW, const MuonGM::MuonDetectorManager *muonDetectorManagerObject) const
int getFEBs(int eta, int layers) const
Eigen::Matrix< double, 3, 1 > Vector3D
@ OFFLINE_CHANNEL_TYPE_PAD