CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 
30 
32 
34  : m_muPTScaleToken(iC.esConsumes<edm::Transition::BeginRun>()),
35  m_etScaleToken(iC.esConsumes<edm::Transition::BeginRun>()),
36  m_jetScaleToken(iC.esConsumes<edm::Transition::BeginRun>()),
37  m_jetFinderParamsToken(iC.esConsumes<edm::Transition::BeginRun>()),
38  m_htMissScaleToken(iC.esConsumes<edm::Transition::BeginRun>()),
39  m_hfRingEtScaleToken(iC.esConsumes<edm::Transition::BeginRun>()) {
40  if (doEtaOrPhi) {
43  }
44 }
45 
46 // constructor
48  : m_tokens(tokens), m_evSetup(evSetup) {
49  //
50 }
51 
52 // destructor
54  // empty
55 }
56 
57 void L1GetHistLimits::getHistLimits(const L1GtObject& l1GtObject, const std::string& quantity) {
62 
63  // number of objects is independent of the object type
64  // and hardcoded in the actual version
65  if (quantity == "NrObjects") {
69 
71 
72  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
76  }
77 
78  // set last bin upper edge
80 
81  return;
82  }
83 
84  switch (l1GtObject) {
85  case Mu: {
86  if (quantity == "PT") {
88 
89  m_l1HistLimits.nrBins = muPtScale.getPtScale()->getNBins();
92 
94 
95  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
96  m_l1HistLimits.binThresholds[iBin] = muPtScale.getPtScale()->getValue(iBin);
97  }
98 
99  // last limit for muon is set too high (10^6) - resize the last bin
100 
102 
103  // limit the size of the last bin to maximum 200 GeV
104  float maxLaxtBinsize = 200;
105  if (lastBinSize >= maxLaxtBinsize) {
109  LogDebug("L1GetHistLimits") << "\n L1ExtraMuon: PT histogram"
110  << "\nm_l1HistLimits.upperBinValue truncated to = "
111  << m_l1HistLimits.upperBinValue << std::endl;
112  }
113 
114  // set last bin upper edge
116 
117  } else if (quantity == "eta" || quantity == "phi") {
119 
120  if (quantity == "eta") {
121  // eta scale defined for positive values - need to be symmetrized
122  int histNrBinsHalf = muScales.getGMTEtaScale()->getNBins();
125 
126  m_l1HistLimits.nrBins = 2 * histNrBinsHalf;
128 
130 
131  int iBin = 0;
132  for (int j = histNrBinsHalf; j > 0; j--, iBin++) {
133  m_l1HistLimits.binThresholds[iBin] = (-1) * muScales.getGMTEtaScale()->getValue(j);
134  }
135  for (int j = 0; j <= histNrBinsHalf; j++, iBin++) {
137  }
138 
139  // set last bin upper edge
141 
142  } else {
143  m_l1HistLimits.nrBins = muScales.getPhiScale()->getNBins();
146 
148 
149  for (int iBin = 0; iBin <= m_l1HistLimits.nrBins; iBin++) {
150  m_l1HistLimits.binThresholds[iBin] = rad2deg(muScales.getPhiScale()->getValue(iBin));
151  }
152 
153  // set last bin upper edge
155  }
156  }
157 
158  } break;
159  case NoIsoEG:
160  case IsoEG: {
161  // common scales for NoIsoEG and IsoEG
162  if (quantity == "ET") {
164 
165  std::vector<double> emThresholds = emScale.getThresholds();
166  m_l1HistLimits.nrBins = emThresholds.size();
167  m_l1HistLimits.lowerBinValue = emThresholds.at(0);
168 
169  // FIXME high edge retrieval in the scale definition
170  // now, last bin has the same width like the last but one
172  emThresholds[m_l1HistLimits.nrBins - 1] +
173  (emThresholds[m_l1HistLimits.nrBins - 1] - emThresholds[m_l1HistLimits.nrBins - 2]);
174 
176 
177  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
178  m_l1HistLimits.binThresholds[iBin] = static_cast<float>(emThresholds[iBin]);
179  }
180 
181  // set last bin upper edge
183 
184  } else if (quantity == "eta" || quantity == "phi") {
185  const L1CaloGeometry* caloGeomScales = &m_evSetup.getData(m_tokens.m_caloGeomESHToken);
186 
187  if (quantity == "eta") {
189  2 * (caloGeomScales->numberGctCentralEtaBinsPerHalf() + caloGeomScales->numberGctForwardEtaBinsPerHalf());
190  m_l1HistLimits.lowerBinValue = caloGeomScales->globalEtaBinLowEdge(0);
192 
194 
195  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
196  m_l1HistLimits.binThresholds[iBin] = caloGeomScales->globalEtaBinLowEdge(iBin);
197  }
198 
199  // set last bin upper edge
201 
202  } else {
203  m_l1HistLimits.nrBins = caloGeomScales->numberGctEmJetPhiBins();
205 
206  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
207  m_l1HistLimits.binThresholds[iBin] = rad2deg(caloGeomScales->emJetPhiBinLowEdge(iBin));
208 
209  // treat correctly the 10 deg anti-clockwise rotation
210  if (rad2deg(caloGeomScales->emJetPhiBinHighEdge(iBin)) < m_l1HistLimits.binThresholds[iBin]) {
212  }
213  }
214 
216 
217  // last bin upper limit
219 
221  }
222  }
223 
224  } break;
225  case CenJet:
226  case ForJet:
227  case TauJet: {
228  // common scales for all jets
229  if (quantity == "ET") {
231 
232  std::vector<double> jetThresholds = jetScale.getThresholds();
233  m_l1HistLimits.nrBins = jetThresholds.size();
234  m_l1HistLimits.lowerBinValue = jetThresholds.at(0);
235 
236  // FIXME high edge retrieval in the scale definition
237  // now, last bin has the same width like the last but one
239  jetThresholds[m_l1HistLimits.nrBins - 1] +
240  (jetThresholds[m_l1HistLimits.nrBins - 1] - jetThresholds[m_l1HistLimits.nrBins - 2]);
241 
243 
244  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
245  m_l1HistLimits.binThresholds[iBin] = static_cast<float>(jetThresholds[iBin]);
246  }
247 
248  // set last bin upper edge
250 
251  } else if (quantity == "eta" || quantity == "phi") {
252  const L1CaloGeometry* caloGeomScales = &m_evSetup.getData(m_tokens.m_caloGeomESHToken);
253 
254  if (quantity == "eta") {
256  2 * (caloGeomScales->numberGctCentralEtaBinsPerHalf() + caloGeomScales->numberGctForwardEtaBinsPerHalf());
257  m_l1HistLimits.lowerBinValue = caloGeomScales->globalEtaBinLowEdge(0);
259 
261 
262  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
263  m_l1HistLimits.binThresholds[iBin] = caloGeomScales->globalEtaBinLowEdge(iBin);
264  }
265 
266  // set last bin upper edge
268 
269  } else {
270  m_l1HistLimits.nrBins = caloGeomScales->numberGctEmJetPhiBins();
272 
273  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
274  m_l1HistLimits.binThresholds[iBin] = rad2deg(caloGeomScales->emJetPhiBinLowEdge(iBin));
275 
276  // treat correctly the 10 deg anti-clockwise rotation
277  if (rad2deg(caloGeomScales->emJetPhiBinHighEdge(iBin)) < m_l1HistLimits.binThresholds[iBin]) {
279  }
280  }
281 
283 
284  // last bin upper limit
286 
288  }
289  }
290  } break;
291  case ETM: {
292  if (quantity == "ET") {
294 
295  const double etSumLSB = etMissScale.linearLsb();
296 
298 
301 
303 
304  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
305  m_l1HistLimits.binThresholds[iBin] = iBin * etSumLSB;
306  }
307 
308  // set last bin upper edge
310 
311  } else if (quantity == "eta" || quantity == "phi") {
312  const L1CaloGeometry* caloGeomScales = &m_evSetup.getData(m_tokens.m_caloGeomESHToken);
313 
314  if (quantity == "eta") {
315  // do nothing, eta is not defined for ETM
316 
317  } else {
318  m_l1HistLimits.nrBins = caloGeomScales->numberGctEtSumPhiBins();
321 
323 
324  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
325  m_l1HistLimits.binThresholds[iBin] = rad2deg(caloGeomScales->etSumPhiBinLowEdge(iBin));
326  }
327 
328  // last bin upper limit
330  }
331  }
332 
333  } break;
334  case ETT: {
335  if (quantity == "ET") {
337 
338  const double etSumLSB = etMissScale.linearLsb();
339 
341 
344 
346 
347  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
348  m_l1HistLimits.binThresholds[iBin] = iBin * etSumLSB;
349  }
350 
351  // set last bin upper edge
353 
354  } else if (quantity == "eta" || quantity == "phi") {
355  // do nothing, eta and phi are not defined for ETT
356  }
357 
358  } break;
359  case HTT: {
360  if (quantity == "ET") {
362  double htSumLSB = jetFinderParams.getHtLsbGeV();
363 
365 
368 
370 
371  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
372  m_l1HistLimits.binThresholds[iBin] = iBin * htSumLSB;
373  }
374 
375  // set last bin upper edge
377 
378  } else if (quantity == "eta" || quantity == "phi") {
379  // do nothing, eta and phi are not defined for HTT
380  }
381  } break;
382  case HTM: {
383  if (quantity == "ET") {
385 
386  const std::vector<double>& htThresholds = htMissScale.getThresholds();
387  m_l1HistLimits.nrBins = htThresholds.size();
388  m_l1HistLimits.lowerBinValue = htThresholds[0];
389 
390  // FIXME high edge retrieval in the scale definition
391  // now, last bin has the same width like the last but one
393  htThresholds[m_l1HistLimits.nrBins - 1] +
394  (htThresholds[m_l1HistLimits.nrBins - 1] - htThresholds[m_l1HistLimits.nrBins - 2]);
395 
397 
398  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
399  m_l1HistLimits.binThresholds[iBin] = static_cast<float>(htThresholds[iBin]);
400  }
401 
402  // set last bin upper edge
404 
405  } else if (quantity == "eta" || quantity == "phi") {
406  const L1CaloGeometry* caloGeomScales = &m_evSetup.getData(m_tokens.m_caloGeomESHToken);
407 
408  if (quantity == "eta") {
409  // do nothing, eta is not defined for HTM
410 
411  } else {
412  m_l1HistLimits.nrBins = caloGeomScales->numberGctHtSumPhiBins();
415 
417 
418  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
419  m_l1HistLimits.binThresholds[iBin] = rad2deg(caloGeomScales->htSumPhiBinLowEdge(iBin));
420  }
421 
422  // last bin upper limit
424  }
425  }
426  } break;
427  case JetCounts: {
428  } break;
429  case HfBitCounts: {
430  // there are no scales for HfBitCounts, so one implements a fixed scale
431  // use same values as GCT for 3 bits
432  const unsigned int R3BINS = 8;
433  const float R3MIN = -0.5;
434  const float R3MAX = 7.5;
435 
439 
441 
442  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
443  m_l1HistLimits.binThresholds[iBin] = R3MIN + iBin * (R3MAX - R3MIN) / R3BINS;
444  }
445 
446  // last bin upper limit
448 
449  } break;
450  case HfRingEtSums: {
451  if (quantity == "ET") {
453 
454  const std::vector<double>& hfRingEtThresholds = hfRingEtScale.getThresholds();
455  m_l1HistLimits.nrBins = hfRingEtThresholds.size();
456  m_l1HistLimits.lowerBinValue = hfRingEtThresholds[0];
457 
458  // FIXME high edge retrieval in the scale definition
459  // now, last bin has the same width like the last but one
461  hfRingEtThresholds[m_l1HistLimits.nrBins - 1] +
462  (hfRingEtThresholds[m_l1HistLimits.nrBins - 1] - hfRingEtThresholds[m_l1HistLimits.nrBins - 2]);
463 
465 
466  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
467  m_l1HistLimits.binThresholds[iBin] = static_cast<float>(hfRingEtThresholds[iBin]);
468  }
469 
470  // set last bin upper edge
472 
473  } else if (quantity == "eta" || quantity == "phi") {
474  // do nothing, eta and phi are not defined for HfRingEtSums
475  }
476  } break;
477  case TechTrig:
478  case Castor:
479  case BPTX:
480  default: {
481  // do nothing, for these cases ET/PT, eta and phi are not defined
482 
483  } break;
484  }
485 }
486 
488  const std::string& quantity) {
489  getHistLimits(l1GtObject, quantity);
490 
491  if (edm::isDebugEnabled()) {
492  LogDebug("L1GetHistLimits") << "\n Histogram limits for L1GtObject " << l1GtObject << " and quantity " << quantity
493  << "\n Number of bins: " << m_l1HistLimits.nrBins
494  << "\n Lower limit of first bin: " << m_l1HistLimits.lowerBinValue
495  << "\n Upper limit of last bin: " << m_l1HistLimits.upperBinValue << std::endl;
496 
497  int binThreshSize = static_cast<int>(m_l1HistLimits.binThresholds.size());
498 
499  if (binThreshSize != (m_l1HistLimits.nrBins + 1)) {
500  LogTrace("L1GetHistLimits") << "\n Warning: inconsistent nrBins and binThresholds size"
501  << "\n Number of bins nrBins = " << m_l1HistLimits.nrBins
502  << "\n binThresholds size = " << binThreshSize
503  << "\n Please fix the L1GetLimits class.\n\n"
504  << std::endl;
505  }
506 
507  for (int iBin = 0; iBin < binThreshSize; ++iBin) {
508  LogTrace("L1GetHistLimits") << " Bin " << std::right << std::setw(5) << iBin << ": "
509  << m_l1HistLimits.binThresholds[iBin] << std::endl;
510  }
511  }
512 
513  return m_l1HistLimits;
514 }
515 
517  const std::string& quantity,
518  const double histMinValue,
519  const double histMaxValue) {
520  getHistLimits(l1GtObject, quantity);
521 
522  bool foundLowerBinValue = false;
523  bool foundUpperBinValue = false;
524 
525  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
526  if (m_l1HistLimits.binThresholds[iBin] <= histMinValue) {
528  foundLowerBinValue = true;
529  break;
530  }
531  }
532 
533  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
534  if (m_l1HistLimits.binThresholds[iBin] > histMaxValue) {
536  foundUpperBinValue = true;
537  break;
538  }
539  }
540 
541  if (foundLowerBinValue && foundUpperBinValue) {
542  int countBins = -1;
543  std::vector<float> binThresh;
544  binThresh.reserve(m_l1HistLimits.binThresholds.size());
545 
546  for (int iBin = 0; iBin < m_l1HistLimits.nrBins; ++iBin) {
547  if ((m_l1HistLimits.binThresholds[iBin] >= histMinValue) && m_l1HistLimits.binThresholds[iBin] < histMaxValue) {
549 
550  countBins++;
551  binThresh.push_back(m_l1HistLimits.binThresholds[iBin]);
552  }
553  }
554 
555  m_l1HistLimits.nrBins = countBins;
557  m_l1HistLimits.binThresholds = binThresh;
558 
559  // FIXME last bin untested.
560 
561  } else {
566 
567  LogDebug("L1GetHistLimits") << "\n Histogram limits for L1GtObject" << l1GtObject << " and quantity " << quantity
568  << " within the required range [" << histMinValue << ", " << histMaxValue
569  << "] not found."
570  << "\n The range is not included in the original histogram range." << std::endl;
571 
572  return m_l1HistLimits;
573  }
574 
575  if (edm::isDebugEnabled()) {
576  LogDebug("L1GetHistLimits") << "\n Histogram limits for L1GtObject" << l1GtObject << " and quantity " << quantity
577  << "\n Number of bins: " << m_l1HistLimits.nrBins
578  << "\n Lower limit of first bin: " << m_l1HistLimits.lowerBinValue
579  << "\n Upper limit of last bin: " << m_l1HistLimits.upperBinValue << std::endl;
580 
581  int binThreshSize = static_cast<int>(m_l1HistLimits.binThresholds.size());
582 
583  if (binThreshSize != (m_l1HistLimits.nrBins + 1)) {
584  LogTrace("L1GetHistLimits") << "\n Warning: inconsistent nrBins and binThresholds size"
585  << "\n Number of bins nrBins = " << m_l1HistLimits.nrBins
586  << "\n binThresholds size = " << binThreshSize
587  << "\n Please fix the L1GetLimits class.\n\n"
588  << std::endl;
589  }
590 
591  for (int iBin = 0; iBin < binThreshSize; ++iBin) {
592  LogTrace("L1GetHistLimits") << " Bin " << std::right << std::setw(5) << iBin << ": "
593  << m_l1HistLimits.binThresholds[iBin] << std::endl;
594  }
595  }
596 
597  return m_l1HistLimits;
598 }
599 
600 const int L1GetHistLimits::l1HistNrBins(const L1GtObject& l1GtObject, const std::string& quantity) {
601  getHistLimits(l1GtObject, quantity);
602  return m_l1HistLimits.nrBins;
603 }
604 
605 const double L1GetHistLimits::l1HistLowerBinValue(const L1GtObject& l1GtObject, const std::string& quantity) {
606  getHistLimits(l1GtObject, quantity);
608 }
609 
610 const double L1GetHistLimits::l1HistUpperBinValue(const L1GtObject& l1GtObject, const std::string& quantity) {
611  getHistLimits(l1GtObject, quantity);
613 }
614 
615 const std::vector<float>& L1GetHistLimits::l1HistBinThresholds(const L1GtObject& l1GtObject,
616  const std::string& quantity) {
617  getHistLimits(l1GtObject, quantity);
619 }
double globalEtaBinLowEdge(unsigned int globalEtaIndex) const
bool isDebugEnabled()
const edm::ESGetToken< L1MuTriggerPtScale, L1MuTriggerPtScaleRcd > m_muPTScaleToken
unsigned int numberGctForwardEtaBinsPerHalf() const
virtual float getScaleMax() const =0
get the upper edge of the last bin
const edm::ESGetToken< L1GctJetFinderParams, L1GctJetFinderParamsRcd > m_jetFinderParamsToken
void getHistLimits(const L1GtObject &l1GtObject, const std::string &quantity)
const edm::EventSetup & m_evSetup
Definition: L1GtObject.h:38
L1HistLimits m_l1HistLimits
all limits for a histogram
unsigned int numberGctHtSumPhiBins() const
const L1MuScale * getPtScale() const
get the Pt scale
const edm::ESGetToken< L1CaloEtScale, L1HfRingEtScaleRcd > m_hfRingEtScaleToken
double htSumPhiBinLowEdge(unsigned int phiIndex) const
const double l1HistUpperBinValue(const L1GtObject &l1GtObject, const std::string &quantity)
Definition: L1GtObject.h:35
Tokens(edm::ConsumesCollector, bool doEtaOrPhi)
edm::ESGetToken< L1CaloGeometry, L1CaloGeometryRecord > m_caloGeomESHToken
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
double getHtLsbGeV() const
double linearLsb() const
get LSB of linear input scale
Definition: L1CaloEtScale.h:54
virtual ~L1GetHistLimits()
#define LogTrace(id)
Definition: L1GtObject.h:37
bool getData(T &iHolder) const
Definition: EventSetup.h:128
L1GetHistLimits(const Tokens &, const edm::EventSetup &evSetup)
edm::ESGetToken< L1MuTriggerScales, L1MuTriggerScalesRcd > m_muScalesToken
const std::vector< double > & getThresholds() const
get thresholds
Definition: L1CaloEtScale.h:66
const unsigned int R3BINS
Definition: L1TGCT.cc:44
const L1MuScale * getPhiScale() const
get the phi scale
virtual float getValue(unsigned i) const =0
get value of the underlying vector for bin i
Transition
Definition: Transition.h:12
virtual float getScaleMin() const =0
get the lower edge of the first bin
std::vector< float > binThresholds
const double rad2deg(const double &)
convert phi from rad (-pi, pi] to deg (0, 360)
Definition: L1GtObject.h:29
double globalEtaBinHighEdge(unsigned int globalEtaIndex) const
double etSumPhiBinLowEdge(unsigned int phiIndex) const
virtual unsigned getNBins() const =0
get number of bins
Definition: L1GtObject.h:36
const Tokens & m_tokens
const edm::ESGetToken< L1CaloEtScale, L1HtMissScaleRcd > m_htMissScaleToken
const L1MuScale * getGMTEtaScale() const
get the GMT eta scale
double emJetPhiBinLowEdge(unsigned int phiIndex) const
double htSumPhiBinHighEdge(unsigned int phiIndex) const
const float R3MAX
Definition: L1TGCT.cc:46
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
const double l1HistLowerBinValue(const L1GtObject &l1GtObject, const std::string &quantity)
const edm::ESGetToken< L1CaloEtScale, L1EmEtScaleRcd > m_etScaleToken
double emJetPhiBinHighEdge(unsigned int phiIndex) const
double etSumPhiBinHighEdge(unsigned int phiIndex) const
const float R3MIN
Definition: L1TGCT.cc:45
#define LogDebug(id)
const L1HistLimits & l1HistLimits(const L1GtObject &l1GtObject, const std::string &quantity)
const edm::ESGetToken< L1CaloEtScale, L1JetEtScaleRcd > m_jetScaleToken