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