ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_BarrelCode.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
6// TRT_BarrelCode.h
8// (c) ATLAS Detector software
10
11#ifndef TRT_BarrelCode_h
12#define TRT_BarrelCode_h 1
13
14#include <ostream>
15
16// Include the string class header
17#include <string>
18
19namespace InDetDD {
20
25
27 {
28 public:
29 typedef enum
30 {
34 } Module;
35
37 TRT_BarrelCode( unsigned int isPositive, unsigned int moduleIndex, unsigned phiIndex, unsigned int strawLayerIndex);
38
39 TRT_BarrelCode( const TRT_BarrelCode & right ) = default;
40 TRT_BarrelCode & operator=( const TRT_BarrelCode & right ) = default;
41 TRT_BarrelCode( TRT_BarrelCode && right ) = default;
42 TRT_BarrelCode & operator=( TRT_BarrelCode && right ) = default;
43
44 ~TRT_BarrelCode() = default;
45
46 bool operator < (const TRT_BarrelCode & right) const;
47 bool operator > (const TRT_BarrelCode & right) const;
48 bool operator== (const TRT_BarrelCode & right) const;
49 bool operator!= (const TRT_BarrelCode & right) const;
50
51 unsigned int isPosZ() const;
52 unsigned int getModuleIndex() const;
53 unsigned int getPhiIndex() const;
54 unsigned int getStrawLayerIndex() const;
55 unsigned int getKey() const;
56 std::string getName() const;
57
58 private:
59
60 // Define key as a bit string:
61 // bit 0 Z (negative=0 or positive=1)
62 // bit 1-2 Module Index (0-2)
63 // bit 3-7 Phi Index
64 // bit 8-12 StrawLayer Index
65
66 unsigned short int m_key;
67
68 static const int Z_MASK;
69 static const int MODULE_MASK;
70 static const int PHI_MASK;
71 static const int STRAWLAYER_MASK;
72
73
74 static const int Z_SHIFT;
75 static const int MODULE_SHIFT;
76 static const int PHI_SHIFT;
77 static const int STRAWLAYER_SHIFT;
78
79 };
80
81
82
83 inline unsigned int TRT_BarrelCode::isPosZ() const {
84 unsigned int ret = m_key;
85 return (ret >> Z_SHIFT) & Z_MASK;
86 }
87
88 inline unsigned int TRT_BarrelCode::getModuleIndex() const{
89 unsigned int ret = m_key;
90 return (ret >> MODULE_SHIFT) & MODULE_MASK;
91 }
92
93 inline unsigned int TRT_BarrelCode::getPhiIndex() const{
94 unsigned int ret = m_key;
95 return (ret >> PHI_SHIFT) & PHI_MASK;
96 }
97
98 inline unsigned int TRT_BarrelCode::getStrawLayerIndex() const {
99 unsigned int ret = m_key;
100 return (ret >> STRAWLAYER_SHIFT) & STRAWLAYER_MASK;
101 }
102
103 inline unsigned int TRT_BarrelCode::getKey() const {
104 return m_key;
105 }
106
107
108 inline bool TRT_BarrelCode::operator==(const TRT_BarrelCode &right) const
109 {
110 return (getKey() == right.getKey());
111 }
112
113 inline bool TRT_BarrelCode::operator!=(const TRT_BarrelCode &right) const
114 {
115 return (getKey() != right.getKey());
116 }
117
118 inline bool TRT_BarrelCode::operator<(const TRT_BarrelCode &right) const
119 {
120 return (getKey() < right.getKey());
121 }
122
123 inline bool TRT_BarrelCode::operator>(const TRT_BarrelCode &right) const
124 {
125 return (getKey() > right.getKey());
126 }
127} // End InDetDD namespace
128
129
130inline std::ostream & operator << (std::ostream & os, const InDetDD::TRT_BarrelCode & code) {
131 // Plus/minus
132 if (code.isPosZ()) os << '+';
133 else os << '-';
134 // Module
135 unsigned int mod = code.getModuleIndex();
136 if (mod==0) os << 'A';
137 else if (mod==1) os << 'B';
138 else if (mod==2) os << 'C';
139 else os << "?";
140 // Phi Index:
141 os << code.getPhiIndex();
142 // Separator:
143 os << '/';
144 // StrawLayer:
145 os << code.getStrawLayerIndex();
146 return os;
147}
148
149#endif
std::ostream & operator<<(std::ostream &os, const InDetDD::TRT_BarrelCode &code)
bit definitions to decode TRT straws in barrel
static const int STRAWLAYER_SHIFT
std::string getName() const
bool operator!=(const TRT_BarrelCode &right) const
unsigned int isPosZ() const
bool operator==(const TRT_BarrelCode &right) const
unsigned int getPhiIndex() const
bool operator>(const TRT_BarrelCode &right) const
unsigned int getKey() const
TRT_BarrelCode(const TRT_BarrelCode &right)=default
TRT_BarrelCode(unsigned int isPositive, unsigned int moduleIndex, unsigned phiIndex, unsigned int strawLayerIndex)
static const int MODULE_SHIFT
unsigned short int m_key
static const int STRAWLAYER_MASK
static const int Z_MASK
unsigned int getStrawLayerIndex() const
static const int Z_SHIFT
unsigned int getModuleIndex() const
TRT_BarrelCode & operator=(const TRT_BarrelCode &right)=default
static const int MODULE_MASK
TRT_BarrelCode(TRT_BarrelCode &&right)=default
static const int PHI_MASK
TRT_BarrelCode & operator=(TRT_BarrelCode &&right)=default
static const int PHI_SHIFT
bool operator<(const TRT_BarrelCode &right) const
Message Stream Member.