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 //
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) :
55  m_tf(tf), m_spid(id),
56  m_SectorReceiver(new L1MuDTSectorReceiver(*this)),
57  m_DataBuffer(new L1MuDTDataBuffer(*this)),
58  m_EU(new L1MuDTExtrapolationUnit(*this)),
59  m_TA(new L1MuDTTrackAssembler(*this)),
60  m_AUs(), m_TrackCands(), m_TracKCands() {
61 
62  // 2 assignment units
63  m_AUs.reserve(2);
64  m_AUs.push_back(new L1MuDTAssignmentUnit(*this,0));
65  m_AUs.push_back(new L1MuDTAssignmentUnit(*this,1));
66 
67  // now the 2 track candidates
68  m_TrackCands.reserve(2);
69  m_TrackCands.push_back(new L1MuDTTrack(m_spid) );
70  m_TrackCands.push_back(new L1MuDTTrack(m_spid) );
71 
72  m_TracKCands.reserve(2);
73  m_TracKCands.push_back(new L1MuDTTrack(m_spid) );
74  m_TracKCands.push_back(new L1MuDTTrack(m_spid) );
75 
76 }
77 
78 
79 //--------------
80 // Destructor --
81 //--------------
82 
84 
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 //--------------
99 // Operations --
100 //--------------
101 
102 //
103 // run Sector Processor
104 //
106 
107  // receive data and store them into the data buffer
108  if ( m_SectorReceiver ) m_SectorReceiver->run(bx, e, c);
109 
110  // check content of data buffer
111  if ( m_DataBuffer ) {
112  if ( L1MuDTTFConfig::Debug(4) && m_DataBuffer->numberTSphi() > 0 ) {
113  cout << "Phi track segments received by " << m_spid << " : " << endl;
115  }
116  }
117 
118  // perform all extrapolations
119  int n_ext = 0; // number of successful extrapolations
120  if ( m_EU && m_DataBuffer && m_DataBuffer->numberTSphi() > 1 ) {
121  m_EU->run(c);
122  n_ext = m_EU->numberOfExt();
123  if ( L1MuDTTFConfig::Debug(3) && n_ext > 0 ) {
124  cout << "Number of successful extrapolations : " << n_ext << endl;
125  m_EU->print();
126  }
127  }
128 
129  // hardware debug (output from Extrapolator and Quality Sorter)
130  // m_EU->print(1);
131 
132  // perform track assembling
133  if ( m_TA && n_ext > 0 ) {
134  m_TA->run();
135  if ( L1MuDTTFConfig::Debug(3) ) m_TA->print();
136  }
137 
138  // assign pt, eta, phi and quality
139  if ( m_AUs[0] && !m_TA->isEmpty(0) ) m_AUs[0]->run(c);
140  if ( m_AUs[1] && !m_TA->isEmpty(1) ) m_AUs[1]->run(c);
141 
142  if ( m_spid.wheel() == -1 ) {
143  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(2)>3 && m_TrackCands[0]->address(2)<6 ) m_TrackCands[0]->reset();
144  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(3)>3 && m_TrackCands[0]->address(3)<6 ) m_TrackCands[0]->reset();
145  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(4)>3 && m_TrackCands[0]->address(4)<6 ) m_TrackCands[0]->reset();
146 
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[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(2)>3 && m_TrackCands[1]->address(2)<6 ) m_TrackCands[1]->reset();
152  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(3)>3 && m_TrackCands[1]->address(3)<6 ) m_TrackCands[1]->reset();
153  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(4)>3 && m_TrackCands[1]->address(4)<6 ) m_TrackCands[1]->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[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(2)>7 && m_TrackCands[0]->address(2)<10 ) m_TrackCands[0]->reset();
160  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(3)>7 && m_TrackCands[0]->address(3)<10 ) m_TrackCands[0]->reset();
161  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() && m_TrackCands[0]->address(4)>7 && m_TrackCands[0]->address(4)<10 ) m_TrackCands[0]->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[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(2)>7 && m_TrackCands[1]->address(2)<10 ) m_TrackCands[1]->reset();
168  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(3)>7 && m_TrackCands[1]->address(3)<10 ) m_TrackCands[1]->reset();
169  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() && m_TrackCands[1]->address(4)>7 && m_TrackCands[1]->address(4)<10 ) m_TrackCands[1]->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 
176 }
177 
178 
179 //
180 // reset Sector Processor
181 //
183 
185  if ( m_DataBuffer ) m_DataBuffer->reset();
186  if ( m_EU ) m_EU->reset();
187  if ( m_TA ) m_TA->reset();
188  if ( m_AUs[0] ) m_AUs[0]->reset();
189  if ( m_AUs[1] ) m_AUs[1]->reset();
190  if ( m_TrackCands[0] ) m_TrackCands[0]->reset();
191  if ( m_TrackCands[1] ) m_TrackCands[1]->reset();
192  if ( m_TracKCands[0] ) m_TracKCands[0]->reset();
193  if ( m_TracKCands[1] ) m_TracKCands[1]->reset();
194 
195 }
196 
197 
198 //
199 // print candidates found in Sector Processor
200 //
202 
203  if ( anyTrack() ) {
204  cout << "Muon candidates found in " << m_spid << " : " << endl;
205  vector<L1MuDTTrack*>::const_iterator iter = m_TrackCands.begin();
206  while ( iter != m_TrackCands.end() ) {
207  if ( *iter) (*iter)->print();
208  iter++;
209  }
210  }
211 
212 }
213 
214 
215 //
216 // return pointer to nextWheel neighbour
217 //
219 
220  int sector = m_spid.sector();
221  int wheel = m_spid.wheel();
222 
223  // the neighbour is in the same wedge with the following definition:
224  // current SP -3 -2 -1 +1 +2 +3
225  // neighbour -2 -1 +1 0 +1 +2
226 
227  if ( wheel == 1) return 0;
228  wheel = (wheel == -1) ? 1 : (wheel/abs(wheel)) * (abs(wheel)-1);
229 
230  const L1MuDTSecProcId id(wheel,sector);
231 
232  return m_tf.sp(id);
233 
234 }
235 
236 
237 //
238 // are there any muon candidates?
239 //
241 
242  if ( m_TrackCands[0] && !m_TrackCands[0]->empty() ) return true;
243  if ( m_TrackCands[1] && !m_TrackCands[1]->empty() ) return true;
244 
245  return false;
246 
247 }
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
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
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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