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