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>

Inheritance diagram for L1MuBMWedgeSorter:
L1AbstractProcessor

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 () override
 reset Wedge Sorter More...
 
void run () override
 run Wedge Sorter More...
 
const std::vector< const L1MuBMTrack * > & tracks () const
 return vector of muon candidates More...
 
 ~L1MuBMWedgeSorter () override
 destructor More...
 
- Public Member Functions inherited from L1AbstractProcessor
virtual void run (const edm::EventSetup &c)
 
virtual void run (const edm::EventSetup &c)
 
virtual ~L1AbstractProcessor ()
 destructor More...
 
virtual ~L1AbstractProcessor ()
 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 45 of file L1MuBMWedgeSorter.h.

Constructor & Destructor Documentation

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

constructor

Definition at line 50 of file L1MuBMWedgeSorter.cc.

References m_TrackCands.

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

destructor

Definition at line 62 of file L1MuBMWedgeSorter.cc.

62  {
63 
64 }

Member Function Documentation

bool L1MuBMWedgeSorter::anyMuonCands ( ) const
inline

return number of muon candidates

Definition at line 71 of file L1MuBMWedgeSorter.h.

References anyTrack(), neighbour(), and runCOL().

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

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

Definition at line 177 of file L1MuBMWedgeSorter.cc.

References m_TrackCands.

Referenced by anyMuonCands(), and print().

177  {
178 
179  vector<const L1MuBMTrack*>::const_iterator iter = m_TrackCands.begin();
180  while ( iter != m_TrackCands.end() ) {
181  if ( *iter && !(*iter)->empty() ) return true;
182  iter++;
183  }
184 
185  return false;
186 
187 }
std::vector< const L1MuBMTrack * > m_TrackCands
int L1MuBMWedgeSorter::id ( void  ) const
inline

return Wedge Sorter identifier (0-11)

Definition at line 56 of file L1MuBMWedgeSorter.h.

References m_wsid, print(), reset(), and run().

56 { return m_wsid; }
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 247 of file L1MuBMWedgeSorter.cc.

References L1MuBMSecProcId::sector(), and L1MuBMSecProcId::wheel().

Referenced by anyMuonCands(), and runCOL().

248  {
249 
250  // neighbour definition:
251  // wheel 1 : -2, -1, +1, +1, +2
252  // wheel 2 : -3, -2, -1, +2, +3
253 
254  bool neigh = false;
255 
256  int sector1 = spid1.sector();
257  int wheel1 = spid1.wheel();
258 
259  int sector2 = spid2.sector();
260  int wheel2 = spid2.wheel();
261 
262  if ( sector1 == sector2 ) {
263 
264  if ( ( wheel1 == -2 && wheel2 == -3 ) ||
265  ( wheel1 == -1 && wheel2 == -2 ) ||
266  ( wheel1 == +1 && wheel2 == -1 ) ||
267  ( wheel1 == +1 && wheel2 == +2 ) ||
268  ( wheel1 == +2 && wheel2 == +3 ) ) neigh = true;
269 
270  }
271 
272  return neigh;
273 
274 }
int sector() const
return sector number
int wheel() const
return wheel number
void L1MuBMWedgeSorter::print ( void  ) const

print results after sorting

Definition at line 159 of file L1MuBMWedgeSorter.cc.

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

Referenced by id().

159  {
160 
161  if ( anyTrack() ) {
162  cout << "Muon candidates found in Wedge Sorter " << m_wsid << " : " << endl;
163  vector<const L1MuBMTrack*>::const_iterator iter = m_TrackCands.begin();
164  while ( iter != m_TrackCands.end() ) {
165  if ( *iter ) cout << *(*iter) << " found in "
166  << (*iter)->spid() << endl;
167  iter++;
168  }
169  }
170 
171 }
std::vector< const L1MuBMTrack * > m_TrackCands
bool anyTrack() const
are there any non-empty muon candidates in the Wedge Sorter?
void L1MuBMWedgeSorter::reset ( void  )
overridevirtual

reset Wedge Sorter

Implements L1AbstractProcessor.

Definition at line 146 of file L1MuBMWedgeSorter.cc.

References m_TrackCands.

Referenced by id().

146  {
147 
148  vector<const L1MuBMTrack*>::iterator iter;
149  for ( iter = m_TrackCands.begin(); iter != m_TrackCands.end(); iter++ ) {
150  *iter = nullptr;
151  }
152 
153 }
std::vector< const L1MuBMTrack * > m_TrackCands
void L1MuBMWedgeSorter::run ( void  )
overridevirtual

run Wedge Sorter

Reimplemented from L1AbstractProcessor.

Definition at line 74 of file L1MuBMWedgeSorter.cc.

References L1MuBMTrack::address(), gather_cfg::cout, L1MuBMTFConfig::Debug(), L1MuBMTrack::empty(), m_tf, m_TrackCands, m_wsid, runCOL(), L1MuBMTrackFinder::sp(), L1MuBMSectorProcessor::track(), and makeMuonMisalignmentScenario::wheel.

Referenced by id().

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

run the Cancel Out Logic of the wedge sorter

Definition at line 193 of file L1MuBMWedgeSorter.cc.

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

Referenced by anyMuonCands(), and run().

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

return vector of muon candidates

Definition at line 68 of file L1MuBMWedgeSorter.h.

References m_TrackCands.

Referenced by L1MuBMMuonSorter::run().

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

Member Data Documentation

const L1MuBMTrackFinder& L1MuBMWedgeSorter::m_tf
private

Definition at line 86 of file L1MuBMWedgeSorter.h.

Referenced by run().

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

Definition at line 89 of file L1MuBMWedgeSorter.h.

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

int L1MuBMWedgeSorter::m_wsid
private

Definition at line 87 of file L1MuBMWedgeSorter.h.

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