ATLAS Offline Software
Loading...
Searching...
No Matches
CscIdHelper.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
9#include "IdDict/IdDictMgr.h"
10#include "IdDict/IdDictRegion.h"
12
13CscIdHelper::CscIdHelper() : MuonIdHelper("CscIdHelper", "csc") {
14 m_module_hashes.fill(-1);
16}
17
20 int status = 0;
21
22 // Check whether this helper should be reinitialized
23 if (!reinitialize(dict_mgr)) {
24 ATH_MSG_INFO("Request to reinitialize not satisfied - tags have not changed");
25 return 0;
26 } else {
27 ATH_MSG_DEBUG("(Re)initialize");
28 }
29
31 if (AtlasDetectorID::initialize_from_dictionary(dict_mgr)) return 1;
32
33 // Register version of the MuonSpectrometer dictionary
34 if (register_dict_tag(dict_mgr, "MuonSpectrometer")) return 1;
35
36 m_dict = dict_mgr.find_dictionary("MuonSpectrometer");
37 if (!m_dict) {
38 ATH_MSG_ERROR(" initialize_from_dict - cannot access MuonSpectrometer dictionary ");
39 return 1;
40 }
41
43
44 if (initLevelsFromDict()) return 1;
45
46 int index = technologyIndex("CSC");
47 if (index == -1) {
48 ATH_MSG_DEBUG("initLevelsFromDict - there are no CSC entries in the dictionary! ");
49 return 0;
50 }
51
52 const IdDictField* field = m_dict->find_field("chamberLayer");
53 if (field) {
54 m_CHAMBERLAYER_INDEX = field->index();
55 } else {
56 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'chamberLayer' field ");
57 return 1;
58 }
59
60 field = m_dict->find_field("wireLayer");
61 if (field) {
62 m_WIRELAYER_INDEX = field->index();
63 } else {
64 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'wireLayer' field ");
65 return 1;
66 }
67
68 field = m_dict->find_field("cscMeasuresPhi");
69 if (field) {
70 m_MEASURESPHI_INDEX = field->index();
71 } else {
72 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'cscMeasuresPhi' field ");
73 return 1;
74 }
75
76 field = m_dict->find_field("cscStrip");
77 if (field) {
78 m_CHANNEL_INDEX = field->index();
79 } else {
80 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'cscStrip' field ");
81 return 1;
82 }
83
84 // initialize the multilayer index
86
88
89 const IdDictGroup* cscGroup = m_dict->find_group("csc");
90 if (!cscGroup) {
91 ATH_MSG_ERROR("Cannot find csc group");
92 } else {
93 m_GROUP_INDEX = cscGroup->region(0).index();
94 }
95
96 const IdDictRegion& region = m_dict->region(m_GROUP_INDEX);
104
105 ATH_MSG_DEBUG(" CSC decode index and bit fields for each level: " << std::endl
106 << " muon " << m_muon_impl.show_to_string() << std::endl
107 << " station " << m_sta_impl.show_to_string() << std::endl
108 << " eta " << m_eta_impl.show_to_string() << std::endl
109 << " phi " << m_phi_impl.show_to_string() << std::endl
110 << " technology " << m_tec_impl.show_to_string() << std::endl
111 << " cham layer " << m_cla_impl.show_to_string() << std::endl
112 << " layer " << m_lay_impl.show_to_string() << std::endl
113 << " phi " << m_mea_impl.show_to_string() << std::endl
114 << " strip " << m_str_impl.show_to_string());
115
119
121
122 int muonField = -1;
123 const IdDictDictionary* atlasDict = dict_mgr.find_dictionary("ATLAS");
124 if (atlasDict->get_label_value("subdet", "MuonSpectrometer", muonField)) {
125 ATH_MSG_ERROR("Could not get value for label 'MuonSpectrometer' of field "
126 << "'subdet' in dictionary " << atlasDict->name());
127 return 1;
128 }
129
131
132 ExpandedIdentifier region_id;
133 region_id.add(muonField);
134 Range prefix;
135 MultiRange muon_range = m_dict->build_multirange(region_id, prefix, "technology");
136 if (muon_range.size() > 0) {
137 ATH_MSG_INFO("MultiRange built successfully to Technology: "
138 << "MultiRange size is " << muon_range.size());
139 } else {
140 ATH_MSG_ERROR("Muon MultiRange is empty for modules");
141 return 1;
142 }
143
144 // Build MultiRange down to "detector element" for all mdt regions
145
146 ExpandedIdentifier detectorElement_region;
147 detectorElement_region.add(muonField);
148 Range detectorElement_prefix;
149 MultiRange muon_detectorElement_range = m_dict->build_multirange(detectorElement_region, detectorElement_prefix, "chamberLayer");
150 if (muon_detectorElement_range.size() > 0) {
151 ATH_MSG_INFO("MultiRange built successfully to detector element: "
152 << "Multilayer MultiRange size is " << muon_detectorElement_range.size());
153 } else {
154 ATH_MSG_ERROR("Muon CSC detector element MultiRange is empty");
155 return 1;
156 }
157
159
160 ExpandedIdentifier csc_region;
161 csc_region.add(muonField);
162 Range csc_prefix;
163 MultiRange muon_channel_range = m_dict->build_multirange(csc_region, csc_prefix, "cscStrip");
164 if (muon_channel_range.size() > 0) {
165 ATH_MSG_INFO("MultiRange built successfully to cscStrip: "
166 << "MultiRange size is " << muon_channel_range.size());
167 } else {
168 ATH_MSG_ERROR("Muon MultiRange is empty for channels");
169 return 1;
170 }
171
178
179 int cscField = -1;
180 status = m_dict->get_label_value("technology", "CSC", cscField);
181
182 for (int i = 0; i < (int)muon_range.size(); ++i) {
183 const Range& range = muon_range[i];
184 if (range.fields() > m_TECHNOLOGY_INDEX) {
185 const Range::field& field = range[m_TECHNOLOGY_INDEX];
186 if (field.match((ExpandedIdentifier::element_type)cscField)) {
187 m_full_module_range.add(range);
188 ATH_MSG_DEBUG("field size is " << (int)range.cardinality() << " field index = " << i);
189 }
190 }
191 }
192
193 for (int j = 0; j < (int)muon_detectorElement_range.size(); ++j) {
194 const Range& range = muon_detectorElement_range[j];
195 if (range.fields() > m_TECHNOLOGY_INDEX) {
196 const Range::field& field = range[m_TECHNOLOGY_INDEX];
197 if (field.match((ExpandedIdentifier::element_type)cscField)) {
199 ATH_MSG_DEBUG("detector element field size is " << (int)range.cardinality() << " field index = " << j);
200 }
201 }
202 }
203
204 for (int j = 0; j < (int)muon_channel_range.size(); ++j) {
205 const Range& range = muon_channel_range[j];
206 if (range.fields() > m_TECHNOLOGY_INDEX) {
207 const Range::field& field = range[m_TECHNOLOGY_INDEX];
208 if (field.match((ExpandedIdentifier::element_type)cscField)) {
209 m_full_channel_range.add(range);
210 ATH_MSG_DEBUG("channel field size is " << (int)range.cardinality() << " field index = " << j);
211 }
212 }
213 }
214
216
217 if (m_full_module_range.size() == 0) {
218 ATH_MSG_ERROR("CSC MultiRange ID is empty for modules");
219 return 1;
220 }
221
223
224 if (m_full_detectorElement_range.size() == 0) {
225 ATH_MSG_ERROR("CSC MultiRange ID is empty for detector elements");
226 return 1;
227 }
228
230
231 if (m_full_channel_range.size() == 0) {
232 ATH_MSG_ERROR("CSC MultiRange ID is empty for channels");
233 return 1;
234 }
235
237
238 ATH_MSG_INFO("Initializing CSC hash indices ... ");
239 status += init_hashes();
240 status += init_detectorElement_hashes(); // for chamber layer - a chamber
241 status += init_channel_hashes();
242 status += strip_hash_offsets();
243 status += init_id_to_hashes();
244
246
247 ATH_MSG_INFO("Initializing CSC hash indices for finding neighbors ... ");
248 status += init_neighbors();
249
250 // now we have to set the stripMax values (for the stripMax(id) function)
251 // this could be also done on an event-by-event basis as for stripMin(id)
252 // however, for all existing layouts there are only 2 possible values for stripMax,
253 // namely those for layers which measure phi (measuresPhi(id)=true) and the rest.
254 // thus, we initialize 2 member variables here to speed up calling the function during runtime
255 // loop on the channel Identifiers and check (for consistency!) that really only
256 // two maximum numbers of strips (w/o measuresPhi) are around
257 ExpandedIdentifier expId;
258 IdContext strip_context = channel_context();
259 for (const auto& id : m_channel_vec) {
260 if (get_expanded_id(id, expId, &strip_context)) {
261 ATH_MSG_ERROR("Failed to retrieve ExpandedIdentifier from Identifier " << id.get_compact());
262 return 1;
263 }
264 bool measPhi = measuresPhi(id);
265 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
266 const Range& range = m_full_channel_range[i];
267 if (range.match(expId)) {
268 const Range::field& phi_field = range[m_CHANNEL_INDEX];
269 if (not !phi_field.empty()) {
270 ATH_MSG_ERROR("Range::field for phi at position " << i << " does not have a maximum");
271 return 1;
272 }
273 unsigned int max = phi_field.get_maximum();
274 if (measPhi) {
275 if (m_stripMaxPhi != UINT_MAX && m_stripMaxPhi != max) {
276 ATH_MSG_ERROR("Maximum of Range::field for phi (" << max << ") is not equal to m_stripMaxPhi=" << m_stripMaxPhi);
277 return 1;
278 } else
280 } else {
281 if (m_stripMaxEta != UINT_MAX && m_stripMaxEta != max) {
282 ATH_MSG_ERROR("Maximum of Range::field for phi (" << max << ") is not equal to m_stripMaxEta=" << m_stripMaxEta);
283 return 1;
284 } else
286 }
287 }
288 }
289 }
290
291 // check whether the current layout contains chamberLayer 1 Identifiers (pre-Run3) in the vector of module Identifiers
292 if (!m_module_vec.empty() && chamberLayer(m_module_vec.at(0)) == 1) m_hasChamLay1 = true;
293 m_init = true;
294 return (status);
295}
296
297inline unsigned int CscIdHelper::moduleHashIdx(const Identifier& id) const{
300 constexpr unsigned int C = s_phiDim;
301 constexpr unsigned int BxC = C*s_etaDim;
302 const int stEta = stationEta(id);
303 return (stationName(id) - m_stationShift)*BxC + (stEta + s_etaDim/2 - (stEta>0))*C + (stationPhi(id) -1);
304}
305inline unsigned int CscIdHelper::detEleHashIdx(const Identifier& id) const{
306 return moduleHashIdx(id) *s_mlDim + (chamberLayer(id) -1);
307}
308
310
311 for (const Identifier& id : m_module_vec) m_stationShift = std::min(m_stationShift, 1u* stationName(id));
312 unsigned int hash_max = module_hash_max();
313 for (unsigned int i = 0; i < hash_max; ++i) {
314 const Identifier& id = m_module_vec[i];
315 const unsigned idx = moduleHashIdx(id);
316 if (idx >= m_module_hashes.size() || m_module_hashes[idx] < hash_max){
317 ATH_MSG_FATAL("Failed to assign module hash to "<<show_to_string(id));
318 return 1;
319 }
320 m_module_hashes[idx] = i;
321 }
322
323 hash_max = detectorElement_hash_max();
324 for (unsigned int i = 0; i < hash_max; ++i) {
325 const Identifier& id = m_detectorElement_vec[i];
326 const unsigned idx = detEleHashIdx(id);
327 if (idx >= m_detectorElement_hashes.size() || m_detectorElement_hashes[idx] < hash_max){
328 ATH_MSG_FATAL("Failed to assign detector hash to "<<show_to_string(id));
329 return 1;
330 }
332 }
333
334 return 0;
335}
336
338 const unsigned int idx = moduleHashIdx(id);
339 if (idx >= m_module_hashes.size()) return 1;
340 hash_id = m_module_hashes[idx];
341 return 0;
342}
344 const unsigned int idx = detEleHashIdx(id);
345 if (idx >= m_detectorElement_hashes.size()) return 1;
346 hash_id = m_detectorElement_hashes[idx];
347 return 0;
348}
349
350
351
352void CscIdHelper::idChannels(const Identifier& id, std::vector<Identifier>& vect) const {
353 vect.clear();
354 Identifier parent = parentID(id);
355 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
356 const Range& range = m_full_channel_range[i];
357 ConstRangeIterator rit(range);
358 for (const auto & expId : rit) {
359 Identifier child;
360 get_id(expId, child);
361 if (parentID(child) == parent) vect.push_back(child);
362 }
363 }
364}
365
367 ExpandedIdentifier expId;
368 IdContext eta_context(expId, 0, m_ETA_INDEX);
369 if (!get_expanded_id(id, expId, &eta_context)) {
370 int result = -999;
371 for (unsigned int i = 0; i < m_full_module_range.size(); ++i) {
372 const Range& range = m_full_module_range[i];
373 if (range.match(expId)) {
374 const Range::field& eta_field = range[m_ETA_INDEX];
375 if (not eta_field.empty()) {
376 int etamin = eta_field.get_minimum();
377 if (-999 == result) {
378 result = etamin;
379 } else {
380 if (etamin < result) result = etamin;
381 }
382 }
383 }
384 }
385 return (result);
386 }
387 return (999);
388}
389
391 ExpandedIdentifier expId;
392 IdContext eta_context(expId, 0, m_ETA_INDEX);
393 if (!get_expanded_id(id, expId, &eta_context)) {
394 int result = -999;
395 for (unsigned int i = 0; i < m_full_module_range.size(); ++i) {
396 const Range& range = m_full_module_range[i];
397 if (range.match(expId)) {
398 const Range::field& eta_field = range[m_ETA_INDEX];
399 if (not eta_field.empty()) {
400 int etamax = eta_field.get_maximum();
401 if (result < etamax) result = etamax;
402 }
403 }
404 }
405 return (result);
406 }
407 return (-999);
408}
409
411 ExpandedIdentifier expId;
412 IdContext phi_context(expId, 0, m_PHI_INDEX);
413 if (!get_expanded_id(id, expId, &phi_context)) {
414 for (unsigned int i = 0; i < m_full_module_range.size(); ++i) {
415 const Range& range = m_full_module_range[i];
416 if (range.match(expId)) {
417 const Range::field& phi_field = range[m_PHI_INDEX];
418 if (not phi_field.empty()) { return (phi_field.get_minimum()); }
419 }
420 }
421 }
423 return (999);
424}
425
427 ExpandedIdentifier expId;
428 IdContext phi_context(expId, 0, m_PHI_INDEX);
429 if (!get_expanded_id(id, expId, &phi_context)) {
430 for (unsigned int i = 0; i < m_full_module_range.size(); ++i) {
431 const Range& range = m_full_module_range[i];
432 if (range.match(expId)) {
433 const Range::field& phi_field = range[m_PHI_INDEX];
434 if (not phi_field.empty()) { return (phi_field.get_maximum()); }
435 }
436 }
437 }
439 return (-999);
440}
441
443 ExpandedIdentifier expId;
444 IdContext chamberLayer_context(expId, 0, m_CHAMBERLAYER_INDEX);
445 if (!get_expanded_id(id, expId, &chamberLayer_context)) {
446 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
447 const Range& range = m_full_channel_range[i];
448 if (range.match(expId)) {
449 const Range::field& phi_field = range[m_CHAMBERLAYER_INDEX];
450 if (not phi_field.empty()) { return (phi_field.get_minimum()); }
451 }
452 }
453 }
455 return (999);
456}
457
459 ExpandedIdentifier expId;
460 IdContext chamberLayer_context(expId, 0, m_CHAMBERLAYER_INDEX);
461 if (!get_expanded_id(id, expId, &chamberLayer_context)) {
462 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
463 const Range& range = m_full_channel_range[i];
464 if (range.match(expId)) {
465 const Range::field& phi_field = range[m_CHAMBERLAYER_INDEX];
466 if (not phi_field.empty()) { return (phi_field.get_maximum()); }
467 }
468 }
469 }
471 return (-999);
472}
473
475 ExpandedIdentifier expId;
476 IdContext wireLayer_context(expId, 0, m_WIRELAYER_INDEX);
477 if (!get_expanded_id(id, expId, &wireLayer_context)) {
478 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
479 const Range& range = m_full_channel_range[i];
480 if (range.match(expId)) {
481 const Range::field& phi_field = range[m_WIRELAYER_INDEX];
482 if (not phi_field.empty()) { return (phi_field.get_minimum()); }
483 }
484 }
485 }
487 return (999);
488}
489
491 ExpandedIdentifier expId;
492 IdContext chamberLayer_context(expId, 0, m_WIRELAYER_INDEX);
493 if (!get_expanded_id(id, expId, &chamberLayer_context)) {
494 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
495 const Range& range = m_full_channel_range[i];
496 if (range.match(expId)) {
497 const Range::field& phi_field = range[m_WIRELAYER_INDEX];
498 if (not phi_field.empty()) { return (phi_field.get_maximum()); }
499 }
500 }
501 }
503 return (-999);
504}
505
507 ExpandedIdentifier expId;
508 IdContext measuresPhi_context(expId, 0, m_MEASURESPHI_INDEX);
509 if (!get_expanded_id(id, expId, &measuresPhi_context)) {
510 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
511 const Range& range = m_full_channel_range[i];
512 if (range.match(expId)) {
513 const Range::field& phi_field = range[m_MEASURESPHI_INDEX];
514 if (not phi_field.empty()) { return (phi_field.get_minimum()); }
515 }
516 }
517 }
519 return (999);
520}
521
523 ExpandedIdentifier expId;
524 IdContext measuresPhi_context(expId, 0, m_MEASURESPHI_INDEX);
525 if (!get_expanded_id(id, expId, &measuresPhi_context)) {
526 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
527 const Range& range = m_full_channel_range[i];
528 if (range.match(expId)) {
529 const Range::field& phi_field = range[m_MEASURESPHI_INDEX];
530 if (not phi_field.empty()) { return (phi_field.get_maximum()); }
531 }
532 }
533 }
535 return (-999);
536}
537
538int CscIdHelper::stripMin(const Identifier& id) const {
539 ExpandedIdentifier expId;
540 IdContext strip_context = channel_context();
541 if (!get_expanded_id(id, expId, &strip_context)) {
542 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
543 const Range& range = m_full_channel_range[i];
544 if (range.match(expId)) {
545 const Range::field& phi_field = range[m_CHANNEL_INDEX];
546 if (not phi_field.empty()) { return (phi_field.get_minimum()); }
547 }
548 }
549 }
551 return (999);
552}
553
554int CscIdHelper::stripMax(const Identifier& id) const {
555 if (measuresPhi(id))
556 return m_stripMaxPhi;
557 else
558 return m_stripMaxEta;
559}
560
562
563bool CscIdHelper::valid(const Identifier& id) const {
564 if (!validElement(id)) return false;
565
566 int cLayer = chamberLayer(id);
567 if ((cLayer < chamberLayerMin(id)) || (cLayer > chamberLayerMax(id))) {
568 ATH_MSG_DEBUG("Invalid chamberLayer=" << cLayer << " chamberLayerMin=" << chamberLayerMin(id)
569 << " chamberLayerMax=" << chamberLayerMax(id));
570 return false;
571 }
572
573 int wLayer = wireLayer(id);
574 if ((wLayer < wireLayerMin(id)) || (wLayer > wireLayerMax(id))) {
575 ATH_MSG_DEBUG("Invalid wireLayer=" << wLayer << " wireLayerMin=" << wireLayerMin(id) << " wireLayerMax=" << wireLayerMax(id));
576 return false;
577 }
578
579 int mPhi = measuresPhi(id);
580 if ((mPhi < measuresPhiMin(id)) || (mPhi > measuresPhiMax(id))) {
581 ATH_MSG_DEBUG("Invalid measuresPhi=" << mPhi << " measuresPhiMin=" << measuresPhiMin(id)
582 << " measuresPhiMax=" << measuresPhiMax(id));
583 return false;
584 }
585
586 int channel = strip(id);
587 if ((channel > stripMax(id)) || (channel < stripMin(id))) {
588 ATH_MSG_DEBUG("Invalid strip=" << channel << " stripMin=" << stripMin(id) << " stripMax=" << stripMax(id));
589 return false;
590 }
591 return true;
592}
593bool CscIdHelper::isStNameInTech(const std::string& stationName) const { return stationName[0] == 'C'; }
595 int station = stationName(id);
596 if (!validStation(station)) {
597 ATH_MSG_DEBUG("Invalid stationName=" << stationNameString(station));
598 return false;
599 }
600
601 int eta = stationEta(id);
602 if ((eta < stationEtaMin(id)) || (eta > stationEtaMax(id)) || (0 == eta)) {
603 ATH_MSG_DEBUG("Invalid stationEta=" << eta << " for stationName=" << stationNameString(station)
604 << " stationEtaMin=" << stationEtaMin(id) << " stationEtaMax=" << stationEtaMax(id));
605 return false;
606 }
607
608 int phi = stationPhi(id);
609 if ((phi < stationPhiMin(id)) || (phi > stationPhiMax(id))) {
610 ATH_MSG_DEBUG("Invalid stationPhi=" << phi << " for stationName=" << stationNameString(station)
611 << " stationPhiMin=" << stationPhiMin(id) << " stationPhiMax=" << stationPhiMax(id));
612 return false;
613 }
614 return true;
615}
616
618
621 ATH_MSG_DEBUG("Invalid stationName=" << stationNameString(stationName));
622 return false;
623 }
624 if ((stationEta < stationEtaMin(id)) || (stationEta > stationEtaMax(id)) || (0 == stationEta)) {
625 ATH_MSG_DEBUG("Invalid stationEta=" << stationEta << " for stationName=" << stationNameString(stationName)
626 << " stationEtaMin=" << stationEtaMin(id) << " stationEtaMax=" << stationEtaMax(id));
627 return false;
628 }
629 if ((stationPhi < stationPhiMin(id)) || (stationPhi > stationPhiMax(id))) {
630 ATH_MSG_DEBUG("Invalid stationPhi=" << stationPhi << " for stationName=" << stationNameString(stationName)
631 << " stationPhiMin=" << stationPhiMin(id) << " stationPhiMax=" << stationPhiMax(id));
632 return false;
633 }
634 return true;
635}
636
638 int measuresPhi, int strip) const {
639 if (!validElement(id, stationName, stationEta, stationPhi)) return false;
640
642 ATH_MSG_DEBUG("Invalid chamberLayer=" << chamberLayer << " chamberLayerMin=" << chamberLayerMin(id)
643 << " chamberLayerMax=" << chamberLayerMax(id));
644 return false;
645 }
646 if ((wireLayer < wireLayerMin(id)) || (wireLayer > wireLayerMax(id))) {
647 ATH_MSG_DEBUG("Invalid wireLayer=" << wireLayer << " wireLayerMin=" << wireLayerMin(id) << " wireLayerMax=" << wireLayerMax(id));
648 return false;
649 }
650 if ((measuresPhi < measuresPhiMin(id)) || (measuresPhi > measuresPhiMax(id))) {
651 ATH_MSG_DEBUG("Invalid measuresPhi=" << measuresPhi << " measuresPhiMin=" << measuresPhiMin(id)
652 << " measuresPhiMax=" << measuresPhiMax(id));
653 return false;
654 }
655 if ((strip > stripMax(id)) || (strip < stripMin(id))) {
656 ATH_MSG_DEBUG("Invalid strip=" << strip << " stripMin=" << stripMin(id) << " stripMax=" << stripMax(id));
657 return false;
658 }
659 return true;
660}
661
662// calculate the hash offset
664 m_hashOffset[0][0] = 0;
665 std::string version = m_dict->version();
666
667 if (version == "H8 2004") {
668 m_hashOffset[0][1] = 1536;
669 m_hashOffset[1][0] = m_hashOffset[0][0];
670 m_hashOffset[1][1] = m_hashOffset[0][1];
671 } else if (version == "CSC Cosmic") {
672 m_hashOffset[0][1] = 3072;
673 m_hashOffset[1][0] = m_hashOffset[0][0];
674 m_hashOffset[1][1] = m_hashOffset[0][1];
675 } else if (version == "P.03" || version == "H8 2003" || version == "H8 2002" || version == "M2.8") {
676 m_hashOffset[0][1] = 27392;
677 m_hashOffset[1][0] = m_hashOffset[0][1] + 3584;
678 m_hashOffset[1][1] = m_hashOffset[0][1] + m_hashOffset[1][0];
679 } else {
680 m_hashOffset[0][1] = 24576;
681 m_hashOffset[1][0] = m_hashOffset[0][1] + 6144;
682 m_hashOffset[1][1] = m_hashOffset[0][1] + m_hashOffset[1][0];
683 }
684 return 0;
685}
687 // pack fields independently
688 Identifier result((Identifier::value_type)0);
694 return result;
695}
697 try {
700 return result;
701 } catch (const std::out_of_range&) { isValid = false; }
702 return Identifier{0};
703}
704
705Identifier CscIdHelper::elementID(const std::string& stationNameStr, int stationEta, int stationPhi) const {
706 return elementID(stationNameIndex(stationNameStr), stationEta, stationPhi);
707}
708Identifier CscIdHelper::elementID(const std::string& stationNameStr, int stationEta, int stationPhi, bool& isValid) const {
709 return elementID(stationNameIndex(stationNameStr), stationEta, stationPhi, isValid);
710}
711
712Identifier CscIdHelper::elementID(const Identifier& id) const { return parentID(id); }
713
715 int strip) const {
716 // pack fields independently
717 Identifier result((Identifier::value_type)0);
726 m_str_impl.pack(strip, result);
727 return result;
728}
730 int strip, bool& isValid) const {
731 try {
734 return result;
735 } catch (const std::out_of_range&) { isValid = false; }
736 return Identifier{0};
737}
738
739Identifier CscIdHelper::channelID(const std::string& stationNameStr, int stationEta, int stationPhi, int chamberLayer, int wireLayer,
740 int measuresPhi, int strip) const {
742}
743Identifier CscIdHelper::channelID(const std::string& stationNameStr, int stationEta, int stationPhi, int chamberLayer, int wireLayer,
744 int measuresPhi, int strip, bool& isValid) const {
746}
747
757 try {
760 return result;
761 } catch (const std::out_of_range&) { isValid = false; }
762 return Identifier{0};
763}
764
765
767 assert(is_csc(id));
768 Identifier result(id);
769 m_cla_impl.reset(result);
770 m_lay_impl.reset(result);
771 m_mea_impl.reset(result);
772 m_str_impl.reset(result);
773 return result;
774}
775
776// Access to components of the ID
777
778int CscIdHelper::chamberLayer(const Identifier& id) const { return m_cla_impl.unpack(id); }
779
780int CscIdHelper::wireLayer(const Identifier& id) const { return m_lay_impl.unpack(id); }
781
782bool CscIdHelper::measuresPhi(const Identifier& id) const { return m_mea_impl.unpack(id); }
783
784int CscIdHelper::strip(const Identifier& id) const { return m_str_impl.unpack(id); }
785
786int CscIdHelper::channel(const Identifier& id) const { return strip(id); }
787
789
791
793
795
797
799
801
803
805
807
809
811
813
815
817 int cscField = technologyIndex("CSC");
818 if (m_dict) { cscField = csc_field_value(); }
819 return cscField;
820}
821
822int CscIdHelper::sector(const Identifier& id) const { return stationEta(id) * (2 * stationPhi(id) - (stationName(id) - 49) + 1); }
823
824int CscIdHelper::gasGap(const Identifier& id) const { return chamberLayer(id); }
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(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
#define max(a, b)
Definition cfImp.cxx:41
int muon_field_value() const
int csc_field_value() const
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
int register_dict_tag(const IdDictMgr &dict_mgr, const std::string &dict_name)
Register the file and tag names for a particular IdDict dictionary.
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
bool is_csc(Identifier id) const
unsigned int m_stripMaxPhi
int get_detectorElement_hash(const Identifier &id, IdentifierHash &hash_id) const override
static int wireLayerMax()
static int stationEtaMax()
size_type m_CHAMBERLAYER_INDEX
static int measuresPhiMin()
int sector(const Identifier &id) const
Identifier parentID(const Identifier &id) const
get parent id from channel id
static int stripMax()
Identifier channelID(int stationName, int stationEta, int stationPhi, int chamberLayer, int wireLayer, int measuresPhi, int strip) const
Identifier elementID(int stationName, int stationEta, int stationPhi) const
int wireLayer(const Identifier &id) const
static int stationPhiMax()
unsigned int moduleHashIdx(const Identifier &id) const
static int stationEtaMin()
Access to min and max of level ranges.
bool m_hasChamLay1
IdDictFieldImplementation m_cla_impl
IdDictFieldImplementation m_mea_impl
int chamberLayer(const Identifier &id) const
void idChannels(const Identifier &id, std::vector< Identifier > &vect) const
bool isStNameInTech(const std::string &stationName) const override
The valid element checks converted the identifier to a stationName string in order to assess whether ...
IdDictFieldImplementation m_lay_impl
int gasGap(const Identifier &id) const override
get the hashes
int strip(const Identifier &id) const
unsigned int m_stripMaxEta
static constexpr unsigned int s_mlDim
2 multi layer
size_type m_MEASURESPHI_INDEX
int strip_hash_offsets()
static constexpr unsigned int s_etaDim
static int chamberLayerMin()
IdDictFieldImplementation m_str_impl
size_type m_WIRELAYER_INDEX
bool valid(const Identifier &id) const
Public validation of levels.
int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
bool validChannel(const Identifier &id, int stationName, int stationEta, int stationPhi, int chamberLayer, int wireLayer, int measuresPhi, int strip) const
unsigned int detEleHashIdx(const Identifier &id) const
bool measuresPhi(const Identifier &id) const override
static int measuresPhiMax()
static int stripMin()
static constexpr unsigned int s_phiDim
8 phi stations
std::array< unsigned int, s_modHashDim > m_module_hashes
bool validElement(const Identifier &id) const
int init_id_to_hashes()
unsigned int m_stationShift
Minimal station index found.
static int stationPhiMin()
std::array< unsigned int, s_detHashDim > m_detectorElement_hashes
int cscTechnology() const
Utility methods.
int channel(const Identifier &id) const override
static int chamberLayerMax()
int m_hashOffset[2][2]
int get_module_hash(const Identifier &id, IdentifierHash &hash_id) const override
static int wireLayerMin()
void add(element_type value)
Append a value into a new field.
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
int get_label_value(const std::string &field, const std::string &label, int &value) const
const std::string & name() const
Dictionary name.
const IdDictRegion & region(size_t index) const
const IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
size_t index() const
const IdDictFieldImplementation & implementation(size_t i) const
element_type get_minimum() const
Query the values.
bool empty() const
If true, this field does not have any constraints, and may hold any value representable by element_ty...
element_type get_maximum() const
This is a "hash" representation of an Identifier.
A MultiRange combines several Ranges.
Definition MultiRange.h:17
size_type size() const
int stationNameIndex(const std::string &name) const
int stationEta(const Identifier &id) const
IdDictFieldImplementation m_phi_impl
size_t m_GROUP_INDEX
IdDictFieldImplementation m_tec_impl
int get_expanded_id(const Identifier &id, ExpandedIdentifier &exp_id, const IdContext *context) const
Create expanded id from compact id (return == 0 for OK)
const std::string & stationNameString(const Identifier &id) const
size_type m_PHI_INDEX
virtual int get_id(const IdentifierHash &hash_id, Identifier &id, const IdContext *context=0) const override
Create compact id from hash id (return == 0 for OK)
size_type m_CHANNEL_INDEX
int technologyIndex(const std::string &name) const
IdDictFieldImplementation m_sta_impl
MultiRange m_full_module_range
id_vec m_channel_vec
IdDictFieldImplementation m_eta_impl
size_type module_hash_max() const
the maximum hash value
MultiRange m_full_detectorElement_range
size_type m_ETA_INDEX
const IdDictDictionary * m_dict
int stationPhi(const Identifier &id) const
size_type m_DETECTORELEMENT_INDEX
int stationName(const Identifier &id) const
int init_channel_hashes()
int initLevelsFromDict()
id_vec m_detectorElement_vec
virtual int init_detectorElement_hashes()
size_type detectorElement_hash_max() const
IdDictFieldImplementation m_muon_impl
void resetAndSet(const IdDictFieldImplementation &dict, const int new_val, Identifier &id) const
bool validStation(int stationName, int technology) const
MultiRange m_full_channel_range
IdContext channel_context() const
id for channel
MuonIdHelper(const std::string &logName, const std::string &group)
id_vec m_module_vec
size_type m_TECHNOLOGY_INDEX
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
struct color C
Definition index.py:1