test
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  setHwHF(false);
122  setHwEta(eta);
123 
124 
125 }
126 
127 
128 //
129 // return start phi track segment
130 //
132 
133  return m_tsphiList.front();
134 
135 }
136 
137 
138 //
139 // return end phi track segment
140 //
142 
143  return m_tsphiList.back();
144 
145 }
146 
147 
148 //
149 // return start eta track segment
150 //
152 
153  return m_tsetaList.front();
154 
155 }
156 
157 
158 //
159 // return end eta track segment
160 //
162 
163  return m_tsetaList.back();
164 
165 }
166 
167 
168 //
169 // set phi track segments used to form the muon candidate
170 //
171 void L1MuBMTrack::setTSphi(const vector<const L1MuBMTrackSegPhi*>& tsList) {
172 
173  if ( !tsList.empty() ) {
174  vector<const L1MuBMTrackSegPhi*>::const_iterator iter;
175  for ( iter = tsList.begin(); iter != tsList.end(); iter++ ) {
176  if ( *iter ) m_tsphiList.push_back(**iter);
177  }
178  }
179 
180 }
181 
182 
183 //
184 // set eta track segments used to form the muon candidate
185 //
186 void L1MuBMTrack::setTSeta(const vector<const L1MuBMTrackSegEta*>& tsList) {
187 
188  if ( !tsList.empty() ) {
189  vector<const L1MuBMTrackSegEta*>::const_iterator iter;
190  for ( iter = tsList.begin(); iter != tsList.end(); iter++ ) {
191  if ( *iter ) m_tsetaList.push_back(**iter);
192  }
193  }
194 
195 }
196 
197 
198 //
199 // convert pt value in GeV to pt code
200 //
201 unsigned int L1MuBMTrack::triggerScale(float value, const edm::EventSetup& c) const {
202 
203  const float eps = 1.e-5; // add an epsilon so that setting works with low edge value
204 
205  edm::ESHandle< L1MuTriggerPtScale > theTriggerScales;
206  c.get< L1MuTriggerPtScaleRcd >().get( theTriggerScales );
207  unsigned int t_Scale = theTriggerScales->getPtScale()->getPacked( value + eps );
208 
209  return t_Scale;
210 }
211 
212 
213 //
214 // Assignment operator
215 //
217 
218  if ( this != &track ) {
219  this->setBx(track.bx());
220  //this->setDataWord(track.getDataWord());
221  m_spid = track.m_spid;
222  m_empty = track.m_empty;
223  m_name = track.m_name;
224  m_tc = track.m_tc;
225  m_addArray = track.m_addArray;
226  m_tsphiList = track.m_tsphiList;
227  m_tsetaList = track.m_tsetaList;
228  }
229  return *this;
230 
231 }
232 
233 
234 //
235 // Equal operator
236 //
237 bool L1MuBMTrack::operator==(const L1MuBMTrack& track) const {
238 
239  if ( m_spid != track.m_spid ) return false;
240  if ( m_empty != track.m_empty ) return false;
241  if ( m_tc != track.m_tc ) return false;
242  if ( bx() != track.bx() ) return false;
243  if ( phi() != track.phi() ) return false;
244  if ( eta() != track.eta() ) return false;
245  if ( fineEtaBit() != track.fineEtaBit() ) return false;
246  if ( pt() != track.pt() ) return false;
247  if ( charge() != track.charge() ) return false;
248  if ( quality() != track.quality() ) return false;
249  if ( m_addArray != track.m_addArray ) return false;
250  return true;
251 
252 }
253 
254 
255 //
256 // Unequal operator
257 //
258 bool L1MuBMTrack::operator!=(const L1MuBMTrack& track) const {
259 
260  if ( m_spid != track.m_spid ) return true;
261  if ( m_empty != track.m_empty ) return true;
262  if ( m_tc != track.m_tc ) return true;
263  if ( bx() != track.bx() ) return true;
264  if ( phi() != track.phi() ) return true;
265  if ( eta() != track.eta() ) return true;
266  if ( fineEtaBit() != track.fineEtaBit() ) return true;
267  if ( pt() != track.pt() ) return true;
268  if ( charge() != track.charge() ) return true;
269  if ( quality() != track.quality() ) return true;
270  if ( m_addArray != track.m_addArray ) return true;
271  return false;
272 
273 }
274 
275 
276 //
277 // print parameters of track candidate
278 //
279 void L1MuBMTrack::print() const {
280 
281  if ( !empty() ) {
282  cout.setf(ios::showpoint);
283  cout.setf(ios::right,ios::adjustfield);
284  cout << setiosflags(ios::showpoint | ios::fixed);
285  cout << "MUON : "
286  << "pt = " << setw(3) << hwPt() << " "
287  << "charge = " << setw(2) << hwSign() << " "
288  << "eta = " << setw(2) << hwEta()
289  //<< " (" << setw(1) << finehalo_packed() << ") "
290  << "phi = " << setw(3) << hwPhi() << " "
291  << "quality = " << setw(1) << hwQual() << '\t'
292  << "class = " << tc() << " "
293  << "bx = " << setw(2) << bx() << endl;
294  cout << " found in " << m_spid << " with phi track segments :" << endl;
295  vector<L1MuBMTrackSegPhi>::const_iterator iter;
296  for ( iter = m_tsphiList.begin(); iter != m_tsphiList.end(); iter++ ) {
297  cout << " " << (*iter) << endl;
298  }
299  }
300 
301 }
302 
303 
304 //
305 // output stream operator for track candidate
306 //
307 ostream& operator<<(ostream& s, const L1MuBMTrack& id) {
308 
309  if ( !id.empty() ) {
310  s << setiosflags(ios::showpoint | ios::fixed)
311  << "pt = " << setw(3) << id.hwPt() << " "
312  << "charge = " << setw(2) << id.hwSign() << " "
313  << "eta = " << setw(2) << id.hwEta()
314  //<< " (" << setw(1) << id.finehalo_packed() << ") "
315  << "phi = " << setw(3) << id.hwPhi() << " "
316  << "quality = " << setw(1) << id.hwQual() << '\t'
317  << "bx = " << setw(2) << id.bx();
318  }
319  return s;
320 
321 }
322 
unsigned int pt() const
get pt-code (5 bits)
Definition: L1MuBMTrack.h:76
bool operator!=(const L1MuBMTrack &) const
unequal operator
Definition: L1MuBMTrack.cc:258
L1MuBMTrack & operator=(const L1MuBMTrack &)
assignment operator
Definition: L1MuBMTrack.cc:216
const L1MuBMTrackSegPhi & getStartTSphi() const
return start phi track segment of muon candidate
Definition: L1MuBMTrack.cc:131
const L1MuBMTrackSegEta & getEndTSeta() const
return end eta track segment of muon candidate
Definition: L1MuBMTrack.cc:161
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
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:201
void setTSeta(const std::vector< const L1MuBMTrackSegEta * > &tsList)
set eta track segments used to form the muon candidate
Definition: L1MuBMTrack.cc:186
virtual ~L1MuBMTrack()
destructor
Definition: L1MuBMTrack.cc:93
unsigned int phi() const
get phi-code (8 bits)
Definition: L1MuBMTrack.h:79
void setHwHF(bool bit)
Set HF (halo / fine eta) bit (EMTF: halo -&gt; 1; BMTF: fine eta -&gt; 1)
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:171
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:141
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:237
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:279
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:151
L1MuBMAddressArray m_addArray
Definition: L1MuBMTrack.h:216
L1MuBMTrack()
default constructor
Definition: L1MuBMTrack.cc:48