CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
42 
43 using namespace std;
44 
45 // --------------------------------
46 // class L1MuBMSectorProcessor
47 //---------------------------------
48 
49 //----------------
50 // Constructors --
51 //----------------
52 
54  const L1MuBMSecProcId& id,
56 
57  m_tf(tf), m_spid(id),
58  m_SectorReceiver(new L1MuBMSectorReceiver(*this, std::move(iC))),
59  m_DataBuffer(new L1MuBMDataBuffer(*this)),
60  m_EU(new L1MuBMExtrapolationUnit(*this)),
61  m_TA(new L1MuBMTrackAssembler(*this)),
62  m_AUs(), m_TrackCands(), m_TracKCands() {
63 
64  // 2 assignment units
65  m_AUs.reserve(2);
66  m_AUs.push_back(new L1MuBMAssignmentUnit(*this,0));
67  m_AUs.push_back(new L1MuBMAssignmentUnit(*this,1));
68 
69  // now the 2 track candidates
70  m_TrackCands.reserve(2);
71  m_TrackCands.push_back(new L1MuBMTrack(m_spid) );
72  m_TrackCands.push_back(new L1MuBMTrack(m_spid) );
73 
74  m_TracKCands.reserve(2);
75  m_TracKCands.push_back(new L1MuBMTrack(m_spid) );
76  m_TracKCands.push_back(new L1MuBMTrack(m_spid) );
77 
78 }
79 
80 
81 //--------------
82 // Destructor --
83 //--------------
84 
86 
87  delete m_SectorReceiver;
88  delete m_DataBuffer;
89  delete m_EU;
90  delete m_TA;
91  delete m_AUs[0];
92  delete m_AUs[1];
93  delete m_TrackCands[0];
94  delete m_TrackCands[1];
95  delete m_TracKCands[0];
96  delete m_TracKCands[1];
97 
98 }
99 
100 //--------------
101 // Operations --
102 //--------------
103 
104 //
105 // run Sector Processor
106 //
108 
109  // receive data and store them into the data buffer
110  if ( m_SectorReceiver ) m_SectorReceiver->run(bx, e, c);
111 
112  // check content of data buffer
113  if ( m_DataBuffer ) {
114  if ( L1MuBMTFConfig::Debug(4) && m_DataBuffer->numberTSphi() > 0 ) {
115  cout << "Phi track segments received by " << m_spid << " : " << endl;
117  }
118  }
119 
120  // perform all extrapolations
121  int n_ext = 0; // number of successful extrapolations
122  if ( m_EU && m_DataBuffer && m_DataBuffer->numberTSphi() > 1 ) {
123  m_EU->run(c);
124  n_ext = m_EU->numberOfExt();
125  if ( L1MuBMTFConfig::Debug(3) && n_ext > 0 ) {
126 // if ( print_flag && n_ext > 0 ) {
127  cout << "Number of successful extrapolations : " << n_ext << endl;
128  m_EU->print();
129  }
130  }
131 
132  // hardware debug (output from Extrapolator and Quality Sorter)
133  // m_EU->print(1);
134 
135  // perform track assembling
136  if ( m_TA && n_ext > 0 ) {
137  m_TA->run();
138  if ( L1MuBMTFConfig::Debug(3) ) m_TA->print();
139  }
140 
141  // assign pt, eta, phi and quality
142  if ( m_AUs[0] && !m_TA->isEmpty(0) ) m_AUs[0]->run(c);
143  if ( m_AUs[1] && !m_TA->isEmpty(1) ) m_AUs[1]->run(c);
144 
145  if ( m_spid.wheel() == -1 ) {
146  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(2)>3 && m_TrackCands[0]->address(2)<6 ) m_TrackCands[0]->reset();
147  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(3)>3 && m_TrackCands[0]->address(3)<6 ) m_TrackCands[0]->reset();
148  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(4)>3 && m_TrackCands[0]->address(4)<6 ) m_TrackCands[0]->reset();
149 
150  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(2)>3 && m_TracKCands[0]->address(2)<6 ) m_TracKCands[0]->reset();
151  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(3)>3 && m_TracKCands[0]->address(3)<6 ) m_TracKCands[0]->reset();
152  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(4)>3 && m_TracKCands[0]->address(4)<6 ) m_TracKCands[0]->reset();
153 
154  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(2)>3 && m_TrackCands[1]->address(2)<6 ) m_TrackCands[1]->reset();
155  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(3)>3 && m_TrackCands[1]->address(3)<6 ) m_TrackCands[1]->reset();
156  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(4)>3 && m_TrackCands[1]->address(4)<6 ) m_TrackCands[1]->reset();
157 
158  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(2)>3 && m_TracKCands[1]->address(2)<6 ) m_TracKCands[1]->reset();
159  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(3)>3 && m_TracKCands[1]->address(3)<6 ) m_TracKCands[1]->reset();
160  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(4)>3 && m_TracKCands[1]->address(4)<6 ) m_TracKCands[1]->reset();
161 
162  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(2)>7 && m_TrackCands[0]->address(2)<10 ) m_TrackCands[0]->reset();
163  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(3)>7 && m_TrackCands[0]->address(3)<10 ) m_TrackCands[0]->reset();
164  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(4)>7 && m_TrackCands[0]->address(4)<10 ) m_TrackCands[0]->reset();
165 
166  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(2)>7 && m_TracKCands[0]->address(2)<10 ) m_TracKCands[0]->reset();
167  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(3)>7 && m_TracKCands[0]->address(3)<10 ) m_TracKCands[0]->reset();
168  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(4)>7 && m_TracKCands[0]->address(4)<10 ) m_TracKCands[0]->reset();
169 
170  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(2)>7 && m_TrackCands[1]->address(2)<10 ) m_TrackCands[1]->reset();
171  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(3)>7 && m_TrackCands[1]->address(3)<10 ) m_TrackCands[1]->reset();
172  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(4)>7 && m_TrackCands[1]->address(4)<10 ) m_TrackCands[1]->reset();
173 
174  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(2)>7 && m_TracKCands[1]->address(2)<10 ) m_TracKCands[1]->reset();
175  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(3)>7 && m_TracKCands[1]->address(3)<10 ) m_TracKCands[1]->reset();
176  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(4)>7 && m_TracKCands[1]->address(4)<10 ) m_TracKCands[1]->reset();
177  }
178 
179 }
180 
181 
182 //
183 // reset Sector Processor
184 //
186 
188  if ( m_DataBuffer ) m_DataBuffer->reset();
189  if ( m_EU ) m_EU->reset();
190  if ( m_TA ) m_TA->reset();
191  if ( m_AUs[0] ) m_AUs[0]->reset();
192  if ( m_AUs[1] ) m_AUs[1]->reset();
193  if ( m_TrackCands[0] ) m_TrackCands[0]->reset();
194  if ( m_TrackCands[1] ) m_TrackCands[1]->reset();
195  if ( m_TracKCands[0] ) m_TracKCands[0]->reset();
196  if ( m_TracKCands[1] ) m_TracKCands[1]->reset();
197 
198 }
199 
200 
201 //
202 // print candidates found in Sector Processor
203 //
205 
206  if ( anyTrack() ) {
207  cout << "Muon candidates found in " << m_spid << " : " << endl;
208  vector<L1MuBMTrack*>::const_iterator iter = m_TrackCands.begin();
209  while ( iter != m_TrackCands.end() ) {
210  if ( *iter) (*iter)->print();
211  iter++;
212  }
213  }
214 
215 }
216 
217 
218 //
219 // return pointer to nextWheel neighbour
220 //
222 
223  int sector = m_spid.sector();
224  int wheel = m_spid.wheel();
225 
226  // the neighbour is in the same wedge with the following definition:
227  // current SP -3 -2 -1 +1 +2 +3
228  // neighbour -2 -1 +1 0 +1 +2
229 
230  if ( wheel == 1) return 0;
231  wheel = (wheel == -1) ? 1 : (wheel/abs(wheel)) * (abs(wheel)-1);
232 
233  const L1MuBMSecProcId id(wheel,sector);
234 
235  return m_tf.sp(id);
236 
237 }
238 
239 
240 //
241 // are there any muon candidates?
242 //
244 
245  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() ) return true;
246  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() ) return true;
247 
248  return false;
249 
250 }
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
virtual void run()
run Track Assembler
std::vector< L1MuBMTrack * > m_TracKCands
int sector() const
return sector number
void reset()
clear Data Buffer
void print() const
print result of Track Assembler
std::vector< L1MuBMTrack * > m_TrackCands
virtual void reset()
reset Extrapolation Unit
def move
Definition: eostools.py:510
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
virtual void reset()
reset Track Assembler
L1MuBMSectorProcessor(const L1MuBMTrackFinder &, const L1MuBMSecProcId &, edm::ConsumesCollector &&)
constructor
bool isEmpty(int id) const
is it a valid Track Class?
static bool Debug()
void reset()
clear Sector Receiver
L1MuBMSectorReceiver * m_SectorReceiver
L1MuBMTrackAssembler * m_TA
L1MuBMDataBuffer * m_DataBuffer
std::vector< L1MuBMAssignmentUnit * > m_AUs
tuple cout
Definition: gather_cfg.py:145
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
virtual void run(const edm::EventSetup &c)
run Extrapolation Unit
int wheel() const
return wheel number