CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 //----------------
52 // Constructors --
53 //----------------
54 
56 
57  // set configuration parameters
58  if ( m_config == 0 ) m_config = new L1MuDTTFConfig(ps);
59 
60  if ( L1MuDTTFConfig::Debug(1) ) cout << endl;
61  if ( L1MuDTTFConfig::Debug(1) ) cout << "**** entering L1MuDTTrackFinder ****" << endl;
62  if ( L1MuDTTFConfig::Debug(1) ) cout << endl;
63 
64  m_spmap = new L1MuDTSecProcMap();
65  m_epvec.reserve(12);
66  m_wsvec.reserve(12);
67  m_ms = 0;
68 
69  _cache.reserve(4*17);
70  _cache0.reserve(144*17);
71 
72 }
73 
74 
75 //--------------
76 // Destructor --
77 //--------------
78 
80 
81  delete m_spmap;
82 
83  vector<L1MuDTEtaProcessor*>::iterator it_ep = m_epvec.begin();
84  while ( it_ep != m_epvec.end() ) {
85  delete (*it_ep);
86  it_ep++;
87  }
88  m_epvec.clear();
89 
90  vector<L1MuDTWedgeSorter*>::iterator it_ws = m_wsvec.begin();
91  while ( it_ws != m_wsvec.end() ) {
92  delete (*it_ws);
93  it_ws++;
94  }
95  m_wsvec.clear();
96 
97  delete m_ms;
98 
99  if ( m_config ) delete m_config;
100  m_config = 0;
101 
102 }
103 
104 
105 //--------------
106 // Operations --
107 //--------------
108 
109 //
110 // setup MTTF configuration
111 //
113 
114  // build the barrel Muon Trigger Track Finder
115 
116  if ( L1MuDTTFConfig::Debug(1) ) cout << endl;
117  if ( L1MuDTTFConfig::Debug(1) ) cout << "**** L1MuDTTrackFinder building ****" << endl;
118  if ( L1MuDTTFConfig::Debug(1) ) cout << endl;
119 
120  // create new sector processors
121  for ( int wh = -3; wh <= 3; wh++ ) {
122  if ( wh == 0 ) continue;
123  for ( int sc = 0; sc < 12; sc++ ) {
124  L1MuDTSecProcId tmpspid(wh,sc);
125  L1MuDTSectorProcessor* sp = new L1MuDTSectorProcessor(*this,tmpspid);
126  if ( L1MuDTTFConfig::Debug(2) ) cout << "creating " << tmpspid << endl;
127  m_spmap->insert(tmpspid,sp);
128  }
129  }
130 
131  // create new eta processors and wedge sorters
132  for ( int sc = 0; sc < 12; sc++ ) {
133  L1MuDTEtaProcessor* ep = new L1MuDTEtaProcessor(*this,sc);
134  if ( L1MuDTTFConfig::Debug(2) ) cout << "creating Eta Processor " << sc << endl;
135  m_epvec.push_back(ep);
136  L1MuDTWedgeSorter* ws = new L1MuDTWedgeSorter(*this,sc);
137  if ( L1MuDTTFConfig::Debug(2) ) cout << "creating Wedge Sorter " << sc << endl;
138  m_wsvec.push_back(ws);
139  }
140 
141  // create new muon sorter
142  if ( L1MuDTTFConfig::Debug(2) ) cout << "creating DT Muon Sorter " << endl;
143  m_ms = new L1MuDTMuonSorter(*this);
144 
145 }
146 
147 
148 //
149 // run MTTF
150 //
152 
153  // run the barrel Muon Trigger Track Finder
154 
157  if ( dttrig->getContainer()->size() == 0 ) return;
158 
159  if ( L1MuDTTFConfig::Debug(2) ) cout << endl;
160  if ( L1MuDTTFConfig::Debug(2) ) cout << "**** L1MuDTTrackFinder processing ****" << endl;
161  if ( L1MuDTTFConfig::Debug(2) ) cout << endl;
162 
163  int bx_min = L1MuDTTFConfig::getBxMin();
164  int bx_max = L1MuDTTFConfig::getBxMax();
165 
166  for ( int bx = bx_min; bx <= bx_max; bx++ ) {
167 
168  if ( dttrig->bxEmpty(bx) ) continue;
169 
170  if ( L1MuDTTFConfig::Debug(2) ) cout << "L1MuDTTrackFinder processing bunch-crossing : " << bx << endl;
171 
172  // reset MTTF
173  reset();
174 
175  // run sector processors
176  L1MuDTSecProcMap::SPmap_iter it_sp = m_spmap->begin();
177  while ( it_sp != m_spmap->end() ) {
178  if ( L1MuDTTFConfig::Debug(2) ) cout << "running "
179  << (*it_sp).second->id() << endl;
180  if ( (*it_sp).second ) (*it_sp).second->run(bx,e,c);
181  if ( L1MuDTTFConfig::Debug(2) && (*it_sp).second ) (*it_sp).second->print();
182  it_sp++;
183  }
184 
185  // run eta processors
186  vector<L1MuDTEtaProcessor*>::iterator it_ep = m_epvec.begin();
187  while ( it_ep != m_epvec.end() ) {
188  if ( L1MuDTTFConfig::Debug(2) ) cout << "running Eta Processor "
189  << (*it_ep)->id() << endl;
190  if ( *it_ep ) (*it_ep)->run(bx,e,c);
191  if ( L1MuDTTFConfig::Debug(2) && *it_ep ) (*it_ep)->print();
192  it_ep++;
193  }
194 
195  // read sector processors
196  it_sp = m_spmap->begin();
197  while ( it_sp != m_spmap->end() ) {
198  if ( L1MuDTTFConfig::Debug(2) ) cout << "reading "
199  << (*it_sp).second->id() << endl;
200  for ( int number = 0; number < 2; number++ ) {
201  const L1MuDTTrack* cand = (*it_sp).second->tracK(number);
202  if ( cand && !cand->empty() ) _cache0.push_back(L1MuDTTrackCand(cand->getDataWord(),cand->bx(),
203  cand->spid().wheel(),cand->spid().sector(),number,cand->address(1),
204  cand->address(2),cand->address(3),cand->address(4),cand->tc()));
205  }
206  it_sp++;
207  }
208 
209  // run wedge sorters
210  vector<L1MuDTWedgeSorter*>::iterator it_ws = m_wsvec.begin();
211  while ( it_ws != m_wsvec.end() ) {
212  if ( L1MuDTTFConfig::Debug(2) ) cout << "running Wedge Sorter "
213  << (*it_ws)->id() << endl;
214  if ( *it_ws ) (*it_ws)->run();
215  if ( L1MuDTTFConfig::Debug(2) && *it_ws ) (*it_ws)->print();
216  it_ws++;
217  }
218 
219  // run muon sorter
220  if ( L1MuDTTFConfig::Debug(2) ) cout << "running DT Muon Sorter" << endl;
221  if ( m_ms ) m_ms->run();
222  if ( L1MuDTTFConfig::Debug(2) && m_ms ) m_ms->print();
223 
224  // store found track candidates in container (cache)
225  if ( m_ms->numberOfTracks() > 0 ) {
226  const vector<const L1MuDTTrack*>& mttf_cont = m_ms->tracks();
227  vector<const L1MuDTTrack*>::const_iterator iter;
228  for ( iter = mttf_cont.begin(); iter != mttf_cont.end(); iter++ ) {
229  if ( *iter ) _cache.push_back(L1MuRegionalCand((*iter)->getDataWord(),(*iter)->bx()));
230  }
231  }
232 
233  }
234 
235 }
236 
237 
238 //
239 // reset MTTF
240 //
242 
243  L1MuDTSecProcMap::SPmap_iter it_sp = m_spmap->begin();
244  while ( it_sp != m_spmap->end() ) {
245  if ( (*it_sp).second ) (*it_sp).second->reset();
246  it_sp++;
247  }
248 
249  vector<L1MuDTEtaProcessor*>::iterator it_ep = m_epvec.begin();
250  while ( it_ep != m_epvec.end() ) {
251  if ( *it_ep ) (*it_ep)->reset();
252  it_ep++;
253  }
254 
255  vector<L1MuDTWedgeSorter*>::iterator it_ws = m_wsvec.begin();
256  while ( it_ws != m_wsvec.end() ) {
257  if ( *it_ws ) (*it_ws)->reset();
258  it_ws++;
259  }
260 
261  if ( m_ms ) m_ms->reset();
262 
263 }
264 
265 
266 //
267 // return Sector Processor container
268 //
270 
271  return m_spmap->sp(id);
272 
273 }
274 
275 
276 //
277 // return number of muon candidates found by the barrel MTTF
278 //
280 
281  return _cache.size();
282 
283 }
284 
285 
287 
288  return _cache.begin();
289 
290 }
291 
292 
294 
295  return _cache.end();
296 
297 }
298 
299 
301 
302  _cache.clear();
303  _cache0.clear();
304 
305 }
306 
307 
308 //
309 // return number of muon candidates found by the barrel MTTF at a given bx
310 //
312 
313  int number = 0;
314  for ( TFtracks_const_iter it = _cache.begin(); it != _cache.end(); it++ ) {
315  if ( (*it).bx() == bx ) number++;
316  }
317 
318  return number;
319 
320 }
321 
322 
323 // static data members
324 
static int getBxMax()
TFtracks_const_iter begin()
L1MuDTAddressArray address() const
get address-array for this muon candidate
Definition: L1MuDTTrack.h:96
TrackClass tc() const
get track-class
Definition: L1MuDTTrack.h:87
TFtracks_const_iter end()
void run(const edm::Event &e, const edm::EventSetup &c)
run the barrel MTTF
const L1MuDTSectorProcessor * sp(const L1MuDTSecProcId &) const
get a pointer to a Sector Processor
L1MuDTTrackFinder(const edm::ParameterSet &ps)
constructor
int sector() const
return sector number
virtual ~L1MuDTTrackFinder()
destructor
void reset()
reset the barrel MTTF
int numberOfTracks()
get number of muon candidates found by the barrel MTTF
unsigned getDataWord() const
return data word
static int getBxMin()
static bool Debug()
const L1MuDTSecProcId & spid() const
return Sector Processor in which the muon candidate was found
Definition: L1MuDTTrack.h:93
bool empty() const
is it an empty muon candidate?
Definition: L1MuDTTrack.h:90
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
SPmap::iterator SPmap_iter
std::vector< L1MuRegionalCand >::const_iterator TFtracks_const_iter
container for muon candidates
static edm::InputTag getDTDigiInputTag()
int bx() const
return bunch crossing identifier
void setup()
build the structure of the barrel MTTF
int wheel() const
return wheel number
tuple cout
Definition: gather_cfg.py:121
static L1MuDTTFConfig * m_config
Track Finder configuration.
void reset(double vett[256])
Definition: TPedValues.cc:11