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