CMS 3D CMS Logo

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

#include <L1MuDTMuonSorter.h>

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...
 
void reset ()
 reset Muon Sorter More...
 
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...
 
 ~L1MuDTMuonSorter ()
 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

N. Neumeister CERN EP

Definition at line 43 of file L1MuDTMuonSorter.h.

Constructor & Destructor Documentation

L1MuDTMuonSorter::L1MuDTMuonSorter ( const L1MuDTTrackFinder tf)

constructor

Definition at line 48 of file L1MuDTMuonSorter.cc.

References m_TrackCands.

48 : m_tf(tf), m_TrackCands() { m_TrackCands.reserve(4); }
std::vector< const L1MuDTTrack * > m_TrackCands
const L1MuDTTrackFinder & m_tf
L1MuDTMuonSorter::~L1MuDTMuonSorter ( )

destructor

Definition at line 54 of file L1MuDTMuonSorter.cc.

54 {}

Member Function Documentation

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

find out if two Sector Processors are neighbours

Definition at line 304 of file L1MuDTMuonSorter.cc.

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

Referenced by runCOL().

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

return number of found muon candidates after sorter

Definition at line 61 of file L1MuDTMuonSorter.h.

References m_TrackCands.

Referenced by print().

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

print results after sorting

Definition at line 131 of file L1MuDTMuonSorter.cc.

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

131  {
132  cout << endl;
133  cout << "Muon candidates found by the barrel MTTF : " << numberOfTracks() << endl;
134  vector<const L1MuDTTrack*>::const_iterator iter = m_TrackCands.begin();
135  while (iter != m_TrackCands.end()) {
136  if (*iter)
137  cout << *(*iter) << endl;
138  iter++;
139  }
140  cout << endl;
141 }
std::vector< const L1MuDTTrack * > m_TrackCands
int numberOfTracks() const
return number of found muon candidates after sorter
tuple cout
Definition: gather_cfg.py:144
void L1MuDTMuonSorter::reset ( void  )

reset Muon Sorter

Definition at line 120 of file L1MuDTMuonSorter.cc.

References m_TrackCands.

120  {
121  m_TrackCands.clear();
122  vector<const L1MuDTTrack*>::iterator iter;
123  for (iter = m_TrackCands.begin(); iter != m_TrackCands.end(); iter++) {
124  *iter = nullptr;
125  }
126 }
std::vector< const L1MuDTTrack * > m_TrackCands
void L1MuDTMuonSorter::run ( )

run Muon Sorter

Definition at line 63 of file L1MuDTMuonSorter.cc.

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

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

run the Cancel Out Logic of the muon sorter

Definition at line 146 of file L1MuDTMuonSorter.cc.

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

Referenced by run().

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

return pointer to a muon candidate

Definition at line 64 of file L1MuDTMuonSorter.h.

References gpuClustering::id, and m_TrackCands.

64 { return m_TrackCands[id]; }
uint16_t *__restrict__ 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 67 of file L1MuDTMuonSorter.h.

References m_TrackCands.

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

Member Data Documentation

const L1MuDTTrackFinder& L1MuDTMuonSorter::m_tf
private

Definition at line 77 of file L1MuDTMuonSorter.h.

Referenced by run().

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

Definition at line 78 of file L1MuDTMuonSorter.h.

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