CMS 3D CMS Logo

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