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 //
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 }
personalPlayback.level
level
Definition: personalPlayback.py:22
ext
Definition: memstream.h:15
start
Definition: start.py:1
L1MuDTTFParameters::get_soc_run_21
bool get_soc_run_21(int wh, int sc) const
Definition: L1MuDTTFParameters.cc:234
MAX_EXT
const int MAX_EXT
Definition: L1MuDTExtParam.h:19
EX13
Definition: L1MuDTExtParam.h:22
L1MuDTTFConfig.h
L1MuDTSecProcId.h
L1MuDTExtrapolationUnit::~L1MuDTExtrapolationUnit
~L1MuDTExtrapolationUnit() override
destructor
Definition: L1MuDTExtrapolationUnit.cc:79
L1MuDTTFParameters.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
L1MuDTSectorProcessor.h
L1MuDTExtrapolationUnit.h
L1MuDTExtrapolationUnit::pars
edm::ESHandle< L1MuDTTFParameters > pars
Definition: L1MuDTExtrapolationUnit.h:98
L1MuDTExtrapolationUnit::getQSTable
const std::bitset< 12 > & getQSTable(Extrapolation ext, unsigned int startAdr) const
get Quality Sorter table for a given SEU
Definition: L1MuDTExtrapolationUnit.cc:222
L1MuDTTrackFinder.h
L1MuDTSectorProcessor::tf
const L1MuDTTrackFinder & tf() const
return reference to barrel MTTF
Definition: L1MuDTSectorProcessor.h:77
L1MuDTERS.h
EX34
Definition: L1MuDTExtParam.h:22
L1MuDTExtrapolationUnit::print
void print(int level=0) const
print all successful extrapolations
Definition: L1MuDTExtrapolationUnit.cc:248
quality
const uint32_t *__restrict__ Quality * quality
Definition: CAHitNtupletGeneratorKernelsImpl.h:122
EX15
Definition: L1MuDTExtParam.h:22
L1MuDTTrackSegPhi.h
L1MuDTSectorProcessor::id
const L1MuDTSecProcId & id() const
return Sector Processor identifier
Definition: L1MuDTSectorProcessor.h:74
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
L1MuDTExtrapolationUnit::getAddress
unsigned short int getAddress(Extrapolation ext, unsigned int startAdr, int id) const
get extrapolation address from a given ERS
Definition: L1MuDTExtrapolationUnit.cc:167
L1MuDTExtrapolationUnit::L1MuDTExtrapolationUnit
L1MuDTExtrapolationUnit(const L1MuDTSectorProcessor &)
constructor
Definition: L1MuDTExtrapolationUnit.cc:55
L1MuDTSecProcId::wheel
int wheel() const
return wheel number
Definition: L1MuDTSecProcId.h:55
Extrapolation
Extrapolation
Definition: L1MuDTExtParam.h:22
L1MuDTTFConfig::getUseEX21
bool getUseEX21() const
Definition: L1MuDTTFConfig.h:62
L1MuDTExtrapolationUnit::reset
void reset() override
reset Extrapolation Unit
Definition: L1MuDTExtrapolationUnit.cc:144
source
static const std::string source
Definition: EdmProvDump.cc:47
L1MuDTSectorProcessor::data
const L1MuDTDataBuffer * data() const
return pointer to Data Buffer
Definition: L1MuDTSectorProcessor.h:86
svgfig.load
def load(fileName)
Definition: svgfig.py:547
L1MuDTExtParam.h
EX21
Definition: L1MuDTExtParam.h:22
L1MuDTSEU::ext
Extrapolation ext() const
return extrapolation type
Definition: L1MuDTSEU.h:78
L1MuDTSecProcId::sector
int sector() const
return sector number
Definition: L1MuDTSecProcId.h:58
EX23
Definition: L1MuDTExtParam.h:22
EX12
Definition: L1MuDTExtParam.h:22
L1MuDTExtrapolationUnit::m_SEUs
SEUmap m_SEUs
Definition: L1MuDTExtrapolationUnit.h:96
EX25
Definition: L1MuDTExtParam.h:22
L1MuDTEUX.h
L1AbstractProcessor::run
virtual void run()
run processor logic
Definition: L1AbstractProcessor.h:40
L1MuDTTrackSegPhi::empty
bool empty() const
is it an empty phi track segment?
Definition: L1MuDTTrackSegPhi.h:110
EX24
Definition: L1MuDTExtParam.h:22
L1MuDTSEU.h
edm::EventSetup
Definition: EventSetup.h:58
L1MuDTDataBuffer.h
L1MuDTTrackFinder::config
static L1MuDTTFConfig * config()
return configuration
Definition: L1MuDTTrackFinder.h:102
get
#define get
L1MuDTExtrapolationUnit::numberOfExt
int numberOfExt() const
return number of successful extrapolations
Definition: L1MuDTExtrapolationUnit.cc:235
L1MuDTSectorProcessor
Definition: L1MuDTSectorProcessor.h:53
std
Definition: JetResolutionObject.h:76
L1MuDTExtrapolationUnit::SEUId
std::pair< Extrapolation, unsigned int > SEUId
Definition: L1MuDTExtrapolationUnit.h:54
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
L1MuDTSEU::tsId
unsigned int tsId() const
return start track segment identifier (relative address)
Definition: L1MuDTSEU.h:81
filterCSVwithJSON.target
target
Definition: filterCSVwithJSON.py:32
L1MuDTTrackSegPhi
Definition: L1MuDTTrackSegPhi.h:36
L1MuDTExtrapolationUnit::which_ext
static std::pair< int, int > which_ext(Extrapolation ext)
return station of start and target track segment for a given extrapolation
Definition: L1MuDTExtrapolationUnit.cc:292
L1MuDTDataBuffer::getTSphi
const TSPhivector & getTSphi() const
get all track segments from the buffer
Definition: L1MuDTDataBuffer.h:56
L1MuDTExtrapolationUnit::m_sp
const L1MuDTSectorProcessor & m_sp
Definition: L1MuDTExtrapolationUnit.h:94
L1MuDTExtrapolationUnit::getQuality
unsigned short int getQuality(Extrapolation ext, unsigned int startAdr, int id) const
get extrapolation quality from a given ERS
Definition: L1MuDTExtrapolationUnit.cc:188
EX14
Definition: L1MuDTExtParam.h:22
L1MuDTTFConfig::Debug
static bool Debug()
Definition: L1MuDTTFConfig.h:49
L1MuDTSEU
Definition: L1MuDTSEU.h:48
L1MuDTTFParametersRcd.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
L1MuDTExtrapolationUnit::getEXTable
const std::bitset< 12 > & getEXTable(Extrapolation ext, unsigned int startAdr) const
get Extrapolator table for a given SEU
Definition: L1MuDTExtrapolationUnit.cc:209
L1MuDTTFParametersRcd
Definition: L1MuDTTFParametersRcd.h:10