DAS  3.0
Das Analysis System
BTagCalibrationReader::BTagCalibrationReaderImpl
+ Collaboration diagram for BTagCalibrationReader::BTagCalibrationReaderImpl:

Classes

struct  TmpEntry
 

Private Member Functions

 BTagCalibrationReaderImpl (BTagEntry::OperatingPoint op, const std::string &sysType, const std::vector< std::string > &otherSysTypes={})
 
void load (const BTagCalibration &c, BTagEntry::JetFlavor jf, std::string measurementType)
 
double eval (BTagEntry::JetFlavor jf, float eta, float pt, float discr) const
 
double eval_auto_bounds (const std::string &sys, BTagEntry::JetFlavor jf, float eta, float pt, float discr) const
 
std::pair< float, float > min_max_pt (BTagEntry::JetFlavor jf, float eta, float discr) const
 
std::pair< float, float > min_max_eta (BTagEntry::JetFlavor jf, float discr) const
 

Private Attributes

BTagEntry::OperatingPoint op_
 
std::string sysType_
 
std::map< BTagEntry::JetFlavor, std::vector< TmpEntry > > tmpData_
 
std::map< std::string, std::shared_ptr< BTagCalibrationReaderImpl > > otherSysTypeReaders_
 

Friends

class BTagCalibrationReader
 

Constructor & Destructor Documentation

◆ BTagCalibrationReaderImpl()

BTagCalibrationReaderImpl ( BTagEntry::OperatingPoint  op,
const std::string &  sysType,
const std::vector< std::string > &  otherSysTypes = {} 
)
private
423  :
424  op_(op),
425  sysType_(sysType)
426 {
427  for (const std::string & ost : otherSysTypes) {
428  if (otherSysTypeReaders_.count(ost)) {
429 std::cerr << "ERROR in BTagCalibration: "
430  << "Every otherSysType should only be given once. Duplicate: "
431  << ost;
432 throw std::exception();
433  }
434  otherSysTypeReaders_[ost] = std::auto_ptr<BTagCalibrationReaderImpl>(
435  new BTagCalibrationReaderImpl(op, ost)
436  );
437  }
438 }

Member Function Documentation

◆ eval()

double eval ( BTagEntry::JetFlavor  jf,
float  eta,
float  pt,
float  discr 
) const
private
489 {
490  bool use_discr = (op_ == BTagEntry::OP_RESHAPING);
491 
492  // search linearly through eta, pt and discr ranges and eval
493  // future: find some clever data structure based on intervals
494  const auto &entries = tmpData_.at(jf);
495  for (unsigned i=0; i<entries.size(); ++i) {
496  const auto &e = entries.at(i);
497  if (
498  e.etaMin <= eta && eta <= e.etaMax // find eta
499  && e.ptMin < pt && pt <= e.ptMax // check pt
500  ){
501  if (use_discr) { // discr. reshaping?
502  if (e.discrMin <= discr && discr < e.discrMax) { // check discr
503  return e.func.Eval(discr);
504  }
505  } else {
506  return e.func.Eval(pt);
507  }
508  }
509  }
510 
511  return 0.; // default value
512 }

◆ eval_auto_bounds()

double eval_auto_bounds ( const std::string &  sys,
BTagEntry::JetFlavor  jf,
float  eta,
float  pt,
float  discr 
) const
private
520 {
521  auto sf_bounds_eta = min_max_eta(jf, discr);
522  bool eta_is_out_of_bounds = false;
523 
524  if (sf_bounds_eta.first < 0) sf_bounds_eta.first = -sf_bounds_eta.second;
525  if (eta <= sf_bounds_eta.first || eta > sf_bounds_eta.second ) {
526  eta_is_out_of_bounds = true;
527  }
528 
529  if (eta_is_out_of_bounds) {
530  return 1.;
531  }
532 
533 
534  auto sf_bounds = min_max_pt(jf, eta, discr);
535  float pt_for_eval = pt;
536  bool is_out_of_bounds = false;
537 
538  if (pt <= sf_bounds.first) {
539  pt_for_eval = sf_bounds.first + .0001;
540  is_out_of_bounds = true;
541  } else if (pt > sf_bounds.second) {
542  pt_for_eval = sf_bounds.second - .0001;
543  is_out_of_bounds = true;
544  }
545 
546  // get central SF (and maybe return)
547  double sf = eval(jf, eta, pt_for_eval, discr);
548  if (sys == sysType_) {
549  return sf;
550  }
551 
552  // get sys SF (and maybe return)
553  if (!otherSysTypeReaders_.count(sys)) {
554 std::cerr << "ERROR in BTagCalibration: "
555  << "sysType not available (maybe not loaded?): "
556  << sys;
557 throw std::exception();
558  }
559  double sf_err = otherSysTypeReaders_.at(sys)->eval(jf, eta, pt_for_eval, discr);
560  if (!is_out_of_bounds) {
561  return sf_err;
562  }
563 
564  // double uncertainty on out-of-bounds and return
565  sf_err = sf + 2*(sf_err - sf);
566  return sf_err;
567 }

◆ load()

void load ( const BTagCalibration c,
BTagEntry::JetFlavor  jf,
std::string  measurementType 
)
private
444 {
445  if (tmpData_[jf].size()) {
446 std::cerr << "ERROR in BTagCalibration: "
447  << "Data for this jet-flavor is already loaded: "
448  << jf;
449 throw std::exception();
450  }
451 
452  BTagEntry::Parameters params(op_, measurementType, sysType_);
453  const std::vector<BTagEntry> &entries = c.getEntries(params);
454 
455  for (const auto &be : entries) {
456  if (be.params.jetFlavor != jf) {
457  continue;
458  }
459 
460  TmpEntry te;
461  te.etaMin = be.params.etaMin;
462  te.etaMax = be.params.etaMax;
463  te.ptMin = be.params.ptMin;
464  te.ptMax = be.params.ptMax;
465  te.discrMin = be.params.discrMin;
466  te.discrMax = be.params.discrMax;
467 
468  if (op_ == BTagEntry::OP_RESHAPING) {
469  te.func = TF1("", be.formula.c_str(),
470  be.params.discrMin, be.params.discrMax);
471  } else {
472  te.func = TF1("", be.formula.c_str(),
473  be.params.ptMin, be.params.ptMax);
474  }
475 
476  tmpData_[be.params.jetFlavor].push_back(te);
477  }
478 
479  for (auto & p : otherSysTypeReaders_) {
480  p.second->load(c, jf, measurementType);
481  }
482 }

◆ min_max_eta()

std::pair< float, float > min_max_eta ( BTagEntry::JetFlavor  jf,
float  discr 
) const
private
606 {
607  bool use_discr = (op_ == BTagEntry::OP_RESHAPING);
608 
609  const auto &entries = tmpData_.at(jf);
610  float min_eta = 0., max_eta = 0.;
611  for (const auto & e: entries) {
612 
613  if (use_discr) { // discr. reshaping?
614  if (e.discrMin <= discr && discr < e.discrMax) { // check discr
615  min_eta = min_eta < e.etaMin ? min_eta : e.etaMin;
616  max_eta = max_eta > e.etaMax ? max_eta : e.etaMax;
617  }
618  } else {
619  min_eta = min_eta < e.etaMin ? min_eta : e.etaMin;
620  max_eta = max_eta > e.etaMax ? max_eta : e.etaMax;
621  }
622  }
623 
624 
625  return std::make_pair(min_eta, max_eta);
626 }

◆ min_max_pt()

std::pair< float, float > min_max_pt ( BTagEntry::JetFlavor  jf,
float  eta,
float  discr 
) const
private
573 {
574  bool use_discr = (op_ == BTagEntry::OP_RESHAPING);
575 
576  const auto &entries = tmpData_.at(jf);
577  float min_pt = -1., max_pt = -1.;
578  for (const auto & e: entries) {
579  if (
580  e.etaMin <= eta && eta <=e.etaMax // find eta
581  ){
582  if (min_pt < 0.) { // init
583  min_pt = e.ptMin;
584  max_pt = e.ptMax;
585  continue;
586  }
587 
588  if (use_discr) { // discr. reshaping?
589  if (e.discrMin <= discr && discr < e.discrMax) { // check discr
590  min_pt = min_pt < e.ptMin ? min_pt : e.ptMin;
591  max_pt = max_pt > e.ptMax ? max_pt : e.ptMax;
592  }
593  } else {
594  min_pt = min_pt < e.ptMin ? min_pt : e.ptMin;
595  max_pt = max_pt > e.ptMax ? max_pt : e.ptMax;
596  }
597  }
598  }
599 
600  return std::make_pair(min_pt, max_pt);
601 }

Friends And Related Function Documentation

◆ BTagCalibrationReader

friend class BTagCalibrationReader
friend

Member Data Documentation

◆ op_

◆ otherSysTypeReaders_

std::map<std::string, std::shared_ptr<BTagCalibrationReaderImpl> > otherSysTypeReaders_
private

◆ sysType_

std::string sysType_
private

◆ tmpData_

std::map<BTagEntry::JetFlavor,std::vector<TmpEntry> > tmpData_
private

The documentation for this class was generated from the following file:
Ntupliser_cfg.params
dictionary params
Definition: Ntupliser_cfg.py:20
Ntupliser_cfg.cerr
cerr
Definition: Ntupliser_cfg.py:93
jmarExample.pt
pt
Definition: jmarExample.py:19
BTagCalibration::getEntries
const std::vector< BTagEntry > & getEntries(const BTagEntry::Parameters &par) const
Definition: BTagCalibration.cc:301
BTagCalibrationReader::BTagCalibrationReaderImpl::otherSysTypeReaders_
std::map< std::string, std::shared_ptr< BTagCalibrationReaderImpl > > otherSysTypeReaders_
Definition: BTagCalibration.cc:416
Ntupliser_cfg.p
p
Definition: Ntupliser_cfg.py:358
BTagEntry::Parameters
Definition: BTagCalibration.h:37
BTagCalibrationReader::BTagCalibrationReaderImpl::eval
double eval(BTagEntry::JetFlavor jf, float eta, float pt, float discr) const
Definition: BTagCalibration.cc:484
BTagCalibrationReader::BTagCalibrationReaderImpl::tmpData_
std::map< BTagEntry::JetFlavor, std::vector< TmpEntry > > tmpData_
Definition: BTagCalibration.cc:415
BTagCalibrationReader::BTagCalibrationReaderImpl::sysType_
std::string sysType_
Definition: BTagCalibration.cc:414
BTagEntry::OP_RESHAPING
@ OP_RESHAPING
Definition: BTagCalibration.h:30
BTagCalibrationReader::BTagCalibrationReaderImpl::min_max_pt
std::pair< float, float > min_max_pt(BTagEntry::JetFlavor jf, float eta, float discr) const
Definition: BTagCalibration.cc:569
BTagCalibrationReader::BTagCalibrationReaderImpl::BTagCalibrationReaderImpl
BTagCalibrationReaderImpl(BTagEntry::OperatingPoint op, const std::string &sysType, const std::vector< std::string > &otherSysTypes={})
Definition: BTagCalibration.cc:420
BTagCalibrationReader::BTagCalibrationReaderImpl::min_max_eta
std::pair< float, float > min_max_eta(BTagEntry::JetFlavor jf, float discr) const
Definition: BTagCalibration.cc:603
jercExample.sf
sf
Definition: jercExample.py:112
BTagCalibrationReader::BTagCalibrationReaderImpl::op_
BTagEntry::OperatingPoint op_
Definition: BTagCalibration.cc:413
jmarExample.eta
eta
DeepAK8/ParticleNet tagging.
Definition: jmarExample.py:19