ATLAS Offline Software
InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.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 TRTConditionsData_TRTCondIdentifier_h
6 #define TRTConditionsData_TRTCondIdentifier_h
7 
8 #include <iostream>
9 #include <string>
10 
11 namespace TRTCond
12 {
13  // Important note: inside the conditions code, we'll number the
14  // barrel/endcap elements differently, in order to ensure that they
15  // are labeled from something that starts at 0. an alternative is to
16  // introduce an offset here in the identifier. i'll think about
17  // that.
18 
30  {
31  private:
32  size_t m_index[5] ;
33  size_t m_level ;
34  public:
35 
38 
41  m_index[0] = m_index[1] = m_index[2] = m_index[3] = m_index[4] = 0 ;}
42 
44  ExpandedIdentifier(int bec, int layerorwheel, int module, int strawlayer, int straw, int l=STRAW)
45  : m_level(l) {
46  m_index[0] = becidtoindex(bec) ; // this is where we couild introduce a map
47  m_index[1] = layerorwheel ;
48  m_index[2] = module ;
49  m_index[3] = strawlayer ;
50  m_index[4] = straw ;
51  }
52 
53  // index operator subtracting 1 from the supplied index to skip the 'detector' level
54  //const size_t& operator[](size_t l) const { return m_index[l-1] ; }
55  //size_t& operator[]( size_t l ) { return m_index[l-1] ; }
56 
58  const size_t& index(size_t l) const { return m_index[l-1] ; }
59 
61  size_t& index(size_t l) { return m_index[l-1] ; }
62 
64  size_t level() const { return m_level ; }
65 
67  const std::string name(size_t l) const {
68  static const std::string names[] = {"detector","barrelec","layer_or_wheel","module","straw_layer","straw"} ;
69  return names[l] ;
70  }
71 
73  void print(std::ostream& os = std::cout) const ;
74 
76  void write(std::ostream& os) const ;
77 
79  void read(std::istream& is) ;
80 
82  size_t becidtoindex(int becid) const { return becid<0 ? becid+2 : becid + 1 ; }
83 
85  int becindextoid(size_t becindex) const { return becindex<2 ? int(becindex)-2 : becindex-1; }
86 
88  int id(size_t l) const { return l==BARRELEC ? becindextoid(index(l)) : index(l) ; }
89 
90  } ;
91 
92 }
93 
94 inline std::ostream& operator<<(std::ostream& os, const TRTCond::ExpandedIdentifier& id)
95 {
96  id.write(os) ;
97  return os ;
98 }
99 
100 inline std::istream& operator>>(std::istream& is, TRTCond::ExpandedIdentifier& id)
101 {
102  id.read(is) ;
103  return is ;
104 }
105 
106 #endif
TRT::Hit::straw
@ straw
Definition: HitInfo.h:82
TRTCond::ExpandedIdentifier::id
int id(size_t l) const
returns TRT_ID index at given level
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:88
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ParticleGun_SamplingFraction.bec
int bec
Definition: ParticleGun_SamplingFraction.py:89
TRTCond::ExpandedIdentifier::ExpandedIdentifier
ExpandedIdentifier(int bec, int layerorwheel, int module, int strawlayer, int straw, int l=STRAW)
normal constructor
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:44
TRTCond::ExpandedIdentifier::BARRELEC
@ BARRELEC
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:37
TRTCond::ExpandedIdentifier::index
const size_t & index(size_t l) const
returns const index at given level.
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:58
TRTCond::ExpandedIdentifier::m_level
size_t m_level
Granularity level.
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:33
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
TRTCond::ExpandedIdentifier::print
void print(std::ostream &os=std::cout) const
print the object
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/src/ExpandedIdentifier.cxx:11
TRTCond::ExpandedIdentifier::ExpandedIdentifier
ExpandedIdentifier()
default constructor
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:40
python.PyAthena.module
module
Definition: PyAthena.py:134
TRTCond::ExpandedIdentifier::level
size_t level() const
returns level
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:64
python.subdetectors.mmg.names
names
Definition: mmg.py:8
TRTCond::ExpandedIdentifier::STRAWLAYER
@ STRAWLAYER
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:37
TRTCond::ExpandedIdentifier::DETECTOR
@ DETECTOR
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:37
operator>>
std::istream & operator>>(std::istream &is, TRTCond::ExpandedIdentifier &id)
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:100
TRTCond::ExpandedIdentifier::Level
Level
enum to specify the granularity level
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:37
TRTCond::ExpandedIdentifier::index
size_t & index(size_t l)
returns index at given level
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:61
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
TRTCond::ExpandedIdentifier::becidtoindex
size_t becidtoindex(int becid) const
returns subdetector index given the barrel_ec number
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:82
TRTCond::ExpandedIdentifier::m_index
size_t m_index[5]
Index within levels higher than DETECTOR.
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:32
TRTCond::ExpandedIdentifier::STRAW
@ STRAW
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:37
TRTCond::ExpandedIdentifier::read
void read(std::istream &is)
read the object from file
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/src/ExpandedIdentifier.cxx:30
TRTCond
Definition: BasicRtRelation.cxx:8
TRTCond::ExpandedIdentifier::becindextoid
int becindextoid(size_t becindex) const
returns barrel_ec number given the subdetector index
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:85
TRTCond::ExpandedIdentifier::LAYERWHEEL
@ LAYERWHEEL
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:37
TRTCond::ExpandedIdentifier::name
const std::string name(size_t l) const
returns level name
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:67
TRTCond::ExpandedIdentifier::write
void write(std::ostream &os) const
write the object to file
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/src/ExpandedIdentifier.cxx:16
TRTCond::ExpandedIdentifier
Identifier for TRT detector elements in the conditions code.
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:30
TRTCond::ExpandedIdentifier::MODULE
@ MODULE
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:37
operator<<
std::ostream & operator<<(std::ostream &os, const TRTCond::ExpandedIdentifier &id)
Definition: InnerDetector/InDetConditions/TRT_ConditionsData/TRT_ConditionsData/ExpandedIdentifier.h:94