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