CMS 3D CMS Logo

L1MuBMExtrapolationUnit.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuBMExtrapolationUnit
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 
41 
44 
45 using namespace std;
46 
47 // --------------------------------
48 // class L1MuBMExtrapolationUnit
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 L1MuBMSEU(sp, ext, startAddress);
68  if (L1MuBMTFConfig::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  const L1TMuonBarrelParamsRcd& bmtfParamsRcd = c.get<L1TMuonBarrelParamsRcd>();
97  bmtfParamsRcd.get(bmtfParamsHandle);
98  const L1TMuonBarrelParams& bmtfParams = *bmtfParamsHandle.product();
99  pars = bmtfParams.l1mudttfparams;
100 
101  SEUmap::const_iterator iter;
102  for (iter = m_SEUs.begin(); iter != m_SEUs.end(); iter++) {
103  pair<int, int> ext_pair = which_ext(((*iter).second)->ext());
104  int start = ext_pair.first;
105 
106  const L1MuBMTrackSegPhi* ts = nullptr;
107 
108  //get start track segment
109  ts = m_sp.data()->getTSphi(start, ((*iter).second)->tsId());
110 
111  if (ts != nullptr && !ts->empty()) {
112  ((*iter).second)->load(ts);
113  ((*iter).second)->run(c);
114  }
115  }
116 
117  //
118  // use EX21 to cross-check EX12
119  //
120  bool run_21 = pars.get_soc_run_21(m_sp.id().wheel(), m_sp.id().sector());
121  if (L1MuBMTFConfig::getUseEX21() || run_21) {
122  // search for EX12 + EX21 single extrapolation units
123  for (unsigned int startAdr = 0; startAdr < 2; startAdr++) {
124  bitset<12> extab12 = this->getEXTable(EX12, startAdr);
125  bitset<12> extab21 = this->getEXTable(EX21, startAdr);
126 
127  for (int eux = 0; eux < 12; eux++) {
128  if (extab12.test(eux) && !extab21.test(eux)) {
129  reset(EX12, startAdr, eux);
130  if (L1MuBMTFConfig::Debug(6)) {
131  SEUId seuid = make_pair(EX12, startAdr);
132  L1MuBMSEU* SEU12 = m_SEUs[seuid];
133  cout << " EX12 - EX21 mismatch : "
134  << " EX12 : " << extab12 << " , "
135  << " EX21 : " << extab21 << endl
136  << " Cancel: " << SEU12->ext() << " start addr = " << SEU12->tsId() << " target addr = " << eux
137  << endl;
138  }
139  }
140  }
141  }
142  }
143 }
144 
145 //
146 // reset Extrapolation Unit
147 //
149  SEUmap::const_iterator iter;
150  for (iter = m_SEUs.begin(); iter != m_SEUs.end(); iter++) {
151  ((*iter).second)->reset();
152  }
153 }
154 
155 //
156 // reset a single extrapolation
157 //
158 void L1MuBMExtrapolationUnit::reset(Extrapolation ext, unsigned int startAdr, unsigned int relAdr) {
159  // assert( startAdr >= 0 && startAdr <= 3 );
160  // assert( relAdr >= 0 && relAdr <= 12 );
161 
162  SEUId seuid = make_pair(ext, startAdr);
163  SEUmap::const_iterator iter = m_SEUs.find(seuid);
164  if (iter != m_SEUs.end())
165  ((*iter).second)->reset(relAdr);
166 }
167 
168 //
169 // get extrapolation address from ERS
170 //
171 unsigned short int L1MuBMExtrapolationUnit::getAddress(Extrapolation ext, unsigned int startAdr, int id) const {
172  // get extrapolation address from ERS
173  // startAdr = 0, 1 : own wheel
174  // startAdr = 2, 3 : next wheel neighbour
175 
176  // assert( startAdr >= 0 && startAdr <= 3 );
177  // assert( id == 0 || id == 1 );
178 
179  unsigned short int address = 15;
180 
181  SEUId seuid = make_pair(ext, startAdr);
182  SEUmap::const_iterator iter = m_SEUs.find(seuid);
183  if (iter != m_SEUs.end())
184  address = ((*iter).second)->ers()->address(id);
185 
186  return address;
187 }
188 
189 //
190 // get extrapolation quality from ERS
191 //
192 unsigned short int L1MuBMExtrapolationUnit::getQuality(Extrapolation ext, unsigned int startAdr, int id) const {
193  // get extrapolation quality from ERS
194  // startAdr = 0, 1 : own wheel
195  // startAdr = 2, 3 : next wheel neighbour
196 
197  // assert( startAdr >= 0 && startAdr <= 3 );
198  // assert( id == 0 || id == 1 );
199 
200  unsigned short int quality = 0;
201 
202  SEUId seuid = make_pair(ext, startAdr);
203  SEUmap::const_iterator iter = m_SEUs.find(seuid);
204  if (iter != m_SEUs.end())
205  quality = ((*iter).second)->ers()->quality(id);
206 
207  return quality;
208 }
209 
210 //
211 // get Extrapolator table for a given SEU
212 //
213 const bitset<12>& L1MuBMExtrapolationUnit::getEXTable(Extrapolation ext, unsigned int startAdr) const {
214  // startAdr = 0, 1 : own wheel
215  // startAdr = 2, 3 : next wheel neighbour
216 
217  // assert( startAdr >= 0 && startAdr <= 3 );
218 
219  SEUId seuid = make_pair(ext, startAdr);
220  return m_SEUs[seuid]->exTable();
221 }
222 
223 //
224 // get Quality Sorter table for a given SEU
225 //
226 const bitset<12>& L1MuBMExtrapolationUnit::getQSTable(Extrapolation ext, unsigned int startAdr) const {
227  // startAdr = 0, 1 : own wheel
228  // startAdr = 2, 3 : next wheel neighbour
229 
230  // assert( startAdr >= 0 && startAdr <= 3 );
231 
232  SEUId seuid = make_pair(ext, startAdr);
233  return m_SEUs[seuid]->qsTable();
234 }
235 
236 //
237 // get number of successful extrapolations
238 //
240  int number = 0;
241  SEUmap::const_iterator iter;
242  for (iter = m_SEUs.begin(); iter != m_SEUs.end(); iter++) {
243  number += ((*iter).second)->numberOfExt();
244  }
245 
246  return number;
247 }
248 
249 //
250 // print all successful extrapolations
251 //
253  SEUmap::const_iterator iter_seu;
254 
255  if (level == 0) {
256  for (iter_seu = m_SEUs.begin(); iter_seu != m_SEUs.end(); iter_seu++) {
257  vector<L1MuBMEUX*> vec_eux = ((*iter_seu).second)->eux();
258  vector<L1MuBMEUX*>::const_iterator iter_eux;
259  for (iter_eux = vec_eux.begin(); iter_eux != vec_eux.end(); iter_eux++) {
260  if ((*iter_eux)->result()) {
261  cout << ((*iter_seu).second)->ext() << " " << ((*iter_seu).second)->tsId() << " " << (*iter_eux)->id()
262  << endl;
263  cout << "start : " << *(*iter_eux)->ts().first << endl;
264  cout << "target : " << *(*iter_eux)->ts().second << endl;
265  cout << "result : "
266  << "quality = " << (*iter_eux)->quality() << '\t' << "address = " << (*iter_eux)->address() << endl;
267  }
268  }
269  }
270  }
271 
272  //
273  // print all results from Extrapolator and Quality Sorter
274  //
275  if (level == 1) {
276  cout << "Results from Extrapolator and Quality Sorter of " << m_sp.id() << " : \n" << endl;
277 
278  cout << " EXT QSU " << endl;
279  cout << " S E U 11 11 " << endl;
280  cout << " 109876543210 109876543210 " << endl;
281  cout << "-------------------------------------" << endl;
282  for (iter_seu = m_SEUs.begin(); iter_seu != m_SEUs.end(); iter_seu++) {
283  cout << ((*iter_seu).second)->ext() << "_ " << ((*iter_seu).second)->tsId() << ": "
284  << ((*iter_seu).second)->exTable() << " " << ((*iter_seu).second)->qsTable() << endl;
285  }
286 
287  cout << endl;
288  }
289 }
290 
291 // static
292 
293 //
294 // get station of start and target track segment for a given extrapolation
295 //
297  int source = 0;
298  int target = 0;
299 
300  // assert( ext >= 0 && ext < MAX_EXT );
301 
302  switch (ext) {
303  case EX12: {
304  source = 1;
305  target = 2;
306  break;
307  }
308  case EX13: {
309  source = 1;
310  target = 3;
311  break;
312  }
313  case EX14: {
314  source = 1;
315  target = 4;
316  break;
317  }
318  case EX21: {
319  source = 1;
320  target = 2;
321  break;
322  }
323  case EX23: {
324  source = 2;
325  target = 3;
326  break;
327  }
328  case EX24: {
329  source = 2;
330  target = 4;
331  break;
332  }
333  case EX34: {
334  source = 3;
335  target = 4;
336  break;
337  }
338  case EX15: {
339  source = 1;
340  target = 3;
341  break;
342  }
343  case EX25: {
344  source = 2;
345  target = 3;
346  break;
347  }
348  default: {
349  source = 1;
350  target = 2;
351  break;
352  }
353  }
354 
355  return pair<int, int>(source, target);
356 }
personalPlayback.level
level
Definition: personalPlayback.py:22
L1MuBMERS.h
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
ext
Definition: memstream.h:15
L1MuBMExtrapolationUnit.h
L1MuBMExtrapolationUnit::getEXTable
const std::bitset< 12 > & getEXTable(Extrapolation ext, unsigned int startAdr) const
get Extrapolator table for a given SEU
Definition: L1MuBMExtrapolationUnit.cc:213
L1MuBMDataBuffer::getTSphi
const TSPhivector & getTSphi() const
get all track segments from the buffer
Definition: L1MuBMDataBuffer.h:56
start
Definition: start.py:1
L1MuBMTrackSegPhi
Definition: L1MuBMTrackSegPhi.h:41
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
L1MuBMSEU::tsId
unsigned int tsId() const
return start track segment identifier (relative address)
Definition: L1MuBMSEU.h:81
L1MuBMTFConfig::getUseEX21
static bool getUseEX21()
Definition: L1MuBMTFConfig.h:64
L1MuDTTFParameters.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
L1TMuonBarrelParams::l1mudttfparams
L1MuDTTFParameters l1mudttfparams
Definition: L1TMuonBarrelParams.h:65
L1MuBMTrackSegPhi.h
L1MuBMExtrapolationUnit::getQuality
unsigned short int getQuality(Extrapolation ext, unsigned int startAdr, int id) const
get extrapolation quality from a given ERS
Definition: L1MuBMExtrapolationUnit.cc:192
L1MuBMExtrapolationUnit::pars
L1MuDTTFParameters pars
Definition: L1MuBMExtrapolationUnit.h:102
L1MuBMExtrapolationUnit::getAddress
unsigned short int getAddress(Extrapolation ext, unsigned int startAdr, int id) const
get extrapolation address from a given ERS
Definition: L1MuBMExtrapolationUnit.cc:171
L1MuBMSectorProcessor
Definition: L1MuBMSectorProcessor.h:54
L1MuBMSecProcId::sector
int sector() const
return sector number
Definition: L1MuBMSecProcId.h:58
L1MuBMSecProcId::wheel
int wheel() const
return wheel number
Definition: L1MuBMSecProcId.h:55
EX34
Definition: L1MuDTExtParam.h:22
quality
const uint32_t *__restrict__ Quality * quality
Definition: CAHitNtupletGeneratorKernelsImpl.h:109
L1MuBMExtrapolationUnit::reset
void reset() override
reset Extrapolation Unit
Definition: L1MuBMExtrapolationUnit.cc:148
EX15
Definition: L1MuDTExtParam.h:22
L1MuBMEUX.h
L1MuBMExtrapolationUnit::m_sp
const L1MuBMSectorProcessor & m_sp
Definition: L1MuBMExtrapolationUnit.h:96
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
L1MuBMSEU.h
L1MuBMExtrapolationUnit::bmtfParamsHandle
edm::ESHandle< L1TMuonBarrelParams > bmtfParamsHandle
Definition: L1MuBMExtrapolationUnit.h:101
Extrapolation
Extrapolation
Definition: L1MuDTExtParam.h:22
L1MuBMExtrapolationUnit::~L1MuBMExtrapolationUnit
~L1MuBMExtrapolationUnit() override
destructor
Definition: L1MuBMExtrapolationUnit.cc:79
source
static const std::string source
Definition: EdmProvDump.cc:47
svgfig.load
def load(fileName)
Definition: svgfig.py:547
L1MuBMExtrapolationUnit::getQSTable
const std::bitset< 12 > & getQSTable(Extrapolation ext, unsigned int startAdr) const
get Quality Sorter table for a given SEU
Definition: L1MuBMExtrapolationUnit.cc:226
L1MuDTExtParam.h
L1MuBMTFConfig::Debug
static bool Debug()
Definition: L1MuBMTFConfig.h:54
EX21
Definition: L1MuDTExtParam.h:22
L1MuBMSectorProcessor::id
const L1MuBMSecProcId & id() const
return Sector Processor identifier
Definition: L1MuBMSectorProcessor.h:75
EX23
Definition: L1MuDTExtParam.h:22
EX12
Definition: L1MuDTExtParam.h:22
L1MuBMTFConfig.h
EX25
Definition: L1MuDTExtParam.h:22
L1AbstractProcessor::run
virtual void run()
run processor logic
Definition: L1AbstractProcessor.h:40
L1MuBMTrackSegPhi::empty
bool empty() const
is it an empty phi track segment?
Definition: L1MuBMTrackSegPhi.h:115
EX24
Definition: L1MuDTExtParam.h:22
L1MuBMSecProcId.h
L1MuBMExtrapolationUnit::numberOfExt
int numberOfExt() const
return number of successful extrapolations
Definition: L1MuBMExtrapolationUnit.cc:239
L1MuBMExtrapolationUnit::SEUId
std::pair< Extrapolation, unsigned int > SEUId
Definition: L1MuBMExtrapolationUnit.h:56
L1MuBMSEU::ext
Extrapolation ext() const
return extrapolation type
Definition: L1MuBMSEU.h:78
edm::EventSetup
Definition: EventSetup.h:58
L1MuBMSectorProcessor::data
const L1MuBMDataBuffer * data() const
return pointer to Data Buffer
Definition: L1MuBMSectorProcessor.h:87
std
Definition: JetResolutionObject.h:76
L1MuBMExtrapolationUnit::L1MuBMExtrapolationUnit
L1MuBMExtrapolationUnit(const L1MuBMSectorProcessor &)
constructor
Definition: L1MuBMExtrapolationUnit.cc:55
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
L1MuBMDataBuffer.h
filterCSVwithJSON.target
target
Definition: filterCSVwithJSON.py:32
edm::eventsetup::EventSetupRecordImplementation::get
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
Definition: EventSetupRecordImplementation.h:74
L1TMuonBarrelParams
Definition: L1TMuonBarrelParams.h:23
EX14
Definition: L1MuDTExtParam.h:22
L1MuDTTFParametersRcd.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
L1MuBMExtrapolationUnit::print
void print(int level=0) const
print all successful extrapolations
Definition: L1MuBMExtrapolationUnit.cc:252
L1MuBMExtrapolationUnit::m_SEUs
SEUmap m_SEUs
Definition: L1MuBMExtrapolationUnit.h:98
L1TMuonBarrelParamsRcd
Definition: L1TMuonBarrelParamsRcd.h:13
L1MuBMSectorProcessor.h
L1MuBMSEU
Definition: L1MuBMSEU.h:48
L1MuBMExtrapolationUnit::which_ext
static std::pair< int, int > which_ext(Extrapolation ext)
return station of start and target track segment for a given extrapolation
Definition: L1MuBMExtrapolationUnit.cc:296