CMS 3D CMS Logo

SimpleL1MuGMTCand.cc
Go to the documentation of this file.
1 // This class header:
3 
4 // Fast Simulation headers
6 
7 // The muon scales
8 
9 //CMSSW headers
10 
11 // STL headers
12 #include <iomanip>
13 
14 
16  m_name("FastL1MuCand"), m_empty(true),
17  m_phi(0), m_eta(31), m_pt(0), m_charge(0), m_quality(0),
18  m_rank(0), m_smearedPt(0) { }
19 
21  m_name(mu.m_name), m_empty(mu.m_empty),
22  m_phi(mu.m_phi), m_eta(mu.m_eta), m_pt(mu.m_pt),
26  setQuality(m_quality & 7);
27  setEtaPacked(m_eta & 63);
28  setPhiPacked(m_phi & 255);
30  setPtPacked(m_pt & 31);
31 }
32 
34  m_name(mu->m_name), m_empty(mu->m_empty),
35  m_phi(mu->m_phi), m_eta(mu->m_eta), m_pt(mu->m_pt),
38  setMomentum(mu->getMomentum());
39  setQuality(m_quality & 7);
40  setEtaPacked(m_eta & 63);
41  setPhiPacked(m_phi & 255);
43  setPtPacked(m_pt & 31);
44 }
45 
47  // setMomentum(p->momentum());
48  LorentzVector toBeRemoved(p->momentum().x(),p->momentum().y(),p->momentum().z(),p->momentum().t());
49  setMomentum(toBeRemoved);
50  m_name = "FastL1MuCand";
51  m_empty = false;
52  m_quality = 7;
54  m_rank = 0;
55  setEta(myMomentum.Eta());
56  setPhi(myMomentum.Phi());
57  setCharge(int(p->charge()));
58  setPt(myMomentum.Pt());
59  setBx(0);
60  if ( fabs(myMomentum.eta()) > 1.04 )
61  setFwdBit(1);
62  else
63  setFwdBit(0);
64  setRPCBit(0);
65 
66 }
67 
69  unsigned etaIndex,
70  unsigned phiIndex,
71  unsigned pTIndex,
72  float etaValue,
73  float phiValue,
74  float pTValue) {
75  // setMomentum(p->momentum());
76  LorentzVector toBeRemoved(p->momentum().x(),p->momentum().y(),p->momentum().z(),p->momentum().t());
77  setMomentum(toBeRemoved);
78  m_name = "FastL1MuCand";
79  m_empty = false;
80  m_quality = 7;
82  m_rank = 0;
84  setPhiPacked(phiIndex);
85  setPhiValue(phiValue);
87  setEtaPacked(etaIndex);
88  setEtaValue(etaValue);
89  setCharge(int(p->charge()));
90  m_pt = pTIndex;
91  setPtPacked(pTIndex);
92  setPtValue(pTValue);
93  m_smearedPt = myMomentum.Pt();
94  setBx(0);
95  if ( fabs(etaValue) > 1.04 )
96  setFwdBit(1);
97  else
98  setFwdBit(0);
99  setRPCBit(0);
100 
101 }
102 
104 
105  reset();
106 
107 }
108 
109 
110 //
112 
113  m_empty = true;
114  m_phi = 0;
115  m_eta = 31;
116  m_pt = 0;
117  m_charge = 0;
118  m_quality = 0;
119  m_rank = 0;
120  m_smearedPt = 0;
121 
122 }
123 
124 
125 //
126 // set phi-value of muon candidate
127 //
129 
130  int index = 0;
131  float mindiff = 1000.0;
132 
133  if (phi < 0.) {phi = 2* M_PI + phi; }
134  for ( int i = 0; i < 144; i++ ) {
135  float diff = fabs(SimpleL1MuGMTCand::phiScale[i]-phi);
136  if ( diff <= mindiff ) {
137  mindiff = diff;
138  index = i;
139  }
140  }
141 
142  m_phi = index;
143  setPhiPacked(m_phi & 255 );
145 
146 }
147 
148 
149 //
150 // set eta-value of muon candidate
151 //
153 
154  int index = 0;
155  float mindiff = 1000.0;
156 
157  for ( int i = 0; i < 63; i++ ) {
158  float diff = fabs(SimpleL1MuGMTCand::etaScale[i]-eta);
159  if ( diff <= mindiff ) {
160  mindiff = diff;
161  index = i;
162  }
163  }
164 
165  m_eta = index;
166  setEtaPacked(m_eta & 63 );
168 
169 }
170 
171 
172 //
173 // set pt (value!!) of muon candidate
174 //
176 
177  int index = 0;
178  m_smearedPt = pt;
179 
180  float mindiff = 1000.0;
181 
182  for ( int i = 0; i < 32; i++ ) {
183  float diff = fabs(SimpleL1MuGMTCand::ptScale[i]-pt);
184  if ( diff <= mindiff ) {
185  mindiff = diff;
186  index = i;
187  }
188  }
189 
190  m_pt = index;
191  setPtPacked(m_pt & 31 );
193 
194 }
195 
196 
197 //
198 // set charge and packed code of muon candidate
199 //
201 
202  m_charge = charge;
203  setChargePacked(charge == 1 ? 0 : 1);
204 
205 }
206 
207 
208 
209 //
210 // set generator particle of muon candidate
211 //
212 /*
213 void SimpleL1MuGMTCand::setGenPart(const HepMC::GenParticle * rhp) {
214 
215  myGenParticle = rhp;
216 }
217 */
218 
219 
220 //
221 // Assignment operator
222 //
224 
225  if ( this != &cand ) {
226 
227  m_empty = cand.m_empty;
228  m_phi = cand.m_phi;
229  m_eta = cand.m_eta;
230  m_pt = cand.m_pt;
231  m_charge = cand.m_charge;
232  m_quality = cand.m_quality;
233  m_rank = cand.m_rank;
234  m_smearedPt = cand.m_smearedPt;
235 
236  }
237  return *this;
238 
239 }
240 
241 
242 //
243 // Assignment operator for SimTrack's
244 //
246 
247  m_empty = false;
248  setEta(p->momentum().eta());
249  setPhi(p->momentum().phi());
250  setCharge(int(p->charge()));
251  setPt(std::sqrt(p->momentum().perp2()));
252 
253  return this;
254 }
255 
256 //
257 // Equal operator
258 //
260 
261  if ( m_empty != cand.m_empty ) return false;
262  if ( m_phi != cand.m_phi ) return false;
263  if ( m_eta != cand.m_eta ) return false;
264  if ( m_pt != cand.m_pt ) return false;
265  if ( m_charge != cand.m_charge ) return false;
266  if ( m_quality != cand.m_quality ) return false;
267  if ( m_rank != cand.m_rank ) return false;
268  return true;
269 
270 }
271 
272 
273 //
274 // Unequal operator
275 //
277 
278  if ( m_empty != cand.m_empty ) return true;
279  if ( m_phi != cand.m_phi ) return true;
280  if ( m_eta != cand.m_eta ) return true;
281  if ( m_pt != cand.m_pt ) return true;
282  if ( m_charge != cand.m_charge ) return true;
283  if ( m_quality != cand.m_quality ) return true;
284  if ( m_rank != cand.m_rank ) return true;
285  return false;
286 
287 }
288 
289 
290 //
291 // print parameters of track candidate
292 //
294 
295  using namespace std;
296 
297  if ( !empty() ) {
298  cout.setf(ios::showpoint);
299  cout.setf(ios::right,ios::adjustfield);
300  cout << setiosflags(ios::showpoint | ios::fixed)
301  << "pt = " << setw(5) << setprecision(1) << ptValue() << " GeV "
302  << "charge = " << setw(2) << charge() << " "
303  << "eta = " << setw(5) << setprecision(2) << etaValue() << " "
304  << "phi = " << setw(5) << setprecision(3) << phiValue() << " rad "
305  << "rank = " << setw(6) << rank() << endl;
306  }
307 
308 }
309 
310 
311 //
312 // output stream operator for track candidate
313 //
314 std::ostream& operator<<(std::ostream& s, const SimpleL1MuGMTCand& id) {
315 
316  using namespace std;
317 
318  if ( !id.empty() ) {
319  s << setiosflags(ios::showpoint | ios::fixed)
320  << "pt = " << setw(5) << setprecision(1) << id.ptValue() << " GeV "
321  << "charge = " << setw(2) << id.charge() << " "
322  << "eta = " << setw(5) << setprecision(2) << id.etaValue() << " "
323  << "phi = " << setw(5) << setprecision(3) << id.phiValue() << " rad ";
324 
325  }
326  return s;
327 
328 }
329 
330 //static
331 
332 
333 // pt scale in GeV
334 // low edges of pt bins
335 const float SimpleL1MuGMTCand::ptScale[32] = {
336  0.0, 0.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0,
337  4.5, 5.0, 6.0, 7.0, 8.0, 10.0, 12.0, 14.0,
338  16.0, 18.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0,
339  50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 120.0, 140.0 };
340 
341 // eta scale
342 const float SimpleL1MuGMTCand::etaScale[63] = {
343  -2.40, -2.35, -2.30, -2.25, -2.20, -2.15, -2.10, -2.05,
344  -2.00, -1.95, -1.90, -1.85, -1.80, -1.75, -1.70, -1.60,
345  -1.50, -1.40, -1.30, -1.20, -1.10, -1.00, -0.90, -0.80,
346  -0.70, -0.60, -0.50, -0.40, -0.30, -0.20, -0.10, 0.00,
347  0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80,
348  0.90, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60,
349  1.70, 1.75, 1.80, 1.85, 1.90, 1.95, 2.00, 2.05,
350  2.10, 2.15, 2.20, 2.25, 2.30, 2.35, 2.40 };
351 
352 // phi scale
353 const float SimpleL1MuGMTCand::phiScale[144] = {
354  0.0000, 0.0436, 0.0873, 0.1309, 0.1745, 0.2182,
355  0.2618, 0.3054, 0.3491, 0.3927, 0.4363, 0.4800,
356  0.5236, 0.5672, 0.6109, 0.6545, 0.6981, 0.7418,
357  0.7854, 0.8290, 0.8727, 0.9163, 0.9599, 1.0036,
358  1.0472, 1.0908, 1.1345, 1.1781, 1.2217, 1.2654,
359  1.3090, 1.3526, 1.3963, 1.4399, 1.4835, 1.5272,
360  1.5708, 1.6144, 1.6581, 1.7017, 1.7453, 1.7890,
361  1.8326, 1.8762, 1.9199, 1.9635, 2.0071, 2.0508,
362  2.0944, 2.1380, 2.1817, 2.2253, 2.2689, 2.3126,
363  2.3562, 2.3998, 2.4435, 2.4871, 2.5307, 2.5744,
364  2.6180, 2.6616, 2.7053, 2.7489, 2.7925, 2.8362,
365  2.8798, 2.9234, 2.9671, 3.0107, 3.0543, 3.0980,
366  3.1416, 3.1852, 3.2289, 3.2725, 3.3161, 3.3598,
367  3.4034, 3.4470, 3.4907, 3.5343, 3.5779, 3.6216,
368  3.6652, 3.7088, 3.7525, 3.7961, 3.8397, 3.8834,
369  3.9270, 3.9706, 4.0143, 4.0579, 4.1015, 4.1452,
370  4.1888, 4.2324, 4.2761, 4.3197, 4.3633, 4.4070,
371  4.4506, 4.4942, 4.5379, 4.5815, 4.6251, 4.6688,
372  4.7124, 4.7560, 4.7997, 4.8433, 4.8869, 4.9306,
373  4.9742, 5.0178, 5.0615, 5.1051, 5.1487, 5.1924,
374  5.2360, 5.2796, 5.3233, 5.3669, 5.4105, 5.4542,
375  5.4978, 5.5414, 5.5851, 5.6287, 5.6723, 5.7160,
376  5.7596, 5.8032, 5.8469, 5.8905, 5.9341, 5.9778,
377  6.0214, 6.0650, 6.1087, 6.1523, 6.1959, 6.2396 };
float etaValue() const
Definition: L1MuGMTCand.cc:114
void setPtPacked(unsigned pt)
set packed pt-code of muon candidate
Definition: L1MuGMTCand.h:154
float phiValue() const
Definition: L1MuGMTCand.cc:100
unsigned int eta() const
get eta-code
unsigned int rank() const
get rank
unsigned int phiIndex() const
get phi-code
Definition: L1MuGMTCand.h:73
int charge() const
get charge
unsigned int etaIndex() const
get eta-code
Definition: L1MuGMTCand.h:108
float charge() const
charge
Definition: CoreSimTrack.cc:18
SimpleL1MuGMTCand & operator=(const SimpleL1MuGMTCand &)
assignment operator
unsigned int m_quality
void print() const
print parameters of muon candidate
bool operator!=(const SimpleL1MuGMTCand &) const
unequal operator
bool operator==(const SimpleL1MuGMTCand &) const
equal operator
unsigned int pt() const
get pt-code
static const float etaScale[63]
void setPhiValue(float phiVal)
Setters for physical values.
Definition: L1MuGMTCand.h:177
void setFwdBit(unsigned int fwdbit)
set forward bit (1=forward, 0=barrel)
T sqrt(T t)
Definition: SSEVec.h:18
math::XYZTLorentzVector LorentzVector
static const float ptScale[32]
void reset()
reset muon candidate
void setCharge(int charge)
set charge and packed code of muon candidate
const int mu
Definition: Constants.h:22
void setBx(int bx)
set bunch crossing identifier
Definition: L1MuGMTCand.h:172
bool empty() const
is it an empty muon candidate?
~SimpleL1MuGMTCand() override
destructor
friend std::ostream & operator<<(std::ostream &, const SimpleL1MuGMTCand &)
output stream operator
void setChargePacked(unsigned ch)
set packed charge/synchronization word of muon candidate (0=POS, 1=NEG, 2=UNDEF, 3=SYNC) ...
Definition: L1MuGMTCand.h:169
void setPt(float pt)
set pt-value and packed code of muon candidate
#define M_PI
float ptValue() const
Definition: L1MuGMTCand.cc:128
void setEta(float eta)
set eta-value and packed code of muon candidate
void setQuality(unsigned quality)
set quality of muon candidate
Definition: L1MuGMTCand.h:157
void setEtaPacked(unsigned eta)
set packed eta-code of muon candidate
Definition: L1MuGMTCand.h:160
void setEtaValue(float etaVal)
Set Eta Value (need to set type, first)
Definition: L1MuGMTCand.h:183
const LorentzVector getMomentum() const
void setRPCBit(unsigned int rpcbit)
set RPC bit (1=RPC, 0=DT/CSC or matched)
SimpleL1MuGMTCand()
constructor
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:22
void setMomentum(const LorentzVector &m)
unsigned int phi() const
get phi-code
void setPhi(float phi)
set phi-value and packed code of muon candidate
void setPtValue(float ptVal)
Set Pt Value.
Definition: L1MuGMTCand.h:180
LorentzVector myMomentum
static const float phiScale[144]
void setPhiPacked(unsigned phi)
set packed phi-code of muon candidate
Definition: L1MuGMTCand.h:151