CMS 3D CMS Logo

L1MuBMSectorProcessor.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuBMSectorProcessor
4 //
5 // Description: Sector Processor
6 //
7 //
8 //
9 // Author :
10 // N. Neumeister CERN EP
11 // J. Troconiz UAM Madrid
12 //
13 //--------------------------------------------------
14 
15 //-----------------------
16 // This Class's Header --
17 //-----------------------
18 
19 #include "L1MuBMSectorProcessor.h"
20 
21 //---------------
22 // C++ Headers --
23 //---------------
24 
25 #include <iostream>
26 #include <cmath>
27 
28 //-------------------------------
29 // Collaborating Class Headers --
30 //-------------------------------
31 
40 
43 
44 using namespace std;
45 
46 // --------------------------------
47 // class L1MuBMSectorProcessor
48 //---------------------------------
49 
50 //----------------
51 // Constructors --
52 //----------------
53 
55  const L1MuBMSecProcId& id,
57 
58  m_tf(tf), m_spid(id),
59  m_SectorReceiver(new L1MuBMSectorReceiver(*this, std::move(iC))),
60  m_DataBuffer(new L1MuBMDataBuffer(*this)),
61  m_EU(new L1MuBMExtrapolationUnit(*this)),
62  m_TA(new L1MuBMTrackAssembler(*this)),
63  m_AUs(), m_TrackCands(), m_TracKCands() {
64 
65  // 2 assignment units
66  m_AUs.reserve(2);
67  m_AUs.push_back(new L1MuBMAssignmentUnit(*this,0));
68  m_AUs.push_back(new L1MuBMAssignmentUnit(*this,1));
69 
70  // now the 2 track candidates
71  m_TrackCands.reserve(2);
72  m_TrackCands.push_back(new L1MuBMTrack(m_spid) );
73  m_TrackCands.push_back(new L1MuBMTrack(m_spid) );
74 
75  m_TracKCands.reserve(2);
76  m_TracKCands.push_back(new L1MuBMTrack(m_spid) );
77  m_TracKCands.push_back(new L1MuBMTrack(m_spid) );
78 
79 }
80 
81 
82 //--------------
83 // Destructor --
84 //--------------
85 
87 
88  delete m_SectorReceiver;
89  delete m_DataBuffer;
90  delete m_EU;
91  delete m_TA;
92  delete m_AUs[0];
93  delete m_AUs[1];
94  delete m_TrackCands[0];
95  delete m_TrackCands[1];
96  delete m_TracKCands[0];
97  delete m_TracKCands[1];
98 
99 }
100 
101 //--------------
102 // Operations --
103 //--------------
104 
105 //
106 // run Sector Processor
107 //
109 
110  // receive data and store them into the data buffer
111  if ( m_SectorReceiver ) m_SectorReceiver->run(bx, e, c);
112 
113  // check content of data buffer
114  if ( m_DataBuffer ) {
115  if ( L1MuBMTFConfig::Debug(4) && m_DataBuffer->numberTSphi() > 0 ) {
116  cout << "Phi track segments received by " << m_spid << " : " << endl;
118  }
119  }
120 
121  // perform all extrapolations
122  int n_ext = 0; // number of successful extrapolations
123  if ( m_EU && m_DataBuffer && m_DataBuffer->numberTSphi() > 1 ) {
124  m_EU->run(c);
125  n_ext = m_EU->numberOfExt();
126  if ( L1MuBMTFConfig::Debug(3) && n_ext > 0 ) {
127 // if ( print_flag && n_ext > 0 ) {
128  cout << "Number of successful extrapolations : " << n_ext << endl;
129  m_EU->print();
130  }
131  }
132 
133  // hardware debug (output from Extrapolator and Quality Sorter)
134  // m_EU->print(1);
135 
136  // perform track assembling
137  if ( m_TA && n_ext > 0 ) {
138  m_TA->run();
139  if ( L1MuBMTFConfig::Debug(3) ) m_TA->print();
140  }
141 
142  // assign pt, eta, phi and quality
143  if ( m_AUs[0] && !m_TA->isEmpty(0) ) m_AUs[0]->run(c);
144  if ( m_AUs[1] && !m_TA->isEmpty(1) ) m_AUs[1]->run(c);
145 
146  if ( m_spid.wheel() == -1 ) {
147  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(2)>3 && m_TrackCands[0]->address(2)<6 ) m_TrackCands[0]->reset();
148  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(3)>3 && m_TrackCands[0]->address(3)<6 ) m_TrackCands[0]->reset();
149  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(4)>3 && m_TrackCands[0]->address(4)<6 ) m_TrackCands[0]->reset();
150 
151  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(2)>3 && m_TracKCands[0]->address(2)<6 ) m_TracKCands[0]->reset();
152  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(3)>3 && m_TracKCands[0]->address(3)<6 ) m_TracKCands[0]->reset();
153  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(4)>3 && m_TracKCands[0]->address(4)<6 ) m_TracKCands[0]->reset();
154 
155  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(2)>3 && m_TrackCands[1]->address(2)<6 ) m_TrackCands[1]->reset();
156  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(3)>3 && m_TrackCands[1]->address(3)<6 ) m_TrackCands[1]->reset();
157  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(4)>3 && m_TrackCands[1]->address(4)<6 ) m_TrackCands[1]->reset();
158 
159  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(2)>3 && m_TracKCands[1]->address(2)<6 ) m_TracKCands[1]->reset();
160  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(3)>3 && m_TracKCands[1]->address(3)<6 ) m_TracKCands[1]->reset();
161  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(4)>3 && m_TracKCands[1]->address(4)<6 ) m_TracKCands[1]->reset();
162 
163  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(2)>7 && m_TrackCands[0]->address(2)<10 ) m_TrackCands[0]->reset();
164  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(3)>7 && m_TrackCands[0]->address(3)<10 ) m_TrackCands[0]->reset();
165  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(4)>7 && m_TrackCands[0]->address(4)<10 ) m_TrackCands[0]->reset();
166 
167  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(2)>7 && m_TracKCands[0]->address(2)<10 ) m_TracKCands[0]->reset();
168  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(3)>7 && m_TracKCands[0]->address(3)<10 ) m_TracKCands[0]->reset();
169  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(4)>7 && m_TracKCands[0]->address(4)<10 ) m_TracKCands[0]->reset();
170 
171  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(2)>7 && m_TrackCands[1]->address(2)<10 ) m_TrackCands[1]->reset();
172  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(3)>7 && m_TrackCands[1]->address(3)<10 ) m_TrackCands[1]->reset();
173  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(4)>7 && m_TrackCands[1]->address(4)<10 ) m_TrackCands[1]->reset();
174 
175  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(2)>7 && m_TracKCands[1]->address(2)<10 ) m_TracKCands[1]->reset();
176  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(3)>7 && m_TracKCands[1]->address(3)<10 ) m_TracKCands[1]->reset();
177  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(4)>7 && m_TracKCands[1]->address(4)<10 ) m_TracKCands[1]->reset();
178  }
179 
180 }
181 
182 
183 //
184 // reset Sector Processor
185 //
187 
189  if ( m_DataBuffer ) m_DataBuffer->reset();
190  if ( m_EU ) m_EU->reset();
191  if ( m_TA ) m_TA->reset();
192  if ( m_AUs[0] ) m_AUs[0]->reset();
193  if ( m_AUs[1] ) m_AUs[1]->reset();
194  if ( m_TrackCands[0] ) m_TrackCands[0]->reset();
195  if ( m_TrackCands[1] ) m_TrackCands[1]->reset();
196  if ( m_TracKCands[0] ) m_TracKCands[0]->reset();
197  if ( m_TracKCands[1] ) m_TracKCands[1]->reset();
198 
199 }
200 
201 
202 //
203 // print candidates found in Sector Processor
204 //
206 
207  if ( anyTrack() ) {
208  cout << "Muon candidates found in " << m_spid << " : " << endl;
209  vector<L1MuBMTrack*>::const_iterator iter = m_TrackCands.begin();
210  while ( iter != m_TrackCands.end() ) {
211  if ( *iter) (*iter)->print();
212  iter++;
213  }
214  }
215 
216 }
217 
218 
219 //
220 // return pointer to nextWheel neighbour
221 //
223 
224  int sector = m_spid.sector();
225  int wheel = m_spid.wheel();
226 
227  // the neighbour is in the same wedge with the following definition:
228  // current SP -3 -2 -1 +1 +2 +3
229  // neighbour -2 -1 +1 0 +1 +2
230 
231  if ( wheel == 1) return nullptr;
232  wheel = (wheel == -1) ? 1 : (wheel/abs(wheel)) * (abs(wheel)-1);
233 
234  const L1MuBMSecProcId id(wheel,sector);
235 
236  return m_tf.sp(id);
237 
238 }
239 
240 
241 //
242 // are there any muon candidates?
243 //
245 
246  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() ) return true;
247  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() ) return true;
248 
249  return false;
250 
251 }
void run(const edm::EventSetup &c) override
run Extrapolation Unit
int numberTSphi() const
return number of non-empty phi track segments
const L1MuBMSectorProcessor * neighbour() const
return pointer to the next wheel neighbour
void run(int bx, const edm::Event &e, const edm::EventSetup &c)
receive track segment data from the BBMX and CSC chamber triggers
bool anyTrack() const
are there any non-empty muon candidates?
void printTSphi() const
print all phi track segments which are in the buffer
virtual ~L1MuBMSectorProcessor()
destructor
std::vector< L1MuBMTrack * > m_TracKCands
void run() override
run Track Assembler
int sector() const
return sector number
void reset() override
reset Extrapolation Unit
void reset()
clear Data Buffer
void print() const
print result of Track Assembler
std::vector< L1MuBMTrack * > m_TrackCands
const L1MuBMTrackFinder & m_tf
const L1MuBMSectorProcessor * sp(const L1MuBMSecProcId &) const
get a pointer to a Sector Processor
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int numberOfExt() const
return number of successful extrapolations
const L1MuBMSecProcId & id() const
return Sector Processor identifier
void print() const
print muon candidates found by the Sector Processor
void print(int level=0) const
print all successful extrapolations
L1MuBMSectorProcessor(const L1MuBMTrackFinder &, const L1MuBMSecProcId &, edm::ConsumesCollector &&)
constructor
bool isEmpty(int id) const
is it a valid Track Class?
void reset() override
reset Track Assembler
static bool Debug()
void reset()
clear Sector Receiver
L1MuBMSectorReceiver * m_SectorReceiver
L1MuBMTrackAssembler * m_TA
L1MuBMDataBuffer * m_DataBuffer
std::vector< L1MuBMAssignmentUnit * > m_AUs
L1MuBMExtrapolationUnit * m_EU
virtual void run(int bx, const edm::Event &e, const edm::EventSetup &c)
run the Sector Processor
virtual void reset()
reset the Sector Processor
def move(src, dest)
Definition: eostools.py:511
int wheel() const
return wheel number