ATLAS Offline Software
Loading...
Searching...
No Matches
HGTD_ID.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
8#include "IdDict/IdDictMgr.h"
12#include <set>
13#include <algorithm>
14#include <iostream>
15
16// Constructor
33
34// Destructor
37
38void
40 int layer,
41 int phi_module,
42 int eta_module ) const
43{
44
45 // Check that id is within allowed range
46
47 // Fill expanded id
51 if (!m_full_wafer_range.match(id)) { // module range check is sufficient
52 ATH_MSG_ERROR(" HGTD_ID::wafer_id result is NOT ok. ID, range "
53 << (std::string)id << " " << (std::string)m_full_wafer_range);
54 }
55}
56
57void
59 int layer,
60 int phi_module,
61 int eta_module,
62 int phi_index,
63 int eta_index) const
64{
65
66 // Check that id is within allowed range
67
68 // Fill expanded id
72
73 if (!m_full_pixel_range.match(id)) {
74 ATH_MSG_ERROR(" HGTD_ID::pixel_id result is NOT ok. ID, range "
75 << (std::string)id << " " << (std::string)m_full_pixel_range);
76 }
77}
78
79int
81{
82 // get max from dictionary
84 IdContext wafer_context1 = wafer_context();
85 get_expanded_id(id, expId, &wafer_context1);
86 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
87 const Range& range = m_full_wafer_range[i];
88 if (range.match(expId)) {
89 const Range::field& layer_field = range[m_LAYER_INDEX];
90 if (not layer_field.empty()) {
91 return (layer_field.get_maximum());
92 }
93 }
94 }
95 return (-999); // default
96}
97
98int
100{
101 // get max from dictionary
102 ExpandedIdentifier expId;
103 IdContext wafer_context1 = wafer_context();
104 get_expanded_id(id, expId, &wafer_context1);
105 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
106 const Range& range = m_full_wafer_range[i];
107 if (range.match(expId)) {
108 const Range::field& phi_module_field = range[m_PHI_MODULE_INDEX];
109 if (not phi_module_field.empty()) {
110 return (phi_module_field.get_maximum());
111 }
112 }
113 }
114 return (-999); // default
115}
116
117int
119{
120 // get max from dictionary
121 ExpandedIdentifier expId;
122 IdContext wafer_context1 = wafer_context();
123 get_expanded_id(id, expId, &wafer_context1);
124 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
125 const Range& range = m_full_wafer_range[i];
126 if (range.match(expId)) {
127 const Range::field& eta_module_field = range[m_ETA_MODULE_INDEX];
128 if (not eta_module_field.empty()) {
129 return (eta_module_field.get_maximum());
130 }
131 }
132 }
133 return (-999); // default
134}
135
136int
138{
139 // get min from dictionary
140 ExpandedIdentifier expId;
141 IdContext wafer_context1 = wafer_context();
142 get_expanded_id(id, expId, &wafer_context1);
143 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
144 const Range& range = m_full_wafer_range[i];
145 if (range.match(expId)) {
146 const Range::field& eta_module_field = range[m_ETA_MODULE_INDEX];
147 if (not eta_module_field.empty()) {
148 return (eta_module_field.get_minimum());
149 }
150 }
151 }
152 return (-999); // default
153}
154
155int
157{
158 // get max from dictionary
159 ExpandedIdentifier expId;
160 IdContext wafer_context1 = wafer_context();
161 get_expanded_id(id, expId, &wafer_context1);
162 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
163 const Range& range = m_full_wafer_range[i];
164 if (range.match(expId)) {
165 const Range::field& phi_field = range[m_PHI_INDEX_INDEX];
166 if (not phi_field.empty()) {
167 return (phi_field.get_maximum());
168 }
169 }
170 }
171 return (-999); // default
172}
173
174int
176{
177 // get max from dictionary
178 ExpandedIdentifier expId;
179 IdContext wafer_context1 = wafer_context();
180 get_expanded_id(id, expId, &wafer_context1);
181 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
182 const Range& range = m_full_wafer_range[i];
183 if (range.match(expId)) {
184 const Range::field& eta_field = range[m_ETA_INDEX_INDEX];
185 if (not eta_field.empty()) {
186 return (eta_field.get_maximum());
187 }
188 }
189 }
190 return (-999); // default
191}
192
193bool
195{
196 return (phi_module(id) == phi_module_max(id));
197}
198
199int
201{
202
203 ATH_MSG_INFO("Initialize from dictionary");
204
205 // Check whether this helper should be reinitialized
206 if (!reinitialize(dict_mgr)) {
207 ATH_MSG_INFO("Request to reinitialize not satisfied - tags have not changed");
208 return (0);
209 }
210 else {
211 ATH_MSG_DEBUG("(Re)initialize");
212 }
213
214 // init base object
215 if(AtlasDetectorID::initialize_from_dictionary(dict_mgr)) return (1);
216
217 // Register version of InnerDetector dictionary
218 if (register_dict_tag(dict_mgr, "InnerDetector")) return(1);
219
220 m_dict = dict_mgr.find_dictionary ("InnerDetector");
221 if(!m_dict) {
222 ATH_MSG_FATAL(" HGTD_ID::initialize_from_dict - cannot access InnerDetector dictionary ");
223 return (1);
224 }
225
226 AtlasDetectorID::setDictVersion(dict_mgr, "InnerDetector");
227
228 // Initialize the field indices
229 if(initLevelsFromDict()) return (1);
230
231 //
232 // Build multirange for the valid set of identifiers
233 //
234
235 // Find value for the field InnerDetector
236 const IdDictDictionary* atlasDict = dict_mgr.find_dictionary ("ATLAS");
237 int inDetField = -1;
238 if (atlasDict->get_label_value("subdet", "InnerDetector", inDetField)) {
239 ATH_MSG_FATAL("Could not get value for label 'InnerDetector' of field 'subdet' in dictionary "
240 << atlasDict->name());
241 return (1);
242 }
243
244 // Find value for the field HGTD
245 int hgtdField = -1;
246 if (m_dict->get_label_value("part", "HGTD", hgtdField)) {
247 ATH_MSG_FATAL("Could not get value for label 'HGTD' of field 'part' in dictionary "
248 << m_dict->name());
249 return (1);
250 }
251 ATH_MSG_DEBUG(" HGTD_ID::initialize_from_dict "
252 << "Found field values: InDet/HGTD "
253 << inDetField << "/"
254 << hgtdField);
255
256 // Set up id for region and range prefix
257 ExpandedIdentifier region_id;
258 region_id.add(inDetField);
259 region_id.add(hgtdField);
260 Range prefix;
261 m_full_wafer_range = m_dict->build_multirange(region_id, prefix, m_moduleInRow);
262 m_full_pixel_range = m_dict->build_multirange(region_id, prefix);
263
264 // Setup the hash tables
265 if(init_hashes()) return (1);
266
267 // Setup hash tables for finding neighbors
268 if(init_neighbors()) return (1);
269
270 ATH_MSG_DEBUG("HGTD_ID::initialize_from_dict");
271 ATH_MSG_DEBUG("Wafer range -> " << (std::string)m_full_wafer_range);
272 ATH_MSG_DEBUG("Pixel range -> " << (std::string)m_full_pixel_range);
273 return 0;
274}
275
276int
278{
279
280 //
281 // create a vector(s) to retrieve the hashes for compact ids. For
282 // the moment, we implement a hash for wafers but NOT for pixels
283 // (too many)
284 //
285
286 // wafer hash
287 m_wafer_hash_max = m_full_wafer_range.cardinality();
288 m_wafer_vec.clear();
290 unsigned int nids = 0;
291 std::set<Identifier> ids;
292 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
293 const Range& range = m_full_wafer_range[i];
294 ConstRangeIterator rit(range);
295 auto first = rit.begin();
296 auto last = rit.end();
297 for (; first != last; ++first) {
298 const ExpandedIdentifier& exp_id = (*first);
299 Identifier id = wafer_id (exp_id[m_ENDCAP_INDEX],
300 exp_id[m_LAYER_INDEX],
301 exp_id[m_PHI_MODULE_INDEX],
302 exp_id[m_ETA_MODULE_INDEX]);
303 if(!(ids.insert(id)).second) {
304 ATH_MSG_FATAL(" HGTD_ID::init_hashes "
305 << " Error: duplicated id for wafer id. nid " << nids
306 << " id " << show_to_string(id)
307 << " exp id " << (std::string)exp_id
308 << " " << (std::string)m_full_wafer_range);
309 }
310 nids++;
311 }
312 }
313 if(ids.size() != m_wafer_hash_max) {
314 ATH_MSG_FATAL(" HGTD_ID::init_hashes "
315 << " Error: set size NOT EQUAL to hash max. size " << ids.size()
316 << " hash max " << m_wafer_hash_max);
317 return (1);
318 }
319
320 nids = 0;
321 std::set<Identifier>::const_iterator first = ids.begin();
322 std::set<Identifier>::const_iterator last = ids.end();
323 for (; first != last && nids < m_wafer_vec.size(); ++first) {
324 m_wafer_vec[nids] = (*first);
325 nids++;
326 }
327
328 // pixel hash - we do not keep a vec for the pixels - too large
329 // TODO: is it worthwhile/possible though for HGTD?
330 m_pixel_hash_max = m_full_pixel_range.cardinality();
331
332 return 0;
333
334}
335
336int
338{
339 unsigned short index = id;
340 if (index < m_prev_phi_wafer_vec.size()) {
341 if (m_prev_phi_wafer_vec[index] == NOT_VALID_HASH) return (1);
343 return (0);
344 }
345 return (1);
346}
347
348int
350{
351 unsigned short index = id;
352 if (index < m_next_phi_wafer_vec.size()) {
353 if (m_next_phi_wafer_vec[index] == NOT_VALID_HASH) return (1);
355 return (0);
356 }
357 return (1);
358}
359
360int
362{
363 unsigned short index = id;
364 if (index < m_prev_eta_wafer_vec.size()) {
365 if (m_prev_eta_wafer_vec[index] == NOT_VALID_HASH) return (1);
367 return (0);
368 }
369 return (1);
370}
371
372int
374{
375 unsigned short index = id;
376 if (index < m_next_eta_wafer_vec.size()) {
377 if (m_next_eta_wafer_vec[index] == NOT_VALID_HASH) return (1);
379 return (0);
380 }
381 return (1);
382}
383
384int
386{
387 //
388 // create a vector(s) to retrieve the hashes for compact ids for
389 // wafer neighbors.
390 //
391
392 ATH_MSG_DEBUG("HGTD_ID::init_neighbors");
393
394 m_prev_phi_wafer_vec.clear();
395 m_next_phi_wafer_vec.clear();
396 m_prev_eta_wafer_vec.clear();
397 m_next_eta_wafer_vec.clear();
402
403 for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) {
404 const Range& range = m_full_wafer_range[i];
405 const Range::field& phi_field = range[m_PHI_MODULE_INDEX];
406 const Range::field& eta_field = range[m_ETA_MODULE_INDEX];
407 ConstRangeIterator rit(range);
408 auto first = rit.begin();
409 auto last = rit.end();
410 for (; first != last; ++first) {
411 const ExpandedIdentifier& exp_id = (*first);
416 bool pphi = phi_field.get_previous(exp_id[m_PHI_MODULE_INDEX], previous_phi);
417 bool nphi = phi_field.get_next (exp_id[m_PHI_MODULE_INDEX], next_phi);
418 bool peta = eta_field.get_previous(exp_id[m_ETA_MODULE_INDEX], previous_eta);
419 bool neta = eta_field.get_next (exp_id[m_ETA_MODULE_INDEX], next_eta);
420
421 IdContext wcontext = wafer_context();
422
423 // First get primary hash id
424 IdentifierHash hash_id;
425 Identifier id = wafer_id (exp_id[m_ENDCAP_INDEX],
426 exp_id[m_LAYER_INDEX],
427 exp_id[m_PHI_MODULE_INDEX],
428 exp_id[m_ETA_MODULE_INDEX]);
429 if (get_hash(id, hash_id, &wcontext)) {
430 ATH_MSG_FATAL(" HGTD_ID::init_neighbors - unable to get hash, exp/compact "
431 << id.getString() << " " << show_to_string(id));
432 return (1);
433 }
434
435 // index for the subsequent arrays
436 unsigned short index = hash_id;
437 assert (hash_id < m_prev_phi_wafer_vec.size());
438 assert (hash_id < m_next_phi_wafer_vec.size());
439 assert (hash_id < m_prev_eta_wafer_vec.size());
440 assert (hash_id < m_next_eta_wafer_vec.size());
441
442 if (pphi) {
443 // Get previous phi hash id
444 ExpandedIdentifier expId = exp_id;
445 expId[m_PHI_MODULE_INDEX] = previous_phi;
447 expId[m_LAYER_INDEX],
448 expId[m_PHI_MODULE_INDEX],
449 expId[m_ETA_MODULE_INDEX]);
450 if (get_hash(id, hash_id, &wcontext)) {
451 ATH_MSG_FATAL(" HGTD_ID::init_neighbors - unable to get previous phi hash, exp/compact "
452 << id.getString() << " " << show_to_string(id));
453 return (1);
454 }
455 m_prev_phi_wafer_vec[index] = hash_id;
456 }
457
458 if (nphi) {
459 // Get next phi hash id
460 ExpandedIdentifier expId = exp_id;
461 expId[m_PHI_MODULE_INDEX] = next_phi;
463 expId[m_LAYER_INDEX],
464 expId[m_PHI_MODULE_INDEX],
465 expId[m_ETA_MODULE_INDEX]);
466 if (get_hash(id, hash_id, &wcontext)) {
467 ATH_MSG_FATAL(" HGTD_ID::init_neighbors - unable to get next phi hash, exp/compact " <<
468 id.getString() << " " << show_to_string(id));
469 return (1);
470 }
471 m_next_phi_wafer_vec[index] = hash_id;
472 }
473
474 if (peta) {
475 // Get previous eta hash id
476 ExpandedIdentifier expId = exp_id;
477 expId[m_ETA_MODULE_INDEX] = previous_eta;
479 expId[m_LAYER_INDEX],
480 expId[m_PHI_MODULE_INDEX],
481 expId[m_ETA_MODULE_INDEX]);
482 if (get_hash(id, hash_id, &wcontext)) {
483 ATH_MSG_FATAL(" HGTD_ID::init_neighbors - unable to get previous eta hash, exp/compact "
484 << id.getString() << " " << show_to_string(id));
485 return (1);
486 }
487 m_prev_eta_wafer_vec[index] = hash_id;
488 }
489
490 if (neta) {
491 // Get next eta hash id
492 ExpandedIdentifier expId = exp_id;
493 expId[m_ETA_MODULE_INDEX] = next_eta;
495 expId[m_LAYER_INDEX],
496 expId[m_PHI_MODULE_INDEX],
497 expId[m_ETA_MODULE_INDEX]);
498 if (get_hash(id, hash_id, &wcontext)) {
499 ATH_MSG_FATAL(" HGTD_ID::init_neighbors - unable to get next eta hash, exp/compact "
500 << id.getString() << " " << show_to_string(id));
501 return (1);
502 }
503 m_next_eta_wafer_vec[index] = hash_id;
504 }
505 }
506 }
507 return (0);
508}
509
510
511void HGTD_ID::set_useNewIdentifierScheme(bool switchIntoNewIdentifier)
512{
513 m_useNewIdentifierScheme = switchIntoNewIdentifier;
514}
515
520
521int
523{
524
525 if(!m_dict) {
526 ATH_MSG_FATAL(" HGTD_ID::initLevelsFromDict - dictionary NOT initialized ");
527 return (1);
528 }
529
530 // Find out which identifier field corresponds to each level. Use
531 // names to find each field/level.
532
533 m_INDET_INDEX = 999;
534 m_HGTD_INDEX = 999;
535 m_ENDCAP_INDEX = 999;
536 m_LAYER_INDEX = 999;
537 m_PHI_MODULE_INDEX = 999;
538 m_ETA_MODULE_INDEX = 999;
539 m_PHI_INDEX_INDEX = 999;
540 m_ETA_INDEX_INDEX = 999;
541
542 // Save index to a PIXEL region for unpacking
545 if (m_dict->find_region(id, m_hgtd_region_index)) {
546 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find hgtd region index: id, reg "
547 << (std::string)id << " " << m_hgtd_region_index);
548 return (1);
549 }
550 // Choose the name of the identification scheme based on the dictionary name,
551 // this information is gotten from HGTD_IDDetDescrCnv
552
554 m_endcap_ID = "endcap";
555 m_layer_ID = "layer";
556 m_moduleInLayer_Or_Row = "moduleInLayer";
557 m_moduleInRow = "dummyVariable";
558 m_padInModuleRow = "padInModuleRow";
559 m_padInModuleColumn = "padInModuleColumn";
560 }
561 // Get levels
562 const IdDictField* field = m_dict->find_field("subdet");
563 if (field) {
564 m_INDET_INDEX = field->index();
565 }
566 else {
567 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'subdet' field ");
568 return (1);
569 }
570
571 field = m_dict->find_field("part");
572 if (field) {
573 m_HGTD_INDEX = field->index();
574 }
575 else {
576 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'part' field ");
577 return (1);
578 }
579
580 field = m_dict->find_field(m_endcap_ID);
581 if (field) {
582 m_ENDCAP_INDEX = field->index();
583 }
584 else {
585 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'endcap' field " );
586 }
587 field = m_dict->find_field(m_layer_ID);
588 if (field) {
589 m_LAYER_INDEX = field->index();
590 }
591 else {
592 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'layer' field " );
593 }
594 field = m_dict->find_field(m_moduleInLayer_Or_Row);
595 if (field) {
596 m_PHI_MODULE_INDEX = field->index();
597 }
598 else {
599 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'moduleInLayer' field " );
600 return (1);
601 }
602 field = m_dict->find_field(m_moduleInRow);
603 if (field) {
604 m_ETA_MODULE_INDEX = field->index();
605 }
606 else {
607 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'hgtd_eta_module' field " );
608 return (1);
609 }
610 field = m_dict->find_field(m_padInModuleRow);
611 if (field) {
612 m_PHI_INDEX_INDEX = field->index();
613 }
614 else {
615 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'hgtd_phi_index' field " );
616 return (1);
617 }
618 field = m_dict->find_field(m_padInModuleColumn);
619 if (field) {
620 m_ETA_INDEX_INDEX = field->index();
621 }
622 else {
623 ATH_MSG_FATAL("HGTD_ID::initLevelsFromDict - unable to find 'hgtd_eta_index' field " );
624 return (1);
625 }
626 // Set the field implementations
627
628 const IdDictRegion& region = m_dict->region(m_hgtd_region_index);
629
638
639 ATH_MSG_DEBUG("decode index and bit fields for each level: ");
640 ATH_MSG_DEBUG("indet " << m_indet_impl.show_to_string());
641 ATH_MSG_DEBUG("hgtd " << m_hgtd_impl.show_to_string());
642 ATH_MSG_DEBUG("ec " << m_ec_impl.show_to_string());
643 ATH_MSG_DEBUG("layer " << m_layer_impl.show_to_string());
644 ATH_MSG_DEBUG("phi_mod " << m_phi_mod_impl.show_to_string());
645 ATH_MSG_DEBUG("eta_mod " << m_eta_mod_impl.show_to_string());
646 ATH_MSG_DEBUG("phi_index " << m_phi_index_impl.show_to_string());
647 ATH_MSG_DEBUG("eta_index " << m_eta_index_impl.show_to_string());
648
649 std::cout << "indet " << m_indet_impl.decode_index() << " "
650 << (std::string)m_indet_impl.ored_field() << " "
651 << std::hex << m_indet_impl.mask() << " "
652 << m_indet_impl.zeroing_mask() << " "
653 << std::dec << m_indet_impl.shift()
654 << " " << m_indet_impl.bits() << " " << m_indet_impl.bits_offset() << " ";
655 m_indet_impl.ored_field().show();
656 std::cout << "hgtd " << m_hgtd_impl.decode_index() << " "
657 << (std::string)m_hgtd_impl.ored_field() << " "
658 << std::hex << m_hgtd_impl.mask() << " "
659 << m_hgtd_impl.zeroing_mask() << " "
660 << std::dec << m_hgtd_impl.shift()
661 << " " << m_hgtd_impl.bits() << " " << m_hgtd_impl.bits_offset() << " ";
662 m_hgtd_impl.ored_field().show();
663 std::cout << "ec " << m_ec_impl.decode_index() << " "
664 << (std::string)m_ec_impl.ored_field() << " "
665 << std::hex << m_ec_impl.mask() << " "
666 << m_ec_impl.zeroing_mask() << " "
667 << std::dec << m_ec_impl.shift()
668 << " " << m_ec_impl.bits() << " " << m_ec_impl.bits_offset() << " ";
669 m_ec_impl.ored_field().show();
670 std::cout << "layer " << m_layer_impl.decode_index() << " "
671 << (std::string)m_layer_impl.ored_field() << " "
672 << std::hex << m_layer_impl.mask() << " "
673 << m_layer_impl.zeroing_mask() << " "
674 << std::dec << m_layer_impl.shift()
675 << " " << m_layer_impl.bits() << " " << m_layer_impl.bits_offset() << " ";
676 m_layer_impl.ored_field().show();
677 std::cout << "phi_mod " << m_phi_mod_impl.decode_index() << " "
678 << (std::string)m_phi_mod_impl.ored_field() << " "
679 << std::hex << m_phi_mod_impl.mask() << " "
680 << m_phi_mod_impl.zeroing_mask() << " "
681 << std::dec << m_phi_mod_impl.shift()
682 << " " << m_phi_mod_impl.bits() << " " << m_phi_mod_impl.bits_offset() << " ";
683 m_phi_mod_impl.ored_field().show();
684 std::cout << "eta_mod " << m_eta_mod_impl.decode_index() << " "
685 << (std::string)m_eta_mod_impl.ored_field() << " "
686 << std::hex << m_eta_mod_impl.mask() << " "
687 << m_eta_mod_impl.zeroing_mask() << " "
688 << std::dec << m_eta_mod_impl.shift()
689 << " " << m_eta_mod_impl.bits() << " " << m_eta_mod_impl.bits_offset() << " ";
690 m_eta_mod_impl.ored_field().show();
691 std::cout << "phi_index " << m_phi_index_impl.decode_index() << " "
692 << (std::string)m_phi_index_impl.ored_field() << " "
693 << std::hex << m_phi_index_impl.mask() << " "
694 << m_phi_index_impl.zeroing_mask() << " "
695 << std::dec << m_phi_index_impl.shift()
696 << " " << m_phi_index_impl.bits() << " " << m_phi_index_impl.bits_offset() << " ";
697 m_phi_index_impl.ored_field().show();
698 std::cout << "eta_index " << m_eta_index_impl.decode_index() << " "
699 << (std::string)m_eta_index_impl.ored_field() << " "
700 << std::hex << m_eta_index_impl.mask() << " "
701 << m_eta_index_impl.zeroing_mask() << " "
702 << std::dec << m_eta_index_impl.shift()
703 << " " << m_eta_index_impl.bits() << " " << m_eta_index_impl.bits_offset() << " ";
704 m_eta_index_impl.ored_field().show();
705
706
707 std::cout << "HGTD_ID::initLevelsFromDict - found levels " << std::endl;
708 std::cout << "subdet " << m_INDET_INDEX << std::endl;
709 std::cout << "part " << m_HGTD_INDEX << std::endl;
710 std::cout << "endcap " << m_ENDCAP_INDEX << std::endl;
711 std::cout << "layer " << m_LAYER_INDEX << std::endl;
712 std::cout << "phi_module " << m_PHI_MODULE_INDEX << std::endl;
713 std::cout << "eta_module " << m_ETA_MODULE_INDEX << std::endl;
714 std::cout << "phi_index " << m_PHI_INDEX_INDEX << std::endl;
715 std::cout << "eta_index " << m_ETA_INDEX_INDEX << std::endl;
716
717 return 0;
718}
719
722{
723 return m_wafer_hash_max;
724}
725
728{
729 return m_pixel_hash_max;
730}
731
733{
734 return (m_wafer_vec.begin());
735}
736
738{
739 return (m_wafer_vec.end());
740}
741
743{
744 return (m_full_pixel_range.factory_begin());
745}
746
748{
749 return (m_full_pixel_range.factory_end());
750}
751
752void
754 ExpandedIdentifier& exp_id,
755 const IdContext* context) const
756{
757 exp_id.clear();
758 exp_id << indet_field_value()
760 << endcap(id)
761 << layer(id)
762 << phi_module(id)
763 << eta_module(id);
764 if(!context || context->end_index() == m_ETA_INDEX_INDEX) {
765 exp_id << phi_index(id)
766 << eta_index(id);
767 }
768}
769
770// From hash get Identifier
771int
773 Identifier& id,
774 const IdContext* context) const
775{
776 int result = 1;
777
778 size_t begin = (context) ? context->begin_index(): 0;
779 // cannot get hash if end is 0:
780 size_t end = (context) ? context->end_index() : 0;
781 if (0 == begin) {
782 // No hashes yet for ids with prefixes
783 if (m_ETA_MODULE_INDEX == end) {
784 if (hash_id < (unsigned int)(m_wafer_vec.end() - m_wafer_vec.begin())) {
785 id = m_wafer_vec[hash_id];
786 result = 0;
787 }
788 }
789 else if (m_ETA_INDEX_INDEX == end) {
790 // Do not know how to calculate pixel id from hash yet!!
791 std::cout << "Do not know how to calculate pixel id from hash yet!!" << std::endl;
792 }
793 }
794
795 return (result);
796}
797
798int
800 IdentifierHash& hash_id,
801 const IdContext* context) const
802{
803
804 // Get the hash code from either a vec (for wafers) or calculate
805 // it (pixels). For the former, we convert to compact and call
806 // get_hash again. For the latter, we calculate the hash from the
807 // Identifier.
808
809 int result = 1;
810
811 hash_id = 0;
812 size_t begin = (context) ? context->begin_index(): 0;
813 size_t end = (context) ? context->end_index() : 0;
814 if (0 == begin) {
815 // No hashes yet for ids with prefixes
816 if (m_ETA_MODULE_INDEX == end) {
817 hash_id = wafer_hash(id);
818 if (hash_id.is_valid()) result = 0;
819 }
820 else if (context && context->end_index() == m_ETA_INDEX_INDEX) {
821 // Must calculate for pixel hash
822 ExpandedIdentifier new_id;
823 get_expanded_id(id, new_id, context);
824 hash_id = m_full_pixel_range.cardinalityUpTo(new_id);
825 result = 0;
826 }
827 }
828
829 return (result);
830}
831
832void
834{
835 if (m_dict) {
836
837 int nids = 0;
838 IdContext context = wafer_context();
839 const_id_iterator first = m_wafer_vec.begin();
840 const_id_iterator last = m_wafer_vec.end();
841 for (; first != last; ++first, ++nids) {
842 Identifier id = (*first);
843 ExpandedIdentifier expId;
844 get_expanded_id(id, expId, &context);
845 Identifier new_id = wafer_id (expId[m_ENDCAP_INDEX],
846 expId[m_LAYER_INDEX],
847 expId[m_PHI_MODULE_INDEX],
848 expId[m_ETA_MODULE_INDEX]);
849 if (id != new_id) {
850 ATH_MSG_ERROR("HGTD_ID::test_wafer_packing: new and old compact id not equal. New/old/expanded ids "
851 << show_to_string(new_id) << " " << show_to_string(id) << " "
852 << (std::string)expId);
853 continue;
854 }
855 }
856
857 nids = 0;
858 context = pixel_context();
861 for (; first_pixel != last_pixel && nids < 1000; ++first_pixel, ++nids) {
862 const ExpandedIdentifier& exp_id = *first_pixel;
863 ExpandedIdentifier new_exp_id;
864
865 Identifier id = wafer_id (exp_id[m_ENDCAP_INDEX],
866 exp_id[m_LAYER_INDEX],
867 exp_id[m_PHI_MODULE_INDEX],
868 exp_id[m_ETA_MODULE_INDEX]);
869
870 get_expanded_id(id, new_exp_id, &context);
871 if (exp_id[0] != new_exp_id[0] ||
872 exp_id[1] != new_exp_id[1] ||
873 exp_id[2] != new_exp_id[2] ||
874 exp_id[3] != new_exp_id[3] ||
875 exp_id[4] != new_exp_id[4] ||
876 exp_id[5] != new_exp_id[5]) {
877 ATH_MSG_ERROR("HGTD_ID::test_wafer_packing: new and old expanded ids not equal. New/old/compact ids "
878 << (std::string)new_exp_id
879 << " " << (std::string)exp_id
880 << " " << show_to_string(id));
881 }
882
883 Identifier pid = pixel_id (exp_id[m_ENDCAP_INDEX],
884 exp_id[m_LAYER_INDEX],
885 exp_id[m_PHI_MODULE_INDEX],
886 exp_id[m_ETA_MODULE_INDEX],
887 exp_id[m_PHI_INDEX_INDEX],
888 exp_id[m_ETA_INDEX_INDEX]);
889 Identifier pid1 = pixel_id (endcap(pid),
890 layer(pid),
891 phi_module(pid),
892 eta_module(pid),
893 phi_index(pid),
894 eta_index(pid));
895 if (pid != pid1) {
896 ATH_MSG_ERROR("HGTD_ID::test_wafer_packing: new and old pixel ids not equal. New/old ids "
897 << " " << show_to_string(pid1) << " "
898 << show_to_string(pid));
899 }
900 }
901
902 ATH_MSG_DEBUG("HGTD_ID::test_wafer_packing: Successful tested "
903 << nids << " ids. ");
904 }
905 else {
906 ATH_MSG_ERROR("HGTD_ID::test_wafer_packing: Unable to test wafer is packing - no dictionary has been defined. ");
907 }
908}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
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.
virtual void setDictVersion(const IdDictMgr &dict_mgr, const std::string &name) override
int register_dict_tag(const IdDictMgr &dict_mgr, const std::string &dict_name)
Register the file and tag names for a particular IdDict dictionary.
int hgtd_field_value() const
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
AtlasDetectorID(const std::string &name, const std::string &group)
int indet_field_value() const
Provide efficient access to individual field values, for subclass idhelpers.
ConstRangeIterator end() const
ConstRangeIterator begin() const
void clear()
Erase all fields.
size_type m_HGTD_INDEX
Definition HGTD_ID.h:245
hash_vec m_next_phi_wafer_vec
Definition HGTD_ID.h:262
int init_hashes()
Definition HGTD_ID.cxx:277
int get_next_in_phi(const IdentifierHash &id, IdentifierHash &next) const
Next wafer hash in phi (return == 0 for neighbor found)
Definition HGTD_ID.cxx:349
int eta_module(const Identifier &id) const
Definition HGTD_ID.h:489
int initLevelsFromDict()
Definition HGTD_ID.cxx:522
size_type m_ETA_MODULE_INDEX
Definition HGTD_ID.h:249
void pixel_id_checks(int endcap, int layer, int phi_module, int eta_module, int phi_index, int eta_index) const
Definition HGTD_ID.cxx:58
std::string m_padInModuleColumn
Definition HGTD_ID.h:213
size_type m_PHI_INDEX_INDEX
Definition HGTD_ID.h:250
IdDictFieldImplementation m_layer_impl
Definition HGTD_ID.h:269
@ NOT_VALID_HASH
Definition HGTD_ID.h:217
hash_vec m_prev_eta_wafer_vec
Definition HGTD_ID.h:263
int eta_index(const Identifier &id) const
Definition HGTD_ID.h:503
std::string m_layer_ID
Definition HGTD_ID.h:209
Identifier wafer_id(int endcap, int layer, int phi_module, int eta_module) const
For a single crystal.
Definition HGTD_ID.h:287
void wafer_id_checks(int endcap, int layer, int phi_module, int eta_module) const
Definition HGTD_ID.cxx:39
virtual int get_id(const IdentifierHash &hash_id, Identifier &id, const IdContext *context=0) const
Create compact id from hash id (return == 0 for OK)
Definition HGTD_ID.cxx:772
id_vec m_wafer_vec
Definition HGTD_ID.h:259
void set_useNewIdentifierScheme(bool switchIntoNewIdentifier)
Definition HGTD_ID.cxx:511
int get_next_in_eta(const IdentifierHash &id, IdentifierHash &next) const
Next wafer hash in eta (return == 0 for neighbor found)
Definition HGTD_ID.cxx:373
int phi_module_max(const Identifier &id) const
Definition HGTD_ID.cxx:99
size_type m_ENDCAP_INDEX
Definition HGTD_ID.h:246
Identifier pixel_id(int endcap, int layer, int phi_module, int eta_module, int phi_index, int eta_index) const
For an individual pixel.
Definition HGTD_ID.h:331
Identifier::size_type size_type
Definition HGTD_ID.h:52
size_type wafer_hash_max() const
Definition HGTD_ID.cxx:721
int get_prev_in_phi(const IdentifierHash &id, IdentifierHash &prev) const
Previous wafer hash in phi (return == 0 for neighbor found)
Definition HGTD_ID.cxx:337
int init_neighbors()
Definition HGTD_ID.cxx:385
MultiRange::const_identifier_factory const_expanded_id_iterator
Definition HGTD_ID.h:54
hash_vec m_next_eta_wafer_vec
Definition HGTD_ID.h:264
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
Definition HGTD_ID.h:404
int phi_index(const Identifier &id) const
Definition HGTD_ID.h:496
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr)
Initialization from the identifier dictionary.
Definition HGTD_ID.cxx:200
~HGTD_ID()
Definition HGTD_ID.cxx:35
MultiRange m_full_wafer_range
Definition HGTD_ID.h:254
size_type m_PHI_MODULE_INDEX
Definition HGTD_ID.h:248
IdContext pixel_context() const
Definition HGTD_ID.h:458
size_type m_LAYER_INDEX
Definition HGTD_ID.h:247
const_id_iterator wafer_end() const
Definition HGTD_ID.cxx:737
IdDictFieldImplementation m_phi_index_impl
Definition HGTD_ID.h:272
int eta_index_max(const Identifier &id) const
Definition HGTD_ID.cxx:175
IdContext wafer_context() const
Definition HGTD_ID.h:450
int phi_index_max(const Identifier &id) const
Definition HGTD_ID.cxx:156
size_type m_hgtd_region_index
Definition HGTD_ID.h:243
int eta_module_max(const Identifier &id) const
Definition HGTD_ID.cxx:118
const_id_iterator wafer_begin() const
Iterators over full set of ids. Wafer iterator is sorted.
Definition HGTD_ID.cxx:732
size_type m_ETA_INDEX_INDEX
Definition HGTD_ID.h:251
std::string m_moduleInLayer_Or_Row
Definition HGTD_ID.h:210
const IdDictDictionary * m_dict
Definition HGTD_ID.h:253
size_type pixel_hash_max() const
Definition HGTD_ID.cxx:727
int layer_max(const Identifier &id) const
Max/Min values for each field (error returns -999)
Definition HGTD_ID.cxx:80
int get_prev_in_eta(const IdentifierHash &id, IdentifierHash &prev) const
Previous wafer hash in eta (return == 0 for neighbor found)
Definition HGTD_ID.cxx:361
const_expanded_id_iterator pixel_end() const
Definition HGTD_ID.cxx:747
size_type m_INDET_INDEX
Definition HGTD_ID.h:244
int layer(const Identifier &id) const
Definition HGTD_ID.h:475
IdDictFieldImplementation m_phi_mod_impl
Definition HGTD_ID.h:270
void test_wafer_packing() const
Tests of packing.
Definition HGTD_ID.cxx:833
IdDictFieldImplementation m_eta_index_impl
Definition HGTD_ID.h:273
bool get_useNewIdentifierScheme() const
Definition HGTD_ID.cxx:516
int endcap(const Identifier &id) const
Values of different levels (failure returns 0)
Definition HGTD_ID.h:468
void get_expanded_id(const Identifier &id, ExpandedIdentifier &exp_id, const IdContext *context=0) const
Create expanded id from compact id (return == 0 for OK)
Definition HGTD_ID.cxx:753
size_type m_wafer_hash_max
Definition HGTD_ID.h:256
const_expanded_id_iterator pixel_begin() const
For pixel ids, only expanded id iterators are available.
Definition HGTD_ID.cxx:742
std::vector< Identifier >::const_iterator const_id_iterator
Definition HGTD_ID.h:53
IdDictFieldImplementation m_hgtd_impl
Definition HGTD_ID.h:267
MultiRange m_full_pixel_range
Definition HGTD_ID.h:255
IdDictFieldImplementation m_indet_impl
Definition HGTD_ID.h:266
bool m_useNewIdentifierScheme
Definition HGTD_ID.h:205
std::string m_padInModuleRow
Definition HGTD_ID.h:212
IdDictFieldImplementation m_ec_impl
Definition HGTD_ID.h:268
hash_vec m_prev_phi_wafer_vec
Definition HGTD_ID.h:261
std::string m_moduleInRow
Definition HGTD_ID.h:211
IdDictFieldImplementation m_eta_mod_impl
Definition HGTD_ID.h:271
int eta_module_min(const Identifier &id) const
Definition HGTD_ID.cxx:137
bool is_phi_module_max(const Identifier &id) const
To check for when phi wrap around may be needed.
Definition HGTD_ID.cxx:194
std::string m_endcap_ID
Definition HGTD_ID.h:208
size_type m_pixel_hash_max
Definition HGTD_ID.h:257
virtual int get_hash(const Identifier &id, IdentifierHash &hash_id, const IdContext *context=0) const
Create hash id from compact id (return == 0 for OK)
Definition HGTD_ID.cxx:799
HGTD_ID()
Definition HGTD_ID.cxx:17
int phi_module(const Identifier &id) const
Definition HGTD_ID.h:482
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
size_type begin_index() const
Definition IdContext.h:45
size_type end_index() const
Definition IdContext.h:46
int get_label_value(const std::string &field, const std::string &label, int &value) const
const std::string & name() const
Dictionary name.
const IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
const IdDictFieldImplementation & implementation(size_t i) const
bool get_previous(element_type current, element_type &previous) const
Returns false if previous/next is at end of range, or not possible.
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...
bool get_next(element_type current, element_type &next) const
element_type get_maximum() const
This is a "hash" representation of an Identifier.
bool is_valid() const
Check if id is in a valid state.
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition index.py:1