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