ATLAS Offline Software
DetectorDescription/Identifier/Identifier/Identifier.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef IDENTIFIER_IDENTIFIER_H
6 #define IDENTIFIER_IDENTIFIER_H
7 
8 
9 #define IDENTIFIER_TYPE unsigned long long
10 #define IDENTIFIER_DIFF_TYPE long long
11 #define IDENTIFIER_PCODE "ll"
12 
13 #include "GaudiKernel/MsgStream.h"
15 #include <string>
16 #include <boost/io/ios_state.hpp>
17 
32 {
33 public:
34 
42 
43  typedef enum
44  {
45  NBITS = sizeof(value_type) * 8, // bits per byte
46  MAX_BIT = (static_cast<value_type>(1) << (NBITS - 1)),
47  ALL_BITS = ~(static_cast<value_type>(0))
49 
53 
55  Identifier() = default;
57  Identifier(const Identifier& other) = default;
59  Identifier(Identifier&& other) = default;
61  Identifier& operator=(const Identifier& old) = default;
65  ~Identifier() = default;
66 
70 
73 
77  explicit Identifier (int value);
78 
79 
80 
84 
91 
92 private:
96 
97 public:
98 
100  void set (const std::string& id);
101 
103  void clear ();
104 
107 
111 
115 
117  value_type get_compact (void) const;
118 
121  {
122  public:
124  {
125  return id.get_compact();
126  }
127  };
128 
132 
133  bool operator == (const Identifier& other) const;
134  bool operator != (const Identifier& other) const;
135  bool operator < (const Identifier& other) const;
136  bool operator > (const Identifier& other) const;
137  bool operator <= (const Identifier& other) const;
138  bool operator >= (const Identifier& other) const;
139 
149  bool operator == (int other) const;
151  bool operator != (int other) const;
152 
156 
158  bool is_valid () const;
159 
163 
165  std::string getString() const;
166 
168  void show () const;
169 
170 private:
171 
174 
177 
180 
181  // allow IdDict access to the following private methods
182  friend class IdDictDictionary;
184  friend class AtlasDetectorID;
185  friend class PixelID;
186 
187  typedef enum {
188  //max_value = 0xFFFFFFFFFFFFFFFFULL
189  max_value = ~(static_cast<value_type>(0))
191 
192  //----------------------------------------------------------------
193  // The compact identifier data.
194  //----------------------------------------------------------------
196 
197 };
198 //-----------------------------------------------
199 
200 
201 // Define a hash functional
202 
203 namespace std {
204 template<>
206 {
207  size_t operator()(const Identifier& id) const
208  {
209  return static_cast<size_t>(id.get_compact());
210  }
211 };
212 }
213 
214 #include "Identifier/Identifier.icc"
215 
216 #endif
Identifier::value_type
IDENTIFIER_TYPE value_type
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:39
Identifier::operator>
bool operator>(const Identifier &other) const
Identifier::get_compact_func
A get_compact functional for use in STL algorithms.
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:121
Identifier32
Definition: Identifier32.h:25
Identifier::set
void set(const std::string &id)
build from a string form - hexadecimal
Definition: Identifier.cxx:18
Identifier::MAX_BIT
@ MAX_BIT
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:46
Identifier32::value_type
unsigned int value_type
Definition: Identifier32.h:33
Identifier::operator|=
Identifier & operator|=(value_type value)
Bitwise operations.
Identifier::mask_shift
value_type mask_shift(value_type mask, size_type shift) const
extract field(s) by masking first, then shifting
Identifier::max_value
@ max_value
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:189
Identifier::id_type
Identifier id_type
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:38
std::hash< Identifier >::operator()
size_t operator()(const Identifier &id) const
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:207
athena.value
value
Definition: athena.py:122
Identifier::operator&=
Identifier & operator&=(value_type value)
Identifier::set_literal
Identifier & set_literal(value_type value)
Set literal value.
Identifier::Identifier
Identifier(Identifier &&other)=default
Default Move constructor.
Identifier::is_valid
bool is_valid() const
Check if id is in a valid state.
Identifier::m_id
value_type m_id
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:195
Identifier::Identifier
Identifier(value_type value)
Additional ctors Constructor from value_type.
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
Identifier::operator>=
bool operator>=(const Identifier &other) const
Identifier::operator=
Identifier & operator=(Identifier &&old)=default
Default Move Assignment operator.
Identifier::operator<
bool operator<(const Identifier &other) const
IDENTIFIER_DIFF_TYPE
#define IDENTIFIER_DIFF_TYPE
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:10
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
Identifier::Identifier
Identifier(int value)
Identifier::operator=
Identifier & operator=(const Identifier &old)=default
Default Assignment operators.
Identifier::bit_defs
bit_defs
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:44
Identifier::get_compact_func::operator()
value_type operator()(const Identifier &id)
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:123
Identifier::show
void show() const
Print out in hex form.
Definition: Identifier.cxx:36
Identifier::ALL_BITS
@ ALL_BITS
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:47
Identifier::clear
void clear()
Reset to invalid state.
Identifier::operator==
bool operator==(const Identifier &other) const
Identifier::NBITS
@ NBITS
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:45
IdDictDictionary
Definition: IdDictDefs.h:97
Identifier::Identifier
Identifier(Identifier32::value_type value)
Constructor from 32-bit value_type and int (to avoid common implicit conversions)
Identifier::Identifier
Identifier(const Identifier &other)=default
Default Copy constructor.
Identifier.icc
Identifier::getString
std::string getString() const
Provide a string form of the identifier - hexadecimal.
Definition: Identifier.cxx:25
Identifier::max_value_type
max_value_type
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:187
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
Identifier::get_compact
value_type get_compact(void) const
Get the compact id.
Identifier::operator!=
bool operator!=(const Identifier &other) const
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
CSV_InDetExporter.old
old
Definition: CSV_InDetExporter.py:141
Identifier::operator<=
bool operator<=(const Identifier &other) const
Identifier::size_type
IDENTIFIER_TYPE size_type
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:41
Identifier::Identifier
Identifier(const Identifier32 &other)
Constructor from Identifier32.
IdDictFieldImplementation
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
Definition: IdDictFieldImplementation.h:58
Identifier::get_identifier32
Identifier32 get_identifier32(void) const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
PixelID
Definition: PixelID.h:67
value_type
Definition: EDM_MasterSearch.h:11
Identifier32.h
Identifier::extract
value_type extract(size_type shift, size_type mask) const
extract field from identifier (shift first, then mask)
AtlasDetectorID
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Definition: AtlasDetectorID.h:57
Identifier::diff_type
IDENTIFIER_DIFF_TYPE diff_type
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:40
Identifier::Identifier
Identifier()=default
Default constructor.
Identifier::extract
value_type extract(size_type shift) const
extract field, no mask
Identifier::~Identifier
~Identifier()=default
Default dtor.
IDENTIFIER_TYPE
#define IDENTIFIER_TYPE
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:9