CMS 3D CMS Logo

L1MuDTTrackFinder.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuDTTrackFinder
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 //
13 //--------------------------------------------------
14 
15 //-----------------------
16 // This Class's Header --
17 //-----------------------
18 
20 
21 //---------------
22 // C++ Headers --
23 //---------------
24 
25 #include <iostream>
26 
27 //-------------------------------
28 // Collaborating Class Headers --
29 //-------------------------------
30 
43 
44 using namespace std;
45 
46 //---------------------------------
47 // class L1MuDTTrackFinder
48 //---------------------------------
49 
50 //----------------
51 // Constructors --
52 //----------------
53 
55  // set configuration parameters
56  if (not m_config) {
57  auto temp = std::make_shared<L1MuDTTFConfig>(ps);
58  std::shared_ptr<L1MuDTTFConfig> empty;
59  std::atomic_compare_exchange_strong(&m_config, &empty, temp);
60  }
61 
62  if (m_config->Debug(1))
63  cout << endl;
64  if (m_config->Debug(1))
65  cout << "**** entering L1MuDTTrackFinder ****" << endl;
66  if (m_config->Debug(1))
67  cout << endl;
68 
69  m_spmap = new L1MuDTSecProcMap();
70  m_epvec.reserve(12);
71  m_wsvec.reserve(12);
72  m_ms = nullptr;
73 
74  _cache.reserve(4 * 17);
75  _cache0.reserve(144 * 17);
76 
77  m_DTDigiToken = iC.consumes<L1MuDTChambPhContainer>(m_config->getDTDigiInputTag());
78 }
79 
80 //--------------
81 // Destructor --
82 //--------------
83 
85  delete m_spmap;
86 
87  vector<L1MuDTEtaProcessor*>::iterator it_ep = m_epvec.begin();
88  while (it_ep != m_epvec.end()) {
89  delete (*it_ep);
90  it_ep++;
91  }
92  m_epvec.clear();
93 
94  vector<L1MuDTWedgeSorter*>::iterator it_ws = m_wsvec.begin();
95  while (it_ws != m_wsvec.end()) {
96  delete (*it_ws);
97  it_ws++;
98  }
99  m_wsvec.clear();
100 
101  delete m_ms;
102 }
103 
104 //--------------
105 // Operations --
106 //--------------
107 
108 //
109 // setup MTTF configuration
110 //
112  // build the barrel Muon Trigger Track Finder
113 
114  if (m_config->Debug(1))
115  cout << endl;
116  if (m_config->Debug(1))
117  cout << "**** L1MuDTTrackFinder building ****" << endl;
118  if (m_config->Debug(1))
119  cout << endl;
120 
121  // create new sector processors
122  for (int wh = -3; wh <= 3; wh++) {
123  if (wh == 0)
124  continue;
125  for (int sc = 0; sc < 12; sc++) {
126  L1MuDTSecProcId tmpspid(wh, sc);
127  L1MuDTSectorProcessor* sp = new L1MuDTSectorProcessor(*this, tmpspid, std::move(iC));
128  if (m_config->Debug(2))
129  cout << "creating " << tmpspid << endl;
130  m_spmap->insert(tmpspid, sp);
131  }
132  }
133 
134  // create new eta processors and wedge sorters
135  for (int sc = 0; sc < 12; sc++) {
136  L1MuDTEtaProcessor* ep = new L1MuDTEtaProcessor(*this, sc, std::move(iC));
137  if (m_config->Debug(2))
138  cout << "creating Eta Processor " << sc << endl;
139  m_epvec.push_back(ep);
140  L1MuDTWedgeSorter* ws = new L1MuDTWedgeSorter(*this, sc);
141  if (m_config->Debug(2))
142  cout << "creating Wedge Sorter " << sc << endl;
143  m_wsvec.push_back(ws);
144  }
145 
146  // create new muon sorter
147  if (m_config->Debug(2))
148  cout << "creating DT Muon Sorter " << endl;
149  m_ms = new L1MuDTMuonSorter(*this);
150 }
151 
152 //
153 // run MTTF
154 //
156  // run the barrel Muon Trigger Track Finder
157 
159  e.getByToken(m_DTDigiToken, dttrig);
160  if (dttrig->getContainer()->empty())
161  return;
162 
163  if (m_config->Debug(2))
164  cout << endl;
165  if (m_config->Debug(2))
166  cout << "**** L1MuDTTrackFinder processing ****" << endl;
167  if (m_config->Debug(2))
168  cout << endl;
169 
170  int bx_min = m_config->getBxMin();
171  int bx_max = m_config->getBxMax();
172 
173  for (int bx = bx_min; bx <= bx_max; bx++) {
174  if (dttrig->bxEmpty(bx))
175  continue;
176 
177  if (m_config->Debug(2))
178  cout << "L1MuDTTrackFinder processing bunch-crossing : " << bx << endl;
179 
180  // reset MTTF
181  reset();
182 
183  // run sector processors
184  L1MuDTSecProcMap::SPmap_iter it_sp = m_spmap->begin();
185  while (it_sp != m_spmap->end()) {
186  if (m_config->Debug(2))
187  cout << "running " << (*it_sp).second->id() << endl;
188  if ((*it_sp).second)
189  (*it_sp).second->run(bx, e, c);
190  if (m_config->Debug(2) && (*it_sp).second)
191  (*it_sp).second->print();
192  it_sp++;
193  }
194 
195  // run eta processors
196  vector<L1MuDTEtaProcessor*>::iterator it_ep = m_epvec.begin();
197  while (it_ep != m_epvec.end()) {
198  if (m_config->Debug(2))
199  cout << "running Eta Processor " << (*it_ep)->id() << endl;
200  if (*it_ep)
201  (*it_ep)->run(bx, e, c);
202  if (m_config->Debug(2) && *it_ep)
203  (*it_ep)->print();
204  it_ep++;
205  }
206 
207  // read sector processors
208  it_sp = m_spmap->begin();
209  while (it_sp != m_spmap->end()) {
210  if (m_config->Debug(2))
211  cout << "reading " << (*it_sp).second->id() << endl;
212  for (int number = 0; number < 2; number++) {
213  const L1MuDTTrack* cand = (*it_sp).second->tracK(number);
214  if (cand && !cand->empty())
215  _cache0.push_back(L1MuDTTrackCand(cand->getDataWord(),
216  cand->bx(),
217  cand->spid().wheel(),
218  cand->spid().sector(),
219  number,
220  cand->address(1),
221  cand->address(2),
222  cand->address(3),
223  cand->address(4),
224  cand->tc()));
225  }
226  it_sp++;
227  }
228 
229  // run wedge sorters
230  vector<L1MuDTWedgeSorter*>::iterator it_ws = m_wsvec.begin();
231  while (it_ws != m_wsvec.end()) {
232  if (m_config->Debug(2))
233  cout << "running Wedge Sorter " << (*it_ws)->id() << endl;
234  if (*it_ws)
235  (*it_ws)->run();
236  if (m_config->Debug(2) && *it_ws)
237  (*it_ws)->print();
238  it_ws++;
239  }
240 
241  // run muon sorter
242  if (m_config->Debug(2))
243  cout << "running DT Muon Sorter" << endl;
244  if (m_ms)
245  m_ms->run();
246  if (m_config->Debug(2) && m_ms)
247  m_ms->print();
248 
249  // store found track candidates in container (cache)
250  if (m_ms->numberOfTracks() > 0) {
251  const vector<const L1MuDTTrack*>& mttf_cont = m_ms->tracks();
252  vector<const L1MuDTTrack*>::const_iterator iter;
253  for (iter = mttf_cont.begin(); iter != mttf_cont.end(); iter++) {
254  if (*iter)
255  _cache.push_back(L1MuRegionalCand((*iter)->getDataWord(), (*iter)->bx()));
256  }
257  }
258  }
259 }
260 
261 //
262 // reset MTTF
263 //
265  L1MuDTSecProcMap::SPmap_iter it_sp = m_spmap->begin();
266  while (it_sp != m_spmap->end()) {
267  if ((*it_sp).second)
268  (*it_sp).second->reset();
269  it_sp++;
270  }
271 
272  vector<L1MuDTEtaProcessor*>::iterator it_ep = m_epvec.begin();
273  while (it_ep != m_epvec.end()) {
274  if (*it_ep)
275  (*it_ep)->reset();
276  it_ep++;
277  }
278 
279  vector<L1MuDTWedgeSorter*>::iterator it_ws = m_wsvec.begin();
280  while (it_ws != m_wsvec.end()) {
281  if (*it_ws)
282  (*it_ws)->reset();
283  it_ws++;
284  }
285 
286  if (m_ms)
287  m_ms->reset();
288 }
289 
290 //
291 // return Sector Processor container
292 //
293 const L1MuDTSectorProcessor* L1MuDTTrackFinder::sp(const L1MuDTSecProcId& id) const { return m_spmap->sp(id); }
294 
295 //
296 // return number of muon candidates found by the barrel MTTF
297 //
298 int L1MuDTTrackFinder::numberOfTracks() { return _cache.size(); }
299 
301 
303 
305  _cache.clear();
306  _cache0.clear();
307 }
308 
309 //
310 // return number of muon candidates found by the barrel MTTF at a given bx
311 //
313  int number = 0;
314  for (TFtracks_const_iter it = _cache.begin(); it != _cache.end(); it++) {
315  if ((*it).bx() == bx)
316  number++;
317  }
318 
319  return number;
320 }
321 
322 // static data members
323 
324 std::shared_ptr<L1MuDTTFConfig> L1MuDTTrackFinder::m_config;
TFtracks_const_iter begin()
TFtracks_const_iter end()
static std::shared_ptr< L1MuDTTFConfig > m_config
Track Finder configuration.
void run(const edm::Event &e, const edm::EventSetup &c)
run the barrel MTTF
void setup(edm::ConsumesCollector &&iC)
build the structure of the barrel MTTF
auto &__restrict__ ws
virtual ~L1MuDTTrackFinder()
destructor
void reset()
reset the barrel MTTF
int numberOfTracks()
get number of muon candidates found by the barrel MTTF
L1MuDTTrackFinder(const edm::ParameterSet &ps, edm::ConsumesCollector &&iC)
constructor
const L1MuDTSectorProcessor * sp(const L1MuDTSecProcId &) const
get a pointer to a Sector Processor
bool bxEmpty(int step) const
Phi_Container const * getContainer() const
SPmap::iterator SPmap_iter
std::vector< L1MuRegionalCand >::const_iterator TFtracks_const_iter
container for muon candidates
void reset(double vett[256])
Definition: TPedValues.cc:11
def move(src, dest)
Definition: eostools.py:511