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 
59  m_tf(tf),
60  m_spid(id),
61  m_SectorReceiver(new L1MuBMSectorReceiver(*this, std::move(iC))),
62  m_DataBuffer(new L1MuBMDataBuffer(*this)),
63  m_EU(new L1MuBMExtrapolationUnit(*this, iC)),
64  m_TA(new L1MuBMTrackAssembler(*this)),
65  m_bmtfParamsToken(iC.esConsumes()),
66  m_AUs(),
67  m_TrackCands(),
68  m_TracKCands() {
69  // 2 assignment units
70  m_AUs.reserve(2);
71  m_AUs.push_back(new L1MuBMAssignmentUnit(*this, 0));
72  m_AUs.push_back(new L1MuBMAssignmentUnit(*this, 1));
73 
74  // now the 2 track candidates
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  m_TracKCands.reserve(2);
80  m_TracKCands.push_back(new L1MuBMTrack(m_spid));
81  m_TracKCands.push_back(new L1MuBMTrack(m_spid));
82 }
83 
84 //--------------
85 // Destructor --
86 //--------------
87 
89  delete m_SectorReceiver;
90  delete m_DataBuffer;
91  delete m_EU;
92  delete m_TA;
93  delete m_AUs[0];
94  delete m_AUs[1];
95  delete m_TrackCands[0];
96  delete m_TrackCands[1];
97  delete m_TracKCands[0];
98  delete m_TracKCands[1];
99 }
100 
101 //--------------
102 // Operations --
103 //--------------
104 
105 //
106 // run Sector Processor
107 //
109  // receive data and store them into the data buffer
110  if (m_SectorReceiver)
111  m_SectorReceiver->run(bx, e, c);
112 
113  // check content of data buffer
114  if (m_DataBuffer) {
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))
140  m_TA->print();
141  }
142 
143  L1TMuonBarrelParams const& bmtfParams = c.getData(m_bmtfParamsToken);
144 
145  // assign pt, eta, phi and quality
146  if (m_AUs[0] && !m_TA->isEmpty(0))
147  m_AUs[0]->run(bmtfParams);
148  if (m_AUs[1] && !m_TA->isEmpty(1))
149  m_AUs[1]->run(bmtfParams);
150 
151  if (m_spid.wheel() == -1) {
152  if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(2) > 3 &&
153  m_TrackCands[0]->address(2) < 6)
154  m_TrackCands[0]->reset();
155  if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(3) > 3 &&
156  m_TrackCands[0]->address(3) < 6)
157  m_TrackCands[0]->reset();
158  if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(4) > 3 &&
159  m_TrackCands[0]->address(4) < 6)
160  m_TrackCands[0]->reset();
161 
162  if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(2) > 3 &&
163  m_TracKCands[0]->address(2) < 6)
164  m_TracKCands[0]->reset();
165  if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(3) > 3 &&
166  m_TracKCands[0]->address(3) < 6)
167  m_TracKCands[0]->reset();
168  if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(4) > 3 &&
169  m_TracKCands[0]->address(4) < 6)
170  m_TracKCands[0]->reset();
171 
172  if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(2) > 3 &&
173  m_TrackCands[1]->address(2) < 6)
174  m_TrackCands[1]->reset();
175  if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(3) > 3 &&
176  m_TrackCands[1]->address(3) < 6)
177  m_TrackCands[1]->reset();
178  if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(4) > 3 &&
179  m_TrackCands[1]->address(4) < 6)
180  m_TrackCands[1]->reset();
181 
182  if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(2) > 3 &&
183  m_TracKCands[1]->address(2) < 6)
184  m_TracKCands[1]->reset();
185  if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(3) > 3 &&
186  m_TracKCands[1]->address(3) < 6)
187  m_TracKCands[1]->reset();
188  if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(4) > 3 &&
189  m_TracKCands[1]->address(4) < 6)
190  m_TracKCands[1]->reset();
191 
192  if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(2) > 7 &&
193  m_TrackCands[0]->address(2) < 10)
194  m_TrackCands[0]->reset();
195  if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(3) > 7 &&
196  m_TrackCands[0]->address(3) < 10)
197  m_TrackCands[0]->reset();
198  if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(4) > 7 &&
199  m_TrackCands[0]->address(4) < 10)
200  m_TrackCands[0]->reset();
201 
202  if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(2) > 7 &&
203  m_TracKCands[0]->address(2) < 10)
204  m_TracKCands[0]->reset();
205  if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(3) > 7 &&
206  m_TracKCands[0]->address(3) < 10)
207  m_TracKCands[0]->reset();
208  if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(4) > 7 &&
209  m_TracKCands[0]->address(4) < 10)
210  m_TracKCands[0]->reset();
211 
212  if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(2) > 7 &&
213  m_TrackCands[1]->address(2) < 10)
214  m_TrackCands[1]->reset();
215  if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(3) > 7 &&
216  m_TrackCands[1]->address(3) < 10)
217  m_TrackCands[1]->reset();
218  if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(4) > 7 &&
219  m_TrackCands[1]->address(4) < 10)
220  m_TrackCands[1]->reset();
221 
222  if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(2) > 7 &&
223  m_TracKCands[1]->address(2) < 10)
224  m_TracKCands[1]->reset();
225  if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(3) > 7 &&
226  m_TracKCands[1]->address(3) < 10)
227  m_TracKCands[1]->reset();
228  if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(4) > 7 &&
229  m_TracKCands[1]->address(4) < 10)
230  m_TracKCands[1]->reset();
231  }
232 }
233 
234 //
235 // reset Sector Processor
236 //
238  if (m_SectorReceiver)
240  if (m_DataBuffer)
241  m_DataBuffer->reset();
242  if (m_EU)
243  m_EU->reset();
244  if (m_TA)
245  m_TA->reset();
246  if (m_AUs[0])
247  m_AUs[0]->reset();
248  if (m_AUs[1])
249  m_AUs[1]->reset();
250  if (m_TrackCands[0])
251  m_TrackCands[0]->reset();
252  if (m_TrackCands[1])
253  m_TrackCands[1]->reset();
254  if (m_TracKCands[0])
255  m_TracKCands[0]->reset();
256  if (m_TracKCands[1])
257  m_TracKCands[1]->reset();
258 }
259 
260 //
261 // print candidates found in Sector Processor
262 //
264  if (anyTrack()) {
265  cout << "Muon candidates found in " << m_spid << " : " << endl;
266  vector<L1MuBMTrack*>::const_iterator iter = m_TrackCands.begin();
267  while (iter != m_TrackCands.end()) {
268  if (*iter)
269  (*iter)->print();
270  iter++;
271  }
272  }
273 }
274 
275 //
276 // return pointer to nextWheel neighbour
277 //
279  int sector = m_spid.sector();
280  int wheel = m_spid.wheel();
281 
282  // the neighbour is in the same wedge with the following definition:
283  // current SP -3 -2 -1 +1 +2 +3
284  // neighbour -2 -1 +1 0 +1 +2
285 
286  if (wheel == 1)
287  return nullptr;
288  wheel = (wheel == -1) ? 1 : (wheel / abs(wheel)) * (abs(wheel) - 1);
289 
290  const L1MuBMSecProcId id(wheel, sector);
291 
292  return m_tf.sp(id);
293 }
294 
295 //
296 // are there any muon candidates?
297 //
299  if (m_TrackCands[0] && !m_TrackCands[0]->empty())
300  return true;
301  if (m_TrackCands[1] && !m_TrackCands[1]->empty())
302  return true;
303 
304  return false;
305 }
const L1MuBMSectorProcessor * sp(const L1MuBMSecProcId &) const
get a pointer to a Sector Processor
const L1MuBMSecProcId & id() const
return Sector Processor identifier
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
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?
int wheel() const
return wheel number
virtual ~L1MuBMSectorProcessor()
destructor
void run()
run Track Assembler
const L1MuBMSectorProcessor * neighbour() const
return pointer to the next wheel neighbour
std::vector< L1MuBMTrack * > m_TracKCands
const edm::ESGetToken< L1TMuonBarrelParams, L1TMuonBarrelParamsRcd > m_bmtfParamsToken
int numberTSphi() const
return number of non-empty phi track segments
void reset()
clear Data Buffer
void print() const
print muon candidates found by the Sector Processor
std::vector< L1MuBMTrack * > m_TrackCands
void reset()
reset Extrapolation Unit
const L1MuBMTrackFinder & m_tf
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int sector() const
return sector number
void reset()
reset Track Assembler
void print() const
print result of Track Assembler
L1MuBMSectorProcessor(const L1MuBMTrackFinder &, const L1MuBMSecProcId &, edm::ConsumesCollector &&)
constructor
static bool Debug()
void reset()
clear Sector Receiver
L1MuBMSectorReceiver * m_SectorReceiver
L1MuBMTrackAssembler * m_TA
int numberOfExt() const
return number of successful extrapolations
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
bool isEmpty(int id) const
is it a valid Track Class?
void print(int level=0) const
print all successful extrapolations
void printTSphi() const
print all phi track segments which are in the buffer
virtual void reset()
reset the Sector Processor
void run(const edm::EventSetup &c)
run Extrapolation Unit
def move(src, dest)
Definition: eostools.py:511