CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1MuDTSectorProcessor.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuDTSectorProcessor
4 //
5 // Description: Sector Processor
6 //
7 //
8 // $Date: 2010/06/28 14:35:29 $
9 // $Revision: 1.7 $
10 //
11 // Author :
12 // N. Neumeister CERN EP
13 // J. Troconiz UAM Madrid
14 //
15 //--------------------------------------------------
16 
17 //-----------------------
18 // This Class's Header --
19 //-----------------------
20 
22 
23 //---------------
24 // C++ Headers --
25 //---------------
26 
27 #include <iostream>
28 #include <cmath>
29 
30 //-------------------------------
31 // Collaborating Class Headers --
32 //-------------------------------
33 
44 
45 using namespace std;
46 
47 // --------------------------------
48 // class L1MuDTSectorProcessor
49 //---------------------------------
50 
51 //----------------
52 // Constructors --
53 //----------------
54 
56  const L1MuDTSecProcId& id) :
57  m_tf(tf), m_spid(id),
58  m_SectorReceiver(new L1MuDTSectorReceiver(*this)),
59  m_DataBuffer(new L1MuDTDataBuffer(*this)),
60  m_EU(new L1MuDTExtrapolationUnit(*this)),
61  m_TA(new L1MuDTTrackAssembler(*this)),
62  m_AUs(), m_TrackCands(), m_TracKCands() {
63 
64  // 2 assignment units
65  m_AUs.reserve(2);
66  m_AUs.push_back(new L1MuDTAssignmentUnit(*this,0));
67  m_AUs.push_back(new L1MuDTAssignmentUnit(*this,1));
68 
69  // now the 2 track candidates
70  m_TrackCands.reserve(2);
71  m_TrackCands.push_back(new L1MuDTTrack(m_spid) );
72  m_TrackCands.push_back(new L1MuDTTrack(m_spid) );
73 
74  m_TracKCands.reserve(2);
75  m_TracKCands.push_back(new L1MuDTTrack(m_spid) );
76  m_TracKCands.push_back(new L1MuDTTrack(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 ( L1MuDTTFConfig::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 ( L1MuDTTFConfig::Debug(3) && n_ext > 0 ) {
126  cout << "Number of successful extrapolations : " << n_ext << endl;
127  m_EU->print();
128  }
129  }
130 
131  // hardware debug (output from Extrapolator and Quality Sorter)
132  // m_EU->print(1);
133 
134  // perform track assembling
135  if ( m_TA && n_ext > 0 ) {
136  m_TA->run();
137  if ( L1MuDTTFConfig::Debug(3) ) m_TA->print();
138  }
139 
140  // assign pt, eta, phi and quality
141  if ( m_AUs[0] && !m_TA->isEmpty(0) ) m_AUs[0]->run(c);
142  if ( m_AUs[1] && !m_TA->isEmpty(1) ) 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 && m_TrackCands[0]->address(2)<6 ) m_TrackCands[0]->reset();
146  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(3)>3 && m_TrackCands[0]->address(3)<6 ) m_TrackCands[0]->reset();
147  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(4)>3 && m_TrackCands[0]->address(4)<6 ) m_TrackCands[0]->reset();
148 
149  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(2)>3 && m_TracKCands[0]->address(2)<6 ) m_TracKCands[0]->reset();
150  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(3)>3 && m_TracKCands[0]->address(3)<6 ) m_TracKCands[0]->reset();
151  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(4)>3 && m_TracKCands[0]->address(4)<6 ) m_TracKCands[0]->reset();
152 
153  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(2)>3 && m_TrackCands[1]->address(2)<6 ) m_TrackCands[1]->reset();
154  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(3)>3 && m_TrackCands[1]->address(3)<6 ) m_TrackCands[1]->reset();
155  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(4)>3 && m_TrackCands[1]->address(4)<6 ) m_TrackCands[1]->reset();
156 
157  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(2)>3 && m_TracKCands[1]->address(2)<6 ) m_TracKCands[1]->reset();
158  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(3)>3 && m_TracKCands[1]->address(3)<6 ) m_TracKCands[1]->reset();
159  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(4)>3 && m_TracKCands[1]->address(4)<6 ) m_TracKCands[1]->reset();
160 
161  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(2)>7 && m_TrackCands[0]->address(2)<10 ) m_TrackCands[0]->reset();
162  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(3)>7 && m_TrackCands[0]->address(3)<10 ) m_TrackCands[0]->reset();
163  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(4)>7 && m_TrackCands[0]->address(4)<10 ) m_TrackCands[0]->reset();
164 
165  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(2)>7 && m_TracKCands[0]->address(2)<10 ) m_TracKCands[0]->reset();
166  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(3)>7 && m_TracKCands[0]->address(3)<10 ) m_TracKCands[0]->reset();
167  if ( m_TracKCands[0] && !m_TracKCands[0]->empty() && m_TracKCands[0]->address(4)>7 && m_TracKCands[0]->address(4)<10 ) m_TracKCands[0]->reset();
168 
169  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(2)>7 && m_TrackCands[1]->address(2)<10 ) m_TrackCands[1]->reset();
170  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(3)>7 && m_TrackCands[1]->address(3)<10 ) m_TrackCands[1]->reset();
171  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(4)>7 && m_TrackCands[1]->address(4)<10 ) m_TrackCands[1]->reset();
172 
173  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(2)>7 && m_TracKCands[1]->address(2)<10 ) m_TracKCands[1]->reset();
174  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(3)>7 && m_TracKCands[1]->address(3)<10 ) m_TracKCands[1]->reset();
175  if ( m_TracKCands[1] && !m_TracKCands[1]->empty() && m_TracKCands[1]->address(4)>7 && m_TracKCands[1]->address(4)<10 ) m_TracKCands[1]->reset();
176  }
177 
178 }
179 
180 
181 //
182 // reset Sector Processor
183 //
185 
187  if ( m_DataBuffer ) m_DataBuffer->reset();
188  if ( m_EU ) m_EU->reset();
189  if ( m_TA ) m_TA->reset();
190  if ( m_AUs[0] ) m_AUs[0]->reset();
191  if ( m_AUs[1] ) m_AUs[1]->reset();
192  if ( m_TrackCands[0] ) m_TrackCands[0]->reset();
193  if ( m_TrackCands[1] ) m_TrackCands[1]->reset();
194  if ( m_TracKCands[0] ) m_TracKCands[0]->reset();
195  if ( m_TracKCands[1] ) m_TracKCands[1]->reset();
196 
197 }
198 
199 
200 //
201 // print candidates found in Sector Processor
202 //
204 
205  if ( anyTrack() ) {
206  cout << "Muon candidates found in " << m_spid << " : " << endl;
207  vector<L1MuDTTrack*>::const_iterator iter = m_TrackCands.begin();
208  while ( iter != m_TrackCands.end() ) {
209  if ( *iter) (*iter)->print();
210  iter++;
211  }
212  }
213 
214 }
215 
216 
217 //
218 // return pointer to nextWheel neighbour
219 //
221 
222  int sector = m_spid.sector();
223  int wheel = m_spid.wheel();
224 
225  // the neighbour is in the same wedge with the following definition:
226  // current SP -3 -2 -1 +1 +2 +3
227  // neighbour -2 -1 +1 0 +1 +2
228 
229  if ( wheel == 1) return 0;
230  wheel = (wheel == -1) ? 1 : (wheel/abs(wheel)) * (abs(wheel)-1);
231 
232  const L1MuDTSecProcId id(wheel,sector);
233 
234  return m_tf.sp(id);
235 
236 }
237 
238 
239 //
240 // are there any muon candidates?
241 //
243 
244  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() ) return true;
245  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() ) return true;
246 
247  return false;
248 
249 }
void printTSphi() const
print all phi track segments which are in the buffer
void reset()
clear Sector Receiver
virtual void reset()
reset Extrapolation Unit
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
#define abs(x)
Definition: mlp_lapack.h:159
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
int sector() const
return sector number
void reset()
clear Data Buffer
virtual void run()
run Track Assembler
std::vector< L1MuDTTrack * > m_TracKCands
L1MuDTExtrapolationUnit * m_EU
static bool Debug()
virtual void reset()
reset Track Assembler
const L1MuDTSecProcId & id() const
return Sector Processor identifier
void print() const
print muon candidates found by the Sector Processor
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
tuple cout
Definition: gather_cfg.py:121
L1MuDTTrackAssembler * m_TA
const L1MuDTTrackFinder & m_tf
L1MuDTSectorProcessor(const L1MuDTTrackFinder &, const L1MuDTSecProcId &)
constructor
virtual ~L1MuDTSectorProcessor()
destructor
std::vector< L1MuDTTrack * > m_TrackCands
virtual void run(const edm::EventSetup &c)
run Extrapolation Unit