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