ATLAS Offline Software
Loading...
Searching...
No Matches
JGTowerBase_ID.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
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
25JGTowerBase_ID::JGTowerBase_ID(const std::string& name,
26 const std::string& group) :
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)
38
39{
40
41}
42
44
45
46
49{
51 return {id, 0, m_REGION_INDEX};
52}
53
56{
58 return {id, 0, m_PHI_INDEX};
59}
60
61
62int 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
97int 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
146int 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() +
236 m_sampling_impl.bits() +
237 m_region_impl.bits();
238 IdDictFieldImplementation::size_type bits_offset = m_jgtower_impl.bits_offset();
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 ;
257 m_hash_calcs[m_pnz_reg_impl.unpack(min)] = hc;
258
259 if (m_pnz_reg_impl.unpack(min) >= size)
260 {
261 ATH_MSG_DEBUG("Min > " << size);
263 ATH_MSG_DEBUG(" " << m_pnz_reg_impl.unpack(min));
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
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
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
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
367float 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
374float 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
381int
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
393int
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);
399 next = m_next_phi_vec[index];
400 return (0);
401 }
402 return (1);
403}
404
405int
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
417int
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);
423 next = m_next_eta_vec[index];
424 return (0);
425 }
426 return (1);
427}
428
429
430int 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}
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
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
496int 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:");
597 ATH_MSG_DEBUG("calo " << m_calo_impl);
598 ATH_MSG_DEBUG("detzside " << m_jgtower_impl);
599 ATH_MSG_DEBUG("sampling " << m_sampling_impl);
600 ATH_MSG_DEBUG("reg " << m_region_impl);
601 ATH_MSG_DEBUG("eta " << m_eta_impl);
602 ATH_MSG_DEBUG("phi " << m_phi_impl);
603
604 return(0) ;
605}
606
607
609{
610 // tower hash
611 m_tower_hash_max = m_full_tower_range.cardinality();
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];
617 ConstRangeIterator rit(range);
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];
654 ConstRangeIterator rit(range);
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];
697 ConstRangeIterator rit(range);
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
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
795int
796JGTowerBase_ID::fill_vec_of_dict_regions (const std::string& group_name /*= ""*/)
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}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Factor out code common between JTower_ID and GTower_ID.
static Double_t sc
Provide helper functions to create formatted strings.
size_t size() const
Number of registered mappings.
#define min(a, b)
Definition cfImp.cxx:40
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
int register_dict_tag(const IdDictMgr &dict_mgr, const std::string &dict_name)
Register the file and tag names for a particular IdDict dictionary.
int calo_field_value() const
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
const std::string & group() const
Group name for this helper.
ExpandedIdentifier calo_exp(void) const
AtlasDetectorID(const std::string &name, const std::string &group)
Exception class for Calo Identifiers.
ConstRangeIterator end() const
ConstRangeIterator begin() const
void add(element_type value)
Append a value into a new field.
void clear()
Erase all fields.
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
const IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
bool get_previous(element_type current, element_type &previous) const
Returns false if previous/next is at end of range, or not possible.
element_type get_minimum() const
Query the values.
bool empty() const
If true, this field does not have any constraints, and may hold any value representable by element_ty...
bool get_next(element_type current, element_type &next) const
element_type get_maximum() const
This is a "hash" representation of an Identifier.
unsigned int value_type
small class holding the starting hash value, the min eta and the number of phi bins of each region
int sampling(const Identifier id) const
return sampling according to :
int fill_vec_of_dict_regions(const std::string &group_name="")
float eta0(const Identifier regId) const
Return the minimum eta of region, or NOT_VALID.
int eta_max(const Identifier regId) const
max value of eta index (-999 == failure)
IdDictFieldImplementation m_region_impl
size_type m_calo_region_hash_max
int region(const Identifier id) const
return region according to :
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
std::vector< unsigned short > m_next_phi_vec
IdentifierHash tower_hash_binary_search(Identifier towerId) const
create hash id from tower id – method NOT optimised, please use tower_hash() above
int eta_min(const Identifier regId) const
min value of eta index (-999 == failure)
int get_expanded_id(const Identifier &id, ExpandedIdentifier &exp_id, const IdContext *context) const
create expanded Identifier from Identifier (return == 0 for OK)
size_type m_PHI_INDEX
int pos_neg(const Identifier id) const
Test wether given tower or layer is part of the Tile Calorimeter.
float phiGranularity(const Identifier regId) const
Return the phi granularity of a region, or NOT_VALID.
std::vector< Identifier > m_tower_vec
size_type m_REGION_INDEX
size_type m_tower_hash_max
IdDictFieldImplementation m_sampling_impl
JGTowerBase_ID(const std::string &name, const std::string &group)
const IdDictDictionary * m_dict
size_type m_SAMPLING_INDEX
int phi_max(const Identifier regId) const
min value of phi index (-999 == failure)
int phi(const Identifier id) const
return phi according to :
IdentifierHash calo_region_hash(const Identifier id) const
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)
int initLevelsFromDict(const std::string &t_pre)
std::vector< unsigned short > m_prev_phi_vec
size_type m_CALO_INDEX
IdentifierHash tower_hash(Identifier towerId) const
create hash id from tower id
std::vector< HashCalc > m_hash_calcs
size_type m_jgtower_region_index
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
virtual int initialize_base_from_dictionary(const IdDictMgr &dict_mgr, const std::string &t_pre)
initialization from the identifier dictionary
IdContext tower_context() const
access to IdContext's which define which levels of fields are contained in the id
MultiRange m_full_tower_range
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)
std::vector< unsigned short > m_next_eta_vec
std::vector< unsigned short > m_prev_eta_vec
IdContext region_context() const
access to IdContext's which define which levels of fields are contained in the id
Identifier tower_id(int pos_neg, int sampling, int region, int eta, int phi) const
build a tower identifier
MultiRange m_full_reg_range
std::vector< const IdDictRegion * > m_vecOfDictRegions
List of IdDictRegion objects.
IdDictFieldImplementation m_eta_impl
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
void tower_id_checks(int pos_neg, int sampling, int region, int eta, int phi) const
Identifier region_id(int pos_neg, int sampling, int region) const
build a region (of towers) identifier
IdDictFieldImplementation m_jgtower_impl
float etaGranularity(const Identifier regId) const
Return the eta granularity of a region, or NOT_VALID.
IdDictFieldImplementation m_phi_impl
std::vector< Identifier > m_region_vec
float phi0(const Identifier regId) const
Return the minimum phi of region, or NOT_VALID.
IdDictFieldImplementation m_pnz_reg_impl
int eta(const Identifier id) const
return eta according to :
void region_id_checks(int pos_neg, int sampling, int region) const
IdDictFieldImplementation m_calo_impl
size_type m_DETZSIDE_INDEX
virtual ~JGTowerBase_ID()
size_type m_ETA_INDEX
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
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
std::string strformat(const char *fmt,...)
return a std::string according to a format fmt and varargs
Definition StrFormat.cxx:49
Definition index.py:1