CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1MuBMTrack.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuBMTrack
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 L1MuBMTrack
43 //---------------------------------
44 
45 //----------------
46 // Constructors --
47 //----------------
49  //L1MuRegionalCand(0,0),-->
50  l1t::RegionalMuonCand(),
51  m_spid(L1MuBMSecProcId()), m_name("L1MuBMTrack"), m_empty(true),
52  m_tc(UNDEF),
53  m_addArray(), m_tsphiList(), m_tsetaList() {
54 
55  m_tsphiList.reserve(4);
56  m_tsetaList.reserve(3);
57 
58  //setType(0);
59  //setChargeValid(true);
60  setHwSignValid(1);
61 
62 }
63 
64 
66  //L1MuRegionalCand(0,0),-->
67  l1t::RegionalMuonCand(),
68  m_spid(spid), m_name("L1MuBMTrack"), m_empty(true),
69  m_tc(UNDEF),
70  m_addArray(), m_tsphiList(), m_tsetaList() {
71 
72  m_tsphiList.reserve(4);
73  m_tsetaList.reserve(3);
74  //setType(0);
75  //setChargeValid(true);
76  setHwSignValid(1);
77 
78 }
79 
80 
82  //L1MuRegionalCand(id),-->
83  l1t::RegionalMuonCand(id),
84  m_spid(id.m_spid), m_name(id.m_name), m_empty(id.m_empty),
85  m_tc(id.m_tc),
86  m_addArray(id.m_addArray),
87  m_tsphiList(id.m_tsphiList), m_tsetaList(id.m_tsetaList) {}
88 
89 
90 //--------------
91 // Destructor --
92 //--------------
94 
95 
96 //--------------
97 // Operations --
98 //--------------
99 
100 //
101 // reset Muon Track Candidate
102 //
104 
105  //L1MuRegionalCand::reset();
106  m_empty = true;
107  m_tc = UNDEF;
108  m_addArray.reset();
109  m_tsphiList.clear();
110  m_tsetaList.clear();
111 
112 }
113 
114 
115 //
116 // set (packed) eta-code of muon candidate
117 //
119 
120  // eta is a signed integer [-115,118],
121  setHwEta(eta);
122 
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 L1MuBMTrack::setTSphi(const vector<const L1MuBMTrackSegPhi*>& tsList) {
171 
172  if ( !tsList.empty() ) {
173  vector<const L1MuBMTrackSegPhi*>::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 L1MuBMTrack::setTSeta(const vector<const L1MuBMTrackSegEta*>& tsList) {
186 
187  if ( !tsList.empty() ) {
188  vector<const L1MuBMTrackSegEta*>::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 L1MuBMTrack::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 //
236 bool L1MuBMTrack::operator==(const L1MuBMTrack& track) const {
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 //
257 bool L1MuBMTrack::operator!=(const L1MuBMTrack& track) const {
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 L1MuBMTrack::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(3) << hwPt() << " "
286  << "charge = " << setw(2) << hwSign() << " "
287  << "eta = " << setw(2) << hwEta()
288  //<< " (" << setw(1) << finehalo_packed() << ") "
289  << "phi = " << setw(3) << hwPhi() << " "
290  << "quality = " << setw(1) << hwQual() << '\t'
291  << "class = " << tc() << " "
292  << "bx = " << setw(2) << bx() << endl;
293  cout << " found in " << m_spid << " with phi track segments :" << endl;
294  vector<L1MuBMTrackSegPhi>::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 L1MuBMTrack& id) {
307 
308  if ( !id.empty() ) {
309  s << setiosflags(ios::showpoint | ios::fixed)
310  << "pt = " << setw(3) << id.hwPt() << " "
311  << "charge = " << setw(2) << id.hwSign() << " "
312  << "eta = " << setw(2) << id.hwEta()
313  //<< " (" << setw(1) << id.finehalo_packed() << ") "
314  << "phi = " << setw(3) << id.hwPhi() << " "
315  << "quality = " << setw(1) << id.hwQual() << '\t'
316  << "bx = " << setw(2) << id.bx();
317  }
318  return s;
319 
320 }
321 
unsigned int pt() const
get pt-code (5 bits)
Definition: L1MuBMTrack.h:76
bool operator!=(const L1MuBMTrack &) const
unequal operator
Definition: L1MuBMTrack.cc:257
L1MuBMTrack & operator=(const L1MuBMTrack &)
assignment operator
Definition: L1MuBMTrack.cc:215
const L1MuBMTrackSegPhi & getStartTSphi() const
return start phi track segment of muon candidate
Definition: L1MuBMTrack.cc:130
const L1MuBMTrackSegEta & getEndTSeta() const
return end eta track segment of muon candidate
Definition: L1MuBMTrack.cc:160
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
std::vector< L1MuBMTrackSegEta > m_tsetaList
Definition: L1MuBMTrack.h:218
L1MuBMSecProcId m_spid
Definition: L1MuBMTrack.h:210
int charge() const
get charge (1 bit)
Definition: L1MuBMTrack.h:88
const int hwQual() const
Get quality code.
TrackClass tc() const
get track-class
Definition: L1MuBMTrack.h:94
unsigned int triggerScale(float value, const edm::EventSetup &c) const
convert pt value in GeV to pt code
Definition: L1MuBMTrack.cc:200
void setTSeta(const std::vector< const L1MuBMTrackSegEta * > &tsList)
set eta track segments used to form the muon candidate
Definition: L1MuBMTrack.cc:185
virtual ~L1MuBMTrack()
destructor
Definition: L1MuBMTrack.cc:93
unsigned int phi() const
get phi-code (8 bits)
Definition: L1MuBMTrack.h:79
void setBx(int bx)
set charge of muon candidate
Definition: L1MuBMTrack.h:163
const int hwEta() const
Get compressed eta (returned int * 0.010875 = eta)
const int hwPhi() const
Get compressed local phi (returned int * 2*pi/576 = local phi in rad)
int bx() const
get the bunch crossing for this muon candidate
Definition: L1MuBMTrack.h:109
TrackClass m_tc
Definition: L1MuBMTrack.h:213
unsigned int quality() const
get quality
Definition: L1MuBMTrack.h:91
void setHwEta(int bits)
Set compressed eta as transmitted by hardware LSB = 0.010875 (9 bits)
void setTSphi(const std::vector< const L1MuBMTrackSegPhi * > &tsList)
set phi track segments used to form the muon candidate
Definition: L1MuBMTrack.cc:170
const T & get() const
Definition: EventSetup.h:56
void reset()
reset address array
void reset()
reset muon candidate
Definition: L1MuBMTrack.cc:103
void setEta(int eta)
set eta-code of muon candidate
Definition: L1MuBMTrack.cc:118
const L1MuBMTrackSegPhi & getEndTSphi() const
return end phi track segment of muon candidate
Definition: L1MuBMTrack.cc:140
const int hwPt() const
Get compressed pT (returned int * 0.5 = pT (GeV))
const int hwSign() const
Get charge sign bit (charge = (-1)^(sign))
void setHwSignValid(int bits)
Set whether charge measurement is valid (0 for high pT muons)
bool operator==(const L1MuBMTrack &) const
equal operator
Definition: L1MuBMTrack.cc:236
tuple cout
Definition: gather_cfg.py:145
int eta() const
get eta-code (6 bits)
Definition: L1MuBMTrack.h:82
std::vector< L1MuBMTrackSegPhi > m_tsphiList
Definition: L1MuBMTrack.h:217
void print() const
print parameters of muon candidate
Definition: L1MuBMTrack.cc:278
bool fineEtaBit() const
get fine eta bit
Definition: L1MuBMTrack.h:85
std::string m_name
Definition: L1MuBMTrack.h:211
bool empty() const
is it an empty muon candidate?
Definition: L1MuBMTrack.h:97
const L1MuBMTrackSegEta & getStartTSeta() const
return start eta track segment of muon candidate
Definition: L1MuBMTrack.cc:150
L1MuBMAddressArray m_addArray
Definition: L1MuBMTrack.h:216
L1MuBMTrack()
default constructor
Definition: L1MuBMTrack.cc:48