CMS 3D CMS Logo

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