CMS 3D CMS Logo

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