ATLAS Offline Software
Loading...
Searching...
No Matches
RPCchamber.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
11
12#include <iomanip>
13
14using namespace RPC_CondCabling;
17 for (int i = 0; i < m_params.etaStrips; ++i) m_eta_read_mul.push_back(0);
18}
19
20RPCchamber::~RPCchamber() = default;
21
22int RPCchamber::eta_strips() const { return m_params.etaStrips; }
23int RPCchamber::eta_connectors() const { return m_params.etaConnectors; }
26int RPCchamber::phi_strips() const { return m_params.phiStrips; }
27
28int RPCchamber::phi_connectors() const { return m_params.phiConnectors; }
29
30int RPCchamber::ijk_etaReadout() const { return m_params.ijk_EtaReadOut; }
31int RPCchamber::ijk_phiReadout() const { return m_params.ijk_PhiReadOut; }
32
33const std::string& RPCchamber::chamber_name() const { return m_params.chamberName; }
34std::string RPCchamber::stationName() const { return m_params.chamberName.substr(0, 3); }
35int RPCchamber::stationEta() const { return m_params.stationEta; }
36int RPCchamber::doubletR() const { return m_params.doubletR; }
37int RPCchamber::doubletZ() const { return m_params.doubletZ; }
38int RPCchamber::phiReadoutPannels() const { return m_params.phiReadOutPanels; }
39
40int RPCchamber::strips_in_Eta_Conn() const { return m_params.stripsInEtaCon; }
41int RPCchamber::strips_in_Phi_Conn() const { return m_params.stripsInPhiCon; }
42
44
47
49 RPCchamber* rpc = setup.find_chamber(station(), 1);
50 int ijk_eta = rpc->ijk_etaReadout();
51 int ijk_phi = rpc->ijk_phiReadout();
52
53 if (ijk_eta != m_params.ijk_EtaReadOut) {
54 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "RPCchamber")
55 << error("==> mismatch of ijk_etaReadout with respect to others RPC");
56 return false;
57 }
58
59 if (ijk_phi != m_params.ijk_PhiReadOut) {
60 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "RPCchamber")
61 << error("==> mismatch of ijk_phiReadout with respect to others RPC");
62 return false;
63 }
64
65 return true;
66}
67
69 if (m_readoutCMAs.empty()) {
70 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "RPCchamber")
71 << error("==> No readout coverage for this chamber!");
72 return false;
73 }
74
75 RPCchamber::CMAlist::const_iterator cma = m_readoutCMAs.begin();
76 const CMAinput IO = (*cma)->whichCMAinput(station());
77
78 int channels = m_params.etaStrips;
79 for (int i = 0; i < channels; ++i) {
80 if (!m_eta_read_mul[i]) {
81 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "RPCchamber")
82 << error("==> No readout coverage for the full set of ETA strip!");
83 return false;
84 }
85 if (m_eta_read_mul[i] > 1 && IO == Pivot) {
86 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "RPCchamber")
87 << error("==> Pivot plane ETA strips must be read only once!");
88 return false;
89 }
90 if (m_eta_read_mul[i] > 2) {
91 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "RPCchamber")
92 << error("==> Confirm plane ETA strips can be read only twice!");
93 return false;
94 }
95 }
96
97 if (m_readoutWORs.size() > 1) {
98 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "RPCchamber")
99 << error("==> Gives input to more than 1 Wired OR pannel!");
100 return false;
101 }
102 return true;
103}
104
105std::string RPCchamber::error(const std::string& mess) const {
106 std::ostringstream disp;
107 disp << error_header()
108 << mess << std::endl << *this;
109 return disp.str();
110}
111
112bool RPCchamber::local_strip(ViewType side, int strip_number, int& local_address) const {
113 if (side == Eta) {
114 if (strip_number >= m_params.etaStrips) return false;
115 if (number()) {
116 local_address = strip_number + 1;
117 } else {
118 int middle = m_params.etaStrips / 2;
119 int address = strip_number - middle;
120 local_address = (strip_number < middle) ? address : address + 1;
121 }
122 return true;
123 }
124
125 if (side == Phi) {
126 if (strip_number >= m_params.phiStrips) return false;
127 local_address = strip_number + 1;
128 }
129
130 return false;
131}
132
133bool RPCchamber::global_strip(ViewType side, HalfType h_barrel, int strip_number, int& global_address) const {
134 int local_address;
135 if (local_strip(side, strip_number, local_address)) {
136 if (side == Eta) {
137 global_address = local_address + m_eta_strip_global;
138 if (number()) {
139 if (h_barrel == Negative) global_address = -global_address;
140 } else {
141 if (h_barrel == Negative && global_address > 0) return false;
142 if (h_barrel == Positive && global_address < 0) return false;
143 }
144 return true;
145 }
146
147 if (side == Phi) { return false; }
148 }
149
150 return false;
151}
152
153bool RPCchamber::local_connector(ViewType side, int strip_number, int& local_address, int& low_eta_strips, int& hi_eta_strips) const {
154 int strip_address;
155 if (local_strip(side, strip_number, strip_address)) {
156 int address = abs(strip_address) - 1;
157 int strip_sign = (abs(strip_address)) / strip_address;
158 if (side == Eta) {
159 local_address = (address / m_params.stripsInEtaCon + 1) * strip_sign;
160 low_eta_strips = address % m_params.stripsInEtaCon;
161 int left = m_params.stripsInEtaCon - low_eta_strips - 1;
162 int residual_strips = residual(side, strip_number);
163 hi_eta_strips = (left <= residual_strips) ? left : residual_strips;
164 return true;
165 }
166 if (side == Phi) { return false; }
167 }
168
169 return false;
170}
171
172int RPCchamber::residual(ViewType side, int strip_number) const {
173 if (side == Eta) {
174 if (number()) {
175 return (m_params.etaStrips - 1 - strip_number);
176 } else {
177 int total_strips = m_params.etaStrips / 2;
178 if (strip_number < total_strips)
179 return strip_number;
180 else
181 return m_params.etaStrips - strip_number - 1;
182 }
183 }
184 if (side == Phi) { return (m_params.phiStrips - 1 - strip_number); }
185 return 0;
186}
187
188bool RPCchamber::global_connector(ViewType side, HalfType h_barrel, int strip_number, int& global_address, int& left_strips,
189 int& right_strips) const {
190 int l_address;
191 if (local_connector(side, strip_number, l_address, left_strips, right_strips)) {
192 if (side == Eta) {
193 global_address = l_address + m_eta_conn_global;
194 if (number()) {
195 if (h_barrel == Negative) global_address = -global_address;
196 } else {
197 if (h_barrel == Negative && global_address > 0) return false;
198 if (h_barrel == Positive && global_address < 0) return false;
199 }
200 return true;
201 }
202 if (side == Phi) { return false; }
203 }
204
205 return false;
206}
207
208bool RPCchamber::Gstrip_2_Lnumber(ViewType side, int global_address, int& strip_number) const {
209 if (side == Eta) {
210 if (number()) {
211 strip_number = abs(global_address) - m_eta_strip_global - 1;
212 if (strip_number <= m_params.etaStrips - 1) return true;
213 } else {
214 strip_number = (global_address > 0) ? global_address + m_params.etaStrips / 2 - 1 : global_address + m_params.etaStrips / 2;
215 if (strip_number <= m_params.etaStrips - 1 && strip_number >= 0) return true;
216 }
217 }
218 if (side == Phi) { return false; }
219
220 return false;
221}
222
223bool RPCchamber::Gconn_2_Lnumber(ViewType side, int global_address, int& local_address, int& strip_number) const {
224 if (side == Eta) {
225 if (number()) {
226 local_address = abs(global_address) - m_eta_conn_global - 1;
227 if (local_address <= m_params.etaConnectors - 1) {
228 strip_number = local_address * m_params.stripsInEtaCon;
229 return true;
230 }
231 } else {
232 local_address =
233 (global_address > 0) ? global_address + m_params.etaConnectors / 2 - 1 : global_address + m_params.etaConnectors / 2;
234 if (local_address <= m_params.etaConnectors - 1 && local_address >= 0) {
235 strip_number = local_address * m_params.stripsInEtaCon;
236 return true;
237 }
238 }
239 }
240
241 if (side == Phi) { return false; }
242
243 return false;
244}
245
247
249
250void RPCchamber::Print(std::ostream& stream, bool detail) const {
251 stream << " chamber n. " << std::setw(2) << number() << " ";
252 stream << chamber_name();
253 if (chamber_name().length() == 5) stream << " ";
254 stream << " " << std::setw(2) << stationEta() << std::setw(2) << doubletR();
255 stream << std::setw(2) << doubletZ() << " ";
256 stream << " (stat " << station() << ")";
257 stream << " : eta -> " << std::setw(2) << eta_strips() << " ";
258 stream << std::setw(2) << eta_connectors() << " ";
259 stream << std::setw(2) << std::setfill('0') << ijk_etaReadout() << std::setfill(' ');
260 stream << " phi -> " << std::setw(2) << phi_strips() << " ";
261 stream << std::setw(2) << phi_connectors() << " ";
262 stream << std::setw(2) << std::setfill('0') << ijk_phiReadout() << std::setfill(' ');
263 stream << std::endl;
264 if (detail) {
265 stream << " global strips offset -( " << m_eta_strip_global << " )- global connectors offset -( " << m_eta_conn_global << " )-"
266 << std::endl;
267 stream << " It gives input to " << m_readoutCMAs.size() << " Eta CMA:" << std::endl;
268 CMAlist::const_iterator cma = m_readoutCMAs.begin();
269 while (cma != m_readoutCMAs.end()) {
270 stream << *(*cma);
271 ++cma;
272 }
273 stream << " Eta Readout multiplicity:" << std::endl;
274 stream << " "
275 << " 1 5 10 15 20 25 30 35 40" << std::endl;
276 stream << " "
277 << " | | | | | | | | |" << std::endl;
278 stream << " ";
279 for (int i = 0; i < eta_strips(); ++i) stream << m_eta_read_mul[i];
280 stream << std::endl;
281 stream << " It gives input to " << m_readoutWORs.size() << " WiredOR pannel:" << std::endl;
282 RPCchamber::WORlist::const_iterator wor = m_readoutWORs.begin();
283 while (wor != m_readoutWORs.end()) {
284 stream << *(*wor);
285 ++wor;
286 }
287
288 stream << "========================================"
289 << "=======================================" << std::endl;
290 }
291}
292
293void RPCchamber::add_cma(const EtaCMA* cma) { m_readoutCMAs.push_back(cma); }
294
295void RPCchamber::add_wor(const WiredOR* wor) { m_readoutWORs.push_back(wor); }
296
297void RPCchamber::add_eta_channel(int channel) { m_eta_read_mul[channel] += 1; }
298
299std::string RPCchamber::extendedName(int sector) const {
300 std::string side;
301 if (sector <= 31)
302 side = "C";
303 else
304 side = "A";
305
306 std::string sd;
307
308 switch (stationName()[2]) {
309 case 'L': sd = (sector % 2) ? "HV" : "RO"; break;
310
311 case 'E': sd = (sector % 2) ? "HV" : "RO"; break;
312
313 case 'R': sd = (sector % 2) ? "HV" : "RO"; break;
314
315 case 'M': sd = (sector % 2) ? "HV" : "RO"; break;
316
317 case 'S': sd = (sector % 2) ? "RO" : "HV"; break;
318
319 case 'F': sd = (sector % 2) ? "RO" : "HV"; break;
320
321 case 'G': sd = (sector % 2) ? "RO" : "HV"; break;
322
323 default: return "";
324 }
325
326 std::ostringstream out;
327
328 int physicsSector = (((sector + 1) % 32) / 2 + 1) % 16;
329 if (!physicsSector) physicsSector = 16;
330
331 if (stationName().c_str()[1] == 'O' && (stationName().c_str()[2] == 'F' || stationName().c_str()[2] == 'G')) {
332 int etaIdx = (stationName().c_str()[2] == 'F') ? (stationEta() - 1) * 2 + 1 : (stationEta()) * 2;
333
334 out << stationName() << etaIdx << side << std::setw(2) << std::setfill('0') << physicsSector << "-" << sd << "-" << doubletZ();
335 } else {
336 out << stationName() << stationEta() << side << std::setw(2) << std::setfill('0') << physicsSector << "-" << sd << "-"
337 << doubletZ();
338 }
339
340 std::string outstr;
341 outstr = out.str();
342
343 return outstr;
344}
345
346bool RPCchamber::inversion(int sector) const {
347 switch (stationName()[2]) {
348 case 'L':
349 if (sector % 2)
350 return sector <= 31; // HV
351 else
352 return sector > 31; // RO
353 break;
354
355 case 'E':
356 if (sector % 2)
357 return sector <= 31; // HV
358 else
359 return sector > 31; // RO
360 break;
361
362 case 'R':
363 if (sector % 2)
364 return (sector <= 31) ? false : false; // HV
365 else
366 return (sector <= 31) ? false : false; // RO
367 break;
368
369 case 'M':
370 if (sector % 2)
371 return (sector <= 31) ? false : false; // HV
372 else
373 return (sector <= 31) ? false : false; // RO
374 break;
375
376 case 'S':
377 if (sector % 2)
378 return sector <= 31; // RO
379 else
380 return sector > 31; // HV
381 break;
382
383 case 'F':
384 if (stationName()[1] == 'O' && (sector == 25 || sector == 26 || sector == 57 || sector == 58)) {
385 if (sector % 2)
386 return sector > 31; // RO
387 else
388 return sector <= 31; // HV
389 }
390
391 if (sector % 2)
392 return sector <= 31; // RO
393 else
394 return sector > 31; // HV
395 break;
396
397 case 'G':
398 if (stationName()[1] == 'O' && stationName()[3] != '8' && (sector == 25 || sector == 26 || sector == 57 || sector == 58)) {
399 if (sector % 2)
400 return sector > 31; // RO
401 else
402 return sector <= 31; // HV
403 }
404
405 if (sector % 2)
406 return sector <= 31; // RO
407 else
408 return sector > 31; // HV
409 break;
410
411 default: return false;
412 }
413}
CMAinput
@ Pivot
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
double length(const pvec &v)
ViewType
Definition RPCdef.h:8
HalfType
Definition RPCdef.h:9
@ Positive
Definition RPCdef.h:9
@ Negative
Definition RPCdef.h:9
int number() const
int station() const
std::string error_header() const
CablingObject(const cablingParameters &, const std::string &)
RPCchamber(const RPCchamber::chamberParameters &params)
Helper struct to reduce the number of arguments in the constructor.
std::list< const WiredOR * > WORlist
Definition RPCchamber.h:68
bool global_strip(ViewType, HalfType, int, int &) const
std::list< const EtaCMA * > CMAlist
Definition RPCchamber.h:67
const CMAlist & readoutCMAs() const
bool Gconn_2_Lnumber(ViewType, int, int &, int &) const
std::string extendedName(int) const
bool global_connector(ViewType, HalfType, int, int &, int &, int &) const
void Print(std::ostream &, bool) const
std::string stationName() const
void add_wor(const WiredOR *)
bool setup(SectorLogicSetup &)
bool local_strip(ViewType, int, int &) const
void add_cma(const EtaCMA *)
const WORlist & readoutWORs() const
const std::string & chamber_name() const
bool local_connector(ViewType, int, int &, int &, int &) const
bool Gstrip_2_Lnumber(ViewType, int, int &) const
int residual(ViewType, int) const
chamberDefineParams m_params
Definition RPCchamber.h:70
const ReadoutCh & eta_read_mul() const
std::string error(const std::string &) const
std::vector< int > ReadoutCh
Definition RPCchamber.h:66