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