CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GetHistLimits.cc
Go to the documentation of this file.
1 
17 // this class header
19 
20 // system include files
21 #include <iostream>
22 #include <iomanip>
23 #include <string>
24 
25 // user include files
28 
29 
33 
36 
37 // constructor
39  m_evSetup(evSetup) {
40 
41  //
42 
43 }
44 
45 // destructor
47 
48  // empty
49 
50 }
51 
53  const std::string& quantity) {
54 
59 
60 
61  // number of objects is independent of the object type
62  // and hardcoded in the actual version
63  if (quantity == "NrObjects") {
64 
68 
70 
71  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
76 
77  }
78 
79  // set last bin upper edge
82 
83  return;
84 
85  }
86 
87  switch (l1GtObject) {
88  case Mu: {
89 
90  if (quantity == "PT") {
91 
93  m_evSetup.get<L1MuTriggerPtScaleRcd>().get(muPtScale);
94 
95  m_l1HistLimits.nrBins = muPtScale->getPtScale()->getNBins();
97  = muPtScale->getPtScale()->getScaleMin();
99  = muPtScale->getPtScale()->getScaleMax();
100 
102 
103  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
105  = muPtScale->getPtScale()->getValue(iBin);
106 
107  }
108 
109  // last limit for muon is set too high (10^6) - resize the last bin
110 
111  float lastBinSize = m_l1HistLimits.upperBinValue
113 
114  // limit the size of the last bin to maximum 200 GeV
115  float maxLaxtBinsize = 200;
116  if (lastBinSize >= maxLaxtBinsize) {
121  LogDebug("L1GetHistLimits")
122  << "\n L1ExtraMuon: PT histogram"
123  << "\nm_l1HistLimits.upperBinValue truncated to = "
124  << m_l1HistLimits.upperBinValue << std::endl;
125  }
126 
127  // set last bin upper edge
130 
131  } else if (quantity == "eta" || quantity == "phi") {
133  m_evSetup.get<L1MuTriggerScalesRcd>().get(muScales);
134 
135  if (quantity == "eta") {
136  // eta scale defined for positive values - need to be symmetrized
137  int histNrBinsHalf = muScales->getGMTEtaScale()->getNBins();
139  = muScales->getGMTEtaScale()->getScaleMin();
141  = muScales->getGMTEtaScale()->getScaleMax();
142 
143  m_l1HistLimits.nrBins = 2 * histNrBinsHalf;
146 
148 
149  int iBin = 0;
150  for (int j = histNrBinsHalf; j > 0; j--, iBin++) {
151  m_l1HistLimits.binThresholds[iBin] = (-1)
152  * muScales->getGMTEtaScale()->getValue(j);
153  }
154  for (int j = 0; j <= histNrBinsHalf; j++, iBin++) {
156  = muScales->getGMTEtaScale()->getValue(j);
157  }
158 
159  // set last bin upper edge
162 
163  } else {
164  m_l1HistLimits.nrBins = muScales->getPhiScale()->getNBins();
166  muScales->getPhiScale()->getScaleMin());
168  muScales->getPhiScale()->getScaleMax());
169 
171  + 1);
172 
173  for (int iBin = 0; iBin <= m_l1HistLimits.nrBins; iBin++) {
175  muScales->getPhiScale()->getValue(iBin));
176  }
177 
178  // set last bin upper edge
181 
182  }
183 
184  }
185 
186  }
187  break;
188  case NoIsoEG:
189  case IsoEG: {
190  // common scales for NoIsoEG and IsoEG
191  if (quantity == "ET") {
193  m_evSetup.get<L1EmEtScaleRcd>().get(emScale);
194 
195  std::vector<double> emThresholds = emScale->getThresholds();
196  m_l1HistLimits.nrBins = emThresholds.size();
197  m_l1HistLimits.lowerBinValue = emThresholds.at(0);
198 
199  // FIXME high edge retrieval in the scale definition
200  // now, last bin has the same width like the last but one
202  = emThresholds[m_l1HistLimits.nrBins - 1]
203  + (emThresholds[m_l1HistLimits.nrBins - 1]
204  - emThresholds[m_l1HistLimits.nrBins - 2]);
205 
207 
208  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
210  = static_cast<float>(emThresholds[iBin]);
211 
212  }
213 
214  // set last bin upper edge
217 
218  } else if (quantity == "eta" || quantity == "phi") {
219  edm::ESHandle<L1CaloGeometry> caloGeomESH;
220  m_evSetup.get<L1CaloGeometryRecord>().get(caloGeomESH);
221  const L1CaloGeometry* caloGeomScales = caloGeomESH.product();
222 
223  if (quantity == "eta") {
225  = 2 * (caloGeomScales->numberGctCentralEtaBinsPerHalf()
226  + caloGeomScales->numberGctForwardEtaBinsPerHalf());
228  = caloGeomScales->globalEtaBinLowEdge(0);
230  = caloGeomScales->globalEtaBinHighEdge(
231  m_l1HistLimits.nrBins - 1);
232 
234 
235  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
237  = caloGeomScales->globalEtaBinLowEdge(iBin);
238  }
239 
240  // set last bin upper edge
243 
244 
245 
246  } else {
247 
249  = caloGeomScales->numberGctEmJetPhiBins();
251  + 1);
252 
253  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
254 
256  caloGeomScales->emJetPhiBinLowEdge(iBin));
257 
258  // treat correctly the 10 deg anti-clockwise rotation
259  if (rad2deg(caloGeomScales->emJetPhiBinHighEdge(iBin))
260  < m_l1HistLimits.binThresholds[iBin]) {
262  = m_l1HistLimits.binThresholds[iBin] - 360.;
263  }
264 
265  }
266 
269 
270  // last bin upper limit
272  caloGeomScales->emJetPhiBinHighEdge(
273  m_l1HistLimits.nrBins - 1));
274 
277 
278  }
279 
280  }
281 
282  }
283  break;
284  case CenJet:
285  case ForJet:
286  case TauJet: {
287  // common scales for all jets
288  if (quantity == "ET") {
290  m_evSetup.get<L1JetEtScaleRcd>().get(jetScale);
291 
292  std::vector<double> jetThresholds = jetScale->getThresholds();
293  m_l1HistLimits.nrBins = jetThresholds.size();
294  m_l1HistLimits.lowerBinValue = jetThresholds.at(0);
295 
296  // FIXME high edge retrieval in the scale definition
297  // now, last bin has the same width like the last but one
299  = jetThresholds[m_l1HistLimits.nrBins - 1]
300  + (jetThresholds[m_l1HistLimits.nrBins - 1]
301  - jetThresholds[m_l1HistLimits.nrBins - 2]);
302 
304 
305  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
307  = static_cast<float>(jetThresholds[iBin]);
308 
309  }
310 
311  // set last bin upper edge
314 
315  } else if (quantity == "eta" || quantity == "phi") {
316  edm::ESHandle<L1CaloGeometry> caloGeomESH;
317  m_evSetup.get<L1CaloGeometryRecord>().get(caloGeomESH);
318  const L1CaloGeometry* caloGeomScales = caloGeomESH.product();
319 
320  if (quantity == "eta") {
322  = 2 * (caloGeomScales->numberGctCentralEtaBinsPerHalf()
323  + caloGeomScales->numberGctForwardEtaBinsPerHalf());
325  = caloGeomScales->globalEtaBinLowEdge(0);
327  = caloGeomScales->globalEtaBinHighEdge(
328  m_l1HistLimits.nrBins - 1);
329 
331 
332  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
334  = caloGeomScales->globalEtaBinLowEdge(iBin);
335  }
336 
337  // set last bin upper edge
340 
341  } else {
342 
344  = caloGeomScales->numberGctEmJetPhiBins();
346  + 1);
347 
348  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
349 
351  caloGeomScales->emJetPhiBinLowEdge(iBin));
352 
353  // treat correctly the 10 deg anti-clockwise rotation
354  if (rad2deg(caloGeomScales->emJetPhiBinHighEdge(iBin))
355  < m_l1HistLimits.binThresholds[iBin]) {
357  = m_l1HistLimits.binThresholds[iBin] - 360.;
358  }
359 
360  }
361 
364 
365  // last bin upper limit
367  caloGeomScales->emJetPhiBinHighEdge(
368  m_l1HistLimits.nrBins - 1));
369 
372 
373  }
374 
375  }
376  }
377  break;
378  case ETM: {
379  if (quantity == "ET") {
380 
381  edm::ESHandle<L1CaloEtScale> etMissScale;
382  m_evSetup.get<L1JetEtScaleRcd>().get(etMissScale);
383 
384  const double etSumLSB = etMissScale->linearLsb() ;
385 
387 
390  * etSumLSB;
391 
393 
394  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
395  m_l1HistLimits.binThresholds[iBin] = iBin * etSumLSB;
396 
397  }
398 
399  // set last bin upper edge
402 
403  } else if (quantity == "eta" || quantity == "phi") {
404  edm::ESHandle<L1CaloGeometry> caloGeomESH;
405  m_evSetup.get<L1CaloGeometryRecord>().get(caloGeomESH);
406  const L1CaloGeometry* caloGeomScales = caloGeomESH.product();
407 
408  if (quantity == "eta") {
409 
410  // do nothing, eta is not defined for ETM
411 
412  } else {
414  = caloGeomScales->numberGctEtSumPhiBins();
416  caloGeomScales->etSumPhiBinLowEdge(0));
418  caloGeomScales->etSumPhiBinHighEdge(
419  m_l1HistLimits.nrBins - 1));
420 
422  + 1);
423 
424  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
426  caloGeomScales->etSumPhiBinLowEdge(iBin));
427 
428  }
429 
430  // last bin upper limit
433 
434  }
435 
436  }
437 
438  }
439  break;
440  case ETT: {
441  if (quantity == "ET") {
442 
443  edm::ESHandle<L1CaloEtScale> etMissScale;
444  m_evSetup.get<L1JetEtScaleRcd>().get(etMissScale);
445 
446  const double etSumLSB = etMissScale->linearLsb() ;
447 
449 
452  * etSumLSB;
453 
455 
456  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
457  m_l1HistLimits.binThresholds[iBin] = iBin * etSumLSB;
458 
459  }
460 
461  // set last bin upper edge
464 
465  } else if (quantity == "eta" || quantity == "phi") {
466 
467  // do nothing, eta and phi are not defined for ETT
468 
469  }
470 
471  }
472  break;
473  case HTT: {
474  if (quantity == "ET") {
475 
476  edm::ESHandle< L1GctJetFinderParams > jetFinderParams ;
477  m_evSetup.get< L1GctJetFinderParamsRcd >().get( jetFinderParams ) ;
478  double htSumLSB = jetFinderParams->getHtLsbGeV();
479 
481 
484  * htSumLSB;
485 
487 
488  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
489  m_l1HistLimits.binThresholds[iBin] = iBin * htSumLSB;
490 
491  }
492 
493  // set last bin upper edge
496 
497  } else if (quantity == "eta" || quantity == "phi") {
498 
499  // do nothing, eta and phi are not defined for HTT
500 
501  }
502  }
503  break;
504  case HTM: {
505  if (quantity == "ET") {
506  edm::ESHandle<L1CaloEtScale> htMissScale;
507  m_evSetup.get<L1HtMissScaleRcd>().get(htMissScale);
508 
509  const std::vector<double>& htThresholds =
510  htMissScale->getThresholds();
511  m_l1HistLimits.nrBins = htThresholds.size();
512  m_l1HistLimits.lowerBinValue = htThresholds[0];
513 
514  // FIXME high edge retrieval in the scale definition
515  // now, last bin has the same width like the last but one
517  = htThresholds[m_l1HistLimits.nrBins - 1]
518  + (htThresholds[m_l1HistLimits.nrBins - 1]
519  - htThresholds[m_l1HistLimits.nrBins - 2]);
520 
522 
523  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
525  = static_cast<float>(htThresholds[iBin]);
526 
527  }
528 
529  // set last bin upper edge
532 
533  } else if (quantity == "eta" || quantity == "phi") {
534  edm::ESHandle<L1CaloGeometry> caloGeomESH;
535  m_evSetup.get<L1CaloGeometryRecord>().get(caloGeomESH);
536  const L1CaloGeometry* caloGeomScales = caloGeomESH.product();
537 
538  if (quantity == "eta") {
539 
540  // do nothing, eta is not defined for HTM
541 
542  } else {
544  = caloGeomScales->numberGctHtSumPhiBins();
546  caloGeomScales->htSumPhiBinLowEdge(0));
548  caloGeomScales->htSumPhiBinHighEdge(
549  m_l1HistLimits.nrBins - 1));
550 
552  + 1);
553 
554  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
556  caloGeomScales->htSumPhiBinLowEdge(iBin));
557 
558  }
559 
560  // last bin upper limit
563 
564  }
565 
566  }
567  }
568  break;
569  case JetCounts: {
570 
571  }
572  break;
573  case HfBitCounts: {
574  // there are no scales for HfBitCounts, so one implements a fixed scale
575  // use same values as GCT for 3 bits
576  const unsigned int R3BINS = 8;
577  const float R3MIN = -0.5;
578  const float R3MAX = 7.5;
579 
581  = R3BINS;
583  = R3MIN;
585  = R3MAX;
586 
588  + 1);
589 
590  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
592  = R3MIN + iBin*(R3MAX - R3MIN)/R3BINS;
593 
594  }
595 
596  // last bin upper limit
599 
600 
601 
602  }
603  break;
604  case HfRingEtSums: {
605  if (quantity == "ET") {
606  edm::ESHandle<L1CaloEtScale> hfRingEtScale;
607  m_evSetup.get<L1HfRingEtScaleRcd>().get(hfRingEtScale);
608 
609  const std::vector<double>& hfRingEtThresholds =
610  hfRingEtScale->getThresholds();
611  m_l1HistLimits.nrBins = hfRingEtThresholds.size();
612  m_l1HistLimits.lowerBinValue = hfRingEtThresholds[0];
613 
614  // FIXME high edge retrieval in the scale definition
615  // now, last bin has the same width like the last but one
617  = hfRingEtThresholds[m_l1HistLimits.nrBins - 1]
618  + (hfRingEtThresholds[m_l1HistLimits.nrBins - 1]
619  - hfRingEtThresholds[m_l1HistLimits.nrBins - 2]);
620 
622 
623  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
625  = static_cast<float>(hfRingEtThresholds[iBin]);
626 
627  }
628 
629  // set last bin upper edge
632 
633  } else if (quantity == "eta" || quantity == "phi") {
634 
635  // do nothing, eta and phi are not defined for HfRingEtSums
636  }
637  }
638  break;
639  case TechTrig:
640  case Castor:
641  case BPTX:
642  default: {
643 
644  // do nothing, for these cases ET/PT, eta and phi are not defined
645 
646  }
647  break;
648  }
649 
650 }
651 
653  const L1GtObject& l1GtObject, const std::string& quantity) {
654 
655  getHistLimits(l1GtObject, quantity);
656 
657  if (edm::isDebugEnabled()) {
658  LogDebug("L1GetHistLimits") << "\n Histogram limits for L1GtObject "
659  << l1GtObject << " and quantity " << quantity
660  << "\n Number of bins: " << m_l1HistLimits.nrBins
661  << "\n Lower limit of first bin: "
663  << "\n Upper limit of last bin: "
664  << m_l1HistLimits.upperBinValue << std::endl;
665 
666  int binThreshSize = static_cast<int>(m_l1HistLimits.binThresholds.size());
667 
668  if (binThreshSize != (m_l1HistLimits.nrBins + 1)) {
669 
670  LogTrace("L1GetHistLimits")
671  << "\n Warning: inconsistent nrBins and binThresholds size"
672  << "\n Number of bins nrBins = " << m_l1HistLimits.nrBins
673  << "\n binThresholds size = " << binThreshSize
674  << "\n Please fix the L1GetLimits class.\n\n" << std::endl;
675 
676  }
677 
678  for (int iBin = 0; iBin < binThreshSize; ++iBin) {
679  LogTrace("L1GetHistLimits") << " Bin " << std::right
680  << std::setw(5) << iBin << ": "
681  << m_l1HistLimits.binThresholds[iBin] << std::endl;
682 
683  }
684  }
685 
686  return m_l1HistLimits;
687 
688 }
689 
690 
692  const L1GtObject& l1GtObject, const std::string& quantity,
693  const double histMinValue, const double histMaxValue) {
694 
695  getHistLimits(l1GtObject, quantity);
696 
697  bool foundLowerBinValue = false;
698  bool foundUpperBinValue = false;
699 
700  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
701  if (m_l1HistLimits.binThresholds[iBin] <= histMinValue) {
703  foundLowerBinValue = true;
704  break;
705  }
706  }
707 
708  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
709  if (m_l1HistLimits.binThresholds[iBin] > histMaxValue) {
711  foundUpperBinValue = true;
712  break;
713  }
714  }
715 
716  if (foundLowerBinValue && foundUpperBinValue) {
717 
718  int countBins = -1;
719  std::vector<float> binThresh;
720  binThresh.reserve(m_l1HistLimits.binThresholds.size());
721 
722  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
723  if ((m_l1HistLimits.binThresholds[iBin] >= histMinValue)
724  && m_l1HistLimits.binThresholds[iBin] < histMaxValue) {
727 
728  countBins++;
729  binThresh.push_back(m_l1HistLimits.binThresholds[iBin]);
730 
731  }
732  }
733 
734  m_l1HistLimits.nrBins = countBins;
736  m_l1HistLimits.binThresholds = binThresh;
737 
738  // FIXME last bin untested.
739 
740  } else {
745 
746  LogDebug("L1GetHistLimits") << "\n Histogram limits for L1GtObject"
747  << l1GtObject << " and quantity " << quantity
748  << " within the required range [" << histMinValue << ", "
749  << histMaxValue << "] not found."
750  << "\n The range is not included in the original histogram range."
751  << std::endl;
752 
753  return m_l1HistLimits;
754 
755  }
756 
757  if (edm::isDebugEnabled()) {
758  LogDebug("L1GetHistLimits") << "\n Histogram limits for L1GtObject"
759  << l1GtObject << " and quantity " << quantity
760  << "\n Number of bins: " << m_l1HistLimits.nrBins
761  << "\n Lower limit of first bin: "
763  << "\n Upper limit of last bin: "
764  << m_l1HistLimits.upperBinValue << std::endl;
765 
766  int binThreshSize = static_cast<int>(m_l1HistLimits.binThresholds.size());
767 
768  if (binThreshSize != (m_l1HistLimits.nrBins + 1)) {
769 
770  LogTrace("L1GetHistLimits")
771  << "\n Warning: inconsistent nrBins and binThresholds size"
772  << "\n Number of bins nrBins = " << m_l1HistLimits.nrBins
773  << "\n binThresholds size = " << binThreshSize
774  << "\n Please fix the L1GetLimits class.\n\n" << std::endl;
775 
776  }
777 
778  for (int iBin = 0; iBin < binThreshSize; ++iBin) {
779  LogTrace("L1GetHistLimits") << " Bin " << std::right
780  << std::setw(5) << iBin << ": "
781  << m_l1HistLimits.binThresholds[iBin] << std::endl;
782 
783  }
784  }
785 
786 
787  return m_l1HistLimits;
788 
789 }
790 
791 
792 const int L1GetHistLimits::l1HistNrBins(const L1GtObject& l1GtObject,
793  const std::string& quantity) {
794 
795  getHistLimits(l1GtObject, quantity);
796  return m_l1HistLimits.nrBins;
797 
798 }
799 
800 const double L1GetHistLimits::l1HistLowerBinValue(const L1GtObject& l1GtObject,
801  const std::string& quantity) {
802 
803  getHistLimits(l1GtObject, quantity);
805 
806 }
807 
808 const double L1GetHistLimits::l1HistUpperBinValue(const L1GtObject& l1GtObject,
809  const std::string& quantity) {
810 
811  getHistLimits(l1GtObject, quantity);
813 
814 }
815 
816 const std::vector<float>& L1GetHistLimits::l1HistBinThresholds(
817  const L1GtObject& l1GtObject, const std::string& quantity) {
818 
819  getHistLimits(l1GtObject, quantity);
821 
822 }
#define LogDebug(id)
double globalEtaBinLowEdge(unsigned int globalEtaIndex) const
bool isDebugEnabled()
unsigned int numberGctForwardEtaBinsPerHalf() const
void getHistLimits(const L1GtObject &l1GtObject, const std::string &quantity)
const edm::EventSetup & m_evSetup
Definition: L1GtObject.h:41
L1HistLimits m_l1HistLimits
all limits for a histogram
unsigned int numberGctHtSumPhiBins() const
double htSumPhiBinLowEdge(unsigned int phiIndex) const
const double l1HistUpperBinValue(const L1GtObject &l1GtObject, const std::string &quantity)
Definition: L1GtObject.h:38
unsigned int numberGctEtSumPhiBins() const
const std::vector< float > & l1HistBinThresholds(const L1GtObject &l1GtObject, const std::string &quantity)
unsigned int numberGctEmJetPhiBins() const
const int l1HistNrBins(const L1GtObject &l1GtObject, const std::string &quantity)
unsigned int numberGctCentralEtaBinsPerHalf() const
virtual ~L1GetHistLimits()
Definition: L1GtObject.h:40
const unsigned int R3BINS
Definition: L1TGCT.cc:226
int j
Definition: DBlmapReader.cc:9
#define LogTrace(id)
std::vector< float > binThresholds
const double rad2deg(const double &)
convert phi from rad (-pi, pi] to deg (0, 360)
Definition: L1GtObject.h:32
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
double globalEtaBinHighEdge(unsigned int globalEtaIndex) const
double etSumPhiBinLowEdge(unsigned int phiIndex) const
Definition: L1GtObject.h:39
double emJetPhiBinLowEdge(unsigned int phiIndex) const
double htSumPhiBinHighEdge(unsigned int phiIndex) const
L1GetHistLimits(const edm::EventSetup &evSetup)
const float R3MAX
Definition: L1TGCT.cc:228
const double l1HistLowerBinValue(const L1GtObject &l1GtObject, const std::string &quantity)
double emJetPhiBinHighEdge(unsigned int phiIndex) const
double etSumPhiBinHighEdge(unsigned int phiIndex) const
const float R3MIN
Definition: L1TGCT.cc:227
const L1HistLimits & l1HistLimits(const L1GtObject &l1GtObject, const std::string &quantity)