CMS 3D CMS Logo

CaloTools.cc
Go to the documentation of this file.
2 
3 
5 
8 
9 const float l1t::CaloTools::kGTEtaLSB = 0.0435;
10 const float l1t::CaloTools::kGTPhiLSB = 0.0435;
11 const float l1t::CaloTools::kGTEtLSB = 0.5;
12 
13 const int64_t l1t::CaloTools::cos_coeff[72] = {1023, 1019, 1007, 988, 961, 927, 886, 838, 784, 723, 658, 587, 512, 432, 350, 265, 178, 89, 0, -89, -178, -265, -350, -432, -512, -587, -658, -723, -784, -838, -886, -927, -961, -988, -1007, -1019, -1023, -1019, -1007, -988, -961, -927, -886, -838, -784, -723, -658, -587, -512, -432, -350, -265, -178, -89, 0, 89, 178, 265, 350, 432, 511, 587, 658, 723, 784, 838, 886, 927, 961, 988, 1007, 1019};
14 
15 const int64_t l1t::CaloTools::sin_coeff[72] = {0, 89, 178, 265, 350, 432, 512, 587, 658, 723, 784, 838, 886, 927, 961, 988, 1007, 1019, 1023, 1019, 1007, 988, 961, 927, 886, 838, 784, 723, 658, 587, 512, 432, 350, 265, 178, 89, 0, -89, -178, -265, -350, -432, -512, -587, -658, -723, -784, -838, -886, -927, -961, -988, -1007, -1019, -1023, -1019, -1007, -988, -961, -927, -886, -838, -784, -723, -658, -587, -512, -432, -350, -265, -178, -89};
16 
17 // mapping between sums in emulator and data
19  9, 1, 19, 8, 0, 18, 10, 4, 6, 14, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
20  28, 24, 13, 27, 23, 15, 5, 7, 22, 12, // 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
21  3, 21, 11, 2, 20, 17, 30, 26, 16, 29, // 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
22  25 // 30, 31
23 };
24 
25 
26 bool l1t::CaloTools::insertTower(std::vector<l1t::CaloTower>& towers, const l1t::CaloTower& tower) {
27  size_t towerIndex = CaloTools::caloTowerHash(tower.hwEta(), tower.hwPhi());
28  if (towers.size() > towerIndex) {
29  towers.at(towerIndex) = tower;
30  return true;
31  }
32  else return false;
33 }
34 
35 //currently implemented as a brute force search but this will hopefully change in the future
36 //with standarising the layout of std::vector<l1t::CaloTower>
37 const l1t::CaloTower& l1t::CaloTools::getTower(const std::vector<l1t::CaloTower>& towers,int iEta,int iPhi)
38 {
39  if(abs(iEta) > CaloTools::kHFEnd) return nullTower_;
40 
41  size_t towerIndex = CaloTools::caloTowerHash(iEta, iPhi);
42  if(towerIndex<towers.size()){
43  if(towers[towerIndex].hwEta()!=iEta || towers[towerIndex].hwPhi()!=iPhi){ //it failed, this is bad, but we will not log the error due to policy and silently attempt to do a brute force search instead
44  //std::cout <<"error, tower "<<towers[towerIndex].hwEta()<<" "<<towers[towerIndex].hwPhi()<<" does not match "<<iEta<<" "<<iPhi<<" index "<<towerIndex<<" nr towrs "<<towers.size()<<std::endl;
45  for(size_t towerNr=0;towerNr<towers.size();towerNr++){
46  if(towers[towerNr].hwEta()==iEta && towers[towerNr].hwPhi()==iPhi) return towers[towerNr];
47  }
48  }else return towers[towerIndex];
49 
50  }
51  else{// in case the vector of towers do not contain all the towers (towerIndex can be > towers.size())
52  for(size_t towerNr=0;towerNr<towers.size();towerNr++){
53  if(towers[towerNr].hwEta()==iEta && towers[towerNr].hwPhi()==iPhi) return towers[towerNr];
54  }
55  }
56 
57  return nullTower_;
58 }
59 
60 const l1t::CaloCluster& l1t::CaloTools::getCluster(const std::vector<l1t::CaloCluster>& clusters,int iEta,int iPhi)
61 {
62  for(size_t clusterNr=0;clusterNr<clusters.size();clusterNr++){
63  if(clusters[clusterNr].hwEta()==iEta && clusters[clusterNr].hwPhi()==iPhi) return clusters[clusterNr];
64  }
65  return nullCluster_;
66 }
67 
68 
69 
70 //this implimentation has not all the necessary info yet, we need to check the exact HF numbering
71 //(iEta=-28,iPhi=1)=index 0 to (iEta=28,iPhi=72)=index 28*72*2-1
72 //HF then runs after that so -32,1 = 28*72*2
73 size_t l1t::CaloTools::caloTowerHash(int iEta,int iPhi)
74 {
75 
76  if(!isValidIEtaIPhi(iEta,iPhi)) return caloTowerHashMax();
77  else{
78  const int absIEta = abs(iEta);
79  if(absIEta>kHFEnd) return kNrTowers;
80  else if(absIEta<=kHBHEEnd){ //HBHE
81  int iEtaNoZero=iEta;
82  if(iEta>0) iEtaNoZero--;
83  return (iEtaNoZero+kHBHEEnd)*kHBHENrPhi+iPhi-1;
84  }else{ //HF
85  int iEtaIndex = iEta+kHFEnd; //iEta=-32 is 0
86  if(iEta>0) iEtaIndex= iEta-kHBHEEnd+(kHFEnd-kHBHEEnd)-1; //but iEta=29 is 4
87  return iEtaIndex*kHFNrPhi+iPhi/kHFPhiSeg + kNrHBHETowers;
88  }
89  }
90 }
91 
92 
94 {
95  return kNrTowers;
96 }
97 
98 
99 bool l1t::CaloTools::isValidIEtaIPhi(int iEta,int iPhi)
100 {
101  size_t absIEta = abs(iEta);
102  if(iPhi<=0 || iPhi>kNPhi) return false;
103  if(absIEta==0 || absIEta>kHFEnd) return false;
104  //if(absIEta>kHBHEEnd && iPhi%kHFPhiSeg!=1) return false;
105  return true;
106 
107 }
108 
109 int l1t::CaloTools::calHwEtSum(int iEta,int iPhi,const std::vector<l1t::CaloTower>& towers,
110  int localEtaMin,int localEtaMax,int localPhiMin,int localPhiMax,
111  SubDet etMode)
112 {
113 
114  return calHwEtSum(iEta,iPhi,towers,localEtaMin,localEtaMax,localPhiMin,localPhiMax,kHFEnd,etMode);
115 }
116 
117 int l1t::CaloTools::calHwEtSum(int iEta,int iPhi,const std::vector<l1t::CaloTower>& towers,
118  int localEtaMin,int localEtaMax,int localPhiMin,int localPhiMax,
119  int iEtaAbsMax,SubDet etMode)
120 {
121  int hwEtSum=0;
122  for(int etaNr=localEtaMin;etaNr<=localEtaMax;etaNr++){
123  for(int phiNr=localPhiMin;phiNr<=localPhiMax;phiNr++){
124 
125  int towerIEta = l1t::CaloStage2Nav::offsetIEta(iEta,etaNr);
126  int towerIPhi = l1t::CaloStage2Nav::offsetIPhi(iPhi,phiNr);
127  if(abs(towerIEta)<=iEtaAbsMax){
128  const l1t::CaloTower& tower = getTower(towers,towerIEta,towerIPhi);
129  if(etMode==ECAL) hwEtSum+=tower.hwEtEm();
130  else if(etMode==HCAL) hwEtSum+=tower.hwEtHad();
131  else if(etMode==CALO) hwEtSum+=tower.hwPt();
132  }
133  }
134  }
135  return hwEtSum;
136 }
137 
138 
139 size_t l1t::CaloTools::calNrTowers(int iEtaMin,int iEtaMax,int iPhiMin,int iPhiMax,const std::vector<l1t::CaloTower>& towers,int minHwEt,int maxHwEt,SubDet etMode)
140 {
141  size_t nrTowers=0;
142  l1t::CaloStage2Nav nav(iEtaMin,iPhiMin);
143  while(nav.currIEta()<=iEtaMax){
144  bool finishPhi = false;
145  while(!finishPhi){
146  const l1t::CaloTower& tower = l1t::CaloTools::getTower(towers,CaloTools::caloEta(nav.currIEta()),nav.currIPhi());
147  int towerHwEt =0;
148  if(etMode==ECAL) towerHwEt+=tower.hwEtEm();
149  else if(etMode==HCAL) towerHwEt+=tower.hwEtHad();
150  else if(etMode==CALO) towerHwEt+=tower.hwPt();
151  if(towerHwEt>=minHwEt && towerHwEt<=maxHwEt) nrTowers++;
152  finishPhi = (nav.currIPhi() == iPhiMax);
153  nav.north();
154  }
155  nav.east();
156  nav.resetIPhi();
157  }
158  return nrTowers;
159 }
160 
161 std::pair<float,float> l1t::CaloTools::towerEtaBounds(int ieta)
162 {
163  if(ieta==0) ieta = 1;
164  if(ieta>kHFEnd) ieta = kHFEnd;
165  if(ieta<(-1*kHFEnd)) ieta = -1*kHFEnd;
166  //const float towerEtas[33] = {0,0.087,0.174,0.261,0.348,0.435,0.522,0.609,0.696,0.783,0.870,0.957,1.044,1.131,1.218,1.305,1.392,1.479,1.566,1.653,1.740,1.830,1.930,2.043,2.172,2.322,2.5,2.650,3.000,3.5,4.0,4.5,5.0};
167  const float towerEtas[42] = {0,0.087,0.174,0.261,0.348,0.435,0.522,0.609,0.696,0.783,0.870,0.957,1.044,1.131,1.218,1.305,1.392,1.479,1.566,1.653,1.740,1.830,1.930,2.043,2.172,2.322,2.5,2.650,2.853,3.139,3.314,3.489,3.664,3.839,4.013,4.191,4.363,4.538,4.716,4.889,5.191,5.191};
168  return std::make_pair( towerEtas[abs(ieta)-1],towerEtas[abs(ieta)] );
169 }
170 
172 {
173  std::pair<float,float> bounds = towerEtaBounds(ieta);
174  float eta = (bounds.second+bounds.first)/2.;
175  float sign = ieta>0 ? 1. : -1.;
176  return sign*eta;
177 }
178 
179 float l1t::CaloTools::towerPhi(int ieta, int iphi)
180 {
181  float phi = (float(iphi)-0.5)*towerPhiSize(ieta);
182  if (phi > M_PI) phi = phi - (2*M_PI);
183  return phi;
184 }
185 
187 {
188  std::pair<float,float> bounds = towerEtaBounds(ieta);
189  float size = (bounds.second-bounds.first);
190  return size;
191 }
192 
194 {
195  return 2.*M_PI/kNPhi;
196 }
197 
198 
199 // convert from calo ieta to internal MP ieta
200 int l1t::CaloTools::mpEta(int ieta) {
201 
202  if (ieta>kHFBegin) return ieta-1;
203  else if (ieta<-1*kHFBegin) return ieta+1;
204  else return ieta;
205 
206 }
207 
208 
209 // convert from internal MP ieta to calo ieta
211 
212  if (mpEta>=kHFBegin) return mpEta+1;
213  else if (mpEta<=-1*kHFBegin) return mpEta-1;
214  else return mpEta;
215 
216 }
217 
218 
219 // convert calorimeter ieta to RCT region index
221 {
222 
223  // outside HF
224  if (abs(ieta) > kHFEnd)
225  return (ieta<0 ? 0 : 21);
226 
227  // inside HBHE
228  if (abs(ieta) <= kHFBegin)
229  {
230  if (ieta<0)
231  return 11 - ceil( double (abs(ieta) /4.) );
232  else
233  return ceil( double (abs(ieta) /4.) ) + 10;
234  }
235 
236  // in HF
237  if (ieta<0)
238  return 4 - ceil( double (abs(ieta)-29) /4. );
239  else
240  return ceil( double (abs(ieta)-29) /4. ) + 17;
241 
242 }
243 
244 
245 // convert calorimeter ieta to etaBin16 index
247 {
248  int absIEta = abs(ieta);
249 
250  if (absIEta>0 && absIEta<=5) return 0;
251  else if (absIEta<=9) return 1;
252  else if (absIEta<=13) return 2;
253  else if (absIEta<=15) return 3;
254  else if (absIEta<=17) return 4;
255  else if (absIEta<=19) return 5;
256  else if (absIEta<=21) return 6;
257  else if (absIEta==22) return 7;
258  else if (absIEta==23) return 8;
259  else if (absIEta==24) return 9;
260  else if (absIEta==25) return 10;
261  else if (absIEta==26) return 11;
262  else if (absIEta<=28) return 12;
263  else if (absIEta<=32) return 13;
264  else if (absIEta<=36) return 14;
265  else if (absIEta<=41) return 15;
266  else return -1; // error
267 }
268 
269 
270 int l1t::CaloTools::gtEta(int ieta) {
271 
272  double eta = towerEta(ieta);
273  return round ( eta / kGTEtaLSB );
274 
275 }
276 
277 int l1t::CaloTools::gtPhi(int ieta, int iphi) {
278 
279  double phi = towerPhi(ieta, iphi);
280  if (phi<0) phi = phi + 2*M_PI;
281  return round ( phi / kGTPhiLSB );
282 
283 }
284 
285 
286 
287 
288 
289 // this conversion is based on GT input definitions in CMS DN-2014/029
291 
292  return math::PtEtaPhiMLorentzVector( cand->hwPt() * kGTEtLSB + 1.E-6,
293  cand->hwEta() * kGTEtaLSB,
294  cand->hwPhi() * kGTPhiLSB,
295  0. ) ;
296 
297 }
298 
299 
301 
302  l1t::EGamma tmpEG( p4Demux(&eg),
303  eg.hwPt(),
304  eg.hwEta(),
305  eg.hwPhi(),
306  eg.hwQual(),
307  eg.hwIso() );
308  tmpEG.setTowerIPhi(eg.towerIPhi());
309  tmpEG.setTowerIEta(eg.towerIEta());
310  tmpEG.setRawEt(eg.rawEt());
311  tmpEG.setIsoEt(eg.isoEt());
312  tmpEG.setFootprintEt(eg.footprintEt());
313  tmpEG.setNTT(eg.nTT());
314  tmpEG.setShape(eg.shape());
315  tmpEG.setTowerHoE(eg.towerHoE());
316 
317  return tmpEG;
318 
319 }
320 
321 
323 
324  l1t::Tau tmpTau ( p4Demux(&tau),
325  tau.hwPt(),
326  tau.hwEta(),
327  tau.hwPhi(),
328  tau.hwQual(),
329  tau.hwIso());
330  tmpTau.setTowerIPhi(tau.towerIPhi());
331  tmpTau.setTowerIEta(tau.towerIEta());
332  tmpTau.setRawEt(tau.rawEt());
333  tmpTau.setIsoEt(tau.isoEt());
334  tmpTau.setNTT(tau.nTT());
335  tmpTau.setHasEM(tau.hasEM());
336  tmpTau.setIsMerged(tau.isMerged());
337 
338  return tmpTau;
339 
340 }
341 
342 
344 
345 
346  l1t::Jet tmpJet ( p4Demux(&jet),
347  jet.hwPt(),
348  jet.hwEta(),
349  jet.hwPhi(),
350  jet.hwQual() );
351  tmpJet.setTowerIPhi(jet.towerIPhi());
352  tmpJet.setTowerIEta(jet.towerIEta());
353  tmpJet.setRawEt(jet.rawEt());
354  tmpJet.setSeedEt(jet.seedEt());
355  tmpJet.setPUEt(jet.puEt());
356  tmpJet.setPUDonutEt(0,jet.puDonutEt(0));
357  tmpJet.setPUDonutEt(1,jet.puDonutEt(1));
358  tmpJet.setPUDonutEt(2,jet.puDonutEt(2));
359  tmpJet.setPUDonutEt(3,jet.puDonutEt(3));
360 
361  return tmpJet;
362 
363 }
364 
365 
367 
368  return l1t::EtSum( p4Demux(&etsum),
369  etsum.getType(),
370  etsum.hwPt(),
371  etsum.hwEta(),
372  etsum.hwPhi(),
373  etsum.hwQual() );
374 
375 }
376 
377 
378 
379 //
381 
382  return math::PtEtaPhiMLorentzVector( cand->hwPt() * 0.5 + 1.E-6,
383  towerEta(cand->hwEta()),
384  towerPhi(cand->hwEta(), cand->hwPhi()),
385  0. ) ;
386 
387 }
388 
390 
391  l1t::EGamma tmpEG( p4MP(&eg),
392  eg.hwPt(),
393  eg.hwEta(),
394  eg.hwPhi(),
395  eg.hwQual(),
396  eg.hwIso() );
397  tmpEG.setTowerIPhi(eg.towerIPhi());
398  tmpEG.setTowerIEta(eg.towerIEta());
399  tmpEG.setRawEt(eg.rawEt());
400  tmpEG.setIsoEt(eg.isoEt());
401  tmpEG.setFootprintEt(eg.footprintEt());
402  tmpEG.setNTT(eg.nTT());
403  tmpEG.setShape(eg.shape());
404  tmpEG.setTowerHoE(eg.towerHoE());
405 
406  return tmpEG;
407 
408 }
409 
410 
412 
413  l1t::Tau tmpTau ( p4MP(&tau),
414  tau.hwPt(),
415  tau.hwEta(),
416  tau.hwPhi(),
417  tau.hwQual(),
418  tau.hwIso());
419  tmpTau.setTowerIPhi(tau.towerIPhi());
420  tmpTau.setTowerIEta(tau.towerIEta());
421  tmpTau.setRawEt(tau.rawEt());
422  tmpTau.setIsoEt(tau.isoEt());
423  tmpTau.setNTT(tau.nTT());
424  tmpTau.setHasEM(tau.hasEM());
425  tmpTau.setIsMerged(tau.isMerged());
426 
427  return tmpTau;
428 }
429 
430 
432 
433  l1t::Jet tmpJet ( p4MP(&jet),
434  jet.hwPt(),
435  jet.hwEta(),
436  jet.hwPhi(),
437  jet.hwQual() );
438  tmpJet.setTowerIPhi(jet.towerIPhi());
439  tmpJet.setTowerIEta(jet.towerIEta());
440  tmpJet.setRawEt(jet.rawEt());
441  tmpJet.setSeedEt(jet.seedEt());
442  tmpJet.setPUEt(jet.puEt());
443  tmpJet.setPUDonutEt(0,jet.puDonutEt(0));
444  tmpJet.setPUDonutEt(1,jet.puDonutEt(1));
445  tmpJet.setPUDonutEt(2,jet.puDonutEt(2));
446  tmpJet.setPUDonutEt(3,jet.puDonutEt(3));
447 
448  return tmpJet;
449 
450 }
451 
453 
454  return l1t::EtSum( p4MP(&etsum),
455  etsum.getType(),
456  etsum.hwPt(),
457  etsum.hwEta(),
458  etsum.hwPhi(),
459  etsum.hwQual() );
460 
461 }
462 unsigned int l1t::CaloTools::gloriousDivision( uint32_t aNumerator , uint32_t aDenominator)
463 {
464 
465  static const uint64_t lLut[] = { 0,
466  16777215, 4194304, 1864135, 1048576, 671089, 466034, 342392, 262144, 207126, 167772, 138655, 116508, 99273, 85598, 74565,
467  65536, 58053, 51782, 46474, 41943, 38044, 34664, 31715, 29127, 26844, 24818, 23014, 21400, 19949, 18641, 17458,
468  16384, 15406, 14513, 13696, 12945, 12255, 11619, 11030, 10486, 9980, 9511, 9074, 8666, 8285, 7929, 7595,
469  7282, 6988, 6711, 6450, 6205, 5973, 5754, 5546, 5350, 5164, 4987, 4820, 4660, 4509, 4365, 4227,
470  4096, 3971, 3852, 3737, 3628, 3524, 3424, 3328, 3236, 3148, 3064, 2983, 2905, 2830, 2758, 2688,
471  2621, 2557, 2495, 2435, 2378, 2322, 2268, 2217, 2166, 2118, 2071, 2026, 1982, 1940, 1899, 1859,
472  1820, 1783, 1747, 1712, 1678, 1645, 1613, 1581, 1551, 1522, 1493, 1465, 1438, 1412, 1387, 1362,
473  1337, 1314, 1291, 1269, 1247, 1226, 1205, 1185, 1165, 1146, 1127, 1109, 1091, 1074, 1057, 1040,
474  1024, 1008, 993, 978, 963, 948, 934, 921, 907, 894, 881, 868, 856, 844, 832, 820,
475  809, 798, 787, 776, 766, 756, 746, 736, 726, 717, 707, 698, 689, 681, 672, 664,
476  655, 647, 639, 631, 624, 616, 609, 602, 594, 587, 581, 574, 567, 561, 554, 548,
477  542, 536, 530, 524, 518, 512, 506, 501, 496, 490, 485, 480, 475, 470, 465, 460,
478  455, 450, 446, 441, 437, 432, 428, 424, 419, 415, 411, 407, 403, 399, 395, 392,
479  388, 384, 380, 377, 373, 370, 366, 363, 360, 356, 353, 350, 347, 344, 340, 337,
480  334, 331, 328, 326, 323, 320, 317, 314, 312, 309, 306, 304, 301, 299, 296, 294,
481  291, 289, 286, 284, 282, 280, 277, 275, 273, 271, 268, 266, 264, 262, 260, 258,
482  256, 254, 252, 250, 248, 246, 244, 243, 241, 239, 237, 235, 234, 232, 230, 228,
483  227, 225, 223, 222, 220, 219, 217, 216, 214, 212, 211, 209, 208, 207, 205, 204,
484  202, 201, 199, 198, 197, 195, 194, 193, 191, 190, 189, 188, 186, 185, 184, 183,
485  182, 180, 179, 178, 177, 176, 175, 173, 172, 171, 170, 169, 168, 167, 166, 165,
486  164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149,
487  149, 148, 147, 146, 145, 144, 143, 143, 142, 141, 140, 139, 139, 138, 137, 136,
488  135, 135, 134, 133, 132, 132, 131, 130, 129, 129, 128, 127, 127, 126, 125, 125,
489  124, 123, 123, 122, 121, 121, 120, 119, 119, 118, 117, 117, 116, 116, 115, 114,
490  114, 113, 113, 112, 111, 111, 110, 110, 109, 109, 108, 108, 107, 106, 106, 105,
491  105, 104, 104, 103, 103, 102, 102, 101, 101, 100, 100, 99, 99, 98, 98, 97,
492  97, 96, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 92, 91, 91, 90,
493  90, 89, 89, 89, 88, 88, 87, 87, 87, 86, 86, 85, 85, 85, 84, 84,
494  84, 83, 83, 82, 82, 82, 81, 81, 81, 80, 80, 80, 79, 79, 79, 78,
495  78, 78, 77, 77, 77, 76, 76, 76, 75, 75, 75, 74, 74, 74, 73, 73,
496  73, 73, 72, 72, 72, 71, 71, 71, 70, 70, 70, 70, 69, 69, 69, 68,
497  68, 68, 68, 67, 67, 67, 67, 66, 66, 66, 66, 65, 65, 65, 65, 64 };
498 
499 // Firmware uses 18bit integers - make sure we are in the same range
500  aNumerator &= 0x3FFFF;
501  aDenominator &= 0x3FFFF;
502 
503 // Shift the denominator to optimise the polynomial expansion
504 // I limit the shift to half the denominator size in the firmware to save on resources
505  uint32_t lBitShift(0);
506  for( ;lBitShift!=9 ; ++lBitShift )
507  {
508  if ( aDenominator & 0x20000 ) break; // There is a 1 in the MSB
509  aDenominator <<= 1;
510  }
511 
512 // The magical polynomial expansion Voodoo
513  uint64_t lInverseDenominator( ( ( aDenominator & 0x3FE00 ) - ( aDenominator & 0x001FF ) ) * ( lLut[ aDenominator >> 9 ] ) );
514 
515 // Save on DSPs by throwing away a bunch of LSBs
516  lInverseDenominator >>= 17;
517 
518 // Multiply the numerator by the inverse denominator
519  uint64_t lResult( aNumerator * lInverseDenominator );
520 
521 // Add two bits to the result, to make the Voodoo below work (saves us having an if-else on the shift direction)
522  lResult <<= 2;
523 
524 // Restore the scale by taking into account the bitshift applied above.
525 // We are now 18 bit left-shifted, so the 18 LSBs are effectively the fractional part...
526 
527  uint32_t aFractional = ( lResult >>= ( 9 - lBitShift) ) & 0x3FFFF;
528 // ...and the top 18 bits are the integer part
529 
530  // uint32_t aInteger = ( lResult >>= 18 ) & 0x3FFFF;
531 
532  unsigned int result = aFractional >> 10;
533 
534  return result;
535 
536 // Simples!
537 }
size
Write out results.
static float towerEta(int ieta)
Definition: CaloTools.cc:171
static l1t::Tau tauP4MP(l1t::Tau &)
Definition: CaloTools.cc:411
bool hasEM() const
static const int kHFPhiSeg
Definition: CaloTools.h:42
short int towerIEta() const
Definition: EGamma.cc:75
static l1t::EtSum etSumP4MP(l1t::EtSum &)
Definition: CaloTools.cc:452
static bool isValidIEtaIPhi(int iEta, int iPhi)
Definition: CaloTools.cc:99
short int towerIPhi() const
Definition: EGamma.cc:79
static const float kGTPhiLSB
Definition: CaloTools.h:134
static unsigned int gloriousDivision(uint32_t aNumerator, uint32_t aDenominator)
Definition: CaloTools.cc:462
static float towerPhi(int ieta, int iphi)
Definition: CaloTools.cc:179
std::pair< int, int > north()
static int mpEta(int ieta)
Definition: CaloTools.cc:200
static const int64_t cos_coeff[72]
Definition: CaloTools.h:120
static const int kHBHEEnd
Definition: CaloTools.h:39
static const int emul_to_data_sum_index_map[31]
Definition: CaloTools.h:124
static l1t::EGamma egP4MP(l1t::EGamma &)
Definition: CaloTools.cc:389
static int regionEta(int ieta)
Definition: CaloTools.cc:220
short int rawEt() const
Definition: Tau.h:21
static int offsetIEta(int iEta, int offset)
Definition: CaloStage2Nav.h:44
static float towerEtaSize(int ieta)
Definition: CaloTools.cc:186
static int calHwEtSum(int iEta, int iPhi, const std::vector< l1t::CaloTower > &towers, int localEtaMin, int localEtaMax, int localPhiMin, int localPhiMax, SubDet etMode=CALO)
Definition: CaloTools.cc:109
static const int kNrHBHETowers
Definition: CaloTools.h:47
static const int kNPhi
Definition: CaloTools.h:45
static const float kGTEtaLSB
Definition: CaloTools.h:133
static math::PtEtaPhiMLorentzVector p4MP(l1t::L1Candidate *)
Definition: CaloTools.cc:380
short int shape() const
Definition: EGamma.cc:99
int hwPhi() const
Definition: L1Candidate.h:50
int hwEtEm() const
Definition: CaloTower.cc:64
short int footprintEt() const
Definition: EGamma.cc:91
static int gtPhi(int ieta, int iphi)
Definition: CaloTools.cc:277
static const int64_t sin_coeff[72]
Definition: CaloTools.h:121
short int seedEt() const
static size_t caloTowerHash(int iEta, int iPhi)
Definition: CaloTools.cc:73
static const int kHFBegin
Definition: CaloTools.h:40
int currIPhi() const
short int towerIEta() const
short int rawEt() const
Definition: EGamma.cc:83
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
int hwIso() const
Definition: L1Candidate.h:52
Definition: Jet.h:21
static const int kHFNrPhi
Definition: CaloTools.h:43
short int towerHoE() const
Definition: EGamma.cc:103
short int isoEt() const
Definition: EGamma.cc:87
static int offsetIPhi(int iPhi, int offset)
Definition: CaloStage2Nav.h:33
bool isMerged() const
static size_t calNrTowers(int iEtaMin, int iEtaMax, int iPhiMin, int iPhiMax, const std::vector< l1t::CaloTower > &towers, int minHwEt, int maxHwEt, SubDet etMode=CALO)
Definition: CaloTools.cc:139
short int puEt() const
static l1t::EGamma egP4Demux(l1t::EGamma &)
Definition: CaloTools.cc:300
static const int kHFEnd
Definition: CaloTools.h:41
static int gtEta(int ieta)
Definition: CaloTools.cc:270
static const l1t::CaloCluster & getCluster(const std::vector< l1t::CaloCluster > &clusters, int iEta, int iPhi)
Definition: CaloTools.cc:60
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static l1t::Jet jetP4MP(l1t::Jet &)
Definition: CaloTools.cc:431
static l1t::Jet jetP4Demux(l1t::Jet &)
Definition: CaloTools.cc:343
int hwEta() const
Definition: L1Candidate.h:49
static const int kNrTowers
Definition: CaloTools.h:46
int hwQual() const
Definition: L1Candidate.h:51
#define M_PI
short int towerIEta() const
Definition: HCAL.py:1
static float towerPhiSize(int ieta)
Definition: CaloTools.cc:193
short int rawEt() const
static l1t::Tau tauP4Demux(l1t::Tau &)
Definition: CaloTools.cc:322
int hwPt() const
Definition: L1Candidate.h:48
unsigned long long uint64_t
Definition: Time.h:15
static const int kHBHENrPhi
Definition: CaloTools.h:44
static std::pair< float, float > towerEtaBounds(int ieta)
Definition: CaloTools.cc:161
static size_t caloTowerHashMax()
Definition: CaloTools.cc:93
static const l1t::CaloTower nullTower_
Definition: CaloTools.h:130
static bool insertTower(std::vector< l1t::CaloTower > &towers, const l1t::CaloTower &tower)
Definition: CaloTools.cc:26
std::pair< int, int > east()
static int caloEta(int ietaMP)
Definition: CaloTools.cc:210
static const l1t::CaloTower & getTower(const std::vector< l1t::CaloTower > &towers, int iEta, int iPhi)
Definition: CaloTools.cc:37
short int towerIPhi() const
static const float kGTEtLSB
Definition: CaloTools.h:135
void setTowerIPhi(short int iphi)
Definition: EGamma.cc:47
void setTowerIPhi(short int iphi)
short int puDonutEt(int i) const
static int bin16Eta(int ieta)
Definition: CaloTools.cc:246
static math::PtEtaPhiMLorentzVector p4Demux(l1t::L1Candidate *)
Definition: CaloTools.cc:290
short int isoEt() const
int hwEtHad() const
Definition: CaloTower.cc:69
short int towerIPhi() const
static const l1t::CaloCluster nullCluster_
Definition: CaloTools.h:131
EtSumType getType() const
Definition: EtSum.cc:37
short int nTT() const
static l1t::EtSum etSumP4Demux(l1t::EtSum &)
Definition: CaloTools.cc:366
void setTowerIPhi(short int iphi)
short int nTT() const
Definition: EGamma.cc:95
int currIEta() const