Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TileHWID.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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"
17 #include "GaudiKernel/MsgStream.h"
18 
19 #include <algorithm>
20 #include <iostream>
21 #include <stdio.h>
22 #include <assert.h>
23 
24 
25 
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  MsgStream log(m_msgSvc, "TileHWID" );
508  log << MSG::ERROR << "get_id: hwadc hash_id out of range " << hash_id
509  << " => " << m_adc_vec.size() << endmsg;
510  }
511  } else if ( m_CHANNEL_INDEX == end ) {
512  if (hash_id < (unsigned int)(m_channel_vec.end() - m_channel_vec.begin())) {
513  id = m_channel_vec[hash_id];
514  result = 0;
515  } else {
516  MsgStream log(m_msgSvc, "TileHWID" );
517  log << MSG::ERROR << "get_id: channel hash_id is out of range "
518  << hash_id << " => " << m_channel_vec.size() << endmsg;
519  }
520  } else if ( m_DRAWER_INDEX == end ) {
521  if (hash_id < (unsigned int)(m_drawer_vec.end() - m_drawer_vec.begin())) {
522  id = m_drawer_vec[hash_id];
523  result = 0;
524  } else {
525  MsgStream log(m_msgSvc, "TileHWID" );
526  log << MSG::ERROR << "get_id: drawer hash_id is out of range " << hash_id
527  << " => " << m_drawer_vec.size() << endmsg;
528  }
529  } else if ( m_ROS_INDEX == end ) {
530  if (hash_id < (unsigned int)(m_ros_vec.end() - m_ros_vec.begin())) {
531  id = m_ros_vec[hash_id];
532  result = 0;
533  } else {
534  MsgStream log(m_msgSvc, "TileHWID" );
535  log << MSG::ERROR << "get_id: ROS hash_id is out of range " << hash_id
536  << " => " << m_ros_vec.size() << endmsg;
537  }
538  }
539  }
540  return(result);
541 }
542 
543 // for fast retrieval do not perform error checking
545 {
546  std::vector<HWIdentifier>::const_iterator it = std::lower_bound(m_adc_vec.begin(),m_adc_vec.end(),id);
547  return (IdentifierHash)(it - m_adc_vec.begin());
548 }
549 
550 int TileHWID::get_hash (const HWIdentifier& id, IdentifierHash& hash_id, const IdContext* context ) const
551 {
552 
553  hash_id = 0;
554  int result = 1;
555 
556  size_t begin = (context) ? context->begin_index(): 0;
557  size_t end = (context) ? context->end_index() : 0;
558 
559  if (0 == begin) {
560  if ( m_ADC_INDEX == end ) {
561  std::vector<HWIdentifier>::const_iterator it = std::lower_bound(m_adc_vec.begin(),m_adc_vec.end(),id);
562  if ( it != m_adc_vec.end() ){
563  hash_id = it - m_adc_vec.begin();
564  result = 0;
565  }
566  } else if ( m_CHANNEL_INDEX == end ) {
567  std::vector<HWIdentifier>::const_iterator it = std::lower_bound(m_channel_vec.begin(),m_channel_vec.end(),id);
568  if ( it != m_channel_vec.end() ){
569  hash_id = it - m_channel_vec.begin();
570  result = 0;
571  }
572  } else if ( m_DRAWER_INDEX == end ) {
573  std::vector<HWIdentifier>::const_iterator it = std::lower_bound(m_drawer_vec.begin(),m_drawer_vec.end(),id);
574  if ( it != m_drawer_vec.end() ){
575  hash_id = it - m_drawer_vec.begin();
576  result = 0;
577  }
578  } else if ( m_ROS_INDEX == end ) {
579  std::vector<HWIdentifier>::const_iterator it = std::lower_bound(m_ros_vec.begin(),m_ros_vec.end(),id);
580  if ( it != m_ros_vec.end() ){
581  hash_id = it - m_ros_vec.begin();
582  result = 0;
583  }
584  }
585  }
586 
587  return (result);
588 }
589 
591 {
592  std::vector<HWIdentifier>::const_iterator it = std::lower_bound(m_channel_vec.begin(),m_channel_vec.end(),id);
593  if ( it != m_channel_vec.end() ){
594  return (it - m_channel_vec.begin());
595  } else {
596  return NOT_VALID_HASH;
597  }
598 }
599 
600 
602 {
603  MsgStream log(m_msgSvc, "TileHWID" );
604  log << MSG::INFO << "initialize_from_dictionary " << endmsg;
605 
606  // Check whether this helper should be reinitialized
607  if (!reinitialize(dict_mgr)) {
608  log << MSG::DEBUG << "Request to reinitialize not satisfied - tags have not changed" << endmsg;
609  return (0);
610  }
611  else {
612  log << MSG::DEBUG << "(Re)initialize" << endmsg;
613  }
614 
615  log << MSG::DEBUG << "calling base initialize_from_dictionary" << endmsg;
616 
617  // init base object
618  if(AtlasDetectorID::initialize_from_dictionary(dict_mgr)) return (1);
619 
620  // Register version of the TileCalo dictionary
621  if (register_dict_tag(dict_mgr, "TileCalorimeter")) return(1);
622 
623  m_dict = dict_mgr.find_dictionary ("TileCalorimeter");
624  if(!m_dict) {
625  log << MSG::ERROR << "cannot access TileCalorimeter dictionary" << endmsg;
626  return 1;
627  }
628 
629  // Initialize the field indices
630  if(initLevelsFromDict()) return (1);
631 
632 
633  // Find value for the field Tile Calorimeter
634  const IdDictDictionary* atlasDict = dict_mgr.find_dictionary ("ATLAS");
635  int tileField = -1;
636  if (atlasDict->get_label_value("subdet", "TileCalorimeter", tileField)) {
637  log << MSG::ERROR << "Could not get value for label 'TileCalorimeter' of field 'subdet' in dictionary "
638  << atlasDict->m_name
639  << endmsg;
640  return (1);
641  }
642 
643  // Find value for the field Tile Online
644  int tilehwField = -1;
645  if (m_dict->get_label_value("section", "Online", tilehwField)) {
646  log << MSG::ERROR << "Could not get value for label 'Online' of field 'section' in dictionary "
647  << m_dict->m_name
648  << endmsg;
649  return (1);
650  }
651 
652  /*
653  log << MSG::DEBUG << "initialize_from_dict - found field values: TileHW "
654  << TileHWField
655  << endmsg;
656  */
657 
658  // Set up id for region and range prefix
659  ExpandedIdentifier reg_id;
660  reg_id.add(tileField);
661  reg_id.add(tilehwField);
662  Range prefix;
663 
664  m_full_adc_range = m_dict->build_multirange(reg_id, prefix, "gain");
665  m_full_channel_range= m_dict->build_multirange(reg_id, prefix, "channel");
666  m_full_drawer_range = m_dict->build_multirange(reg_id, prefix, "drawer");
667  m_full_ros_range = m_dict->build_multirange(reg_id, prefix, "ros");
668 
669  log << MSG::DEBUG << "initialize_from_dict : " << endmsg;
670  log << MSG::DEBUG << " ros range -> " << (std::string)m_full_ros_range << endmsg;
671  log << MSG::DEBUG << " drawer range -> " << (std::string)m_full_drawer_range << endmsg;
672  log << MSG::DEBUG << " channel range -> " << (std::string)m_full_channel_range << endmsg;
673  log << MSG::DEBUG << " adc range -> " << (std::string)m_full_adc_range << endmsg;
674 
675  // Setup the hash tables
676  if(init_hashes()) return (1);
677 
678  return 0;
679 
680 }
681 
682 int TileHWID::get_expanded_id (const HWIdentifier& id, ExpandedIdentifier& exp_id, const IdContext* context) const
683 {
684  int result = 1;
685 
686  size_t begin = (context) ? context->begin_index() : 0;
687  size_t end = (context) ? context->end_index() : m_ADC_INDEX;
688  assert (end <= m_ADC_INDEX);
689 
690  if (0 == end) {
691  result = 0;
692  }
693  else if ( 0 == begin) {
694  ExpandedIdentifier empty;
695  result = m_dict->unpack(id, empty, end, exp_id);
696  }
697  else {
698  result = m_dict->unpack(id, context->prefix_id(), end, exp_id);
699  }
700  return result;
701 }
702 
704 {
705  MsgStream log(m_msgSvc, "TileHWID" );
706 
707  if(!m_dict) {
708  log << MSG::ERROR << "initLevelsFromDict - dictionary NOT initialized "
709  << endmsg ;
710  return (1);
711  }
712 
713  // Find out which identifier field corresponds to each level.
714 
715  m_SYSTEM_INDEX = 999;
716  m_SECTION_INDEX = 999;
717  m_ROS_INDEX = 999;
718  m_DRAWER_INDEX = 999;
719  m_CHANNEL_INDEX = 999;
720  m_ADC_INDEX = 999;
721 
722  // Save index to a Tile region for unpacking
723  ExpandedIdentifier expId(tile_exp());
725  log << MSG::ERROR << "initLevelsFromDict - unable to find tile region index: expId, reg "
726  << (std::string)expId << " " << m_tile_region_index
727  << endmsg;
728  return (1);
729  }
730 
731  // Fing a Tile region
732  IdDictField* field = m_dict->find_field("subdet") ;
733  if (field) {
734  m_SYSTEM_INDEX = field->m_index ;
735  }
736  else {
737  log << MSG::ERROR << "initLevelsFromDict - unable to find 'subdet' field "
738  << endmsg ;
739  return (1);
740  }
741 
742  field = m_dict->find_field("section") ;
743  if (field) {
744  m_SECTION_INDEX = field->m_index ;
745  }
746  else {
747  log << MSG::ERROR << "initLevelsFromDict - unable to find 'section' field "
748  << endmsg ;
749  return (1);
750  }
751 
752  field = m_dict->find_field("ros") ;
753  if (field) {
754  m_ROS_INDEX = field->m_index ;
755  }
756  else {
757  log << MSG::ERROR << "initLevelsFromDict - unable to find 'ros' field "
758  << endmsg ;
759  return (1);
760  }
761 
762  field = m_dict->find_field("drawer") ;
763  if (field) {
764  m_DRAWER_INDEX = field->m_index ;
765  }
766  else {
767  log << MSG::ERROR << "initLevelsFromDict - unable to find 'drawer' field "
768  << endmsg ;
769  return (1);
770  }
771 
772  field = m_dict->find_field("channel") ;
773  if (field) {
774  m_CHANNEL_INDEX = field->m_index ;
775  }
776  else {
777  log << MSG::ERROR << "initLevelsFromDict - unable to find 'channel' field "
778  << endmsg ;
779  return (1);
780  }
781 
782  field = m_dict->find_field("gain") ;
783  if (field) {
784  m_ADC_INDEX = field->m_index ;
785  }
786  else {
787  log << MSG::ERROR << "initLevelsFromDict - unable to find 'gain' field "
788  << endmsg ;
789  return (1);
790  }
791 
792  /* Set the field implementations */
794 
801 
805 
806  log << MSG::DEBUG << "initLevelsFromDict decode index and bit fields for each level: " << endmsg ;
807  log << MSG::DEBUG << " system [" << m_SYSTEM_INDEX << "] " << m_system_impl.show_to_string() << endmsg ;
808  log << MSG::DEBUG << " section [" << m_SECTION_INDEX << "] " << m_section_impl.show_to_string() << endmsg ;
809  log << MSG::DEBUG << " ros [" << m_ROS_INDEX << "] " << m_ros_impl.show_to_string() << endmsg ;
810  log << MSG::DEBUG << " drawer [" << m_DRAWER_INDEX << "] " << m_drawer_impl.show_to_string() << endmsg ;
811  log << MSG::DEBUG << " channel [" << m_CHANNEL_INDEX << "] " << m_channel_impl.show_to_string() << endmsg ;
812  log << MSG::DEBUG << " adc [" << m_ADC_INDEX << "] " << m_adc_impl.show_to_string() << endmsg ;
813 
814  return(0) ;
815 }
816 
818 {
819  MsgStream log(m_msgSvc, "TileHWID" );
820 
821  // ros hash
822  unsigned int nids = 0;
823  std::set<HWIdentifier> ids;
824  for (unsigned int i = 0; i < m_full_ros_range.size(); ++i) {
825  const Range& range = m_full_ros_range[i];
827  for (const auto & exp_id : rit) {
828  HWIdentifier id = ros_id (exp_id[m_ROS_INDEX]);
829  if(!(ids.insert(id)).second){
830  log << MSG::ERROR << "init_hashes "
831  << " Error: duplicated id for ros id. nids= " << nids
832  << " compact Id " << show_to_string(id)
833  << endmsg;
834  }
835  nids++;
836  }
837  }
839  if ( fill_vec(ids, m_ros_hash_max, m_ros_vec) ) return (1);
840 
841  // drawer hash
842  nids = 0;
843  ids.clear();
844  for (unsigned int i = 0; i < m_full_drawer_range.size(); ++i) {
845  const Range& range = m_full_drawer_range[i];
847  for (const auto & exp_id:rit) {
848  HWIdentifier id = drawer_id (exp_id[m_ROS_INDEX],
849  exp_id[m_DRAWER_INDEX]);
850  if(!(ids.insert(id)).second){
851  log << MSG::ERROR << "init_hashes "
852  << " Error: duplicated id for drawer id. nids= " << nids
853  << " compact Id " << show_to_string(id)
854  << endmsg;
855  }
856  nids++;
857  }
858  }
860  if ( fill_vec(ids, m_drawer_hash_max, m_drawer_vec) ) return (1);
861 
862  // channel hash
863  nids = 0;
864  ids.clear();
865  for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
866  const Range& range = m_full_channel_range[i];
868  for (const auto & exp_id:rit) {
869  HWIdentifier id = channel_id (exp_id[m_ROS_INDEX],
870  exp_id[m_DRAWER_INDEX],
871  exp_id[m_CHANNEL_INDEX]);
872  if(!(ids.insert(id)).second){
873  log << MSG::ERROR << "init_hashes "
874  << " Error: duplicated id for channel id. nids= " << nids
875  << " compact Id " << show_to_string(id)
876  << endmsg;
877  }
878  nids++;
879  }
880  }
882  if ( fill_vec(ids, m_channel_hash_max, m_channel_vec) ) return (1);
883 
884  // adc hash
885  nids = 0;
886  ids.clear();
887  for (unsigned int i = 0; i < m_full_adc_range.size(); ++i) {
888  const Range& range = m_full_adc_range[i];
890  for (const auto & exp_id : rit) {
891  HWIdentifier id = adc_id (exp_id[m_ROS_INDEX],
892  exp_id[m_DRAWER_INDEX],
893  exp_id[m_CHANNEL_INDEX],
894  exp_id[m_ADC_INDEX]);
895  if(!(ids.insert(id)).second){
896  log << MSG::ERROR << "init_hashes "
897  << " Error: duplicated id for adc id. nids= " << nids
898  << " compact Id " << show_to_string(id)
899  << endmsg;
900  }
901  nids++;
902  }
903  }
905  if ( fill_vec(ids, m_adc_hash_max, m_adc_vec) ) return (1);
906 /*
907  for(std::vector<HWIdentifier>::const_iterator it=m_adc_vec.begin()
908  ;it!=m_adc_vec.end();++it){
909  std::vector<HWIdentifier>::const_iterator i
910  =std::lower_bound(vec.begin(),vec.end(),it);
911  m_adc_vec[m_adc_impl.unpack(*it)]
912 
913  }
914 */
915 
916  return (0);
917 }
918 
919 int TileHWID::fill_vec (std::set<HWIdentifier> & ids,
920  unsigned int hash_max, std::vector<HWIdentifier> & vec)
921 {
922 
923  if(ids.size() != hash_max) {
924 
925  MsgStream log(m_msgSvc, "TileHWID" );
926  log << MSG::ERROR << "fill_vec "
927  << " Error: set size NOT EQUAL to hash max. size " << ids.size()
928  << " hash max " << hash_max
929  << endmsg;
930 
931  return (1);
932  }
933 
934  vec.resize(hash_max);
935 
936  std::set<HWIdentifier>::const_iterator first = ids.begin();
937  std::set<HWIdentifier>::const_iterator last = ids.end();
938 
939  int index = 0;
940  for (;first != last; ++first) {
941  vec[index++] = (*first);
942  }
943 
944 
945  return (0);
946 }
947 
951 
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
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:299
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: IdDictDictionary.cxx:683
AtlasDetectorID::initialize_from_dictionary
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
Definition: AtlasDetectorID.cxx:240
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:491
TileHWID::fill_vec
int fill_vec(std::set< HWIdentifier > &ids, unsigned int hash_max, std::vector< HWIdentifier > &vec)
Definition: TileHWID.cxx:919
IdDictFieldImplementation::show_to_string
std::string show_to_string(void) const
Definition: IdDictFieldImplementation.cxx:38
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
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:478
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:401
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:89
TileHWID::TileHWID
TileHWID(void)
Default constructor.
Definition: TileHWID.cxx:26
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:368
TileHWID::tilehw_id
HWIdentifier tilehw_id(void) const
online identifer for whole Tile
Definition: TileHWID.cxx:119
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: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:471
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:601
TileHWID::NOT_VALID_HASH
@ NOT_VALID_HASH
Definition: TileHWID.h:314
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: IdDictDictionary.cxx:45
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: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:183
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: IdDictMgr.h:14
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:115
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:544
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: IdDictDictionary.h:235
TileHWID::get_channel_hash
virtual IdentifierHash get_channel_hash(const HWIdentifier &id) const
create hash id from compact Channel id
Definition: TileHWID.cxx:590
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
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:186
TileHWID::~TileHWID
virtual ~TileHWID()
Default destructor.
Definition: TileHWID.cxx:42
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: IdDictDictionary.cxx:73
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:227
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::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:464
TileHWID::m_ADC_INDEX
size_type m_ADC_INDEX
Definition: TileHWID.h:346
IdDictDictionary
Definition: IdDictDictionary.h:30
TileHWID::adc_context
IdContext adc_context(void) const
idContext for ADCs
Definition: TileHWID.cxx:485
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:206
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: IdDictDictionary.h:216
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:350
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
TileHWID::initLevelsFromDict
int initLevelsFromDict(void)
Definition: TileHWID.cxx:703
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:536
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:817
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:682
TileHWID::is_high_gain
bool is_high_gain(const HWIdentifier &id) const
Test ID for high gain.
Definition: TileHWID.cxx:107
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: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
IdDictRegion::m_implementation
std::vector< IdDictFieldImplementation > m_implementation
Definition: IdDictRegion.h:42
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