ATLAS Offline Software
Loading...
Searching...
No Matches
SiCellId.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// SiCellId.h
8// (c) ATLAS Detector software
10
11#ifndef INDETREADOUTGEOMETRY_SICELLID_H
12#define INDETREADOUTGEOMETRY_SICELLID_H
13
14#include <iostream>
15
16namespace InDetDD {
17
28
29 class SiCellId {
30
32 // Public methods:
34 public:
35
37 SiCellId();
39 SiCellId(int strip);
41 SiCellId(int phiIndex, int etaIndex);
42
44 // Const methods:
46
47 // Get the indices
48 // NB. phiIndex() and strip() are equivalent.
50 int etaIndex() const;
52 int phiIndex() const;
54 int strip() const;
55
57 bool isValid() const;
58
60 bool operator==(const SiCellId & other) const;
62 bool operator!=(const SiCellId & other) const;
63
65 bool operator<(const SiCellId & other) const;
66
67 unsigned int word() const { return m_word; }
68
69private:
70 unsigned int m_word;
71
72 // Masks and shift values.
73 // bits 0 - 15 : phi_index
74 // bits 16 - 30 : eta_index
75 // bit 31 : valid flag
77 PHI_MASK = 0x0000ffff,
78 PHI_NEG = 0x00008000, // (PHI_MASK >> 1 + 1)
79 ETA_MASK = 0x00007fff,
81 ETA_NEG = 0x40000000, // ((ETA_MASK >> 1 + 1) << ETA_SHIFT)
82 VALID = 0x80000000
83 };
84
85};
86
87std::ostream & operator << (std::ostream & os, const SiCellId & cellId);
88
90// Inline methods:
93{
94 // set in invalid state
95 // This sets the invalid bit plus set phi and eta index to their most negative value
97}
98
100{
101 // The negative check is not really necessary if negative numbers are represented as twos complement but
102 // I don't think that assumption is guaranteed to be portable.
103 if (phiIndex < 0) phiIndex = PHI_MASK + phiIndex + 1; // For negative number store as two's complement
104 if (etaIndex < 0) etaIndex = ETA_MASK + etaIndex + 1;
106}
107
109{
110 if (strip < 0) strip = PHI_MASK + strip + 1;
112}
113
114inline int SiCellId::etaIndex() const
115{
116 if (m_word & ETA_NEG) { // Negative index
117 return ((m_word >> ETA_SHIFT) & ETA_MASK) - ETA_MASK - 1;
118 }
119 return (m_word >> ETA_SHIFT) & ETA_MASK;
120}
121
122inline int SiCellId::phiIndex() const
123{
124 if (m_word & PHI_NEG) { // Negative index
125 return (m_word & PHI_MASK) - PHI_MASK - 1;
126 }
127 return (m_word & PHI_MASK);
128
129}
130
131inline int SiCellId::strip() const
132{
133 return phiIndex();
134}
135
136inline bool SiCellId::isValid() const
137{
138 return !(m_word & VALID);
139}
140
141inline bool SiCellId::operator==(const SiCellId & other) const
142{
143 return (m_word == other.m_word);
144}
145
146inline bool SiCellId::operator!=(const SiCellId & other) const
147{
148 return (m_word != other.m_word);
149}
150
151inline bool SiCellId::operator<(const SiCellId & other) const
152{
153 return (m_word < other.m_word);
154}
155
156
157} // namespace InDetDD
158
159
160#endif // INDETREADOUTGEOMETRY_SICELLID_H
bool operator==(const SiCellId &other) const
Test equality.
Definition SiCellId.h:141
int strip() const
Get strip number. Equivalent to phiIndex().
Definition SiCellId.h:131
SiCellId()
Constructor. Set in invalid state.
Definition SiCellId.h:92
int phiIndex() const
Get phi index. Equivalent to strip().
Definition SiCellId.h:122
bool operator!=(const SiCellId &other) const
Test inequality.
Definition SiCellId.h:146
unsigned int word() const
Definition SiCellId.h:67
bool isValid() const
Test if its in a valid state.
Definition SiCellId.h:136
int etaIndex() const
Get eta index.
Definition SiCellId.h:114
unsigned int m_word
Definition SiCellId.h:70
bool operator<(const SiCellId &other) const
Operator for sorting.
Definition SiCellId.h:151
Identifier for the strip or pixel cell.
Definition SiCellId.h:29
Message Stream Member.
std::ostream & operator<<(std::ostream &os, const SiCellId &cellId)
Definition SiCellId.cxx:8