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