test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1MuDTExtrapolationUnit.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuDTExtrapolationUnit
4 //
5 // Description: Extrapolation Unit
6 //
7 //
8 //
9 // Author :
10 // N. Neumeister CERN EP
11 //
12 //--------------------------------------------------
13 
14 //-----------------------
15 // This Class's Header --
16 //-----------------------
17 
19 
20 //---------------
21 // C++ Headers --
22 //---------------
23 
24 #include <iostream>
25 #include <bitset>
26 #include <cassert>
27 
28 //-------------------------------
29 // Collaborating Class Headers --
30 //-------------------------------
31 
43 
44 using namespace std;
45 
46 // --------------------------------
47 // class L1MuDTExtrapolationUnit
48 //---------------------------------
49 
50 //----------------
51 // Constructors --
52 //----------------
53 
55  m_sp(sp), m_SEUs() {
56 
57  for ( int ext_idx = 0; ext_idx < MAX_EXT; ext_idx++ ) {
58 
59  Extrapolation ext = static_cast<Extrapolation>(ext_idx);
60 
61  if ( ext == EX12 || ext == EX13 || ext == EX14 ||
62  ext == EX21 || ext == EX23 || ext == EX24 || ext == EX34 ) {
63 
64  unsigned int maxaddr = 4;
65 
66  if ( ext == EX12 || ext == EX13 || ext == EX14 ) maxaddr = 2;
67 
68  for ( unsigned int startAddress = 0; startAddress < maxaddr; startAddress++ ) {
69  SEUId id = make_pair(ext, startAddress);
70  m_SEUs[id] = new L1MuDTSEU(sp,ext,startAddress);
71  if ( L1MuDTTFConfig::Debug(6) ) cout << " creating SEU " << ext << " " << startAddress << endl;
72  }
73  }
74  }
75 
76 }
77 
78 
79 //--------------
80 // Destructor --
81 //--------------
82 
84 
85  for ( SEUmap::iterator iter = m_SEUs.begin(); iter != m_SEUs.end(); iter++ ) {
86  delete (*iter).second;
87  (*iter).second = 0;
88  }
89  m_SEUs.clear();
90 
91 }
92 
93 
94 //--------------
95 // Operations --
96 //--------------
97 
98 //
99 // run Extrapolation Unit
100 //
102 
103  c.get< L1MuDTTFParametersRcd >().get( pars );
104 
105  SEUmap::const_iterator iter;
106  for ( iter = m_SEUs.begin(); iter != m_SEUs.end(); iter++ ) {
107 
108  pair<int,int> ext_pair = which_ext(((*iter).second)->ext());
109  int start = ext_pair.first;
110 
111  const L1MuDTTrackSegPhi* ts = 0;
112 
113  //get start track segment
114  ts = m_sp.data()->getTSphi(start, ((*iter).second)->tsId() );
115 
116  if ( ts != 0 && !ts->empty() ) {
117  ((*iter).second)->load(ts);
118  ((*iter).second)->run(c);
119  }
120 
121  }
122 
123  //
124  // use EX21 to cross-check EX12
125  //
126  bool run_21 = pars->get_soc_run_21(m_sp.id().wheel(), m_sp.id().sector());
127  if ( L1MuDTTFConfig::getUseEX21() || run_21 ) {
128 
129  // search for EX12 + EX21 single extrapolation units
130  for ( unsigned int startAdr = 0; startAdr < 2; startAdr++ ) {
131 
132  bitset<12> extab12 = this->getEXTable( EX12, startAdr );
133  bitset<12> extab21 = this->getEXTable( EX21, startAdr );
134 
135  for ( int eux = 0; eux < 12; eux++ ) {
136  if ( extab12.test(eux) && !extab21.test(eux) ) {
137  reset(EX12,startAdr,eux);
138  if ( L1MuDTTFConfig::Debug(6) ) {
139  SEUId seuid = make_pair(EX12, startAdr);
140  L1MuDTSEU* SEU12 = m_SEUs[seuid];
141  cout << " EX12 - EX21 mismatch : "
142  << " EX12 : " << extab12 << " , "
143  << " EX21 : " << extab21 << endl
144  << " Cancel: " << SEU12->ext()
145  << " start addr = " << SEU12->tsId()
146  << " target addr = " << eux << endl;
147  }
148  }
149  }
150 
151  }
152  }
153 
154 }
155 
156 
157 //
158 // reset Extrapolation Unit
159 //
161 
162  SEUmap::const_iterator iter;
163  for ( iter = m_SEUs.begin(); iter != m_SEUs.end(); iter++ ) {
164  ((*iter).second)->reset();
165  }
166 
167 }
168 
169 
170 //
171 // reset a single extrapolation
172 //
173 void L1MuDTExtrapolationUnit::reset(Extrapolation ext, unsigned int startAdr, unsigned int relAdr) {
174 
175  // assert( startAdr >= 0 && startAdr <= 3 );
176  // assert( relAdr >= 0 && relAdr <= 12 );
177 
178  SEUId seuid = make_pair(ext, startAdr);
179  SEUmap::const_iterator iter = m_SEUs.find(seuid);
180  if ( iter != m_SEUs.end() ) ((*iter).second)->reset(relAdr);
181 
182 }
183 
184 
185 //
186 // get extrapolation address from ERS
187 //
188 unsigned short int L1MuDTExtrapolationUnit::getAddress(Extrapolation ext, unsigned int startAdr, int id) const {
189 
190  // get extrapolation address from ERS
191  // startAdr = 0, 1 : own wheel
192  // startAdr = 2, 3 : next wheel neighbour
193 
194  // assert( startAdr >= 0 && startAdr <= 3 );
195  // assert( id == 0 || id == 1 );
196 
197  unsigned short int address = 15;
198 
199  SEUId seuid = make_pair(ext, startAdr);
200  SEUmap::const_iterator iter = m_SEUs.find(seuid);
201  if ( iter != m_SEUs.end() ) address = ((*iter).second)->ers()->address(id);
202 
203  return address;
204 
205 }
206 
207 
208 //
209 // get extrapolation quality from ERS
210 //
211 unsigned short int L1MuDTExtrapolationUnit::getQuality(Extrapolation ext, unsigned int startAdr, int id) const {
212 
213  // get extrapolation quality from ERS
214  // startAdr = 0, 1 : own wheel
215  // startAdr = 2, 3 : next wheel neighbour
216 
217  // assert( startAdr >= 0 && startAdr <= 3 );
218  // assert( id == 0 || id == 1 );
219 
220  unsigned short int quality = 0;
221 
222  SEUId seuid = make_pair(ext, startAdr);
223  SEUmap::const_iterator iter = m_SEUs.find(seuid);
224  if ( iter != m_SEUs.end() ) quality = ((*iter).second)->ers()->quality(id);
225 
226  return quality;
227 
228 }
229 
230 
231 //
232 // get Extrapolator table for a given SEU
233 //
234 const bitset<12>& L1MuDTExtrapolationUnit::getEXTable(Extrapolation ext, unsigned int startAdr) const {
235 
236  // startAdr = 0, 1 : own wheel
237  // startAdr = 2, 3 : next wheel neighbour
238 
239  // assert( startAdr >= 0 && startAdr <= 3 );
240 
241  SEUId seuid = make_pair(ext, startAdr);
242  return m_SEUs[seuid]->exTable();
243 
244 }
245 
246 
247 //
248 // get Quality Sorter table for a given SEU
249 //
250 const bitset<12>& L1MuDTExtrapolationUnit::getQSTable(Extrapolation ext, unsigned int startAdr) const {
251 
252  // startAdr = 0, 1 : own wheel
253  // startAdr = 2, 3 : next wheel neighbour
254 
255  // assert( startAdr >= 0 && startAdr <= 3 );
256 
257  SEUId seuid = make_pair(ext, startAdr);
258  return m_SEUs[seuid]->qsTable();
259 
260 }
261 
262 
263 //
264 // get number of successful extrapolations
265 //
267 
268  int number = 0;
269  SEUmap::const_iterator iter;
270  for ( iter = m_SEUs.begin(); iter != m_SEUs.end(); iter++ ) {
271  number += ((*iter).second)->numberOfExt();
272  }
273 
274  return number;
275 
276 }
277 
278 
279 //
280 // print all successful extrapolations
281 //
283 
284  SEUmap::const_iterator iter_seu;
285 
286  if ( level == 0 ) {
287  for ( iter_seu = m_SEUs.begin(); iter_seu != m_SEUs.end(); iter_seu++ ) {
288  vector<L1MuDTEUX*> vec_eux = ((*iter_seu).second)->eux();
289  vector<L1MuDTEUX*>::const_iterator iter_eux;
290  for ( iter_eux = vec_eux.begin();
291  iter_eux != vec_eux.end(); iter_eux++ ) {
292  if ( (*iter_eux)->result() ) {
293  cout << ((*iter_seu).second)->ext() << " "
294  << ((*iter_seu).second)->tsId() << " "
295  << (*iter_eux)->id() << endl;
296  cout << "start : " << *(*iter_eux)->ts().first << endl;
297  cout << "target : " << *(*iter_eux)->ts().second << endl;
298  cout << "result : " << "quality = " << (*iter_eux)->quality() << '\t'
299  << "address = " << (*iter_eux)->address() << endl;
300  }
301  }
302  }
303  }
304 
305  //
306  // print all results from Extrapolator and Quality Sorter
307  //
308  if ( level == 1 ) {
309  cout << "Results from Extrapolator and Quality Sorter of " << m_sp.id()
310  << " : \n" << endl;
311 
312  cout << " EXT QSU " << endl;
313  cout << " S E U 11 11 " << endl;
314  cout << " 109876543210 109876543210 " << endl;
315  cout << "-------------------------------------" << endl;
316  for ( iter_seu = m_SEUs.begin(); iter_seu != m_SEUs.end(); iter_seu++ ) {
317 
318  cout << ((*iter_seu).second)->ext() << "_ "
319  << ((*iter_seu).second)->tsId() << ": "
320  << ((*iter_seu).second)->exTable() << " "
321  << ((*iter_seu).second)->qsTable() << endl;
322 
323  }
324 
325  cout << endl;
326  }
327 
328 }
329 
330 
331 // static
332 
333 //
334 // get station of start and target track segment for a given extrapolation
335 //
337 
338  int source = 0;
339  int target = 0;
340 
341  // assert( ext >= 0 && ext < MAX_EXT );
342 
343  switch ( ext ) {
344  case EX12 : { source = 1; target = 2; break; }
345  case EX13 : { source = 1; target = 3; break; }
346  case EX14 : { source = 1; target = 4; break; }
347  case EX21 : { source = 1; target = 2; break; }
348  case EX23 : { source = 2; target = 3; break; }
349  case EX24 : { source = 2; target = 4; break; }
350  case EX34 : { source = 3; target = 4; break; }
351  case EX15 : { source = 1; target = 3; break; }
352  case EX25 : { source = 2; target = 3; break; }
353  default : { source = 1; target = 2; break; }
354  }
355 
356  return pair<int,int>(source,target);
357 
358 }
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
Extrapolation ext() const
return extrapolation type
Definition: L1MuDTSEU.h:80
const std::bitset< 12 > & getEXTable(Extrapolation ext, unsigned int startAdr) const
get Extrapolator table for a given SEU
std::pair< Extrapolation, unsigned int > SEUId
virtual void reset()
reset Extrapolation Unit
unsigned short int getQuality(Extrapolation ext, unsigned int startAdr, int id) const
get extrapolation quality from a given ERS
void print(int level=0) const
print all successful extrapolations
int sector() const
return sector number
const L1MuDTDataBuffer * data() const
return pointer to Data Buffer
const std::bitset< 12 > & getQSTable(Extrapolation ext, unsigned int startAdr) const
get Quality Sorter table for a given SEU
const L1MuDTSectorProcessor & m_sp
L1MuDTExtrapolationUnit(const L1MuDTSectorProcessor &)
constructor
virtual void run()
run processor logic
const int MAX_EXT
def load
Definition: svgfig.py:546
unsigned short int getAddress(Extrapolation ext, unsigned int startAdr, int id) const
get extrapolation address from a given ERS
bool empty() const
is it an empty phi track segment?
static bool Debug()
const L1MuDTSecProcId & id() const
return Sector Processor identifier
Extrapolation
static std::pair< int, int > which_ext(Extrapolation ext)
return station of start and target track segment for a given extrapolation
const TSPhivector & getTSphi() const
get all track segments from the buffer
static bool getUseEX21()
const T & get() const
Definition: EventSetup.h:56
edm::ESHandle< L1MuDTTFParameters > pars
int numberOfExt() const
return number of successful extrapolations
int wheel() const
return wheel number
tuple cout
Definition: gather_cfg.py:145
virtual ~L1MuDTExtrapolationUnit()
destructor
tuple level
Definition: testEve_cfg.py:34
Definition: sp.h:21
static std::string const source
Definition: EdmProvDump.cc:43
unsigned int tsId() const
return start track segment identifier (relative address)
Definition: L1MuDTSEU.h:83