ATLAS Offline Software
RPCdecoder.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <string>
8 
10 #include "GaudiKernel/MsgStream.h"
11 
13 
14 const int RPCdecoder::s_value_boundaries[4][2] = {
15  {1, 2}, // Min-Max of strip_type value
16  {0, 63}, // Min-Max of logic_sector value
17  {1, 3}, // Min-Max of station value
18  {0, 1} // Min_max of rpc_layer value
19 };
20 const char RPCdecoder::s_value_descriptions[4][15] = {{"strip_type"}, {"logic_sector"}, {"lvl1_station"}, {"rpc_layer"}};
21 
24 
26  this->reset();
27  this->set_indexes(code);
28 }
29 
30 RPCdecoder::RPCdecoder(int strip_type, int logic_sector, int lvl1_station, int rpc_layer, int rpc_z_index, int strip_number) {
31  this->reset();
33 }
34 
35 RPCdecoder::RPCdecoder(ViewType side, int logic_sector, int lvl1_station, int rpc_layer, int rpc_z_index, int strip_number) {
36  this->reset();
37  int strip_type = this->side2type(side);
39 }
40 
42  this->reset();
43  this->set_indexes(deco.code());
44 }
45 
47 
49  this->reset();
50  this->set_indexes(deco.code());
51  return *this;
52 }
53 
56  this->reset_status();
57  this->reset_data();
58 }
59 
61  m_code = 0;
62  m_strip_type = -1;
63  m_logic_sector = -1;
64  m_lvl1_station = -1;
65  m_rpc_layer = -1;
66  m_rpc_z_index = -1;
67  m_strip_number = -1;
68 }
69 
70 void RPCdecoder::reset_status() { m_fail = false; }
71 
73  MsgStream log(Athena::getMessageSvc(), "RPCdecoder");
74  log << MSG::INFO << "fault_decoding() - RPC decoder error: received " << s_value_descriptions[type] << " = " << value
75  << " (min = " << s_value_boundaries[type][0] << ", max = " << s_value_boundaries[type][1] << ")" << endmsg;
76 
77  m_fail = true;
78 }
79 
80 bool RPCdecoder::OK(int value, value_type type) const {
81  if (value >= s_value_boundaries[type][0] && value <= s_value_boundaries[type][1]) return true;
82  return false;
83 }
84 
85 void RPCdecoder::set_code(int strip_type, int logic_sector, int lvl1_station, int rpc_layer, int rpc_z_index, int strip_number) {
90 
91  if (m_fail) {
92  this->reset_data();
93  return;
94  }
95 
96  m_code = strip_type * 100000000 + logic_sector * 1000000 + lvl1_station * 100000 + rpc_layer * 10000 + rpc_z_index * 100 + strip_number;
97 
104 }
105 
106 void RPCdecoder::set_indexes(unsigned int code) {
107  m_strip_number = code % 100;
108  m_rpc_z_index = (code / 100) % 100;
109  m_rpc_layer = (code / 10000) % 10;
110  m_lvl1_station = (code / 100000) % 10;
111  m_logic_sector = (code / 1000000) % 100;
112  m_strip_type = code / 100000000;
113 
118 
119  if (m_fail) {
120  this->reset_data();
121  return;
122  }
123 
124  m_code = code;
125 }
126 
128 
130  this->reset();
131  this->set_indexes(code);
132  return *this;
133 }
134 
135 RPCdecoder& RPCdecoder::operator()(int strip_type, int logic_sector, int lvl1_station, int rpc_layer, int rpc_z_index, int strip_number) {
136  this->reset();
138  return *this;
139 }
140 
141 RPCdecoder& RPCdecoder::operator()(ViewType side, int logic_sector, int lvl1_station, int rpc_layer, int rpc_z_index, int strip_number) {
142  this->reset();
143  int strip_type = side2type(side);
145  return *this;
146 }
147 
149 
151  if (m_strip_type == -1) return NoView;
152  return (m_strip_type == 1) ? Phi : Eta;
153 }
154 
156  if (m_logic_sector == -1) return NoHalf;
157  return (m_logic_sector < 32) ? Negative : Positive;
158 }
159 
161  if (side == NoView) return -1;
162  return (side == Eta) ? 2 : 1;
163 }
164 
165 void RPCdecoder::Print(std::ostream& stream, bool detail) const {
166  unsigned int div = 247;
167  std::string half = (half_barrel() == Negative) ? "Negative" : "Positive";
168 
169  stream << "RPC strip hash code " << code() << ":" << std::endl;
170  if (detail) {
171  stream << " half barrel = " << half << std::endl;
172  stream << " type (1=Phi/2=Eta) = " << strip_type() << std::endl;
173  stream << " logic sector (0" << (char)div << "63) = " << logic_sector() << std::endl;
174  stream << " level-1 station (1" << (char)div << "n) = " << lvl1_station() << std::endl;
175  stream << " RPC layer (0/1) = " << rpc_layer() << std::endl;
176  stream << " RPC z index (0" << (char)div << "n) = " << rpc_z_index() << std::endl;
177  stream << " RPC strip number (0" << (char)div << "n) = " << strip_number() << std::endl;
178  stream << " strip cabling code = " << cabling_code() << std::endl;
179  }
180 }
RPCdecoder
Definition: RPCdecoder.h:13
RPCdecoder::OK
bool OK(int, value_type) const
Definition: RPCdecoder.cxx:80
RPCdecoder::rpc_layer
int rpc_layer(void) const
Definition: RPCdecoder.h:68
RPCdecoder::reset
void reset(void)
Definition: RPCdecoder.cxx:55
RPCdecoder::RPCdecoder
RPCdecoder()
Definition: RPCdecoder.cxx:23
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
RPCdecoder::m_logic_sector
int m_logic_sector
Definition: RPCdecoder.h:28
RPCdecoder::RPC_Layer
@ RPC_Layer
Definition: RPCdecoder.h:15
RPCdecoder::strip_number
int strip_number(void) const
Definition: RPCdecoder.h:70
RPCdecoder::Strip_Type
@ Strip_Type
Definition: RPCdecoder.h:15
RPCdecoder::set_indexes
void set_indexes(unsigned int)
Definition: RPCdecoder.cxx:106
xAOD::char
char
Definition: TrigDecision_v1.cxx:38
RPCdecoder::Logic_Sector
@ Logic_Sector
Definition: RPCdecoder.h:15
NoHalf
@ NoHalf
Definition: RPCdef.h:9
athena.value
value
Definition: athena.py:124
RPCdecoder::m_strip_number
int m_strip_number
Definition: RPCdecoder.h:32
detail
Definition: extract_histogram_tag.cxx:14
Phi
@ Phi
Definition: RPCdef.h:8
RPCdecoder::m_rpc_layer
int m_rpc_layer
Definition: RPCdecoder.h:30
RPCdecoder::m_rpc_z_index
int m_rpc_z_index
Definition: RPCdecoder.h:31
RPCdecoder::rpc_z_index
int rpc_z_index(void) const
Definition: RPCdecoder.h:69
RPCdecoder::LVL1_Station
@ LVL1_Station
Definition: RPCdecoder.h:15
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
RPCdecoder::side2type
int side2type(ViewType side) const
Definition: RPCdecoder.cxx:160
RPCdecoder::fault_decoding
void fault_decoding(int, value_type)
Definition: RPCdecoder.cxx:72
RPCdecoder::s_value_descriptions
static const char s_value_descriptions[4][15]
Definition: RPCdecoder.h:19
TRT::Hit::side
@ side
Definition: HitInfo.h:83
RPCdecoder::m_lvl1_station
int m_lvl1_station
Definition: RPCdecoder.h:29
RPCdecoder::strip_type
int strip_type(void) const
Definition: RPCdecoder.h:65
RPCdecoder::code
unsigned int code(void) const
Definition: RPCdecoder.h:64
histSizes.code
code
Definition: histSizes.py:129
RPCdecoder::Print
void Print(std::ostream &, bool) const
Definition: RPCdecoder.cxx:165
ViewType
ViewType
Definition: RPCdef.h:8
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
RPCdecoder.h
RPCdecoder::set_code
void set_code(int, int, int, int, int, int)
Definition: RPCdecoder.cxx:85
Negative
@ Negative
Definition: RPCdef.h:9
RPCdecoder::lvl1_station
int lvl1_station(void) const
Definition: RPCdecoder.h:67
NoView
@ NoView
Definition: RPCdef.h:8
RPCdecoder::operator=
RPCdecoder & operator=(const RPCdecoder &deco)
Definition: RPCdecoder.cxx:48
RPCdecoder::reset_data
void reset_data(void)
Definition: RPCdecoder.cxx:60
RPCdecoder::s_value_boundaries
static const int s_value_boundaries[4][2]
Definition: RPCdecoder.h:18
Positive
@ Positive
Definition: RPCdef.h:9
RPCdecoder::reset_status
void reset_status(void)
Definition: RPCdecoder.cxx:70
RPCdecoder::m_fail
bool m_fail
Definition: RPCdecoder.h:22
RPCdecoder::m_code
unsigned int m_code
Definition: RPCdecoder.h:25
RPCdecoder::half_barrel
HalfType half_barrel(void) const
Definition: RPCdecoder.cxx:155
RPCdecoder::view
ViewType view(void) const
Definition: RPCdecoder.cxx:150
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
RPCdecoder::cabling_code
int cabling_code(void) const
Definition: RPCdecoder.h:71
RPCdecoder::logic_sector
int logic_sector(void) const
Definition: RPCdecoder.h:66
RPCdecoder::m_strip_type
int m_strip_type
Definition: RPCdecoder.h:27
value_type
Definition: EDM_MasterSearch.h:11
HalfType
HalfType
Definition: RPCdef.h:9
Eta
@ Eta
Definition: RPCdef.h:8
RPCdecoder::operator()
RPCdecoder & operator()(unsigned int)
Definition: RPCdecoder.cxx:129