ATLAS Offline Software
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")
27  , m_tile_region_index(0)
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)
35  , m_ros_hash_max(0)
36  , m_drawer_hash_max(0)
37  , m_channel_hash_max(0)
38  , m_adc_hash_max(0)
39 {
40 }
41 
43 {
44 }
45 
46 //
47 // TileHWID methods
48 //
49 std::string
50 TileHWID::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 //
74 int
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 //
88 bool
90 {
91  bool result = is_tile(id)
92  && ( section(id) == TileHWID::TILE_ONLINE );
93 
94  return result;
95 }
96 
97 bool
99 {
100  bool result = is_tilehw(id)
101  && ( adc(id) == TileHWID::LOWGAIN );
102 
103  return result;
104 }
105 
106 bool
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 //
130 TileHWID::ros_id ( int ros ) const
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
142  ExpandedIdentifier expId(tile_exp());
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 
158 TileHWID::drawer_id ( int ros, int drawer ) const
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
171  ExpandedIdentifier expId(tile_exp());
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 
187 TileHWID::drawer_id ( int frag ) const
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 //
199 TileHWID::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
213  ExpandedIdentifier expId(tile_exp());
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 
229 TileHWID::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
244  ExpandedIdentifier expId(tile_exp());
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 
260 TileHWID::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 
270 TileHWID::channel_id ( const HWIdentifier & any_id ) const
271 {
272  HWIdentifier compactId(any_id);
273  m_adc_impl.reset(compactId);
274  return (compactId);
275 }
276 
278 TileHWID::channel_id ( const HWIdentifier & drawer_id,
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 
358 TileHWID::adc_id ( const HWIdentifier & drawer_id,
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 
398 bool TileHWID::drawer_id ( const HWIdentifier& ros_id,
399  int drawer, HWIdentifier& drawer_id )
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 
414 bool TileHWID::channel_id ( const HWIdentifier& ros_id,
415  int drawer, int channel, HWIdentifier& channel_id )
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 
431 bool TileHWID::channel_id ( const HWIdentifier& drawer_id,
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 
460  return true;
461 }
462 
463 IdContext
465 {
467  return (IdContext(id, 0, m_ROS_INDEX));
468 }
469 
470 IdContext
472 {
474  return (IdContext(id, 0, m_DRAWER_INDEX));
475 }
476 
477 IdContext
479 {
481  return (IdContext(id, 0, m_CHANNEL_INDEX));
482 }
483 
484 IdContext
486 {
488  return (IdContext(id, 0, m_ADC_INDEX));
489 }
490 
491 int 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 
546 int 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 
669 int 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) {
681  ExpandedIdentifier empty;
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
707  ExpandedIdentifier expId(tile_exp());
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];
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  }
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];
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];
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];
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  }
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 
890 int 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 
TileHWID::m_SYSTEM_INDEX
size_type m_SYSTEM_INDEX
Definition: TileHWID.h:341
IdDictMgr.h
TileHWID::ros_id
HWIdentifier ros_id(int ros) const
ROS HWIdentifer.
Definition: TileHWID.cxx:130
ConstRangeIterator
Definition: RangeIterator.h:46
IdDictDictionary::build_multirange
MultiRange build_multirange() const
Get MultiRange for full dictionary.
Definition: IdDictDictionary.cxx:309
AtlasDetectorID::initialize_from_dictionary
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
Definition: AtlasDetectorID.cxx:257
TileHWID::adc_context
IdContext adc_context() const
idContext for ADCs
Definition: TileHWID.cxx:485
get_generator_info.result
result
Definition: get_generator_info.py:21
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TileHWID::get_id
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
TileHWID::fill_vec
int fill_vec(std::set< HWIdentifier > &ids, unsigned int hash_max, std::vector< HWIdentifier > &vec)
Definition: TileHWID.cxx:890
IdDictFieldImplementation::show_to_string
std::string show_to_string(void) const
Definition: IdDictFieldImplementation.cxx:32
TileHWID::is_low_gain
bool is_low_gain(const HWIdentifier &id) const
Test ID for low gain.
Definition: TileHWID.cxx:98
TileHWID::m_section_impl
IdDictFieldImplementation m_section_impl
Definition: TileHWID.h:351
index
Definition: index.py:1
IdDictDictionary::region
const IdDictRegion & region(size_t i) const
Region at index i.
Definition: IdDictDictionary.h:354
TileHWID::m_ros_vec
std::vector< HWIdentifier > m_ros_vec
Definition: TileHWID.h:365
IdDictDictionary.h
IdContext::end_index
size_type end_index() const
Definition: IdContext.h:46
ExpandedIdentifier::add
void add(element_type value)
Append a value into a new field.
skel.it
it
Definition: skel.GENtoEVGEN.py:407
TileHWID::m_DRAWER_INDEX
size_type m_DRAWER_INDEX
Definition: TileHWID.h:344
ReadBchFromCrest.begin
begin
Definition: ReadBchFromCrest.py:80
TileHWID::is_tilehw
bool is_tilehw(const HWIdentifier &id) const
Test ID for Tile online ID.
Definition: TileHWID.cxx:89
IdDictDictionary::find_field
const IdDictField * find_field(const std::string &name) const
Definition: IdDictDictionary.cxx:47
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
TileHWID::m_adc_hash_max
size_type m_adc_hash_max
Definition: TileHWID.h:364
IdDictFieldImplementation::pack
void pack(int value, Identifier &id) const
Definition: IdDictFieldImplementation.h:178
TileHWID::m_channel_impl
IdDictFieldImplementation m_channel_impl
Definition: TileHWID.h:354
TileHWID::frag
int frag(const HWIdentifier &id) const
extract frag field from HW identifier
Definition: TileHWID.h:181
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:9
AtlasDetectorID::m_do_checks
bool m_do_checks
Flag for subclasses to know whether or not to perform checks.
Definition: AtlasDetectorID.h:354
TileHWID::m_SECTION_INDEX
size_type m_SECTION_INDEX
Definition: TileHWID.h:342
ReadBchFromCrest.ros
ros
Definition: ReadBchFromCrest.py:73
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
IdDictDictionary::name
const std::string & name() const
Dictionary name.
Definition: IdDictDictionary.h:336
HWIdentifier
Definition: HWIdentifier.h:13
TileHWID::HIGHGAIN
@ HIGHGAIN
Definition: TileHWID.h:73
TileHWID::initialize_from_dictionary
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr)
initialization from the identifier dictionary
Definition: TileHWID.cxx:597
TileHWID::TileHWID
TileHWID()
Default constructor.
Definition: TileHWID.cxx:25
AtlasDetectorID::tile_exp
ExpandedIdentifier tile_exp(void) const
Definition: AtlasDetectorID.cxx:1056
Example_ReadSampleNoise.drawer
drawer
Definition: Example_ReadSampleNoise.py:39
IdDictRegion
Definition: IdDictRegion.h:21
TileHWID::channel
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
Definition: TileHWID.h:189
TileHWID::m_ros_impl
IdDictFieldImplementation m_ros_impl
Definition: TileHWID.h:352
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
TileHWID::ros
int ros(const HWIdentifier &id) const
extract ros field from HW identifier
Definition: TileHWID.h:167
IdDictFieldImplementation::reset
void reset(Identifier &id) const
Definition: IdDictFieldImplementation.h:188
TileHWID::LOWGAIN
@ LOWGAIN
Definition: TileHWID.h:72
TileHWID::m_adc_vec
std::vector< HWIdentifier > m_adc_vec
Definition: TileHWID.h:368
AtlasDetectorID::size_type
Identifier::size_type size_type
Definition: AtlasDetectorID.h:369
IdDictDictionary::find_region
const IdDictRegion * find_region(const std::string &region_name) const
Definition: IdDictDictionary.cxx:114
TileHWID::m_adc_impl
IdDictFieldImplementation m_adc_impl
Definition: TileHWID.h:355
IdDictRegion::implementation
const IdDictFieldImplementation & implementation(size_t i) const
Definition: IdDictRegion.cxx:38
IdDictMgr
Definition: IdDictMgr.h:16
TileHWID::adc
int adc(const HWIdentifier &id) const
extract adc field from HW identifier
Definition: TileHWID.h:193
IdContext::begin_index
size_type begin_index() const
Definition: IdContext.h:45
TileHWID::NOT_VALID_HASH
@ NOT_VALID_HASH
Definition: TileHWID.h:314
TileHWID.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TileHWID::section
int section(const HWIdentifier &id) const
extract section field from HW identifier
Definition: TileHWID.h:163
TileHWID::m_channel_hash_max
size_type m_channel_hash_max
Definition: TileHWID.h:363
lumiFormat.i
int i
Definition: lumiFormat.py:85
TileHWID::get_hash
virtual IdentifierHash get_hash(const HWIdentifier &id) const
create hash id from compact ADC id without error checking
Definition: TileHWID.cxx:540
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
createCoolChannelIdFile.channel_id
channel_id
Definition: createCoolChannelIdFile.py:51
TileHWID::ros_context
IdContext ros_context() const
access to IdContext's which define which levels of fields are contained in the id
Definition: TileHWID.cxx:464
TileHWID::TILE_ONLINE
@ TILE_ONLINE
Definition: TileHWID.h:66
TileHWID::channel_context
IdContext channel_context() const
idContext for channels
Definition: TileHWID.cxx:478
TileHWID::get_channel_hash
virtual IdentifierHash get_channel_hash(const HWIdentifier &id) const
create hash id from compact Channel id
Definition: TileHWID.cxx:586
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
TileID_Exception
Exception class for Tile Identifiers.
Definition: TileID_Exception.h:16
AtlasDetectorID::is_tile
bool is_tile(Identifier id) const
Definition: AtlasDetectorID.h:548
AtlasDetectorID::group
const std::string & group() const
Group name for this helper.
Definition: AtlasDetectorID.cxx:34
TileHWID::m_CHANNEL_INDEX
size_type m_CHANNEL_INDEX
Definition: TileHWID.h:345
TileHWID::m_ros_hash_max
size_type m_ros_hash_max
Definition: TileHWID.h:361
TileHWID::m_tile_region_index
size_type m_tile_region_index
Definition: TileHWID.h:340
TileHWID::m_base_tile_ros
HWIdentifier m_base_tile_ros
Definition: TileHWID.h:370
AtlasDetectorID::register_dict_tag
int register_dict_tag(const IdDictMgr &dict_mgr, const std::string &dict_name)
Register the file and tag names for a particular IdDict dictionary.
Definition: AtlasDetectorID.cxx:203
TileHWID::~TileHWID
virtual ~TileHWID()
Default destructor.
Definition: TileHWID.cxx:42
AtlasDetectorID::tile_field_value
int tile_field_value() const
Definition: AtlasDetectorID.h:470
IdDictDictionary::get_label_value
int get_label_value(const std::string &field, const std::string &label, int &value) const
Definition: IdDictDictionary.cxx:92
IdDictDictionary::unpack
int unpack(const std::string &group, const Identifier &id, const ExpandedIdentifier &prefix, size_t index2, ExpandedIdentifier &unpackedId) const
Unpack the value_type id to an expanded Identifier for a given group, considering the provided prefix...
Definition: IdDictDictionary.cxx:679
TileHWID::m_full_channel_range
MultiRange m_full_channel_range
Definition: TileHWID.h:359
IdContext::prefix_id
const ExpandedIdentifier & prefix_id() const
Accessors.
Definition: IdContext.h:44
TileHWID::drawer_id
HWIdentifier drawer_id(int frag) const
ROS HWIdentifer.
Definition: TileHWID.cxx:187
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:239
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
TileHWID::get_field
int get_field(const HWIdentifier &id, size_type index) const
unpack one field from Identifier
Definition: TileHWID.cxx:75
TileHWID::channel_id
HWIdentifier channel_id(int ros, int drawer, int channel) const
channel HWIdentifer
Definition: TileHWID.cxx:199
IdentifierHash.h
RangeIterator.h
TileHWID::m_ROS_INDEX
size_type m_ROS_INDEX
Definition: TileHWID.h:343
TileHWID::m_full_ros_range
MultiRange m_full_ros_range
Definition: TileHWID.h:357
TileHWID::m_full_drawer_range
MultiRange m_full_drawer_range
Definition: TileHWID.h:358
Range
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition: DetectorDescription/Identifier/Identifier/Range.h:29
TileHWID::drawer_context
IdContext drawer_context() const
idContext for drawers
Definition: TileHWID.cxx:471
TileHWID::m_ADC_INDEX
size_type m_ADC_INDEX
Definition: TileHWID.h:346
IdDictDictionary
Definition: IdDictDictionary.h:31
TileHWID::adc_id
HWIdentifier adc_id(int ros, int drawer, int channel, int adc) const
adc HWIdentifer
Definition: TileHWID.cxx:229
MultiRange::match
int match(const ExpandedIdentifier &id) const
Match an identifier.
Definition: MultiRange.cxx:57
Identifier::getString
std::string getString() const
Provide a string form of the identifier - hexadecimal.
Definition: Identifier.cxx:25
AtlasDetectorID::reinitialize
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
Definition: AtlasDetectorID.cxx:223
IdDictField.h
TileHWID::tilehw_id
HWIdentifier tilehw_id() const
online identifer for whole Tile
Definition: TileHWID.cxx:119
IdDictMgr::find_dictionary
const IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
Definition: IdDictMgr.cxx:116
TileHWID::drawer
int drawer(const HWIdentifier &id) const
extract drawer field from HW identifier
Definition: TileHWID.h:171
AtlasDetectorID::show_to_string
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:367
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
TileHWID::m_system_impl
IdDictFieldImplementation m_system_impl
Definition: TileHWID.h:350
TileHWID::m_dict
const IdDictDictionary * m_dict
Definition: TileHWID.h:348
MultiRange::size
size_type size() const
Definition: MultiRange.cxx:70
DeMoScan.first
bool first
Definition: DeMoScan.py:534
TileHWID::m_channel_vec
std::vector< HWIdentifier > m_channel_vec
Definition: TileHWID.h:367
TileHWID::get_expanded_id
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
TileHWID::initLevelsFromDict
int initLevelsFromDict()
Definition: TileHWID.cxx:690
TileHWID::is_high_gain
bool is_high_gain(const HWIdentifier &id) const
Test ID for high gain.
Definition: TileHWID.cxx:107
TileHWID::init_hashes
int init_hashes()
Definition: TileHWID.cxx:794
IdDictRegion.h
TileHWID::m_full_adc_range
MultiRange m_full_adc_range
Definition: TileHWID.h:360
IdDictField
Definition: IdDictField.h:16
MultiRange::cardinality
size_type cardinality() const
Computes a possible cardinality from all ranges.
Definition: MultiRange.cxx:82
TileHWID::to_string
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
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
TileHWID::m_drawer_vec
std::vector< HWIdentifier > m_drawer_vec
Definition: TileHWID.h:366
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition: IdContext.h:26
TileHWID::m_drawer_hash_max
size_type m_drawer_hash_max
Definition: TileHWID.h:362
TileHWID::m_drawer_impl
IdDictFieldImplementation m_drawer_impl
Definition: TileHWID.h:353
AtlasDetectorID
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Definition: AtlasDetectorID.h:52