ATLAS Offline Software
TTOnlineID.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "CxxUtils/StrFormat.h"
8 #include "GaudiKernel/MsgStream.h"
9 #include "IdDict/IdDictDefs.h"
12 #include <algorithm>
13 #include <cassert>
14 #include <cmath>
15 #include <cstdio>
16 #include <iostream>
17 #include <set>
18 #include <string>
19 
21 
22 
24  m_calo_index(999),
25  m_detzside_index(999),
26  m_l1online_regions_index(999),
27  m_crate_index(999),
28  m_module_index(999),
29  m_submodule_index(999),
30  m_channel_index(999),
31  m_dict(nullptr),
32  m_crateHashMax(0),
33  m_moduleHashMax(0),
34  m_submoduleHashMax(0),
35  m_channelHashMax(0),
36  m_iDetZSideFieldValue(-1)
37 {
38 
39 }
40 
41 TTOnlineID:: ~TTOnlineID()= default;
42 
43 
45 {
47  return {id, 0, m_crate_index};
48 }
49 
51 {
53  return {id, 0, m_module_index};
54 }
55 
57 {
59  return {id, 0, m_submodule_index};
60 }
61 
63 {
65  return {id, 0, m_channel_index};
66 }
67 
68 
69 
70 //==========================================================================
72 //==========================================================================
73 {
74 
75  MsgStream log(m_msgSvc, "TTOnlineID" );
76  std::string strg = "initialize_from_dictionary";
77  if(m_msgSvc) {
78  log << MSG::INFO << strg << endmsg;
79  }
80  else {
81  std::cout << strg << std::endl;
82  }
83 
84  // Check whether this helper should be reinitialized
85  // -------------------------------------------------
86  if (!reinitialize(dict_mgr)) {
87  if(m_msgSvc)log << MSG::DEBUG << "Request to reinitialize not satisfied - tags have not changed"
88  << endmsg;
89  return (0);
90  }
91  else {
92  log << MSG::DEBUG << "(Re)initialize" << endmsg;
93  }
94 
95  // init base object
96  // ----------------
98  return (1);
99  }
100 
101  m_dict = dict_mgr.find_dictionary("Calorimeter");
102 
103  log << MSG::DEBUG << " => defined m_dict from find_dictionary(Calorimeter) = " << m_dict << endmsg;
104  if(!m_dict)
105  {
106  strg = " initialize_from_dictionary - cannot access Calorimeter dictionary";
107  if(m_msgSvc) {
108  //log << MSG::ERROR << strg << endmsg;
109  }
110  else
111  {
112  std::cout << "TTOnlineID::" << strg << std::endl;
113  }
114  return 1;
115  }
116 
117  // Register version of the dictionary used
118  // ---------------------------------------
119  if (register_dict_tag(dict_mgr, "Calorimeter")) return(1);
120 
121  // initialize dictionary version
122  // -----------------------------
123  AtlasDetectorID::setDictVersion(dict_mgr, "Calorimeter");
124 
125 
126  // Initialize the field indices
127  // --------------------------------------
128  if(initLevelsFromDict()) return (1);
129 
130  /* Find value for the field Calorimeter */
131  // ---------------------------------------
132  const IdDictDictionary* atlasDict = dict_mgr.find_dictionary ("ATLAS");
133  int caloValue = -1;
134  if (atlasDict->get_label_value("subdet", "Calorimeter", caloValue)) {
135  std::stringstream strm;
136  strm << atlasDict->m_name;
137  strg= " Could not get value for label 'Calorimeter' of field 'subdet' in dictionary "+strm.str();
138  if(m_msgSvc){
139  log << MSG::ERROR << strg << endmsg;
140  }
141  else{
142  std::cout << "TTOnlineID:" << strg << std::endl;
143  }
144  return (1);
145  }
146  log << MSG::DEBUG << "[init_from_dictionary] > caloValue = "<< caloValue << endmsg;
147 
148  /* Find values for the fake field DetZside */
149  // --------------------------------------
150 
151  // retrieve the calo tag from the DB
152  std::string tag = m_dict->dict_tag();
153  bool oldTag = ( tag.empty() || tag == "CaloIdentifier-DC3-05" || tag == "CaloIdentifier-LVL1-01");
154  log << MSG::DEBUG << "Calorimeter dict. DB tag= " << tag << endmsg;
155 
156  //int detzsideValue = -1;
157  //if (m_dict->get_label_value("DetZside", "no_side", detzsideValue)) {
158  if (m_dict->get_label_value("DetZside", "no_side", m_iDetZSideFieldValue)) {
159  if (!oldTag) {
160  std::stringstream strm;
161  strm << m_dict->m_name;
162  strg = "WARNING : Could not get value for label 'DetZside' in dictionary "+strm.str();
163  if(m_msgSvc) {
164  log << MSG::INFO << strg << endmsg;
165  }
166  else{
167  std::cout << strg << std::endl;
168  }
169  }
170  return (0);
171  }
172  log << MSG::DEBUG << "[init_from_dictionary] > detzsideValue = "<< detzside_field_value() << endmsg;
173 
174 
175  // Set up id for tower and layer's range prefix
176  // ---------------------------------------------
177  // Note: negative value is good enough to get multirange since the
178  // regions are symmetric in +/-eta
179 
180  ExpandedIdentifier reg_id;
181  reg_id.add(caloValue);
182  reg_id.add(detzside_field_value());
183 
184  Range prefix;
185  m_full_crate_range = m_dict->build_multirange(reg_id, prefix, "crate");
186  m_full_module_range = m_dict->build_multirange(reg_id, prefix, "module");
187  m_full_submodule_range = m_dict->build_multirange(reg_id, prefix, "submodule");
188  m_full_channel_range = m_dict->build_multirange(reg_id, prefix, "channel");
189 
190  log << MSG::DEBUG << "[initialize_from_dictionary] > Crate range -> "
191  << (std::string)m_full_crate_range << endmsg;
192  log << MSG::DEBUG << "[initialize_from_dictionary] > Module range -> "
193  << (std::string)m_full_module_range << endmsg;
194  log << MSG::DEBUG << "[initialize_from_dictionary] > SubModule range -> "
195  << (std::string)m_full_submodule_range << endmsg;
196  log << MSG::DEBUG << "[initialize_from_dictionary] > Channel range -> "
197  << (std::string)m_full_channel_range << endmsg;
198 
199 
200  // Setup the hash tables
201  // --------------------------------------
202  if(init_hashes()) return (1);
203  return 0;
204 }
205 
206 
207 //=====================================================================================
209  const IdContext* context) const
210 //=====================================================================================
211 {
212  MsgStream log(m_msgSvc, "TTOnlineID" );
213  // We assume that the context is >= region
214  exp_id.clear();
215  exp_id << calo_field_value();
216  exp_id << detzside_field_value();
217  if(context && context->end_index() >= m_crate_index) {
218  exp_id << crate(id);
219  if(context->end_index() >= m_module_index) {
220  exp_id << module(id);
221  if(context->end_index() >= m_submodule_index) {
222  exp_id << submodule(id);
223  if(context->end_index() >= m_channel_index)
224  exp_id << channel(id);
225  }
226  }
227  }
228  return (0);
229 }
230 
231 
232 //=====================================================================================
233 void TTOnlineID::channel_Id_checks ( int crate, int module, int submodule, int channel ) const
234 //=====================================================================================
235 {
236  // Fill expanded id
237  ExpandedIdentifier id(calo_exp());
238  id << detzside_field_value() << crate << module << submodule << channel;
239  if (!m_full_channel_range.match(id)) {
240  std::string errorMessage = "[TTOnlineID]::channnelId() result is not OK: ID, range = "
241  + std::string(id) + " , " + (std::string)m_full_channel_range;
242  throw CaloID_Exception(errorMessage , 2);
243  }
244 }
245 
246 /* ================================================================*/
247 void TTOnlineID::channel_Id_checks ( const HWIdentifier submoduleId, int channel ) const
248 /* ================================================================*/
249 {
250  // Check that id is within allowed range
251  // Fill expanded id
252  ExpandedIdentifier expId;
253  IdContext context = submoduleContext();
254  if (get_expanded_id(submoduleId, expId, &context)) {
255  std::string errorMessage = "TTOnlineID::channel_Id_checks(submoduleId) result is not OK: ID = "
256  + show_to_string(submoduleId) ;
257  throw CaloID_Exception(errorMessage , 99);
258  }
259 
260  expId << channel;
261  if (!m_full_channel_range.match(expId)) {
262  std::string errorMessage = "TTOnlineID::channel_Id_checks(submoduleId) result is not OK: ID, range = "
263  + std::string(expId) + " , " + (std::string)m_full_channel_range;
264  throw CaloID_Exception(errorMessage , 99);
265  }
266 }
267 
268 /* ================================================================*/
269 void TTOnlineID::channel_Id_checks ( const HWIdentifier moduleId, int submodule, int channel ) const
270 /* ================================================================*/
271 {
272  // Check that id is within allowed range
273  // Fill expanded id
274  ExpandedIdentifier expId;
275  IdContext context = moduleContext();
276  if (get_expanded_id(moduleId, expId, &context)) {
277  std::string errorMessage = "TTOnlineID::channel_Id_checks(moduleId) result is not OK: ID = "
278  + show_to_string(moduleId) ;
279  throw CaloID_Exception(errorMessage , 99);
280  }
281 
282  expId << submodule << channel;
283  if (!m_full_channel_range.match(expId)) {
284  std::string errorMessage = "TTOnlineID::channel_Id_checks(submoduleId) result is not OK: ID, range = "
285  + std::string(expId) + " , " + (std::string)m_full_channel_range;
286  throw CaloID_Exception(errorMessage , 99);
287  }
288 }
289 
290 /* ================================================================*/
291 void TTOnlineID::channel_Id_checks ( const HWIdentifier crateId, int module, int submodule, int channel ) const
292 /* ================================================================*/
293 {
294  // Check that id is within allowed range
295  // Fill expanded id
296  ExpandedIdentifier expId;
297  IdContext context = crateContext();
298  if (get_expanded_id(crateId, expId, &context)) {
299  std::string errorMessage = "TTOnlineID::channel_Id_checks(crateId) result is not OK: ID = "
300  + show_to_string(crateId) ;
301  throw CaloID_Exception(errorMessage , 99);
302  }
303 
304  expId << module << submodule << channel;
305  if (!m_full_channel_range.match(expId)) {
306  std::string errorMessage = "TTOnlineID::channel_Id_checks(crateId) result is not OK: ID, range = "
307  + std::string(expId) + " , " + (std::string)m_full_channel_range;
308  throw CaloID_Exception(errorMessage , 99);
309  }
310 }
311 
312 /* ================================================================*/
313 void TTOnlineID::submodule_Id_checks( int crate, int module, int submodule ) const
314 /* ================================================================*/
315 {
316  // Check that id is within allowed range
317  // Fill expanded id
318  ExpandedIdentifier expId(calo_exp());
319  expId << detzside_field_value() << crate << module << submodule;
320 
321  if (!m_full_submodule_range.match(expId)) { std::string errorMessage = "TTOnlineID::submodule_Id_checks() result is not OK: ID, range = "
322  + std::string(expId) + " , " + (std::string)m_full_submodule_range;
323  throw CaloID_Exception(errorMessage , 99);
324  }
325 }
326 
327 /* ================================================================*/
328 void TTOnlineID::module_Id_checks( int crate, int module ) const
329 /* ================================================================*/
330 {
331  // Check that id is within allowed range
332  // Fill expanded id
333  ExpandedIdentifier expId(calo_exp());
334  expId << detzside_field_value() << crate << module;
335 
336  if (!m_full_module_range.match(expId)) { std::string errorMessage = "TTOnlineID::module_Id_checks() result is not OK: ID, range = "
337  + std::string(expId) + " , " + (std::string)m_full_module_range;
338  throw CaloID_Exception(errorMessage , 99);
339  }
340 }
341 
342 /* ================================================================*/
343 void TTOnlineID::crate_Id_checks( int crate ) const
344 /* ================================================================*/
345 {
346  // Check that id is within allowed range
347  // Fill expanded id
348  ExpandedIdentifier expId(calo_exp());
349  expId << detzside_field_value() << crate;
350 
351  if (!m_full_crate_range.match(expId)) { std::string errorMessage = "TTOnlineID::crate_Id_checks() result is not OK: ID, range = "
352  + std::string(expId) + " , " + (std::string)m_full_crate_range;
353  throw CaloID_Exception(errorMessage , 99);
354  }
355 }
356 
357 
358 //=========================================================
360 //=========================================================
361 {
362  MsgStream log(m_msgSvc, "TTOnlineID" );
363  log << MSG::DEBUG << "[initLevelsFromDict] (0) Entering routine... " << endmsg;
364 
365  if(!m_dict) {
366  log << MSG::INFO << "TTOnlineID::initLevelsFromDict - dictionary NOT initialized "
367  << endmsg ;
368  return (1);
369  }
370 
371  log << MSG::DEBUG << "[initLevelsFromDict] (1) m_dict OK ... " << endmsg;
372 
373  // Find out which identifier field corresponds to each level.
374  // ----------------------------------------------------------
375  m_calo_index = 999 ;
376  m_detzside_index = 999 ;
377  m_crate_index = 999 ;
378  m_module_index = 999 ;
379  m_submodule_index = 999 ;
380  m_channel_index = 999 ;
381 
382  log << MSG::DEBUG << "[initLevelsFromDict] (2) data member initialization OK ... " << endmsg;
383 
384  // retrieve the calo tag from the DB
385  std::string tag = m_dict->dict_tag();
386  bool oldTag = ( tag.empty() || tag == "CaloIdentifier-DC3-05" || tag == "CaloIdentifier-LVL1-01");
387  log << MSG::DEBUG << "Calorimeter dict. DB tag= " << tag << endmsg;
388 
389  // Save index to a Online LVL1 region for unpacking - search with region name
390  IdDictRegion* reg = m_dict->find_region("PPM_Crate-00");
391  if (reg) {
393  else {
394  if(!oldTag) log << MSG::INFO << "WARNING : TTOnlineID::initLevelsFromDict - unable to find 'PPM_Crate-00' region" << endmsg;
395  return (0);
396  }
397  log << MSG::DEBUG << "[initLevelsFromDict] (3) region 'PPM_Crate-00' found OK ... " << m_l1online_regions_index << endmsg;
398 
399  // Look for Fields...
400  // ------------------
401  IdDictField* field = m_dict->find_field("subdet") ;
402  if (field) {
403  m_calo_index = field->m_index;}
404  else {
405  log << MSG::INFO << "TTOnlineID::initLevelsFromDict - unable to find 'Calo' field "
406  << endmsg ;
407  return (1);
408  }
409  log << MSG::DEBUG << "[initLevelsFromDict] (4) field 'Calo' found OK " << endmsg;
410 
411 
412  field = m_dict->find_field("DetZside") ;
413  if (field) {
414  m_detzside_index = field->m_index ;}
415  else {
416  log << MSG::INFO << "TTOnlineID::initLevelsFromDict - unable to find 'DetZside' field "
417  << endmsg ;
418  return (1);
419  }
420  log << MSG::DEBUG << "[initLevelsFromDict] (5) field 'DetZside' found OK " << endmsg;
421 
422 
423  field = m_dict->find_field("crate") ;
424  if (field) {
425  m_crate_index = field->m_index ;}
426  else {
427  log << MSG::INFO << "TTOnlineID::initLevelsFromDict - unable to find 'crate' field "
428  << endmsg ;
429  return (1);
430  }
431  log << MSG::DEBUG << "[initLevelsFromDict] (6) field 'crate' found OK " << endmsg;
432 
433  field = m_dict->find_field("module") ;
434  if (field) {
435  m_module_index = field->m_index ;
436  }
437  else {
438  log << MSG::INFO << "TTOnlineID::initLevelsFromDict - unable to find 'module' field "
439  << endmsg ;
440  return (1);
441  }
442  log << MSG::DEBUG << "[initLevelsFromDict] (7) field 'module' found OK " << endmsg;
443 
444  field = m_dict->find_field("submodule") ;
445  if (field) {
446  m_submodule_index = field->m_index ;
447  }
448  else {
449  log << MSG::INFO << "TTOnlineID::initLevelsFromDict - unable to find 'submodule' field " << endmsg ;
450  return (1);
451  }
452  log << MSG::DEBUG << "[initLevelsFromDict] (8) field 'submodule' found OK " << endmsg;
453 
454  field = m_dict->find_field("channel") ;
455  if (field) {
456  m_channel_index = field->m_index ;
457  }
458  else {
459  log << MSG::INFO << "TTOnlineID::initLevelsFromDict - unable to find 'channel' field " << endmsg;
460  return (1);
461  }
462  log << MSG::DEBUG << "[initLevelsFromDict] (9) field 'channel' found OK " << endmsg;
463 
464 
465  // Set the field implementation
466  // ------------------------------
468  log << MSG::DEBUG << "[initLevelsFromDict] (10) found levels: " << endmsg ;
469  log << MSG::DEBUG << "[initLevelsFromDict] > subdet " << m_calo_index << endmsg ;
470  log << MSG::DEBUG << "[initLevelsFromDict] > detzside " << m_detzside_index << endmsg ;
471  log << MSG::DEBUG << "[initLevelsFromDict] > crate " << m_crate_index << endmsg ;
472  log << MSG::DEBUG << "[initLevelsFromDict] > module " << m_module_index << endmsg ;
473  log << MSG::DEBUG << "[initLevelsFromDict] > submodule " << m_submodule_index << endmsg ;
474  log << MSG::DEBUG << "[initLevelsFromDict] > channel " << m_channel_index << endmsg ;
475 
476  log << MSG::DEBUG << "[initLevelsFromDict] > ...fields implementation... " << endmsg;
477  log << MSG::DEBUG << "[initLevelsFromDict] > ...implementation: m_calo_index " << endmsg;
479 
480  log << MSG::DEBUG << "[initLevelsFromDict] > ...implementation: m_det_side_index " << endmsg;
482 
483  log << MSG::DEBUG << "[initLevelsFromDict] > ...implementation: m_crate_index " << endmsg;
485 
486  log << MSG::DEBUG << "[initLevelsFromDict] > ...implementation: m_module_index " << endmsg;
488  log << MSG::DEBUG << "[initLevelsFromDict] > ...implementation: m_submodule_index " << endmsg;
490  log << MSG::DEBUG << "[initLevelsFromDict] > ...implementation: m_channel_index " << endmsg;
492 
493  if (!m_quiet) {
494  log << MSG::DEBUG << "[initLevelsFromDict] (11) decode index and bit fields for each level: " << endmsg;
495  log << MSG::DEBUG << "[initLevelsFromDict] > calo " << m_calo_impl.show_to_string() << endmsg;
496  log << MSG::DEBUG << "[initLevelsFromDict] > detzside " << m_calo_detzside_impl.show_to_string() << endmsg;
497  log << MSG::DEBUG << "[initLevelsFromDict] > crate " << m_crate_impl.show_to_string() << endmsg;
498  log << MSG::DEBUG << "[initLevelsFromDict] > module " << m_module_impl.show_to_string() << endmsg;
499  log << MSG::DEBUG << "[initLevelsFromDict] > submodule " << m_submodule_impl.show_to_string() << endmsg;
500  log << MSG::DEBUG << "[initLevelsFromDict] > channel " << m_channel_impl.show_to_string() << endmsg;
501  }
502 
503  return(0) ;
504 }
505 
506 
507 //=====================================================
509 //=====================================================
510 {
511  MsgStream log(m_msgSvc, "TTOnlineID" );
512  std::stringstream strm1;
513  std::stringstream strm2;
514  std::stringstream strm3;
515  std::string strg1;
516  std::string strg2;
517  std::string strg3;
518 
519  // Crate hash
520  // -----------
521  {
523  m_crate_vec.resize(m_crateHashMax);
524  unsigned int nids = 0;
525  std::set<HWIdentifier> ids;
526  for (unsigned int i = 0; i < m_full_crate_range.size(); ++i) {
527  const Range& range = m_full_crate_range[i];
529  auto first = rit.begin();
530  auto last = rit.end();
531  for (; first != last; ++first) {
532  const ExpandedIdentifier& exp_id = (*first);
533  HWIdentifier cra_id = crateId( exp_id[m_crate_index] ) ;
534 
535  if(!(ids.insert(cra_id)).second){
536  strm1 << nids;
537  strg1 = "[init_hashes] > duplicated id for channel nb = "+strm1.str();
538  strm3 << show_to_string(cra_id);
539  strg3 = " expanded Id= "+strm3.str();
540  if(m_msgSvc){
541  log << MSG::ERROR << strg1 << endmsg;
542  log << MSG::ERROR << strg3 << endmsg;
543  }
544  else{
545  std::cout << "TTOnlineID::Error" << strg1 << std::endl;
546  std::cout << strg3 << std::endl;
547  }
548  }
549  nids++;
550  }
551  }
552  if(ids.size() != m_crateHashMax) {
553  strm1 << ids.size();
554  strm2 << m_crateHashMax;
555  strg1 = "[init_hashes] >";
556  strg2 = " set size NOT EQUAL to hash max. size "+strm1.str();
557  strg3 = " hash max "+strm2.str();
558  if(m_msgSvc)
559  {
560  log << MSG::ERROR << strg1 << endmsg;
561  log << MSG::ERROR << strg2 << endmsg;
562  log << MSG::ERROR << strg3 << endmsg;
563  }
564  else
565  {
566  std::cout << "TTOnlineID::" << strg1 << std::endl;
567  std::cout << "Error" << strg2 << std::endl;
568  std::cout << strg3 << std::endl;
569  }
570  return (1);
571  }
572 
573  nids=0;
574  std::set<HWIdentifier>::const_iterator first = ids.begin();
575  std::set<HWIdentifier>::const_iterator last = ids.end();
576  for (;first != last && nids < m_crate_vec.size(); ++first) {
577  m_crate_vec[nids] = (*first) ;
578  nids++;
579  }
580  log << MSG::DEBUG << "[init_hashes()] > Crate_size= " << m_crate_vec.size() << endmsg;
581  }
582 
583  // Module hash
584  // -----------
585  {
588  unsigned int nids = 0;
589  std::set<HWIdentifier> ids;
590  for (unsigned int i = 0; i < m_full_module_range.size(); ++i) {
591  const Range& range = m_full_module_range[i];
593  auto first = rit.begin();
594  auto last = rit.end();
595  for (; first != last; ++first) {
596  const ExpandedIdentifier& exp_id = (*first);
597  HWIdentifier mod_id = moduleId(exp_id[m_crate_index], exp_id[m_module_index] ) ;
598 
599  if(!(ids.insert(mod_id)).second){
600  strm1 << nids;
601  strg1 = "[init_hashes] > duplicated id for channel nb = "+strm1.str();
602  strm3 << show_to_string(mod_id);
603  strg3 = " expanded Id= "+strm3.str();
604  if(m_msgSvc){
605  log << MSG::ERROR << strg1 << endmsg;
606  log << MSG::ERROR << strg3 << endmsg;
607  }
608  else{
609  std::cout << "TTOnlineID::Error" << strg1 << std::endl;
610  std::cout << strg3 << std::endl;
611  }
612  }
613  nids++;
614  }
615  }
616  if(ids.size() != m_moduleHashMax) {
617  strm1 << ids.size();
618  strm2 << m_moduleHashMax;
619  strg1 = "[init_hashes] >";
620  strg2 = " set size NOT EQUAL to hash max. size "+strm1.str();
621  strg3 = " hash max "+strm2.str();
622  if(m_msgSvc)
623  {
624  log << MSG::ERROR << strg1 << endmsg;
625  log << MSG::ERROR << strg2 << endmsg;
626  log << MSG::ERROR << strg3 << endmsg;
627  }
628  else
629  {
630  std::cout << "TTOnlineID::" << strg1 << std::endl;
631  std::cout << "Error" << strg2 << std::endl;
632  std::cout << strg3 << std::endl;
633  }
634  return (1);
635  }
636 
637  nids=0;
638  std::set<HWIdentifier>::const_iterator first = ids.begin();
639  std::set<HWIdentifier>::const_iterator last = ids.end();
640  for (;first != last && nids < m_module_vec.size(); ++first) {
641  m_module_vec[nids] = (*first) ;
642  nids++;
643  }
644  log << MSG::DEBUG << "[init_hashes()] > Module_size= " << m_module_vec.size() << endmsg;
645  }
646 
647  // SubModule hash
648  // -----------
649  {
652  unsigned int nids = 0;
653  std::set<HWIdentifier> ids;
654  for (unsigned int i = 0; i < m_full_submodule_range.size(); ++i) {
657  auto first = rit.begin();
658  auto last = rit.end();
659  for (; first != last; ++first) {
660  const ExpandedIdentifier& exp_id = (*first);
661  HWIdentifier submod_id = submoduleId(exp_id[m_crate_index], exp_id[m_module_index], exp_id[m_submodule_index] ) ;
662 
663  if(!(ids.insert(submod_id)).second){
664  strm1 << nids;
665  strg1 = "[init_hashes] > duplicated id for channel nb = "+strm1.str();
666  strm3 << show_to_string(submod_id);
667  strg3 = " expanded Id= "+strm3.str();
668  if(m_msgSvc){
669  log << MSG::ERROR << strg1 << endmsg;
670  log << MSG::ERROR << strg3 << endmsg;
671  }
672  else{
673  std::cout << "TTOnlineID::Error" << strg1 << std::endl;
674  //std::cout << strg2 << std::endl;
675  std::cout << strg3 << std::endl;
676  }
677  }
678  nids++;
679  }
680  }
681  if(ids.size() != m_submoduleHashMax) {
682  strm1 << ids.size();
683  strm2 << m_submoduleHashMax;
684  strg1 = "[init_hashes] >";
685  strg2 = " set size NOT EQUAL to hash max. size "+strm1.str();
686  strg3 = " hash max "+strm2.str();
687  if(m_msgSvc)
688  {
689  log << MSG::ERROR << strg1 << endmsg;
690  log << MSG::ERROR << strg2 << endmsg;
691  log << MSG::ERROR << strg3 << endmsg;
692  }
693  else
694  {
695  std::cout << "TTOnlineID::" << strg1 << std::endl;
696  std::cout << "Error" << strg2 << std::endl;
697  std::cout << strg3 << std::endl;
698  }
699  return (1);
700  }
701 
702  nids=0;
703  std::set<HWIdentifier>::const_iterator first = ids.begin();
704  std::set<HWIdentifier>::const_iterator last = ids.end();
705  for (;first != last && nids < m_submodule_vec.size(); ++first) {
706  m_submodule_vec[nids] = (*first) ;
707  nids++;
708  }
709  log << MSG::DEBUG << "[init_hashes()] > Submodule_size= " << m_submodule_vec.size() << endmsg;
710  }
711 
712  // Channel hash
713  // -----------
714  {
717  unsigned int nids = 0;
718  std::set<HWIdentifier> ids;
719  for (unsigned int i = 0; i < m_full_channel_range.size(); ++i) {
720  const Range& range = m_full_channel_range[i];
722  auto first = rit.begin();
723  auto last = rit.end();
724  for (; first != last; ++first) {
725  const ExpandedIdentifier& exp_id = (*first);
726  HWIdentifier chan_id = channelId(exp_id[m_crate_index], exp_id[m_module_index], exp_id[m_submodule_index], exp_id[m_channel_index]) ;
727 
728  if(!(ids.insert(chan_id)).second){
729  strm1 << nids;
730  strg1 = "[init_hashes] > duplicated id for channel nb = "+strm1.str();
731  strm3 << show_to_string(chan_id);
732  strg3 = " expanded Id= "+strm3.str();
733  if(m_msgSvc){
734  log << MSG::ERROR << strg1 << endmsg;
735  log << MSG::ERROR << strg3 << endmsg;
736  }
737  else{
738  std::cout << "TTOnlineID::Error" << strg1 << std::endl;
739  std::cout << strg3 << std::endl;
740  }
741  }
742  nids++;
743  }
744  }
745  if(ids.size() != m_channelHashMax) {
746  strm1 << ids.size();
747  strm2 << m_channelHashMax;
748  strg1 = "[init_hashes] >";
749  strg2 = " set size NOT EQUAL to hash max. size "+strm1.str();
750  strg3 = " hash max "+strm2.str();
751  if(m_msgSvc)
752  {
753  log << MSG::ERROR << strg1 << endmsg;
754  log << MSG::ERROR << strg2 << endmsg;
755  log << MSG::ERROR << strg3 << endmsg;
756  }
757  else
758  {
759  std::cout << "TTOnlineID::" << strg1 << std::endl;
760  std::cout << "Error" << strg2 << std::endl;
761  std::cout << strg3 << std::endl;
762  }
763  return (1);
764  }
765 
766  nids=0;
767  std::set<HWIdentifier>::const_iterator first = ids.begin();
768  std::set<HWIdentifier>::const_iterator last = ids.end();
769  for (;first != last && nids < m_channel_vec.size(); ++first) {
770  m_channel_vec[nids] = (*first) ;
771  nids++;
772  }
773  log << MSG::DEBUG << "[init_hashes()] > Channel_size= " << m_channel_vec.size() << endmsg;
774  }
775  return (0);
776 }
777 
778 
779 
IdDictDictionary::find_region
IdDictRegion * find_region(const std::string &region_name) const
Definition: IdDictDictionary.cxx:101
IdDictDictionary::dict_tag
const std::string & dict_tag(void) const
Access to the dictionary tag.
Definition: IdDictDictionary.h:262
TTOnlineID::m_channel_impl
IdDictFieldImplementation m_channel_impl
Definition: TTOnlineID.h:204
ConstRangeIterator
Definition: RangeIterator.h:46
TTOnlineID::m_calo_detzside_impl
IdDictFieldImplementation m_calo_detzside_impl
Definition: TTOnlineID.h:200
IdDictDictionary::build_multirange
MultiRange build_multirange() const
Get MultiRange for full dictionary.
Definition: IdDictDictionary.cxx:299
AtlasDetectorID::initialize_from_dictionary
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
Definition: AtlasDetectorID.cxx:320
TTOnlineID::m_submodule_vec
std::vector< HWIdentifier > m_submodule_vec
Definition: TTOnlineID.h:177
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
CaloID_Exception
Exception class for Calo Identifiers.
Definition: CaloID_Exception.h:20
TTOnlineID::crate_Id_checks
void crate_Id_checks(int crate) const
Definition: TTOnlineID.cxx:343
IdDictFieldImplementation::show_to_string
std::string show_to_string(void) const
Definition: IdDictFieldImplementation.cxx:38
TTOnlineID::m_submodule_index
size_type m_submodule_index
Definition: TTOnlineID.h:161
ExpandedIdentifier::add
void add(element_type value)
Append a value into a new field.
TTOnlineID::m_l1online_regions_index
size_type m_l1online_regions_index
Definition: TTOnlineID.h:158
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
TTOnlineID::m_full_channel_range
MultiRange m_full_channel_range
Definition: TTOnlineID.h:168
TTOnlineID::m_crate_index
size_type m_crate_index
Definition: TTOnlineID.h:159
TTOnlineID::submoduleContext
IdContext submoduleContext(void) const
Definition: TTOnlineID.cxx:56
AtlasDetectorID::m_msgSvc
IMessageSvc * m_msgSvc
pointer to the message service
Definition: AtlasDetectorID.h:368
TTOnlineID::initialize_from_dictionary
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr)
Initialization from the identifier dictionary.
Definition: TTOnlineID.cxx:71
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
TTOnlineID::m_module_impl
IdDictFieldImplementation m_module_impl
Definition: TTOnlineID.h:202
HWIdentifier
Definition: HWIdentifier.h:13
TTOnlineID::m_iDetZSideFieldValue
int m_iDetZSideFieldValue
Definition: TTOnlineID.h:180
IdDictDictionary::find_field
IdDictField * find_field(const std::string &name) const
Definition: IdDictDictionary.cxx:45
IdDictRegion
Definition: IdDictRegion.h:20
TTOnlineID::moduleId
HWIdentifier moduleId(int crate, int module) const
(1) create towerId from fields
Definition: TTOnlineID.h:287
IdDictDefs.h
python.PyAthena.module
module
Definition: PyAthena.py:131
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
IdDictMgr
Definition: IdDictMgr.h:14
TTOnlineID::m_module_vec
std::vector< HWIdentifier > m_module_vec
Definition: TTOnlineID.h:176
StrFormat.h
Provide helper functions to create formatted strings.
IdDictMgr::find_dictionary
IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
Definition: IdDictMgr.cxx:115
IdDictRegion::m_index
size_t m_index
Definition: IdDictRegion.h:43
TTOnlineID::~TTOnlineID
~TTOnlineID(void)
lumiFormat.i
int i
Definition: lumiFormat.py:85
TTOnlineID::submoduleId
HWIdentifier submoduleId(int crate, int module, int submodule) const
(1) create towerId from fields
Definition: TTOnlineID.h:341
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TTOnlineID::m_detzside_index
size_type m_detzside_index
Definition: TTOnlineID.h:157
TTOnlineID::m_submoduleHashMax
size_type m_submoduleHashMax
Definition: TTOnlineID.h:172
TTOnlineID::detzside_field_value
int detzside_field_value() const
return the value of the detzside field (initialized in initialize_from_dictionary())
Definition: TTOnlineID.h:483
IdDictDictionary::m_regions
std::vector< IdDictRegion * > m_regions
Definition: IdDictDictionary.h:235
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
ConstRangeIterator::begin
ConstRangeIterator begin() const
Definition: RangeIterator.cxx:18
TTOnlineID::channelContext
IdContext channelContext(void) const
Definition: TTOnlineID.cxx:62
TTOnlineID.h
TTOnlineID::channel_Id_checks
void channel_Id_checks(int crate, int module, int submodule, int channel) const
Definition: TTOnlineID.cxx:233
AtlasDetectorID::m_quiet
bool m_quiet
If true, suppress DEBUG/INFO messages.
Definition: AtlasDetectorID.h:371
TTOnlineID::m_moduleHashMax
size_type m_moduleHashMax
Definition: TTOnlineID.h:171
TTOnlineID::m_crate_impl
IdDictFieldImplementation m_crate_impl
Definition: TTOnlineID.h:201
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
IdDictDictionary::get_label_value
int get_label_value(const std::string &field, const std::string &label, int &value) const
Definition: IdDictDictionary.cxx:73
TTOnlineID::m_full_module_range
MultiRange m_full_module_range
Definition: TTOnlineID.h:166
TTOnlineID::m_calo_index
size_type m_calo_index
Member Data index.
Definition: TTOnlineID.h:156
CxxUtils::strformat
std::string strformat(const char *fmt,...)
return a std::string according to a format fmt and varargs
Definition: StrFormat.cxx:49
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
IdentifierHash.h
RangeIterator.h
TTOnlineID::m_submodule_impl
IdDictFieldImplementation m_submodule_impl
Definition: TTOnlineID.h:203
TTOnlineID::m_calo_impl
IdDictFieldImplementation m_calo_impl
Field Implementation.
Definition: TTOnlineID.h:199
AtlasDetectorID::setDictVersion
virtual void setDictVersion(const IdDictMgr &dict_mgr, const std::string &name) override
Definition: AtlasDetectorID.cxx:759
Range
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition: DetectorDescription/Identifier/Identifier/Range.h:29
TTOnlineID::init_hashes
int init_hashes(void)
Definition: TTOnlineID.cxx:508
IdDictDictionary
Definition: IdDictDictionary.h:30
TTOnlineID::get_expanded_id
int get_expanded_id(const HWIdentifier &id, ExpandedIdentifier &exp_id, const IdContext *context) const
create expanded HWIdentifier from HWIdentifier (return == 0 for OK)
Definition: TTOnlineID.cxx:208
TTOnlineID::moduleContext
IdContext moduleContext(void) const
Definition: TTOnlineID.cxx:50
TTOnlineID::submodule_Id_checks
void submodule_Id_checks(int crate, int module, int submodule) const
Definition: TTOnlineID.cxx:313
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
TTOnlineID::m_full_crate_range
MultiRange m_full_crate_range
Definition: TTOnlineID.h:165
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:574
TTOnlineID::m_channel_index
size_type m_channel_index
Definition: TTOnlineID.h:162
TTOnlineID::initLevelsFromDict
int initLevelsFromDict(void)
init() hashes
Definition: TTOnlineID.cxx:359
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
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TTOnlineID::crateId
HWIdentifier crateId(int crate) const
(1) create towerId from fields
Definition: TTOnlineID.h:234
TTOnlineID::channelId
HWIdentifier channelId(int crate, int module, int submodule, int channel) const
(1) create towerId from fields
Definition: TTOnlineID.h:398
TTOnlineID::crateContext
IdContext crateContext(void) const
context for feedthroughs, feb & channels
Definition: TTOnlineID.cxx:44
TTOnlineID::m_dict
const IdDictDictionary * m_dict
Definition: TTOnlineID.h:164
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
TTOnlineID::m_module_index
size_type m_module_index
Definition: TTOnlineID.h:160
ConstRangeIterator::end
ConstRangeIterator end() const
Definition: RangeIterator.cxx:32
IdDictField
Definition: IdDictField.h:15
MultiRange::cardinality
size_type cardinality() const
Computes a possible cardinality from all ranges.
Definition: MultiRange.cxx:82
TTOnlineID::m_crate_vec
std::vector< HWIdentifier > m_crate_vec
Definition: TTOnlineID.h:175
TTOnlineID::m_channelHashMax
size_type m_channelHashMax
Definition: TTOnlineID.h:173
TTOnlineID::module_Id_checks
void module_Id_checks(int crate, int module) const
Definition: TTOnlineID.cxx:328
TTOnlineID::m_crateHashMax
size_type m_crateHashMax
Definition: TTOnlineID.h:170
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
TTOnlineID::TTOnlineID
TTOnlineID(void)
Definition: TTOnlineID.cxx:23
TTOnlineID::m_full_submodule_range
MultiRange m_full_submodule_range
Definition: TTOnlineID.h:167
TTOnlineID::m_channel_vec
std::vector< HWIdentifier > m_channel_vec
Definition: TTOnlineID.h:178