CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
L1MuBMMuonSorter Class Reference

#include <L1MuBMMuonSorter.h>

Public Member Functions

 L1MuBMMuonSorter (const L1MuBMTrackFinder &)
 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 L1MuBMTracktrack (int id) const
 return pointer to a muon candidate More...
 
const std::vector< const L1MuBMTrack * > & tracks () const
 return vector of muon candidates More...
 
 ~L1MuBMMuonSorter ()
 destructor More...
 

Private Member Functions

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

Static Private Member Functions

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

Private Attributes

const L1MuBMTrackFinderm_tf
 
std::vector< const L1MuBMTrack * > m_TrackCands
 

Detailed Description

BM Muon Sorter:

The BM 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 L1MuBMMuonSorter.h.

Constructor & Destructor Documentation

◆ L1MuBMMuonSorter()

L1MuBMMuonSorter::L1MuBMMuonSorter ( const L1MuBMTrackFinder tf)

constructor

Definition at line 49 of file L1MuBMMuonSorter.cc.

References m_TrackCands.

49 : m_tf(tf), m_TrackCands() { m_TrackCands.reserve(4); }
const L1MuBMTrackFinder & m_tf
std::vector< const L1MuBMTrack * > m_TrackCands

◆ ~L1MuBMMuonSorter()

L1MuBMMuonSorter::~L1MuBMMuonSorter ( )

destructor

Definition at line 55 of file L1MuBMMuonSorter.cc.

55 {}

Member Function Documentation

◆ neighbour()

int L1MuBMMuonSorter::neighbour ( const L1MuBMSecProcId spid1,
const L1MuBMSecProcId spid2 
)
staticprivate

find out if two Sector Processors are neighbours

Definition at line 305 of file L1MuBMMuonSorter.cc.

References funct::abs(), L1MuBMSecProcId::sector(), hgcalTopologyTester_cfi::sector1, hgcalTopologyTester_cfi::sector2, HLT_2024v10_cff::topology, and L1MuBMSecProcId::wheel().

Referenced by runCOL().

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

◆ numberOfTracks()

int L1MuBMMuonSorter::numberOfTracks ( ) const
inline

return number of found muon candidates after sorter

Definition at line 61 of file L1MuBMMuonSorter.h.

References m_TrackCands.

Referenced by print().

61 { return m_TrackCands.size(); }
std::vector< const L1MuBMTrack * > m_TrackCands

◆ print()

void L1MuBMMuonSorter::print ( void  ) const

print results after sorting

Definition at line 132 of file L1MuBMMuonSorter.cc.

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

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

◆ reset()

void L1MuBMMuonSorter::reset ( void  )

reset Muon Sorter

Definition at line 121 of file L1MuBMMuonSorter.cc.

References m_TrackCands.

Referenced by L1MuBMTrackFinder::reset().

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

◆ run()

void L1MuBMMuonSorter::run ( )

run Muon Sorter

Definition at line 64 of file L1MuBMMuonSorter.cc.

References gather_cfg::cout, L1MuBMTFConfig::Debug(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, m_tf, m_TrackCands, L1MuBMTrack::rank(), runCOL(), L1MuBMWedgeSorter::tracks(), and L1MuBMTrackFinder::ws().

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

◆ runCOL()

void L1MuBMMuonSorter::runCOL ( std::vector< L1MuBMTrack *> &  cands) const
private

run the Cancel Out Logic of the muon sorter

Definition at line 147 of file L1MuBMMuonSorter.cc.

References funct::abs(), HLT_2024v10_cff::cands, gather_cfg::cout, L1MuBMTFConfig::Debug(), neighbour(), hitfit::phidiff(), HLT_2024v10_cff::pt1, HLT_2024v10_cff::pt2, HLT_2024v10_cff::topology, and w2.

Referenced by run().

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

◆ track()

const L1MuBMTrack* L1MuBMMuonSorter::track ( int  id) const
inline

return pointer to a muon candidate

Definition at line 64 of file L1MuBMMuonSorter.h.

References l1ctLayer2EG_cff::id, and m_TrackCands.

64 { return m_TrackCands[id]; }
std::vector< const L1MuBMTrack * > m_TrackCands

◆ tracks()

const std::vector<const L1MuBMTrack*>& L1MuBMMuonSorter::tracks ( void  ) const
inline

return vector of muon candidates

Definition at line 67 of file L1MuBMMuonSorter.h.

References m_TrackCands.

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

Member Data Documentation

◆ m_tf

const L1MuBMTrackFinder& L1MuBMMuonSorter::m_tf
private

Definition at line 77 of file L1MuBMMuonSorter.h.

Referenced by run().

◆ m_TrackCands

std::vector<const L1MuBMTrack*> L1MuBMMuonSorter::m_TrackCands
private

Definition at line 78 of file L1MuBMMuonSorter.h.

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