ATLAS Offline Software
Loading...
Searching...
No Matches
CaloDM_ID.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef CALODM_ID_H
6#define CALODM_ID_H
7
13
15
16#include <vector>
17#include <algorithm>
18
19
99class IdentifierHash;
100
102{
103public:
104
105 typedef Identifier::size_type size_type ;
106
107
108 CaloDM_ID();
109
110 virtual ~CaloDM_ID();
111
113 Identifier region_id ( int pos_neg_z, int dmat, int sampling, int region ) const;
114 Identifier region_id ( int pos_neg_z, int dmat, int sampling, int region, bool checks) const;
115
117 Identifier region_id (const Identifier& zoneId ) const;
118
120 Identifier zone_id (int pos_neg_z, int dat, int sampling, int region,
121 int eta, int phi ) const;
122 Identifier zone_id (int pos_neg_z, int dat, int sampling, int region,
123 int eta, int phi, bool checks ) const;
124
126 Identifier zone_id (const Identifier& regionId,
127 int eta, int phi ) const ;
128 Identifier zone_id (const Identifier& regionId,
129 int eta, int phi, bool checks ) const ;
130
132 bool is_lar (const Identifier& zoneId) const;
134 bool is_tile (const Identifier& zoneId) const;
135
137 Identifier lar_region_id (IdentifierHash lar_region_hash_id) const;
139 Identifier tile_region_id (IdentifierHash tile_region_hash_id) const;
140
142 Identifier lar_zone_id (IdentifierHash lar_zone_hash_id) const;
144 Identifier tile_zone_id (IdentifierHash tile_zone_hash_id) const;
145
147 IdentifierHash lar_region_hash (Identifier LArRegionId) const;
149 IdentifierHash tile_region_hash (Identifier TileRegionId) const;
150
152 IdentifierHash lar_zone_hash (Identifier LArZoneId) const;
154 IdentifierHash tile_zone_hash (Identifier TileZoneId) const;
155
156
165
167 std::vector<Identifier>::const_iterator lar_region_begin () const;
169 std::vector<Identifier>::const_iterator lar_region_end () const;
171 std::vector<Identifier>::const_iterator tile_region_begin () const;
173 std::vector<Identifier>::const_iterator tile_region_end () const;
174
176 std::vector<Identifier>::const_iterator lar_zone_begin () const;
178 std::vector<Identifier>::const_iterator lar_zone_end () const;
180 std::vector<Identifier>::const_iterator tile_zone_begin () const;
182 std::vector<Identifier>::const_iterator tile_zone_end () const;
183
184
198 int pos_neg_z (const Identifier& id)const;
199
213 int dmat (const Identifier& id)const;
214
228 int sampling (const Identifier& id)const;
229
248 int region (const Identifier& id)const;
249
254 int eta (const Identifier& id)const;
255
260 int phi (const Identifier& id)const;
261
262
263
266 int eta_min(const Identifier& id) const;
269 int eta_max(const Identifier& id) const;
272 int phi_min(const Identifier& id) const;
275 int phi_max(const Identifier& id) const;
276
277
279 virtual int initialize_from_dictionary (const IdDictMgr& dict_mgr);
280
282 IdContext region_context () const;
283
285 IdContext zone_context () const;
286
287
288private:
289
290
291 enum {NOT_VALID_HASH = 128000};
292
293
296
298 int get_expanded_id (const Identifier& id, ExpandedIdentifier& exp_id, const IdContext* context) const;
299
300
301 void lar_region_id_checks ( int pos_neg_z, int dmat, int sampling, int region ) const;
302
303 void tile_region_id_checks ( int pos_neg_z, int dmat, int sampling, int region ) const;
304
305 void lar_zone_id_checks (int pos_neg_z, int dat, int sampling, int region,
306 int eta, int phi ) const;
307 void tile_zone_id_checks (int pos_neg_z, int dat, int sampling, int region,
308 int eta, int phi ) const;
309 void zone_id_checks (const Identifier& regionId,
310 int eta, int phi ) const;
311
312
313
314 int initLevelsFromDict();
315
316 int init_lar_hashes();
317 int init_tile_hashes();
318
319
328
330
335 std::vector<Identifier> m_lar_zone_vec;
336 std::vector<Identifier> m_lar_region_vec;
337
342 std::vector<Identifier> m_tile_zone_vec;
343 std::vector<Identifier> m_tile_region_vec;
344
351 {
352 public:
354 m_hash(0),
355 m_etamin(0),
356 m_nphi(0) {}
360 };
361
362 std::vector<HashCalc> m_lar_hash_calcs;
363 std::vector<HashCalc> m_tile_hash_calcs;
364
365
366
374
375
377
378};
379
380//using the macros below we can assign an identifier (and a version)
381//This is required and checked at compile time when you try to record/retrieve
382CLASS_DEF( CaloDM_ID , 167756483 , 1 )
383
384
385//----------------------------------------------------------------------------
387 bool checks) const
388{
390 // Pack fields independently
393 m_dmat_impl.pack (dmat, result);
396
397 // Do checks
398 if(checks) {
399 if(abs(pos_neg_z) == 4) {
401 } else
402 if(abs(pos_neg_z) == 5) {
404 }
405 else
406 {
407 CaloID_Exception except("wrong value for pos_neg_z, only +-4 and +-5 allowed" , 99);
408 throw except ;
409 }
410 }
411
412 return result;
413}
414
416{
418}
419
420//----------------------------------------------------------------------------
421inline Identifier
422CaloDM_ID::region_id ( const Identifier& zoneId ) const
423{
424 Identifier result(zoneId);
425 // reset eta/phi
426 m_eta_impl.reset(result);
427 m_phi_impl.reset(result);
428 return (result);
429}
430
431//----------------------------------------------------------------------------
433 int eta, int phi,
434 bool checks) const
435{
437 // Pack fields independently
440 m_dmat_impl.pack (dmat, result);
443 m_eta_impl.pack (eta, result);
444 m_phi_impl.pack (phi, result);
445
446 // Do checks
447 if(checks) {
448 if(abs(pos_neg_z) == 4) {
450 }
451 else if(abs(pos_neg_z) == 5) {
453 }
454 else {
455 CaloID_Exception except("wrong value for pos_neg_z, only +-4 and +-5 allowed" , 99);
456 throw except ;
457 }
458 }
459
460 return result;
461}
462
464 int eta, int phi ) const
465{
467}
468
469//----------------------------------------------------------------------------
470inline Identifier CaloDM_ID::zone_id ( const Identifier& regionId,
471 int eta, int phi, bool checks ) const
472{
473 Identifier result(regionId);
474
475 // Reset the fields and then set the values
476 m_eta_impl.reset (result);
477 m_phi_impl.reset (result);
478 m_eta_impl.pack (eta, result);
479 m_phi_impl.pack (phi, result);
480
481 // Do checks
482 if(checks) {
483 zone_id_checks( regionId, eta, phi );
484 }
485
486 return result;
487}
488
489inline Identifier CaloDM_ID::zone_id ( const Identifier& regionId,
490 int eta, int phi ) const
491{
492 return zone_id (regionId, eta, phi, do_checks());
493}
494
495//----------------------------------------------------------------------------
496inline bool CaloDM_ID::is_lar(const Identifier& zoneId) const
497{
498 return ( abs(m_calodm_impl.unpack(zoneId)) == 4 );
499}
500
501//----------------------------------------------------------------------------
502inline bool CaloDM_ID::is_tile(const Identifier& zoneId) const
503{
504 return ( abs(m_calodm_impl.unpack(zoneId)) == 5 );
505}
506
507//----------------------------------------------------------------------------
508inline Identifier CaloDM_ID::lar_region_id (IdentifierHash lar_region_hash_id) const
509{
510 return(m_lar_region_vec[lar_region_hash_id]);
511}
512
513//----------------------------------------------------------------------------
514inline Identifier CaloDM_ID::tile_region_id (IdentifierHash tile_region_hash_id) const
515{
516 return(m_tile_region_vec[tile_region_hash_id]);
517}
518
519//----------------------------------------------------------------------------
520inline Identifier CaloDM_ID::lar_zone_id (IdentifierHash lar_zone_hash_id) const
521{
522 return(m_lar_zone_vec[lar_zone_hash_id]);
523}
524
525//----------------------------------------------------------------------------
526inline Identifier CaloDM_ID::tile_zone_id (IdentifierHash tile_zone_hash_id) const
527{
528 return(m_tile_zone_vec[tile_zone_hash_id]);
529}
530
531//----------------------------------------------------------------------------
533{
534 std::vector<Identifier>::const_iterator it = std::lower_bound(m_lar_region_vec.begin(),m_lar_region_vec.end(),LArRegionId);
535 if ( it != m_lar_region_vec.end() ){
536 return (it - m_lar_region_vec.begin());
537 }
538 return (0);
539}
540
541//----------------------------------------------------------------------------
543{
544 std::vector<Identifier>::const_iterator it = std::lower_bound(m_tile_region_vec.begin(),m_tile_region_vec.end(),TileRegionId);
545 if ( it != m_tile_region_vec.end() ){
546 return (it - m_tile_region_vec.begin());
547 }
548 return (0);
549}
550
551//----------------------------------------------------------------------------
553{
554 const HashCalc& hc = m_lar_hash_calcs[m_pnz_reg_impl.unpack(LArZoneId)];
555 return (hc.m_hash + (eta(LArZoneId)-hc.m_etamin)*hc.m_nphi + phi(LArZoneId));
556}
557
558//----------------------------------------------------------------------------
560{
561 const HashCalc& hc = m_tile_hash_calcs[m_pnz_reg_impl.unpack(TileZoneId)];
562 return (hc.m_hash + (eta(TileZoneId)-hc.m_etamin)*hc.m_nphi + phi(TileZoneId));
563}
564
565//----------------------------------------------------------------------------
570
571//----------------------------------------------------------------------------
576
577//----------------------------------------------------------------------------
582
583//----------------------------------------------------------------------------
588
589//----------------------------------------------------------------------------
590inline std::vector<Identifier>::const_iterator CaloDM_ID::lar_region_begin () const
591{
592 return(m_lar_region_vec.begin());
593}
594
595//----------------------------------------------------------------------------
596inline std::vector<Identifier>::const_iterator CaloDM_ID::lar_region_end () const
597{
598 return(m_lar_region_vec.end());
599}
600
601//----------------------------------------------------------------------------
602inline std::vector<Identifier>::const_iterator CaloDM_ID::lar_zone_begin () const
603{
604 return(m_lar_zone_vec.begin());
605}
606
607//----------------------------------------------------------------------------
608inline std::vector<Identifier>::const_iterator CaloDM_ID::lar_zone_end () const
609{
610 return(m_lar_zone_vec.end());
611}
612
613//----------------------------------------------------------------------------
614inline std::vector<Identifier>::const_iterator CaloDM_ID::tile_region_begin () const
615{
616 return(m_tile_region_vec.begin());
617}
618
619//----------------------------------------------------------------------------
620inline std::vector<Identifier>::const_iterator CaloDM_ID::tile_region_end () const
621{
622 return(m_tile_region_vec.end());
623}
624
625
626//----------------------------------------------------------------------------
627inline std::vector<Identifier>::const_iterator CaloDM_ID::tile_zone_begin () const
628{
629 return(m_tile_zone_vec.begin());
630}
631
632//----------------------------------------------------------------------------
633inline std::vector<Identifier>::const_iterator CaloDM_ID::tile_zone_end () const
634{
635 return(m_tile_zone_vec.end());
636}
637
638//----------------------------------------------------------------------------
639inline int CaloDM_ID::pos_neg_z(const Identifier& id) const
640{
641 return (m_calodm_impl.unpack(id));
642}
643
644//----------------------------------------------------------------------------
645inline int CaloDM_ID::sampling(const Identifier& id) const
646{
647 return (m_sampling_impl.unpack(id));
648}
649
650//----------------------------------------------------------------------------
651inline int CaloDM_ID::region(const Identifier& id) const
652{
653 return (m_region_impl.unpack(id));
654}
655
656//----------------------------------------------------------------------------
657inline int CaloDM_ID::eta(const Identifier& id) const
658{
659 return (m_eta_impl.unpack(id));
660}
661
662//----------------------------------------------------------------------------
663inline int CaloDM_ID::phi(const Identifier& id) const
664{
665 return (m_phi_impl.unpack(id));
666}
667
668//----------------------------------------------------------------------------
669inline int CaloDM_ID::dmat(const Identifier& id) const
670{
671 return (m_dmat_impl.unpack(id));
672}
673
674//----------------------------------------------------------------------------
676{
677 std::vector<Identifier>::const_iterator it = std::lower_bound(m_lar_zone_vec.begin(),m_lar_zone_vec.end(),zoneId);
678 if ( it != m_lar_zone_vec.end() ){
679 return (it - m_lar_zone_vec.begin());
680 }
681 return (0);
682}
683
684//----------------------------------------------------------------------------
686{
687 std::vector<Identifier>::const_iterator it = std::lower_bound(m_tile_zone_vec.begin(),m_tile_zone_vec.end(),zoneId);
688 if ( it != m_tile_zone_vec.end() ){
689 return (it - m_tile_zone_vec.begin());
690 }
691 return (0);
692}
693
694#endif // CALODM_ID_H
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
virtual bool do_checks(void) const override
Checks are performed by default in debug compilation and NOT in optimized compilation.
int calo_field_value() 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
Helper class for Calo Dead Material offline identifiers.
Definition CaloDM_ID.h:102
size_type m_DETZSIDE_INDEX
Definition CaloDM_ID.h:322
size_type m_DMAT_INDEX
Definition CaloDM_ID.h:323
std::vector< Identifier >::const_iterator tile_region_end() const
end iterator over tile regions
Definition CaloDM_ID.h:620
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 tile_zone_hash_max() const
tile zone hash table max size
Definition CaloDM_ID.h:584
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
std::vector< Identifier >::const_iterator lar_region_end() const
end iterator over lar regions
Definition CaloDM_ID.h:596
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
Identifier::size_type size_type
Definition CaloDM_ID.h:105
IdDictFieldImplementation m_calodm_impl
Definition CaloDM_ID.h:368
std::vector< Identifier >::const_iterator tile_zone_begin() const
begin iterator over full set of Tile identifiers
Definition CaloDM_ID.h:627
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()
IdentifierHash lar_region_hash(Identifier LArRegionId) const
create a lar hash id from region id
Definition CaloDM_ID.h:532
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
std::vector< Identifier >::const_iterator lar_region_begin() const
begin iterator over lar regions
Definition CaloDM_ID.h:590
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 lar_region_hash_max() const
lar region hash table max size
Definition CaloDM_ID.h:566
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)
std::vector< Identifier >::const_iterator lar_zone_end() const
end iterator over full set of LAr identifiers
Definition CaloDM_ID.h:608
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
@ NOT_VALID_HASH
Definition CaloDM_ID.h:291
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
size_type tile_region_hash_max() const
tile region hash table max size
Definition CaloDM_ID.h:578
std::vector< Identifier >::const_iterator lar_zone_begin() const
begin iterator over full set of LAr identifiers
Definition CaloDM_ID.h:602
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
std::vector< Identifier >::const_iterator tile_region_begin() const
begin iterator over tile regions
Definition CaloDM_ID.h:614
virtual ~CaloDM_ID()
IdentifierHash lar_zone_hash_binary_search(Identifier zoneId) const
Definition CaloDM_ID.h:675
std::vector< Identifier >::const_iterator tile_zone_end() const
end iterator over full set of Tile identifiers
Definition CaloDM_ID.h:633
IdDictFieldImplementation m_sampling_impl
Definition CaloDM_ID.h:370
IdentifierHash tile_region_hash(Identifier TileRegionId) const
create a tile hash id from region id
Definition CaloDM_ID.h:542
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()
size_type lar_zone_hash_max() const
lar zone hash table max size
Definition CaloDM_ID.h:572
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.
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
This is a "hash" representation of an Identifier.
A MultiRange combines several Ranges.
Definition MultiRange.h:17