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