CMS 3D CMS Logo

RPCWheel.cc
Go to the documentation of this file.
1 // Include files
2 #include <array>
3 
4 // local
6 #include "GeometryConstants.h"
7 //-----------------------------------------------------------------------------
8 // Implementation file for class : RPCWheel
9 //
10 // 2008-10-15 : Andres Osorio
11 //-----------------------------------------------------------------------------
12 using namespace rpctechnicaltrigger;
13 
14 //=============================================================================
15 // Standard constructor, initializes variables
16 //=============================================================================
17 RPCWheel::RPCWheel() : m_id{0}, m_debug{false} {}
18 
19 void RPCWheel::setProperties(int wid) {
20  m_id = wid;
21 
22  int bisector[2];
23 
24  m_RBCE.reserve(m_maxrbc);
25  for (int k = 0; k < m_maxrbc; ++k) {
26  bisector[0] = s_sec1id[k];
27  bisector[1] = s_sec2id[k];
28  m_RBCE.emplace_back(std::make_unique<RBCEmulator>());
29  m_RBCE[k]->setid(wid, bisector);
30  }
31 
32  for (int k = 0; k < m_maxsectors; ++k)
33  m_wheelmap[k].reset();
34 }
35 
36 void RPCWheel::setProperties(int wid, const char* logic_type) {
37  m_id = wid;
38 
39  int bisector[2];
40  m_RBCE.reserve(m_maxrbc);
41  for (int k = 0; k < m_maxrbc; ++k) {
42  bisector[0] = s_sec1id[k];
43  bisector[1] = s_sec2id[k];
44  m_RBCE.push_back(std::make_unique<RBCEmulator>(logic_type));
45  m_RBCE[k]->setid(wid, bisector);
46  }
47 
48  for (int k = 0; k < m_maxsectors; ++k)
49  m_wheelmap[k].reset();
50 }
51 
52 void RPCWheel::setProperties(int wid, const char* f_name, const char* logic_type) {
53  m_id = wid;
54 
55  int bisector[2];
56 
57  m_RBCE.reserve(m_maxrbc);
58  for (int k = 0; k < m_maxrbc; ++k) {
59  bisector[0] = (k * 2) + 1;
60  bisector[1] = (k * 2) + 2;
61  m_RBCE.push_back(std::make_unique<RBCEmulator>(f_name, logic_type));
62  m_RBCE[k]->setid(wid, bisector);
63  }
64 
65  for (int k = 0; k < m_maxsectors; ++k)
66  m_wheelmap[k].reset();
67 }
68 
69 //=============================================================================
71  for (int k = 0; k < m_maxrbc; ++k)
72  m_RBCE[k]->setSpecifications(rbcspecs);
73 }
74 
76  bool status(false);
77  for (int k = 0; k < m_maxrbc; ++k)
78  status = m_RBCE[k]->initialise();
79  return status;
80 }
81 
83  //This is a test emulation
84  for (int k = 0; k < m_maxrbc; ++k) {
85  m_RBCE[k]->emulate();
86  }
87 }
88 
89 bool RPCWheel::process(int bx, const std::map<int, RBCInput*>& data) {
90  int bxsign(1);
91  bool status(false);
92 
93  std::map<int, RBCInput*>::const_iterator itr;
94 
95  if (bx != 0)
96  bxsign = (bx / abs(bx));
97  else
98  bxsign = 1;
99 
100  for (int k = 0; k < m_maxrbc; ++k) {
101  m_RBCE[k]->reset();
102 
103  int key = bxsign * (1000000 * abs(bx) + m_RBCE[k]->rbcinfo().wheelIdx() * 10000 +
104  m_RBCE[k]->rbcinfo().sector(0) * 100 + m_RBCE[k]->rbcinfo().sector(1));
105 
106  itr = data.find(key);
107 
108  if (itr != data.end()) {
109  if (!(*itr).second->hasData) {
110  status |= false;
111  continue;
112  } else {
113  if (m_debug)
114  std::cout << "RPCWheel::process> found data at: " << key << '\t' << (itr->second) << std::endl;
115  m_RBCE[k]->emulate((itr->second));
116  status |= true;
117  }
118 
119  } else {
120  //if( m_debug ) std::cout << "RPCWheel::process> position not found: " << key << std::endl;
121  status |= false;
122  }
123  }
124 
125  return status;
126 }
127 
128 bool RPCWheel::process(int bx, const std::map<int, TTUInput*>& data) {
129  int bxsign(1);
130  bool status(false);
131 
132  std::map<int, TTUInput*>::const_iterator itr;
133 
134  if (bx != 0)
135  bxsign = (bx / abs(bx));
136  else
137  bxsign = 1;
138 
139  int key = bxsign * (1000000 * abs(bx) + (m_id + 2) * 10000);
140 
141  itr = data.find(key);
142 
143  if (itr != data.end()) {
144  if (m_debug)
145  std::cout << "RPCWheel::process> found data at: " << key << '\t' << (itr->second) << std::endl;
146 
147  if (!(*itr).second->m_hasHits)
148  return false;
149 
150  for (int k = 0; k < m_maxsectors; ++k) {
151  m_wheelmap[k] = (*itr).second->input_sec[k];
152  status = true;
153  }
154 
155  } else {
156  //if( m_debug ) std::cout << "RPCWheel::process> position not found: " << key << std::endl;
157  status = false;
158  }
159 
160  return status;
161 }
162 
163 //.............................................................................
164 
166  m_rbcDecision.reset();
167 
168  std::bitset<6> layersignal;
169 
170  layersignal = *m_RBCE[0]->getlayersignal(0);
171  m_wheelmap[11] = layersignal;
172 
173  m_rbcDecision.set(11, m_RBCE[0]->getdecision(0));
174 
175  for (int k = 0; k < (m_maxrbc - 1); ++k) {
176  layersignal = *m_RBCE[k + 1]->getlayersignal(0);
177  m_wheelmap[(k * 2) + 1] = layersignal;
178  layersignal = *m_RBCE[k + 1]->getlayersignal(1);
179  m_wheelmap[(k * 2) + 2] = layersignal;
180 
181  m_rbcDecision.set((k * 2) + 1, m_RBCE[k + 1]->getdecision(0));
182  m_rbcDecision.set((k * 2) + 2, m_RBCE[k + 1]->getdecision(1));
183  }
184 
185  layersignal = *m_RBCE[0]->getlayersignal(1);
186  m_wheelmap[0] = layersignal;
187 
188  m_rbcDecision.set(0, m_RBCE[0]->getdecision(1));
189 
190  if (m_debug)
191  std::cout << "RPCWheel::createWheelMap done" << std::endl;
192 }
193 
195  if (m_debug)
196  std::cout << "RPCWheel::retrieveWheelMap starts" << std::endl;
197  output.reset();
198 
199  for (int i = 0; i < m_maxsectors; ++i) {
200  for (int j = 0; j < m_maxlayers; ++j) {
201  output.input_sec[i].set(j, m_wheelmap[i][j]);
202  }
203  }
204 
205  output.m_wheelId = m_id;
206 
207  output.m_rbcDecision = m_rbcDecision;
208 
209  if (m_debug)
211  if (m_debug)
212  std::cout << "RPCWheel::retrieveWheelMap done" << std::endl;
213 }
214 
215 //=============================================================================
216 
217 void RPCWheel::printinfo() const {
218  std::cout << "Wheel -> " << m_id << '\n';
219  for (int k = 0; k < m_maxrbc; ++k)
220  m_RBCE[k]->printinfo();
221 }
222 
223 void RPCWheel::print_wheel(const TTUInput& wmap) const {
224  std::cout << "RPCWheel::print_wheel> " << wmap.m_wheelId << '\t' << wmap.m_bx << std::endl;
225 
226  for (int i = 0; i < m_maxsectors; ++i)
227  std::cout << '\t' << (i + 1);
228  std::cout << std::endl;
229 
230  for (int k = 0; k < m_maxlayers; ++k) {
231  std::cout << (k + 1) << '\t';
232  for (int j = 0; j < m_maxsectors; ++j)
233  std::cout << wmap.input_sec[j][k] << '\t';
234  std::cout << std::endl;
235  }
236 }
237 
238 //=============================================================================
mps_fire.i
i
Definition: mps_fire.py:428
rpctechnicaltrigger
Definition: GeometryConstants.cc:18
RPCWheel::print_wheel
void print_wheel(const TTUInput &) const
Definition: RPCWheel.cc:223
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
mps_update.status
status
Definition: mps_update.py:68
RPCWheel::m_maxlayers
static constexpr int m_maxlayers
Definition: RPCWheel.h:62
gather_cfg.cout
cout
Definition: gather_cfg.py:144
RPCWheel::m_debug
bool m_debug
Definition: RPCWheel.h:70
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
RPCWheel::m_rbcDecision
std::bitset< 12 > m_rbcDecision
Definition: RPCWheel.h:67
rpctechnicaltrigger::s_sec1id
constexpr std::array< int, 6 > s_sec1id
Definition: GeometryConstants.h:29
RPCWheel::m_wheelmap
std::array< std::bitset< 6 >, 12 > m_wheelmap
Definition: RPCWheel.h:68
TTUInput::m_wheelId
int m_wheelId
Definition: TTUInput.h:32
RPCWheel::m_id
int m_id
Definition: RPCWheel.h:60
TTUInput
Definition: TTUInput.h:18
dqmdumpme.k
k
Definition: dqmdumpme.py:60
RBCBoardSpecs
Definition: RBCBoardSpecs.h:17
RPCWheel::process
bool process(int, const std::map< int, RBCInput * > &)
Definition: RPCWheel.cc:89
RPCWheel::RPCWheel
RPCWheel()
Standard constructor.
Definition: RPCWheel.cc:17
RPCWheel::m_maxrbc
static constexpr int m_maxrbc
Definition: RPCWheel.h:61
RPCWheel::m_maxsectors
static constexpr int m_maxsectors
Definition: RPCWheel.h:63
RPCWheel::createWheelMap
void createWheelMap()
Definition: RPCWheel.cc:165
RPCWheel::initialise
bool initialise()
Definition: RPCWheel.cc:75
GeometryConstants.h
RPCWheel::setProperties
void setProperties(int)
Definition: RPCWheel.cc:19
RPCWheel::m_RBCE
std::vector< std::unique_ptr< RBCEmulator > > m_RBCE
Definition: RPCWheel.h:58
RPCWheel::retrieveWheelMap
void retrieveWheelMap(TTUInput &)
Definition: RPCWheel.cc:194
TTUInput::m_bx
int m_bx
Definition: TTUInput.h:30
TTUInput::input_sec
std::array< std::bitset< 6 >, 12 > input_sec
Definition: TTUInput.h:36
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
reset
void reset(double vett[256])
Definition: TPedValues.cc:11
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
RPCWheel::setSpecifications
void setSpecifications(const RBCBoardSpecs *)
Definition: RPCWheel.cc:70
rpctechnicaltrigger::s_sec2id
constexpr std::array< int, 6 > s_sec2id
Definition: GeometryConstants.h:30
RPCWheel.h
RPCWheel::printinfo
void printinfo() const
Definition: RPCWheel.cc:217
crabWrapper.key
key
Definition: crabWrapper.py:19
RPCWheel::emulate
void emulate()
Definition: RPCWheel.cc:82