ATLAS Offline Software
TileHWID.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  Tile Calorimeter detector description package
7  -----------------------------------------
8  ***************************************************************************/
9 
10 //<doc><file> $Id: TileHWID.h,v 1.11 2008-11-03 15:25:00 solodkov Exp $
11 //<version> $Name: not supported by cvs2svn $
12 
13 // TileHWID.h
14 //
15 // Atlas detector Identifier class for Tile Calorimeter (hardware identifier)
16 //
17 
18 #ifndef TILEIDENTIFIER_TILEHWID_H
19 #define TILEIDENTIFIER_TILEHWID_H
20 
21 #include "CaloIdentifier/TileID.h"
24 
49 class TileHWID : public AtlasDetectorID {
50 
51 public:
52 
54 
58  TileHWID(void);
59 
63  virtual ~TileHWID();
64 
67  enum ROSID { BEAM_ROS = 0,
71  EXTBAR_NEG = 4 };
74 
78  HWIdentifier tilehw_id ( void ) const;
82  HWIdentifier ros_id ( int ros) const;
86  HWIdentifier drawer_id ( int frag ) const;
90  HWIdentifier drawer_id ( int ros, int drawer ) const;
94  HWIdentifier channel_id ( int ros, int drawer,
95  int channel ) const;
99  HWIdentifier adc_id ( int ros, int drawer,
100  int channel, int adc ) const;
101 
105  HWIdentifier drawer_id ( const HWIdentifier& id ) const;
109  HWIdentifier channel_id ( const HWIdentifier& id ) const;
114  int channel ) const;
118  HWIdentifier adc_id ( const HWIdentifier& id,
119  int channel, int adc ) const;
123  HWIdentifier adc_id ( const HWIdentifier& id,
124  int adc ) const;
125 
130  inline HWIdentifier channel_id ( IdentifierHash hash_id ) const
131  { return m_channel_vec[hash_id]; }
132 
138  int adc ) const
139  { return adc_id(m_channel_vec[hash_id],adc); }
140 
141 
145  bool is_tilehw ( const HWIdentifier& id ) const;
149  bool is_low_gain ( const HWIdentifier& id ) const;
153  bool is_high_gain ( const HWIdentifier& id ) const;
154 
155 
159  inline int system ( const HWIdentifier & id ) const { return m_system_impl.unpack(id); }
163  inline int section ( const HWIdentifier & id ) const { return m_section_impl.unpack(id); }
167  inline int ros ( const HWIdentifier & id ) const { return m_ros_impl.unpack(id); }
171  inline int drawer ( const HWIdentifier & id ) const { return m_drawer_impl.unpack(id); }
175  inline int drawerIdx( const HWIdentifier & id ) const {
176  return std::max(0,(int)(std::upper_bound(m_drawer_vec.begin(),m_drawer_vec.end(),id) - m_drawer_vec.begin())-1);
177  }
181  inline int frag ( const HWIdentifier & id ) const { return ((ros(id) << 8) | drawer(id)); }
185  inline int frag ( int ros, int drawer ) const { return ((ros << 8) | drawer); }
189  inline int channel ( const HWIdentifier & id ) const { return m_channel_impl.unpack(id); }
193  inline int adc ( const HWIdentifier & id ) const { return m_adc_impl.unpack(id); }
194 
204  std::string to_string ( const HWIdentifier & id, int level=0 ) const;
205 
211  IdContext ros_context (void) const;
215  IdContext drawer_context (void) const;
219  IdContext channel_context (void) const;
223  IdContext adc_context (void) const;
224 
228  virtual int get_id (const IdentifierHash& hash_id, HWIdentifier& id, const IdContext* context = 0 ) const;
232  virtual int get_id (const IdentifierHash& hash_id, Identifier& id, const IdContext* context = 0 ) const
233  { HWIdentifier hwid(id); int stat=get_id(hash_id, hwid, context); id = hwid.get_compact(); return stat; }
234 
238  virtual IdentifierHash get_hash (const HWIdentifier& id) const;
239 
243  virtual int get_hash (const HWIdentifier& id, IdentifierHash& hash_id, const IdContext* context = 0 ) const;
247  virtual int get_hash (const Identifier& id, IdentifierHash& hash_id, const IdContext* context = 0 ) const
248  { HWIdentifier hwid(id); return get_hash(hwid, hash_id, context); }
249 
253  virtual IdentifierHash get_channel_hash (const HWIdentifier& id) const;
254 
255 
259  virtual int initialize_from_dictionary (const IdDictMgr& dict_mgr);
260 
264  inline size_type ros_hash_max (void) const { return m_ros_hash_max; }
268  inline size_type drawer_hash_max (void) const { return m_drawer_hash_max; }
272  inline size_type channel_hash_max (void) const { return m_channel_hash_max; }
276  inline size_type adc_hash_max (void) const { return m_adc_hash_max; }
277 
281  std::vector<HWIdentifier>::const_iterator ros_begin (void) const { return(m_ros_vec.begin()); }
285  std::vector<HWIdentifier>::const_iterator ros_end (void) const { return(m_ros_vec.end()); }
286 
290  std::vector<HWIdentifier>::const_iterator drawer_begin (void) const { return(m_drawer_vec.begin()); }
294  std::vector<HWIdentifier>::const_iterator drawer_end (void) const { return(m_drawer_vec.end()); }
295 
299  std::vector<HWIdentifier>::const_iterator channel_begin (void) const { return(m_channel_vec.begin()); }
303  std::vector<HWIdentifier>::const_iterator channel_end (void) const { return(m_channel_vec.end()); }
304 
308  std::vector<HWIdentifier>::const_iterator adc_begin (void) const { return(m_adc_vec.begin()); }
312  std::vector<HWIdentifier>::const_iterator adc_end (void) const { return(m_adc_vec.end()); }
313 
314  enum {NOT_VALID_HASH = 64000};
315 
316 private:
317 
321  int get_expanded_id (const HWIdentifier& id, ExpandedIdentifier& exp_id, const IdContext* context) const;
322 
326  int get_field ( const HWIdentifier & id,
327  size_type index ) const;
328 
329  int initLevelsFromDict(void) ;
330 
331  int init_hashes(void) ;
332 
336  bool adc_id (const HWIdentifier& channel_id, int adc, HWIdentifier& adc_id );
337  int fill_vec (std::set<HWIdentifier> & ids,
338  unsigned int hash_max, std::vector<HWIdentifier> & vec);
339 
347 
349 
356 
365  std::vector<HWIdentifier> m_ros_vec;
366  std::vector<HWIdentifier> m_drawer_vec;
367  std::vector<HWIdentifier> m_channel_vec;
368  std::vector<HWIdentifier> m_adc_vec;
369 
371 
372 };
373 
374 //using the macro below we can assign an identifier (and a version)
375 //This is required and checked at compile time when you try to record/retrieve
376 CLASS_DEF( TileHWID , 2902 , 1 )
377 
378 #endif // TILEIDENTIFIER_TILEHWID_H
379 
TileHWID::m_SYSTEM_INDEX
size_type m_SYSTEM_INDEX
Definition: TileHWID.h:341
TileHWID::ros_id
HWIdentifier ros_id(int ros) const
ROS HWIdentifer.
Definition: TileHWID.cxx:130
max
#define max(a, b)
Definition: cfImp.cxx:41
TileHWID::frag
int frag(int ros, int drawer) const
make frag from ROS and drawer
Definition: TileHWID.h:185
Tile_Base_ID::ONLINE
@ ONLINE
Definition: Tile_Base_ID.h:48
TileHWID::get_id
virtual int get_id(const IdentifierHash &hash_id, HWIdentifier &id, const IdContext *context=0) const
create compact HW ID from hash id (return == 0 for OK)
Definition: TileHWID.cxx:491
TileHWID::ros_begin
std::vector< HWIdentifier >::const_iterator ros_begin(void) const
begin iterator for ROS Identifiers
Definition: TileHWID.h:281
TileHWID::ros_end
std::vector< HWIdentifier >::const_iterator ros_end(void) const
end iterator for ROS Identifiers
Definition: TileHWID.h:285
TileHWID::fill_vec
int fill_vec(std::set< HWIdentifier > &ids, unsigned int hash_max, std::vector< HWIdentifier > &vec)
Definition: TileHWID.cxx:919
TileHWID::is_low_gain
bool is_low_gain(const HWIdentifier &id) const
Test ID for low gain.
Definition: TileHWID.cxx:98
TileHWID::m_section_impl
IdDictFieldImplementation m_section_impl
Definition: TileHWID.h:351
index
Definition: index.py:1
TileHWID::m_ros_vec
std::vector< HWIdentifier > m_ros_vec
Definition: TileHWID.h:365
TileHWID::channel_context
IdContext channel_context(void) const
idContext for channels
Definition: TileHWID.cxx:478
TileHWID::m_DRAWER_INDEX
size_type m_DRAWER_INDEX
Definition: TileHWID.h:344
TileHWID::ROSID
ROSID
Definition: TileHWID.h:67
TileHWID::BEAM_ROS
@ BEAM_ROS
Definition: TileHWID.h:67
TileHWID::is_tilehw
bool is_tilehw(const HWIdentifier &id) const
Test ID for Tile online ID.
Definition: TileHWID.cxx:89
TileHWID::TileHWID
TileHWID(void)
Default constructor.
Definition: TileHWID.cxx:26
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
Identifier::get_compact
value_type get_compact() const
Get the compact id.
TileHWID::m_adc_hash_max
size_type m_adc_hash_max
Definition: TileHWID.h:364
TileHWID::SECTION
SECTION
Identifier numbering.
Definition: TileHWID.h:66
TileHWID::adc_begin
std::vector< HWIdentifier >::const_iterator adc_begin(void) const
begin iterator for ADC Identifiers
Definition: TileHWID.h:308
TileHWID::m_channel_impl
IdDictFieldImplementation m_channel_impl
Definition: TileHWID.h:354
TileHWID::frag
int frag(const HWIdentifier &id) const
extract frag field from HW identifier
Definition: TileHWID.h:181
Tile_Base_ID::HIGHGAIN
@ HIGHGAIN
Definition: Tile_Base_ID.h:57
TileHWID::drawer_hash_max
size_type drawer_hash_max(void) const
drawer hash table max size
Definition: TileHWID.h:268
TileHWID::tilehw_id
HWIdentifier tilehw_id(void) const
online identifer for whole Tile
Definition: TileHWID.cxx:119
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
TileHWID::m_SECTION_INDEX
size_type m_SECTION_INDEX
Definition: TileHWID.h:342
TileHWID::drawer_context
IdContext drawer_context(void) const
idContext for drawers
Definition: TileHWID.cxx:471
HWIdentifier
Definition: HWIdentifier.h:13
TileHWID::HIGHGAIN
@ HIGHGAIN
Definition: TileHWID.h:73
TileHWID::initialize_from_dictionary
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr)
initialization from the identifier dictionary
Definition: TileHWID.cxx:601
IdDictFieldImplementation::unpack
int unpack(Identifier id) const
Identifier manipulation methods.
Definition: IdDictFieldImplementation.h:148
TileHWID::channel
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
Definition: TileHWID.h:189
TileID.h
TileHWID::m_ros_impl
IdDictFieldImplementation m_ros_impl
Definition: TileHWID.h:352
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
TileHWID::ros
int ros(const HWIdentifier &id) const
extract ros field from HW identifier
Definition: TileHWID.h:167
TileHWID::channel_end
std::vector< HWIdentifier >::const_iterator channel_end(void) const
end iterator for channel Identifiers
Definition: TileHWID.h:303
TileHWID::LOWGAIN
@ LOWGAIN
Definition: TileHWID.h:72
TileHWID::m_adc_vec
std::vector< HWIdentifier > m_adc_vec
Definition: TileHWID.h:368
AtlasDetectorID::size_type
Identifier::size_type size_type
Definition: AtlasDetectorID.h:384
TileHWID
Helper class for TileCal online (hardware) identifiers.
Definition: TileHWID.h:49
TileHWID::m_adc_impl
IdDictFieldImplementation m_adc_impl
Definition: TileHWID.h:355
IdDictMgr
Definition: IdDictDefs.h:32
TileHWID::adc
int adc(const HWIdentifier &id) const
extract adc field from HW identifier
Definition: TileHWID.h:193
TileHWID::channel_begin
std::vector< HWIdentifier >::const_iterator channel_begin(void) const
begin iterator for channel Identifiers
Definition: TileHWID.h:299
TileHWID::system
int system(const HWIdentifier &id) const
extract system field from HW identifier
Definition: TileHWID.h:159
TileHWID::ros_hash_max
size_type ros_hash_max(void) const
ROS hash table max size.
Definition: TileHWID.h:264
TileHWID::get_hash
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)
Definition: TileHWID.h:247
TileHWID::section
int section(const HWIdentifier &id) const
extract section field from HW identifier
Definition: TileHWID.h:163
TileHWID::m_channel_hash_max
size_type m_channel_hash_max
Definition: TileHWID.h:363
TileHWID::get_hash
virtual IdentifierHash get_hash(const HWIdentifier &id) const
create hash id from compact ADC id without error checking
Definition: TileHWID.cxx:544
TileHWID::size_type
Identifier::size_type size_type
Definition: TileHWID.h:53
TileHWID::drawer_begin
std::vector< HWIdentifier >::const_iterator drawer_begin(void) const
begin iterator for drawer Identifiers
Definition: TileHWID.h:290
TileHWID::channel_id
HWIdentifier channel_id(IdentifierHash hash_id) const
create channel ID from channel hash ID
Definition: TileHWID.h:130
TileHWID::get_id
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)
Definition: TileHWID.h:232
TileHWID::TILE_ONLINE
@ TILE_ONLINE
Definition: TileHWID.h:66
TileHWID::get_channel_hash
virtual IdentifierHash get_channel_hash(const HWIdentifier &id) const
create hash id from compact Channel id
Definition: TileHWID.cxx:590
TileHWID::EXTBAR_NEG
@ EXTBAR_NEG
Definition: TileHWID.h:71
TileHWID::adc_hash_max
size_type adc_hash_max(void) const
ADC hash table max size.
Definition: TileHWID.h:276
Tile_Base_ID::LOWGAIN
@ LOWGAIN
Definition: Tile_Base_ID.h:57
TileHWID::m_CHANNEL_INDEX
size_type m_CHANNEL_INDEX
Definition: TileHWID.h:345
TileHWID::NOT_VALID_HASH
@ NOT_VALID_HASH
Definition: TileHWID.h:314
TileHWID::GAIN
GAIN
Definition: TileHWID.h:72
TileHWID::m_ros_hash_max
size_type m_ros_hash_max
Definition: TileHWID.h:361
TileHWID::m_tile_region_index
size_type m_tile_region_index
Definition: TileHWID.h:340
TileHWID::m_base_tile_ros
HWIdentifier m_base_tile_ros
Definition: TileHWID.h:370
beamspotman.stat
stat
Definition: beamspotman.py:266
TileHWID::~TileHWID
virtual ~TileHWID()
Default destructor.
Definition: TileHWID.cxx:42
TileHWID::adc_id
HWIdentifier adc_id(IdentifierHash hash_id, int adc) const
create adc ID from channel hash ID
Definition: TileHWID.h:137
TileHWID::m_full_channel_range
MultiRange m_full_channel_range
Definition: TileHWID.h:359
MultiRange
A MultiRange combines several Ranges.
Definition: MultiRange.h:17
TileHWID::drawer_id
HWIdentifier drawer_id(int frag) const
ROS HWIdentifer.
Definition: TileHWID.cxx:187
HWIdentifier.h
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
TileHWID::get_field
int get_field(const HWIdentifier &id, size_type index) const
unpack one field from Identifier
Definition: TileHWID.cxx:75
TileHWID::drawerIdx
int drawerIdx(const HWIdentifier &id) const
construct drawer index from HW identifier
Definition: TileHWID.h:175
TileHWID::channel_id
HWIdentifier channel_id(int ros, int drawer, int channel) const
channel HWIdentifer
Definition: TileHWID.cxx:199
IdentifierHash.h
TileHWID::BARREL_NEG
@ BARREL_NEG
Definition: TileHWID.h:69
TileHWID::EXTBAR_POS
@ EXTBAR_POS
Definition: TileHWID.h:70
TileHWID::m_ROS_INDEX
size_type m_ROS_INDEX
Definition: TileHWID.h:343
TileHWID::m_full_ros_range
MultiRange m_full_ros_range
Definition: TileHWID.h:357
TileHWID::m_full_drawer_range
MultiRange m_full_drawer_range
Definition: TileHWID.h:358
TileHWID::ros_context
IdContext ros_context(void) const
access to IdContext's which define which levels of fields are contained in the id
Definition: TileHWID.cxx:464
TileHWID::m_ADC_INDEX
size_type m_ADC_INDEX
Definition: TileHWID.h:346
IdDictDictionary
Definition: IdDictDefs.h:97
TileHWID::BARREL_POS
@ BARREL_POS
Definition: TileHWID.h:68
TileHWID::adc_context
IdContext adc_context(void) const
idContext for ADCs
Definition: TileHWID.cxx:485
TileHWID::adc_id
HWIdentifier adc_id(int ros, int drawer, int channel, int adc) const
adc HWIdentifer
Definition: TileHWID.cxx:229
TileHWID::channel_hash_max
size_type channel_hash_max(void) const
channel hash table max size
Definition: TileHWID.h:272
TileHWID::drawer
int drawer(const HWIdentifier &id) const
extract drawer field from HW identifier
Definition: TileHWID.h:171
TileHWID::initLevelsFromDict
int initLevelsFromDict(void)
Definition: TileHWID.cxx:703
TileHWID::m_system_impl
IdDictFieldImplementation m_system_impl
Definition: TileHWID.h:350
TileHWID::m_dict
const IdDictDictionary * m_dict
Definition: TileHWID.h:348
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
TileHWID::m_channel_vec
std::vector< HWIdentifier > m_channel_vec
Definition: TileHWID.h:367
TileHWID::init_hashes
int init_hashes(void)
Definition: TileHWID.cxx:817
TileHWID::get_expanded_id
int get_expanded_id(const HWIdentifier &id, ExpandedIdentifier &exp_id, const IdContext *context) const
create expanded Identifier from Identifier (return == 0 for OK)
Definition: TileHWID.cxx:682
TileHWID::is_high_gain
bool is_high_gain(const HWIdentifier &id) const
Test ID for high gain.
Definition: TileHWID.cxx:107
TileHWID::drawer_end
std::vector< HWIdentifier >::const_iterator drawer_end(void) const
end iterator for drawer Identifiers
Definition: TileHWID.h:294
TileHWID::m_full_adc_range
MultiRange m_full_adc_range
Definition: TileHWID.h:360
TileHWID::to_string
std::string to_string(const HWIdentifier &id, int level=0) const
extract all fields from HW identifier HWIdentifier get_all_fields ( const HWIdentifier & id,...
Definition: TileHWID.cxx:50
Identifier::size_type
unsigned long long size_type
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:29
IdDictFieldImplementation
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
Definition: IdDictFieldImplementation.h:58
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
TileHWID::m_drawer_vec
std::vector< HWIdentifier > m_drawer_vec
Definition: TileHWID.h:366
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition: IdContext.h:26
TileHWID::m_drawer_hash_max
size_type m_drawer_hash_max
Definition: TileHWID.h:362
TileHWID::m_drawer_impl
IdDictFieldImplementation m_drawer_impl
Definition: TileHWID.h:353
TileHWID::adc_end
std::vector< HWIdentifier >::const_iterator adc_end(void) const
end iterator for ADC Identifiers
Definition: TileHWID.h:312
AtlasDetectorID
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Definition: AtlasDetectorID.h:57
Identifier
Definition: IdentifierFieldParser.cxx:14