ATLAS Offline Software
JGTowerBase_ID.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 "IdDict/IdDictField.h"
8 #include "IdDict/IdDictRegion.h"
9 #include "IdDict/IdDictMgr.h"
11 #include "CxxUtils/StrFormat.h"
14 #include <algorithm>
15 #include <cassert>
16 #include <cmath>
17 #include <cstdio>
18 #include <iostream>
19 #include <set>
20 #include <string>
21 
23 
24 
26  const std::string& group) :
28  , m_jgtower_region_index(0)
29  , m_CALO_INDEX(999)
30  , m_DETZSIDE_INDEX(999)
31  , m_SAMPLING_INDEX(999)
32  , m_REGION_INDEX(999)
33  , m_ETA_INDEX(999)
34  , m_PHI_INDEX(999)
35  , m_dict(nullptr)
36  , m_tower_hash_max(0)
37  , m_calo_region_hash_max(0)
38 
39 {
40 
41 }
42 
44 
45 
46 
47 IdContext
49 {
51  return {id, 0, m_REGION_INDEX};
52 }
53 
54 IdContext
56 {
58  return {id, 0, m_PHI_INDEX};
59 }
60 
61 
62 int JGTowerBase_ID::get_id (const IdentifierHash& hash_id, Identifier& id, const IdContext* context) const
63 {
64  int result = 1;
65  id.clear();
66 
67  size_t begin = (context) ? context->begin_index(): 0;
68  // cannot get hash if end is 0:
69  size_t end = (context) ? context->end_index() : 0;
70 
71  if (0 == begin) {
72  if (m_REGION_INDEX == end) {
73  if (hash_id < (unsigned int)(m_region_vec.end() - m_region_vec.begin()))
74  {
75  id = m_region_vec[hash_id];
76  result = 0;
77  }
78  else
79  {
80  ATH_MSG_ERROR("hash_id out of range " << hash_id);
81  }
82  }
83  else if (m_PHI_INDEX == end) {
84  if (hash_id < (unsigned int)(m_tower_vec.end() - m_tower_vec.begin())) {
85  id = m_tower_vec[hash_id];
86  result = 0;
87  }
88  else
89  {
90  ATH_MSG_ERROR("hash_id out of range " << hash_id);
91  }
92  }
93  }
94  return(result);
95 }
96 
97 int JGTowerBase_ID::get_hash (const Identifier& id, IdentifierHash& hash_id, const IdContext* context) const
98 {
99  hash_id = 0;
100  int result = 1;
101 
102  size_t begin = (context) ? context->begin_index(): 0;
103  size_t end = (context) ? context->end_index() : 0;
104 
105  if (0 == begin) {
106  if (m_REGION_INDEX == end) {
107  Identifier redId = region_id (id);
108  std::vector<Identifier>::const_iterator it = std::lower_bound(m_region_vec.begin(),m_region_vec.end(),redId);
109  if ( it != m_region_vec.end() ){
110  hash_id = it - m_region_vec.begin();
111  result = 0;
112  }
113  }
114  else if (m_PHI_INDEX == end) {
115 
116  //Identifier redId = tower_id (id);
117 
118  std::vector<Identifier>::const_iterator it = std::lower_bound(m_tower_vec.begin(),m_tower_vec.end(),id);
119  if ( it != m_tower_vec.end() ){
120  hash_id = it - m_tower_vec.begin();
121  result = 0;
122  }
123  }
124 
125  else {
126  std::string errorMessage =
127  "Error in JGTowerBase_ID::get_hash, invalid context ";
128  throw CaloID_Exception(errorMessage , 10);
129  }
130  }
131 
132  return (result);
133 }
134 
135 
137 {
138  IdentifierHash regHash;
139  IdContext regionContext = region_context();
140  int sc = get_hash(regId, regHash, &regionContext);
141  if (sc!=0) return NOT_VALID;
142  return regHash;
143 }
144 
145 
146 int JGTowerBase_ID::initialize_base_from_dictionary (const IdDictMgr& dict_mgr, const std::string& t_pre)
147 {
148  ATH_MSG_INFO("initialize_from_dictionary");
149 
150  // Check whether this helper should be reinitialized
151  if (!reinitialize(dict_mgr)) {
152  ATH_MSG_DEBUG("Request to reinitialize not satisfied - tags have not changed");
153  return (0);
154  }
155  else {
156  ATH_MSG_DEBUG("(Re)initialize");
157  }
158 
159  // init base object
160  if(AtlasDetectorID::initialize_from_dictionary(dict_mgr)) return (1);
161 
162  // Register version of the Calorimeter dictionary
163  if (register_dict_tag(dict_mgr, "Calorimeter")) return(1);
164 
165  m_dict = dict_mgr.find_dictionary ("Calorimeter");
166  if(!m_dict)
167  {
168  ATH_MSG_ERROR("initialize_from_dict - cannot access Calorimeter dictionary");
169  return(1);
170  }
171 
172  // Initialize the field indices
173  if(initLevelsFromDict(t_pre)) return (1);
174 
175  // Find values for the calo and JGTOWER (neg) fields
176  int caloValue = -1;
177  if (m_dict->get_label_value("subdet", "Calorimeter", caloValue))
178  {
179  ATH_MSG_ERROR("Could not get value for label 'Calorimeter' of field 'subdet' in dictionary " << m_dict->name());
180  return (1);
181  }
182 
183  int jgtowerCaloValue = -1;
184  // negative half
185  // if (m_dict->get_label_value("DetZside", "negative_jgtower_side", jgtowerCaloValue))
186  // positive half FLG 12 Jul 07: negative side -> problem for test beam
187  if (m_dict->get_label_value("DetZside", "positive_lvl1_side", jgtowerCaloValue))
188  {
189  ATH_MSG_ERROR("Could not get value for label 'positive_lvl1_side' of field 'DetZside' in dictionary " << m_dict->name());
190  return (1);
191  }
192 
193  // Set up id for region and range prefix
194  // NOTE: negative value is good enough to get multirange since the
195  // regions are symmetric in +/-eta
196  // FLG Jul 07: EXCEPT FOR CTB !!!!!!!!!!
197 
198  ExpandedIdentifier reg_id;
199  reg_id.add(caloValue);
200  reg_id.add(jgtowerCaloValue);
201  Range prefix;
202  m_full_reg_range = m_dict->build_multirange(reg_id, "Reg_"+t_pre+"ower", prefix, t_pre+"region");
203  m_full_tower_range = m_dict->build_multirange(reg_id, "Reg_"+t_pre+"ower", prefix, t_pre+"phi");
204 
205  // Setup the hash tables
206  if(init_hashes()) return (1);
207 
208  // initialize dictionary regions
209  if (fill_vec_of_dict_regions ("Reg_"+t_pre+"ower")) return 1;
210 
211  // Setup hash tables for finding neighbors
212  if(init_neighbors()) return (1);
213 
214  ATH_MSG_DEBUG("JGTowerBase_ID::initialize_from_dict :");
215  ATH_MSG_DEBUG("tower range -> " << (std::string)m_full_tower_range);
216 
217  // Setup for hash calculation
218 
219  // Regions have uniform eta/phi granularity
220  // The lookup table only needs to contain the
221  // hash offset for each region, the first eta index
222  // and the number of phi cells.
223 
224  // The implementation requires:
225 
226  // 1) a lookup table for each region containing hash offset,
227  // etamin and nphi
228  // 2) a decoder to access the "index" corresponding to the
229  // pnz/samp/reg fields. These fields use 6 bits, so the
230  // vector has a length of 64 for 16 regions.
231 
232 
233  // Create decoder for fields pnz to region
235  m_jgtower_impl.bits() +
239  m_pnz_reg_impl.set_bits(bits, bits_offset);
240  int size = (1 << bits);
241 
242  // Set up vector as lookup table for hash calculation.
243  m_hash_calcs.resize(size);
244 
245  for (unsigned int i = 0; i < m_calo_region_hash_max; ++i) {
246 
247  Identifier regId = region_id(i) ;
248 
249  HashCalc hc;
250 
251  int etamin = eta_min(regId);
252  Identifier min = tower_id ( regId, etamin, 0);
254  hc.m_hash = min_hash;
255  hc.m_etamin = etamin;
256  hc.m_nphi = phi_max(min)+1 ;
258 
259  if (m_pnz_reg_impl.unpack(min) >= size)
260  {
261  ATH_MSG_DEBUG("Min > " << size);
264  }
265  }
266 
267  // Check hash calculation
268  for (unsigned int i = 0; i < m_tower_hash_max; ++i) {
269  Identifier id = tower_id(i);
270  if (tower_hash(id) != i)
271  {
272  ATH_MSG_ERROR("***** Error tower ranges, id, hash, i = " << show_to_string(id));
273  ATH_MSG_ERROR(", " << tower_hash(id));
274  ATH_MSG_ERROR(", " << i);
275  }
276  }
277 
278  return 0;
279 
280 }
281 
282 
283 
284 
285 int JGTowerBase_ID::eta_min(const Identifier regId) const
286 {
287  ExpandedIdentifier expId;
288  IdContext region_cntxt = region_context();
289  if(!get_expanded_id(regId, expId, &region_cntxt)) {
290  int result = -999;
291  for (unsigned int i = 0; i < m_full_tower_range.size(); ++i) {
292  const Range& range = m_full_tower_range[i];
293  if (range.match(expId)) {
294  const Range::field& eta_field = range[m_ETA_INDEX];
295  if (not eta_field.empty()) {
296  int etamin = eta_field.get_minimum();
297  if (-999 == result) {
298  result = etamin;
299  }
300  else {
301  if (etamin < result) result = etamin;
302  }
303  }
304  }
305  }
306  return (result);
307  }
308  return (-999);
309 }
310 
311 int JGTowerBase_ID::eta_max(const Identifier regId) const
312 {
313  ExpandedIdentifier expId;
314  IdContext region_cntxt = region_context();
315  if(!get_expanded_id(regId, expId, &region_cntxt)) {
316  int result = -999;
317  for (unsigned int i = 0; i < m_full_tower_range.size(); ++i) {
318  const Range& range = m_full_tower_range[i];
319  if (range.match(expId)) {
320  const Range::field& eta_field = range[m_ETA_INDEX];
321  if (not eta_field.empty()) {
322  int etamax = eta_field.get_maximum();
323  if (result < etamax) result = etamax;
324  }
325  }
326  }
327  return (result);
328  }
329  return (-999); // default
330 }
331 
332 int JGTowerBase_ID::phi_max(const Identifier regId) const
333 {
334  ExpandedIdentifier expId;
335  IdContext region_cntxt = region_context();
336  if(!get_expanded_id(regId, expId, &region_cntxt)) {
337  int result = -999;
338  for (unsigned int i = 0; i < m_full_tower_range.size(); ++i) {
339  const Range& range = m_full_tower_range[i];
340  if (range.match(expId)) {
341  const Range::field& phi_field = range[m_PHI_INDEX];
342  if (not phi_field.empty()) {
343  int phimax = phi_field.get_maximum();
344  if (result < phimax) result = phimax;
345  }
346  }
347  }
348  return (result);
349  }
350  return (-999); // default
351 }
352 
354 {
355  IdentifierHash regHash = calo_region_hash(regId);
356  if (regHash >= m_vecOfDictRegions.size()) return NOT_VALID;
357  return m_vecOfDictRegions[regHash]->deta();
358 }
359 
361 {
362  IdentifierHash regHash = calo_region_hash(regId);
363  if (regHash >= m_vecOfDictRegions.size()) return NOT_VALID;
364  return m_vecOfDictRegions[regHash]->dphi();
365 }
366 
367 float JGTowerBase_ID::eta0(const Identifier regId) const
368 {
369  IdentifierHash regHash = calo_region_hash(regId);
370  if (regHash >= m_vecOfDictRegions.size()) return NOT_VALID;
371  return m_vecOfDictRegions[regHash]->eta0();
372 }
373 
374 float JGTowerBase_ID::phi0(const Identifier regId) const
375 {
376  IdentifierHash regHash = calo_region_hash(regId);
377  if (regHash >= m_vecOfDictRegions.size()) return NOT_VALID;
378  return m_vecOfDictRegions[regHash]->phi0();
379 }
380 
381 int
383 {
384  unsigned short index = id;
385  if (index < m_prev_phi_vec.size()) {
386  if (m_prev_phi_vec[index] == NOT_VALID_HASH) return (1);
387  prev = m_prev_phi_vec[index];
388  return (0);
389  }
390  return (1);
391 }
392 
393 int
395 {
396  unsigned short index = id;
397  if (index < m_next_phi_vec.size()) {
398  if (m_next_phi_vec[index] == NOT_VALID_HASH) return (1);
400  return (0);
401  }
402  return (1);
403 }
404 
405 int
407 {
408  unsigned short index = id;
409  if (index < m_prev_eta_vec.size()) {
410  if (m_prev_eta_vec[index] == NOT_VALID_HASH) return (1);
411  prev = m_prev_eta_vec[index];
412  return (0);
413  }
414  return (1);
415 }
416 
417 int
419 {
420  unsigned short index = id;
421  if (index < m_next_eta_vec.size()) {
422  if (m_next_eta_vec[index] == NOT_VALID_HASH) return (1);
424  return (0);
425  }
426  return (1);
427 }
428 
429 
430 int JGTowerBase_ID::get_expanded_id (const Identifier& id, ExpandedIdentifier& exp_id, const IdContext* context) const
431 {
432  // We assume that the context is >= region
433  exp_id.clear();
434  exp_id << calo_field_value()
435  << pos_neg(id)
436  << sampling(id)
437  << region(id);
438  if(context && context->end_index() >= m_ETA_INDEX) {
439  exp_id << eta(id);
440  if(context->end_index() >= m_PHI_INDEX) {
441  exp_id << phi(id);
442  }
443  }
444  return (0);
445 }
446 void JGTowerBase_ID::tower_id_checks ( int pos_neg, int sampling, int region,
447  int eta, int phi ) const
448 {
449  // Fill expanded id
451  id << pos_neg << sampling <<
452  region << eta << phi;
453 
454  if (!m_full_tower_range.match(id)) {
455  std::string errorMessage = "JGTowerBase_ID::tower_id() result is not OK: ID, range = "
456  + std::string(id) + " , " + (std::string)m_full_tower_range;
457  throw CaloID_Exception(errorMessage , 2);
458  }
459 }
460 
462  int eta, int phi ) const
463 {
464  // Fill expanded id
466 
467  IdContext context = region_context();
468  if (get_expanded_id(regionId, id, &context)) {
469  std::string errorMessage = "JGTowerBase_ID::tower_id(regionId) result is not OK: ID= "
470  + show_to_string(regionId) ;
471  throw CaloID_Exception(errorMessage , 2);
472  }
473 
474  id << eta << phi;
475 
476  if (!m_full_tower_range.match(id)) {
477  std::string errorMessage = "JGTowerBase_ID::tower_id(regionId,field values) result is not OK: ID, range = "
478  + std::string(id) + " , " + (std::string)m_full_tower_range;
479  throw CaloID_Exception(errorMessage , 2);
480  }
481 }
482 
483 void JGTowerBase_ID::region_id_checks (int pos_neg, int sampling, int region)const
484 {
485  // Fill expanded id
487  id << pos_neg << sampling << region ;
488 
489  if (!m_full_reg_range.match(id)) {
490  std::string errorMessage = "JGTowerBase_ID::region_id() result is not OK: ID, range = "
491  + std::string(id) + " , " + (std::string)m_full_reg_range;
492  throw CaloID_Exception(errorMessage , 2);
493  }
494 }
495 
496 int JGTowerBase_ID::initLevelsFromDict(const std::string& t_pre)
497 {
498  if(!m_dict)
499  {
500  ATH_MSG_ERROR("initLevelsFromDict - dictionary NOT initialized");
501  return (1);
502  }
503 
504  // Find out which identifier field corresponds to each level.
505 
506  m_CALO_INDEX = 999 ;
507  m_DETZSIDE_INDEX = 999 ;
508  m_SAMPLING_INDEX = 999 ;
509  m_REGION_INDEX = 999 ;
510  m_ETA_INDEX = 999 ;
511  m_PHI_INDEX = 999 ;
512 
513  // Save index to a JGTOWER region for unpacking - search with region name
514  const IdDictRegion* reg = m_dict->find_region(t_pre+"ower_0");
515  if (reg)
516  {
517  m_jgtower_region_index = reg->index();
518  }
519  else
520  {
521  ATH_MSG_ERROR("initLevelsFromDict - unable to find jgtower region");
522  return (1);
523  }
524 
525  // Find a JGTOWER region
526  const IdDictField* field = m_dict->find_field("subdet") ;
527  if (field) {
528  m_CALO_INDEX = field->index();
529  }
530  else
531  {
532  ATH_MSG_ERROR("initLevelsFromDict - unable to find 'subdet' field");
533  return (1);
534  }
535 
536  field = m_dict->find_field("DetZside") ;
537  if (field) {
538  m_DETZSIDE_INDEX = field->index();
539  }
540  else
541  {
542  ATH_MSG_ERROR("initLevelsFromDict - unable to find 'DetZside' field");
543  return (1);
544  }
545 
546  field = m_dict->find_field(t_pre+"sampling") ;
547  if (field) {
548  m_SAMPLING_INDEX = field->index();
549  }
550  else
551  {
552  ATH_MSG_ERROR("initLevelsFromDict - unable to find '" << t_pre << "sampling' field");
553  return (1);
554  }
555 
556  field = m_dict->find_field(t_pre+"region") ;
557  if (field) {
558  m_REGION_INDEX = field->index();
559  }
560  else
561  {
562  ATH_MSG_ERROR("initLevelsFromDict - unable to find 'region' field");
563  return (1);
564  }
565 
566  field = m_dict->find_field(t_pre+"eta") ;
567  if (field) {
568  m_ETA_INDEX = field->index();
569  }
570  else
571  {
572  ATH_MSG_ERROR("initLevelsFromDict - unable to find 'eta' field");
573  return (1);
574  }
575 
576  field = m_dict->find_field(t_pre+"phi") ;
577  if (field) {
578  m_PHI_INDEX = field->index();
579  }
580  else
581  {
582  ATH_MSG_ERROR("initLevelsFromDict - unable to find 'phi' field");
583  return (1);
584  }
585  // Set the field implementations
586 
588 
589  m_calo_impl = region.implementation(m_CALO_INDEX);
590  m_jgtower_impl = region.implementation(m_DETZSIDE_INDEX);
591  m_sampling_impl = region.implementation(m_SAMPLING_INDEX);
592  m_region_impl = region.implementation(m_REGION_INDEX);
593  m_eta_impl = region.implementation(m_ETA_INDEX);
594  m_phi_impl = region.implementation(m_PHI_INDEX);
595 
596  ATH_MSG_DEBUG("decode index and bit fields for each level:");
598  ATH_MSG_DEBUG("detzside " << m_jgtower_impl.show_to_string());
599  ATH_MSG_DEBUG("sampling " << m_sampling_impl.show_to_string());
603 
604  return(0) ;
605 }
606 
607 
609 {
610  // tower hash
613  unsigned int nids = 0;
614  std::set<Identifier> ids;
615  for (unsigned int i = 0; i < m_full_tower_range.size(); ++i) {
616  const Range& range = m_full_tower_range[i];
618  auto first = rit.begin();
619  auto last = rit.end();
620  for (; first != last; ++first) {
621  const ExpandedIdentifier& exp_id = (*first);
622  Identifier tow_id = tower_id ( exp_id[m_DETZSIDE_INDEX],
623  exp_id[m_SAMPLING_INDEX],
624  exp_id[m_REGION_INDEX] ,
625  exp_id[m_ETA_INDEX] ,
626  exp_id[m_PHI_INDEX] ) ;
627  if(!(ids.insert(tow_id)).second)
628  {
629  ATH_MSG_ERROR("init_hashes duplicated id for J/GTower id. nids= " << nids << " compact Id " << show_to_string(tow_id));
630  }
631  nids++;
632  }
633  }
634  if(ids.size() != m_tower_hash_max)
635  {
636  ATH_MSG_ERROR("init_hashes set size NOT EQUAL to hash max. size " << ids.size() << " hash max " << m_tower_hash_max);
637  return (1);
638  }
639 
640  nids=0;
641  std::set<Identifier>::const_iterator first = ids.begin();
642  std::set<Identifier>::const_iterator last = ids.end();
643  for (;first != last && nids < m_tower_vec.size(); ++first) {
644  m_tower_vec[nids] = (*first) ;
645  nids++;
646  }
647  // region hash
650  nids = 0;
651  ids.clear();
652  for (unsigned int i = 0; i < m_full_reg_range.size(); ++i) {
653  const Range& range = m_full_reg_range[i];
655  auto first = rit.begin();
656  auto last = rit.end();
657  for (; first != last; ++first) {
658  const ExpandedIdentifier& exp_id = (*first);
659  Identifier reg_id = region_id ( exp_id[m_DETZSIDE_INDEX],
660  exp_id[m_SAMPLING_INDEX],
661  exp_id[m_REGION_INDEX] );
662  if(!(ids.insert(reg_id)).second)
663  {
664  ATH_MSG_ERROR("init_hashes duplicated id for region id. nids= " << nids << " compact Id " << show_to_string(reg_id));
665  }
666  nids++;
667  }
668  }
669  if(ids.size() != m_calo_region_hash_max)
670  {
671  ATH_MSG_ERROR("init_hashes set size NOT EQUAL to region hash max. size " << ids.size() << " region hash max " << m_calo_region_hash_max);
672  return (1);
673  }
674  nids=0;
675  first = ids.begin();
676  last = ids.end();
677  for (;first != last && nids < m_region_vec.size(); ++first) {
678  m_region_vec[nids] = (*first) ;
679  nids++;
680  }
681 
682  return (0);
683 }
684 
685 
686 
688 {
693  for (unsigned int i = 0; i < m_full_tower_range.size(); ++i) {
694  const Range& range = m_full_tower_range[i];
695  const Range::field& eta_field = range[m_ETA_INDEX];
696  const Range::field& phi_field = range[m_PHI_INDEX];
698  auto first = rit.begin();
699  auto last = rit.end();
700  for (; first != last; ++first) {
701  const ExpandedIdentifier& exp_id = (*first);
706  bool peta = eta_field.get_previous(exp_id[m_ETA_INDEX], previous_eta);
707  bool neta = eta_field.get_next (exp_id[m_ETA_INDEX], next_eta);
708  bool pphi = phi_field.get_previous(exp_id[m_PHI_INDEX], previous_phi);
709  bool nphi = phi_field.get_next (exp_id[m_PHI_INDEX], next_phi);
710 
711  IdContext tcontext = tower_context();
712 
713  // Get and save region id to speed things up
714  Identifier reg_id = region_id ( exp_id[m_DETZSIDE_INDEX],
715  exp_id[m_SAMPLING_INDEX],
716  exp_id[m_REGION_INDEX] );
717 
718  // First get primary hash id
719  IdentifierHash hash_id;
720  Identifier id = tower_id (reg_id,
721  exp_id[m_ETA_INDEX],
722  exp_id[m_PHI_INDEX]);
723  if (get_hash(id, hash_id,&tcontext))
724  {
725  ATH_MSG_ERROR("init_neighbors - unable to get hash, compact");
726  return (1);
727  }
728 
729  // index for the subsequent arrays
730  unsigned short index = hash_id;
731  assert (hash_id < m_prev_phi_vec.size());
732  assert (hash_id < m_next_phi_vec.size());
733  assert (hash_id < m_prev_eta_vec.size());
734  assert (hash_id < m_next_eta_vec.size());
735 
736  if (pphi) {
737  // Get previous phi hash id
738  id = tower_id (reg_id,
739  exp_id[m_ETA_INDEX],
740  previous_phi);
741  // forward to compact -> hash
742  if (get_hash(id, hash_id,&tcontext))
743  {
744  ATH_MSG_ERROR("init_neighbors - unable to get previous phi hash, exp/compact");
745  return (1);
746  }
747  m_prev_phi_vec[index] = hash_id;
748  }
749 
750  if (nphi) {
751  // Get next phi hash id
752  id = tower_id (reg_id,
753  exp_id[m_ETA_INDEX],
754  next_phi);
755  // forward to compact -> hash
756  if (get_hash(id, hash_id,&tcontext))
757  {
758  ATH_MSG_ERROR("init_neighbors - unable to get next phi hash, exp/compact");
759  return (1);
760  }
761  m_next_phi_vec[index] = hash_id;
762  }
763  if (peta) {
764  // Get previous eta hash id
765  id = tower_id (reg_id,
766  previous_eta,
767  exp_id[m_PHI_INDEX]);
768  // forward to compact -> hash
769  if (get_hash(id, hash_id,&tcontext))
770  {
771  ATH_MSG_ERROR("init_neighbors - unable to get previous eta hash, exp/compact");
772  return (1);
773  }
774  m_prev_eta_vec[index] = hash_id;
775  }
776 
777  if (neta) {
778  // Get next eta hash id
779  id = tower_id (reg_id,
780  next_eta,
781  exp_id[m_PHI_INDEX]);
782  // forward to compact -> hash
783  if (get_hash(id, hash_id,&tcontext))
784  {
785  ATH_MSG_ERROR("init_neighbors - unable to get next eta hash, exp/compact");
786  return (1);
787  }
788  m_next_eta_vec[index] = hash_id;
789  } // end neta cond
790  } // end loop on identifiers
791  } // end loop on ranges
792  return (0);
793 }
794 
795 int
797 {
798  m_vecOfDictRegions.clear();
800  IdContext region_cntxt = region_context();
801  ExpandedIdentifier expRegId;
802  for (unsigned int i = 0; i < m_calo_region_hash_max; ++i) {
803  Identifier id = region_id(i);
804  if(!get_expanded_id(id, expRegId, &region_cntxt)) {
805  m_vecOfDictRegions.push_back (m_dict->find_region(expRegId,group_name));
806  }
807  }
808  //assert (m_vecOfDictRegions.size() == regions().hash_max());
809  return 0;
810 }
IdDictMgr.h
JGTowerBase_ID::get_prev_in_phi
int get_prev_in_phi(const IdentifierHash &id, IdentifierHash &prev) const
access to hashes for neighbours in phi – towers only (no extended) return == 0 for neighbours found
Definition: JGTowerBase_ID.cxx:382
ConstRangeIterator
Definition: RangeIterator.h:46
JGTowerBase_ID::m_vecOfDictRegions
std::vector< const IdDictRegion * > m_vecOfDictRegions
List of IdDictRegion objects.
Definition: JGTowerBase_ID.h:327
JGTowerBase_ID::eta
int eta(const Identifier id) const
return eta according to :
Definition: JGTowerBase_ID.h:484
IdDictDictionary::build_multirange
MultiRange build_multirange() const
Get MultiRange for full dictionary.
Definition: IdDictDictionary.cxx:309
JGTowerBase_ID::fill_vec_of_dict_regions
int fill_vec_of_dict_regions(const std::string &group_name="")
Definition: JGTowerBase_ID.cxx:796
AtlasDetectorID::initialize_from_dictionary
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
Definition: AtlasDetectorID.cxx:257
get_generator_info.result
result
Definition: get_generator_info.py:21
JGTowerBase_ID::phi0
float phi0(const Identifier regId) const
Return the minimum phi of region, or NOT_VALID.
Definition: JGTowerBase_ID.cxx:374
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
JGTowerBase_ID::m_prev_eta_vec
std::vector< unsigned short > m_prev_eta_vec
Definition: JGTowerBase_ID.h:323
CaloID_Exception
Exception class for Calo Identifiers.
Definition: CaloID_Exception.h:20
IdDictFieldImplementation::show_to_string
std::string show_to_string(void) const
Definition: IdDictFieldImplementation.cxx:32
JGTowerBase_ID::tower_id_checks
void tower_id_checks(int pos_neg, int sampling, int region, int eta, int phi) const
Definition: JGTowerBase_ID.cxx:446
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
JGTowerBase_ID::calo_region_hash
IdentifierHash calo_region_hash(const Identifier id) const
Definition: JGTowerBase_ID.cxx:136
index
Definition: index.py:1
IdDictDictionary::region
const IdDictRegion & region(size_t i) const
Region at index i.
Definition: IdDictDictionary.h:354
JGTowerBase_ID::HashCalc::m_etamin
size_type m_etamin
Definition: JGTowerBase_ID.h:342
JGTowerBase_ID::tower_hash
IdentifierHash tower_hash(Identifier towerId) const
create hash id from tower id
Definition: JGTowerBase_ID.h:586
IdentifierField::get_minimum
element_type get_minimum() const
Query the values.
Definition: IdentifierField.h:121
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
IdDictDictionary.h
JGTowerBase_ID::phi
int phi(const Identifier id) const
return phi according to :
Definition: JGTowerBase_ID.h:490
IdContext::end_index
size_type end_index() const
Definition: IdContext.h:46
AtlasDetectorID::calo_field_value
int calo_field_value() const
Definition: AtlasDetectorID.h:476
JGTowerBase_ID::get_hash
virtual int get_hash(const Identifier &id, IdentifierHash &hash_id, const IdContext *context=0) const
create hash id from compact id (return == 0 for OK)
Definition: JGTowerBase_ID.cxx:97
JGTowerBase_ID::m_sampling_impl
IdDictFieldImplementation m_sampling_impl
Definition: JGTowerBase_ID.h:351
ExpandedIdentifier::add
void add(element_type value)
Append a value into a new field.
skel.it
it
Definition: skel.GENtoEVGEN.py:407
ReadBchFromCrest.begin
begin
Definition: ReadBchFromCrest.py:80
JGTowerBase_ID::m_next_eta_vec
std::vector< unsigned short > m_next_eta_vec
Definition: JGTowerBase_ID.h:324
JGTowerBase_ID::sampling
int sampling(const Identifier id) const
return sampling according to :
Definition: JGTowerBase_ID.h:473
IdDictDictionary::find_field
const IdDictField * find_field(const std::string &name) const
Definition: IdDictDictionary.cxx:47
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
JGTowerBase_ID::region
int region(const Identifier id) const
return region according to :
Definition: JGTowerBase_ID.h:478
JGTowerBase_ID::tower_context
IdContext tower_context() const
access to IdContext's which define which levels of fields are contained in the id
Definition: JGTowerBase_ID.cxx:55
JGTowerBase_ID::phi_max
int phi_max(const Identifier regId) const
min value of phi index (-999 == failure)
Definition: JGTowerBase_ID.cxx:332
JGTowerBase_ID::get_prev_in_eta
int get_prev_in_eta(const IdentifierHash &id, IdentifierHash &prev) const
access to hashes for neighbours in eta – towers only (no extended) return == 0 for neighbours found
Definition: JGTowerBase_ID.cxx:406
IdentifierField::get_maximum
element_type get_maximum() const
Definition: IdentifierField.h:130
JGTowerBase_ID::region_context
IdContext region_context() const
access to IdContext's which define which levels of fields are contained in the id
Definition: JGTowerBase_ID.cxx:48
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
JGTowerBase_ID::m_PHI_INDEX
size_type m_PHI_INDEX
Definition: JGTowerBase_ID.h:311
IdDictDictionary::name
const std::string & name() const
Dictionary name.
Definition: IdDictDictionary.h:336
JGTowerBase_ID::m_region_impl
IdDictFieldImplementation m_region_impl
Definition: JGTowerBase_ID.h:352
JGTowerBase_ID::m_CALO_INDEX
size_type m_CALO_INDEX
Definition: JGTowerBase_ID.h:306
JGTowerBase_ID::m_region_vec
std::vector< Identifier > m_region_vec
Definition: JGTowerBase_ID.h:320
JGTowerBase_ID::m_pnz_reg_impl
IdDictFieldImplementation m_pnz_reg_impl
Definition: JGTowerBase_ID.h:356
IdDictFieldImplementation::unpack
int unpack(Identifier id) const
Identifier manipulation methods.
Definition: IdDictFieldImplementation.h:152
JGTowerBase_ID::m_prev_phi_vec
std::vector< unsigned short > m_prev_phi_vec
Definition: JGTowerBase_ID.h:321
JGTowerBase_ID::get_next_in_eta
int get_next_in_eta(const IdentifierHash &id, IdentifierHash &next) const
access to hashes for neighbours in eta – towers only (no extended) return == 0 for neighbours found
Definition: JGTowerBase_ID.cxx:418
JGTowerBase_ID::m_full_reg_range
MultiRange m_full_reg_range
Definition: JGTowerBase_ID.h:315
IdDictRegion
Definition: IdDictRegion.h:21
JGTowerBase_ID::m_calo_region_hash_max
size_type m_calo_region_hash_max
Definition: JGTowerBase_ID.h:318
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
JGTowerBase_ID::m_hash_calcs
std::vector< HashCalc > m_hash_calcs
Definition: JGTowerBase_ID.h:345
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
JGTowerBase_ID::m_SAMPLING_INDEX
size_type m_SAMPLING_INDEX
Definition: JGTowerBase_ID.h:308
JGTowerBase_ID::m_jgtower_region_index
size_type m_jgtower_region_index
Definition: JGTowerBase_ID.h:305
JGTowerBase_ID::initialize_base_from_dictionary
virtual int initialize_base_from_dictionary(const IdDictMgr &dict_mgr, const std::string &t_pre)
initialization from the identifier dictionary
Definition: JGTowerBase_ID.cxx:146
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
IdDictDictionary::find_region
const IdDictRegion * find_region(const std::string &region_name) const
Definition: IdDictDictionary.cxx:114
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
IdDictMgr
Definition: IdDictMgr.h:16
IdContext::begin_index
size_type begin_index() const
Definition: IdContext.h:45
StrFormat.h
Provide helper functions to create formatted strings.
JGTowerBase_ID::HashCalc
small class holding the starting hash value, the min eta and the number of phi bins of each region
Definition: JGTowerBase_ID.h:335
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
IdentifierField::empty
bool empty() const
If true, this field does not have any constraints, and may hold any value representable by element_ty...
Definition: IdentifierField.h:182
lumiFormat.i
int i
Definition: lumiFormat.py:85
IdDictFieldImplementation::set_bits
void set_bits(size_type bits, size_type bits_offset)
Definition: IdDictFieldImplementation.h:283
JGTowerBase_ID::JGTowerBase_ID
JGTowerBase_ID(const std::string &name, const std::string &group)
Definition: JGTowerBase_ID.cxx:25
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
JGTowerBase_ID::HashCalc::m_nphi
size_type m_nphi
Definition: JGTowerBase_ID.h:343
IdDictFieldImplementation::bits_offset
size_type bits_offset() const
Definition: IdDictFieldImplementation.h:213
JGTowerBase_ID::m_tower_vec
std::vector< Identifier > m_tower_vec
Definition: JGTowerBase_ID.h:319
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
mc.group_name
group_name
Definition: mc.PhPy8EG_A14NNPDF23_NNLOPS_example.py:33
IdentifierField::get_next
bool get_next(element_type current, element_type &next) const
Definition: IdentifierField.cxx:149
ConstRangeIterator::begin
ConstRangeIterator begin() const
Definition: RangeIterator.cxx:18
JGTowerBase_ID::m_REGION_INDEX
size_type m_REGION_INDEX
Definition: JGTowerBase_ID.h:309
JGTowerBase_ID::~JGTowerBase_ID
virtual ~JGTowerBase_ID()
JGTowerBase_ID::init_hashes
int init_hashes()
Definition: JGTowerBase_ID.cxx:608
JGTowerBase_ID::m_next_phi_vec
std::vector< unsigned short > m_next_phi_vec
Definition: JGTowerBase_ID.h:322
JGTowerBase_ID::eta0
float eta0(const Identifier regId) const
Return the minimum eta of region, or NOT_VALID.
Definition: JGTowerBase_ID.cxx:367
JGTowerBase_ID::m_dict
const IdDictDictionary * m_dict
Definition: JGTowerBase_ID.h:313
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:203
JGTowerBase_ID::region_id_checks
void region_id_checks(int pos_neg, int sampling, int region) const
Definition: JGTowerBase_ID.cxx:483
IdDictDictionary::get_label_value
int get_label_value(const std::string &field, const std::string &label, int &value) const
Definition: IdDictDictionary.cxx:92
JGTowerBase_ID::init_neighbors
int init_neighbors()
Definition: JGTowerBase_ID.cxx:687
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
JGTowerBase_ID::region_id
Identifier region_id(int pos_neg, int sampling, int region) const
build a region (of towers) identifier
Definition: JGTowerBase_ID.h:573
IdentifierHash.h
JGTowerBase_ID::m_jgtower_impl
IdDictFieldImplementation m_jgtower_impl
Definition: JGTowerBase_ID.h:350
JGTowerBase_ID::m_ETA_INDEX
size_type m_ETA_INDEX
Definition: JGTowerBase_ID.h:310
RangeIterator.h
Range
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition: DetectorDescription/Identifier/Identifier/Range.h:29
AtlasDetectorID::calo_exp
ExpandedIdentifier calo_exp(void) const
Definition: AtlasDetectorID.cxx:1070
JGTowerBase_ID::m_tower_hash_max
size_type m_tower_hash_max
Definition: JGTowerBase_ID.h:317
JGTowerBase_ID::get_id
virtual int get_id(const IdentifierHash &hash_id, Identifier &id, const IdContext *context=0) const
create compact id from hash id (return == 0 for OK)
Definition: JGTowerBase_ID.cxx:62
JGTowerBase_ID::m_DETZSIDE_INDEX
size_type m_DETZSIDE_INDEX
Definition: JGTowerBase_ID.h:307
JGTowerBase_ID::tower_id
Identifier tower_id(int pos_neg, int sampling, int region, int eta, int phi) const
build a tower identifier
Definition: JGTowerBase_ID.h:384
MultiRange::match
int match(const ExpandedIdentifier &id) const
Match an identifier.
Definition: MultiRange.cxx:57
JGTowerBase_ID::get_next_in_phi
int get_next_in_phi(const IdentifierHash &id, IdentifierHash &next) const
access to hashes for neighbours in phi – towers only (no extended) return == 0 for neighbours found
Definition: JGTowerBase_ID.cxx:394
DeMoScan.index
string index
Definition: DeMoScan.py:362
AtlasDetectorID::reinitialize
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
Definition: AtlasDetectorID.cxx:223
IdDictField.h
JGTowerBase_ID::NOT_VALID_HASH
@ NOT_VALID_HASH
Definition: JGTowerBase_ID.h:287
IdDictMgr::find_dictionary
const IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
Definition: IdDictMgr.cxx:116
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
JGTowerBase_ID::pos_neg
int pos_neg(const Identifier id) const
return pos_neg according to :
Definition: JGTowerBase_ID.h:467
JGTowerBase_ID::tower_hash_binary_search
IdentifierHash tower_hash_binary_search(Identifier towerId) const
create hash id from tower id – method NOT optimised, please use tower_hash() above
Definition: JGTowerBase_ID.h:593
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:367
JGTowerBase_ID::eta_max
int eta_max(const Identifier regId) const
max value of eta index (-999 == failure)
Definition: JGTowerBase_ID.cxx:311
MultiRange::size
size_type size() const
Definition: MultiRange.cxx:70
DeMoScan.first
bool first
Definition: DeMoScan.py:534
JGTowerBase_ID::HashCalc::m_hash
IdentifierHash m_hash
Definition: JGTowerBase_ID.h:341
JGTowerBase_ID::initLevelsFromDict
int initLevelsFromDict(const std::string &t_pre)
Definition: JGTowerBase_ID.cxx:496
JGTowerBase_ID::eta_min
int eta_min(const Identifier regId) const
min value of eta index (-999 == failure)
Definition: JGTowerBase_ID.cxx:285
IdentifierField
This is the individual specification for the range of one ExpandedIdentifier IdentifierField.
Definition: IdentifierField.h:83
JGTowerBase_ID::get_expanded_id
int get_expanded_id(const Identifier &id, ExpandedIdentifier &exp_id, const IdContext *context) const
create expanded Identifier from Identifier (return == 0 for OK)
Definition: JGTowerBase_ID.cxx:430
ExpandedIdentifier::clear
void clear()
Erase all fields.
IdentifierField::get_previous
bool get_previous(element_type current, element_type &previous) const
Returns false if previous/next is at end of range, or not possible.
Definition: IdentifierField.cxx:106
JGTowerBase_ID::phiGranularity
float phiGranularity(const Identifier regId) const
Return the phi granularity of a region, or NOT_VALID.
Definition: JGTowerBase_ID.cxx:360
IdDictRegion::index
size_t index() const
Definition: IdDictRegion.h:175
IdDictRegion.h
JGTowerBase_ID::m_phi_impl
IdDictFieldImplementation m_phi_impl
Definition: JGTowerBase_ID.h:354
ConstRangeIterator::end
ConstRangeIterator end() const
Definition: RangeIterator.cxx:32
IdDictField
Definition: IdDictField.h:16
MultiRange::cardinality
size_type cardinality() const
Computes a possible cardinality from all ranges.
Definition: MultiRange.cxx:82
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
LArCellBinning.etamin
etamin
Definition: LArCellBinning.py:137
ExpandedIdentifier::element_type
int element_type
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:106
JGTowerBase_ID::m_full_tower_range
MultiRange m_full_tower_range
Definition: JGTowerBase_ID.h:316
JGTowerBase_ID::m_calo_impl
IdDictFieldImplementation m_calo_impl
Definition: JGTowerBase_ID.h:349
JGTowerBase_ID.h
Factor out code common between JTower_ID and GTower_ID.
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition: IdContext.h:26
JGTowerBase_ID::etaGranularity
float etaGranularity(const Identifier regId) const
Return the eta granularity of a region, or NOT_VALID.
Definition: JGTowerBase_ID.cxx:353
JGTowerBase_ID::NOT_VALID
@ NOT_VALID
Definition: JGTowerBase_ID.h:33
AtlasDetectorID
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Definition: AtlasDetectorID.h:52
IdDictFieldImplementation::size_type
Identifier::size_type size_type
Definition: IdDictFieldImplementation.h:63
JGTowerBase_ID::m_eta_impl
IdDictFieldImplementation m_eta_impl
Definition: JGTowerBase_ID.h:353
IdDictFieldImplementation::bits
size_type bits() const
Definition: IdDictFieldImplementation.h:207
Identifier
Definition: IdentifierFieldParser.cxx:14