CMS 3D CMS Logo

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

#include <L1MuBMWedgeSorter.h>

Public Member Functions

bool anyMuonCands () const
 return number of muon candidates More...
 
int id () const
 return Wedge Sorter identifier (0-11) More...
 
 L1MuBMWedgeSorter (const L1MuBMTrackFinder &, int id)
 constructor More...
 
void print () const
 print results after sorting More...
 
void reset ()
 reset Wedge Sorter More...
 
void run ()
 run Wedge Sorter More...
 
const std::vector< const L1MuBMTrack * > & tracks () const
 return vector of muon candidates More...
 
 ~L1MuBMWedgeSorter ()
 destructor More...
 

Private Member Functions

bool anyTrack () const
 are there any non-empty muon candidates in the Wedge Sorter? More...
 
void runCOL (std::vector< L1MuBMTrack *> &) const
 run the Cancel Out Logic of the wedge sorter More...
 

Static Private Member Functions

static bool neighbour (const L1MuBMSecProcId &spid1, const L1MuBMSecProcId &spid2)
 find out if two Sector Processors are neighbours in the same wedge More...
 

Private Attributes

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

Detailed Description

Wedge Sorter:

A Wedge Sorter receives 2 muon candidates from each of the 6 Sector Processors of a wedge and forwards the 2 highest rank candidates per wedge to the BM Muon Sorter

N. Neumeister CERN EP

Definition at line 43 of file L1MuBMWedgeSorter.h.

Constructor & Destructor Documentation

◆ L1MuBMWedgeSorter()

L1MuBMWedgeSorter::L1MuBMWedgeSorter ( const L1MuBMTrackFinder tf,
int  id 
)

constructor

Definition at line 50 of file L1MuBMWedgeSorter.cc.

References m_TrackCands.

50  : m_tf(tf), m_wsid(id), m_TrackCands(3) {
51  m_TrackCands.reserve(3);
52 }
std::vector< const L1MuBMTrack * > m_TrackCands
const L1MuBMTrackFinder & m_tf

◆ ~L1MuBMWedgeSorter()

L1MuBMWedgeSorter::~L1MuBMWedgeSorter ( )

destructor

Definition at line 58 of file L1MuBMWedgeSorter.cc.

58 {}

Member Function Documentation

◆ anyMuonCands()

bool L1MuBMWedgeSorter::anyMuonCands ( ) const
inline

return number of muon candidates

Definition at line 67 of file L1MuBMWedgeSorter.h.

References anyTrack().

67 { return anyTrack(); }
bool anyTrack() const
are there any non-empty muon candidates in the Wedge Sorter?

◆ anyTrack()

bool L1MuBMWedgeSorter::anyTrack ( ) const
private

are there any non-empty muon candidates in the Wedge Sorter?

Definition at line 163 of file L1MuBMWedgeSorter.cc.

References m_TrackCands.

Referenced by anyMuonCands(), and print().

163  {
164  vector<const L1MuBMTrack*>::const_iterator iter = m_TrackCands.begin();
165  while (iter != m_TrackCands.end()) {
166  if (*iter && !(*iter)->empty())
167  return true;
168  iter++;
169  }
170 
171  return false;
172 }
std::vector< const L1MuBMTrack * > m_TrackCands

◆ id()

int L1MuBMWedgeSorter::id ( void  ) const
inline

return Wedge Sorter identifier (0-11)

Definition at line 52 of file L1MuBMWedgeSorter.h.

References m_wsid.

52 { return m_wsid; }

◆ neighbour()

bool L1MuBMWedgeSorter::neighbour ( const L1MuBMSecProcId spid1,
const L1MuBMSecProcId spid2 
)
staticprivate

find out if two Sector Processors are neighbours in the same wedge

Definition at line 239 of file L1MuBMWedgeSorter.cc.

References L1MuBMSecProcId::sector(), hgcalTopologyTester_cfi::sector1, hgcalTopologyTester_cfi::sector2, and L1MuBMSecProcId::wheel().

Referenced by runCOL().

239  {
240  // neighbour definition:
241  // wheel 1 : -2, -1, +1, +1, +2
242  // wheel 2 : -3, -2, -1, +2, +3
243 
244  bool neigh = false;
245 
246  int sector1 = spid1.sector();
247  int wheel1 = spid1.wheel();
248 
249  int sector2 = spid2.sector();
250  int wheel2 = spid2.wheel();
251 
252  if (sector1 == sector2) {
253  if ((wheel1 == -2 && wheel2 == -3) || (wheel1 == -1 && wheel2 == -2) || (wheel1 == +1 && wheel2 == -1) ||
254  (wheel1 == +1 && wheel2 == +2) || (wheel1 == +2 && wheel2 == +3))
255  neigh = true;
256  }
257 
258  return neigh;
259 }
int wheel() const
return wheel number
int sector() const
return sector number

◆ print()

void L1MuBMWedgeSorter::print ( void  ) const

print results after sorting

Definition at line 148 of file L1MuBMWedgeSorter.cc.

References anyTrack(), gather_cfg::cout, m_TrackCands, and m_wsid.

148  {
149  if (anyTrack()) {
150  cout << "Muon candidates found in Wedge Sorter " << m_wsid << " : " << endl;
151  vector<const L1MuBMTrack*>::const_iterator iter = m_TrackCands.begin();
152  while (iter != m_TrackCands.end()) {
153  if (*iter)
154  cout << *(*iter) << " found in " << (*iter)->spid() << endl;
155  iter++;
156  }
157  }
158 }
std::vector< const L1MuBMTrack * > m_TrackCands
bool anyTrack() const
are there any non-empty muon candidates in the Wedge Sorter?

◆ reset()

void L1MuBMWedgeSorter::reset ( void  )

reset Wedge Sorter

Definition at line 138 of file L1MuBMWedgeSorter.cc.

References m_TrackCands.

138  {
139  vector<const L1MuBMTrack*>::iterator iter;
140  for (iter = m_TrackCands.begin(); iter != m_TrackCands.end(); iter++) {
141  *iter = nullptr;
142  }
143 }
std::vector< const L1MuBMTrack * > m_TrackCands

◆ run()

void L1MuBMWedgeSorter::run ( )

run Wedge Sorter

Definition at line 67 of file L1MuBMWedgeSorter.cc.

References gather_cfg::cout, L1MuBMTFConfig::Debug(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, m_tf, m_TrackCands, m_wsid, contentValuesFiles::number, L1MuBMTrack::rank(), caHitNtupletGeneratorKernels::reject, runCOL(), nano_mu_digi_cff::sector, L1MuBMTrackFinder::sp(), L1MuBMSectorProcessor::track(), and makeMuonMisalignmentScenario::wheel.

67  {
68  // get track candidates from Sector Processors
69  vector<L1MuBMTrack*> wedgecands;
70  wedgecands.reserve(12);
71 
72  int sector = m_wsid;
73  for (int wheel = -3; wheel <= 3; wheel++) {
74  if (wheel == 0)
75  continue;
76  L1MuBMSecProcId tmpspid(wheel, sector);
77  for (int number = 0; number < 2; number++) {
78  const L1MuBMTrack* cand = m_tf.sp(tmpspid)->track(number);
79  if (cand && !cand->empty()) {
80  // remove tracks which where found in wheel 0 and
81  // which didn't cross wheel boundaries (SP -1)
82  bool reject = false;
83  if (wheel == -1) {
84  reject = true;
85  for (int stat = 2; stat <= 4; stat++) {
86  int adr = cand->address(stat);
87  // check addresses : 0,1,4,5,8,9 (own wheel)
88  if (adr != 15)
89  reject &= ((adr / 2) % 2 == 0);
90  }
91  }
92  if (!reject)
93  wedgecands.push_back(const_cast<L1MuBMTrack*>(cand));
94  }
95  }
96  }
97 
98  // print input data
99  if (L1MuBMTFConfig::Debug(5)) {
100  cout << "Wedge Sorter " << m_wsid << " input: " << wedgecands.size() << endl;
101  vector<L1MuBMTrack*>::const_iterator iter;
102  for (iter = wedgecands.begin(); iter != wedgecands.end(); iter++) {
103  if (*iter)
104  (*iter)->print();
105  }
106  }
107 
108  // print input data
109  runCOL(wedgecands);
110 
111  // remove disabled candidates
112  vector<L1MuBMTrack*>::iterator it = wedgecands.begin();
113  while (it != wedgecands.end()) {
114  if (*it && (*it)->empty()) {
115  wedgecands.erase(it);
116  it = wedgecands.begin();
117  continue;
118  }
119  it++;
120  }
121 
122  // sort candidates by pt and quality and copy the 2 best candidates
123  partial_sort_copy(wedgecands.begin(), wedgecands.end(), m_TrackCands.begin(), m_TrackCands.end(), L1MuBMTrack::rank);
124 
125  if (L1MuBMTFConfig::Debug(4)) {
126  cout << "Wedge Sorter " << m_wsid << " output: " << endl;
127  vector<const L1MuBMTrack*>::const_iterator iter;
128  for (iter = m_TrackCands.begin(); iter != m_TrackCands.end(); iter++) {
129  if (*iter)
130  (*iter)->print();
131  }
132  }
133 }
const L1MuBMSectorProcessor * sp(const L1MuBMSecProcId &) const
get a pointer to a Sector Processor
L1MuBMTrack * track(int id) const
return pointer to muon candidate, index [0,1]
std::vector< const L1MuBMTrack * > m_TrackCands
void runCOL(std::vector< L1MuBMTrack *> &) const
run the Cancel Out Logic of the wedge sorter
const L1MuBMTrackFinder & m_tf
static bool rank(const L1MuBMTrack *first, const L1MuBMTrack *second)
define a rank for muon candidates
Definition: L1MuBMTrack.h:190
static bool Debug()

◆ runCOL()

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

run the Cancel Out Logic of the wedge sorter

Definition at line 177 of file L1MuBMWedgeSorter.cc.

References HLT_2024v10_cff::cands, gather_cfg::cout, L1MuBMTFConfig::Debug(), neighbour(), and L1MuBMSecProcId::wheel().

Referenced by run().

177  {
178  // compare candidates which were found in nearby wheels:
179  // if 2 candidates have at least one track segment in common
180  // disable the one with lower quality;
181  // compare addresses from stations 2, 3 and 4
182 
183  typedef vector<L1MuBMTrack*>::iterator TI;
184  for (TI iter1 = cands.begin(); iter1 != cands.end(); iter1++) {
185  if (*iter1 == nullptr)
186  continue;
187  if ((*iter1)->empty())
188  continue;
189  L1MuBMSecProcId sp1 = (*iter1)->spid();
190  int qual1 = (*iter1)->quality();
191  for (TI iter2 = cands.begin(); iter2 != cands.end(); iter2++) {
192  if (*iter2 == nullptr)
193  continue;
194  if (*iter1 == *iter2)
195  continue;
196  if ((*iter2)->empty())
197  continue;
198  L1MuBMSecProcId sp2 = (*iter2)->spid();
199  int qual2 = (*iter2)->quality();
200  if (sp1 == sp2)
201  continue;
202  if (!neighbour(sp1, sp2))
203  continue;
204  int adr_shift = (sp2.wheel() == -1) ? 0 : 2;
205  int countTS = 0;
206  for (int stat = 2; stat <= 4; stat++) {
207  int adr1 = (*iter1)->address(stat);
208  int adr2 = (*iter2)->address(stat);
209  if (adr1 == 15 || adr2 == 15)
210  continue;
211  if ((adr2 / 2) % 2 == 1)
212  continue;
213  if (adr1 == adr2 + adr_shift)
214  countTS++;
215  }
216  if (countTS > 0) {
217  if (qual1 < qual2) {
218  if (L1MuBMTFConfig::Debug(5)) {
219  cout << "Wedge Sorter cancel : ";
220  (*iter1)->print();
221  }
222  (*iter1)->disable();
223  break;
224  } else {
225  if (L1MuBMTFConfig::Debug(5)) {
226  cout << "Wedge Sorter cancel : ";
227  (*iter2)->print();
228  }
229  (*iter2)->disable();
230  }
231  }
232  }
233  }
234 }
int wheel() const
return wheel number
static bool neighbour(const L1MuBMSecProcId &spid1, const L1MuBMSecProcId &spid2)
find out if two Sector Processors are neighbours in the same wedge
static bool Debug()

◆ tracks()

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

return vector of muon candidates

Definition at line 64 of file L1MuBMWedgeSorter.h.

References m_TrackCands.

Referenced by L1MuBMMuonSorter::run().

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

Member Data Documentation

◆ m_tf

const L1MuBMTrackFinder& L1MuBMWedgeSorter::m_tf
private

Definition at line 80 of file L1MuBMWedgeSorter.h.

Referenced by run().

◆ m_TrackCands

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

Definition at line 83 of file L1MuBMWedgeSorter.h.

Referenced by anyTrack(), L1MuBMWedgeSorter(), print(), reset(), run(), and tracks().

◆ m_wsid

int L1MuBMWedgeSorter::m_wsid
private

Definition at line 81 of file L1MuBMWedgeSorter.h.

Referenced by id(), print(), and run().