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