CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes | Friends
EnergyScaleCorrection::CorrectionCategory Class Reference

#include <EnergyScaleCorrection.h>

Public Member Functions

 CorrectionCategory (const std::string &category, int runnrMin=0, int runnrMax=999999)
 
 CorrectionCategory (const unsigned int runnr, const float et, const float eta, const float r9, const unsigned int gainSeed)
 
 CorrectionCategory (unsigned int runMin, unsigned int runMax, float etaMin, float etaMax, float r9Min, float r9Max, float etMin, float etMax, unsigned int gainSeed)
 for the new file format More...
 
bool inCategory (const unsigned int runnr, const float et, const float eta, const float r9, const unsigned int gainSeed) const
 
bool operator< (const CorrectionCategory &b) const
 
std::ostream & print (std::ostream &os) const
 

Private Attributes

float etaMax_
 max eta value for the bin More...
 
float etaMin_
 min eta value for the bin More...
 
float etMax_
 max Et value for the bin More...
 
float etMin_
 min Et value for the bin More...
 
unsigned int gain_
 12, 6, 1, 61 (double gain switch) More...
 
float r9Max_
 max R9 value for the bin More...
 
float r9Min_
 min R9 vaule for the bin More...
 
unsigned int runMax_
 
unsigned int runMin_
 

Friends

std::ostream & operator<< (std::ostream &os, const CorrectionCategory &a)
 

Detailed Description

Definition at line 81 of file EnergyScaleCorrection.h.

Constructor & Destructor Documentation

EnergyScaleCorrection::CorrectionCategory::CorrectionCategory ( const std::string &  category,
int  runnrMin = 0,
int  runnrMax = 999999 
)

Definition at line 342 of file EnergyScaleCorrection.cc.

References etaMax_, etaMin_, etMax_, etMin_, gain_, SiStripPI::max, min(), p1, p2, r9Max_, and r9Min_.

343  : runMin_(runnrMin),
344  runMax_(runnrMax),
345  etaMin_(0),
346  etaMax_(3),
347  r9Min_(-1),
348  r9Max_(999),
349  etMin_(0),
350  etMax_(9999999),
351  gain_(0) {
352  size_t p1, p2; // boundary
353 
354  // eta region
355  p1 = category.find("absEta_");
356  if (category.find("absEta_0_1") != std::string::npos) {
357  etaMin_ = 0;
358  etaMax_ = 1;
359  } else if (category.find("absEta_1_1.4442") != std::string::npos) {
360  etaMin_ = 1;
361  etaMax_ = 1.479;
362  } else if (category.find("absEta_1.566_2") != std::string::npos) {
363  etaMin_ = 1.479;
364  etaMax_ = 2;
365  } else if (category.find("absEta_2_2.5") != std::string::npos) {
366  etaMin_ = 2;
367  etaMax_ = 3;
368  } else {
369  if (p1 != std::string::npos) {
370  p1 = category.find("_", p1);
371  p2 = category.find("_", p1 + 1);
372  etaMin_ = std::stof(category.substr(p1 + 1, p2 - p1 - 1));
373  p1 = p2;
374  p2 = category.find("-", p1);
375  etaMax_ = std::stof(category.substr(p1 + 1, p2 - p1 - 1));
376  }
377  }
378 
379  if (category.find("EBlowEta") != std::string::npos) {
380  etaMin_ = 0;
381  etaMax_ = 1;
382  };
383  if (category.find("EBhighEta") != std::string::npos) {
384  etaMin_ = 1;
385  etaMax_ = 1.479;
386  };
387  if (category.find("EElowEta") != std::string::npos) {
388  etaMin_ = 1.479;
389  etaMax_ = 2;
390  };
391  if (category.find("EEhighEta") != std::string::npos) {
392  etaMin_ = 2;
393  etaMax_ = 7;
394  };
395 
396  // Et region
397  p1 = category.find("-Et_");
398 
399  if (p1 != std::string::npos) {
400  p1 = category.find("_", p1);
401  p2 = category.find("_", p1 + 1);
402  etMin_ = std::stof(category.substr(p1 + 1, p2 - p1 - 1));
403  p1 = p2;
404  p2 = category.find("-", p1);
405  etMax_ = std::stof(category.substr(p1 + 1, p2 - p1 - 1));
406  }
407 
408  if (category.find("gold") != std::string::npos || category.find("Gold") != std::string::npos ||
409  category.find("highR9") != std::string::npos) {
410  r9Min_ = 0.94;
412  } else if (category.find("bad") != std::string::npos || category.find("Bad") != std::string::npos ||
413  category.find("lowR9") != std::string::npos) {
414  r9Min_ = -1;
415  r9Max_ = 0.94;
416  };
417  // R9 region
418  p1 = category.find("-R9");
419  if (p1 != std::string::npos) {
420  p1 = category.find("_", p1);
421  p2 = category.find("_", p1 + 1);
422  r9Min_ = std::stof(category.substr(p1 + 1, p2 - p1 - 1));
423  // If there is one value, just set lower bound
424  if (p2 != std::string::npos) {
425  p1 = p2;
426  p2 = category.find("-", p1);
427  r9Max_ = std::stof(category.substr(p1 + 1, p2 - p1 - 1));
428  if (r9Max_ >= 1.0)
430  }
431  }
432  //------------------------------
433  p1 = category.find("gainEle_"); // Position of first character
434  if (p1 != std::string::npos) {
435  p1 += 8; // Position of character after _
436  p2 = category.find("-", p1); // Position of - or end of string
437  gain_ = std::stoul(category.substr(p1, p2 - p1), nullptr);
438  }
439  //so turns out the code does an inclusive X<=Y<=Z search for bins
440  //which is what we want for run numbers
441  //however then the problem is when we get a value exactly at the bin boundary
442  //for the et/eta/r9 which then gives multiple bins
443  //so we just decrement the maxValues ever so slightly to ensure that they are different
444  //from the next bins min value
445  etMax_ = std::nextafterf(etMax_, std::numeric_limits<float>::min());
446  etaMax_ = std::nextafterf(etaMax_, std::numeric_limits<float>::min());
447  r9Max_ = std::nextafterf(r9Max_, std::numeric_limits<float>::min());
448 }
unsigned int gain_
12, 6, 1, 61 (double gain switch)
T min(T a, T b)
Definition: MathUtil.h:58
double p2[4]
Definition: TauolaWrapper.h:90
double p1[4]
Definition: TauolaWrapper.h:89
EnergyScaleCorrection::CorrectionCategory::CorrectionCategory ( const unsigned int  runnr,
const float  et,
const float  eta,
const float  r9,
const unsigned int  gainSeed 
)
inline

Definition at line 84 of file EnergyScaleCorrection.h.

References b, stringResolutionProvider_cfi::et, PVValHelper::eta, ALCARECOTkAlBeamHalo_cff::etaMax, ALCARECOTkAlBeamHalo_cff::etaMin, conversionPostprocessing_cfi::etMax, btagDijet_cfi::etMin, operator<(), electrons_cff::r9, photonValidator_cfi::r9Max, and photonValidator_cfi::r9Min.

86  : runMin_(runnr),
87  runMax_(runnr),
90  r9Min_(r9),
91  r9Max_(r9),
92  etMin_(et),
93  etMax_(et),
94  gain_(gainSeed) {}
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned int gain_
12, 6, 1, 61 (double gain switch)
et
define resolution functions of each parameter
EnergyScaleCorrection::CorrectionCategory::CorrectionCategory ( unsigned int  runMin,
unsigned int  runMax,
float  etaMin,
float  etaMax,
float  r9Min,
float  r9Max,
float  etMin,
float  etMax,
unsigned int  gainSeed 
)

for the new file format

Same logic as the above constructor to avoid problems at the bin boundary of et/eta/R9 - just decrement the maxValues ever so slightly to ensure that they are different from the next bins min value

Definition at line 451 of file EnergyScaleCorrection.cc.

References etaMax_, etMax_, min(), and r9Max_.

460  : runMin_(runMin),
461  runMax_(runMax),
462  etaMin_(etaMin),
463  etaMax_(etaMax),
464  r9Min_(r9Min),
465  r9Max_(r9Max),
466  etMin_(etMin),
467  etMax_(etMax),
468  gain_(gainSeed) {
473  etMax_ = std::nextafterf(etMax_, std::numeric_limits<float>::min());
474  etaMax_ = std::nextafterf(etaMax_, std::numeric_limits<float>::min());
475  r9Max_ = std::nextafterf(r9Max_, std::numeric_limits<float>::min());
476 };
unsigned int gain_
12, 6, 1, 61 (double gain switch)
T min(T a, T b)
Definition: MathUtil.h:58

Member Function Documentation

bool EnergyScaleCorrection::CorrectionCategory::inCategory ( const unsigned int  runnr,
const float  et,
const float  eta,
const float  r9,
const unsigned int  gainSeed 
) const

Definition at line 478 of file EnergyScaleCorrection.cc.

References etaMax_, etaMin_, etMin_, gain_, r9Max_, r9Min_, and runMin_.

479  {
480  return runnr >= runMin_ && runnr <= runMax_ && et >= etMin_ && et <= etMax_ && eta >= etaMin_ && eta <= etaMax_ &&
481  r9 >= r9Min_ && r9 <= r9Max_ && (gain_ == 0 || gainSeed == gain_);
482 }
unsigned int gain_
12, 6, 1, 61 (double gain switch)
bool EnergyScaleCorrection::CorrectionCategory::operator< ( const CorrectionCategory b) const

Definition at line 484 of file EnergyScaleCorrection.cc.

References etaMax_, etaMin_, etMax_, etMin_, gain_, r9Max_, r9Min_, runMax_, and runMin_.

484  {
485  if (runMin_ < b.runMin_ && runMax_ < b.runMax_)
486  return true;
487  if (runMax_ > b.runMax_ && runMin_ > b.runMin_)
488  return false;
489 
490  if (etaMin_ < b.etaMin_ && etaMax_ < b.etaMax_)
491  return true;
492  if (etaMax_ > b.etaMax_ && etaMin_ > b.etaMin_)
493  return false;
494 
495  if (r9Min_ < b.r9Min_ && r9Max_ < b.r9Max_)
496  return true;
497  if (r9Max_ > b.r9Max_ && r9Min_ > b.r9Min_)
498  return false;
499 
500  if (etMin_ < b.etMin_ && etMax_ < b.etMax_)
501  return true;
502  if (etMax_ > b.etMax_ && etMin_ > b.etMin_)
503  return false;
504 
505  if (gain_ == 0 || b.gain_ == 0)
506  return false; // if corrections are not categorized in gain then default gain value should always return false in order to have a match with the category
507  if (gain_ < b.gain_)
508  return true;
509  else
510  return false;
511  return false;
512 }
unsigned int gain_
12, 6, 1, 61 (double gain switch)
double b
Definition: hdecay.h:120
std::ostream & EnergyScaleCorrection::CorrectionCategory::print ( std::ostream &  os) const

Definition at line 514 of file EnergyScaleCorrection.cc.

References etaMax_, etaMin_, etMax_, etMin_, gain_, r9Max_, r9Min_, runMax_, and runMin_.

514  {
515  os << runMin_ << " " << runMax_ << "\t" << etaMin_ << " " << etaMax_ << "\t" << r9Min_ << " " << r9Max_ << "\t"
516  << etMin_ << " " << etMax_ << "\t" << gain_;
517  return os;
518 }
unsigned int gain_
12, 6, 1, 61 (double gain switch)

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const CorrectionCategory a 
)
friend

Definition at line 110 of file EnergyScaleCorrection.h.

110 { return a.print(os); }
double a
Definition: hdecay.h:121

Member Data Documentation

float EnergyScaleCorrection::CorrectionCategory::etaMax_
private

max eta value for the bin

Definition at line 118 of file EnergyScaleCorrection.h.

Referenced by CorrectionCategory(), inCategory(), operator<(), and print().

float EnergyScaleCorrection::CorrectionCategory::etaMin_
private

min eta value for the bin

Definition at line 117 of file EnergyScaleCorrection.h.

Referenced by CorrectionCategory(), inCategory(), operator<(), and print().

float EnergyScaleCorrection::CorrectionCategory::etMax_
private

max Et value for the bin

Definition at line 122 of file EnergyScaleCorrection.h.

Referenced by CorrectionCategory(), operator<(), and print().

float EnergyScaleCorrection::CorrectionCategory::etMin_
private

min Et value for the bin

Definition at line 121 of file EnergyScaleCorrection.h.

Referenced by CorrectionCategory(), inCategory(), operator<(), and print().

unsigned int EnergyScaleCorrection::CorrectionCategory::gain_
private

12, 6, 1, 61 (double gain switch)

Definition at line 123 of file EnergyScaleCorrection.h.

Referenced by CorrectionCategory(), inCategory(), operator<(), and print().

float EnergyScaleCorrection::CorrectionCategory::r9Max_
private

max R9 value for the bin

Definition at line 120 of file EnergyScaleCorrection.h.

Referenced by CorrectionCategory(), inCategory(), operator<(), and print().

float EnergyScaleCorrection::CorrectionCategory::r9Min_
private

min R9 vaule for the bin

Definition at line 119 of file EnergyScaleCorrection.h.

Referenced by CorrectionCategory(), inCategory(), operator<(), and print().

unsigned int EnergyScaleCorrection::CorrectionCategory::runMax_
private

Definition at line 116 of file EnergyScaleCorrection.h.

Referenced by operator<(), and print().

unsigned int EnergyScaleCorrection::CorrectionCategory::runMin_
private

Definition at line 115 of file EnergyScaleCorrection.h.

Referenced by inCategory(), operator<(), and print().