CMS 3D CMS Logo

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