CMS 3D CMS Logo

L1MuBMTrackFinder.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuBMTrackFinder
4 //
5 // Description: L1 barrel Muon Trigger Track Finder
6 //
7 //
8 //
9 // Author :
10 // N. Neumeister CERN EP
11 // J. Troconiz UAM Madrid
12 // Modifications:
13 // G. Flouris U.Ioannina
14 // G. Karathanasis U. Athens
15 //--------------------------------------------------
16 
17 //-----------------------
18 // This Class's Header --
19 //-----------------------
20 
22 
23 //---------------
24 // C++ Headers --
25 //---------------
26 
27 #include <iostream>
28 #include <string>
29 
30 //-------------------------------
31 // Collaborating Class Headers --
32 //-------------------------------
33 
36 
40 
46 
47 using namespace std;
48 
49 //---------------------------------
50 // class L1MuBMTrackFinder
51 //---------------------------------
52 
53 //----------------
54 // Constructors --
55 //----------------
56 //:
58  : _cache0(144, -9, 8), _cache(36, -9, 8), m_ms(*this), m_config(ps) {
59  if (config().Debug(1))
60  cout << endl;
61  if (config().Debug(1))
62  cout << "**** entering L1MuBMTrackFinder ****" << endl;
63  if (config().Debug(1))
64  cout << endl;
65 
66  m_epvec.reserve(12);
67  m_wsvec.reserve(12);
68 
70  m_mbParamsToken = iC.esConsumes();
71  setup(std::move(iC));
72 }
73 
74 //--------------
75 // Destructor --
76 //--------------
77 
79 
80 //--------------
81 // Operations --
82 //--------------
83 
84 //
85 // setup MTTF configuration
86 //
88  // build the barrel Muon Trigger Track Finder
89 
90  if (config().Debug(1))
91  cout << endl;
92  if (config().Debug(1))
93  cout << "**** L1MuBMTrackFinder building ****" << endl;
94  if (config().Debug(1))
95  cout << endl;
96 
97  // create new sector processors
98  for (int wh = -3; wh <= 3; wh++) {
99  if (wh == 0)
100  continue;
101  for (int sc = 0; sc < 12; sc++) {
102  L1MuBMSecProcId tmpspid(wh, sc);
103  auto sp = std::make_unique<L1MuBMSectorProcessor>(*this, tmpspid, std::move(iC));
104  if (config().Debug(2))
105  cout << "creating " << tmpspid << endl;
106  m_spmap.insert(tmpspid, std::move(sp));
107  }
108  }
109 
110  // create new eta processors and wedge sorters
111  for (int sc = 0; sc < 12; sc++) {
112  auto ep = std::make_unique<L1MuBMEtaProcessor>(*this, sc, std::move(iC));
113  if (config().Debug(2))
114  cout << "creating Eta Processor " << sc << endl;
115  m_epvec.push_back(std::move(ep));
116  auto ws = std::make_unique<L1MuBMWedgeSorter>(*this, sc);
117  if (config().Debug(2))
118  cout << "creating Wedge Sorter " << sc << endl;
119  m_wsvec.push_back(std::move(ws));
120  }
121 }
122 
123 //
124 // run MTTF
125 //
127  auto presentCacheID = c.get<L1TMuonBarrelParamsRcd>().cacheIdentifier();
128  if (m_recordCache != presentCacheID) {
129  m_recordCache = presentCacheID;
131  }
132  int bx_min = config().getBxMin();
133  int bx_max = config().getBxMax();
134 
135  //Resize the bx range according to the config file
136  _cache0.setBXRange(bx_min, bx_max);
137  _cache.setBXRange(bx_min, bx_max);
138 
139  // run the barrel Muon Trigger Track Finder
141  e.getByToken(m_DTDigiToken, dttrig);
142  if (dttrig->getContainer()->empty())
143  return;
144 
145  if (config().Debug(2))
146  cout << endl;
147  if (config().Debug(2))
148  cout << "**** L1MuBMTrackFinder processing ------****" << endl;
149  if (config().Debug(2))
150  cout << endl;
151 
152  for (int bx = bx_min; bx <= bx_max; bx++) {
153  if (dttrig->bxEmpty(bx))
154  continue;
155 
156  if (config().Debug(2))
157  cout << "L1MuBMTrackFinder processing bunch-crossing : " << bx << endl;
158 
159  // reset MTTF
160  reset();
161 
162  // run sector processors
163  for (auto& sp : m_spmap) {
164  if (config().Debug(2))
165  cout << "running " << sp.second->id() << endl;
166  if (sp.second)
167  sp.second->run(bx, e, c);
168  if (config().Debug(2) && sp.second)
169  sp.second->print();
170  }
171 
172  // run eta processors
173  for (auto& ep : m_epvec) {
174  if (config().Debug(2) && ep)
175  cout << "running Eta Processor " << ep->id() << endl;
176  if (ep)
177  ep->run(bx, e, c);
178  if (config().Debug(2) && ep)
179  ep->print();
180  }
181 
182  // read sector processors
183  for (auto& sp : m_spmap) {
184  if (config().Debug(2))
185  cout << "reading " << sp.second->id() << endl;
186  for (int number = 0; number < 2; number++) {
187  const L1MuBMTrack& cand = sp.second->tracK(number);
188 
189  if (!cand.empty()) {
191 
192  // max value in LUTs is 117
193  if (cand.hwEta() > -117 || cand.hwEta() < 117)
194  rmc.setHwEta(cand.hwEta());
195  else
196  rmc.setHwEta(-1000);
197 
198  rmc.setHwPt(cand.pt());
199  int abs_add_1 = setAdd(1, cand.address(1));
200  int abs_add_2 = setAdd(2, cand.address(2));
201  int abs_add_3 = setAdd(3, cand.address(3));
202  int abs_add_4 = setAdd(4, cand.address(4));
203 
204  rmc.setTrackSubAddress(l1t::RegionalMuonCand::kWheelSide, cand.spid().wheel() < 0); // this has to be set!
206  abs(cand.spid().wheel()) - 1); // this has to be set!
215  rmc.setHwHF(cand.hwHF());
216 
217  rmc.setHwPhi(cand.hwPhi());
218  rmc.setHwSign(cand.hwSign() == 1 ? 0 : 1);
219  rmc.setHwSignValid(cand.hwSignValid());
220  rmc.setHwQual(cand.hwQual());
221  rmc.setTFIdentifiers(cand.spid().sector(), l1t::tftype::bmtf);
222 
223  _cache0.push_back(cand.bx(), rmc);
224  _cache2.insert(std::end(_cache2), std::begin(cand.getTSphi()), std::end(cand.getTSphi()));
225  _cache3.insert(std::end(_cache3), std::begin(cand.getTSeta()), std::end(cand.getTSeta()));
226  }
227  }
228  }
229 
230  // run wedge sorters
231  for (auto& ws : m_wsvec) {
232  if (config().Debug(2))
233  cout << "running Wedge Sorter " << ws->id() << endl;
234  if (ws)
235  ws->run();
236  if (config().Debug(2) && ws)
237  ws->print();
238 
239  // store found track candidates in container (cache)
240  if (ws->anyMuonCands()) {
241  const vector<const L1MuBMTrack*>& mttf_cont = ws->tracks();
242 
243  vector<const L1MuBMTrack*>::const_iterator iter;
244  for (iter = mttf_cont.begin(); iter != mttf_cont.end(); iter++) {
245  if (!*iter)
246  continue;
248  rmc.setHwPt((*iter)->hwPt());
249  int abs_add_1 = setAdd(1, (*iter)->address(1));
250  int abs_add_2 = setAdd(2, (*iter)->address(2));
251  int abs_add_3 = setAdd(3, (*iter)->address(3));
252  int abs_add_4 = setAdd(4, (*iter)->address(4));
253 
255  (*iter)->spid().wheel() < 0); // this has to be set!
257  abs((*iter)->spid().wheel()) - 1); // this has to be set!
266  rmc.setHwHF((*iter)->hwHF());
267 
268  rmc.setHwPhi((*iter)->hwPhi());
269  if ((*iter)->hwEta() > -117 || (*iter)->hwEta() < 117)
270  // rmc.setHwEta(eta_map[(*iter)->hwEta()]);
271  rmc.setHwEta((*iter)->hwEta());
272  else
273  rmc.setHwEta(-1000);
274  rmc.setHwSign((*iter)->hwSign() == 1 ? 0 : 1);
275  rmc.setHwSignValid((*iter)->hwSignValid());
276  rmc.setHwQual((*iter)->hwQual());
277  rmc.setTFIdentifiers((*iter)->spid().sector(), l1t::tftype::bmtf);
278 
279  if (*iter) {
280  _cache.push_back((*iter)->bx(), rmc);
281  _cache1.push_back(**iter);
282  }
283  }
284  }
285  } //end wedge sorting
286 
287  /* // run muon sorter
288  if ( config().Debug(2) ) cout << "running BM Muon Sorter" << endl;
289  if ( m_ms ) m_ms.run();
290  if ( config().Debug(2) && m_ms ) m_ms.print();
291 
292 
293  // store found track candidates in container (cache)
294  if ( m_ms.numberOfTracks() > 0 ) {
295  const vector<const L1MuBMTrack*>& mttf_cont = m_ms.tracks();
296  vector<const L1MuBMTrack*>::const_iterator iter;
297  for ( iter = mttf_cont.begin(); iter != mttf_cont.end(); iter++ ) {
298 
299  l1t::RegionalMuonCand rmc;
300  rmc.setHwPt((*iter)->hwPt());
301  int abs_add_1 = setAdd(1,(*iter)->address(1));
302  int abs_add_2 = setAdd(2,(*iter)->address(2));
303  int abs_add_3 = setAdd(3,(*iter)->address(3));
304  int abs_add_4 = setAdd(4,(*iter)->address(4));
305 
306  rmc.setTrackSubAddress(l1t::RegionalMuonCand::kWheelSide, (*iter)->spid().wheel() < 0); // this has to be set!
307  rmc.setTrackSubAddress(l1t::RegionalMuonCand::kWheelNum, abs((*iter)->spid().wheel()) - 1); // this has to be set!
308  rmc.setTrackSubAddress(l1t::RegionalMuonCand::kStat1, abs_add_1);
309  rmc.setTrackSubAddress(l1t::RegionalMuonCand::kStat2, abs_add_2);
310  rmc.setTrackSubAddress(l1t::RegionalMuonCand::kStat3, abs_add_3);
311  rmc.setTrackSubAddress(l1t::RegionalMuonCand::kStat4, abs_add_4);
312  rmc.setTrackSubAddress(l1t::RegionalMuonCand::kSegSelStat1, 0);
313  rmc.setTrackSubAddress(l1t::RegionalMuonCand::kSegSelStat2, 0);
314  rmc.setTrackSubAddress(l1t::RegionalMuonCand::kSegSelStat3, 0);
315  rmc.setTrackSubAddress(l1t::RegionalMuonCand::kSegSelStat4, 0);
316 
317 
318  rmc.setHwPhi((*iter)->hwPhi());
319  if((*iter)->hwEta()>-33 || (*iter)->hwEta()<32 )
320  rmc.setHwEta(eta_map[(*iter)->hwEta()]);
321  else
322  rmc.setHwEta(-1000);
323  rmc.setHwSign((*iter)->hwSign() == 1 ? 0 : 1);
324  rmc.setHwSignValid((*iter)->hwSignValid());
325  rmc.setHwQual((*iter)->hwQual());
326  rmc.setTFIdentifiers((*iter)->spid().sector(),l1t::tftype::bmtf);
327 
328  if ( *iter ){ _cache.push_back((*iter)->bx(), rmc);}
329  }
330  }
331  */
332 
333  } //end of bx loop
334 }
335 
336 //
337 // reset MTTF
338 //
340  for (auto& sp : m_spmap) {
341  if (sp.second) {
342  sp.second->reset();
343  }
344  }
345 
346  for (auto& ep : m_epvec) {
347  if (ep) {
348  ep->reset();
349  }
350  }
351 
352  for (auto& ws : m_wsvec) {
353  if (ws) {
354  ws->reset();
355  }
356  }
357 
358  m_ms.reset();
359 }
360 
361 //
362 // return Sector Processor container
363 //
366 
367 //
368 // return number of muon candidates found by the barrel MTTF
369 //
371  int num = 0;
372  for (int bx = _cache.getFirstBX(); bx < _cache.getLastBX(); ++bx) {
373  num += _cache.size(bx);
374  }
375  return num;
376 }
377 
379 
381 
383  _cache.clear();
384  _cache0.clear();
385  _cache1.clear();
386  _cache2.clear();
387  _cache3.clear();
388 }
389 
390 //
391 // return number of muon candidates found by the barrel MTTF at a given bx
392 //
394 
395 //
396 // Convert Relative to Absolute Track Addresses
397 //
398 
399 int L1MuBMTrackFinder::setAdd(int ust, int rel_add) {
400  unsigned int uadd = rel_add;
401 
402  switch (uadd) {
403  case 0: {
404  rel_add = 8;
405  break;
406  }
407  case 1: {
408  rel_add = 9;
409  break;
410  }
411  case 2: {
412  rel_add = 0;
413  break;
414  }
415  case 3: {
416  rel_add = 1;
417  break;
418  }
419  case 8: {
420  rel_add = 10;
421  break;
422  }
423  case 9: {
424  rel_add = 11;
425  break;
426  }
427  case 10: {
428  rel_add = 2;
429  break;
430  }
431  case 11: {
432  rel_add = 3;
433  break;
434  }
435  case 4: {
436  rel_add = 12;
437  break;
438  }
439  case 5: {
440  rel_add = 13;
441  break;
442  }
443  case 6: {
444  rel_add = 4;
445  break;
446  }
447  case 7: {
448  rel_add = 5;
449  break;
450  }
451  case 15: {
452  rel_add = 15;
453  break;
454  }
455  default: {
456  rel_add = 15;
457  break;
458  }
459  }
460 
461  if (ust != 1)
462  return rel_add;
463 
464  switch (uadd) {
465  case 0: {
466  rel_add = 2;
467  break;
468  }
469  case 1: {
470  rel_add = 1;
471  break;
472  }
473  case 15: {
474  rel_add = 3;
475  break;
476  }
477  default: {
478  rel_add = 3;
479  break;
480  }
481  }
482  return rel_add;
483 }
std::vector< std::unique_ptr< L1MuBMEtaProcessor > > m_epvec
Eta Processors.
int getLastBX() const
const L1MuBMSectorProcessor * sp(const L1MuBMSecProcId &) const
get a pointer to a Sector Processor
const L1MuBMSecProcId & id() const
return Sector Processor identifier
const L1MuBMWedgeSorter * ws(int id) const
get a pointer to a Wedge Sorter, index [0-11]
L1MuBMTFConfig m_config
Track Finder configuration.
edm::EDGetTokenT< L1MuDTChambPhContainer > m_DTDigiToken
int getFirstBX() const
void setHwPhi(int bits)
Set compressed relative phi as transmitted by hardware LSB = 2*pi/576 (8 bits)
int numberOfTracks()
get number of muon candidates found by the barrel MTTF
int id() const
return Wedge Sorter identifier (0-11)
const L1MuBMEtaProcessor * ep(int id) const
get a pointer to an Eta Processor, index [0-11]
void print() const
print results after sorting
virtual void run(int bx, const edm::Event &e, const edm::EventSetup &c)
run the Eta Processor
L1MuBMSectorProcessor * sp(const L1MuBMSecProcId &) const
return pointer to Sector Processor
void run()
run Wedge Sorter
L1MuBMTrack const & tracK(int id) const
return muon candidate, index [0,1]
const std::vector< const L1MuBMTrack * > & tracks() const
return vector of muon candidates
std::vector< std::unique_ptr< L1MuBMWedgeSorter > > m_wsvec
Wedge Sorters.
L1MuBMTrackSegEtaCollection _cache3
virtual void reset()
reset the Eta Processor
const_iterator begin(int bx) const
unsigned size(int bx) const
void insert(const L1MuBMSecProcId &, std::unique_ptr< L1MuBMSectorProcessor > sp)
insert a Sector Processor into the container
int getBxMax() const
edm::InputTag getBMDigiInputTag() const
void print() const
print muon candidates found by the Sector Processor
L1MuBMTrackFinder(const edm::ParameterSet &ps, edm::ConsumesCollector &&iC)
constructor
void setDefaultsES(const L1TMuonBarrelParams &)
L1MuBMTrackCollection _cache1
void reset()
reset Muon Sorter
void setTFIdentifiers(int processor, tftype trackFinder)
Set the processor ID, track-finder type. From these two, the link is set.
unsigned long long m_recordCache
TFtracks_const_iter begin(int bx)
void setTrackSubAddress(bmtfAddress subAddress, int value)
Set a part of the muon candidates track address; specialised for BMTF.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setHwHF(bool bit)
Set HF (halo / fine eta) bit (EMTF: halo -> 1; BMTF: fine eta -> 1)
int id() const
return Eta Processor identifier (0-11)
bool bxEmpty(int step) const
L1MuBMTrackSegPhiCollection _cache2
void run(const edm::Event &e, const edm::EventSetup &c)
run the barrel MTTF
void setHwQual(int bits)
Set compressed quality code as transmitted by hardware (4 bits)
void setHwPt(int bits)
Set compressed pT as transmitted by hardware LSB = 0.5 (9 bits)
const L1MuBMTFConfig & config() const
return configuration
l1t::RegionalMuonCandBxCollection _cache0
void reset()
reset Wedge Sorter
bool Debug() const
void setHwEta(int bits)
Set compressed eta as transmitted by hardware LSB = 0.010875 (9 bits)
Phi_Container const * getContainer() const
TFtracks_const_iter end(int bx)
void clear()
void setBXRange(int bxFirst, int bxLast)
void print() const
print muon candidates found by the Eta Processor
l1t::RegionalMuonCandBxCollection _cache
bool anyMuonCands() const
return number of muon candidates
const_iterator end(int bx) const
l1t::RegionalMuonCandBxCollection::const_iterator TFtracks_const_iter
container for muon candidates
int setAdd(int ust, int rel_add)
int getBxMin() const
L1MuBMMuonSorter m_ms
BM Muon Sorter.
void setHwSignValid(int bits)
Set whether charge measurement is valid (0 for high pT muons)
void setup(edm::ConsumesCollector &&)
build the structure of the barrel MTTF
void run(int bx, const edm::Event &e, const edm::EventSetup &c)
run the Sector Processor
const bool Debug
void reset()
reset the Sector Processor
L1MuBMSecProcMap m_spmap
Sector Processors.
def move(src, dest)
Definition: eostools.py:511
void push_back(int bx, T object)
void setHwSign(int bits)
Set charge sign bit (charge = (-1)^(sign))
virtual ~L1MuBMTrackFinder()
destructor
void reset()
reset the barrel MTTF
edm::ESGetToken< L1TMuonBarrelParams, L1TMuonBarrelParamsRcd > m_mbParamsToken