test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1MuDTTrack.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuDTTrack
4 //
5 // Description: Muon Track Candidate
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 <iomanip>
27 
28 //-------------------------------
29 // Collaborating Class Headers --
30 //-------------------------------
31 
38 
39 using namespace std;
40 
41 // --------------------------------
42 // class L1MuDTTrack
43 //---------------------------------
44 
45 //----------------
46 // Constructors --
47 //----------------
49  L1MuRegionalCand(0,0),
50  m_spid(L1MuDTSecProcId()), m_name("L1MuDTTrack"), m_empty(true),
51  m_tc(UNDEF),
52  m_addArray(), m_tsphiList(), m_tsetaList() {
53 
54  m_tsphiList.reserve(4);
55  m_tsetaList.reserve(3);
56 
57  setType(0);
58  setChargeValid(true);
59 
60 }
61 
62 
64  L1MuRegionalCand(0,0),
65  m_spid(spid), m_name("L1MuDTTrack"), m_empty(true),
66  m_tc(UNDEF),
67  m_addArray(), m_tsphiList(), m_tsetaList() {
68 
69  m_tsphiList.reserve(4);
70  m_tsetaList.reserve(3);
71 
72  setType(0);
73  setChargeValid(true);
74 
75 }
76 
77 
79  L1MuRegionalCand(id),
80  m_spid(id.m_spid), m_name(id.m_name), m_empty(id.m_empty),
81  m_tc(id.m_tc),
82  m_addArray(id.m_addArray),
83  m_tsphiList(id.m_tsphiList), m_tsetaList(id.m_tsetaList) {}
84 
85 
86 //--------------
87 // Destructor --
88 //--------------
90 
91 
92 //--------------
93 // Operations --
94 //--------------
95 
96 //
97 // reset Muon Track Candidate
98 //
100 
102  m_empty = true;
103  m_tc = UNDEF;
104  m_addArray.reset();
105  m_tsphiList.clear();
106  m_tsetaList.clear();
107 
108 }
109 
110 
111 //
112 // set (packed) eta-code of muon candidate
113 //
115 
116  // eta is a signed integer [-32,31],
117  // representing 64 bins in an interval [-1.2,+1.2]
118  // first convert eta into an unsigned integer
120  setEtaPacked(pEta.packedFromIdx(eta));
121 
122 }
123 
124 
125 //
126 // return start phi track segment
127 //
129 
130  return m_tsphiList.front();
131 
132 }
133 
134 
135 //
136 // return end phi track segment
137 //
139 
140  return m_tsphiList.back();
141 
142 }
143 
144 
145 //
146 // return start eta track segment
147 //
149 
150  return m_tsetaList.front();
151 
152 }
153 
154 
155 //
156 // return end eta track segment
157 //
159 
160  return m_tsetaList.back();
161 
162 }
163 
164 
165 //
166 // set phi track segments used to form the muon candidate
167 //
168 void L1MuDTTrack::setTSphi(const vector<const L1MuDTTrackSegPhi*>& tsList) {
169 
170  if ( !tsList.empty() ) {
171  vector<const L1MuDTTrackSegPhi*>::const_iterator iter;
172  for ( iter = tsList.begin(); iter != tsList.end(); iter++ ) {
173  if ( *iter ) m_tsphiList.push_back(**iter);
174  }
175  }
176 
177 }
178 
179 
180 //
181 // set eta track segments used to form the muon candidate
182 //
183 void L1MuDTTrack::setTSeta(const vector<const L1MuDTTrackSegEta*>& tsList) {
184 
185  if ( !tsList.empty() ) {
186  vector<const L1MuDTTrackSegEta*>::const_iterator iter;
187  for ( iter = tsList.begin(); iter != tsList.end(); iter++ ) {
188  if ( *iter ) m_tsetaList.push_back(**iter);
189  }
190  }
191 
192 }
193 
194 
195 //
196 // convert pt value in GeV to pt code
197 //
198 unsigned int L1MuDTTrack::triggerScale(float value, const edm::EventSetup& c) const {
199 
200  const float eps = 1.e-5; // add an epsilon so that setting works with low edge value
201 
202  edm::ESHandle< L1MuTriggerPtScale > theTriggerScales;
203  c.get< L1MuTriggerPtScaleRcd >().get( theTriggerScales );
204  unsigned int t_Scale = theTriggerScales->getPtScale()->getPacked( value + eps );
205 
206  return t_Scale;
207 }
208 
209 
210 //
211 // Assignment operator
212 //
214 
215  if ( this != &track ) {
216  this->setBx(track.bx());
217  this->setDataWord(track.getDataWord());
218  m_spid = track.m_spid;
219  m_empty = track.m_empty;
220  m_name = track.m_name;
221  m_tc = track.m_tc;
222  m_addArray = track.m_addArray;
223  m_tsphiList = track.m_tsphiList;
224  m_tsetaList = track.m_tsetaList;
225  }
226  return *this;
227 
228 }
229 
230 
231 //
232 // Equal operator
233 //
234 bool L1MuDTTrack::operator==(const L1MuDTTrack& track) const {
235 
236  if ( m_spid != track.m_spid ) return false;
237  if ( m_empty != track.m_empty ) return false;
238  if ( m_tc != track.m_tc ) return false;
239  if ( bx() != track.bx() ) return false;
240  if ( phi() != track.phi() ) return false;
241  if ( eta() != track.eta() ) return false;
242  if ( fineEtaBit() != track.fineEtaBit() ) return false;
243  if ( pt() != track.pt() ) return false;
244  if ( charge() != track.charge() ) return false;
245  if ( quality() != track.quality() ) return false;
246  if ( m_addArray != track.m_addArray ) return false;
247  return true;
248 
249 }
250 
251 
252 //
253 // Unequal operator
254 //
255 bool L1MuDTTrack::operator!=(const L1MuDTTrack& track) const {
256 
257  if ( m_spid != track.m_spid ) return true;
258  if ( m_empty != track.m_empty ) return true;
259  if ( m_tc != track.m_tc ) return true;
260  if ( bx() != track.bx() ) return true;
261  if ( phi() != track.phi() ) return true;
262  if ( eta() != track.eta() ) return true;
263  if ( fineEtaBit() != track.fineEtaBit() ) return true;
264  if ( pt() != track.pt() ) return true;
265  if ( charge() != track.charge() ) return true;
266  if ( quality() != track.quality() ) return true;
267  if ( m_addArray != track.m_addArray ) return true;
268  return false;
269 
270 }
271 
272 
273 //
274 // print parameters of track candidate
275 //
276 void L1MuDTTrack::print() const {
277 
278  if ( !empty() ) {
279  cout.setf(ios::showpoint);
280  cout.setf(ios::right,ios::adjustfield);
281  cout << setiosflags(ios::showpoint | ios::fixed);
282  cout << "MUON : "
283  << "pt = " << setw(2) << pt_packed() << " "
284  << "charge = " << setw(2) << charge_packed() << " "
285  << "eta = " << setw(2) << eta_packed()
286  << " (" << setw(1) << finehalo_packed() << ") "
287  << "phi = " << setw(3) << phi_packed() << " "
288  << "quality = " << setw(1) << quality_packed() << '\t'
289  << "class = " << tc() << " "
290  << "bx = " << setw(2) << bx() << endl;
291  cout << " found in " << m_spid << " with phi track segments :" << endl;
292  vector<L1MuDTTrackSegPhi>::const_iterator iter;
293  for ( iter = m_tsphiList.begin(); iter != m_tsphiList.end(); iter++ ) {
294  cout << " " << (*iter) << endl;
295  }
296  }
297 
298 }
299 
300 
301 //
302 // output stream operator for track candidate
303 //
304 ostream& operator<<(ostream& s, const L1MuDTTrack& id) {
305 
306  if ( !id.empty() ) {
307  s << setiosflags(ios::showpoint | ios::fixed)
308  << "pt = " << setw(2) << id.pt_packed() << " "
309  << "charge = " << setw(2) << id.charge_packed() << " "
310  << "eta = " << setw(2) << id.eta_packed()
311  << " (" << setw(1) << id.finehalo_packed() << ") "
312  << "phi = " << setw(3) << id.phi_packed() << " "
313  << "quality = " << setw(1) << id.quality_packed() << '\t'
314  << "bx = " << setw(2) << id.bx();
315  }
316  return s;
317 
318 }
std::vector< L1MuDTTrackSegEta > m_tsetaList
Definition: L1MuDTTrack.h:204
L1MuDTAddressArray m_addArray
Definition: L1MuDTTrack.h:202
int charge() const
get charge (1 bit)
Definition: L1MuDTTrack.h:84
const L1MuDTTrackSegPhi & getEndTSphi() const
return end phi track segment of muon candidate
Definition: L1MuDTTrack.cc:138
virtual unsigned packedFromIdx(int idx) const
get the packed notation of a value, check range
Definition: L1MuPacking.h:102
bool operator!=(const L1MuDTTrack &) const
unequal operator
Definition: L1MuDTTrack.cc:255
TrackClass tc() const
get track-class
Definition: L1MuDTTrack.h:87
void reset()
reset address array
unsigned charge_packed() const
return charge packed as in hardware (0=pos, 1=neg)
void setTSphi(const std::vector< const L1MuDTTrackSegPhi * > &tsList)
set phi track segments used to form the muon candidate
Definition: L1MuDTTrack.cc:168
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
unsigned int eta() const
get eta-code (6 bits)
Definition: L1MuDTTrack.h:78
const L1MuDTTrackSegEta & getStartTSeta() const
return start eta track segment of muon candidate
Definition: L1MuDTTrack.cc:148
unsigned int phi() const
get phi-code (8 bits)
Definition: L1MuDTTrack.h:75
std::string m_name
Definition: L1MuDTTrack.h:198
L1MuDTTrack & operator=(const L1MuDTTrack &)
assignment operator
Definition: L1MuDTTrack.cc:213
void setEta(int eta)
set eta-code of muon candidate
Definition: L1MuDTTrack.cc:114
void setBx(int bx)
Set Bunch Crossing.
void setTSeta(const std::vector< const L1MuDTTrackSegEta * > &tsList)
set eta track segments used to form the muon candidate
Definition: L1MuDTTrack.cc:183
const L1MuDTTrackSegPhi & getStartTSphi() const
return start phi track segment of muon candidate
Definition: L1MuDTTrack.cc:128
void setDataWord(unsigned dataword)
Set data word.
void print() const
print parameters of muon candidate
Definition: L1MuDTTrack.cc:276
unsigned getDataWord() const
return data word
unsigned eta_packed() const
return eta packed as in hardware
bool empty() const
is it an empty muon candidate?
Definition: L1MuDTTrack.h:90
void setType(unsigned type)
Set Type: 0 DT, 1 bRPC, 2 CSC, 3 fRPC.
std::vector< L1MuDTTrackSegPhi > m_tsphiList
Definition: L1MuDTTrack.h:203
virtual ~L1MuDTTrack()
destructor
Definition: L1MuDTTrack.cc:89
unsigned finehalo_packed() const
return eta-fine (for DT) / halo (for CSC) bit
void reset()
reset muon candidate
Definition: L1MuDTTrack.cc:99
unsigned int pt() const
get pt-code (5 bits)
Definition: L1MuDTTrack.h:72
unsigned int triggerScale(float value, const edm::EventSetup &c) const
convert pt value in GeV to pt code
Definition: L1MuDTTrack.cc:198
L1MuDTTrack()
default constructor
Definition: L1MuDTTrack.cc:48
const T & get() const
Definition: EventSetup.h:56
unsigned int quality() const
return quality
unsigned int quality_packed() const
return quality packed as in hardware
int bx() const
return bunch crossing identifier
void setEtaPacked(unsigned eta)
Set Eta: 6-bit code.
bool operator==(const L1MuDTTrack &) const
equal operator
Definition: L1MuDTTrack.cc:234
virtual void reset()
reset
const L1MuDTTrackSegEta & getEndTSeta() const
return end eta track segment of muon candidate
Definition: L1MuDTTrack.cc:158
tuple cout
Definition: gather_cfg.py:145
void setChargeValid(bool valid)
Set Charge Valid.
TrackClass m_tc
Definition: L1MuDTTrack.h:200
unsigned pt_packed() const
return pt packed as in hardware
bool fineEtaBit() const
get fine eta bit
Definition: L1MuDTTrack.h:81
unsigned phi_packed() const
return phi packed as in hardware
L1MuDTSecProcId m_spid
Definition: L1MuDTTrack.h:197