test
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 
15 // this class header
17 
18 // system include files
19 #include <iostream>
20 #include <iomanip>
21 #include <string>
22 
23 // user include files
26 
27 
31 
34 
35 // constructor
37  m_evSetup(evSetup) {
38 
39  //
40 
41 }
42 
43 // destructor
45 
46  // empty
47 
48 }
49 
51  const std::string& quantity) {
52 
57 
58 
59  // number of objects is independent of the object type
60  // and hardcoded in the actual version
61  if (quantity == "NrObjects") {
62 
66 
68 
69  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
74 
75  }
76 
77  // set last bin upper edge
80 
81  return;
82 
83  }
84 
85  switch (l1GtObject) {
86  case Mu: {
87 
88  if (quantity == "PT") {
89 
91  m_evSetup.get<L1MuTriggerPtScaleRcd>().get(muPtScale);
92 
93  m_l1HistLimits.nrBins = muPtScale->getPtScale()->getNBins();
95  = muPtScale->getPtScale()->getScaleMin();
97  = muPtScale->getPtScale()->getScaleMax();
98 
100 
101  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
103  = muPtScale->getPtScale()->getValue(iBin);
104 
105  }
106 
107  // last limit for muon is set too high (10^6) - resize the last bin
108 
109  float lastBinSize = m_l1HistLimits.upperBinValue
111 
112  // limit the size of the last bin to maximum 200 GeV
113  float maxLaxtBinsize = 200;
114  if (lastBinSize >= maxLaxtBinsize) {
119  LogDebug("L1GetHistLimits")
120  << "\n L1ExtraMuon: PT histogram"
121  << "\nm_l1HistLimits.upperBinValue truncated to = "
122  << m_l1HistLimits.upperBinValue << std::endl;
123  }
124 
125  // set last bin upper edge
128 
129  } else if (quantity == "eta" || quantity == "phi") {
131  m_evSetup.get<L1MuTriggerScalesRcd>().get(muScales);
132 
133  if (quantity == "eta") {
134  // eta scale defined for positive values - need to be symmetrized
135  int histNrBinsHalf = muScales->getGMTEtaScale()->getNBins();
137  = muScales->getGMTEtaScale()->getScaleMin();
139  = muScales->getGMTEtaScale()->getScaleMax();
140 
141  m_l1HistLimits.nrBins = 2 * histNrBinsHalf;
144 
146 
147  int iBin = 0;
148  for (int j = histNrBinsHalf; j > 0; j--, iBin++) {
149  m_l1HistLimits.binThresholds[iBin] = (-1)
150  * muScales->getGMTEtaScale()->getValue(j);
151  }
152  for (int j = 0; j <= histNrBinsHalf; j++, iBin++) {
154  = muScales->getGMTEtaScale()->getValue(j);
155  }
156 
157  // set last bin upper edge
160 
161  } else {
162  m_l1HistLimits.nrBins = muScales->getPhiScale()->getNBins();
164  muScales->getPhiScale()->getScaleMin());
166  muScales->getPhiScale()->getScaleMax());
167 
169  + 1);
170 
171  for (int iBin = 0; iBin <= m_l1HistLimits.nrBins; iBin++) {
173  muScales->getPhiScale()->getValue(iBin));
174  }
175 
176  // set last bin upper edge
179 
180  }
181 
182  }
183 
184  }
185  break;
186  case NoIsoEG:
187  case IsoEG: {
188  // common scales for NoIsoEG and IsoEG
189  if (quantity == "ET") {
191  m_evSetup.get<L1EmEtScaleRcd>().get(emScale);
192 
193  std::vector<double> emThresholds = emScale->getThresholds();
194  m_l1HistLimits.nrBins = emThresholds.size();
195  m_l1HistLimits.lowerBinValue = emThresholds.at(0);
196 
197  // FIXME high edge retrieval in the scale definition
198  // now, last bin has the same width like the last but one
200  = emThresholds[m_l1HistLimits.nrBins - 1]
201  + (emThresholds[m_l1HistLimits.nrBins - 1]
202  - emThresholds[m_l1HistLimits.nrBins - 2]);
203 
205 
206  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
208  = static_cast<float>(emThresholds[iBin]);
209 
210  }
211 
212  // set last bin upper edge
215 
216  } else if (quantity == "eta" || quantity == "phi") {
217  edm::ESHandle<L1CaloGeometry> caloGeomESH;
218  m_evSetup.get<L1CaloGeometryRecord>().get(caloGeomESH);
219  const L1CaloGeometry* caloGeomScales = caloGeomESH.product();
220 
221  if (quantity == "eta") {
223  = 2 * (caloGeomScales->numberGctCentralEtaBinsPerHalf()
224  + caloGeomScales->numberGctForwardEtaBinsPerHalf());
226  = caloGeomScales->globalEtaBinLowEdge(0);
228  = caloGeomScales->globalEtaBinHighEdge(
229  m_l1HistLimits.nrBins - 1);
230 
232 
233  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
235  = caloGeomScales->globalEtaBinLowEdge(iBin);
236  }
237 
238  // set last bin upper edge
241 
242 
243 
244  } else {
245 
247  = caloGeomScales->numberGctEmJetPhiBins();
249  + 1);
250 
251  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
252 
254  caloGeomScales->emJetPhiBinLowEdge(iBin));
255 
256  // treat correctly the 10 deg anti-clockwise rotation
257  if (rad2deg(caloGeomScales->emJetPhiBinHighEdge(iBin))
258  < m_l1HistLimits.binThresholds[iBin]) {
260  = m_l1HistLimits.binThresholds[iBin] - 360.;
261  }
262 
263  }
264 
267 
268  // last bin upper limit
270  caloGeomScales->emJetPhiBinHighEdge(
271  m_l1HistLimits.nrBins - 1));
272 
275 
276  }
277 
278  }
279 
280  }
281  break;
282  case CenJet:
283  case ForJet:
284  case TauJet: {
285  // common scales for all jets
286  if (quantity == "ET") {
288  m_evSetup.get<L1JetEtScaleRcd>().get(jetScale);
289 
290  std::vector<double> jetThresholds = jetScale->getThresholds();
291  m_l1HistLimits.nrBins = jetThresholds.size();
292  m_l1HistLimits.lowerBinValue = jetThresholds.at(0);
293 
294  // FIXME high edge retrieval in the scale definition
295  // now, last bin has the same width like the last but one
297  = jetThresholds[m_l1HistLimits.nrBins - 1]
298  + (jetThresholds[m_l1HistLimits.nrBins - 1]
299  - jetThresholds[m_l1HistLimits.nrBins - 2]);
300 
302 
303  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
305  = static_cast<float>(jetThresholds[iBin]);
306 
307  }
308 
309  // set last bin upper edge
312 
313  } else if (quantity == "eta" || quantity == "phi") {
314  edm::ESHandle<L1CaloGeometry> caloGeomESH;
315  m_evSetup.get<L1CaloGeometryRecord>().get(caloGeomESH);
316  const L1CaloGeometry* caloGeomScales = caloGeomESH.product();
317 
318  if (quantity == "eta") {
320  = 2 * (caloGeomScales->numberGctCentralEtaBinsPerHalf()
321  + caloGeomScales->numberGctForwardEtaBinsPerHalf());
323  = caloGeomScales->globalEtaBinLowEdge(0);
325  = caloGeomScales->globalEtaBinHighEdge(
326  m_l1HistLimits.nrBins - 1);
327 
329 
330  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
332  = caloGeomScales->globalEtaBinLowEdge(iBin);
333  }
334 
335  // set last bin upper edge
338 
339  } else {
340 
342  = caloGeomScales->numberGctEmJetPhiBins();
344  + 1);
345 
346  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
347 
349  caloGeomScales->emJetPhiBinLowEdge(iBin));
350 
351  // treat correctly the 10 deg anti-clockwise rotation
352  if (rad2deg(caloGeomScales->emJetPhiBinHighEdge(iBin))
353  < m_l1HistLimits.binThresholds[iBin]) {
355  = m_l1HistLimits.binThresholds[iBin] - 360.;
356  }
357 
358  }
359 
362 
363  // last bin upper limit
365  caloGeomScales->emJetPhiBinHighEdge(
366  m_l1HistLimits.nrBins - 1));
367 
370 
371  }
372 
373  }
374  }
375  break;
376  case ETM: {
377  if (quantity == "ET") {
378 
379  edm::ESHandle<L1CaloEtScale> etMissScale;
380  m_evSetup.get<L1JetEtScaleRcd>().get(etMissScale);
381 
382  const double etSumLSB = etMissScale->linearLsb() ;
383 
385 
388  * etSumLSB;
389 
391 
392  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
393  m_l1HistLimits.binThresholds[iBin] = iBin * etSumLSB;
394 
395  }
396 
397  // set last bin upper edge
400 
401  } else if (quantity == "eta" || quantity == "phi") {
402  edm::ESHandle<L1CaloGeometry> caloGeomESH;
403  m_evSetup.get<L1CaloGeometryRecord>().get(caloGeomESH);
404  const L1CaloGeometry* caloGeomScales = caloGeomESH.product();
405 
406  if (quantity == "eta") {
407 
408  // do nothing, eta is not defined for ETM
409 
410  } else {
412  = caloGeomScales->numberGctEtSumPhiBins();
414  caloGeomScales->etSumPhiBinLowEdge(0));
416  caloGeomScales->etSumPhiBinHighEdge(
417  m_l1HistLimits.nrBins - 1));
418 
420  + 1);
421 
422  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
424  caloGeomScales->etSumPhiBinLowEdge(iBin));
425 
426  }
427 
428  // last bin upper limit
431 
432  }
433 
434  }
435 
436  }
437  break;
438  case ETT: {
439  if (quantity == "ET") {
440 
441  edm::ESHandle<L1CaloEtScale> etMissScale;
442  m_evSetup.get<L1JetEtScaleRcd>().get(etMissScale);
443 
444  const double etSumLSB = etMissScale->linearLsb() ;
445 
447 
450  * etSumLSB;
451 
453 
454  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
455  m_l1HistLimits.binThresholds[iBin] = iBin * etSumLSB;
456 
457  }
458 
459  // set last bin upper edge
462 
463  } else if (quantity == "eta" || quantity == "phi") {
464 
465  // do nothing, eta and phi are not defined for ETT
466 
467  }
468 
469  }
470  break;
471  case HTT: {
472  if (quantity == "ET") {
473 
474  edm::ESHandle< L1GctJetFinderParams > jetFinderParams ;
475  m_evSetup.get< L1GctJetFinderParamsRcd >().get( jetFinderParams ) ;
476  double htSumLSB = jetFinderParams->getHtLsbGeV();
477 
479 
482  * htSumLSB;
483 
485 
486  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
487  m_l1HistLimits.binThresholds[iBin] = iBin * htSumLSB;
488 
489  }
490 
491  // set last bin upper edge
494 
495  } else if (quantity == "eta" || quantity == "phi") {
496 
497  // do nothing, eta and phi are not defined for HTT
498 
499  }
500  }
501  break;
502  case HTM: {
503  if (quantity == "ET") {
504  edm::ESHandle<L1CaloEtScale> htMissScale;
505  m_evSetup.get<L1HtMissScaleRcd>().get(htMissScale);
506 
507  const std::vector<double>& htThresholds =
508  htMissScale->getThresholds();
509  m_l1HistLimits.nrBins = htThresholds.size();
510  m_l1HistLimits.lowerBinValue = htThresholds[0];
511 
512  // FIXME high edge retrieval in the scale definition
513  // now, last bin has the same width like the last but one
515  = htThresholds[m_l1HistLimits.nrBins - 1]
516  + (htThresholds[m_l1HistLimits.nrBins - 1]
517  - htThresholds[m_l1HistLimits.nrBins - 2]);
518 
520 
521  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
523  = static_cast<float>(htThresholds[iBin]);
524 
525  }
526 
527  // set last bin upper edge
530 
531  } else if (quantity == "eta" || quantity == "phi") {
532  edm::ESHandle<L1CaloGeometry> caloGeomESH;
533  m_evSetup.get<L1CaloGeometryRecord>().get(caloGeomESH);
534  const L1CaloGeometry* caloGeomScales = caloGeomESH.product();
535 
536  if (quantity == "eta") {
537 
538  // do nothing, eta is not defined for HTM
539 
540  } else {
542  = caloGeomScales->numberGctHtSumPhiBins();
544  caloGeomScales->htSumPhiBinLowEdge(0));
546  caloGeomScales->htSumPhiBinHighEdge(
547  m_l1HistLimits.nrBins - 1));
548 
550  + 1);
551 
552  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
554  caloGeomScales->htSumPhiBinLowEdge(iBin));
555 
556  }
557 
558  // last bin upper limit
561 
562  }
563 
564  }
565  }
566  break;
567  case JetCounts: {
568 
569  }
570  break;
571  case HfBitCounts: {
572  // there are no scales for HfBitCounts, so one implements a fixed scale
573  // use same values as GCT for 3 bits
574  const unsigned int R3BINS = 8;
575  const float R3MIN = -0.5;
576  const float R3MAX = 7.5;
577 
579  = R3BINS;
581  = R3MIN;
583  = R3MAX;
584 
586  + 1);
587 
588  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
590  = R3MIN + iBin*(R3MAX - R3MIN)/R3BINS;
591 
592  }
593 
594  // last bin upper limit
597 
598 
599 
600  }
601  break;
602  case HfRingEtSums: {
603  if (quantity == "ET") {
604  edm::ESHandle<L1CaloEtScale> hfRingEtScale;
605  m_evSetup.get<L1HfRingEtScaleRcd>().get(hfRingEtScale);
606 
607  const std::vector<double>& hfRingEtThresholds =
608  hfRingEtScale->getThresholds();
609  m_l1HistLimits.nrBins = hfRingEtThresholds.size();
610  m_l1HistLimits.lowerBinValue = hfRingEtThresholds[0];
611 
612  // FIXME high edge retrieval in the scale definition
613  // now, last bin has the same width like the last but one
615  = hfRingEtThresholds[m_l1HistLimits.nrBins - 1]
616  + (hfRingEtThresholds[m_l1HistLimits.nrBins - 1]
617  - hfRingEtThresholds[m_l1HistLimits.nrBins - 2]);
618 
620 
621  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
623  = static_cast<float>(hfRingEtThresholds[iBin]);
624 
625  }
626 
627  // set last bin upper edge
630 
631  } else if (quantity == "eta" || quantity == "phi") {
632 
633  // do nothing, eta and phi are not defined for HfRingEtSums
634  }
635  }
636  break;
637  case TechTrig:
638  case Castor:
639  case BPTX:
640  default: {
641 
642  // do nothing, for these cases ET/PT, eta and phi are not defined
643 
644  }
645  break;
646  }
647 
648 }
649 
651  const L1GtObject& l1GtObject, const std::string& quantity) {
652 
653  getHistLimits(l1GtObject, quantity);
654 
655  if (edm::isDebugEnabled()) {
656  LogDebug("L1GetHistLimits") << "\n Histogram limits for L1GtObject "
657  << l1GtObject << " and quantity " << quantity
658  << "\n Number of bins: " << m_l1HistLimits.nrBins
659  << "\n Lower limit of first bin: "
661  << "\n Upper limit of last bin: "
662  << m_l1HistLimits.upperBinValue << std::endl;
663 
664  int binThreshSize = static_cast<int>(m_l1HistLimits.binThresholds.size());
665 
666  if (binThreshSize != (m_l1HistLimits.nrBins + 1)) {
667 
668  LogTrace("L1GetHistLimits")
669  << "\n Warning: inconsistent nrBins and binThresholds size"
670  << "\n Number of bins nrBins = " << m_l1HistLimits.nrBins
671  << "\n binThresholds size = " << binThreshSize
672  << "\n Please fix the L1GetLimits class.\n\n" << std::endl;
673 
674  }
675 
676  for (int iBin = 0; iBin < binThreshSize; ++iBin) {
677  LogTrace("L1GetHistLimits") << " Bin " << std::right
678  << std::setw(5) << iBin << ": "
679  << m_l1HistLimits.binThresholds[iBin] << std::endl;
680 
681  }
682  }
683 
684  return m_l1HistLimits;
685 
686 }
687 
688 
690  const L1GtObject& l1GtObject, const std::string& quantity,
691  const double histMinValue, const double histMaxValue) {
692 
693  getHistLimits(l1GtObject, quantity);
694 
695  bool foundLowerBinValue = false;
696  bool foundUpperBinValue = false;
697 
698  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
699  if (m_l1HistLimits.binThresholds[iBin] <= histMinValue) {
701  foundLowerBinValue = true;
702  break;
703  }
704  }
705 
706  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
707  if (m_l1HistLimits.binThresholds[iBin] > histMaxValue) {
709  foundUpperBinValue = true;
710  break;
711  }
712  }
713 
714  if (foundLowerBinValue && foundUpperBinValue) {
715 
716  int countBins = -1;
717  std::vector<float> binThresh;
718  binThresh.reserve(m_l1HistLimits.binThresholds.size());
719 
720  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
721  if ((m_l1HistLimits.binThresholds[iBin] >= histMinValue)
722  && m_l1HistLimits.binThresholds[iBin] < histMaxValue) {
725 
726  countBins++;
727  binThresh.push_back(m_l1HistLimits.binThresholds[iBin]);
728 
729  }
730  }
731 
732  m_l1HistLimits.nrBins = countBins;
734  m_l1HistLimits.binThresholds = binThresh;
735 
736  // FIXME last bin untested.
737 
738  } else {
743 
744  LogDebug("L1GetHistLimits") << "\n Histogram limits for L1GtObject"
745  << l1GtObject << " and quantity " << quantity
746  << " within the required range [" << histMinValue << ", "
747  << histMaxValue << "] not found."
748  << "\n The range is not included in the original histogram range."
749  << std::endl;
750 
751  return m_l1HistLimits;
752 
753  }
754 
755  if (edm::isDebugEnabled()) {
756  LogDebug("L1GetHistLimits") << "\n Histogram limits for L1GtObject"
757  << l1GtObject << " and quantity " << quantity
758  << "\n Number of bins: " << m_l1HistLimits.nrBins
759  << "\n Lower limit of first bin: "
761  << "\n Upper limit of last bin: "
762  << m_l1HistLimits.upperBinValue << std::endl;
763 
764  int binThreshSize = static_cast<int>(m_l1HistLimits.binThresholds.size());
765 
766  if (binThreshSize != (m_l1HistLimits.nrBins + 1)) {
767 
768  LogTrace("L1GetHistLimits")
769  << "\n Warning: inconsistent nrBins and binThresholds size"
770  << "\n Number of bins nrBins = " << m_l1HistLimits.nrBins
771  << "\n binThresholds size = " << binThreshSize
772  << "\n Please fix the L1GetLimits class.\n\n" << std::endl;
773 
774  }
775 
776  for (int iBin = 0; iBin < binThreshSize; ++iBin) {
777  LogTrace("L1GetHistLimits") << " Bin " << std::right
778  << std::setw(5) << iBin << ": "
779  << m_l1HistLimits.binThresholds[iBin] << std::endl;
780 
781  }
782  }
783 
784 
785  return m_l1HistLimits;
786 
787 }
788 
789 
790 const int L1GetHistLimits::l1HistNrBins(const L1GtObject& l1GtObject,
791  const std::string& quantity) {
792 
793  getHistLimits(l1GtObject, quantity);
794  return m_l1HistLimits.nrBins;
795 
796 }
797 
798 const double L1GetHistLimits::l1HistLowerBinValue(const L1GtObject& l1GtObject,
799  const std::string& quantity) {
800 
801  getHistLimits(l1GtObject, quantity);
803 
804 }
805 
806 const double L1GetHistLimits::l1HistUpperBinValue(const L1GtObject& l1GtObject,
807  const std::string& quantity) {
808 
809  getHistLimits(l1GtObject, quantity);
811 
812 }
813 
814 const std::vector<float>& L1GetHistLimits::l1HistBinThresholds(
815  const L1GtObject& l1GtObject, const std::string& quantity) {
816 
817  getHistLimits(l1GtObject, quantity);
819 
820 }
#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:39
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:36
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:38
const unsigned int R3BINS
Definition: L1TGCT.cc:44
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:30
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
double globalEtaBinHighEdge(unsigned int globalEtaIndex) const
double etSumPhiBinLowEdge(unsigned int phiIndex) const
Definition: L1GtObject.h:37
double emJetPhiBinLowEdge(unsigned int phiIndex) const
double htSumPhiBinHighEdge(unsigned int phiIndex) const
L1GetHistLimits(const edm::EventSetup &evSetup)
const float R3MAX
Definition: L1TGCT.cc:46
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:45
const L1HistLimits & l1HistLimits(const L1GtObject &l1GtObject, const std::string &quantity)