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