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