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  m_config = std::make_unique<L1MuDTTFConfig>(ps);
57 
58  if (m_config->Debug(1))
59  cout << endl;
60  if (m_config->Debug(1))
61  cout << "**** entering L1MuDTTrackFinder ****" << endl;
62  if (m_config->Debug(1))
63  cout << endl;
64 
65  m_spmap = std::make_unique<L1MuDTSecProcMap>();
66  m_epvec.reserve(12);
67  m_wsvec.reserve(12);
68 
69  _cache.reserve(4 * 17);
70  _cache0.reserve(144 * 17);
71 
72  m_DTDigiToken = iC.consumes<L1MuDTChambPhContainer>(m_config->getDTDigiInputTag());
73 }
74 
75 //--------------
76 // Destructor --
77 //--------------
78 
80 
81 //--------------
82 // Operations --
83 //--------------
84 
85 //
86 // setup MTTF configuration
87 //
89  // build the barrel Muon Trigger Track Finder
90 
91  if (m_config->Debug(1))
92  cout << endl;
93  if (m_config->Debug(1))
94  cout << "**** L1MuDTTrackFinder building ****" << endl;
95  if (m_config->Debug(1))
96  cout << endl;
97 
98  // create new sector processors
99  for (int wh = -3; wh <= 3; wh++) {
100  if (wh == 0)
101  continue;
102  for (int sc = 0; sc < 12; sc++) {
103  L1MuDTSecProcId tmpspid(wh, sc);
104  auto sp = std::make_unique<L1MuDTSectorProcessor>(*this, tmpspid, iC);
105  if (m_config->Debug(2))
106  cout << "creating " << tmpspid << endl;
107  m_spmap->insert(tmpspid, std::move(sp));
108  }
109  }
110 
111  // create new eta processors and wedge sorters
112  for (int sc = 0; sc < 12; sc++) {
113  auto ep = std::make_unique<L1MuDTEtaProcessor>(*this, sc, iC);
114  if (m_config->Debug(2))
115  cout << "creating Eta Processor " << sc << endl;
116  m_epvec.push_back(std::move(ep));
117  auto ws = std::make_unique<L1MuDTWedgeSorter>(*this, sc);
118  if (m_config->Debug(2))
119  cout << "creating Wedge Sorter " << sc << endl;
120  m_wsvec.push_back(std::move(ws));
121  }
122 
123  // create new muon sorter
124  if (m_config->Debug(2))
125  cout << "creating DT Muon Sorter " << endl;
126  m_ms = std::make_unique<L1MuDTMuonSorter>(*this);
127 }
128 
129 //
130 // run MTTF
131 //
133  // run the barrel Muon Trigger Track Finder
134 
136  e.getByToken(m_DTDigiToken, dttrig);
137  if (dttrig->getContainer()->empty())
138  return;
139 
140  if (m_config->Debug(2))
141  cout << endl;
142  if (m_config->Debug(2))
143  cout << "**** L1MuDTTrackFinder processing ****" << endl;
144  if (m_config->Debug(2))
145  cout << endl;
146 
147  int bx_min = m_config->getBxMin();
148  int bx_max = m_config->getBxMax();
149 
150  for (int bx = bx_min; bx <= bx_max; bx++) {
151  if (dttrig->bxEmpty(bx))
152  continue;
153 
154  if (m_config->Debug(2))
155  cout << "L1MuDTTrackFinder processing bunch-crossing : " << bx << endl;
156 
157  // reset MTTF
158  reset();
159 
160  // run sector processors
161  for (auto& sp : *m_spmap) {
162  if (m_config->Debug(2))
163  cout << "running " << sp.second->id() << endl;
164  if (sp.second)
165  sp.second->run(bx, e, c);
166  if (m_config->Debug(2) && sp.second)
167  sp.second->print();
168  }
169 
170  // run eta processors
171  for (auto& ep : m_epvec) {
172  if (m_config->Debug(2))
173  cout << "running Eta Processor " << ep->id() << endl;
174  if (ep)
175  ep->run(bx, e, c);
176  if (m_config->Debug(2) && ep)
177  ep->print();
178  }
179 
180  // read sector processors
181  for (auto& sp : *m_spmap) {
182  if (m_config->Debug(2))
183  cout << "reading " << sp.second->id() << endl;
184  for (int number = 0; number < 2; number++) {
185  const L1MuDTTrack* cand = sp.second->tracK(number);
186  if (cand && !cand->empty())
187  _cache0.push_back(L1MuDTTrackCand(cand->getDataWord(),
188  cand->bx(),
189  cand->spid().wheel(),
190  cand->spid().sector(),
191  number,
192  cand->address(1),
193  cand->address(2),
194  cand->address(3),
195  cand->address(4),
196  cand->tc()));
197  }
198  }
199 
200  // run wedge sorters
201  for (auto& ws : m_wsvec) {
202  if (m_config->Debug(2))
203  cout << "running Wedge Sorter " << ws->id() << endl;
204  if (ws)
205  ws->run();
206  if (m_config->Debug(2) && ws)
207  ws->print();
208  }
209 
210  // run muon sorter
211  if (m_config->Debug(2))
212  cout << "running DT Muon Sorter" << endl;
213  if (m_ms)
214  m_ms->run();
215  if (m_config->Debug(2) && m_ms)
216  m_ms->print();
217 
218  // store found track candidates in container (cache)
219  if (m_ms->numberOfTracks() > 0) {
220  for (auto const& mttf : m_ms->tracks()) {
221  if (mttf)
222  _cache.push_back(L1MuRegionalCand(mttf->getDataWord(), mttf->bx()));
223  }
224  }
225  }
226 }
227 
228 //
229 // reset MTTF
230 //
232  for (auto& sp : *m_spmap) {
233  if (sp.second)
234  sp.second->reset();
235  }
236 
237  for (auto& ep : m_epvec) {
238  if (ep)
239  ep->reset();
240  }
241 
242  for (auto& ws : m_wsvec) {
243  if (ws)
244  ws->reset();
245  }
246 
247  if (m_ms)
248  m_ms->reset();
249 }
250 
251 //
252 // return Sector Processor container
253 //
254 const L1MuDTSectorProcessor* L1MuDTTrackFinder::sp(const L1MuDTSecProcId& id) const { return m_spmap->sp(id); }
255 
256 //
257 // return number of muon candidates found by the barrel MTTF
258 //
259 int L1MuDTTrackFinder::numberOfTracks() { return _cache.size(); }
260 
262 
264 
266  _cache.clear();
267  _cache0.clear();
268 }
269 
270 //
271 // return number of muon candidates found by the barrel MTTF at a given bx
272 //
274  int number = 0;
275  for (auto const& elem : _cache) {
276  if (elem.bx() == bx)
277  number++;
278  }
279 
280  return number;
281 }
TFtracks_const_iter begin()
TFtracks_const_iter end()
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
~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
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