CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
L1MuDTMuonSorter Class Reference

#include <L1MuDTMuonSorter.h>

Inheritance diagram for L1MuDTMuonSorter:
L1AbstractProcessor

Public Member Functions

 L1MuDTMuonSorter (const L1MuDTTrackFinder &)
 constructor More...
 
int numberOfTracks () const
 return number of found muon candidates after sorter More...
 
void print () const
 print results after sorting More...
 
virtual void reset ()
 reset Muon Sorter More...
 
virtual void run ()
 run Muon Sorter More...
 
const L1MuDTTracktrack (int id) const
 return pointer to a muon candidate More...
 
const std::vector< const
L1MuDTTrack * > & 
tracks () const
 return vector of muon candidates More...
 
virtual ~L1MuDTMuonSorter ()
 destructor More...
 
- Public Member Functions inherited from L1AbstractProcessor
virtual void run (const edm::EventSetup &c)
 
virtual ~L1AbstractProcessor ()
 destructor More...
 

Private Member Functions

void runCOL (std::vector< L1MuDTTrack * > &) const
 run the Cancel Out Logic of the muon sorter More...
 

Static Private Member Functions

static int neighbour (const L1MuDTSecProcId &spid1, const L1MuDTSecProcId &spid2)
 find out if two Sector Processors are neighbours More...
 

Private Attributes

const L1MuDTTrackFinderm_tf
 
std::vector< const L1MuDTTrack * > m_TrackCands
 

Detailed Description

DT Muon Sorter:

The DT Muon Sorter receives 2 muon candidates from each of the 12 Wedge Sorters and sorts out the 4 best (highest pt, highest quality) muons

Date:
2007/03/30 09:05:32
Revision:
1.3

N. Neumeister CERN EP

Definition at line 47 of file L1MuDTMuonSorter.h.

Constructor & Destructor Documentation

L1MuDTMuonSorter::L1MuDTMuonSorter ( const L1MuDTTrackFinder tf)

constructor

Definition at line 50 of file L1MuDTMuonSorter.cc.

References m_TrackCands.

50  :
51  m_tf(tf), m_TrackCands() {
52 
53  m_TrackCands.reserve(4);
54 
55 }
std::vector< const L1MuDTTrack * > m_TrackCands
const L1MuDTTrackFinder & m_tf
L1MuDTMuonSorter::~L1MuDTMuonSorter ( )
virtual

destructor

Definition at line 62 of file L1MuDTMuonSorter.cc.

62  {
63 
64 }

Member Function Documentation

int L1MuDTMuonSorter::neighbour ( const L1MuDTSecProcId spid1,
const L1MuDTSecProcId spid2 
)
staticprivate

find out if two Sector Processors are neighbours

Definition at line 300 of file L1MuDTMuonSorter.cc.

References abs, L1MuDTSecProcId::sector(), and L1MuDTSecProcId::wheel().

Referenced by runCOL().

301  {
302 
303  // definition of valid topologies:
304 
305  // E T A
306  // -----------------
307  // +
308  // --- ---
309  // | | 2 | | 2 |
310  // P | |___| |___|
311  // | --- --- --- ---
312  // H | | 1 | | 1 | | 1 | | 1 |
313  // | |___| |___| |___| |___|
314  // I | --- ---
315  // | | 2 | | 2 |
316  // |___| |___|
317  // -
318  // result: 1 2 3 4 5 6 otherwise : -1
319 
320  int topology = -1;
321 
322  int sector1 = spid1.sector();
323  int wheel1 = spid1.wheel();
324 
325  int sector2 = spid2.sector();
326  int wheel2 = spid2.wheel();
327 
328  int sectordiff = (sector2 - sector1)%12;
329  if ( sectordiff >= 6 ) sectordiff -= 12;
330  if ( sectordiff < -6 ) sectordiff += 12;
331 
332  if ( abs(sectordiff) == 1 ) {
333 
334  if ( wheel1 == wheel2 ) topology = (sectordiff > 0) ? 1 : 2;
335  if ( wheel1 == +1 && wheel2 == -1 ) topology = (sectordiff > 0) ? 5 : 6;
336  if ( ( wheel1 == -2 && wheel2 == -3 ) ||
337  ( wheel1 == -1 && wheel2 == -2 ) ||
338  ( wheel1 == +1 && wheel2 == +2 ) ||
339  ( wheel1 == +2 && wheel2 == +3 ) ) topology = (sectordiff > 0) ? 3 : 4;
340 
341  }
342 
343  return topology;
344 
345 }
#define abs(x)
Definition: mlp_lapack.h:159
int sector() const
return sector number
int wheel() const
return wheel number
int L1MuDTMuonSorter::numberOfTracks ( ) const
inline

return number of found muon candidates after sorter

Definition at line 67 of file L1MuDTMuonSorter.h.

References m_TrackCands.

Referenced by print().

67 { return m_TrackCands.size(); }
std::vector< const L1MuDTTrack * > m_TrackCands
void L1MuDTMuonSorter::print ( void  ) const

print results after sorting

Definition at line 147 of file L1MuDTMuonSorter.cc.

References gather_cfg::cout, m_TrackCands, and numberOfTracks().

147  {
148 
149  cout << endl;
150  cout << "Muon candidates found by the barrel MTTF : "
151  << numberOfTracks() << endl;
152  vector<const L1MuDTTrack*>::const_iterator iter = m_TrackCands.begin();
153  while ( iter != m_TrackCands.end() ) {
154  if ( *iter ) cout << *(*iter) << endl;
155  iter++;
156  }
157  cout << endl;
158 
159 }
std::vector< const L1MuDTTrack * > m_TrackCands
int numberOfTracks() const
return number of found muon candidates after sorter
tuple cout
Definition: gather_cfg.py:121
void L1MuDTMuonSorter::reset ( void  )
virtual

reset Muon Sorter

Implements L1AbstractProcessor.

Definition at line 133 of file L1MuDTMuonSorter.cc.

References m_TrackCands.

133  {
134 
135  m_TrackCands.clear();
136  vector<const L1MuDTTrack*>::iterator iter;
137  for ( iter = m_TrackCands.begin(); iter != m_TrackCands.end(); iter++ ) {
138  *iter = 0;
139  }
140 
141 }
std::vector< const L1MuDTTrack * > m_TrackCands
void L1MuDTMuonSorter::run ( void  )
virtual

run Muon Sorter

Reimplemented from L1AbstractProcessor.

Definition at line 74 of file L1MuDTMuonSorter.cc.

References gather_cfg::cout, L1MuDTTFConfig::Debug(), m_tf, m_TrackCands, runCOL(), L1MuDTWedgeSorter::tracks(), and L1MuDTTrackFinder::ws().

74  {
75 
76  // get track candidates from Wedge Sorters
77  vector<L1MuDTTrack*> mycands;
78  mycands.reserve(24);
79 
80  for ( int wedge = 0; wedge < 12; wedge++ ) {
81  vector<const L1MuDTTrack*> wscand = m_tf.ws(wedge)->tracks();
82  vector<const L1MuDTTrack*>::iterator iter = wscand.begin();
83  while ( iter != wscand.end() ) {
84  if ( *iter && !(*iter)->empty() )
85  mycands.push_back(const_cast<L1MuDTTrack*>(*iter) );
86  iter++;
87  }
88  }
89 
90  // print input data
91  if ( L1MuDTTFConfig::Debug(4) ) {
92  cout << "DT Muon Sorter input: "
93  << mycands.size() << endl;
94  vector<L1MuDTTrack*>::const_iterator iter;
95  for ( iter = mycands.begin(); iter != mycands.end(); iter++ ) {
96  if (*iter ) (*iter)->print();
97  }
98  }
99 
100  // run Cancel Out Logic
101  runCOL(mycands);
102 
103  // remove disabled candidates
104  vector<L1MuDTTrack*>::iterator it = mycands.begin();
105  while ( it != mycands.end() ) {
106  if ( *it && (*it)->empty() ) {
107  mycands.erase(it);
108  it = mycands.begin(); continue;
109  }
110  it++;
111  }
112 
113  // sort pt and quality
114  stable_sort( mycands.begin(), mycands.end(), L1MuDTTrack::Rank() );
115 
116  // copy the best 4 candidates
117  int number_of_tracks = 0;
118  vector<L1MuDTTrack*>::const_iterator iter1 = mycands.begin();
119  while ( iter1 != mycands.end() ) {
120  if ( *iter1 && number_of_tracks < 4 ) {
121  m_TrackCands.push_back(*iter1);
122  number_of_tracks++;
123  }
124  iter1++;
125  }
126 
127 }
void runCOL(std::vector< L1MuDTTrack * > &) const
run the Cancel Out Logic of the muon sorter
const std::vector< const L1MuDTTrack * > & tracks() const
return vector of muon candidates
static bool Debug()
std::vector< const L1MuDTTrack * > m_TrackCands
const L1MuDTTrackFinder & m_tf
define a rank for muon candidates
Definition: L1MuDTTrack.h:185
const L1MuDTWedgeSorter * ws(int id) const
get a pointer to a Wedge Sorter, index [0-11]
tuple cout
Definition: gather_cfg.py:121
void L1MuDTMuonSorter::runCOL ( std::vector< L1MuDTTrack * > &  cands) const
private

run the Cancel Out Logic of the muon sorter

Definition at line 165 of file L1MuDTMuonSorter.cc.

References abs, gather_cfg::cout, L1MuDTTFConfig::Debug(), neighbour(), hitfit::phidiff(), and w2.

Referenced by run().

165  {
166 
167  // compare candidates which were found in nearby sectors and wheels
168  // if 2 candidates have at least one track segment in common
169  // disable the one with lower quality
170  // compare addresses from stations 2, 3 and 4
171 
172  typedef vector<L1MuDTTrack*>::iterator TI;
173  for ( TI iter1 = cands.begin(); iter1 != cands.end(); iter1++ ) {
174  if ( *iter1 == 0 ) continue;
175  if ( (*iter1)->empty() ) continue;
176  L1MuDTSecProcId sp1 = (*iter1)->spid();
177  int qual1 = (*iter1)->quality();
178  for ( TI iter2 = cands.begin(); iter2 != cands.end(); iter2++ ) {
179  if ( *iter2 == 0 ) continue;
180  if ( *iter1 == *iter2 ) continue;
181  if ( (*iter2)->empty() ) continue;
182  L1MuDTSecProcId sp2 = (*iter2)->spid();
183  int qual2 = (*iter2)->quality();
184  if (sp1 == sp2 ) continue;
185  int topology = neighbour(sp1,sp2);
186  if ( topology == -1 ) continue;
187  int countTS = 0;
188  for ( int stat = 2; stat <= 4; stat++ ) {
189  int adr1 = (*iter1)->address(stat);
190  int adr2 = (*iter2)->address(stat);
191  if ( adr1 == 15 || adr2 == 15 ) continue;
192  switch ( topology ) {
193  case 1 : {
194  if ( adr1 > 7 ) continue;
195  if ( adr2 > 3 && adr2 < 8 ) continue;
196  int adr_shift = ( adr2 > 7 ) ? -8 : 4;
197  if ( adr1 == adr2+adr_shift ) countTS++;
198  break;
199  }
200  case 2 : {
201  if ( adr2 > 7 ) continue;
202  if ( adr1 > 3 && adr1 < 8 ) continue;
203  int adr_shift = ( adr2 > 3 ) ? -4 : 8;
204  if ( adr1 == adr2+adr_shift ) countTS++;
205  break;
206  }
207  case 3 : {
208  if ( ( adr1 == 6 && adr2 == 0 ) ||
209  ( adr1 == 7 && adr2 == 1 ) ||
210  ( adr1 == 2 && adr2 == 8 ) ||
211  ( adr1 == 3 && adr2 == 9 ) ) countTS++;
212  break;
213  }
214  case 4 : {
215  if ( ( adr1 == 2 && adr2 == 4 ) ||
216  ( adr1 == 3 && adr2 == 5 ) ||
217  ( adr1 == 10 && adr2 == 0 ) ||
218  ( adr1 == 11 && adr2 == 1 ) ) countTS++;
219  break;
220  }
221  case 5 : {
222  if ( ( adr1 == 0 && adr2 == 8 ) ||
223  ( adr1 == 1 && adr2 == 9 ) ||
224  ( adr1 == 4 && adr2 == 0 ) ||
225  ( adr1 == 5 && adr2 == 1 ) ) countTS++;
226  break;
227  }
228  case 6 : {
229  if ( ( adr1 == 0 && adr2 == 4 ) ||
230  ( adr1 == 1 && adr2 == 5 ) ||
231  ( adr1 == 8 && adr2 == 0 ) ||
232  ( adr1 == 9 && adr2 == 1 ) ) countTS++;
233  break;
234  }
235  default : break;
236  }
237  }
238  if ( countTS > 0 ) {
239  if ( qual1 < qual2 ) {
240  if ( L1MuDTTFConfig::Debug(5) ) {
241  cout << "Muon Sorter cancel : "; (*iter1)->print();
242  }
243  (*iter1)->disable();
244  break;
245  }
246  else {
247  if ( L1MuDTTFConfig::Debug(5) ) {
248  cout << "Muon Sorter cancel : "; (*iter2)->print();
249  }
250  (*iter2)->disable();
251  }
252  }
253  }
254  }
255 
256 
257  // if two candidates have exactly the same phi and eta values
258  // remove the one with lower rank
259 
260  for ( TI iter1 = cands.begin(); iter1 != cands.end(); iter1++ ) {
261  if ( *iter1 == 0 ) continue;
262  if ( (*iter1)->empty() ) continue;
263  int phi1 = (*iter1)->phi();
264  int pt1 = (*iter1)->pt();
265  int qual1 = (*iter1)->quality();
266  for ( TI iter2 = cands.begin(); iter2 != cands.end(); iter2++ ) {
267  if ( *iter2 == 0 ) continue;
268  if ( *iter1 == *iter2 ) continue;
269  if ( (*iter2)->empty() ) continue;
270  int phi2 = (*iter2)->phi();
271  int pt2 = (*iter2)->pt();
272  int qual2 = (*iter2)->quality();
273  int w1 = (*iter1)->getStartTSphi().wheel();
274  int w2 = (*iter2)->getStartTSphi().wheel();
275  int phidiff = (phi2 - phi1)%144;
276  if ( phidiff >= 72 ) phidiff -= 144;
277  if ( phidiff < -72 ) phidiff += 144;
278  if ( abs(phidiff) < 2 && (w1 == w2) ) {
279  int rank1 = 10 * pt1 + qual1;
280  int rank2 = 10 * pt2 + qual2;
281  if ( L1MuDTTFConfig::Debug(5) ) {
282  cout << "========================================" << endl;
283  cout << " special cancellation : " << endl;
284  (*iter1)->print(); if ( rank1 < rank2 ) cout << "cancelled" << endl;
285  (*iter2)->print(); if ( rank1 >= rank2 ) cout << "cancelled" << endl;
286  cout << "========================================" << endl;
287  }
288  if ( rank1 >= rank2 ) (*iter2)->disable();
289  if ( rank1 < rank2 ) { (*iter1)->disable(); break; }
290  }
291  }
292  }
293 
294 }
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
#define abs(x)
Definition: mlp_lapack.h:159
static int neighbour(const L1MuDTSecProcId &spid1, const L1MuDTSecProcId &spid2)
find out if two Sector Processors are neighbours
double phidiff(double phi)
Normalized difference in azimuthal angles to a range between .
Definition: fourvec.cc:231
static bool Debug()
tuple cout
Definition: gather_cfg.py:121
const L1MuDTTrack* L1MuDTMuonSorter::track ( int  id) const
inline

return pointer to a muon candidate

Definition at line 70 of file L1MuDTMuonSorter.h.

References errorMatrix2Lands_multiChannel::id, and m_TrackCands.

70 { return m_TrackCands[id]; }
std::vector< const L1MuDTTrack * > m_TrackCands
const std::vector<const L1MuDTTrack*>& L1MuDTMuonSorter::tracks ( void  ) const
inline

return vector of muon candidates

Definition at line 73 of file L1MuDTMuonSorter.h.

References m_TrackCands.

73 { return m_TrackCands; }
std::vector< const L1MuDTTrack * > m_TrackCands

Member Data Documentation

const L1MuDTTrackFinder& L1MuDTMuonSorter::m_tf
private

Definition at line 85 of file L1MuDTMuonSorter.h.

Referenced by run().

std::vector<const L1MuDTTrack*> L1MuDTMuonSorter::m_TrackCands
private

Definition at line 86 of file L1MuDTMuonSorter.h.

Referenced by L1MuDTMuonSorter(), numberOfTracks(), print(), reset(), run(), track(), and tracks().