ATLAS Offline Software
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 
19 namespace InDetDD {
20 
27  {
28  public:
29  typedef enum
30  {
31  MODULE_A = 0,
32  MODULE_B = 1,
33  MODULE_C = 2
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 
130 inline 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
InDetDD::TRT_BarrelCode::STRAWLAYER_SHIFT
static const int STRAWLAYER_SHIFT
Definition: TRT_BarrelCode.h:77
InDetDD::TRT_BarrelCode::PHI_SHIFT
static const int PHI_SHIFT
Definition: TRT_BarrelCode.h:76
InDetDD::TRT_BarrelCode::operator=
TRT_BarrelCode & operator=(const TRT_BarrelCode &right)=default
InDetDD::TRT_BarrelCode::Module
Module
Definition: TRT_BarrelCode.h:30
operator<<
std::ostream & operator<<(std::ostream &os, const InDetDD::TRT_BarrelCode &code)
Definition: TRT_BarrelCode.h:130
InDetDD::TRT_BarrelCode::TRT_BarrelCode
TRT_BarrelCode()
Definition: TRT_BarrelCode.cxx:27
InDetDD::TRT_BarrelCode::TRT_BarrelCode
TRT_BarrelCode(TRT_BarrelCode &&right)=default
InDetDD::TRT_BarrelCode::m_key
unsigned short int m_key
Definition: TRT_BarrelCode.h:66
InDetDD::TRT_BarrelCode::operator==
bool operator==(const TRT_BarrelCode &right) const
Definition: TRT_BarrelCode.h:108
InDetDD::TRT_BarrelCode::MODULE_A
@ MODULE_A
Definition: TRT_BarrelCode.h:31
InDetDD::TRT_BarrelCode::operator>
bool operator>(const TRT_BarrelCode &right) const
Definition: TRT_BarrelCode.h:123
InDetDD::TRT_BarrelCode::MODULE_SHIFT
static const int MODULE_SHIFT
Definition: TRT_BarrelCode.h:75
InDetDD::TRT_BarrelCode::operator<
bool operator<(const TRT_BarrelCode &right) const
Definition: TRT_BarrelCode.h:118
InDetDD::TRT_BarrelCode::PHI_MASK
static const int PHI_MASK
Definition: TRT_BarrelCode.h:70
histSizes.code
code
Definition: histSizes.py:129
InDetDD::TRT_BarrelCode::MODULE_C
@ MODULE_C
Definition: TRT_BarrelCode.h:33
maskDeadModules.mod
mod
Definition: maskDeadModules.py:36
InDetDD::TRT_BarrelCode::STRAWLAYER_MASK
static const int STRAWLAYER_MASK
Definition: TRT_BarrelCode.h:71
InDetDD::TRT_BarrelCode::TRT_BarrelCode
TRT_BarrelCode(unsigned int isPositive, unsigned int moduleIndex, unsigned phiIndex, unsigned int strawLayerIndex)
InDetDD::TRT_BarrelCode::MODULE_B
@ MODULE_B
Definition: TRT_BarrelCode.h:32
InDetDD::TRT_BarrelCode::getStrawLayerIndex
unsigned int getStrawLayerIndex() const
Definition: TRT_BarrelCode.h:98
InDetDD::TRT_BarrelCode::isPosZ
unsigned int isPosZ() const
Definition: TRT_BarrelCode.h:83
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
InDetDD::TRT_BarrelCode::getModuleIndex
unsigned int getModuleIndex() const
Definition: TRT_BarrelCode.h:88
InDetDD::TRT_BarrelCode::getName
std::string getName() const
Definition: TRT_BarrelCode.cxx:41
InDetDD::TRT_BarrelCode::Z_SHIFT
static const int Z_SHIFT
Definition: TRT_BarrelCode.h:74
InDetDD::TRT_BarrelCode::~TRT_BarrelCode
~TRT_BarrelCode()=default
eflowRec::phiIndex
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
Definition: EtaPhiLUT.cxx:23
InDetDD
Message Stream Member.
Definition: FakeTrackBuilder.h:8
InDetDD::TRT_BarrelCode
Definition: TRT_BarrelCode.h:27
InDetDD::TRT_BarrelCode::Z_MASK
static const int Z_MASK
Definition: TRT_BarrelCode.h:68
InDetDD::TRT_BarrelCode::getPhiIndex
unsigned int getPhiIndex() const
Definition: TRT_BarrelCode.h:93
InDetDD::TRT_BarrelCode::operator!=
bool operator!=(const TRT_BarrelCode &right) const
Definition: TRT_BarrelCode.h:113
InDetDD::TRT_BarrelCode::MODULE_MASK
static const int MODULE_MASK
Definition: TRT_BarrelCode.h:69
InDetDD::TRT_BarrelCode::getKey
unsigned int getKey() const
Definition: TRT_BarrelCode.h:103
InDetDD::TRT_BarrelCode::TRT_BarrelCode
TRT_BarrelCode(const TRT_BarrelCode &right)=default
InDetDD::TRT_BarrelCode::operator=
TRT_BarrelCode & operator=(TRT_BarrelCode &&right)=default