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 status = 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 status = 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 status = 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 status = 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 }
142
143 // Build MultiRange down to "detector element" for all mdt regions
144
145 ExpandedIdentifier detectorElement_region;
146 detectorElement_region.add(muonField);
147 Range detectorElement_prefix;
148 MultiRange muon_detectorElement_range = m_dict->build_multirange(detectorElement_region, detectorElement_prefix, "chamberLayer");
149 if (muon_detectorElement_range.size() > 0) {
150 ATH_MSG_INFO("MultiRange built successfully to detector element: "
151 << "Multilayer MultiRange size is " << muon_detectorElement_range.size());
152 } else {
153 ATH_MSG_ERROR("Muon CSC detector element MultiRange is empty");
154 }
155
157
158 ExpandedIdentifier csc_region;
159 csc_region.add(muonField);
160 Range csc_prefix;
161 MultiRange muon_channel_range = m_dict->build_multirange(csc_region, csc_prefix, "cscStrip");
162 if (muon_channel_range.size() > 0) {
163 ATH_MSG_INFO("MultiRange built successfully to cscStrip: "
164 << "MultiRange size is " << muon_channel_range.size());
165 } else {
166 ATH_MSG_ERROR("Muon MultiRange is empty for channels");
167 }
168
175
176 int cscField = -1;
177 status = m_dict->get_label_value("technology", "CSC", cscField);
178
179 for (int i = 0; i < (int)muon_range.size(); ++i) {
180 const Range& range = muon_range[i];
181 if (range.fields() > m_TECHNOLOGY_INDEX) {
182 const Range::field& field = range[m_TECHNOLOGY_INDEX];
183 if (field.match((ExpandedIdentifier::element_type)cscField)) {
184 m_full_module_range.add(range);
185 ATH_MSG_DEBUG("field size is " << (int)range.cardinality() << " field index = " << i);
186 }
187 }
188 }
189
190 for (int j = 0; j < (int)muon_detectorElement_range.size(); ++j) {
191 const Range& range = muon_detectorElement_range[j];
192 if (range.fields() > m_TECHNOLOGY_INDEX) {
193 const Range::field& field = range[m_TECHNOLOGY_INDEX];
194 if (field.match((ExpandedIdentifier::element_type)cscField)) {
196 ATH_MSG_DEBUG("detector element field size is " << (int)range.cardinality() << " field index = " << j);
197 }
198 }
199 }
200
201 for (int j = 0; j < (int)muon_channel_range.size(); ++j) {
202 const Range& range = muon_channel_range[j];
203 if (range.fields() > m_TECHNOLOGY_INDEX) {
204 const Range::field& field = range[m_TECHNOLOGY_INDEX];
205 if (field.match((ExpandedIdentifier::element_type)cscField)) {
206 m_full_channel_range.add(range);
207 ATH_MSG_DEBUG("channel field size is " << (int)range.cardinality() << " field index = " << j);
208 }
209 }
210 }
211
213
214 if (m_full_module_range.size() == 0) {
215 ATH_MSG_ERROR("CSC MultiRange ID is empty for modules");
216 status = 1;
217 }
218
220
221 if (m_full_detectorElement_range.size() == 0) {
222 ATH_MSG_ERROR("CSC MultiRange ID is empty for detector elements");
223 status = 1;
224 }
225
227
228 if (m_full_channel_range.size() == 0) {
229 ATH_MSG_ERROR("CSC MultiRange ID is empty for channels");
230 status = 1;
231 }
232
234
235 ATH_MSG_INFO("Initializing CSC hash indices ... ");
236 status = init_hashes();
237 status = init_detectorElement_hashes(); // for chamber layer - a chamber
238 status = init_channel_hashes();
239 status = strip_hash_offsets();
240 status = init_id_to_hashes();
241
243
244 ATH_MSG_INFO("Initializing CSC hash indices for finding neighbors ... ");
245 status = init_neighbors();
246
247 // now we have to set the stripMax values (for the stripMax(id) function)
248 // this could be also done on an event-by-event basis as for stripMin(id)
249 // however, for all existing layouts there are only 2 possible values for stripMax,
250 // namely those for layers which measure phi (measuresPhi(id)=true) and the rest.
251 // thus, we initialize 2 member variables here to speed up calling the function during runtime
252 // loop on the channel Identifiers and check (for consistency!) that really only
253 // two maximum numbers of strips (w/o measuresPhi) are around
254 ExpandedIdentifier expId;
255 IdContext strip_context = channel_context();
256 for (const auto& id : m_channel_vec) {
257 if (get_expanded_id(id, expId, &strip_context)) {
258 ATH_MSG_ERROR("Failed to retrieve ExpandedIdentifier from Identifier " << id.get_compact());
259 return 1;
260 }
261 bool measPhi = measuresPhi(id);
262 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
263 const Range& range = m_full_channel_range[i];
264 if (range.match(expId)) {
265 const Range::field& phi_field = range[m_CHANNEL_INDEX];
266 if (not !phi_field.empty()) {
267 ATH_MSG_ERROR("Range::field for phi at position " << i << " does not have a maximum");
268 return 1;
269 }
270 unsigned int max = phi_field.get_maximum();
271 if (measPhi) {
272 if (m_stripMaxPhi != UINT_MAX && m_stripMaxPhi != max) {
273 ATH_MSG_ERROR("Maximum of Range::field for phi (" << max << ") is not equal to m_stripMaxPhi=" << m_stripMaxPhi);
274 return 1;
275 } else
277 } else {
278 if (m_stripMaxEta != UINT_MAX && m_stripMaxEta != max) {
279 ATH_MSG_ERROR("Maximum of Range::field for phi (" << max << ") is not equal to m_stripMaxEta=" << m_stripMaxEta);
280 return 1;
281 } else
283 }
284 }
285 }
286 }
287
288 // check whether the current layout contains chamberLayer 1 Identifiers (pre-Run3) in the vector of module Identifiers
289 if (!m_module_vec.empty() && chamberLayer(m_module_vec.at(0)) == 1) m_hasChamLay1 = true;
290 m_init = true;
291 return (status);
292}
293
294inline unsigned int CscIdHelper::moduleHashIdx(const Identifier& id) const{
297 constexpr unsigned int C = s_phiDim;
298 constexpr unsigned int BxC = C*s_etaDim;
299 const int stEta = stationEta(id);
300 return (stationName(id) - m_stationShift)*BxC + (stEta + s_etaDim/2 - (stEta>0))*C + (stationPhi(id) -1);
301}
302inline unsigned int CscIdHelper::detEleHashIdx(const Identifier& id) const{
303 return moduleHashIdx(id) *s_mlDim + (chamberLayer(id) -1);
304}
305
307
308 for (const Identifier& id : m_module_vec) m_stationShift = std::min(m_stationShift, 1u* stationName(id));
309 unsigned int hash_max = module_hash_max();
310 for (unsigned int i = 0; i < hash_max; ++i) {
311 const Identifier& id = m_module_vec[i];
312 const unsigned idx = moduleHashIdx(id);
313 if (idx >= m_module_hashes.size() || m_module_hashes[idx] < hash_max){
314 ATH_MSG_FATAL("Failed to assign module hash to "<<show_to_string(id));
315 return 1;
316 }
317 m_module_hashes[idx] = i;
318 }
319
320 hash_max = detectorElement_hash_max();
321 for (unsigned int i = 0; i < hash_max; ++i) {
322 const Identifier& id = m_detectorElement_vec[i];
323 const unsigned idx = detEleHashIdx(id);
324 if (idx >= m_detectorElement_hashes.size() || m_detectorElement_hashes[idx] < hash_max){
325 ATH_MSG_FATAL("Failed to assign detector hash to "<<show_to_string(id));
326 return 1;
327 }
329 }
330
331 return 0;
332}
333
335 const unsigned int idx = moduleHashIdx(id);
336 if (idx >= m_module_hashes.size()) return 1;
337 hash_id = m_module_hashes[idx];
338 return 0;
339}
341 const unsigned int idx = detEleHashIdx(id);
342 if (idx >= m_detectorElement_hashes.size()) return 1;
343 hash_id = m_detectorElement_hashes[idx];
344 return 0;
345}
346
347
348
349void CscIdHelper::idChannels(const Identifier& id, std::vector<Identifier>& vect) const {
350 vect.clear();
351 Identifier parent = parentID(id);
352 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
353 const Range& range = m_full_channel_range[i];
354 ConstRangeIterator rit(range);
355 for (const auto & expId : rit) {
356 Identifier child;
357 get_id(expId, child);
358 if (parentID(child) == parent) vect.push_back(child);
359 }
360 }
361}
362
364 ExpandedIdentifier expId;
365 IdContext eta_context(expId, 0, m_ETA_INDEX);
366 if (!get_expanded_id(id, expId, &eta_context)) {
367 int result = -999;
368 for (unsigned int i = 0; i < m_full_module_range.size(); ++i) {
369 const Range& range = m_full_module_range[i];
370 if (range.match(expId)) {
371 const Range::field& eta_field = range[m_ETA_INDEX];
372 if (not eta_field.empty()) {
373 int etamin = eta_field.get_minimum();
374 if (-999 == result) {
375 result = etamin;
376 } else {
377 if (etamin < result) result = etamin;
378 }
379 }
380 }
381 }
382 return (result);
383 }
384 return (999);
385}
386
388 ExpandedIdentifier expId;
389 IdContext eta_context(expId, 0, m_ETA_INDEX);
390 if (!get_expanded_id(id, expId, &eta_context)) {
391 int result = -999;
392 for (unsigned int i = 0; i < m_full_module_range.size(); ++i) {
393 const Range& range = m_full_module_range[i];
394 if (range.match(expId)) {
395 const Range::field& eta_field = range[m_ETA_INDEX];
396 if (not eta_field.empty()) {
397 int etamax = eta_field.get_maximum();
398 if (result < etamax) result = etamax;
399 }
400 }
401 }
402 return (result);
403 }
404 return (-999);
405}
406
408 ExpandedIdentifier expId;
409 IdContext phi_context(expId, 0, m_PHI_INDEX);
410 if (!get_expanded_id(id, expId, &phi_context)) {
411 for (unsigned int i = 0; i < m_full_module_range.size(); ++i) {
412 const Range& range = m_full_module_range[i];
413 if (range.match(expId)) {
414 const Range::field& phi_field = range[m_PHI_INDEX];
415 if (not phi_field.empty()) { return (phi_field.get_minimum()); }
416 }
417 }
418 }
420 return (999);
421}
422
424 ExpandedIdentifier expId;
425 IdContext phi_context(expId, 0, m_PHI_INDEX);
426 if (!get_expanded_id(id, expId, &phi_context)) {
427 for (unsigned int i = 0; i < m_full_module_range.size(); ++i) {
428 const Range& range = m_full_module_range[i];
429 if (range.match(expId)) {
430 const Range::field& phi_field = range[m_PHI_INDEX];
431 if (not phi_field.empty()) { return (phi_field.get_maximum()); }
432 }
433 }
434 }
436 return (-999);
437}
438
440 ExpandedIdentifier expId;
441 IdContext chamberLayer_context(expId, 0, m_CHAMBERLAYER_INDEX);
442 if (!get_expanded_id(id, expId, &chamberLayer_context)) {
443 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
444 const Range& range = m_full_channel_range[i];
445 if (range.match(expId)) {
446 const Range::field& phi_field = range[m_CHAMBERLAYER_INDEX];
447 if (not phi_field.empty()) { return (phi_field.get_minimum()); }
448 }
449 }
450 }
452 return (999);
453}
454
456 ExpandedIdentifier expId;
457 IdContext chamberLayer_context(expId, 0, m_CHAMBERLAYER_INDEX);
458 if (!get_expanded_id(id, expId, &chamberLayer_context)) {
459 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
460 const Range& range = m_full_channel_range[i];
461 if (range.match(expId)) {
462 const Range::field& phi_field = range[m_CHAMBERLAYER_INDEX];
463 if (not phi_field.empty()) { return (phi_field.get_maximum()); }
464 }
465 }
466 }
468 return (-999);
469}
470
472 ExpandedIdentifier expId;
473 IdContext wireLayer_context(expId, 0, m_WIRELAYER_INDEX);
474 if (!get_expanded_id(id, expId, &wireLayer_context)) {
475 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
476 const Range& range = m_full_channel_range[i];
477 if (range.match(expId)) {
478 const Range::field& phi_field = range[m_WIRELAYER_INDEX];
479 if (not phi_field.empty()) { return (phi_field.get_minimum()); }
480 }
481 }
482 }
484 return (999);
485}
486
488 ExpandedIdentifier expId;
489 IdContext chamberLayer_context(expId, 0, m_WIRELAYER_INDEX);
490 if (!get_expanded_id(id, expId, &chamberLayer_context)) {
491 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
492 const Range& range = m_full_channel_range[i];
493 if (range.match(expId)) {
494 const Range::field& phi_field = range[m_WIRELAYER_INDEX];
495 if (not phi_field.empty()) { return (phi_field.get_maximum()); }
496 }
497 }
498 }
500 return (-999);
501}
502
504 ExpandedIdentifier expId;
505 IdContext measuresPhi_context(expId, 0, m_MEASURESPHI_INDEX);
506 if (!get_expanded_id(id, expId, &measuresPhi_context)) {
507 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
508 const Range& range = m_full_channel_range[i];
509 if (range.match(expId)) {
510 const Range::field& phi_field = range[m_MEASURESPHI_INDEX];
511 if (not phi_field.empty()) { return (phi_field.get_minimum()); }
512 }
513 }
514 }
516 return (999);
517}
518
520 ExpandedIdentifier expId;
521 IdContext measuresPhi_context(expId, 0, m_MEASURESPHI_INDEX);
522 if (!get_expanded_id(id, expId, &measuresPhi_context)) {
523 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
524 const Range& range = m_full_channel_range[i];
525 if (range.match(expId)) {
526 const Range::field& phi_field = range[m_MEASURESPHI_INDEX];
527 if (not phi_field.empty()) { return (phi_field.get_maximum()); }
528 }
529 }
530 }
532 return (-999);
533}
534
535int CscIdHelper::stripMin(const Identifier& id) const {
536 ExpandedIdentifier expId;
537 IdContext strip_context = channel_context();
538 if (!get_expanded_id(id, expId, &strip_context)) {
539 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
540 const Range& range = m_full_channel_range[i];
541 if (range.match(expId)) {
542 const Range::field& phi_field = range[m_CHANNEL_INDEX];
543 if (not phi_field.empty()) { return (phi_field.get_minimum()); }
544 }
545 }
546 }
548 return (999);
549}
550
551int CscIdHelper::stripMax(const Identifier& id) const {
552 if (measuresPhi(id))
553 return m_stripMaxPhi;
554 else
555 return m_stripMaxEta;
556}
557
559
560bool CscIdHelper::valid(const Identifier& id) const {
561 if (!validElement(id)) return false;
562
563 int cLayer = chamberLayer(id);
564 if ((cLayer < chamberLayerMin(id)) || (cLayer > chamberLayerMax(id))) {
565 ATH_MSG_DEBUG("Invalid chamberLayer=" << cLayer << " chamberLayerMin=" << chamberLayerMin(id)
566 << " chamberLayerMax=" << chamberLayerMax(id));
567 return false;
568 }
569
570 int wLayer = wireLayer(id);
571 if ((wLayer < wireLayerMin(id)) || (wLayer > wireLayerMax(id))) {
572 ATH_MSG_DEBUG("Invalid wireLayer=" << wLayer << " wireLayerMin=" << wireLayerMin(id) << " wireLayerMax=" << wireLayerMax(id));
573 return false;
574 }
575
576 int mPhi = measuresPhi(id);
577 if ((mPhi < measuresPhiMin(id)) || (mPhi > measuresPhiMax(id))) {
578 ATH_MSG_DEBUG("Invalid measuresPhi=" << mPhi << " measuresPhiMin=" << measuresPhiMin(id)
579 << " measuresPhiMax=" << measuresPhiMax(id));
580 return false;
581 }
582
583 int channel = strip(id);
584 if ((channel > stripMax(id)) || (channel < stripMin(id))) {
585 ATH_MSG_DEBUG("Invalid strip=" << channel << " stripMin=" << stripMin(id) << " stripMax=" << stripMax(id));
586 return false;
587 }
588 return true;
589}
590bool CscIdHelper::isStNameInTech(const std::string& stationName) const { return stationName[0] == 'C'; }
592 int station = stationName(id);
593 if (!validStation(station)) {
594 ATH_MSG_DEBUG("Invalid stationName=" << stationNameString(station));
595 return false;
596 }
597
598 int eta = stationEta(id);
599 if ((eta < stationEtaMin(id)) || (eta > stationEtaMax(id)) || (0 == eta)) {
600 ATH_MSG_DEBUG("Invalid stationEta=" << eta << " for stationName=" << stationNameString(station)
601 << " stationEtaMin=" << stationEtaMin(id) << " stationEtaMax=" << stationEtaMax(id));
602 return false;
603 }
604
605 int phi = stationPhi(id);
606 if ((phi < stationPhiMin(id)) || (phi > stationPhiMax(id))) {
607 ATH_MSG_DEBUG("Invalid stationPhi=" << phi << " for stationName=" << stationNameString(station)
608 << " stationPhiMin=" << stationPhiMin(id) << " stationPhiMax=" << stationPhiMax(id));
609 return false;
610 }
611 return true;
612}
613
615
618 ATH_MSG_DEBUG("Invalid stationName=" << stationNameString(stationName));
619 return false;
620 }
621 if ((stationEta < stationEtaMin(id)) || (stationEta > stationEtaMax(id)) || (0 == stationEta)) {
622 ATH_MSG_DEBUG("Invalid stationEta=" << stationEta << " for stationName=" << stationNameString(stationName)
623 << " stationEtaMin=" << stationEtaMin(id) << " stationEtaMax=" << stationEtaMax(id));
624 return false;
625 }
626 if ((stationPhi < stationPhiMin(id)) || (stationPhi > stationPhiMax(id))) {
627 ATH_MSG_DEBUG("Invalid stationPhi=" << stationPhi << " for stationName=" << stationNameString(stationName)
628 << " stationPhiMin=" << stationPhiMin(id) << " stationPhiMax=" << stationPhiMax(id));
629 return false;
630 }
631 return true;
632}
633
635 int measuresPhi, int strip) const {
636 if (!validElement(id, stationName, stationEta, stationPhi)) return false;
637
639 ATH_MSG_DEBUG("Invalid chamberLayer=" << chamberLayer << " chamberLayerMin=" << chamberLayerMin(id)
640 << " chamberLayerMax=" << chamberLayerMax(id));
641 return false;
642 }
643 if ((wireLayer < wireLayerMin(id)) || (wireLayer > wireLayerMax(id))) {
644 ATH_MSG_DEBUG("Invalid wireLayer=" << wireLayer << " wireLayerMin=" << wireLayerMin(id) << " wireLayerMax=" << wireLayerMax(id));
645 return false;
646 }
647 if ((measuresPhi < measuresPhiMin(id)) || (measuresPhi > measuresPhiMax(id))) {
648 ATH_MSG_DEBUG("Invalid measuresPhi=" << measuresPhi << " measuresPhiMin=" << measuresPhiMin(id)
649 << " measuresPhiMax=" << measuresPhiMax(id));
650 return false;
651 }
652 if ((strip > stripMax(id)) || (strip < stripMin(id))) {
653 ATH_MSG_DEBUG("Invalid strip=" << strip << " stripMin=" << stripMin(id) << " stripMax=" << stripMax(id));
654 return false;
655 }
656 return true;
657}
658
659// calculate the hash offset
661 m_hashOffset[0][0] = 0;
662 std::string version = m_dict->version();
663
664 if (version == "H8 2004") {
665 m_hashOffset[0][1] = 1536;
666 m_hashOffset[1][0] = m_hashOffset[0][0];
667 m_hashOffset[1][1] = m_hashOffset[0][1];
668 } else if (version == "CSC Cosmic") {
669 m_hashOffset[0][1] = 3072;
670 m_hashOffset[1][0] = m_hashOffset[0][0];
671 m_hashOffset[1][1] = m_hashOffset[0][1];
672 } else if (version == "P.03" || version == "H8 2003" || version == "H8 2002" || version == "M2.8") {
673 m_hashOffset[0][1] = 27392;
674 m_hashOffset[1][0] = m_hashOffset[0][1] + 3584;
675 m_hashOffset[1][1] = m_hashOffset[0][1] + m_hashOffset[1][0];
676 } else {
677 m_hashOffset[0][1] = 24576;
678 m_hashOffset[1][0] = m_hashOffset[0][1] + 6144;
679 m_hashOffset[1][1] = m_hashOffset[0][1] + m_hashOffset[1][0];
680 }
681 return 0;
682}
684 // pack fields independently
685 Identifier result((Identifier::value_type)0);
691 return result;
692}
694 try {
697 return result;
698 } catch (const std::out_of_range&) { isValid = false; }
699 return Identifier{0};
700}
701
702Identifier CscIdHelper::elementID(const std::string& stationNameStr, int stationEta, int stationPhi) const {
703 return elementID(stationNameIndex(stationNameStr), stationEta, stationPhi);
704}
705Identifier CscIdHelper::elementID(const std::string& stationNameStr, int stationEta, int stationPhi, bool& isValid) const {
706 return elementID(stationNameIndex(stationNameStr), stationEta, stationPhi, isValid);
707}
708
709Identifier CscIdHelper::elementID(const Identifier& id) const { return parentID(id); }
710
712 int strip) const {
713 // pack fields independently
714 Identifier result((Identifier::value_type)0);
723 m_str_impl.pack(strip, result);
724 return result;
725}
727 int strip, bool& isValid) const {
728 try {
731 return result;
732 } catch (const std::out_of_range&) { isValid = false; }
733 return Identifier{0};
734}
735
736Identifier CscIdHelper::channelID(const std::string& stationNameStr, int stationEta, int stationPhi, int chamberLayer, int wireLayer,
737 int measuresPhi, int strip) const {
739}
740Identifier CscIdHelper::channelID(const std::string& stationNameStr, int stationEta, int stationPhi, int chamberLayer, int wireLayer,
741 int measuresPhi, int strip, bool& isValid) const {
743}
744
754 try {
757 return result;
758 } catch (const std::out_of_range&) { isValid = false; }
759 return Identifier{0};
760}
761
762
764 assert(is_csc(id));
765 Identifier result(id);
766 m_cla_impl.reset(result);
767 m_lay_impl.reset(result);
768 m_mea_impl.reset(result);
769 m_str_impl.reset(result);
770 return result;
771}
772
773// Access to components of the ID
774
775int CscIdHelper::chamberLayer(const Identifier& id) const { return m_cla_impl.unpack(id); }
776
777int CscIdHelper::wireLayer(const Identifier& id) const { return m_lay_impl.unpack(id); }
778
779bool CscIdHelper::measuresPhi(const Identifier& id) const { return m_mea_impl.unpack(id); }
780
781int CscIdHelper::strip(const Identifier& id) const { return m_str_impl.unpack(id); }
782
783int CscIdHelper::channel(const Identifier& id) const { return strip(id); }
784
786
788
790
792
794
796
798
800
802
804
806
808
810
812
814 int cscField = technologyIndex("CSC");
815 if (m_dict) { cscField = csc_field_value(); }
816 return cscField;
817}
818
819int CscIdHelper::sector(const Identifier& id) const { return stationEta(id) * (2 * stationPhi(id) - (stationName(id) - 49) + 1); }
820
821int 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
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)
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
bool is_csc(const Identifier &id) 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
const std::string & stationNameString(const int &index) const
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