ATLAS Offline Software
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 
19 namespace InDetDD {
20 
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 
127 inline 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
InDetDD::TRT_EndcapCode::getStrawLayerIndex
unsigned int getStrawLayerIndex() const
Definition: TRT_EndcapCode.h:90
InDetDD::TRT_EndcapCode::PHIPOS_MASK
static const int PHIPOS_MASK
Definition: TRT_EndcapCode.h:68
InDetDD::TRT_EndcapCode::operator==
bool operator==(const TRT_EndcapCode &right) const
Definition: TRT_EndcapCode.h:105
InDetDD::TRT_EndcapCode::WHEEL_MASK
static const int WHEEL_MASK
Definition: TRT_EndcapCode.h:66
InDetDD::TRT_EndcapCode::operator=
TRT_EndcapCode & operator=(const TRT_EndcapCode &right)
Definition: TRT_EndcapCode.cxx:52
InDetDD::TRT_EndcapCode::PHIPOS_SHIFT
static const int PHIPOS_SHIFT
Definition: TRT_EndcapCode.h:73
InDetDD::TRT_EndcapCode::operator>
bool operator>(const TRT_EndcapCode &right) const
Definition: TRT_EndcapCode.h:120
InDetDD::TRT_EndcapCode::getWheelIndex
unsigned int getWheelIndex() const
Definition: TRT_EndcapCode.h:84
InDetDD::TRT_EndcapCode
Definition: TRT_EndcapCode.h:27
ret
T ret(T t)
Definition: rootspy.cxx:260
InDetDD::TRT_EndcapCode::Z_MASK
static const int Z_MASK
Definition: TRT_EndcapCode.h:65
InDetDD::TRT_EndcapCode::getName
std::string getName() const
Definition: TRT_EndcapCode.cxx:62
InDetDD::TRT_EndcapCode::m_key
unsigned short int m_key
Definition: TRT_EndcapCode.h:63
InDetDD::TRT_EndcapCode::~TRT_EndcapCode
~TRT_EndcapCode()=default
InDetDD::TRT_EndcapCode::isPosZ
unsigned int isPosZ() const
Definition: TRT_EndcapCode.h:79
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
InDetDD::TRT_EndcapCode::STRAWLAYER_SHIFT
static const int STRAWLAYER_SHIFT
Definition: TRT_EndcapCode.h:72
InDetDD::TRT_EndcapCode::Z_SHIFT
static const int Z_SHIFT
Definition: TRT_EndcapCode.h:70
operator<<
std::ostream & operator<<(std::ostream &os, const InDetDD::TRT_EndcapCode &code)
Definition: TRT_EndcapCode.h:127
InDetDD::TRT_EndcapCode::TRT_EndcapCode
TRT_EndcapCode(unsigned int isPositive, unsigned int wheelIndex, unsigned int strawLayerIndex, unsigned int phiIndex)
pmontree.code
code
Definition: pmontree.py:443
InDetDD::TRT_EndcapCode::TRT_EndcapCode
TRT_EndcapCode()
Definition: TRT_EndcapCode.cxx:27
InDetDD::TRT_EndcapCode::getPhiIndex
unsigned int getPhiIndex() const
Definition: TRT_EndcapCode.h:95
InDetDD::TRT_EndcapCode::WHEEL_SHIFT
static const int WHEEL_SHIFT
Definition: TRT_EndcapCode.h:71
eflowRec::phiIndex
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
Definition: EtaPhiLUT.cxx:23
InDetDD::TRT_EndcapCode::operator<
bool operator<(const TRT_EndcapCode &right) const
Definition: TRT_EndcapCode.h:115
InDetDD
Message Stream Member.
Definition: FakeTrackBuilder.h:8
InDetDD::TRT_EndcapCode::operator!=
bool operator!=(const TRT_EndcapCode &right) const
Definition: TRT_EndcapCode.h:110
InDetDD::TRT_EndcapCode::getKey
unsigned int getKey() const
Definition: TRT_EndcapCode.h:100
InDetDD::TRT_EndcapCode::STRAWLAYER_MASK
static const int STRAWLAYER_MASK
Definition: TRT_EndcapCode.h:67