CMS 3D CMS Logo

L1MuDTSectorProcessor.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuDTSectorProcessor
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 
20 
21 //---------------
22 // C++ Headers --
23 //---------------
24 
25 #include <iostream>
26 #include <cmath>
27 
28 //-------------------------------
29 // Collaborating Class Headers --
30 //-------------------------------
31 
42 
43 using namespace std;
44 
45 // --------------------------------
46 // class L1MuDTSectorProcessor
47 //---------------------------------
48 
49 //----------------
50 // Constructors --
51 //----------------
52 
54  const L1MuDTSecProcId& id,
56  : m_tf(tf),
57  m_spid(id),
58  m_SectorReceiver(new L1MuDTSectorReceiver(*this, std::move(iC))),
59  m_DataBuffer(new L1MuDTDataBuffer(*this)),
60  m_EU(new L1MuDTExtrapolationUnit(*this)),
61  m_TA(new L1MuDTTrackAssembler(*this)),
62  m_AUs(),
63  m_TrackCands(),
64  m_TracKCands() {
65  // 2 assignment units
66  m_AUs.reserve(2);
67  m_AUs.push_back(new L1MuDTAssignmentUnit(*this, 0));
68  m_AUs.push_back(new L1MuDTAssignmentUnit(*this, 1));
69 
70  // now the 2 track candidates
71  m_TrackCands.reserve(2);
72  m_TrackCands.push_back(new L1MuDTTrack(m_spid));
73  m_TrackCands.push_back(new L1MuDTTrack(m_spid));
74 
75  m_TracKCands.reserve(2);
76  m_TracKCands.push_back(new L1MuDTTrack(m_spid));
77  m_TracKCands.push_back(new L1MuDTTrack(m_spid));
78 }
79 
80 //--------------
81 // Destructor --
82 //--------------
83 
85  delete m_SectorReceiver;
86  delete m_DataBuffer;
87  delete m_EU;
88  delete m_TA;
89  delete m_AUs[0];
90  delete m_AUs[1];
91  delete m_TrackCands[0];
92  delete m_TrackCands[1];
93  delete m_TracKCands[0];
94  delete m_TracKCands[1];
95 }
96 
97 //--------------
98 // Operations --
99 //--------------
100 
101 //
102 // run Sector Processor
103 //
105  // receive data and store them into the data buffer
106  if (m_SectorReceiver)
107  m_SectorReceiver->run(bx, e, c);
108 
109  // check content of data buffer
110  if (m_DataBuffer) {
111  if (m_tf.config()->Debug(4) && m_DataBuffer->numberTSphi() > 0) {
112  cout << "Phi track segments received by " << m_spid << " : " << endl;
114  }
115  }
116 
117  // perform all extrapolations
118  int n_ext = 0; // number of successful extrapolations
119  if (m_EU && m_DataBuffer && m_DataBuffer->numberTSphi() > 1) {
120  m_EU->run(c);
121  n_ext = m_EU->numberOfExt();
122  if (m_tf.config()->Debug(3) && n_ext > 0) {
123  cout << "Number of successful extrapolations : " << n_ext << endl;
124  m_EU->print();
125  }
126  }
127 
128  // hardware debug (output from Extrapolator and Quality Sorter)
129  // m_EU->print(1);
130 
131  // perform track assembling
132  if (m_TA && n_ext > 0) {
133  m_TA->run();
134  if (m_tf.config()->Debug(3))
135  m_TA->print();
136  }
137 
138  // assign pt, eta, phi and quality
139  if (m_AUs[0] && !m_TA->isEmpty(0))
140  m_AUs[0]->run(c);
141  if (m_AUs[1] && !m_TA->isEmpty(1))
142  m_AUs[1]->run(c);
143 
144  if (m_spid.wheel() == -1) {
145  if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(2) > 3 &&
146  m_TrackCands[0]->address(2) < 6)
147  m_TrackCands[0]->reset();
148  if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(3) > 3 &&
149  m_TrackCands[0]->address(3) < 6)
150  m_TrackCands[0]->reset();
151  if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(4) > 3 &&
152  m_TrackCands[0]->address(4) < 6)
153  m_TrackCands[0]->reset();
154 
155  if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(2) > 3 &&
156  m_TracKCands[0]->address(2) < 6)
157  m_TracKCands[0]->reset();
158  if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(3) > 3 &&
159  m_TracKCands[0]->address(3) < 6)
160  m_TracKCands[0]->reset();
161  if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(4) > 3 &&
162  m_TracKCands[0]->address(4) < 6)
163  m_TracKCands[0]->reset();
164 
165  if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(2) > 3 &&
166  m_TrackCands[1]->address(2) < 6)
167  m_TrackCands[1]->reset();
168  if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(3) > 3 &&
169  m_TrackCands[1]->address(3) < 6)
170  m_TrackCands[1]->reset();
171  if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(4) > 3 &&
172  m_TrackCands[1]->address(4) < 6)
173  m_TrackCands[1]->reset();
174 
175  if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(2) > 3 &&
176  m_TracKCands[1]->address(2) < 6)
177  m_TracKCands[1]->reset();
178  if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(3) > 3 &&
179  m_TracKCands[1]->address(3) < 6)
180  m_TracKCands[1]->reset();
181  if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(4) > 3 &&
182  m_TracKCands[1]->address(4) < 6)
183  m_TracKCands[1]->reset();
184 
185  if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(2) > 7 &&
186  m_TrackCands[0]->address(2) < 10)
187  m_TrackCands[0]->reset();
188  if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(3) > 7 &&
189  m_TrackCands[0]->address(3) < 10)
190  m_TrackCands[0]->reset();
191  if (m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(4) > 7 &&
192  m_TrackCands[0]->address(4) < 10)
193  m_TrackCands[0]->reset();
194 
195  if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(2) > 7 &&
196  m_TracKCands[0]->address(2) < 10)
197  m_TracKCands[0]->reset();
198  if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(3) > 7 &&
199  m_TracKCands[0]->address(3) < 10)
200  m_TracKCands[0]->reset();
201  if (m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(4) > 7 &&
202  m_TracKCands[0]->address(4) < 10)
203  m_TracKCands[0]->reset();
204 
205  if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(2) > 7 &&
206  m_TrackCands[1]->address(2) < 10)
207  m_TrackCands[1]->reset();
208  if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(3) > 7 &&
209  m_TrackCands[1]->address(3) < 10)
210  m_TrackCands[1]->reset();
211  if (m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(4) > 7 &&
212  m_TrackCands[1]->address(4) < 10)
213  m_TrackCands[1]->reset();
214 
215  if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(2) > 7 &&
216  m_TracKCands[1]->address(2) < 10)
217  m_TracKCands[1]->reset();
218  if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(3) > 7 &&
219  m_TracKCands[1]->address(3) < 10)
220  m_TracKCands[1]->reset();
221  if (m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(4) > 7 &&
222  m_TracKCands[1]->address(4) < 10)
223  m_TracKCands[1]->reset();
224  }
225 }
226 
227 //
228 // reset Sector Processor
229 //
231  if (m_SectorReceiver)
233  if (m_DataBuffer)
234  m_DataBuffer->reset();
235  if (m_EU)
236  m_EU->reset();
237  if (m_TA)
238  m_TA->reset();
239  if (m_AUs[0])
240  m_AUs[0]->reset();
241  if (m_AUs[1])
242  m_AUs[1]->reset();
243  if (m_TrackCands[0])
244  m_TrackCands[0]->reset();
245  if (m_TrackCands[1])
246  m_TrackCands[1]->reset();
247  if (m_TracKCands[0])
248  m_TracKCands[0]->reset();
249  if (m_TracKCands[1])
250  m_TracKCands[1]->reset();
251 }
252 
253 //
254 // print candidates found in Sector Processor
255 //
257  if (anyTrack()) {
258  cout << "Muon candidates found in " << m_spid << " : " << endl;
259  vector<L1MuDTTrack*>::const_iterator iter = m_TrackCands.begin();
260  while (iter != m_TrackCands.end()) {
261  if (*iter)
262  (*iter)->print();
263  iter++;
264  }
265  }
266 }
267 
268 //
269 // return pointer to nextWheel neighbour
270 //
272  int sector = m_spid.sector();
273  int wheel = m_spid.wheel();
274 
275  // the neighbour is in the same wedge with the following definition:
276  // current SP -3 -2 -1 +1 +2 +3
277  // neighbour -2 -1 +1 0 +1 +2
278 
279  if (wheel == 1)
280  return nullptr;
281  wheel = (wheel == -1) ? 1 : (wheel / abs(wheel)) * (abs(wheel) - 1);
282 
283  const L1MuDTSecProcId id(wheel, sector);
284 
285  return m_tf.sp(id);
286 }
287 
288 //
289 // are there any muon candidates?
290 //
292  if (m_TrackCands[0] && !m_TrackCands[0]->empty())
293  return true;
294  if (m_TrackCands[1] && !m_TrackCands[1]->empty())
295  return true;
296 
297  return false;
298 }
void reset() override
reset Extrapolation Unit
void printTSphi() const
print all phi track segments which are in the buffer
void reset()
clear Sector Receiver
L1MuDTSectorReceiver * m_SectorReceiver
const L1MuDTSectorProcessor * neighbour() const
return pointer to the next wheel neighbour
const L1MuDTSectorProcessor * sp(const L1MuDTSecProcId &) const
get a pointer to a Sector Processor
std::vector< L1MuDTAssignmentUnit * > m_AUs
void print() const
print result of Track Assembler
bool anyTrack() const
are there any non-empty muon candidates?
void print(int level=0) const
print all successful extrapolations
virtual void reset()
reset the Sector Processor
void run(const edm::EventSetup &c) override
run Extrapolation Unit
int sector() const
return sector number
void reset()
clear Data Buffer
std::vector< L1MuDTTrack * > m_TracKCands
L1MuDTExtrapolationUnit * m_EU
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static bool Debug()
L1MuDTSectorProcessor(const L1MuDTTrackFinder &, const L1MuDTSecProcId &, edm::ConsumesCollector &&)
constructor
const L1MuDTSecProcId & id() const
return Sector Processor identifier
void print() const
print muon candidates found by the Sector Processor
void run() override
run Track Assembler
static L1MuDTTFConfig * config()
return configuration
virtual void run(int bx, const edm::Event &e, const edm::EventSetup &c)
run the Sector Processor
int numberTSphi() const
return number of non-empty phi track segments
bool isEmpty(int id) const
is it a valid Track Class?
int numberOfExt() const
return number of successful extrapolations
L1MuDTDataBuffer * m_DataBuffer
void run(int bx, const edm::Event &e, const edm::EventSetup &c)
receive track segment data from the DTBX and CSC chamber triggers
int wheel() const
return wheel number
L1MuDTTrackAssembler * m_TA
const L1MuDTTrackFinder & m_tf
void reset() override
reset Track Assembler
def move(src, dest)
Definition: eostools.py:511
virtual ~L1MuDTSectorProcessor()
destructor
std::vector< L1MuDTTrack * > m_TrackCands