ATLAS Offline Software
Loading...
Searching...
No Matches
CaloDM_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/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
22
24
25
27 AtlasDetectorID("CaloDM_ID", "DM_Reg")
29 , m_CALO_INDEX(999)
30 , m_DETZSIDE_INDEX(999)
31 , m_DMAT_INDEX(999)
32 , m_SAMPLING_INDEX(999)
33 , m_REGION_INDEX(999)
34 , m_ETA_INDEX(999)
35 , m_PHI_INDEX(999)
36 , m_dict(nullptr)
41
42{
43
44}
45
46CaloDM_ID:: ~CaloDM_ID()= default;
47
48
49int CaloDM_ID::eta_min(const Identifier& id) const
50{
52 IdContext cntxt = region_context();
53 if(!get_expanded_id(id, expId, &cntxt)) {
54 int result = -999;
55 const MultiRange * zoneRange = nullptr ;
56 if ( is_lar(id) ) {
57 zoneRange = &(m_full_lar_zone_range) ;
58 } else {
59 assert ( is_tile(id) );
60 zoneRange = &(m_full_tile_zone_range) ;
61 }
62 for (unsigned int i = 0; i < (*zoneRange).size(); ++i) {
63 const Range& range = (*zoneRange)[i];
64 if (range.match(expId)) {
65 const Range::field& eta_field = range[m_ETA_INDEX];
66 if (not eta_field.empty()) {
67 int etamin = eta_field.get_minimum();
68 if (-999 == result) {
69 result = etamin;
70 }
71 else {
72 if (etamin < result) result = etamin;
73 }
74 }
75 }
76 }
77 return (result);
78 }
79 return (-999);
80}
81
82int CaloDM_ID::eta_max(const Identifier& id) const
83{
85 IdContext cntxt = region_context();
86 if(!get_expanded_id(id, expId, &cntxt)) {
87 int result = -999;
88 const MultiRange * zoneRange = nullptr ;
89 if ( is_lar(id) ) {
90 zoneRange = &(m_full_lar_zone_range) ;
91 } else {
92 assert ( is_tile(id) );
93 zoneRange = &(m_full_tile_zone_range) ;
94 }
95 for (unsigned int i = 0; i < (*zoneRange).size(); ++i) {
96 const Range& range = (*zoneRange)[i];
97 if (range.match(expId)) {
98 const Range::field& eta_field = range[m_ETA_INDEX];
99 if (not eta_field.empty()) {
100 int etamax = eta_field.get_maximum();
101 if (result < etamax) result = etamax;
102 }
103 }
104 }
105 return (result);
106 }
107 return (-999); // default
108}
109
110int CaloDM_ID::phi_min(const Identifier& id) const
111{
112 ExpandedIdentifier expId;
113 IdContext cntxt = region_context();
114 if(!get_expanded_id(id, expId, &cntxt)) {
115 int result = -999;
116 const MultiRange * zoneRange = nullptr ;
117 if ( is_lar(id) ) {
118 zoneRange = &(m_full_lar_zone_range) ;
119 } else {
120 assert ( is_tile(id) );
121 zoneRange = &(m_full_tile_zone_range) ;
122 }
123 for (unsigned int i = 0; i < (*zoneRange).size(); ++i) {
124 const Range& range = (*zoneRange)[i];
125 if (range.match(expId)) {
126 const Range::field& phi_field = range[m_PHI_INDEX];
127 if (not phi_field.empty()) {
128 int phimin = phi_field.get_minimum();
129 if (-999 == result) {
130 result = phimin;
131 }
132 else {
133 if (phimin < result) result = phimin;
134 }
135 }
136 }
137 }
138 return (result);
139 }
140 return (-999);
141}
142
143int CaloDM_ID::phi_max(const Identifier& id) const
144{
145 ExpandedIdentifier expId;
146 IdContext cntxt = zone_context();
147 if(!get_expanded_id(id, expId, &cntxt)) {
148 int result = -999;
149 const MultiRange * zoneRange = nullptr ;
150 if ( is_lar(id) ) {
151 zoneRange = &(m_full_lar_zone_range) ;
152 } else {
153 assert ( is_tile(id) );
154 zoneRange = &(m_full_tile_zone_range) ;
155 }
156 for (unsigned int i = 0; i < (*zoneRange).size(); ++i) {
157 const Range& range = (*zoneRange)[i];
158 if (range.match(expId)) {
159 const Range::field& phi_field = range[m_PHI_INDEX];
160 if (not phi_field.empty()) {
161 int phimax = phi_field.get_maximum();
162 if (result < phimax) result = phimax;
163 }
164 }
165 }
166 return (result);
167 }
168 return (-999); // default
169}
170
171
172/*===================================================================*/
174/*===================================================================*/
175{
176 ATH_MSG_INFO("initialize_from_dictionary");
177
178 // Check whether this helper should be reinitialized
179 if (!reinitialize(dict_mgr)) {
180 ATH_MSG_INFO("Request to reinitialize not satisfied - tags have not changed");
181 return (0);
182 }
183 else {
184 ATH_MSG_DEBUG("(Re)initialize");
185 }
186
187 // init base object
188 if(AtlasDetectorID::initialize_from_dictionary(dict_mgr)) return (1);
189
190 // Register version of the Calorimeter dictionary
191 if (register_dict_tag(dict_mgr, "Calorimeter")) return(1);
192
193 m_dict = dict_mgr.find_dictionary ("Calorimeter");
194 if(!m_dict) {
195 ATH_MSG_ERROR(" initialize_from_dict - cannot access Calorimeter dictionary ");
196 return 1;
197 }
198
199 // Initialize the field indices
200 if(initLevelsFromDict()) return (1);
201
202
203 // Find values for the calo, LArDM (neg) and TileDM (neg) fields
204 int caloValue = -1;
205 if (m_dict->get_label_value("subdet", "Calorimeter", caloValue))
206 {
207 ATH_MSG_ERROR("Could not get value for label 'Calorimeter' of field 'subdet' in dictionary "
208 << m_dict->name());
209 return (1);
210 }
211
212 int lardmCaloValue = -1;
213 // negative half
214 if (m_dict->get_label_value("DetZside", "negative_DMLar_side", lardmCaloValue))
215 {
216 ATH_MSG_ERROR("Could not get value for label 'negative_DMLar_side' of field 'DetZside' in dictionary "
217 << m_dict->name());
218 return (1);
219 }
220
221 int tiledmCaloValue = -1;
222 // negative half
223 if (m_dict->get_label_value("DetZside", "negative_DMTile_side", tiledmCaloValue))
224 {
225 ATH_MSG_ERROR("Could not get value for label 'negative_DMTile_side' of field 'DetZside' in dictionary "
226 << m_dict->name());
227 return (1);
228 }
229
230
231 // Set up id for region and range prefix
232
233 // NOTE: negative value is good enough to get multirange since the
234 // regions are symmetric in +/-eta
235
236 // LAr
237 ExpandedIdentifier reg_id;
238 reg_id.add(caloValue);
239 reg_id.add(lardmCaloValue);
240 Range prefix;
241 m_full_lar_region_range = m_dict->build_multirange(reg_id, prefix, "DMregion");
242 m_full_lar_zone_range = m_dict->build_multirange(reg_id, prefix, "phivalue");
243
244 // Tile
245 ExpandedIdentifier reg_id2;
246 reg_id2.add(caloValue);
247 reg_id2.add(tiledmCaloValue);
248 Range prefix2;
249 m_full_tile_region_range = m_dict->build_multirange(reg_id2, prefix2, "DMregion");
250 m_full_tile_zone_range = m_dict->build_multirange(reg_id2, prefix2, "phivalue");
251
252 ATH_MSG_DEBUG("CaloDM_ID::initialize_from_dict : ");
253 ATH_MSG_DEBUG("LAr zone range -> " << (std::string)m_full_lar_zone_range);
254 ATH_MSG_DEBUG("LAr region range -> " << (std::string)m_full_lar_region_range);
255 ATH_MSG_DEBUG("Tile zone range -> " << (std::string)m_full_tile_zone_range);
256 ATH_MSG_DEBUG("Tile region range -> " << (std::string)m_full_tile_region_range);
257
258
259 // Setup the hash tables
260 if(init_lar_hashes()) return (1);
261 if(init_tile_hashes()) return (1);
262
263 // Setup for hash calculation
264
265 // Regions have uniform eta/phi granularity
266 // The lookup table only needs to contain the
267 // hash offset for each region, the first eta index
268 // and the number of phi cells.
269
270 // The implementation requires:
271
272 // 1) a lookup table for each region containing hash offset,
273 // etamin and nphi
274 // 2) a decoder to access the "index" corresponding to the
275 // pnz/samp/reg fields. These fields use 6 bits, so the
276 // vector has a length of 64 for 16 regions.
277
278
279 // Create decoder for fields pnz to region
281 m_calodm_impl.bits() +
282 m_dmat_impl.bits() +
283 m_sampling_impl.bits() +
284 m_region_impl.bits();
285 IdDictFieldImplementation::size_type bits_offset = m_calodm_impl.bits_offset();
286 m_pnz_reg_impl.set_bits(bits, bits_offset);
287 int size = (1 << bits);
288
289 // std::cout << "pnz_reg "
290 // << m_pnz_reg_impl.show_to_string() << std::endl;
291 // std::cout << "size " << size << std::endl;
292
293 // std::cout << "pnz_reg " << m_pnz_reg_impl.decode_index() << " "
294 // << (std::string)m_pnz_reg_impl.ored_field() << " "
295 // << std::hex << m_pnz_reg_impl.mask() << " "
296 // << m_pnz_reg_impl.zeroing_mask() << " "
297 // << std::dec << m_pnz_reg_impl.shift()
298 // << " " << m_pnz_reg_impl.bits() << " " <<m_pnz_reg_impl.bits_offset()
299 // << std::endl;
300
301
302 // Set up vector as lookup table for lar hash calculation.
303 m_lar_hash_calcs.resize(size);
304
305 for (unsigned int i = 0; i < m_lar_region_hash_max; ++i) {
306 Identifier regId = lar_region_id(i) ;
307 HashCalc hc;
308 int etamin = eta_min(regId);
309 if(etamin < 0)
310 {
311 etamin = 0;
312 ATH_MSG_WARNING(" seting etamin to 0 because actual value not found for regId " << show_to_string(regId));
313 }
314 Identifier min = zone_id ( regId, etamin, 0);
316 hc.m_hash = min_hash;
317 hc.m_etamin = etamin;
318 hc.m_nphi = phi_max(min)+1 ;
319 m_lar_hash_calcs[m_pnz_reg_impl.unpack(min)] = hc;
320
321 if (m_pnz_reg_impl.unpack(min) >= size)
322 {
323 ATH_MSG_WARNING("min > " << size << " "
324 << i << " "
325 << show_to_string(min) << " "
326 << m_pnz_reg_impl.unpack(min));
327 }
328 }
329
330 // Check lar hash calculation
331 for (unsigned int i = 0; i < m_lar_zone_hash_max; ++i) {
332 Identifier id = lar_zone_id(i);
333 if (lar_zone_hash(id) != i)
334 {
335 ATH_MSG_ERROR("lar zone ranges, id, hash, i = "
336 << show_to_string(id) << ", "
337 << lar_zone_hash(id) << ", "
338 << i);
339 }
340 }
341
342 // Set up vector as lookup table for tile hash calculation.
343 m_tile_hash_calcs.resize(size);
344
345 for (unsigned int i = 0; i < m_tile_region_hash_max; ++i) {
346 Identifier regId = tile_region_id(i) ;
347 HashCalc hc;
348 int etamin = eta_min(regId);
349 if(etamin < 0)
350 {
351 etamin = 0;
352 ATH_MSG_WARNING("seting etamin to 0 because actual value not found for regId " << show_to_string(regId));
353 }
354 Identifier min = zone_id ( regId, etamin, 0);
356 hc.m_hash = min_hash;
357 hc.m_etamin = etamin;
358 hc.m_nphi = phi_max(min)+1 ;
360
361 if (m_pnz_reg_impl.unpack(min) >= size)
362 {
363 ATH_MSG_WARNING("min > " << size << " "
364 << i << " "
365 << show_to_string(min) << " "
366 << m_pnz_reg_impl.unpack(min) << " ");
367 }
368 }
369
370 // Check tile hash calculation
371 for (unsigned int i = 0; i < m_tile_zone_hash_max; ++i) {
372 Identifier id = tile_zone_id(i);
373 if (tile_zone_hash(id) != i)
374 {
375 ATH_MSG_ERROR("tile zone ranges, id, hash, i = "
376 << show_to_string(id) << ", "
377 << tile_zone_hash(id) << ", "
378 << i);
379 }
380 }
381 return 0;
382
383}
384
385 int CaloDM_ID::get_expanded_id (const Identifier& id, ExpandedIdentifier& exp_id, const IdContext* context) const
386{
387 // We assume that the context is >= region
388 exp_id.clear();
389 exp_id << calo_field_value()
390 << pos_neg_z(id)
391 << dmat(id)
392 << sampling(id)
393 << region(id);
394 if(context && context->end_index() >= m_ETA_INDEX) {
395 exp_id << eta(id);
396 if(context->end_index() >= m_PHI_INDEX) {
397 exp_id << phi(id);
398 }
399 }
400 return (0);
401}
402
405{
407 return {id, 0, m_REGION_INDEX};
408}
409
412{
414 return {id, 0, m_PHI_INDEX};
415}
416
417
419{
420 // Fill expanded id
422 id << pos_neg_z << dmat << sampling << region ;
423
424 if (!m_full_lar_region_range.match(id)) {
425 std::string errorMessage = "CaloDM_ID::lar_region_id() result is not OK: ID, range = "
426 + std::string(id) + " , " + (std::string)m_full_lar_zone_range;
427 throw CaloID_Exception(errorMessage , 3);
428 }
429}
430
432{
433 // Fill expanded id
435 id << pos_neg_z << dmat << sampling << region ;
436
437 if (!m_full_tile_region_range.match(id)) {
438 std::string errorMessage = "CaloDM_ID::tile_region_id() result is not OK: ID, range = "
439 + std::string(id) + " , " + (std::string)m_full_tile_zone_range;
440 throw CaloID_Exception(errorMessage , 3);
441 }
442}
443
444
445
447 int eta, int phi ) const
448{
449 // Fill expanded id
451 id << pos_neg_z << dmat << sampling << region << eta << phi;
452
453 if (!m_full_lar_zone_range.match(id)) {
454 std::string errorMessage = "CaloDM_ID::lar_zone_id() result is not OK: ID, range = "
455 + std::string(id) + " , " + (std::string)m_full_lar_zone_range;
456 throw CaloID_Exception(errorMessage , 4);
457 }
458}
459
461 int eta, int phi ) const
462{
463 // Fill expanded id
465 id << pos_neg_z << dmat << sampling << region << eta << phi;
466
467 if (!m_full_tile_zone_range.match(id)) {
468 std::string errorMessage = "CaloDM_ID::tile_zone_id() result is not OK: ID, range = "
469 + std::string(id) + " , " + (std::string)m_full_tile_zone_range;
470 throw CaloID_Exception(errorMessage , 4);
471 }
472}
473
474
476 int eta, int phi ) const
477{
478 // Fill expanded id
480
481 IdContext context = region_context();
482 if (get_expanded_id(regionId, id, &context)) {
483 std::string errorMessage = "CaloDM_ID::zone_id(regionId) result is not OK: ID= "
484 + show_to_string(regionId) ;
485 throw CaloID_Exception(errorMessage , 4);
486 }
487
488 id << eta << phi;
489
490 if(is_lar(regionId)) {
491 if (!m_full_lar_zone_range.match(id)) {
492 std::string errorMessage = "CaloDM_ID::zone_id(regionId) result is not OK: ID, range = "
493 + std::string(id) + " , " + (std::string)m_full_lar_zone_range;
494 throw CaloID_Exception(errorMessage , 4);
495 }
496 } else if(is_tile(regionId)) {
497 if (!m_full_tile_zone_range.match(id)) {
498 std::string errorMessage = "CaloDM_ID::zone_id(regionId) result is not OK: ID, range = "
499 + std::string(id) + " , " + (std::string)m_full_tile_zone_range;
500 throw CaloID_Exception(errorMessage , 4);
501 }
502 }
503}
504
505
506/*=======================================*/
508/*=======================================*/
509{
510 std::string strg;
511 std::stringstream strm;
512 if(!m_dict) {
513 ATH_MSG_ERROR("initLevelsFromDict - dictionary NOT initialized ");
514 return (1);
515 }
516
517 // Find out which identifier field corresponds to each level.
518
519 m_CALO_INDEX = 999 ;
520 m_DETZSIDE_INDEX = 999 ;
521 m_DMAT_INDEX = 999 ;
522 m_SAMPLING_INDEX = 999 ;
523 m_REGION_INDEX = 999 ;
524 m_ETA_INDEX = 999 ;
525 m_PHI_INDEX = 999 ;
526
527 // Save index to a LArDM region for unpacking - search with region name
528 const IdDictRegion* reg = m_dict->find_region("DM_4_1_0_0");
529 if (reg)
530 {
531 m_calodm_region_index = reg->index();
532 }
533 else
534 {
535 ATH_MSG_ERROR("initLevelsFromDict - unable to find lardm region ");
536 return (1);
537 }
538
539
540 // Fing a CaloDM region
541 const IdDictField* field = m_dict->find_field("subdet") ;
542 if (field) {
543 m_CALO_INDEX = field->index();
544 }
545 else
546 {
547 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'subdet' field ");
548 return (1);
549 }
550
551 field = m_dict->find_field("DetZside") ;
552 if (field)
553 {
554 m_DETZSIDE_INDEX = field->index();
555 }
556 else
557 {
558 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'DetZside' field ");
559 return (1);
560 }
561
562 field = m_dict->find_field("DMvalue") ;
563 if (field)
564 {
565 m_DMAT_INDEX = field->index();
566 }
567 else
568 {
569 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'DMvalue' field ");
570 return (1);
571 }
572
573
574 field = m_dict->find_field("samplingvalue") ;
575 if (field)
576 {
577 m_SAMPLING_INDEX = field->index();
578 }
579 else
580 {
581 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'samplingvalue' field ");
582 return (1);
583 }
584
585 field = m_dict->find_field("DMregion") ;
586 if (field)
587 {
588 m_REGION_INDEX = field->index();
589 }
590 else
591 {
592 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'DMregion' field ");
593 return (1);
594 }
595
596 field = m_dict->find_field("DMEta") ;
597 if (field) {
598 m_ETA_INDEX = field->index();
599 }
600 else
601 {
602 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'DMEta' field ");
603 return (1);
604 }
605
606 field = m_dict->find_field("phivalue") ;
607 if (field)
608 {
609 m_PHI_INDEX = field->index();
610 }
611 else
612 {
613 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'phivalue' field ");
614 return (1);
615 }
616
617
618 // Set the field implementations
619
621
622 m_calo_impl = region.implementation(m_CALO_INDEX);
623 m_calodm_impl = region.implementation(m_DETZSIDE_INDEX);
624 m_dmat_impl = region.implementation(m_DMAT_INDEX);
625 m_sampling_impl = region.implementation(m_SAMPLING_INDEX);
626 m_region_impl = region.implementation(m_REGION_INDEX);
627 m_eta_impl = region.implementation(m_ETA_INDEX);
628 m_phi_impl = region.implementation(m_PHI_INDEX);
629
630 ATH_MSG_DEBUG("decode index and bit fields for each level: ");
631 ATH_MSG_DEBUG("calo " << m_calo_impl.show_to_string());
632 ATH_MSG_DEBUG("detzside " << m_calodm_impl.show_to_string());
633 ATH_MSG_DEBUG("dmat " << m_dmat_impl.show_to_string());
634 ATH_MSG_DEBUG("samp " << m_sampling_impl.show_to_string());
635 ATH_MSG_DEBUG("reg " << m_region_impl.show_to_string());
636 ATH_MSG_DEBUG("eta " << m_eta_impl.show_to_string());
637 ATH_MSG_DEBUG("phi " << m_phi_impl.show_to_string());
638
639 return(0) ;
640}
641
642/*=======================================*/
644/*=======================================*/
645{
646 std::string strg;
647 std::stringstream strm;
648
649 // zone hash
652 unsigned int nids = 0;
653 std::set<Identifier> ids;
654 for (unsigned int i = 0; i < m_full_lar_zone_range.size(); ++i) {
655 const Range& range = m_full_lar_zone_range[i];
656 ConstRangeIterator rit(range);
657 auto first = rit.begin();
658 auto last = rit.end();
659 for (; first != last; ++first) {
660 const ExpandedIdentifier& exp_id = (*first);
661 Identifier zon_id = zone_id ( exp_id[m_DETZSIDE_INDEX],
662 exp_id[m_DMAT_INDEX],
663 exp_id[m_SAMPLING_INDEX],
664 exp_id[m_REGION_INDEX] ,
665 exp_id[m_ETA_INDEX] ,
666 exp_id[m_PHI_INDEX] ) ;
667 if(!(ids.insert(zon_id)).second)
668 {
669 ATH_MSG_ERROR(" init_lar_hashes "
670 << " duplicated id for lardm id. nids= " << nids
671 << " compact Id " << show_to_string(zon_id));
672 }
673 nids++;
674 }
675 }
676 if(ids.size() != m_lar_zone_hash_max)
677 {
678 ATH_MSG_ERROR(" init_lar_hashes "
679 << " set size NOT EQUAL to hash max. size " << ids.size()
680 << " hash max " << m_lar_zone_hash_max);
681 return (1);
682 }
683
684 nids=0;
685 std::set<Identifier>::const_iterator first = ids.begin();
686 std::set<Identifier>::const_iterator last = ids.end();
687 for (;first != last && nids < m_lar_zone_vec.size(); ++first) {
688 m_lar_zone_vec[nids] = (*first) ;
689 nids++;
690 }
691
692 // region hash
695 nids = 0;
696 ids.clear();
697 for (unsigned int i = 0; i < m_full_lar_region_range.size(); ++i) {
698 const Range& range = m_full_lar_region_range[i];
699 ConstRangeIterator rit(range);
700 auto first = rit.begin();
701 auto last = rit.end();
702 for (; first != last; ++first) {
703 const ExpandedIdentifier& exp_id = (*first);
704 // std::cout << "exp_id = " << (std::string)exp_id << std::endl;
705 Identifier reg_id = region_id ( exp_id[m_DETZSIDE_INDEX],
706 exp_id[m_DMAT_INDEX],
707 exp_id[m_SAMPLING_INDEX],
708 exp_id[m_REGION_INDEX] );
709 if(!(ids.insert(reg_id)).second)
710 {
711 ATH_MSG_ERROR(" init_lar_hashes (regions) "
712 << " duplicated id for region id. nids= " << nids
713 << " compact Id " << show_to_string(reg_id));
714 }
715 nids++;
716 }
717 }
718 if(ids.size() != m_lar_region_hash_max)
719 {
720 ATH_MSG_ERROR(" init_lar_hashes "
721 << " set size NOT EQUAL to region hash max. size " << ids.size()
722 << " region hash max " << m_lar_region_hash_max);
723 return (1);
724 }
725
726 nids=0;
727 first = ids.begin();
728 last = ids.end();
729 for (;first != last && nids < m_lar_region_vec.size(); ++first) {
730 m_lar_region_vec[nids] = (*first) ;
731 nids++;
732 }
733
734 return (0);
735
736}
737
738/*=====================================*/
740/*=====================================*/
741{
742 std::string strg;
743 std::stringstream strm;
744
745 // zone hash
748 unsigned int nids = 0;
749 std::set<Identifier> ids;
750 for (unsigned int i = 0; i < m_full_tile_zone_range.size(); ++i) {
751 const Range& range = m_full_tile_zone_range[i];
752 ConstRangeIterator rit(range);
753 auto first = rit.begin();
754 auto last = rit.end();
755 for (; first != last; ++first) {
756 const ExpandedIdentifier& exp_id = (*first);
757 Identifier zon_id = zone_id ( exp_id[m_DETZSIDE_INDEX],
758 exp_id[m_DMAT_INDEX],
759 exp_id[m_SAMPLING_INDEX],
760 exp_id[m_REGION_INDEX] ,
761 exp_id[m_ETA_INDEX] ,
762 exp_id[m_PHI_INDEX] ) ;
763 /*
764 std::cout << "detZside,dmat,samp,reg,eta,phi= "
765 <<exp_id[m_DETZSIDE_INDEX] << ", "
766 <<exp_id[m_DMAT_INDEX] << ", "
767 <<exp_id[m_SAMPLING_INDEX] << ", "
768 <<exp_id[m_REGION_INDEX] << ", "
769 <<exp_id[m_ETA_INDEX] << ", "
770 <<exp_id[m_PHI_INDEX];
771 std::cout << std::endl;
772 std::cout << "tile zon_id= " << show_to_string(zon_id) << std::endl;
773 */
774 if(!(ids.insert(zon_id)).second)
775 {
776 ATH_MSG_ERROR(" init_tile_hashes "
777 << " duplicated id for tiledm id. nids= " << nids
778 << " compact Id " << show_to_string(zon_id));
779 }
780 nids++;
781 }
782 }
783 if(ids.size() != m_tile_zone_hash_max)
784 {
785 ATH_MSG_ERROR(" init_tile_hashes "
786 << " set size NOT EQUAL to hash max. size " << ids.size()
787 << " hash max " << m_tile_zone_hash_max);
788 return (1);
789 }
790
791 nids=0;
792 std::set<Identifier>::const_iterator first = ids.begin();
793 std::set<Identifier>::const_iterator last = ids.end();
794 for (;first != last && nids < m_tile_zone_vec.size(); ++first) {
795 m_tile_zone_vec[nids] = (*first) ;
796 nids++;
797 }
798
799 // region hash
802 nids = 0;
803 ids.clear();
804 for (unsigned int i = 0; i < m_full_tile_region_range.size(); ++i) {
805 const Range& range = m_full_tile_region_range[i];
806 ConstRangeIterator rit(range);
807 auto first = rit.begin();
808 auto last = rit.end();
809 for (; first != last; ++first) {
810 const ExpandedIdentifier& exp_id = (*first);
811 // std::cout << "exp_id = " << (std::string)exp_id << std::endl;
812 Identifier reg_id = region_id ( exp_id[m_DETZSIDE_INDEX],
813 exp_id[m_DMAT_INDEX],
814 exp_id[m_SAMPLING_INDEX],
815 exp_id[m_REGION_INDEX] );
816 if(!(ids.insert(reg_id)).second)
817 {
818 ATH_MSG_ERROR(" init_tile_hashes (regions) "
819 << " duplicated id for region id. nids= " << nids
820 << " compact Id " << show_to_string(reg_id));
821 }
822 nids++;
823 }
824 }
825 if(ids.size() != m_tile_region_hash_max)
826 {
827 ATH_MSG_ERROR(" init_tile_hashes "
828 << " set size NOT EQUAL to region hash max. size " << ids.size()
829 << " region hash max " << m_tile_region_hash_max);
830 return (1);
831 }
832
833 nids=0;
834 first = ids.begin();
835 last = ids.end();
836 for (;first != last && nids < m_tile_region_vec.size(); ++first) {
837 m_tile_region_vec[nids] = (*first) ;
838 nids++;
839 }
840
841 return (0);
842
843}
844
845
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Provide helper functions to create formatted strings.
#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
ExpandedIdentifier calo_exp(void) const
AtlasDetectorID(const std::string &name, const std::string &group)
small class holding the starting hash value, the min eta and the number of phi bins of each region
Definition CaloDM_ID.h:351
IdentifierHash m_hash
Definition CaloDM_ID.h:357
size_type m_DETZSIDE_INDEX
Definition CaloDM_ID.h:322
size_type m_DMAT_INDEX
Definition CaloDM_ID.h:323
size_type m_SAMPLING_INDEX
Definition CaloDM_ID.h:324
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_CALO_INDEX
Definition CaloDM_ID.h:321
Identifier lar_zone_id(IdentifierHash lar_zone_hash_id) const
create a lar zone id from hash id
Definition CaloDM_ID.h:520
MultiRange m_full_tile_zone_range
Definition CaloDM_ID.h:339
bool is_tile(const Identifier &zoneId) const
to disentangle between LAr and Tile dead material
Definition CaloDM_ID.h:502
void lar_region_id_checks(int pos_neg_z, int dmat, int sampling, int region) const
size_type m_ETA_INDEX
Definition CaloDM_ID.h:326
size_type m_lar_zone_hash_max
Definition CaloDM_ID.h:333
IdDictFieldImplementation m_pnz_reg_impl
Definition CaloDM_ID.h:376
int eta_min(const Identifier &id) const
min value of eta index (-999 == failure)
Definition CaloDM_ID.cxx:49
size_type m_PHI_INDEX
Definition CaloDM_ID.h:327
int sampling(const Identifier &id) const
return sampling according to :
Definition CaloDM_ID.h:645
IdDictFieldImplementation m_eta_impl
Definition CaloDM_ID.h:372
IdentifierHash lar_zone_hash(Identifier LArZoneId) const
create a lar hash id from zone id
Definition CaloDM_ID.h:552
std::vector< Identifier > m_tile_zone_vec
Definition CaloDM_ID.h:342
size_type m_lar_region_hash_max
Definition CaloDM_ID.h:334
IdDictFieldImplementation m_calo_impl
Definition CaloDM_ID.h:367
std::vector< Identifier > m_lar_region_vec
Definition CaloDM_ID.h:336
std::vector< HashCalc > m_tile_hash_calcs
Definition CaloDM_ID.h:363
int eta(const Identifier &id) const
return eta
Definition CaloDM_ID.h:657
int dmat(const Identifier &id) const
return DMtype according to :
Definition CaloDM_ID.h:669
IdDictFieldImplementation m_calodm_impl
Definition CaloDM_ID.h:368
size_type m_calodm_region_index
Definition CaloDM_ID.h:320
int pos_neg_z(const Identifier &id) const
return pos_neg_z according to :
Definition CaloDM_ID.h:639
int phi_max(const Identifier &id) const
max value of phi index (-999 == failure)
int initLevelsFromDict()
int phi(const Identifier &id) const
return phi
Definition CaloDM_ID.h:663
MultiRange m_full_tile_region_range
Definition CaloDM_ID.h:338
IdDictFieldImplementation m_phi_impl
Definition CaloDM_ID.h:373
void zone_id_checks(const Identifier &regionId, int eta, int phi) const
std::vector< HashCalc > m_lar_hash_calcs
Definition CaloDM_ID.h:362
IdentifierHash tile_zone_hash(Identifier TileZoneId) const
create a tile hash id from zone id
Definition CaloDM_ID.h:559
IdDictFieldImplementation m_region_impl
Definition CaloDM_ID.h:371
void tile_region_id_checks(int pos_neg_z, int dmat, int sampling, int region) const
size_type m_tile_region_hash_max
Definition CaloDM_ID.h:341
bool is_lar(const Identifier &zoneId) const
to disentangle between LAr and Tile dead material
Definition CaloDM_ID.h:496
size_type m_tile_zone_hash_max
Definition CaloDM_ID.h:340
const IdDictDictionary * m_dict
Definition CaloDM_ID.h:329
int phi_min(const Identifier &id) const
min value of phi index (-999 == failure)
IdContext region_context() const
access to IdContext's which define which levels of fields are contained in a region id
Identifier zone_id(int pos_neg_z, int dat, int sampling, int region, int eta, int phi) const
build a zone identifier valid for both LAr and Tiles
Definition CaloDM_ID.h:463
void tile_zone_id_checks(int pos_neg_z, int dat, int sampling, int region, int eta, int phi) const
MultiRange m_full_lar_zone_range
Definition CaloDM_ID.h:332
size_type m_REGION_INDEX
Definition CaloDM_ID.h:325
IdentifierHash tile_zone_hash_binary_search(Identifier zoneId) const
Definition CaloDM_ID.h:685
IdContext zone_context() const
access to IdContext's which define which levels of fields are contained in a zone id
Identifier lar_region_id(IdentifierHash lar_region_hash_id) const
create a lar region id from hash id
Definition CaloDM_ID.h:508
void lar_zone_id_checks(int pos_neg_z, int dat, int sampling, int region, int eta, int phi) const
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr)
initialization from the identifier dictionary
IdDictFieldImplementation m_dmat_impl
Definition CaloDM_ID.h:369
std::vector< Identifier > m_lar_zone_vec
Definition CaloDM_ID.h:335
std::vector< Identifier > m_tile_region_vec
Definition CaloDM_ID.h:343
Identifier region_id(int pos_neg_z, int dmat, int sampling, int region) const
build a region identifier valid for both LAr and Tiles
Definition CaloDM_ID.h:415
virtual ~CaloDM_ID()
IdentifierHash lar_zone_hash_binary_search(Identifier zoneId) const
Definition CaloDM_ID.h:675
IdDictFieldImplementation m_sampling_impl
Definition CaloDM_ID.h:370
Identifier tile_zone_id(IdentifierHash tile_zone_hash_id) const
create a tile zone id from hash id
Definition CaloDM_ID.h:526
MultiRange m_full_lar_region_range
Definition CaloDM_ID.h:331
Identifier tile_region_id(IdentifierHash tile_region_hash_id) const
create a tile region id from hash id
Definition CaloDM_ID.h:514
int region(const Identifier &id) const
return region according to :
Definition CaloDM_ID.h:651
int init_lar_hashes()
int eta_max(const Identifier &id) const
max value of eta index (-999 == failure)
Definition CaloDM_ID.cxx:82
int init_tile_hashes()
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
size_type end_index() const
Definition IdContext.h:46
const IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
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...
element_type get_maximum() const
This is a "hash" representation of an Identifier.
A MultiRange combines several Ranges.
Definition MultiRange.h:17
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