ATLAS Offline Software
Loading...
Searching...
No Matches
TileHWID.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5/***************************************************************************
6 Access to Tile Calorimeter raw data
7 -----------------------------------------
8 ***************************************************************************/
9
10
13#include "IdDict/IdDictField.h"
14#include "IdDict/IdDictMgr.h"
15#include "IdDict/IdDictRegion.h"
18
19#include <algorithm>
20#include <stdio.h>
21#include <assert.h>
22
23
24
26 : AtlasDetectorID("TileHWID", "tile")
28 , m_SYSTEM_INDEX(999)
29 , m_SECTION_INDEX(999)
30 , m_ROS_INDEX(999)
31 , m_DRAWER_INDEX(999)
32 , m_CHANNEL_INDEX(999)
33 , m_ADC_INDEX(999)
34 , m_dict(0)
39{
40}
41
45
46//
47// TileHWID methods
48//
49std::string
50TileHWID::to_string( const HWIdentifier & id, int level ) const
51{
52 IdContext context;
53 switch (level) {
54 case 1: case -4:
55 case 2: case -3: context = ros_context(); break;
56 case 3: case -2: context = drawer_context(); break;
57 case 4: case -1: context = channel_context(); break;
58 case 5: case 0: context = adc_context(); break;
59 default:
60 return "TileHWID::to_string - unknown context";
61 }
62
63 ExpandedIdentifier exp_id;
64 if ( get_expanded_id(id,exp_id,&context) ) {
65 return "TileHWID::to_string - can not expand ID";
66 } else {
67 return (std::string)(exp_id);
68 }
69}
70
71//
72// get methods
73//
74int
76{
77 int field = 0;
78 if(!m_dict->unpack(id, 0, index, m_tile_region_index, field)) {
79 return field;
80 } else {
81 return 0;
82 }
83}
84
85//
86// check methods
87//
88bool
90{
91 bool result = is_tile(id)
92 && ( section(id) == TileHWID::TILE_ONLINE );
93
94 return result;
95}
96
97bool
99{
100 bool result = is_tilehw(id)
101 && ( adc(id) == TileHWID::LOWGAIN );
102
103 return result;
104}
105
106bool
108{
109 bool result = is_tilehw(id)
110 && ( adc(id) == TileHWID::HIGHGAIN );
111
112 return result;
113}
114
115//
116// TileCal HW ID
117//
120{
121
122 HWIdentifier compactID(m_base_tile_ros);
123 return compactID;
124}
125
126//
127// Build ros & drawer id
128//
131{
132
133 HWIdentifier compactID(m_base_tile_ros);
134 m_ros_impl.pack (ros,compactID);
135
136#ifndef NDEBUG
137 if(m_do_checks) {
138
139 // Check that id is within allowed range
140
141 // Fill expanded id
143 expId << TileHWID::TILE_ONLINE << ros;
144
145 if (!m_full_ros_range.match(expId)) {
146 std::string errorMessage = "TileHWID::ros_id() result is not OK: ID, range = "
147 + std::string(expId) + " , " + (std::string)m_full_ros_range;
148 TileID_Exception except(errorMessage , 2);
149 throw except ;
150 }
151 }
152#endif
153
154 return (compactID);
155}
156
159{
160
161 HWIdentifier compactID(m_base_tile_ros);
162 m_ros_impl.pack (ros,compactID);
163 m_drawer_impl.pack (drawer,compactID);
164
165#ifndef NDEBUG
166 if(m_do_checks) {
167
168 // Check that id is within allowed range
169
170 // Fill expanded id
172 expId << TileHWID::TILE_ONLINE << ros << drawer;
173
174 if (!m_full_drawer_range.match(expId)) {
175 std::string errorMessage = "TileHWID::drawer_id() result is not OK: ID, range = "
176 + std::string(expId) + " , " + (std::string)m_full_ros_range;
177 TileID_Exception except(errorMessage , 1);
178 throw except ;
179 }
180 }
181#endif
182
183 return (compactID);
184}
185
188{
189 int ros = (frag >> 8) & 0xFF;
190 int drawer = frag & 0xFF;
191
192 return drawer_id (ros, drawer);
193}
194
195//
196// Build channel & adc id
197//
199TileHWID::channel_id ( int ros, int drawer, int channel ) const
200{
201
202 HWIdentifier compactID(m_base_tile_ros);
203 m_ros_impl.pack (ros,compactID);
204 m_drawer_impl.pack (drawer,compactID);
205 m_channel_impl.pack (channel,compactID);
206
207#ifndef NDEBUG
208 if(m_do_checks) {
209
210 // Check that id is within allowed range
211
212 // Fill expanded id
214 expId << TileHWID::TILE_ONLINE << ros << drawer << channel;
215
216 if (!m_full_channel_range.match(expId)) {
217 std::string errorMessage = "TileHWID::channel_id() result is not OK: ID, range = "
218 + std::string(expId) + " , " + (std::string)m_full_ros_range;
219 TileID_Exception except(errorMessage , 1);
220 throw except ;
221 }
222 }
223#endif
224
225 return (compactID);
226}
227
229TileHWID::adc_id ( int ros, int drawer, int channel, int adc ) const
230{
231
232 HWIdentifier compactID(m_base_tile_ros);
233 m_ros_impl.pack (ros,compactID);
234 m_drawer_impl.pack (drawer,compactID);
235 m_channel_impl.pack (channel,compactID);
236 m_adc_impl.pack (adc,compactID);
237
238#ifdef NDEBUG
239 if(m_do_checks) {
240
241 // Check that id is within allowed range
242
243 // Fill expanded id
245 expId << TileHWID::TILE_ONLINE << ros << drawer << channel << adc;
246
247 if (!m_full_adc_range.match(expId)) {
248 std::string errorMessage = "TileHWID::adc_id() result is not OK: ID, range = "
249 + std::string(expId) + " , " + (std::string)m_full_ros_range;
250 TileID_Exception except(errorMessage , 1);
251 throw except ;
252 }
253 }
254#endif
255
256 return (compactID);
257}
258
260TileHWID::drawer_id ( const HWIdentifier & any_id ) const
261{
262 HWIdentifier compactId(any_id);
263 m_channel_impl.reset(compactId);
264 m_adc_impl.reset(compactId);
265
266 return (compactId);
267}
268
270TileHWID::channel_id ( const HWIdentifier & any_id ) const
271{
272 HWIdentifier compactId(any_id);
273 m_adc_impl.reset(compactId);
274 return (compactId);
275}
276
279 int channel ) const
280{
281
282 HWIdentifier compactId(drawer_id);
283 m_channel_impl.pack(channel,compactId);
284
285#ifndef NDEBUG
286 if(m_do_checks) {
287
288 // Check that id is within allowed range
289
290 // Fill expanded id
291 ExpandedIdentifier expId;
292
293 IdContext context = drawer_context();
294 if (get_expanded_id(compactId, expId, &context)) {
295 std::string errorMessage = "TileHWID::channel_id(drawer_id,channel) result is not OK: ID = "
296 + compactId.getString() ;
297 TileID_Exception except(errorMessage , 1);
298 throw except ;
299
300 // region_id.show();
301 }
302
303 expId << channel;
304
305 if (!m_full_channel_range.match(expId)) {
306 std::string errorMessage = "TileHWID::channel_id() result is not OK: ID, range = "
307 + (std::string)expId + " , " + (std::string)m_full_ros_range;
308 TileID_Exception except(errorMessage , 1);
309 throw except ;
310 }
311 }
312#endif
313
314 return compactId;
315}
316
319 int adc ) const
320{
321
322 HWIdentifier compactId(channel_id);
323 m_adc_impl.pack(adc,compactId);
324
325#ifndef NDEBUG
326 if(m_do_checks) {
327
328 // Check that id is within allowed range
329
330 // Fill expanded id
331 ExpandedIdentifier expId;
332
333 IdContext context = channel_context();
334 if (get_expanded_id(compactId, expId, &context)) {
335 std::string errorMessage = "TileHWID::adc_id(channel_id,adc) result is not OK: ID = "
336 + compactId.getString() ;
337 TileID_Exception except(errorMessage , 1);
338 throw except ;
339
340 // region_id.show();
341 }
342
343 expId << adc;
344
345 if (!m_full_adc_range.match(expId)) {
346 std::string errorMessage = "TileHWID::adc_id() result is not OK: ID, range = "
347 + (std::string)expId + " , " + (std::string)m_full_ros_range;
348 TileID_Exception except(errorMessage , 1);
349 throw except ;
350 }
351 }
352#endif
353
354 return compactId;
355}
356
359 int channel, int adc ) const
360{
361
362 HWIdentifier compactId(drawer_id);
363 m_channel_impl.pack(channel,compactId);
364 m_adc_impl.pack(adc,compactId);
365
366#ifndef NDEBUG
367 if(m_do_checks) {
368
369 // Check that id is within allowed range
370
371 // Fill expanded id
372 ExpandedIdentifier expId;
373
374 IdContext context = drawer_context();
375 if (get_expanded_id(compactId, expId, &context)) {
376 std::string errorMessage = "TileHWID::adc_id(drawer_id,channel,adc) result is not OK: ID = "
377 + compactId.getString() ;
378 TileID_Exception except(errorMessage , 1);
379 throw except ;
380
381 // region_id.show();
382 }
383
384 expId << channel << adc;
385
386 if (!m_full_adc_range.match(expId)) {
387 std::string errorMessage = "TileHWID::adc_id() result is not OK: ID, range = "
388 + (std::string)expId + " , " + (std::string)m_full_ros_range;
389 TileID_Exception except(errorMessage , 1);
390 throw except ;
391 }
392 }
393#endif
394
395 return compactId;
396}
397
400{
402 IdContext context = ros_context();
403 get_expanded_id(ros_id, id, &context);
404 id << drawer;
405 if (!m_full_drawer_range.match(id)) {
406 return false;
407 }
408
411 return true;
412}
413
416{
418 IdContext context = ros_context();
419 get_expanded_id(ros_id, id, &context);
420 id << drawer << channel;
421 if (!m_full_channel_range.match(id)) {
422 return false;
423 }
424
428 return true;
429}
430
433{
435 IdContext context = drawer_context();
436 get_expanded_id(drawer_id, id, &context);
437 id << channel;
438 if (!m_full_channel_range.match(id)) {
439 return false;
440 }
441
444 return true;
445}
446
448 int adc, HWIdentifier& adc_id )
449{
451 IdContext context = channel_context();
452 get_expanded_id(channel_id, id, &context);
453 id << adc;
454 if (!m_full_adc_range.match(id)) {
455 return false;
456 }
457
459 m_adc_impl.pack(adc,adc_id);
460 return true;
461}
462
465{
467 return (IdContext(id, 0, m_ROS_INDEX));
468}
469
472{
474 return (IdContext(id, 0, m_DRAWER_INDEX));
475}
476
479{
481 return (IdContext(id, 0, m_CHANNEL_INDEX));
482}
483
486{
488 return (IdContext(id, 0, m_ADC_INDEX));
489}
490
491int TileHWID::get_id (const IdentifierHash& hash_id, HWIdentifier& id, const IdContext* context ) const
492{
493 int result = 1;
494 id.clear();
495
496 size_t begin = (context) ? context->begin_index(): 0;
497 // cannot get hash if end is 0:
498 size_t end = (context) ? context->end_index() : 0;
499
500 if (0 == begin) {
501
502 if ( m_ADC_INDEX == end ) {
503 if (hash_id < (unsigned int)(m_adc_vec.end() - m_adc_vec.begin())) {
504 id = m_adc_vec[hash_id];
505 result = 0;
506 } else {
507 ATH_MSG_ERROR("get_id: hwadc hash_id out of range " << hash_id
508 << " => " << m_adc_vec.size());
509 }
510 } else if ( m_CHANNEL_INDEX == end ) {
511 if (hash_id < (unsigned int)(m_channel_vec.end() - m_channel_vec.begin())) {
512 id = m_channel_vec[hash_id];
513 result = 0;
514 } else {
515 ATH_MSG_ERROR("get_id: channel hash_id is out of range "
516 << hash_id << " => " << m_channel_vec.size());
517 }
518 } else if ( m_DRAWER_INDEX == end ) {
519 if (hash_id < (unsigned int)(m_drawer_vec.end() - m_drawer_vec.begin())) {
520 id = m_drawer_vec[hash_id];
521 result = 0;
522 } else {
523 ATH_MSG_ERROR("get_id: drawer hash_id is out of range " << hash_id
524 << " => " << m_drawer_vec.size());
525 }
526 } else if ( m_ROS_INDEX == end ) {
527 if (hash_id < (unsigned int)(m_ros_vec.end() - m_ros_vec.begin())) {
528 id = m_ros_vec[hash_id];
529 result = 0;
530 } else {
531 ATH_MSG_ERROR("get_id: ROS hash_id is out of range " << hash_id
532 << " => " << m_ros_vec.size());
533 }
534 }
535 }
536 return(result);
537}
538
539// for fast retrieval do not perform error checking
541{
542 std::vector<HWIdentifier>::const_iterator it = std::lower_bound(m_adc_vec.begin(),m_adc_vec.end(),id);
543 return (IdentifierHash)(it - m_adc_vec.begin());
544}
545
546int TileHWID::get_hash (const HWIdentifier& id, IdentifierHash& hash_id, const IdContext* context ) const
547{
548
549 hash_id = 0;
550 int result = 1;
551
552 size_t begin = (context) ? context->begin_index(): 0;
553 size_t end = (context) ? context->end_index() : 0;
554
555 if (0 == begin) {
556 if ( m_ADC_INDEX == end ) {
557 std::vector<HWIdentifier>::const_iterator it = std::lower_bound(m_adc_vec.begin(),m_adc_vec.end(),id);
558 if ( it != m_adc_vec.end() ){
559 hash_id = it - m_adc_vec.begin();
560 result = 0;
561 }
562 } else if ( m_CHANNEL_INDEX == end ) {
563 std::vector<HWIdentifier>::const_iterator it = std::lower_bound(m_channel_vec.begin(),m_channel_vec.end(),id);
564 if ( it != m_channel_vec.end() ){
565 hash_id = it - m_channel_vec.begin();
566 result = 0;
567 }
568 } else if ( m_DRAWER_INDEX == end ) {
569 std::vector<HWIdentifier>::const_iterator it = std::lower_bound(m_drawer_vec.begin(),m_drawer_vec.end(),id);
570 if ( it != m_drawer_vec.end() ){
571 hash_id = it - m_drawer_vec.begin();
572 result = 0;
573 }
574 } else if ( m_ROS_INDEX == end ) {
575 std::vector<HWIdentifier>::const_iterator it = std::lower_bound(m_ros_vec.begin(),m_ros_vec.end(),id);
576 if ( it != m_ros_vec.end() ){
577 hash_id = it - m_ros_vec.begin();
578 result = 0;
579 }
580 }
581 }
582
583 return (result);
584}
585
587{
588 std::vector<HWIdentifier>::const_iterator it = std::lower_bound(m_channel_vec.begin(),m_channel_vec.end(),id);
589 if ( it != m_channel_vec.end() ){
590 return (it - m_channel_vec.begin());
591 } else {
592 return NOT_VALID_HASH;
593 }
594}
595
596
598{
599 ATH_MSG_INFO("initialize_from_dictionary ");
600
601 // Check whether this helper should be reinitialized
602 if (!reinitialize(dict_mgr)) {
603 ATH_MSG_DEBUG("Request to reinitialize not satisfied - tags have not changed");
604 return (0);
605 }
606 else {
607 ATH_MSG_DEBUG("(Re)initialize");
608 }
609
610 ATH_MSG_DEBUG("calling base initialize_from_dictionary");
611
612 // init base object
613 if(AtlasDetectorID::initialize_from_dictionary(dict_mgr)) return (1);
614
615 // Register version of the TileCalo dictionary
616 if (register_dict_tag(dict_mgr, "TileCalorimeter")) return(1);
617
618 m_dict = dict_mgr.find_dictionary ("TileCalorimeter");
619 if(!m_dict) {
620 ATH_MSG_ERROR("cannot access TileCalorimeter dictionary");
621 return 1;
622 }
623
624 // Initialize the field indices
625 if(initLevelsFromDict()) return (1);
626
627
628 // Find value for the field Tile Calorimeter
629 const IdDictDictionary* atlasDict = dict_mgr.find_dictionary ("ATLAS");
630 int tileField = -1;
631 if (atlasDict->get_label_value("subdet", "TileCalorimeter", tileField)) {
632 ATH_MSG_ERROR("Could not get value for label 'TileCalorimeter' of field 'subdet' in dictionary "
633 << atlasDict->name());
634 return (1);
635 }
636
637 // Find value for the field Tile Online
638 int tilehwField = -1;
639 if (m_dict->get_label_value("section", "Online", tilehwField)) {
640 ATH_MSG_ERROR("Could not get value for label 'Online' of field 'section' in dictionary "
641 << m_dict->name());
642 return (1);
643 }
644
645 // Set up id for region and range prefix
646 ExpandedIdentifier reg_id;
647 reg_id.add(tileField);
648 reg_id.add(tilehwField);
649 Range prefix;
650
651 m_full_adc_range = m_dict->build_multirange(reg_id, prefix, "gain");
652 m_full_channel_range= m_dict->build_multirange(reg_id, prefix, "channel");
653 m_full_drawer_range = m_dict->build_multirange(reg_id, prefix, "drawer");
654 m_full_ros_range = m_dict->build_multirange(reg_id, prefix, "ros");
655
656 ATH_MSG_DEBUG("initialize_from_dict : " );
657 ATH_MSG_DEBUG(" ros range -> " << (std::string)m_full_ros_range );
658 ATH_MSG_DEBUG(" drawer range -> " << (std::string)m_full_drawer_range );
659 ATH_MSG_DEBUG(" channel range -> " << (std::string)m_full_channel_range);
660 ATH_MSG_DEBUG(" adc range -> " << (std::string)m_full_adc_range );
661
662 // Setup the hash tables
663 if(init_hashes()) return (1);
664
665 return 0;
666
667}
668
669int TileHWID::get_expanded_id (const HWIdentifier& id, ExpandedIdentifier& exp_id, const IdContext* context) const
670{
671 int result = 1;
672
673 size_t begin = (context) ? context->begin_index() : 0;
674 size_t end = (context) ? context->end_index() : m_ADC_INDEX;
675 assert (end <= m_ADC_INDEX);
676
677 if (0 == end) {
678 result = 0;
679 }
680 else if ( 0 == begin) {
682 result = m_dict->unpack(group(), id, empty, end, exp_id);
683 }
684 else {
685 result = m_dict->unpack(group(), id, context->prefix_id(), end, exp_id);
686 }
687 return result;
688}
689
691{
692 if(!m_dict) {
693 ATH_MSG_ERROR("initLevelsFromDict - dictionary NOT initialized ");
694 return (1);
695 }
696
697 // Find out which identifier field corresponds to each level.
698
699 m_SYSTEM_INDEX = 999;
700 m_SECTION_INDEX = 999;
701 m_ROS_INDEX = 999;
702 m_DRAWER_INDEX = 999;
703 m_CHANNEL_INDEX = 999;
704 m_ADC_INDEX = 999;
705
706 // Save index to a Tile region for unpacking
708 if (m_dict->find_region(expId,m_tile_region_index)){
709 ATH_MSG_ERROR("initLevelsFromDict - unable to find tile region index: expId, reg "
710 << (std::string)expId << " " << m_tile_region_index);
711 return (1);
712 }
713
714 // Fing a Tile region
715 const IdDictField* field = m_dict->find_field("subdet") ;
716 if (field) {
717 m_SYSTEM_INDEX = field->index();
718 }
719 else {
720 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'subdet' field ");
721 return (1);
722 }
723
724 field = m_dict->find_field("section") ;
725 if (field) {
726 m_SECTION_INDEX = field->index();
727 }
728 else {
729 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'section' field ");
730 return (1);
731 }
732
733 field = m_dict->find_field("ros") ;
734 if (field) {
735 m_ROS_INDEX = field->index();
736 }
737 else {
738 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'ros' field ");
739 return (1);
740 }
741
742 field = m_dict->find_field("drawer") ;
743 if (field) {
744 m_DRAWER_INDEX = field->index();
745 }
746 else {
747 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'drawer' field ");
748 return (1);
749 }
750
751 field = m_dict->find_field("channel") ;
752 if (field) {
753 m_CHANNEL_INDEX = field->index();
754 }
755 else {
756 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'channel' field ");
757 return (1);
758 }
759
760 field = m_dict->find_field("gain") ;
761 if (field) {
762 m_ADC_INDEX = field->index();
763 }
764 else {
765 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'gain' field ");
766 return (1);
767 }
768
769 /* Set the field implementations */
770 const IdDictRegion& region = m_dict->region(m_tile_region_index);
771
778
782
783 ATH_MSG_DEBUG("initLevelsFromDict decode index and bit fields for each level: " );
784 ATH_MSG_DEBUG(" system [" << m_SYSTEM_INDEX << "] " << m_system_impl.show_to_string() );
785 ATH_MSG_DEBUG(" section [" << m_SECTION_INDEX << "] " << m_section_impl.show_to_string() );
786 ATH_MSG_DEBUG(" ros [" << m_ROS_INDEX << "] " << m_ros_impl.show_to_string() );
787 ATH_MSG_DEBUG(" drawer [" << m_DRAWER_INDEX << "] " << m_drawer_impl.show_to_string() );
788 ATH_MSG_DEBUG(" channel [" << m_CHANNEL_INDEX << "] " << m_channel_impl.show_to_string() );
789 ATH_MSG_DEBUG(" adc [" << m_ADC_INDEX << "] " << m_adc_impl.show_to_string() );
790
791 return(0) ;
792}
793
795{
796 // ros hash
797 unsigned int nids = 0;
798 std::set<HWIdentifier> ids;
799 for (unsigned int i = 0; i < m_full_ros_range.size(); ++i) {
800 const Range& range = m_full_ros_range[i];
801 ConstRangeIterator rit(range);
802 for (const auto & exp_id : rit) {
803 HWIdentifier id = ros_id (exp_id[m_ROS_INDEX]);
804 if(!(ids.insert(id)).second){
805 ATH_MSG_ERROR("init_hashes "
806 << " Error: duplicated id for ros id. nids= " << nids
807 << " compact Id " << show_to_string(id));
808 }
809 nids++;
810 }
811 }
812 m_ros_hash_max = m_full_ros_range.cardinality();
813 if ( fill_vec(ids, m_ros_hash_max, m_ros_vec) ) return (1);
814
815 // drawer hash
816 nids = 0;
817 ids.clear();
818 for (unsigned int i = 0; i < m_full_drawer_range.size(); ++i) {
819 const Range& range = m_full_drawer_range[i];
820 ConstRangeIterator rit(range);
821 for (const auto & exp_id:rit) {
822 HWIdentifier id = drawer_id (exp_id[m_ROS_INDEX],
823 exp_id[m_DRAWER_INDEX]);
824 if(!(ids.insert(id)).second){
825 ATH_MSG_ERROR("init_hashes "
826 << " Error: duplicated id for drawer id. nids= " << nids
827 << " compact Id " << show_to_string(id));
828 }
829 nids++;
830 }
831 }
833 if ( fill_vec(ids, m_drawer_hash_max, m_drawer_vec) ) return (1);
834
835 // channel hash
836 nids = 0;
837 ids.clear();
838 for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
839 const Range& range = m_full_channel_range[i];
840 ConstRangeIterator rit(range);
841 for (const auto & exp_id:rit) {
842 HWIdentifier id = channel_id (exp_id[m_ROS_INDEX],
843 exp_id[m_DRAWER_INDEX],
844 exp_id[m_CHANNEL_INDEX]);
845 if(!(ids.insert(id)).second){
846 ATH_MSG_ERROR("init_hashes "
847 << " Error: duplicated id for channel id. nids= " << nids
848 << " compact Id " << show_to_string(id));
849 }
850 nids++;
851 }
852 }
854 if ( fill_vec(ids, m_channel_hash_max, m_channel_vec) ) return (1);
855
856 // adc hash
857 nids = 0;
858 ids.clear();
859 for (unsigned int i = 0; i < m_full_adc_range.size(); ++i) {
860 const Range& range = m_full_adc_range[i];
861 ConstRangeIterator rit(range);
862 for (const auto & exp_id : rit) {
863 HWIdentifier id = adc_id (exp_id[m_ROS_INDEX],
864 exp_id[m_DRAWER_INDEX],
865 exp_id[m_CHANNEL_INDEX],
866 exp_id[m_ADC_INDEX]);
867 if(!(ids.insert(id)).second){
868 ATH_MSG_ERROR("init_hashes "
869 << " Error: duplicated id for adc id. nids= " << nids
870 << " compact Id " << show_to_string(id));
871 }
872 nids++;
873 }
874 }
875 m_adc_hash_max = m_full_adc_range.cardinality();
876 if ( fill_vec(ids, m_adc_hash_max, m_adc_vec) ) return (1);
877/*
878 for(std::vector<HWIdentifier>::const_iterator it=m_adc_vec.begin()
879 ;it!=m_adc_vec.end();++it){
880 std::vector<HWIdentifier>::const_iterator i
881 =std::lower_bound(vec.begin(),vec.end(),it);
882 m_adc_vec[m_adc_impl.unpack(*it)]
883
884 }
885*/
886
887 return (0);
888}
889
890int TileHWID::fill_vec (std::set<HWIdentifier> & ids,
891 unsigned int hash_max, std::vector<HWIdentifier> & vec)
892{
893
894 if(ids.size() != hash_max) {
895
896 ATH_MSG_ERROR("fill_vec "
897 << " Error: set size NOT EQUAL to hash max. size " << ids.size()
898 << " hash max " << hash_max);
899
900 return (1);
901 }
902
903 vec.resize(hash_max);
904
905 std::set<HWIdentifier>::const_iterator first = ids.begin();
906 std::set<HWIdentifier>::const_iterator last = ids.end();
907
908 int index = 0;
909 for (;first != last; ++first) {
910 vec[index++] = (*first);
911 }
912
913
914 return (0);
915}
916
920
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
std::vector< size_t > vec
static const Attributes_t empty
bool m_do_checks
Flag for subclasses to know whether or not to perform checks.
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
int register_dict_tag(const IdDictMgr &dict_mgr, const std::string &dict_name)
Register the file and tag names for a particular IdDict dictionary.
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
bool is_tile(Identifier id) const
ExpandedIdentifier tile_exp(void) const
int tile_field_value() const
const std::string & group() const
Group name for this helper.
AtlasDetectorID(const std::string &name, const std::string &group)
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
size_type begin_index() const
Definition IdContext.h:45
size_type end_index() const
Definition IdContext.h:46
const ExpandedIdentifier & prefix_id() const
Accessors.
Definition IdContext.h:44
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
This is a "hash" representation of an Identifier.
std::string getString() const
Provide a string form of the identifier - hexadecimal.
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
IdContext drawer_context() const
idContext for drawers
Definition TileHWID.cxx:471
int frag(const HWIdentifier &id) const
extract frag field from HW identifier
Definition TileHWID.h:181
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
Definition TileHWID.h:189
std::vector< HWIdentifier > m_ros_vec
Definition TileHWID.h:365
IdContext ros_context() const
access to IdContext's which define which levels of fields are contained in the id
Definition TileHWID.cxx:464
virtual IdentifierHash get_hash(const HWIdentifier &id) const
create hash id from compact ADC id without error checking
Definition TileHWID.cxx:540
size_type m_SYSTEM_INDEX
Definition TileHWID.h:341
size_type m_SECTION_INDEX
Definition TileHWID.h:342
bool is_high_gain(const HWIdentifier &id) const
Test ID for high gain.
Definition TileHWID.cxx:107
size_type m_ADC_INDEX
Definition TileHWID.h:346
MultiRange m_full_adc_range
Definition TileHWID.h:360
@ HIGHGAIN
Definition TileHWID.h:73
@ LOWGAIN
Definition TileHWID.h:72
size_type m_ROS_INDEX
Definition TileHWID.h:343
size_type m_tile_region_index
Definition TileHWID.h:340
@ NOT_VALID_HASH
Definition TileHWID.h:314
std::vector< HWIdentifier > m_drawer_vec
Definition TileHWID.h:366
std::vector< HWIdentifier > m_channel_vec
Definition TileHWID.h:367
size_type m_channel_hash_max
Definition TileHWID.h:363
int adc(const HWIdentifier &id) const
extract adc field from HW identifier
Definition TileHWID.h:193
int drawer(const HWIdentifier &id) const
extract drawer field from HW identifier
Definition TileHWID.h:171
int initLevelsFromDict()
Definition TileHWID.cxx:690
virtual int get_id(const IdentifierHash &hash_id, HWIdentifier &id, const IdContext *context=0) const
create compact HW ID from hash id (return == 0 for OK)
Definition TileHWID.cxx:491
bool is_low_gain(const HWIdentifier &id) const
Test ID for low gain.
Definition TileHWID.cxx:98
IdContext channel_context() const
idContext for channels
Definition TileHWID.cxx:478
IdDictFieldImplementation m_system_impl
Definition TileHWID.h:350
std::vector< HWIdentifier > m_adc_vec
Definition TileHWID.h:368
MultiRange m_full_ros_range
Definition TileHWID.h:357
int get_field(const HWIdentifier &id, size_type index) const
unpack one field from Identifier
Definition TileHWID.cxx:75
virtual ~TileHWID()
Default destructor.
Definition TileHWID.cxx:42
size_type m_drawer_hash_max
Definition TileHWID.h:362
IdDictFieldImplementation m_drawer_impl
Definition TileHWID.h:353
HWIdentifier drawer_id(int frag) const
ROS HWIdentifer.
Definition TileHWID.cxx:187
size_type m_DRAWER_INDEX
Definition TileHWID.h:344
size_type m_CHANNEL_INDEX
Definition TileHWID.h:345
int section(const HWIdentifier &id) const
extract section field from HW identifier
Definition TileHWID.h:163
int init_hashes()
Definition TileHWID.cxx:794
int fill_vec(std::set< HWIdentifier > &ids, unsigned int hash_max, std::vector< HWIdentifier > &vec)
Definition TileHWID.cxx:890
IdDictFieldImplementation m_adc_impl
Definition TileHWID.h:355
TileHWID()
Default constructor.
Definition TileHWID.cxx:25
const IdDictDictionary * m_dict
Definition TileHWID.h:348
MultiRange m_full_channel_range
Definition TileHWID.h:359
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr)
initialization from the identifier dictionary
Definition TileHWID.cxx:597
size_type m_adc_hash_max
Definition TileHWID.h:364
int get_expanded_id(const HWIdentifier &id, ExpandedIdentifier &exp_id, const IdContext *context) const
create expanded Identifier from Identifier (return == 0 for OK)
Definition TileHWID.cxx:669
HWIdentifier channel_id(int ros, int drawer, int channel) const
channel HWIdentifer
Definition TileHWID.cxx:199
IdDictFieldImplementation m_ros_impl
Definition TileHWID.h:352
std::string to_string(const HWIdentifier &id, int level=0) const
extract all fields from HW identifier HWIdentifier get_all_fields ( const HWIdentifier & id,...
Definition TileHWID.cxx:50
MultiRange m_full_drawer_range
Definition TileHWID.h:358
IdDictFieldImplementation m_section_impl
Definition TileHWID.h:351
HWIdentifier adc_id(int ros, int drawer, int channel, int adc) const
adc HWIdentifer
Definition TileHWID.cxx:229
@ TILE_ONLINE
Definition TileHWID.h:66
HWIdentifier ros_id(int ros) const
ROS HWIdentifer.
Definition TileHWID.cxx:130
IdContext adc_context() const
idContext for ADCs
Definition TileHWID.cxx:485
int ros(const HWIdentifier &id) const
extract ros field from HW identifier
Definition TileHWID.h:167
size_type m_ros_hash_max
Definition TileHWID.h:361
virtual IdentifierHash get_channel_hash(const HWIdentifier &id) const
create hash id from compact Channel id
Definition TileHWID.cxx:586
IdDictFieldImplementation m_channel_impl
Definition TileHWID.h:354
HWIdentifier m_base_tile_ros
Definition TileHWID.h:370
Identifier::size_type size_type
Definition TileHWID.h:53
bool is_tilehw(const HWIdentifier &id) const
Test ID for Tile online ID.
Definition TileHWID.cxx:89
HWIdentifier tilehw_id() const
online identifer for whole Tile
Definition TileHWID.cxx:119
Exception class for Tile Identifiers.
Definition index.py:1