ATLAS Offline Software
Loading...
Searching...
No Matches
sTgcIdHelper.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
13/*******************************************************************************/
14// Constructor/Destructor
15sTgcIdHelper::sTgcIdHelper() : MuonIdHelper("sTgcIdHelper", "stgc") {
16 m_module_hashes.fill(-1);
18}
19/*******************************************************************************/
20// Initialize dictionary
22 int status = 0;
23
24 // Check whether this helper should be reinitialized
25 if (!reinitialize(dict_mgr)) {
26 ATH_MSG_INFO("Request to reinitialize not satisfied - tags have not changed");
27 return (0);
28 } else {
29 ATH_MSG_DEBUG("(Re)initialize ");
30 }
31
32 // init base object
33 if (AtlasDetectorID::initialize_from_dictionary(dict_mgr)) return 1;
34
35 // Register version of the MuonSpectrometer dictionary
36 if (register_dict_tag(dict_mgr, "MuonSpectrometer")) return 1;
37
38 m_dict = dict_mgr.find_dictionary("MuonSpectrometer");
39 if (!m_dict) {
40 ATH_MSG_ERROR(" initialize_from_dict - cannot access MuonSpectrometer dictionary ");
41 return 1;
42 }
43
44 // Initialize some of the field indices
45 if (initLevelsFromDict()) return 1;
46
47 int index = technologyIndex("STGC");
48 if (index == -1) {
49 ATH_MSG_DEBUG("initLevelsFromDict - there are no sTGC entries in the dictionary! ");
50 return 0;
51 }
52
53 const IdDictField* field = m_dict->find_field("stgcMultilayer");
54 if (field) {
55 m_DETECTORELEMENT_INDEX = field->index();
56 } else {
57 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'stgcMultilayer' field ");
58 status = 1;
59 }
60
61 field = m_dict->find_field("stgcGasGap");
62 if (field) {
63 m_GASGAP_INDEX = field->index();
64 } else {
65 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'stgcGasGap' field ");
66 status = 1;
67 }
68
69 field = m_dict->find_field("stgcChannelType");
70 if (field) {
71 m_CHANNELTYPE_INDEX = field->index();
72 } else {
73 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'channelType' field ");
74 status = 1;
75 }
76
77 field = m_dict->find_field("stgcChannel");
78 if (field) {
79 m_CHANNEL_INDEX = field->index();
80 } else {
81 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'channel' field ");
82 status = 1;
83 }
84
85 // reinitialize the module ndex
86 // m_DETECTORELEMENT_INDEX = m_MODULE_INDEX;
87
88 // save an index to the first region of tgc
89 const IdDictGroup* stgcGroup = m_dict->find_group("stgc");
90 if (!stgcGroup) {
91 ATH_MSG_ERROR("Cannot find stgc group");
92 } else {
93 m_GROUP_INDEX = stgcGroup->region(0).index();
94 }
95
96 const IdDictRegion& region = m_dict->region(m_GROUP_INDEX);
104
105 ATH_MSG_DEBUG(" sTGC 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 << " multilayer " << m_mplet_impl.show_to_string() << std::endl
112 << " gasgap " << m_gap_impl.show_to_string() << std::endl
113 << " channelType " << m_typ_impl.show_to_string() << std::endl
114 << " channel " << m_cha_impl.show_to_string());
115
116 //
117 // Build multirange for the valid set of identifiers
118 //
119
120 // Find value for the field MuonSpectrometer
121 int muonField = -1;
122 const IdDictDictionary* atlasDict = dict_mgr.find_dictionary("ATLAS");
123 if (atlasDict->get_label_value("subdet", "MuonSpectrometer", muonField)) {
124 ATH_MSG_ERROR("Could not get value for label 'MuonSpectrometer' of field 'subdet' in dictionary " << atlasDict->name());
125 return 1;
126 }
127
128 // Build MultiRange down to "technology" for all (muon) regions
129 ExpandedIdentifier region_id;
130 region_id.add(muonField);
131 Range prefix;
132 MultiRange muon_range = m_dict->build_multirange(region_id, prefix, "technology");
133 if (muon_range.size() > 0) {
134 ATH_MSG_INFO("MultiRange built successfully to Technology: "
135 << "MultiRange size is " << muon_range.size());
136 } else {
137 ATH_MSG_ERROR("Muon sTGC detector element MultiRange is empty");
138 }
139
140 // Build MultiRange down to "detector element" for all sTGC regions
141 ExpandedIdentifier detectorElement_region;
142 detectorElement_region.add(muonField);
143 Range detectorElement_prefix;
144 MultiRange muon_detectorElement_range = m_dict->build_multirange(detectorElement_region, detectorElement_prefix, "stgcMultilayer");
145 if (muon_detectorElement_range.size() > 0) {
146 ATH_MSG_INFO("MultiRange built successfully to detector element: "
147 << "Multilayer MultiRange size is " << muon_detectorElement_range.size());
148 } else {
149 ATH_MSG_ERROR("Muon sTGC detector element MultiRange is empty");
150 }
151
152 // Build MultiRange down to "channel" for all sTGC regions
153 ExpandedIdentifier stgc_region;
154 stgc_region.add(muonField);
155 Range stgc_prefix;
156 MultiRange muon_channel_range = m_dict->build_multirange(stgc_region, stgc_prefix, "stgcChannel");
157 if (muon_channel_range.size() > 0) {
158 ATH_MSG_INFO("MultiRange built successfully to channel: "
159 << "MultiRange size is " << muon_channel_range.size());
160 } else {
161 ATH_MSG_ERROR("Muon sTGC detector MultiRange is empty for channels");
162 }
163
164 // build sTGC module ranges
165 // Find the regions that have a "technology field" that matches the sTGC and save them
166 int stgcField = -1;
167 status = m_dict->get_label_value("technology", "STGC", stgcField);
168
169 for (int i = 0; i < (int)muon_range.size(); ++i) {
170 const Range& range = muon_range[i];
171 if (range.fields() > m_TECHNOLOGY_INDEX) {
172 const Range::field& field = range[m_TECHNOLOGY_INDEX];
173 if (field.match((ExpandedIdentifier::element_type)stgcField)) {
174 m_full_module_range.add(range);
175 ATH_MSG_DEBUG("field size is " << (int)range.cardinality() << " field index = " << i);
176 }
177 }
178 }
179
180 for (int j = 0; j < (int)muon_detectorElement_range.size(); ++j) {
181 const Range& range = muon_detectorElement_range[j];
182 if (range.fields() > m_TECHNOLOGY_INDEX) {
183 const Range::field& field = range[m_TECHNOLOGY_INDEX];
184 if (field.match((ExpandedIdentifier::element_type)stgcField)) {
186 ATH_MSG_DEBUG("detector element field size is " << (int)range.cardinality() << " field index = " << j);
187 }
188 }
189 }
190
191 for (int j = 0; j < (int)muon_channel_range.size(); ++j) {
192 const Range& range = muon_channel_range[j];
193 if (range.fields() > m_TECHNOLOGY_INDEX) {
194 const Range::field& field = range[m_TECHNOLOGY_INDEX];
195 if (field.match((ExpandedIdentifier::element_type)stgcField)) {
196 m_full_channel_range.add(range);
197 ATH_MSG_DEBUG("channel field size is " << (int)range.cardinality() << " field index = " << j);
198 }
199 }
200 }
201
202 // test to see that the multi range is not empty
203 if (m_full_module_range.size() == 0) {
204 ATH_MSG_ERROR("sTGC MultiRange ID is empty for modules");
205 status = 1;
206 }
207
208 // test to see that the detector element multi range is not empty
209 if (m_full_detectorElement_range.size() == 0) {
210 ATH_MSG_ERROR("sTGC MultiRange ID is empty for detector elements");
211 status = 1;
212 }
213
214 // test to see that the multi range is not empty
215 if (m_full_channel_range.size() == 0) {
216 ATH_MSG_ERROR("sTGC MultiRange ID is empty for channels");
217 status = 1;
218 }
219
220 // Setup the hash tables for sTGC
221 ATH_MSG_INFO("Initializing sTGC hash indices ... ");
222 status = init_hashes();
223 status = init_detectorElement_hashes(); // same as module hash
224 status = init_id_to_hashes();
225
226 /*
227 //comment out this bit to test the identifiers
228
229 status = init_channel_hashes();
230 std::cout << " looping over identifiers " << std::endl;
231 const_id_iterator it = channel_begin();
232 const_id_iterator it_end = channel_end();
233 for( ;it!=it_end;++it ){
234 if( !is_stgc(*it) ) (*m_Log) << MSG::DEBUG << "BadStgc: not sTGC " << print_to_string(*it) << endmsg;
235 if( !valid(*it) ) (*m_Log) << MSG::DEBUG << "BadStgc: not valid " << print_to_string(*it) << endmsg;
236 }
237
238 */
239
240 // Setup hash tables for finding neighbors
241 ATH_MSG_INFO("Initializing sTGC hash indices for finding neighbors ... ");
242 status = init_neighbors();
243
244 m_init = true;
245 return (status);
246} // end sTgcIdHelper::initialize_from_dictionary
247/*******************************************************************************/
248inline unsigned int sTgcIdHelper::moduleHashIdx(const Identifier& id) const{
251 constexpr unsigned int C = s_phiDim;
252 constexpr unsigned int BxC = C*s_etaDim;
253 const int stEta = stationEta(id);
254 return (stationName(id) - m_stationShift)*BxC + (stEta + s_etaDim/2 - (stEta>0))*C + (stationPhi(id) -1);
255}
256inline unsigned int sTgcIdHelper::detEleHashIdx(const Identifier& id) const{
257 return moduleHashIdx(id) *s_mlDim + (multilayer(id) -1);
258}
259
261 for (const Identifier& id : m_module_vec) m_stationShift = std::min(m_stationShift, 1u* stationName(id));
262 unsigned int hash_max = module_hash_max();
263 for (unsigned int i = 0; i < hash_max; ++i) {
264 const Identifier& id = m_module_vec[i];
265 const unsigned idx = moduleHashIdx(id);
266 if (idx >= m_module_hashes.size() || m_module_hashes[idx] < hash_max){
267 ATH_MSG_FATAL("Failed to assign module hash to "<<show_to_string(id));
268 return 1;
269 }
270 m_module_hashes[idx] = i;
271 }
272
273 hash_max = detectorElement_hash_max();
274 for (unsigned int i = 0; i < hash_max; ++i) {
275 const Identifier& id = m_detectorElement_vec[i];
276 const unsigned idx = detEleHashIdx(id);
277 if (idx >= m_detectorElement_hashes.size() || m_detectorElement_hashes[idx] < hash_max){
278 ATH_MSG_FATAL("Failed to assign detector hash to "<<show_to_string(id));
279 return 1;
280 }
282 }
283 return 0;
284} // end sTgcIdHelper::init_id_to_hashes()
285/*******************************************************************************/
287 const unsigned int idx = moduleHashIdx(id);
288 if (idx >= m_module_hashes.size()) return 1;
289 hash_id = m_module_hashes[idx];
290 return 0;
291} // end sTgcIdHelper::get_module_hash
292/*******************************************************************************/
294 const unsigned int idx = detEleHashIdx(id);
295 if (idx >= m_detectorElement_hashes.size()) return 1;
296 hash_id = m_detectorElement_hashes[idx];
297 return 0;
298 // return get_module_hash(id, hash_id);
299}
300
301/*******************************************************************************/
303 assert(is_stgc(channelID));
305 m_gap_impl.reset(result);
306 m_typ_impl.reset(result);
307 m_cha_impl.reset(result);
308 return result;
309}
310/*******************************************************************************/
312 Identifier result(moduleID);
314 return result;
315}
317 try {
318 const Identifier result = multilayerID(moduleID, multilayer);
320 return result;
321 } catch (const std::out_of_range&) { isValid = false; }
322 return Identifier{0};
323}
324/*******************************************************************************/
325
326// febID constructs an identifier that can be associcate with a region of the detector that is read out by the same front end board
340 return channelID(channelId, multilayer(channelId), gasGap(channelId),(int)(channelType(channelId) ==sTgcChannelTypes::Strip ? sTgcChannelTypes::Strip : sTgcChannelTypes::Pad), 1);
341}
342
343
344Identifier sTgcIdHelper::hvID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, bool isInnerQ1)const{
345 int channel = 1;
346 if(!isInnerQ1 && std::abs(stationEta)==1) channel = 100;
348}
349
350Identifier sTgcIdHelper::hvID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, bool isInnerQ1, bool& isValid)const{
351 int channel = 1;
352 if(!isInnerQ1 && std::abs(stationEta)==1) channel = 100;
354}
355
356Identifier sTgcIdHelper::hvID(const std::string& stationName, int stationEta, int stationPhi, int multilayer, int gasGap, bool isInnerQ1)const{
357 int channel = 1;
358 if(!isInnerQ1 && std::abs(stationEta)==1) channel = 100;
360}
361
362Identifier sTgcIdHelper::hvID(const std::string& stationName, int stationEta, int stationPhi, int multilayer, int gasGap, bool isInnerQ1, bool& isValid)const{
363 int channel = 1;
364 if(!isInnerQ1 && std::abs(stationEta)==1) channel = 100;
366}
367
368Identifier sTgcIdHelper::hvID(const Identifier& channelId, bool isInnerQ1)const{
369 int channel = 1;
370 if(std::abs(stationEta(channelId))==1 && !isInnerQ1) channel = 100;
371 return channelID(channelId, multilayer(channelId), gasGap(channelId), sTgcChannelTypes::Strip, channel);
372}
373
374
375Identifier sTgcIdHelper::hvID(const Identifier& channelId, bool isInnerQ1, bool& isValid)const{
376 int channel = 1;
377 if(std::abs(stationEta(channelId))==1 && !isInnerQ1) channel = 100;
378 return channelID(channelId, multilayer(channelId), gasGap(channelId), sTgcChannelTypes::Strip, channel, isValid);
379}
380
381
382
383
384
385
386
387
388
389/*******************************************************************************/
390void sTgcIdHelper::idChannels(const Identifier& id, std::vector<Identifier>& vect) const {
391 vect.clear();
392 Identifier parent = parentID(id);
393 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
394 const Range& range = m_full_channel_range[i];
395 ConstRangeIterator rit(range);
396 for (const auto & expId:rit) {
397 Identifier child;
398 get_id(expId, child);
399 if (parentID(child) == parent) vect.push_back(child);
400 }
401 }
402}
403/*******************************************************************************/
405 ExpandedIdentifier expId;
406 IdContext eta_context(expId, 0, m_ETA_INDEX);
407 if (!get_expanded_id(id, expId, &eta_context)) {
408 int result = -999;
409 for (unsigned int i = 0; i < m_full_module_range.size(); ++i) {
410 const Range& range = m_full_module_range[i];
411 if (range.match(expId)) {
412 const Range::field& eta_field = range[m_ETA_INDEX];
413 if (not eta_field.empty()) {
414 int etamin = eta_field.get_minimum();
415 if (-999 == result) {
416 result = etamin;
417 } else {
418 if (etamin < result) result = etamin;
419 }
420 }
421 }
422 }
423 return result;
424 }
425 return 999; // default
426} // end TgcIdHelper::stationEtaMin
427/*******************************************************************************/
429 ExpandedIdentifier expId;
430 IdContext eta_context(expId, 0, m_ETA_INDEX);
431 if (!get_expanded_id(id, expId, &eta_context)) {
432 int result = -999;
433 for (unsigned int i = 0; i < m_full_module_range.size(); ++i) {
434 const Range& range = m_full_module_range[i];
435 if (range.match(expId)) {
436 const Range::field& eta_field = range[m_ETA_INDEX];
437 if (not eta_field.empty()) {
438 int etamax = eta_field.get_maximum();
439 if (result < etamax) result = etamax;
440 }
441 }
442 }
443 return result;
444 }
445 return -999;
446} // end TgcIdHelper::stationEtaMax
447/*******************************************************************************/
449 ExpandedIdentifier expId;
450 IdContext phi_context(expId, 0, m_PHI_INDEX);
451
452 if (!get_expanded_id(id, expId, &phi_context)) {
453 for (unsigned int i = 0; i < m_full_module_range.size(); ++i) {
454 const Range& range = m_full_module_range[i];
455 if (range.match(expId)) {
456 const Range::field& phi_field = range[m_PHI_INDEX];
457 if (not phi_field.empty()) { return (phi_field.get_minimum()); }
458 }
459 }
460 }
461 // Failed to find the min
462 return 999;
463}
464/*******************************************************************************/
466 ExpandedIdentifier expId;
467 IdContext phi_context(expId, 0, m_PHI_INDEX);
468
469 if (!get_expanded_id(id, expId, &phi_context)) {
470 for (unsigned int i = 0; i < m_full_module_range.size(); ++i) {
471 const Range& range = m_full_module_range[i];
472 if (range.match(expId)) {
473 const Range::field& phi_field = range[m_PHI_INDEX];
474 if (not phi_field.empty()) { return (phi_field.get_maximum()); }
475 }
476 }
477 }
478 // Failed to find the max
479 return -999;
480}
481/*******************************************************************************/
483 ExpandedIdentifier expId;
484 IdContext context = technology_context();
485 if (!get_expanded_id(id, expId, &context)) {
486 int result = -999;
487 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
488 const Range& range = m_full_channel_range[i];
489 if (range.match(expId)) {
490 const Range::field& multilayer_field = range[m_DETECTORELEMENT_INDEX];
491 if (not multilayer_field.empty()) {
492 int multilayermax = multilayer_field.get_maximum();
493 if (result < multilayermax) result = multilayermax;
494 }
495 }
496 }
497 return result;
498 }
499 return -999;
500}
501/*******************************************************************************/
503 ExpandedIdentifier expId;
504 IdContext multilayer_context(expId, 0, m_DETECTORELEMENT_INDEX);
505 if (!get_expanded_id(id, expId, &multilayer_context)) {
506 int result = -999;
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& multilayer_field = range[m_DETECTORELEMENT_INDEX];
511 if (not multilayer_field.empty()) {
512 int multilayermin = multilayer_field.get_minimum();
513 if (-999 == result) {
514 result = multilayermin;
515 } else {
516 if (multilayermin < result) result = multilayermin;
517 }
518 }
519 }
520 }
521 return result;
522 }
523 return 999;
524}
525/*******************************************************************************/
527 ExpandedIdentifier expId;
528 IdContext multilayer_context(expId, 0, m_DETECTORELEMENT_INDEX);
529 if (!get_expanded_id(id, expId, &multilayer_context)) {
530 int result = -999;
531 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
532 const Range& range = m_full_channel_range[i];
533 if (range.match(expId)) {
534 const Range::field& multilayer_field = range[m_DETECTORELEMENT_INDEX];
535 if (not multilayer_field.empty()) {
536 int multilayermax = multilayer_field.get_maximum();
537 if (result < multilayermax) result = multilayermax;
538 }
539 }
540 }
541 return result;
542 }
543 return -999;
544}
545/*******************************************************************************/
547 ExpandedIdentifier expId;
548 IdContext gasgap_context(expId, 0, m_GASGAP_INDEX);
549 if (!get_expanded_id(id, expId, &gasgap_context)) {
550 int result = -999;
551 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
552 const Range& range = m_full_channel_range[i];
553 if (range.match(expId)) {
554 const Range::field& gasgap_field = range[m_GASGAP_INDEX];
555 if (not gasgap_field.empty()) {
556 int gasgapmin = gasgap_field.get_minimum();
557 if (-999 == result) {
558 result = gasgapmin;
559 } else {
560 if (gasgapmin < result) result = gasgapmin;
561 }
562 }
563 }
564 }
565 return result;
566 }
567 return 999;
568}
569/*******************************************************************************/
571 ExpandedIdentifier expId;
572 IdContext gasgap_context(expId, 0, m_GASGAP_INDEX);
573 if (!get_expanded_id(id, expId, &gasgap_context)) {
574 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
575 const Range& range = m_full_channel_range[i];
576 if (range.match(expId)) {
577 const Range::field& gasgap_field = range[m_GASGAP_INDEX];
578 if (not gasgap_field.empty()) { return (gasgap_field.get_maximum()); }
579 }
580 }
581 }
582 // Failed to find the max
583 return -999;
584}
585/*******************************************************************************/
587 ExpandedIdentifier expId;
588 IdContext channeltype_context(expId, 0, m_CHANNELTYPE_INDEX);
589 if (!get_expanded_id(id, expId, &channeltype_context)) {
590 int result = -999;
591 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
592 const Range& range = m_full_channel_range[i];
593 if (range.match(expId)) {
594 const Range::field& channeltype_field = range[m_CHANNELTYPE_INDEX];
595 if (not channeltype_field.empty()) {
596 int channeltypemin = channeltype_field.get_minimum();
597 if (-999 == result) {
598 result = channeltypemin;
599 } else {
600 if (channeltypemin < result) result = channeltypemin;
601 }
602 }
603 }
604 }
605 return result;
606 }
607 return 999;
608}
609/*******************************************************************************/
611 ExpandedIdentifier expId;
612 IdContext channeltype_context(expId, 0, m_CHANNELTYPE_INDEX);
613 if (!get_expanded_id(id, expId, &channeltype_context)) {
614 int result = -999;
615 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
616 const Range& range = m_full_channel_range[i];
617 if (range.match(expId)) {
618 const Range::field& channeltype_field = range[m_CHANNELTYPE_INDEX];
619 if (not channeltype_field.empty()) {
620 int channeltypemax = channeltype_field.get_maximum();
621 if (result < channeltypemax) result = channeltypemax;
622 }
623 }
624 }
625 return result;
626 }
627 return -999;
628}
629/*******************************************************************************/
631 ExpandedIdentifier expId;
633 if (!get_expanded_id(id, expId, &channel_context)) {
634 int result = -999;
635 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
636 const Range& range = m_full_channel_range[i];
637 if (range.match(expId)) {
638 const Range::field& channel_field = range[m_CHANNEL_INDEX];
639 if (not channel_field.empty()) {
640 int channelmin = channel_field.get_minimum();
641 if (-999 == result) {
642 result = channelmin;
643 } else {
644 if (channelmin < result) result = channelmin;
645 }
646 }
647 }
648 }
649 return result;
650 }
651 return 999;
652}
653/*******************************************************************************/
655 ExpandedIdentifier expId;
657 if (!get_expanded_id(id, expId, &channel_context)) {
658 int result = -999;
659 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
660 const Range& range = m_full_channel_range[i];
661 if (range.match(expId)) {
662 const Range::field& channel_field = range[m_CHANNEL_INDEX];
663 if (not channel_field.empty()) {
664 int channelmax = channel_field.get_maximum();
665 if (result < channelmax) result = channelmax;
666 }
667 }
668 }
669 return result;
670 }
671 return -999;
672}
673/*******************************************************************************/
674int sTgcIdHelper::padEta(const Identifier& id) const {
675 int ChannelType = channelType(id);
676 int PadEta = 0;
677 if (ChannelType == Pad) {
678 int Channel = channel(id);
679 PadEta = ((Channel - 1) % PadEtaMax) + 1;
680 }
681 return PadEta;
682}
683/*******************************************************************************/
684int sTgcIdHelper::padPhi(const Identifier& id) const {
685 int ChannelType = channelType(id);
686 int PadPhi = 0;
687 if (ChannelType == Pad) {
688 int Channel = channel(id);
689 PadPhi = ((Channel - 1) / PadEtaMax) + 1;
690 }
691 return PadPhi;
692}
693/*******************************************************************************/
694// validation of levels
695bool sTgcIdHelper::valid(const Identifier& id) const {
696 if (!validElement(id)) return false;
697
698 int mplet = multilayer(id);
699 if ((mplet < multilayerMin(id)) || (mplet > multilayerMax(id))) {
700 ATH_MSG_DEBUG("Invalid multilayer=" << mplet << " multilayerMin=" << multilayerMin(id) << " multilayerMax=" << multilayerMax(id));
701 return false;
702 }
703
704 int gasG = gasGap(id);
705 if (gasG < gasGapMin(id) || gasG > gasGapMax(id)) {
706 ATH_MSG_DEBUG("Invalid gasGap=" << gasG << " gasGapMin=" << gasGapMin(id) << " gasGapMax=" << gasGapMax(id));
707 return false;
708 }
709
710 int channeltype = channelType(id);
711 if (channeltype < channelTypeMin(id) || channeltype > channelTypeMax(id)) {
712 ATH_MSG_DEBUG("Invalid channelType=" << channeltype << " channelTypeMin=" << channelTypeMin(id)
713 << " channelTypeMax=" << channelTypeMax(id));
714 return false;
715 }
716
717 int element = channel(id);
718 if (element < channelMin(id) || element > channelMax(id)) {
719 ATH_MSG_DEBUG("Invalid channel=" << element << " channelMin=" << channelMin(id) << " channelMax=" << channelMax(id));
720 return false;
721 }
722
723 if (channeltype == Pad) {
724 int PadEta = padEta(id);
725 int PadPhi = padPhi(id);
726 if (PadEta < PadEtaMin || PadEta > PadEtaMax) {
727 ATH_MSG_DEBUG("Invalid padEta=" << PadEta << " padEtaMin=" << PadEtaMin << " padEtaMax=" << PadEtaMax);
728 return false;
729 }
730 if (PadPhi < PadPhiMin || PadPhi > PadPhiMax) {
731 ATH_MSG_DEBUG("Invalid padEPhi" << PadPhi << " padPhiMin=" << PadPhiMin << " padPhiMax=" << PadPhiMax);
732 return false;
733 }
734 }
735
736 return true;
737} // end sTgcIdHelper::valid
738/*******************************************************************************/
739bool sTgcIdHelper::isStNameInTech(const std::string& name) const { return 'S' == name[0] && 'T' == name[1]; }
741 int station = stationName(id);
742 if (!validStation(station)) {
743 ATH_MSG_DEBUG("Invalid stationName=" << stationNameString(station));
744 return false;
745 }
746
747 int eta = stationEta(id);
748 if (eta < stationEtaMin(id) || eta > stationEtaMax(id)) {
749 ATH_MSG_DEBUG("Invalid stationEta=" << eta << " for stationName=" << stationNameString(station) << " stationIndex=" << station
750 << " stationEtaMin=" << stationEtaMin(id) << " stationEtaMax=" << stationEtaMax(id));
751 return false;
752 }
753
754 int phi = stationPhi(id);
755 if (phi < stationPhiMin(id) || phi > stationPhiMax(id)) {
756 ATH_MSG_DEBUG("Invalid stationPhi=" << phi << " for stationName=" << stationNameString(station) << " stationIndex=" << station
757 << " stationPhiMin=" << stationPhiMin(id) << " stationPhiMax=" << stationPhiMax(id));
758 return false;
759 }
760 return true;
761
762} // end sTgcIdHelper::validElement
763/*******************************************************************************/
764// Private validation of levels
767 ATH_MSG_DEBUG("Invalid stationName=" << stationNameString(stationName));
768 return false;
769 }
771 ATH_MSG_DEBUG("Invalid stationEta=" << stationEta << " for stationName=" << stationNameString(stationName)
772 << " stationIndex=" << stationName << " stationEtaMin=" << stationEtaMin(id)
773 << " stationEtaMax=" << stationEtaMax(id));
774 return false;
775 }
777 ATH_MSG_DEBUG("Invalid stationPhi=" << stationPhi << " for stationName=" << stationNameString(stationName)
778 << " stationIndex=" << stationName << " stationPhiMin=" << stationPhiMin(id)
779 << " stationPhiMax=" << stationPhiMax(id));
780 return false;
781 }
782 return true;
783} // end sTgcIdHelper::validElement
784/*******************************************************************************/
785// Check values down to readout channel level
787 int channelType, int channel) const {
788 if (!validElement(id, stationName, stationEta, stationPhi)) return false;
789
790 if ((multilayer < multilayerMin(id)) || (multilayer > multilayerMax(id))) {
791 ATH_MSG_DEBUG("Invalid multilayer=" << multilayer << " multilayerMin=" << multilayerMin(id)
792 << " multilayerMax=" << multilayerMax(id));
793 return false;
794 }
795
796 if (gasGap < gasGapMin(id) || gasGap > gasGapMax(id)) {
797 ATH_MSG_DEBUG("Invalid gasGap=" << gasGap << " gasGapMin=" << gasGapMin(id) << " gasGapMax=" << gasGapMax(id));
798 return false;
799 }
801 ATH_MSG_DEBUG("Invalid channelType=" << channelType << " channelTypeMin=" << channelTypeMin(id)
802 << " channelTypeMax=" << channelTypeMax(id));
803 return false;
804 }
805 if (channel < channelMin(id) || channel > channelMax(id)) {
806 ATH_MSG_DEBUG("Invalid channel=" << channel << " channelMin=" << channelMin(id) << " channelMax=" << channelMax(id));
807 return false;
808 }
809 if (channelType == Pad) {
810 int PadEta = padEta(id);
811 int PadPhi = padPhi(id);
812 if (PadEta < PadEtaMin || PadEta > PadEtaMax) {
813 ATH_MSG_DEBUG("Invalid padEta=" << PadEta << " padEtaMin=" << PadEtaMin << " padEtaMax=" << PadEtaMax);
814 return false;
815 }
816 if (PadPhi < PadPhiMin || PadPhi > PadPhiMax) {
817 ATH_MSG_DEBUG("Invalid padEPhi" << PadPhi << " padPhiMin=" << PadPhiMin << " padPhiMax=" << PadPhiMax);
818 return false;
819 }
820 }
821 return true;
822} // end sTgcIdHelper::validChannel
823/*******************************************************************************/
824// Check values down to readout channel level
826 int channelType, int padEta, int padPhi) const {
827 if (!validElement(id, stationName, stationEta, stationPhi)) return false;
828
829 if ((multilayer < multilayerMin(id)) || (multilayer > multilayerMax(id))) {
830 ATH_MSG_DEBUG("Invalid multilayer=" << multilayer << " multilayerMin=" << multilayerMin(id)
831 << " multilayerMax=" << multilayerMax(id));
832 return false;
833 }
834
835 if (gasGap < gasGapMin(id) || gasGap > gasGapMax(id)) {
836 ATH_MSG_DEBUG("Invalid gasGap=" << gasGap << " gasGapMin=" << gasGapMin(id) << " gasGapMax=" << gasGapMax(id));
837 return false;
838 }
839 if (channelType != Pad) {
840 ATH_MSG_DEBUG("Invalid channelType=" << channelType << " channelType must be " << Pad << " when specifying padEta and padPhi");
841 return false;
842 }
843 int channel = (padPhi - 1) * PadEtaMax + padEta;
844 if (channel < channelMin(id) || channel > channelMax(id)) {
845 ATH_MSG_DEBUG("Invalid channel=" << channel << " channelMin=" << channelMin(id) << " channelMax=" << channelMax(id)
846 << " for given padEta=" << padEta << " and padPhi=" << padPhi);
847 return false;
848 }
850 ATH_MSG_DEBUG("Invalid padEta=" << padEta << " padEtaMin=" << PadEtaMin << " padEtaMax=" << PadEtaMax);
851 return false;
852 }
854 ATH_MSG_DEBUG("Invalid padEPhi" << padPhi << " padPhiMin=" << PadPhiMin << " padPhiMax=" << PadPhiMax);
855 return false;
856 }
857 return true;
858} // end sTgcIdHelper::validChannel
859 /*******************************************************************************/
860 // Construct ID from components
862 // pack fields independently
863 Identifier result((Identifier::value_type)0);
869 return result;
870}
872 try {
875 return result;
876 } catch (const std::out_of_range&) { isValid = false; }
877 return Identifier{0};
878}
879
880/*******************************************************************************/
881Identifier sTgcIdHelper::elementID(const std::string& stationNameStr, int stationEta, int stationPhi, bool& isValid) const {
882 return elementID(stationNameIndex(stationNameStr), stationEta, stationPhi, isValid);
883}
884Identifier sTgcIdHelper::elementID(const std::string& stationNameStr, int stationEta, int stationPhi) const {
885 return elementID(stationNameIndex(stationNameStr), stationEta, stationPhi);
886}
887
888/*******************************************************************************/
890/*******************************************************************************/
892 int channel) const {
893 // pack fields independently
894 Identifier result((Identifier::value_type)0);
901 m_gap_impl.pack(gasGap, result);
904
905 return result;
906}
908 int channel, bool& isValid) const {
909 try {
912 return result;
913 } catch (const std::out_of_range&) { isValid = false; }
914 return Identifier{0};
915}
916/*******************************************************************************/
917Identifier sTgcIdHelper::channelID(const std::string& stationNameStr, int stationEta, int stationPhi, int multilayer, int gasGap,
918 int channelType, int channel) const {
920}
921Identifier sTgcIdHelper::channelID(const std::string& stationNameStr, int stationEta, int stationPhi, int multilayer, int gasGap,
922 int channelType, int channel, bool& isValid) const {
924}
925
926/*******************************************************************************/
936 try{
939 return result;
940 } catch (const std::out_of_range&) { isValid = false; }
941 return Identifier{0};
942}
943/*******************************************************************************/
945 int padPhi) const {
946 int channel = -1;
947 if (channelType == Pad) {
948 channel = (padPhi - 1) * PadEtaMax + padEta;
949 } else {
950 return Identifier{-1};
951 }
952 // pack fields independently
953 Identifier result((Identifier::value_type)0);
960 m_gap_impl.pack(gasGap, result);
962
964
965 return result;
966}
968 int padPhi, bool& isValid) const {
969 try {
971 isValid = (channelType) == Pad &&
973 return result;
974 } catch (const std::out_of_range&) { isValid = false; }
975 return Identifier{0};
976}
977/*******************************************************************************/
978Identifier sTgcIdHelper::padID(const std::string& stationNameStr, int stationEta, int stationPhi, int multilayer, int gasGap,
979 int channelType, int padEta, int padPhi) const {
981}
982
983Identifier sTgcIdHelper::padID(const std::string& stationNameStr, int stationEta, int stationPhi, int multilayer, int gasGap,
984 int channelType, int padEta, int padPhi, bool& isValid) const {
986}
987
988/*******************************************************************************/
1001 bool& isValid) const {
1002 try {
1004 isValid = (channelType == Pad) && valid(result);
1005 return result;
1006 } catch (const std::out_of_range&) { isValid = false; }
1007 return Identifier{0};
1008}
1009/*******************************************************************************/
1010// get parent id from strip or gang identifier
1012 assert(is_stgc(id));
1013 Identifier result(id);
1014 m_mplet_impl.reset(result);
1015 m_gap_impl.reset(result);
1016 m_typ_impl.reset(result);
1017 m_cha_impl.reset(result);
1018 return result;
1019}
1020/*******************************************************************************/
1021// Access to components of the ID
1022int sTgcIdHelper::multilayer(const Identifier& id) const { return m_mplet_impl.unpack(id); }
1023/*******************************************************************************/
1024// Access to components of the ID
1025int sTgcIdHelper::gasGap(const Identifier& id) const { return m_gap_impl.unpack(id); }
1026/*******************************************************************************/
1027int sTgcIdHelper::channelType(const Identifier& id) const { return m_typ_impl.unpack(id); }
1028/*******************************************************************************/
1030bool sTgcIdHelper::measuresPhi(const Identifier& id) const { return (channelType(id) == Strip) ? 0 : 1; }
1031/*******************************************************************************/
1032int sTgcIdHelper::channel(const Identifier& id) const { return m_cha_impl.unpack(id); }
1033/*******************************************************************************/
1034// Access to min and max of level ranges
1036/*******************************************************************************/
1038/*******************************************************************************/
1040/*******************************************************************************/
1042/*******************************************************************************/
1044/*******************************************************************************/
1046/*******************************************************************************/
1048/*******************************************************************************/
1050/*******************************************************************************/
1052/*******************************************************************************/
1054/*******************************************************************************/
1056/*******************************************************************************/
1058/*******************************************************************************/
1060/*******************************************************************************/
1062/*******************************************************************************/
1064/*******************************************************************************/
1066/*******************************************************************************/
1069 int stgcField = technologyIndex("STGC");
1070 if (m_dict) { stgcField = stgc_field_value(); }
1071 return stgcField;
1072}
1073/*******************************************************************************/
1075/*******************************************************************************/
1077
1078/*******************************************************************************/
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
int muon_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
int stgc_field_value() const
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
IdDictFieldImplementation m_sta_impl
MultiRange m_full_module_range
bool is_stgc(const Identifier &id) const
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
IdContext technology_context() const
access to IdContext's which define which levels or fields are contained in the Muon id
int stationPhi(const Identifier &id) const
size_type m_DETECTORELEMENT_INDEX
int stationName(const Identifier &id) const
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.
static int padPhiMax()
int padPhi(const Identifier &id) const
static int padEtaMax()
static constexpr unsigned int s_etaDim
-3, -2, -1, 1, 2, 3
std::array< unsigned int, s_modHashDim > m_module_hashes
IdDictFieldImplementation m_cha_impl
void idChannels(const Identifier &id, std::vector< Identifier > &vect) const
int multilayer(const Identifier &id) const
bool valid(const Identifier &id) const
virtual int get_detectorElement_hash(const Identifier &id, IdentifierHash &hash_id) const override
static int channelMin()
static int gasGapMin()
static constexpr unsigned int s_mlDim
2 multilayer
bool SmallSector(int stationName) const
unsigned int m_stationShift
Minimal station index found.
static int stationPhiMax()
static int padPhiMin()
IdDictFieldImplementation m_gap_impl
int stgcTechnology() const
Utility methods.
virtual int get_module_hash(const Identifier &id, IdentifierHash &hash_id) const override
Identifier hvID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, bool isInnerQ1) const
int channelType(const Identifier &id) const
static int channelMax()
unsigned int detEleHashIdx(const Identifier &id) const
Identifier elementID(int stationName, int stationEta, int stationPhi) const
int padEta(const Identifier &id) const
int init_id_to_hashes()
Identifier parentID(const Identifier &id) const
static int multilayerMax()
static int gasGapMax()
size_type m_CHANNELTYPE_INDEX
Identifier febID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType) const
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
static int padEtaMin()
static int stationPhiMin()
int channel(const Identifier &id) const override
static int stationEtaMin()
static int multilayerMin()
bool measuresPhi(const Identifier &id) const override
returns measuresPhi
Identifier padID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int padEta, int padPhi) const
bool validChannel(const Identifier &id, int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int channel) const
IdDictFieldImplementation m_mplet_impl
static int stationEtaMax()
bool LargeSector(int stationName) const
int gasGap(const Identifier &id) const override
get the hashes
static constexpr unsigned int s_phiDim
8 phi station
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int channel) const
unsigned int moduleHashIdx(const Identifier &id) const
bool validElement(const Identifier &id) const
Identifier multilayerID(const Identifier &channeldID) const
static int channelTypeMax()
int numberOfMultilayers(const Identifier &id) const
IdDictFieldImplementation m_typ_impl
std::array< unsigned int, s_detHashDim > m_detectorElement_hashes
size_type m_GASGAP_INDEX
bool isStNameInTech(const std::string &stationName) const override
The valid element checks converted the identifier to a stationName string in order to assess whether ...
static int channelTypeMin()
struct color C
Definition index.py:1