ATLAS Offline Software
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
Analysis::CalibrationDataInterfaceROOT Class Reference

#include <CalibrationDataInterfaceROOT.h>

Inheritance diagram for Analysis::CalibrationDataInterfaceROOT:
Collaboration diagram for Analysis::CalibrationDataInterfaceROOT:

Classes

class  HadronisationReferenceHelper
 

Public Types

enum  variableType { kEta, kAbsEta, kPt }
 known variable types that can be used as function arguments More...
 

Public Member Functions

 CalibrationDataInterfaceROOT (const std::string &taggerName, const std::string &configname="BTagCalibration.env", const std::string &pathname="")
 main constructor for "stand-alone" use (with information fed in from a .env configuration file read by TEnv) More...
 
 CalibrationDataInterfaceROOT (const std::string &taggerName, const char *fileSF, const char *fileEff, const std::vector< std::string > &jetAliases, const std::map< std::string, std::string > &SFNames, const std::map< std::string, std::vector< std::string > > &EffNames, const std::map< std::string, std::vector< std::string > > &excludeFromEV, const std::map< std::string, Analysis::EVReductionStrategy > &EVReductions, bool useEV=true, Uncertainty strat=SFEigen, bool useMCMCSF=true, bool useTopologyRescaling=false, bool useRecommendedEVExclusions=false, bool verbose=true, std::vector< std::string > flavours={"B", "C", "Light", "T"})
 alternative constructor passing configuration information explicitly (so that no .env file is needed) More...
 
 CalibrationDataInterfaceROOT ()
 default constructor for PROOF object retrieval More...
 
 CalibrationDataInterfaceROOT (const CalibrationDataInterfaceROOT &other)
 copy constructor More...
 
virtual ~CalibrationDataInterfaceROOT ()
 default destructor More...
 
CalibResult getScaleFactor (const CalibrationDataVariables &variables, const std::string &label, const std::string &OP, Uncertainty unc, unsigned int numVariation=0, unsigned int mapIndex=0)
 efficiency scale factor retrieval by name. More...
 
CalibResult getEfficiency (const CalibrationDataVariables &variables, const std::string &label, const std::string &OP, Uncertainty unc, const std::string &flavour, unsigned int numVariation=0, unsigned int mapIndex=0)
 efficiency retrieval by name More...
 
CalibResult getInefficiencyScaleFactor (const CalibrationDataVariables &variables, const std::string &label, const std::string &OP, Uncertainty unc, unsigned int numVariation=0, unsigned int mapIndex=0)
 "MC" inefficiency scale factor retrieval by name More...
 
CalibResult getInefficiency (const CalibrationDataVariables &variables, const std::string &label, const std::string &OP, Uncertainty unc, unsigned int numVariation=0, unsigned int mapIndex=0)
 inefficiency retrieval by name More...
 
CalibResult getMCEfficiency (const CalibrationDataVariables &variables, const std::string &label, const std::string &OP, Uncertainty unc=None, unsigned int mapIndex=0)
 "MC" efficiency retrieval by name More...
 
CalibResult getMCInefficiency (const CalibrationDataVariables &variables, const std::string &label, const std::string &OP, Uncertainty unc=None, unsigned int mapIndex=0)
 "MC" inefficiency retrieval by name More...
 
std::vector< std::string > listScaleFactorUncertainties (const std::string &author, const std::string &label, const std::string &OP, bool named=false)
 retrieve the list of "uncertainties" relevant to the calibration object. More...
 
unsigned int getNumVariations (const std::string &author, const std::string &label, const std::string &OP, Uncertainty unc)
 retrieve the number of variations relevant to the calibration object. More...
 
bool retrieveCalibrationIndex (const std::string &label, const std::string &OP, const std::string &author, bool isSF, unsigned int &index, unsigned int mapIndex=0)
 Retrieve the index of the calibration object (container) starting from the label and operating point. More...
 
std::string nameFromIndex (unsigned int index) const
 Retrieve the name of the calibration object (container) given its index. More...
 
CalibResult getScaleFactor (const CalibrationDataVariables &variables, unsigned int indexSF, unsigned int indexEff, Uncertainty unc, const std::string &flavour, unsigned int numVariation=0)
 efficiency scale factor retrieval by index #2 More...
 
CalibResult getEfficiency (const CalibrationDataVariables &variables, unsigned int indexSF, unsigned int indexEff, Uncertainty unc, const std::string &flavour, unsigned int numVariation=0)
 efficiency retrieval by index More...
 
CalibResult getInefficiencyScaleFactor (const CalibrationDataVariables &variables, unsigned int indexSF, unsigned int indexEff, Uncertainty unc, const std::string &flavour, unsigned int numVariation=0)
 "MC" inefficiency scale factor retrieval by index More...
 
CalibResult getInefficiency (const CalibrationDataVariables &variables, unsigned int indexSF, unsigned int indexEff, Uncertainty unc, const std::string &flavour, unsigned int numVariation=0)
 inefficiency retrieval by index More...
 
CalibResult getMCEfficiency (const CalibrationDataVariables &variables, unsigned int index, Uncertainty unc=None)
 "MC" efficiency retrieval by index More...
 
CalibResult getMCInefficiency (const CalibrationDataVariables &variables, unsigned int index, Uncertainty unc=None)
 "MC" inefficiency retrieval by index More...
 
double getMCMCScaleFactor (const CalibrationDataVariables &variables, unsigned indexSF, unsigned int indexEff) const
 MC/MC scale factor retrieval. More...
 
std::vector< std::string > listScaleFactorUncertainties (unsigned int index, const std::string &flavour, bool named=false)
 retrieve the list of "uncertainties" relevant to the calibration object. More...
 
unsigned int getNumVariations (unsigned int index, Uncertainty unc, const std::string &flavour)
 retrieve the number of variations relevant to the calibration object. More...
 
std::string fullName (const std::string &author, const std::string &OP, const std::string &label, bool isSF, unsigned mapIndex=0) const
 @ brief construct the full object pathname from its individual components More...
 
CalibrationStatus getScaleFactor (const CalibrationDataVariables &variables, unsigned int indexSF, unsigned int indexEff, Uncertainty unc, unsigned int numVariation, CalibResult &result, const std::string &flavour)
 efficiency scale factor retrieval by index #3 More...
 
CalibrationStatus getEfficiency (const CalibrationDataVariables &variables, unsigned int indexSF, unsigned int indexEff, Uncertainty unc, unsigned int numVariation, CalibResult &result, const std::string &flavour)
 efficiency retrieval by index More...
 
CalibrationStatus getInefficiencyScaleFactor (const CalibrationDataVariables &variables, unsigned int indexSF, unsigned int indexEff, Uncertainty unc, unsigned int numVariation, CalibResult &result, const std::string &flavour)
 "MC" inefficiency scale factor retrieval by index More...
 
CalibrationStatus getInefficiency (const CalibrationDataVariables &variables, unsigned int indexSF, unsigned int indexEff, Uncertainty unc, unsigned int numVariation, CalibResult &result, const std::string &flavour)
 inefficiency retrieval by index More...
 
CalibrationStatus getMCEfficiency (const CalibrationDataVariables &variables, unsigned int index, Uncertainty unc, CalibResult &result)
 "MC" efficiency retrieval by index More...
 
CalibResult getWeightScaleFactor (const CalibrationDataVariables &variables, const std::string &label, Uncertainty unc, unsigned int numVariation=0, unsigned int mapIndex=0)
 efficiency scale factor retrieval by name More...
 
CalibResult getWeightScaleFactor (const CalibrationDataVariables &variables, unsigned int indexSF, unsigned int indexEff, Uncertainty unc, unsigned int numVariation=0)
 efficiency scale factor retrieval by index More...
 
CalibrationStatus getWeightScaleFactor (const CalibrationDataVariables &variables, unsigned int indexSF, unsigned int indexEff, Uncertainty unc, unsigned int numVariation, CalibResult &result)
 efficiency scale factor retrieval by index, with different signature More...
 
CalibrationStatus runEigenVectorRecomposition (const std::string &author, const std::string &label, const std::string &OP, unsigned int mapindex=0)
 run EigenVector Recomposition method More...
 
CalibrationStatus runEigenVectorRecomposition (const std::string &label, unsigned int mapindex=0)
 
std::map< std::string, std::map< std::string, float > > getEigenVectorRecompositionCoefficientMap ()
 Get Eigenvector recomposition map after running runEigenVectorRecomposition() More...
 
const TObject * getMCEfficiencyObject (const std::string &author, const std::string &label, const std::string &OP, unsigned int mapIndex=0)
 retrieve the MC efficiency (central values) object for the given flavour label and operating point. More...
 
const TH1 * getBinnedScaleFactors (const std::string &author, const std::string &label, const std::string &OP)
 retrieve the binned calibration object for the given flavour label and operating point. More...
 
const TH1 * getShiftedScaleFactors (const std::string &author, const std::string &label, const std::string &OP, const std::string &unc, double sigmas)
 retrieve the binned calibration object for the given flavour label and operating point, with the result shifted by the given number of standard deviations for the given systematic uncertainty. More...
 
TMatrixDSym getScaleFactorCovarianceMatrix (const std::string &author, const std::string &label, const std::string &OP, const std::string &unc="all")
 retrieve the named covariance matrix element corresponding to the binned calibration object. More...
 
void initialize (const std::string &jetauthor, const std::string &OP, Uncertainty unc)
 initialization for PROOF usage More...
 
CalibrationDataContainerretrieveContainer (const std::string &label, const std::string &OP, const std::string &author, const std::string &cntname, bool isSF, bool doPrint=true)
 utility function taking care of object retrieval More...
 
const std::string & EffCalibrationName (const std::string &flavour, unsigned int mapIndex=0) const
 Main interface methods accessing the flavour tagging performance information. More...
 
void setEffCalibrationNames (const std::map< std::string, std::vector< std::string > > &names)
 
const std::string & SFCalibrationName (const std::string &flavour) const
 
void setSFCalibrationNames (const std::map< std::string, std::string > &names)
 

Protected Member Functions

std::string getContainername (const std::string &flavour, bool SF, unsigned int mapIndex=0) const
 auxiliary function for retrieval of container name More...
 
std::string getBasename (const std::string &name) const
 auxiliary function for retrieval of name within the directory More...
 
double combinedUncertainty (double stat, const std::pair< double, double > &syst) const
 utility function for combination of statistical and (a priori asymmetric) systematic uncertainty. More...
 

Protected Attributes

std::string m_taggerName
 tagging algorithm name More...
 

Private Member Functions

std::string getAlias (const std::string &author) const
 associated alias retrieval method More...
 
bool checkAbsEta (const CalibrationDataVariables &variables, unsigned int index)
 
void increaseCounter (unsigned int index, OutOfBoundsType oob=Main)
 
void checkWeightScaleFactors (unsigned int indexSF, unsigned int indexEff)
 

Private Attributes

TFile * m_fileEff {}
 pointer to the TFile object providing access to the calibrations More...
 
TFile * m_fileSF {}
 Do not attempt to persistify (PROOF) More...
 
std::map< std::string, std::string > m_aliases
 Do not attempt to persistify (PROOF) More...
 
std::vector< CalibrationDataContainer * > m_objects
 cache the objects themselves (so that the user will not have to delete them after each call etc.). More...
 
std::map< std::string, unsigned int > m_objectIndices
 
std::string m_filenameSF
 in addition, store also the filenames themselves (needed for the copy constructor) More...
 
std::string m_filenameEff
 
std::vector< std::string > m_flavours
 
std::map< const CalibrationDataContainer *, std::shared_ptr< CalibrationDataEigenVariations > > m_eigenVariationsMap
 store the eigenvector class and associate to its CalibrationDataContainer More...
 
bool m_runEigenVectorMethod {}
 decide whether to run the eigenvector method or not More...
 
Uncertainty m_EVStrategy {}
 
std::map< std::string, Analysis::EVReductionStrategym_EVReductions
 Eigenvector reduction strategy (per flavour) More...
 
std::map< std::string, std::vector< std::string > > m_excludeFromCovMatrix
 store the uncertainties which should be excluded from building the full covariance matrix More...
 
bool m_useRecommendedEVExclusions {}
 if true, exclude pre-recommended lists of uncertainties from the covariance matrix building, in addition to the above user specified lists More...
 
bool m_verbose {}
 if true, allow also for some informational (and not only error/warning) messages More...
 
bool m_useMCMCSF {}
 specify whether or not to use MC/MC (hadronisation) scale factors (the fact that this is steerable is intended to be temporary only) More...
 
bool m_useTopologyRescaling {}
 specify whether or not to use MC/MC (topology) scale factors (also this steering option may be removed) More...
 
std::map< std::string, HadronisationReferenceHelper * > m_refMap
 the following maps (one for each directory) specify the name of the container serving as the 'hadronisation' reference for each object More...
 
std::vector< int > m_hadronisationReference
 store the 'hadronisation' reference for each object (-1 means no reference found) More...
 
std::map< std::string, std::map< std::string, float > > m_coefficientMap
 
double m_maxAbsEta {}
 |eta| bounds and strategy for dealing with out-of-bounds conditions More...
 
OutOfBoundsStrategy m_absEtaStrategy {}
 
OutOfBoundsStrategy m_otherStrategy {}
 
std::vector< unsigned int > m_etaCounters
 counters for flagging out-of-bound cases More...
 
std::vector< unsigned int > m_mainCounters
 
std::vector< unsigned int > m_extrapolatedCounters
 
std::vector< std::pair< unsigned int, unsigned int > > m_checkedWeightScaleFactors
 
double m_maxTagWeight {}
 
std::map< std::string, std::vector< std::string > > m_calibrationEffNames
 this simply collects the per-flavour properties. More...
 
std::map< std::string, std::string > m_calibrationSFNames
 

Detailed Description

This tool provides an interface to flavour tagging performance estimates.

A separate instance should be used for each different tagging algorithm. For each instance, all appropriate jet collections and tagger operating points need to be specified.

The model:

The idea is to use the same physical ROOT file that is also accessed through COOL, but to do so in a stand-alone fashion, so that there is no COOL or Athena dependence. Apart from this, the same infrastructure and limitations as with COOL access (

Definition at line 87 of file CalibrationDataInterfaceROOT.h.

Member Enumeration Documentation

◆ variableType

known variable types that can be used as function arguments

Enumerator
kEta 
kAbsEta 
kPt 

Definition at line 67 of file CalibrationDataInterfaceBase.h.

67 { kEta, kAbsEta, kPt };

Constructor & Destructor Documentation

◆ CalibrationDataInterfaceROOT() [1/4]

Analysis::CalibrationDataInterfaceROOT::CalibrationDataInterfaceROOT ( const std::string &  taggerName,
const std::string &  configname = "BTagCalibration.env",
const std::string &  pathname = "" 
)

main constructor for "stand-alone" use (with information fed in from a .env configuration file read by TEnv)

◆ CalibrationDataInterfaceROOT() [2/4]

Analysis::CalibrationDataInterfaceROOT::CalibrationDataInterfaceROOT ( const std::string &  taggerName,
const char *  fileSF,
const char *  fileEff,
const std::vector< std::string > &  jetAliases,
const std::map< std::string, std::string > &  SFNames,
const std::map< std::string, std::vector< std::string > > &  EffNames,
const std::map< std::string, std::vector< std::string > > &  excludeFromEV,
const std::map< std::string, Analysis::EVReductionStrategy > &  EVReductions,
bool  useEV = true,
Uncertainty  strat = SFEigen,
bool  useMCMCSF = true,
bool  useTopologyRescaling = false,
bool  useRecommendedEVExclusions = false,
bool  verbose = true,
std::vector< std::string >  flavours = {"B", "C", "Light", "T"} 
)

alternative constructor passing configuration information explicitly (so that no .env file is needed)

Definition at line 481 of file CalibrationDataInterfaceROOT.cxx.

490  :
491  m_filenameSF(fileSF), m_filenameEff(""), m_flavours(flavours),
492  m_runEigenVectorMethod(useEV), m_EVStrategy(strat), m_EVReductions(EVReductions),
493  m_useRecommendedEVExclusions(useRecommendedEEVExclusions), m_verbose(verbose),
494  m_useMCMCSF(useMCMCSF), m_useTopologyRescaling(useTopologyRescaling),
497 {
498  // Normal constructor avoiding the need for a .env file.
499  //
500  // taggerName: this should correspond to the tagger name as used in the calibration ROOT file
501  // fileSF: full path of the calibration ROOT file containing the calibration scale factors
502  // fileEff: optional full path name of a ROOT file containing additional MC efficiency maps
503  // (use a null pointer to disable the use of such additional file)
504  // flavours; This should correspond to the list of flavour labels that's used by a tagger, and
505  // which corresponds to the labels used in internal maps
506  // jetAliases: this can be used to convert jet collection names to the corresponding names in the
507  // calibration ROOT file (this may be useful as e.g. the collection names in the
508  // calibration ROOT file have the JVF criterion attached as a suffix).
509  // Each alias is specified as
510  // nameOrig->nameTarget,
511  // where nameOrig and nameTarget are the names of the input jet collection and the
512  // jet collection name as used in the calibration ROOT file, respectively.
513  // SFNames: map specifying for each of the calibration flavours ("B", "C", "T", "Light") the
514  // name of the scale factor calibration object
515  // EffNames: map specifying for each of the calibration flavours ("B", "C", "T", "Light") the
516  // names of the possibly relevant efficiency calibration objects
517  // excludeFromEV: map specifying for each of the calibration flavours ("B", "C", "T", "Light") the
518  // systematic uncertainties to be excluded from the Eigenvector variation treatment
519  // (this is used only if Eigenvector variations are used to begin with)
520  // EVReductions: Eigenvector variation reduction strategies for "B", "C", "Light" jets (again,
521  // this is only relevant if Eigenvector variations are used to begin with)
522  // useEV: switch specifying if Eigenvector variations will be used or not
523  // useMCMCSF: switch specifying if generator-dependent scale factors are to be applied or not
524 
525  // Note: at present, the means to change the strategies and maximum values initialized above do not exist
526  // when using this constructor
527 
528  if (m_verbose) {
529  cout << "=== CalibrationDataInterfaceROOT::CalibrationDataInterfaceROOT ===" << endl;
530  cout << " taggerName : " << taggerName.c_str() << endl;
531  cout << " Systematic strategy : ";
533  cout << "SFEigen" << endl;
535  cout << "SFGlobalEigen" << endl;
536  } else {
537  cout << " Other" << endl;
538  }
539  if (fileEff) cout << " Efficiency file name : " << fileEff << endl;
540  cout << " SF file name : " << fileSF << endl
541  << endl;
542  }
543 
544  m_taggerName = taggerName;
545 
546  m_fileSF = TFile::Open(fileSF, "READ");
547  if (fileEff && strcmp(fileSF, fileEff) != 0) {
548  m_filenameEff = string(fileEff);
549  m_fileEff = TFile::Open(fileEff, "READ");
550  } else
552 
553  if (m_verbose) {
554  TObjString* s;
555  m_fileSF->GetObject("VersionInfo/BuildNumber", s);
556  if (s) cout << " CDI file build number: " << s->GetName() << endl;
557  cout << endl;
558  }
559 
560  for (unsigned int i = 0; i < jetAliases.size(); ++i) {
561  // Each alias specification uses an arrow ("->"). Forget about entries
562  // not properly following this specification.
563  string::size_type arrow = jetAliases[i].find("->");
564  if (arrow == string::npos) continue;
565  m_aliases[jetAliases[i].substr(0,arrow)] = jetAliases[i].substr(arrow+2);
566  }
567 
568  setEffCalibrationNames(EffNames);
569  setSFCalibrationNames(SFNames);
570 
571  if (m_runEigenVectorMethod) {
572  // if we want to run EV, then decide which one
573  // The following should hold for both eigenvector decomposition methods (SFEigen and SFGlobalEigen)
574  // The global one simply adapts itself to using the m_excludeFromCovMatrix to perform the same task
575 
576  m_excludeFromCovMatrix = excludeFromEV;
577  unsigned int n_excluded = 0;
578  for (auto const& flavour : m_flavours) {
579  n_excluded += m_excludeFromCovMatrix[flavour].size();
580  }
581  if (m_verbose) {
582  cout << " List of uncertainties to exclude:";
583  if (n_excluded == 0) cout << " none";
584  for (auto const& flavour : m_flavours) {
585  if (m_excludeFromCovMatrix[flavour].size() > 0) {
586  cout << "\n\t" << flavour << ":\t";
587  for (unsigned int i = 0; i < m_excludeFromCovMatrix[flavour].size(); ++i) {
588  cout << m_excludeFromCovMatrix[flavour].at(i);
589  if (i+1 == m_excludeFromCovMatrix[flavour].size()) cout << "; ";
590  }
591  cout << endl;
592  }
593  }
594  cout << endl;
595  }
596 
597  }
598 
599  if (m_verbose) cout << "======= end of CalibrationDataInterfaceROOT instantiation ========" << endl;
600 }

◆ CalibrationDataInterfaceROOT() [3/4]

Analysis::CalibrationDataInterfaceROOT::CalibrationDataInterfaceROOT ( )

default constructor for PROOF object retrieval

Definition at line 603 of file CalibrationDataInterfaceROOT.cxx.

604 {
605  // Default constructor for PROOF purposes
606 
607  m_fileEff=0;
608  m_fileSF=0;
609 }

◆ CalibrationDataInterfaceROOT() [4/4]

Analysis::CalibrationDataInterfaceROOT::CalibrationDataInterfaceROOT ( const CalibrationDataInterfaceROOT other)

copy constructor

Definition at line 612 of file CalibrationDataInterfaceROOT.cxx.

612  :
614  m_filenameSF(other.m_filenameSF), m_filenameEff(other.m_filenameEff),
615  m_eigenVariationsMap(), m_runEigenVectorMethod(other.m_runEigenVectorMethod), m_EVStrategy(other.m_EVStrategy),
616  m_excludeFromCovMatrix(other.m_excludeFromCovMatrix), m_useMCMCSF(other.m_useMCMCSF), m_useTopologyRescaling(other.m_useTopologyRescaling),
618  m_maxAbsEta(other.m_maxAbsEta), m_absEtaStrategy(other.m_absEtaStrategy), m_otherStrategy(other.m_otherStrategy),
619  m_etaCounters(other.m_etaCounters), m_mainCounters(other.m_mainCounters), m_extrapolatedCounters(other.m_extrapolatedCounters),
620  m_checkedWeightScaleFactors(other.m_checkedWeightScaleFactors), m_maxTagWeight(other.m_maxTagWeight)
621 {
622  // Copy constructor. Note that the "cacheable" items aren't copied (they will be re-created if needed)
623 
624  // The TFile objects cannot be copied. Therefore, create duplicate objects starting from the filenames
625  m_fileSF = TFile::Open(m_filenameSF.c_str(), "READ");
628  else
629  m_fileEff = TFile::Open(m_filenameEff.c_str(), "READ");
630 }

◆ ~CalibrationDataInterfaceROOT()

Analysis::CalibrationDataInterfaceROOT::~CalibrationDataInterfaceROOT ( )
virtual

default destructor

Definition at line 633 of file CalibrationDataInterfaceROOT.cxx.

634 {
635  // Destructor
636  if ((m_fileEff!=0) && (m_fileSF!=0)) {
637  if (m_fileEff == m_fileSF) {
638  m_fileEff->Close();
639  delete m_fileEff; m_fileEff = 0;
640  } else {
641  m_fileEff->Close();
642  m_fileSF->Close();
643  delete m_fileEff; m_fileEff = 0;
644  delete m_fileSF; m_fileSF = 0;
645  }
646  }
647  // delete also the stored objects (these are owned by us)
649  if (*it) {
650  delete *it; *it = 0;
651  }
652  }
653 
655  it != m_refMap.end(); ++it) {
656  if(it->second)
657  { delete it->second; it->second=nullptr; }
658  }
659 
660  // Print summary output on out-of-bounds issues
661  if (m_absEtaStrategy == Flag && m_verbose) {
662  bool found = false;
663  cout << "\t\tCalibrationDataInterfaceROOT |eta| out-of-bounds summary:" << endl;
664  for (unsigned int index = 0; index < m_mainCounters.size(); ++index)
665  if (m_etaCounters[index] > 0) {
666  found = true;
667  cout << "\t\t\t" << nameFromIndex(index) << ": " << m_etaCounters[index] << endl;
668  }
669  if (!found) cout << "\t\t\tNo issues found" << endl;
670  }
671  if (m_otherStrategy == Flag && m_verbose) {
672  bool found = false;
673  cout << "\t\tCalibrationDataInterfaceROOT object out-of-bounds summary:" << endl;
674  for (unsigned int index = 0; index < m_mainCounters.size(); ++index)
676  found = true;
677  cout << "\t\t\t" << nameFromIndex(index)
678  << " general: " << m_mainCounters[index]
679  << ", extrapolated: " << m_extrapolatedCounters[index]
680  << endl;
681  }
682  if (!found) cout << "\t\t\tNo issues found" << endl;
683  }
684 }

Member Function Documentation

◆ checkAbsEta()

bool Analysis::CalibrationDataInterfaceROOT::checkAbsEta ( const CalibrationDataVariables variables,
unsigned int  index 
)
private

Definition at line 1919 of file CalibrationDataInterfaceROOT.cxx.

1921 {
1922  // Check whether the jet eta value is outside the range of validity, subject to the strategy
1923  // specified in the configuration file.
1924  bool pass = true;
1925  if (m_absEtaStrategy == Ignore) return pass;
1926 
1927  switch (m_absEtaStrategy) {
1928  case GiveUp:
1929  if (std::fabs(variables.jetEta) > m_maxAbsEta) {
1930  pass = false;
1931  }
1932  break;
1933  case Flag:
1934  default:
1935  if (std::fabs(variables.jetEta) > m_maxAbsEta) {
1937  }
1938 
1939  }
1940  return pass;
1941 }

◆ checkWeightScaleFactors()

void Analysis::CalibrationDataInterfaceROOT::checkWeightScaleFactors ( unsigned int  indexSF,
unsigned int  indexEff 
)
private

Definition at line 1763 of file CalibrationDataInterfaceROOT.cxx.

1765 {
1766  // Check the tag weight scale factors that would result from the combination of
1767  // the provided scale factor and MC tag weight objects.
1768  // The way this is done is by determining the binning that would apply to the
1769  // combination of the two individual inputs, and then by explicitly computing
1770  // the scale factors in each of these resulting bins.
1771 
1772  std::vector<std::pair<unsigned int, unsigned int> >::const_iterator it = std::find(m_checkedWeightScaleFactors.begin(), m_checkedWeightScaleFactors.end(), std::make_pair(indexSF, indexEff));
1773  if (it != m_checkedWeightScaleFactors.end()) return;
1774 
1775 
1776  // Assume that only histogram containers are involved here (this should be the case
1777  // as at least a strict tag weight binning should be applied).
1778  CalibrationDataHistogramContainer* container = dynamic_cast<CalibrationDataHistogramContainer*>(m_objects[indexSF]);
1779  if (! container) {
1780  cerr << "CalibrationDataInterfaceROOT::checkWeightScaleFactors: error: container for object " << nameFromIndex(indexSF) << " not found!" << endl;
1781  return;
1782  } else if (! container->GetValue("MCreference")) {
1783  cerr << "CalibrationDataInterfaceROOT::checkWeightScaleFactors: error: no MCreference histogram for object " << nameFromIndex(indexSF) << "!" << endl;
1784  return;
1785  }
1786  CalibrationDataHistogramContainer* effContainer = dynamic_cast<CalibrationDataHistogramContainer*>(m_objects[indexEff]);
1787  if (! effContainer) {
1788  cerr << "CalibrationDataInterfaceROOT::checkWeightScaleFactors: error: container for object " << nameFromIndex(indexEff) << " not found!" << endl;
1789  return;
1790  }
1791 
1792  // Retrieve the variable types and corresponding bin boundaries
1793  std::vector<unsigned int> vars = container->getVariableTypes();
1794  std::vector<unsigned int> effVars = effContainer->getVariableTypes();
1795  // Retrieve the corresponding bin boundaries
1796  std::map<unsigned int, std::vector<double> > boundaries, effBoundaries, mergedBoundaries;
1797  for (unsigned int t = 0; t < vars.size(); ++t)
1798  boundaries[vars[t]] = container->getBinBoundaries(vars[t]);
1799  for (unsigned int t = 0; t < effVars.size(); ++t)
1800  effBoundaries[effVars[t]] = effContainer->getBinBoundaries(effVars[t]);
1801 
1802  // Special case: handle |eta| versus eta differences, by transforming to the latter
1803  if (boundaries.find(CalibrationDataContainer::kEta) == boundaries.end() && boundaries.find(CalibrationDataContainer::kAbsEta) != boundaries.end()) {
1805  boundaries.erase(CalibrationDataContainer::kAbsEta);
1806  }
1807  if (effBoundaries.find(CalibrationDataContainer::kEta) == effBoundaries.end() && effBoundaries.find(CalibrationDataContainer::kAbsEta) != effBoundaries.end()) {
1808  effBoundaries[CalibrationDataContainer::kEta] = effBoundaries[CalibrationDataContainer::kAbsEta];
1809  effBoundaries.erase(CalibrationDataContainer::kAbsEta);
1810  }
1811  if (boundaries.find(CalibrationDataContainer::kEta) != boundaries.end() && effBoundaries.find(CalibrationDataContainer::kEta) != effBoundaries.end()) {
1812  std::vector<double>& v = boundaries[CalibrationDataContainer::kEta];
1813  std::vector<double>& vEff = effBoundaries[CalibrationDataContainer::kEta];
1814  if (v[0] < 0 && vEff[0] >= 0) {
1815  // in this case, supplement the positive entries in vEff with their negative analogues
1816  std::vector<double> vtmp(vEff);
1817  for (std::vector<double>::iterator it = vtmp.begin(); it != vtmp.end(); ++it)
1818  if (*it > 0) vEff.insert(vEff.begin(), -(*it));
1819  } else if (v[0] >= 0 && vEff[0] < 0) {
1820  // in this case, supplement the positive entries in v with their negative analogues
1821  std::vector<double> vtmp(v);
1822  for (std::vector<double>::iterator it = vtmp.begin(); it != vtmp.end(); ++it)
1823  if (*it > 0) v.insert(v.begin(), -(*it));
1824  }
1825  }
1826 
1827  // Now that the individual sets of boundaries have been determined, merge these
1828  for (unsigned int t = 0; t < vars.size(); ++t) {
1829  if (effBoundaries.find(vars[t]) == effBoundaries.end())
1830  // Variables not present in the efficiency object can go in unmodified
1831  mergedBoundaries[vars[t]] = boundaries[vars[t]];
1832  else {
1833  // Merge the boundaries for variables existing in both objects.
1834  // Take the MC array as a starting point, as it's likely to be the longest.
1835  mergedBoundaries[vars[t]] = effBoundaries[vars[t]];
1836 
1837  for (std::vector<double>::iterator it = boundaries[vars[t]].begin(); it != boundaries[vars[t]].end(); ++it) {
1838  std::vector<double>::iterator itcmp = mergedBoundaries[vars[t]].begin();
1839  // Iterate until we've found a value in the target array equal to
1840  // or larger than the given element
1841  while (itcmp != mergedBoundaries[vars[t]].end() &&
1843  *itcmp < *it) ++itcmp;
1844  // Nothing needs to be done if the values are "nearly identical"
1845  // (or if we don't find such an element).
1846  if (itcmp == mergedBoundaries[vars[t]].end() || CalibrationDataContainer::isNearlyEqual(*itcmp, *it)) continue;
1847  // Otherwise insert the given element (this can mean adding to the end)
1848  mergedBoundaries[vars[t]].insert(itcmp, *it);
1849  }
1850  }
1851  }
1852  // Variables not present in the scale factor object still need to go in
1853  for (unsigned int t = 0; t < effVars.size(); ++t)
1854  if (boundaries.find(effVars[t]) == boundaries.end())
1855  mergedBoundaries[effVars[t]] = effBoundaries[effVars[t]];
1856 
1857  // Carry out a rudimentary cross-check of the tag weight bin
1858  // (the binning used for the scale factor and MC objects should be identical).
1859  if (boundaries.find(CalibrationDataContainer::kTagWeight) == boundaries.end()) {
1860  cerr << "CalibrationDataInterfaceROOT::checkWeightScaleFactors: " << "no tag weight axis found for object " << nameFromIndex(indexSF) << endl;
1861  } else if (effBoundaries.find(CalibrationDataContainer::kTagWeight) == effBoundaries.end()) {
1862  cerr << "CalibrationDataInterfaceROOT::checkWeightScaleFactors: " << "no tag weight axis found for object " << nameFromIndex(indexEff) << endl;
1863  } else if (boundaries[CalibrationDataContainer::kTagWeight].size() != effBoundaries[CalibrationDataContainer::kTagWeight].size()) {
1864  cerr << "CalibrationDataInterfaceROOT::checkWeightScaleFactors: " << "different tag weight binning for objects " << nameFromIndex(indexSF) << " (";
1865  std::vector<double>& v = boundaries[CalibrationDataContainer::kTagWeight];
1866  for (unsigned int ib = 0; ib < v.size()-1; ++ib) cerr << v[ib] << ",";
1867  cerr << v[v.size()-1] << ") and " << nameFromIndex(indexEff) << " (";
1868  v = effBoundaries[CalibrationDataContainer::kTagWeight];
1869  for (unsigned int ib = 0; ib < v.size()-1; ++ib) cerr << v[ib] << ",";
1870  cerr << v[v.size()-1] << ") do not match!" << endl;
1871  } else {
1872  // Make sure that (possibly) dummy vectors exist for _all_ known variables
1873  // (this is a mere technicality allowing to loop over all variables explicitly).
1874  if (mergedBoundaries.find(CalibrationDataContainer::kPt) == mergedBoundaries.end()) {
1875  std::vector<double> v; v.push_back(20.); v.push_back(300.); mergedBoundaries[CalibrationDataContainer::kPt] = v;
1876  }
1877  if (mergedBoundaries.find(CalibrationDataContainer::kEta) == mergedBoundaries.end()) {
1878  std::vector<double> v; v.push_back(-2.5); v.push_back(2.5); mergedBoundaries[CalibrationDataContainer::kEta] = v;
1879  }
1880  // Finally, carry out the cross-check that all this is about: recompute the scale factor
1881  // in each pseudo-bin
1882  if (m_verbose){
1883  cout << "CalibrationDataInterfaceROOT::checkWeightScaleFactors: cross-checking scale factors for objects " << nameFromIndex(indexSF) << " and " << nameFromIndex(indexEff) << "\n" << std::setfill('-') << std::setw(100) << "-" << endl;
1884  cout << std::setfill(' ');
1885  }
1886  CalibrationDataVariables x;
1887  std::vector<double>& vPt = mergedBoundaries[CalibrationDataContainer::kPt], vEta = mergedBoundaries[CalibrationDataContainer::kEta], vTagWeight = mergedBoundaries[CalibrationDataContainer::kTagWeight];
1888  for (unsigned int ipt = 0; ipt < vPt.size()-1; ++ipt) {
1889  x.jetPt = (vPt[ipt] + vPt[ipt+1]) * 500.; // account for MeV -> GeV conversion
1890  for (unsigned int ieta = 0; ieta < vEta.size()-1; ++ieta) {
1891  x.jetEta = (vEta[ieta] + vEta[ieta+1]) / 2.;
1892  for (unsigned int iwt = 0; iwt < vTagWeight.size()-1; ++iwt) {
1893  x.jetTagWeight = (vTagWeight[iwt] + vTagWeight[iwt+1]) / 2.;
1894  // Retrieve the central scale factor value and the old and new MC tag weight fractions
1895  double value;
1896  container->getResult(x, value);
1897  Analysis::UncertaintyResult uncertaintyResult(0,0);
1898  container->getUncertainty("MCreference", x, uncertaintyResult);
1899  double fracMCref = uncertaintyResult.first;
1900  double fracMCnew;
1901  effContainer->getResult(x, fracMCnew);
1902  // Compute the new scale factor value
1903  if (!(fracMCnew > 0.)) {
1904  cout << "\tfor (pt=" << x.jetPt << ",eta=" << x.jetEta << ",tagweight=" << x.jetTagWeight << "): invalid new MC fraction: " << fracMCnew << endl;
1905  } else {
1906  double newvalue = 1.0 + (value - 1.0) * fracMCref/fracMCnew;
1907  if (newvalue <= 0 || newvalue > m_maxTagWeight) cout << "\tfor (pt=" << x.jetPt << ",eta=" << x.jetEta << ",tagweight=" << x.jetTagWeight << "): old (value=" << value << ",MC=" << fracMCref << "), new (value=" << newvalue << ",MC=" << fracMCnew << ")" << endl;
1908  }
1909  }
1910  }
1911  }
1912  }
1913 
1914  m_checkedWeightScaleFactors.push_back(std::make_pair(indexSF, indexEff));
1915 }

◆ combinedUncertainty()

double Analysis::CalibrationDataInterfaceBase::combinedUncertainty ( double  stat,
const std::pair< double, double > &  syst 
) const
protectedinherited

utility function for combination of statistical and (a priori asymmetric) systematic uncertainty.

NB perhaps this should be in its own

Definition at line 147 of file CalibrationDataInterfaceBase.cxx.

149 {
150  // Return the total (combined statistical and systematic) uncertainty started from
151  // its individual components. The result is symmetrised by using only the larger of
152  // the (a priori asymmetric) up- and downward systematic uncertainties.
153 
154  // The systematic uncertainty is (a priori) asymmetric, but this interface doesn't
155  // at present allow for asymmetric uncertainties.
156  // Address this by taking the larger (absolute) value of the two.
157  double largest = syst.first;
158  if (TMath::Abs(syst.second) > TMath::Abs(largest)) largest = syst.second;
159 
160  return TMath::Sqrt(stat*stat + largest*largest);
161 }

◆ EffCalibrationName()

const std::string & Analysis::CalibrationDataInterfaceBase::EffCalibrationName ( const std::string &  flavour,
unsigned int  mapIndex = 0 
) const
inherited

Main interface methods accessing the flavour tagging performance information.

Note that for both of the following, the label is assumed to adhere to the TruthInfo conventions (see package PhysicsAnalysis/JetTagging/JetTagInfo).

Definition at line 47 of file CalibrationDataInterfaceBase.cxx.

49 {
50  // Return the MC efficiency name for the given flavour.
51  // Note that no check is performed on the validity of the flavour.
52 
53  try {
54  return m_calibrationEffNames.at(flavour)[mapIndex];
55  }
56  catch (const std::out_of_range& e) {
57  std::cerr << "EffCalibrationName: flavour '" << flavour << "' is not known." << std::endl;
58  throw e;
59  }
60 }

◆ fullName()

string Analysis::CalibrationDataInterfaceROOT::fullName ( const std::string &  author,
const std::string &  OP,
const std::string &  label,
bool  isSF,
unsigned  mapIndex = 0 
) const

@ brief construct the full object pathname from its individual components

Definition at line 2721 of file CalibrationDataInterfaceROOT.cxx.

2724 {
2725  // Construct the full calibration object's pathname within the calibration ROOT file.
2726  //
2727  // author: jet collection name
2728  // OP: tagger working point
2729  // label: jet flavour label
2730  // isSF: set to true (false) for scale factors (MC efficiencies)
2731  // mapIndex: index in the list of MC efficiency calibration objects
2732 
2733  string flavour = (label == "N/A") ? "Light" : label;
2734  string full(m_taggerName + "/" + getAlias(author) + "/" + OP + "/" + flavour + "/");
2735  full += getContainername(flavour, isSF, mapIndex);
2736  // full += getAlias(author); full += "/";
2737  // string name = (isSF) ?
2738  // getBasename(OP, label, "_SF", true) :
2739  // getBasename(OP, label, "_Eff", false, mapIndex);
2740  // full += name;
2741  return full;
2742 }

◆ getAlias()

string Analysis::CalibrationDataInterfaceROOT::getAlias ( const std::string &  author) const
private

associated alias retrieval method

Definition at line 2710 of file CalibrationDataInterfaceROOT.cxx.

2711 {
2712  // Return the alias for the given jet collection name, if an alias exists.
2713  // If this is not the case, the return value will simply equal the input jet collection name.
2714 
2715  std::map<string,string>::const_iterator it = m_aliases.find(author);
2716  return (it == m_aliases.end()) ? author : it->second;
2717 }

◆ getBasename()

std::string Analysis::CalibrationDataInterfaceBase::getBasename ( const std::string &  name) const
protectedinherited

auxiliary function for retrieval of name within the directory

Definition at line 138 of file CalibrationDataInterfaceBase.cxx.

139 {
140  // Retrieve the name within the directory starting from the full name
141 
142  return name.substr(name.find_last_of('/')+1, std::string::npos);
143 }

◆ getBinnedScaleFactors()

const TH1 * Analysis::CalibrationDataInterfaceROOT::getBinnedScaleFactors ( const std::string &  author,
const std::string &  label,
const std::string &  OP 
)

retrieve the binned calibration object for the given flavour label and operating point.

A null result will be returned in case of error (e.g. if the calibration object isn't binned to begin with).

Definition at line 2108 of file CalibrationDataInterfaceROOT.cxx.

2111 {
2112  // Retrieve the actual histogrammed calibration scale factors, identifying the object by name.
2113  //
2114  // author: jet collection name
2115  // label: jet flavour label
2116  // OP: tagger working point
2117 
2118  unsigned int index;
2119  if (! retrieveCalibrationIndex (label, OP, author, true, index)) {
2120  // Return a dummy result if the object is not found
2121  cerr << "getBinnedScaleFactors: unable to find SF calibration for object " << fullName(author, OP, label, true) << endl;
2122  return 0;
2123  }
2124  CalibrationDataHistogramContainer* container = dynamic_cast<CalibrationDataHistogramContainer*>(m_objects[index]);
2125  return (container) ? dynamic_cast<TH1*>(container->GetValue("result")) : 0;
2126 }

◆ getContainername()

std::string Analysis::CalibrationDataInterfaceBase::getContainername ( const std::string &  flavour,
bool  SF,
unsigned int  mapIndex = 0 
) const
protectedinherited

auxiliary function for retrieval of container name

Definition at line 118 of file CalibrationDataInterfaceBase.cxx.

120 {
121  // Construct the full pathname corresponding to the container indicated by the combination
122  // of tagging operating point, jet flavour, and a possible extra extension. The calibration
123  // container name (stored internally) is also attached.
124 
125  const std::vector<std::string>& effNames = m_calibrationEffNames.at(flavour);
126  if (!SF && mapIndex >= effNames.size()) {
127  std::cerr << "getContainername: given mapIndex=" << mapIndex << " incompatible with array size "
128  << effNames.size() << "; resetting to 0" << std::endl;
129  mapIndex = 0;
130  }
131  std::string name = SF ? m_calibrationSFNames.at(flavour) : effNames[mapIndex];
132  name += SF ? "_SF" : "_Eff";
133 
134  return name;
135 }

◆ getEfficiency() [1/3]

Analysis::CalibResult Analysis::CalibrationDataInterfaceROOT::getEfficiency ( const CalibrationDataVariables variables,
const std::string &  label,
const std::string &  OP,
Uncertainty  unc,
const std::string &  flavour,
unsigned int  numVariation = 0,
unsigned int  mapIndex = 0 
)

efficiency retrieval by name

Definition at line 1071 of file CalibrationDataInterfaceROOT.cxx.

1075 {
1076  // Data efficiency retrieval identifying the requested calibration objects by name.
1077  // The data efficiency is computed as the product of MC efficiency and data/MC efficiency scale factor.
1078  // The return value is either a (value, uncertainty) or an (up, down) variation pair, as documented
1079  // above, and will be a dummy value in case an error occurs.
1080  //
1081  // variables: object holding kinematic (and other) information needed to compute the result
1082  // label: jet flavour label
1083  // OP: tagger operating point
1084  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
1085  // named variations are to be computed)
1086  // numVariation: variation index (in case of eigenvector or named variations)
1087  // mapIndex: index to the efficiency map to be used
1088 
1089  unsigned int indexSF, indexEff;
1090  if (! (retrieveCalibrationIndex (label, OP, variables.jetAuthor, false, indexEff, mapIndex) &&
1091  retrieveCalibrationIndex (label, OP, variables.jetAuthor, true, indexSF))) {
1092  cerr << "getEfficiency: unable to find Eff calibration for object " << fullName(variables.jetAuthor, OP, label, false, mapIndex) << " or SF calibration for object " << fullName(variables.jetAuthor, OP, label, true) << endl;
1093  // Return a dummy result if the object is not found
1094  return Analysis::dummyResult;
1095  }
1096 
1098  return (getEfficiency(variables, indexSF, indexEff, unc, numVariation, result, flavour) == Analysis::kError) ? Analysis::dummyResult : result;
1099 }

◆ getEfficiency() [2/3]

Analysis::CalibResult Analysis::CalibrationDataInterfaceROOT::getEfficiency ( const CalibrationDataVariables variables,
unsigned int  indexSF,
unsigned int  indexEff,
Uncertainty  unc,
const std::string &  flavour,
unsigned int  numVariation = 0 
)

efficiency retrieval by index

Definition at line 1103 of file CalibrationDataInterfaceROOT.cxx.

1106 {
1107  // Data efficiency retrieval identifying the requested calibration objects by index.
1108  // The data efficiency is computed as the product of MC efficiency and data/MC efficiency scale factor.
1109  // The return value is either a (value, uncertainty) or an (up, down) variation pair, as documented
1110  // above, and will be a dummy value in case an error occurs.
1111  //
1112  // variables: object holding kinematic (and other) information needed to compute the result
1113  // indexSF: index to scale factor calibration object
1114  // indexEff: index to MC efficiency object
1115  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
1116  // named variations are to be computed)
1117  // numVariation: variation index (in case of eigenvector or named variations)
1118 
1120  return (getEfficiency(variables, indexSF, indexEff, unc, numVariation, result, flavour) == Analysis::kError) ?
1122 }

◆ getEfficiency() [3/3]

Analysis::CalibrationStatus Analysis::CalibrationDataInterfaceROOT::getEfficiency ( const CalibrationDataVariables variables,
unsigned int  indexSF,
unsigned int  indexEff,
Uncertainty  unc,
unsigned int  numVariation,
Analysis::CalibResult result,
const std::string &  flavour 
)

efficiency retrieval by index

Definition at line 1126 of file CalibrationDataInterfaceROOT.cxx.

1130 {
1131  // Data efficiency retrieval identifying the requested calibration objects by index.
1132  //
1133  // variables: object holding kinematic (and other) information needed to compute the result
1134  // indexSF: index to scale factor calibration object
1135  // indexEff: index to MC efficiency object
1136  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
1137  // named variations are to be computed)
1138  // numVariation: variation index (in case of eigenvector or named variations)
1139  // result: (value, uncertainty) or (up, down) variation pair, depending on the unc value.
1140  // A dummy value will be returned in case of an error.
1141 
1142  Analysis::CalibResult sfResult;
1143  Analysis::CalibrationStatus sfStatus = getScaleFactor(variables, indexSF, indexEff, unc, numVariation, sfResult, flavour);
1144  if (sfStatus == Analysis::kError) return sfStatus;
1145  Analysis::CalibResult effResult;
1146  Analysis::CalibrationStatus effStatus= getMCEfficiency(variables, indexEff, unc, effResult);
1147  if (effStatus == Analysis::kError) return effStatus;
1148 
1149  double relative = 0;
1150  double value = effResult.first;
1151  if (TMath::Abs(sfResult.first) > Analysis::CalibZERO) {
1152  value = std::min(effResult.first*sfResult.first, 1.);
1153 
1154  // Treat the scale factor variation cases separately since the contents of the CalibResult are different
1155  // (e.g. 'value' above contains the upward variation)
1156  if (unc == SFEigen || unc == SFNamed) {
1157  double valueDown = effResult.first*sfResult.second;
1158  result.first = value; // up/down variataions of data-efficiency
1159  result.second = valueDown;
1160  return sfStatus;
1161  }
1162  if (value > 0.) {
1163  relative = effResult.second/effResult.first;
1164  double sfRelative = sfResult.second/sfResult.first;
1165  /*
1166  cout << "sferr=" << sfResult.second
1167  << "btag Calib relative=" << relative << " sfRelative=" << sfRelative << endl;
1168  */
1169  relative = TMath::Sqrt(sfRelative*sfRelative + relative*relative);
1170  }
1171  } else {
1172  // now never happens due to protection of SF return value:
1173  cerr << "ERROR: CalibrationDataInterfaceROOT::getEfficiency: SF null result, SF=" << sfResult.first << " MC eff=" << effResult.first << "; setting SF=1." << endl;
1174  relative = Analysis::dummyValue;
1175  }
1176 
1177  result.first = value;
1178  result.second = value*relative;
1179  // "Select" the status code for the actual calibration (it is subject to more constraints)
1180  return sfStatus;
1181 }

◆ getEigenVectorRecompositionCoefficientMap()

std::map< std::string, std::map< std::string, float > > Analysis::CalibrationDataInterfaceROOT::getEigenVectorRecompositionCoefficientMap ( )

Get Eigenvector recomposition map after running runEigenVectorRecomposition()

Definition at line 2267 of file CalibrationDataInterfaceROOT.cxx.

2267  {
2268  if(m_coefficientMap.empty())
2269  cerr << "getCoefficientMap: Call runEigenVectorRecomposition() before retrieving coefficient map! " <<endl;
2270  return m_coefficientMap;
2271 }

◆ getInefficiency() [1/3]

Analysis::CalibResult Analysis::CalibrationDataInterfaceROOT::getInefficiency ( const CalibrationDataVariables variables,
const std::string &  label,
const std::string &  OP,
Uncertainty  unc,
unsigned int  numVariation = 0,
unsigned int  mapIndex = 0 
)

inefficiency retrieval by name

Definition at line 1307 of file CalibrationDataInterfaceROOT.cxx.

1311 {
1312  // Data inefficiency retrieval identifying the requested calibration objects by name.
1313  // The data efficiency is computed as the product of MC efficiency and data/MC efficiency scale factor;
1314  // the inefficiency is then computed as the 1 minus the efficiency.
1315  // The return value is either a (value, uncertainty) or an (up, down) variation pair, as documented
1316  // above, and will be a dummy value in case an error occurs.
1317  //
1318  // variables: object holding kinematic (and other) information needed to compute the result
1319  // label: jet flavour label
1320  // OP: tagger operating point
1321  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
1322  // named variations are to be computed)
1323  // numVariation: variation index (in case of eigenvector or named variations)
1324  // mapIndex: index to the efficiency map to be used
1325 
1326  unsigned int indexSF, indexEff;
1327  if (! (retrieveCalibrationIndex (label, OP, variables.jetAuthor, false, indexEff, mapIndex) &&
1328  retrieveCalibrationIndex (label, OP, variables.jetAuthor, true, indexSF))) {
1329  cerr << "getInefficiency: unable to find Eff calibration for object "
1330  << fullName(variables.jetAuthor, OP, label, false, mapIndex)
1331  << " or SF calibration for object "
1332  << fullName(variables.jetAuthor, OP, label, true) << endl;
1333  // Return a dummy result if the object is not found
1334  return Analysis::dummyResult;
1335  }
1336 
1338  return (getInefficiency(variables, indexSF, indexEff, unc, numVariation, result, label) == Analysis::kError) ?
1340 }

◆ getInefficiency() [2/3]

Analysis::CalibResult Analysis::CalibrationDataInterfaceROOT::getInefficiency ( const CalibrationDataVariables variables,
unsigned int  indexSF,
unsigned int  indexEff,
Uncertainty  unc,
const std::string &  flavour,
unsigned int  numVariation = 0 
)

inefficiency retrieval by index

Definition at line 1344 of file CalibrationDataInterfaceROOT.cxx.

1347 {
1348  // Data inefficiency retrieval identifying the requested calibration objects by index.
1349  // The data efficiency is computed as the product of MC efficiency and data/MC efficiency scale factor;
1350  // the inefficiency is then computed as the 1 minus the efficiency.
1351  // The return value is either a (value, uncertainty) or an (up, down) variation pair, as documented
1352  // above, and will be a dummy value in case an error occurs.
1353  //
1354  // variables: object holding kinematic (and other) information needed to compute the result
1355  // indexSF: index to scale factor calibration object
1356  // indexEff: index to MC efficiency object
1357  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
1358  // named variations are to be computed)
1359  // numVariation: variation index (in case of eigenvector or named variations)
1360 
1362  return (getInefficiency(variables, indexSF, indexEff, unc, numVariation, result, flavour) == Analysis::kError) ?
1364 }

◆ getInefficiency() [3/3]

Analysis::CalibrationStatus Analysis::CalibrationDataInterfaceROOT::getInefficiency ( const CalibrationDataVariables variables,
unsigned int  indexSF,
unsigned int  indexEff,
Uncertainty  unc,
unsigned int  numVariation,
Analysis::CalibResult result,
const std::string &  flavour 
)

inefficiency retrieval by index

Definition at line 1368 of file CalibrationDataInterfaceROOT.cxx.

1372 {
1373  // Data inefficiency retrieval identifying the requested calibration objects by index.
1374  // The data efficiency is computed as the product of MC efficiency and data/MC efficiency scale factor;
1375  // the inefficiency is then computed as the 1 minus the efficiency.
1376  //
1377  // variables: object holding kinematic (and other) information needed to compute the result
1378  // indexSF: index to scale factor calibration object
1379  // indexEff: index to MC efficiency object
1380  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
1381  // named variations are to be computed)
1382  // numVariation: variation index (in case of eigenvector or named variations)
1383  // result: (value, uncertainty) or (up, down) variation pair, depending on the unc value.
1384  // A dummy value will be returned in case of an error.
1385 
1386  Analysis::CalibResult sfResult;
1387  Analysis::CalibrationStatus sfStatus = getScaleFactor(variables, indexSF, indexEff, unc, numVariation, sfResult, flavour);
1388  if (sfStatus == Analysis::kError) return sfStatus;
1389  Analysis::CalibResult effResult;
1390  Analysis::CalibrationStatus effStatus= getMCEfficiency(variables, indexEff, unc, effResult);
1391  if (effStatus == Analysis::kError) return effStatus;
1392 
1393  double val = std::max(0., 1. - effResult.first * sfResult.first);
1394  double err = 0.; // Analysis::dummyValue;
1395 
1396  // Bail out here if not both results are strictly positive
1397  if (effResult.first <= 0. || sfResult.first <= 0.) return Analysis::kError;
1398 
1399  // Treat the scale factor variation cases separately since the contents of the CalibResult are different
1400  // (e.g. 'val' above contains the upward variation)
1401  if (unc == SFEigen || unc == SFNamed) {
1402  double valDown = std::max(0., 1. - effResult.first*sfResult.second);
1403 
1404  result.first = val;
1405  result.second = valDown;
1406  } else {
1407  // safer than pow(x, 2):
1408  err = effResult.second/effResult.first*effResult.second/effResult.first
1409  + sfResult.second/sfResult.first*sfResult.second/sfResult.first;
1410  err = val*TMath::Sqrt(err);
1411 
1412  result.first = std::max(0., std::min(1., val));
1413  result.second = err;
1414  }
1415 
1416  // "Select" the status code for the actual calibration (it is subject to more constraints)
1417  return sfStatus;
1418 }

◆ getInefficiencyScaleFactor() [1/3]

Analysis::CalibResult Analysis::CalibrationDataInterfaceROOT::getInefficiencyScaleFactor ( const CalibrationDataVariables variables,
const std::string &  label,
const std::string &  OP,
Uncertainty  unc,
unsigned int  numVariation = 0,
unsigned int  mapIndex = 0 
)

"MC" inefficiency scale factor retrieval by name

Definition at line 1186 of file CalibrationDataInterfaceROOT.cxx.

1190 {
1191  // Inefficiency scale factor retrieval identifying the requested calibration objects by name.
1192  // The data efficiency is computed as the product of MC efficiency and data/MC efficiency scale factor;
1193  // the inefficiency scale factor is then computed as the ratio of data to MC inefficiencies.
1194  // The return value is either a (value, uncertainty) or an (up, down) variation pair, as documented
1195  // above, and will be a dummy value in case an error occurs.
1196  //
1197  // variables: object holding kinematic (and other) information needed to compute the result
1198  // label: jet flavour label
1199  // OP: tagger operating point
1200  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
1201  // named variations are to be computed)
1202  // numVariation: variation index (in case of eigenvector or named variations)
1203  // mapIndex: index to the efficiency map to be used
1204 
1205  unsigned int indexSF, indexEff;
1206  if (! (retrieveCalibrationIndex (label, OP, variables.jetAuthor, false, indexEff, mapIndex) &&
1207  retrieveCalibrationIndex (label, OP, variables.jetAuthor, true, indexSF))) {
1208  cerr << "getInefficiencyScaleFactor: unable to find Eff calibration for object "
1209  << fullName(variables.jetAuthor, OP, label, false, mapIndex)
1210  << " or SF calibration for object "
1211  << fullName(variables.jetAuthor, OP, label, true) << endl;
1212  // Return a dummy result if the object is not found
1213  return Analysis::dummyResult;
1214  }
1215 
1217  return (getInefficiencyScaleFactor(variables, indexSF, indexEff, unc, numVariation, result, label) == Analysis::kError) ?
1219 }

◆ getInefficiencyScaleFactor() [2/3]

Analysis::CalibResult Analysis::CalibrationDataInterfaceROOT::getInefficiencyScaleFactor ( const CalibrationDataVariables variables,
unsigned int  indexSF,
unsigned int  indexEff,
Uncertainty  unc,
const std::string &  flavour,
unsigned int  numVariation = 0 
)

"MC" inefficiency scale factor retrieval by index

Definition at line 1223 of file CalibrationDataInterfaceROOT.cxx.

1226 {
1227  // Inefficiency scale factor retrieval identifying the requested calibration objects by index.
1228  // The data efficiency is computed as the product of MC efficiency and data/MC efficiency scale factor;
1229  // the inefficiency scale factor is then computed as the ratio of data to MC inefficiencies.
1230  // The return value is either a (value, uncertainty) or an (up, down) variation pair, as documented
1231  // above, and will be a dummy value in case an error occurs.
1232  //
1233  // variables: object holding kinematic (and other) information needed to compute the result
1234  // indexSF: index to scale factor calibration object
1235  // indexEff: index to MC efficiency object
1236  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
1237  // named variations are to be computed)
1238  // numVariation: variation index (in case of eigenvector or named variations)
1239 
1241  return (getInefficiencyScaleFactor(variables, indexSF, indexEff, unc, numVariation, result, flavour) == Analysis::kError) ?
1243 }

◆ getInefficiencyScaleFactor() [3/3]

Analysis::CalibrationStatus Analysis::CalibrationDataInterfaceROOT::getInefficiencyScaleFactor ( const CalibrationDataVariables variables,
unsigned int  indexSF,
unsigned int  indexEff,
Uncertainty  unc,
unsigned int  numVariation,
Analysis::CalibResult result,
const std::string &  flavour 
)

"MC" inefficiency scale factor retrieval by index

Definition at line 1247 of file CalibrationDataInterfaceROOT.cxx.

1251 {
1252  // Inefficiency scale factor retrieval identifying the requested calibration objects by index.
1253  // The data efficiency is computed as the product of MC efficiency and data/MC efficiency scale factor;
1254  // the inefficiency scale factor is then computed as the ratio of data to MC inefficiencies.
1255  //
1256  // variables: object holding kinematic (and other) information needed to compute the result
1257  // indexSF: index to scale factor calibration object
1258  // indexEff: index to MC efficiency object
1259  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
1260  // named variations are to be computed)
1261  // numVariation: variation index (in case of eigenvector or named variations)
1262  // result: (value, uncertainty) or (up, down) variation pair, depending on the unc value.
1263  // A dummy value will be returned in case of an error.
1264 
1265  Analysis::CalibResult sfResult;
1266  Analysis::CalibrationStatus sfStatus = getScaleFactor(variables, indexSF, indexEff, unc, numVariation, sfResult, flavour);
1267  if (sfStatus == Analysis::kError) return sfStatus;
1268  Analysis::CalibResult effResult;
1269  Analysis::CalibrationStatus effStatus= getMCEfficiency(variables, indexEff, unc, effResult);
1270  if (effStatus == Analysis::kError) return effStatus;
1271 
1272  double eff = std::min(effResult.first, 1.);
1273  // double efferr = effResult.second; // not needed as (per the code change indicated below) we are not doing anything with MC statistical uncertainties
1274  double sf = sfResult.first;
1275  double sferr = sfResult.second;
1276 
1277  double val = 0.; // Analysis::dummyValue;
1278  double err = 0.; // Analysis::dummyValue;
1279  if (1. - eff > CalibZERO) {
1280  // Protect against negative scale factors
1281  val = std::max((1. - eff*sf), CalibZERO) / (1. - eff);
1282  // Treat the scale factor variation cases separately since the contents of the CalibResult are different
1283  // ('sf' and 'sferr' above contain the upward and downward variations, respectively).
1284  if (unc == SFEigen || unc == SFNamed) {
1285  double valDown = std::max((1. - eff*sferr), CalibZERO) / (1. - eff);
1286  result.first = val;
1287  result.second = valDown;
1288  return sfStatus;
1289  }
1290  // When using eigenvector (or named) variations (as above), only scale factor variations are considered.
1291  // For the sake of consistency, it has been decided (see https://its.cern.ch/jira/browse/AFT-350) to remove them also when EV variations aren't used
1292  //err = pow((1. - sf) / (1. - eff) * efferr, 2) + pow(eff*sferr, 2);
1293  err = pow(eff*sferr, 2);
1294  if (err > 0.)
1295  err = 1./(1. - eff) * TMath::Sqrt(err);
1296  // cout << "btag Calib Ineff err=" << err << endl;
1297  }
1298 
1299  result.first = std::max(CalibZERO, val);
1300  result.second = err;
1301  // "Select" the status code for the actual calibration (it is subject to more constraints)
1302  return sfStatus;
1303 }

◆ getMCEfficiency() [1/3]

Analysis::CalibResult Analysis::CalibrationDataInterfaceROOT::getMCEfficiency ( const CalibrationDataVariables variables,
const std::string &  label,
const std::string &  OP,
Uncertainty  unc = None,
unsigned int  mapIndex = 0 
)

"MC" efficiency retrieval by name

Definition at line 963 of file CalibrationDataInterfaceROOT.cxx.

966 {
967  // MC efficiency retrieval identifying the requested calibration object by name.
968  // The return value is a (value, uncertainty) pair, as documented above, and will
969  // be a dummy value in case an error occurs.
970  //
971  // variables: object holding kinematic (and other) information needed to compute the result
972  // label: jet flavour label
973  // OP: tagger operating point
974  // unc: keyword indicating what uncertainties to evaluate
975  // mapIndex: index to the efficiency map to be used
976 
977  unsigned int index;
978  if (! retrieveCalibrationIndex (label, OP, variables.jetAuthor, false, index, mapIndex)) {
979  cerr << "getMCEfficiency: unable to find Eff calibration for object " << fullName(variables.jetAuthor, OP, label, false, mapIndex) << endl;
980  // Return a dummy result if the object is not found
981  return Analysis::dummyResult;
982  }
983 
987 }

◆ getMCEfficiency() [2/3]

Analysis::CalibrationStatus Analysis::CalibrationDataInterfaceROOT::getMCEfficiency ( const CalibrationDataVariables variables,
unsigned int  index,
Uncertainty  unc,
Analysis::CalibResult result 
)

"MC" efficiency retrieval by index

Definition at line 1009 of file CalibrationDataInterfaceROOT.cxx.

1012 {
1013  // MC efficiency retrieval identifying the requested calibration object by index.
1014  //
1015  // variables: object holding kinematic (and other) information needed to compute the result
1016  // index: index to calibration object
1017  // unc: keyword indicating what uncertainties to evaluate
1018  // result: (value, uncertainty) variation pair.
1019  // A dummy value will be returned in case of an error.
1020 
1022  if (! container) return Analysis::kError;
1023 
1024  // perform out-of-bound check of jet eta
1025  if (!checkAbsEta(variables, index)) {
1026  if (m_verbose)
1027  cerr << "Jet |eta| is outside of the boundary!" << endl;
1028  return Analysis::kRange;
1029  }
1030 
1031 
1032  // always retrieve the result itself
1033  double value;
1035  if (status == Analysis::kError) return status;
1036  if (m_otherStrategy == GiveUp)
1037  assert (status != Analysis::kRange); // no need to test also statDown
1038  else if (m_otherStrategy == Flag)
1039  if (status == Analysis::kRange)
1040  this->increaseCounter(index);
1041 
1042  // retrieve the statistical uncertainty if desired
1043  double stat(0);
1044  if (unc == Total || unc == Statistical) {
1045  if (container->getStatUncertainty(variables, stat) == Analysis::kError) {
1046  cerr << "getMCEfficiency: error retrieving MC efficiency parameter covariance matrix!" << endl;
1047  return Analysis::kError;
1048  }
1049  }
1050 
1051  // Temporary(?) hack: comment this out since the present MC results don't have "systematics" contributions
1052  // Analysis::UncertaintyResult resSyst(0,0);
1053  // if (unc == Total || unc == Systematic) {
1054  // if (container->getSystUncertainty(variables, resSyst) == Analysis::kError)
1055  // cerr << "getScaleFactor: error retrieving Scale factor parameter covariance matrix!"
1056  // << endl;
1057  // }
1058 
1059  // since there is no combination of stat/syst uncertainties to be made, comment this out too
1060  double uncertainty = stat; // combinedUncertainty(stat, resSyst);
1061  result.first = std::max(0., std::min(1., value));
1062  result.second = uncertainty;
1063 
1064  return status;
1065 }

◆ getMCEfficiency() [3/3]

Analysis::CalibResult Analysis::CalibrationDataInterfaceROOT::getMCEfficiency ( const CalibrationDataVariables variables,
unsigned int  index,
Uncertainty  unc = None 
)

"MC" efficiency retrieval by index

Definition at line 991 of file CalibrationDataInterfaceROOT.cxx.

993 {
994  // MC efficiency retrieval identifying the requested calibration object by index.
995  // The return value is a (value, uncertainty) pair, as documented above, and will
996  // be a dummy value in case an error occurs.
997  //
998  // variables: object holding kinematic (and other) information needed to compute the result
999  // index: index to calibration object
1000  // unc: keyword indicating what uncertainties to evaluate
1001 
1003  return (getMCEfficiency(variables, index, unc, result) == Analysis::kError) ?
1005 }

◆ getMCEfficiencyObject()

const TObject * Analysis::CalibrationDataInterfaceROOT::getMCEfficiencyObject ( const std::string &  author,
const std::string &  label,
const std::string &  OP,
unsigned int  mapIndex = 0 
)

retrieve the MC efficiency (central values) object for the given flavour label and operating point.

A null result will be returned in case of error (e.g. if the calibration object isn't binned to begin with). It is the user's responsibility to verify whether the object derives from a TH1 or a TF1.

Definition at line 2130 of file CalibrationDataInterfaceROOT.cxx.

2134 {
2135  // Retrieve the actual central values object for the MC efficiences, identifying the object by name.
2136  // The object returned can be either a TH1 or a TF1; it is up to the user to determine which.
2137  //
2138  // author: jet collection name
2139  // label: jet flavour label
2140  // OP: tagger working point
2141  // mapIndex: index to the efficiency map to be used
2142 
2143  unsigned int index;
2144  if (! retrieveCalibrationIndex (label, OP, author, false, index, mapIndex)) {
2145  // Return a dummy result if the object is not found
2146  cerr << "getMCEfficiencyObject: unable to find efficiency calibration for object "
2147  << fullName(author, OP, label, false, mapIndex) << endl;
2148  return 0;
2149  }
2151  return (container) ? container->GetValue("result") : 0;
2152 }

◆ getMCInefficiency() [1/2]

Analysis::CalibResult Analysis::CalibrationDataInterfaceROOT::getMCInefficiency ( const CalibrationDataVariables variables,
const std::string &  label,
const std::string &  OP,
Uncertainty  unc = None,
unsigned int  mapIndex = 0 
)

"MC" inefficiency retrieval by name

Definition at line 1422 of file CalibrationDataInterfaceROOT.cxx.

1425 {
1426  // Data inefficiency retrieval identifying the requested calibration objects by name.
1427  // The inefficiency is computed as the 1 minus the efficiency.
1428  // The return value is a (value, uncertainty), as documented above, and will be a dummy value
1429  // in case an error occurs.
1430  //
1431  // variables: object holding kinematic (and other) information needed to compute the result
1432  // label: jet flavour label
1433  // OP: tagger operating point
1434  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
1435  // named variations are to be computed)
1436  // numVariation: variation index (in case of eigenvector or named variations)
1437  // mapIndex: index to the efficiency map to be used
1438 
1439  Analysis::CalibResult effResult = getMCEfficiency(variables, label, OP, unc, mapIndex);
1440  return std::make_pair(std::max(0., 1. - effResult.first), effResult.second);
1441 }

◆ getMCInefficiency() [2/2]

Analysis::CalibResult Analysis::CalibrationDataInterfaceROOT::getMCInefficiency ( const CalibrationDataVariables variables,
unsigned int  index,
Uncertainty  unc = None 
)

"MC" inefficiency retrieval by index

Definition at line 1445 of file CalibrationDataInterfaceROOT.cxx.

1447 {
1448  // MC inefficiency retrieval identifying the requested calibration object by index.
1449  // The inefficiency is computed as the 1 minus the efficiency.
1450  // The return value is a (value, uncertainty), as documented above, and will be a dummy value
1451  // in case an error occurs.
1452  //
1453  // variables: object holding kinematic (and other) information needed to compute the result
1454  // index: index to MC efficiency object
1455  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
1456  // named variations are to be computed)
1457  // numVariation: variation index (in case of eigenvector or named variations)
1458 
1460  return std::make_pair(std::max(0., 1. - effResult.first), effResult.second);
1461 }

◆ getMCMCScaleFactor()

double Analysis::CalibrationDataInterfaceROOT::getMCMCScaleFactor ( const CalibrationDataVariables variables,
unsigned  indexSF,
unsigned int  indexEff 
) const

MC/MC scale factor retrieval.

Normally this is to be used only internally; however, since this information may be of interest it is made public anyway.

Definition at line 1465 of file CalibrationDataInterfaceROOT.cxx.

1467 {
1468  // Retrieve the MC/MC scale factor given the set of scale factor and efficiency indices.
1469  // variables: object holding kinematic (and other) information needed to compute the result
1470  // indexSF: index to scale factor calibration object
1471  // indexEff: index to MC efficiency object
1472 
1473  // If either reference doesn't exist, or if they are the same, nothing can / needs to be done.
1474  int indexSFRef = m_hadronisationReference[indexSF], indexEffRef = m_hadronisationReference[indexEff];
1475  if (indexSFRef < 0 || indexEffRef < 0 || indexSFRef == indexEffRef) return 1;
1476 
1477  // Verify also that the individual efficiencies are physically meaningful.
1478  double effSFRef; m_objects[indexSFRef]->getResult(variables, effSFRef);
1479  double effEffRef; m_objects[indexEffRef]->getResult(variables, effEffRef);
1480  return (effSFRef > 0 && effEffRef > 0) ? effSFRef/effEffRef : 1;
1481 }

◆ getNumVariations() [1/2]

unsigned int Analysis::CalibrationDataInterfaceROOT::getNumVariations ( const std::string &  author,
const std::string &  label,
const std::string &  OP,
Uncertainty  unc 
)

retrieve the number of variations relevant to the calibration object.

The Uncertainty enum is used to specify the category.

Definition at line 2063 of file CalibrationDataInterfaceROOT.cxx.

2067 {
2068  // Retrieve the number of eigenvector variations or named variations relevant for
2069  // the given scale factor calibration object, identifying the object by name.
2070  //
2071  // author: jet collection name
2072  // label: jet flavour label
2073  // OP: tagger working point
2074  // unc: should be set to SFEigen or SFNamed for the cases of
2075  // eigenvector variations or named variations, respectively
2076 
2077  unsigned int index;
2078 
2079  if (! retrieveCalibrationIndex (label, OP, author, true, index)) return 0;
2080  return getNumVariations(index, unc, label);
2081 }

◆ getNumVariations() [2/2]

unsigned int Analysis::CalibrationDataInterfaceROOT::getNumVariations ( unsigned int  index,
Uncertainty  unc,
const std::string &  flavour 
)

retrieve the number of variations relevant to the calibration object.

The Uncertainty enum is used to specify the category.

Definition at line 2085 of file CalibrationDataInterfaceROOT.cxx.

2087 {
2088  // Retrieve the number of eigenvector variations or named variations relevant for
2089  // the given scale factor calibration object, identifying the object by index.
2090  //
2091  // index: index to calibration scale factor object
2092  // unc: should be set to SFEigen or SFNamed for the cases of
2093  // eigenvector variations or named variations, respectively
2094 
2095  if (! (unc == SFEigen || unc == SFNamed || unc == SFGlobalEigen)) return 0;
2097  if (! container) return 0;
2098  std::shared_ptr<CalibrationDataEigenVariations> eigenVariation=m_eigenVariationsMap.at(container);
2099  if (unc == SFGlobalEigen){
2100  std::shared_ptr<CalibrationDataGlobalEigenVariations> GEV = std::dynamic_pointer_cast<CalibrationDataGlobalEigenVariations>(eigenVariation);
2101  return GEV->getNumberOfEigenVariations(flavour);
2102  }
2103  return (unc == SFEigen) ? eigenVariation->getNumberOfEigenVariations() : eigenVariation->getNumberOfNamedVariations();
2104 }

◆ getScaleFactor() [1/3]

Analysis::CalibResult Analysis::CalibrationDataInterfaceROOT::getScaleFactor ( const CalibrationDataVariables variables,
const std::string &  label,
const std::string &  OP,
Uncertainty  unc,
unsigned int  numVariation = 0,
unsigned int  mapIndex = 0 
)

efficiency scale factor retrieval by name.

#1

Definition at line 736 of file CalibrationDataInterfaceROOT.cxx.

740 {
741  // Scale factor retrieval identifying the requested calibration object by name.
742  // The return value is either a (value, uncertainty) or an (up, down) variation pair, as documented
743  // above, and will be a dummy value in case an error occurs.
744  //
745  // variables: object holding kinematic (and other) information needed to compute the result
746  // label: jet flavour label
747  // OP: tagger operating point
748  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
749  // named variations are to be computed)
750  // numVariation: variation index (in case of eigenvector or named variations)
751  // mapIndex: index to the efficiency map to be used (this is needed for MC/MC scale factor
752  // application)
753  unsigned int indexEff, indexSF;
754  if (! (retrieveCalibrationIndex (label, OP, variables.jetAuthor, false, indexEff, mapIndex) && retrieveCalibrationIndex (label, OP, variables.jetAuthor, true, indexSF))) {
755  cerr << "getScaleFactor: unable to find SF calibration for object " << fullName(variables.jetAuthor, OP, label, false, mapIndex) << " or SF calibration for object " << fullName(variables.jetAuthor, OP, label, true) << endl;
756  // Return a dummy result if the object is not found
757  return Analysis::dummyResult;
758  }
759 
760  Analysis::CalibResult result; // the following is SF #3
761  return (getScaleFactor(variables, indexSF, indexEff, unc, numVariation, result, label) == Analysis::kError) ?
763 }

◆ getScaleFactor() [2/3]

Analysis::CalibResult Analysis::CalibrationDataInterfaceROOT::getScaleFactor ( const CalibrationDataVariables variables,
unsigned int  indexSF,
unsigned int  indexEff,
Uncertainty  unc,
const std::string &  flavour,
unsigned int  numVariation = 0 
)

efficiency scale factor retrieval by index #2

Definition at line 767 of file CalibrationDataInterfaceROOT.cxx.

770 {
771  // Scale factor retrieval identifying the requested calibration object by index.
772  // The return value is either a (value, uncertainty) or an (up, down) variation pair, as documented
773  // above, and will be a dummy value in case an error occurs.
774  //
775  // variables: object holding kinematic (and other) information needed to compute the result
776  // indexSF: index to scale factor calibration object
777  // indexEff: index to MC efficiency object
778  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
779  // named variations are to be computed)
780  // numVariation: variation index (in case of eigenvector or named variations)
781  Analysis::CalibResult result; // the following is SF #3
782  return (getScaleFactor(variables, indexSF, indexEff, unc, numVariation, result, flavour) == Analysis::kError) ?
784 }

◆ getScaleFactor() [3/3]

Analysis::CalibrationStatus Analysis::CalibrationDataInterfaceROOT::getScaleFactor ( const CalibrationDataVariables variables,
unsigned int  indexSF,
unsigned int  indexEff,
Uncertainty  unc,
unsigned int  numVariation,
Analysis::CalibResult result,
const std::string &  flavour 
)

efficiency scale factor retrieval by index #3

Definition at line 788 of file CalibrationDataInterfaceROOT.cxx.

792 {
793  // Scale factor retrieval identifying the requested calibration object by index.
794  //
795  // variables: object holding kinematic (and other) information needed to compute the result
796  // indexSF: index to scale factor calibration object
797  // indexEff: index to MC efficiency object
798  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
799  // named variations are to be computed)
800  // numVariation: variation index (in case of eigenvector or named variations)
801  // result: (value, uncertainty) or (up, down) variation pair, depending on the unc value.
802  // A dummy value will be returned in case of an error.
803 
804  CalibrationDataContainer* container = m_objects[indexSF];
805  if (! container) {
806  cerr << "getScaleFactor: error retrieving container!" << endl;
807  return Analysis::kError;
808  }
809 
810  // perform out-of-bound check of jet eta
811  if (!checkAbsEta(variables, indexSF)) {
812  if (m_verbose)
813  cerr << "Jet |eta| is outside of the boundary!" << endl;
814  return Analysis::kRange;
815  }
816 
817  // retrieve the MC/MC scale factor
818  double MCMCSF = m_useMCMCSF ? getMCMCScaleFactor(variables, indexSF, indexEff) : 1; // if we don't want to switch generator, MCMCSF = 1, as it should be
819 
820  if (!m_runEigenVectorMethod && (unc == SFEigen || unc == SFNamed || unc == SFGlobalEigen))
821  {
822  cerr << " ERROR. Trying to call eigenvector method but initialization not switched on in b-tagging configuration." << endl;
823  cerr << " Please correct your configuration first. Nominal uncertainties used. " << endl;
824  }
825 
826  // Procede with eigenvariations methods i.e. return the SF variations
827  if (unc == SFEigen || unc == SFNamed || unc==SFGlobalEigen) {
828  std::shared_ptr<CalibrationDataEigenVariations> eigenVariation;
829  try {
830  eigenVariation=m_eigenVariationsMap.at(container);
831  } catch (const std::out_of_range&) {
832  cerr << " Could not retrieve eigenvector variation, while it should have been there." << endl;
833  return Analysis::kError;
834  }
835  TH1* up=0;
836  TH1* down=0;
837  bool extrapolate = false; // store if the numVariation is the extrapolation named uncertainty index
838  if (unc == SFEigen || unc==SFNamed){
839  unsigned int maxVariations = (unc == SFEigen) ? eigenVariation->getNumberOfEigenVariations() : eigenVariation->getNumberOfNamedVariations();
840  if (numVariation > maxVariations-1) {
841  cerr << "Asked for " << ((unc == SFEigen) ? "eigenvariation" : "named variation") << " number: " << numVariation << " but overall number of available variations is: " << maxVariations << endl;
842  return Analysis::kError;
843  }
844  bool isOK = eigenVariation->getEigenvectorVariation(numVariation,up,down);
845  if (!isOK) {
846  cerr << "Eigenvector object is there but cannot retrieve up and down uncertainty histograms." << endl;
847  return Analysis::kError;
848  }
849  // the 'extrapolation' uncertainty (always a named one) needs a somewhat special treatment
850  extrapolate = (unc == SFNamed) ? eigenVariation->isExtrapolationVariation(numVariation) : false;
851 
852  } else if (unc == SFGlobalEigen) {
853  std::shared_ptr<CalibrationDataGlobalEigenVariations> GEV = std::dynamic_pointer_cast<CalibrationDataGlobalEigenVariations>(eigenVariation); //dynamic_cast<std::shared_ptr<CalibrationDataGlobalEigenVariations> >(eigenVariation);
854  if (not GEV){
855  cerr << "Analysis::CalibrationDataInterfaceROOT::getScaleFactor: dynamic cast failed\n";
856  return Analysis::kError;
857  }
858  unsigned int maxVariations = GEV->getNumberOfEigenVariations(flavour); // <----- This gets the number of variations of the flavour
859  if (numVariation > maxVariations-1) {
860  cerr << "Asked for global eigenvariation number: " << numVariation << " but overall number of available variations is: " << maxVariations << endl;
861  return Analysis::kError;
862  }
863  bool isOK = GEV->getEigenvectorVariation(flavour, numVariation,up,down);
864  if (!isOK) {
865  cerr << "Eigenvector object is there but cannot retrieve up and down uncertainty histograms." << endl;
866  return Analysis::kError;
867  }
868  // the 'extrapolation' uncertainty (always a named one) needs a somewhat special treatment
869  extrapolate = GEV->isExtrapolationVariation(numVariation, flavour);
870  } else {
871  std::cerr << "ERROR: you requested " << unc << " but that isn't in the set of (SFEigen, SFGlobalEigen, SFNamed) for eigenvariations. " << std::endl;
872  return Analysis::kError;
873  }
874 
875  double valueUp;
876  double valueDown;
877  Analysis::CalibrationStatus statUp = container->getResult(variables, valueUp, up, extrapolate); // This is what actually retrieves results from the container
878  Analysis::CalibrationStatus statDown = container->getResult(variables, valueDown,down, extrapolate);
879 
880  if (statUp == Analysis::kError || statDown == Analysis::kError)
881  return Analysis::kError;
882  if (m_otherStrategy == GiveUp)
883  assert (statUp != Analysis::kRange); // no need to test also statDown
885  assert (statUp != Analysis::kExtrapolatedRange); // no need to test also statDown
886  else if (m_otherStrategy == Flag) {
887  if (statUp == Analysis::kRange)
888  increaseCounter(indexSF);
889  else if (statUp == Analysis::kExtrapolatedRange)
890  increaseCounter(indexSF, Extrapolated);
891  }
892 
893  result.first = MCMCSF*valueUp;
894  result.second = MCMCSF*valueDown;
895 
896  // Prevent negative return values. Should the comparison be against a strict 0?
897  result.first = std::max(Analysis::CalibZERO, result.first);
898  result.second = std::max(Analysis::CalibZERO, result.second);
899 
900  return statUp; // end of getScaleFactor if SFEigen, SFGlobalEigen, or SFNamed is set
901 
902 
903  } // The above returns the up/down varied scale factor
904  //Proceed with no-eigenvector result
905 
906  // always retrieve the result itself
907  double value;
909  if (status == Analysis::kError) {
910  cerr << "getScaleFactor: error retrieving result in non-EV context!" << endl;
911  return status;
912  }
913  if (m_otherStrategy == GiveUp){
914  assert (status != Analysis::kRange);
915  } else if (m_otherStrategy == GiveUpExtrapolated) {
917  } else if (m_otherStrategy == Flag) {
918  if (status == Analysis::kRange){
919  increaseCounter(indexSF);
920  } else if (status == Analysis::kExtrapolatedRange) {
921  increaseCounter(indexSF, Extrapolated);
922  }
923  }
924 
925  // retrieve the statistical uncertainty if desired
926  double stat(0);
927  if (unc == Total || unc == Statistical) {
928  if (container->getStatUncertainty(variables, stat) == Analysis::kError) {
929  cerr << "getScaleFactor: error retrieving Scale factor parameter covariance matrix!" << endl;
930  return Analysis::kError;
931  }
932  }
933 
934  Analysis::UncertaintyResult resSyst(0,0);
935  if (unc == Total || unc == Systematic) {
936  if (container->getSystUncertainty(variables, resSyst) == Analysis::kError) {
937  cerr << "getScaleFactor: error retrieving Scale factor parameter systematic uncertainty!" << endl;
938  return Analysis::kError;
939  }
940  } else if (unc == Extrapolation) {
941  // this uncertainty is special, since it is not normally to be combined into the overall systematic uncertainty
942  if (container->getUncertainty("extrapolation", variables, resSyst) == Analysis::kError)
943  cerr << "getScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
944  } else if (unc == TauExtrapolation) {
945  // also this uncertainty is special, since it it singles out an uncertainty relevant only for tau "jets",
946  // and some care has to be taken not to duplicate or omit uncertainties
947  if (container->getUncertainty("extrapolation from charm", variables, resSyst) == Analysis::kError)
948  cerr << "getScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
949  }
950 
951  double uncertainty = combinedUncertainty(stat, resSyst);
952  result.first = MCMCSF*value;
953  result.second = MCMCSF*uncertainty;
954 
955  // Prevent negative return values. Should the comparison be against a strict 0?
956  result.first = std::max(Analysis::CalibZERO, result.first);
957  return status;
958 
959 }

◆ getScaleFactorCovarianceMatrix()

TMatrixDSym Analysis::CalibrationDataInterfaceROOT::getScaleFactorCovarianceMatrix ( const std::string &  author,
const std::string &  label,
const std::string &  OP,
const std::string &  unc = "all" 
)

retrieve the named covariance matrix element corresponding to the binned calibration object.

The unc argument should correspond to a given source of statistical or systematic uncertainty, or "all" (in case the full covariance matrix is required) For 2D and 3D histograms, the bin numbering follows the "global" bin number as defined by class TH1.

Definition at line 2415 of file CalibrationDataInterfaceROOT.cxx.

2419 {
2420  // Return the scale factor covariance matrix for the given calibration object.
2421  // This function is deprecated since its functionality is duplicated in the
2422  // CalibrationDataEigenVariations class.
2423  //
2424  // author: jet collection name
2425  // label: jet flavour label
2426  // OP: tagger working point
2427  // unc: source of uncertainty to consider
2428  // Catch issues with the specified input as early as possible
2429  TMatrixDSym dummy;
2430  if (unc == "comment" || unc == "result" || unc == "combined") return dummy;
2431 
2432  unsigned int index;
2433  if (! retrieveCalibrationIndex (label, OP, author, true, index)) {
2434  // Return a dummy result if the object is not found
2435  cerr << "getScaleFactorCovarianceMatrix: unable to find SF calibration for object " << fullName(author, OP, label, true) << endl;
2436  return dummy;
2437  }
2438  CalibrationDataHistogramContainer* container = dynamic_cast<CalibrationDataHistogramContainer*>(m_objects[index]);
2439  if (!container) return dummy;
2440 
2441  // retrieve the central calibration and its axes
2442  TH1* result = dynamic_cast<TH1*>(container->GetValue("result"));
2443  if (! result) return dummy;
2444  // "normal" case: single source of uncertainty
2445  if (unc != "all") {
2446  if (unc == "statistics") {
2447  return getStatCovarianceMatrix(result);
2448  } else {
2449  TH1* hunc = dynamic_cast<TH1*>(container->GetValue(unc.c_str()));
2450  if (! hunc) {
2451  cout << "getScaleFactorCovarianceMatrix: no uncertainty object found "
2452  << "corresponding to name " << unc << endl;
2453  return dummy;
2454  }
2455  return getSystCovarianceMatrix(result, hunc, container->isBinCorrelated(unc), unc, container->getTagWeightAxis());
2456  }
2457  }
2458 
2459  // special case: complete covariance matrix. This is to be constructed
2460  // as the sum over all individual contributions.
2461  // First, treat the statistics separately (as above)
2462  TMatrixDSym cov = getStatCovarianceMatrix(result);
2463 
2464  // Then loop through the list of (other) uncertainties
2465  std::vector<string> uncs = container->listUncertainties();
2466  for (unsigned int t = 0; t < uncs.size(); ++t) {
2467  if (uncs[t] == "comment" || uncs[t] == "result" || uncs[t] == "combined" ||
2468  uncs[t] == "statistics" || uncs[t]=="extrapolation" || uncs[t]=="MChadronisation" ||
2469  uncs[t]=="ReducedSets" || uncs[t]=="systematics") continue;
2470  TH1* hunc = dynamic_cast<TH1*>(container->GetValue(uncs[t].c_str()));
2471  if (not hunc) {
2472  std::cerr<<"Analysis::CalibrationDataInterfaceROOT::getScaleFactorCovarianceMatrix : dynamic cast failed\n";
2473  continue;
2474  }
2475  TMatrixDSym syst_cov = getSystCovarianceMatrix(result, hunc, container->isBinCorrelated(uncs[t]), uncs[t], container->getTagWeightAxis());
2476  cov += syst_cov;
2477  }
2478 
2479  return cov;
2480 }

◆ getShiftedScaleFactors()

const TH1 * Analysis::CalibrationDataInterfaceROOT::getShiftedScaleFactors ( const std::string &  author,
const std::string &  label,
const std::string &  OP,
const std::string &  unc,
double  sigmas 
)

retrieve the binned calibration object for the given flavour label and operating point, with the result shifted by the given number of standard deviations for the given systematic uncertainty.

A null result will be returned in case of error (e.g. if the calibration object isn't binned to begin with, or if the uncertainty asked for isn't fully correlated from bin to bin).

Definition at line 2158 of file CalibrationDataInterfaceROOT.cxx.

2163 {
2164  // Retrieve the actual histogrammed calibration scale factors, identifying the object by name
2165  // and with the scale factors shifted by the uncertainties due to the given source of uncertainty
2166  // (where bin-to-bin correlations are accounted for, i.e., shifts may be either positive or negative).
2167  //
2168  // author: jet collection name
2169  // label: jet flavour label
2170  // OP: tagger working point
2171  // unc: source of uncertainty to consider
2172  // sigmas: number of standard deviations by which to shift the scale factor central values
2173 
2174  // quick sanity check
2175  if (unc == "comment" || unc == "result" || unc == "combined" || unc == "statistics") return 0;
2176 
2177  unsigned int index;
2178  if (! retrieveCalibrationIndex (label, OP, author, true, index)) {
2179  // Return a null result if the object is not found
2180  cerr << "getShiftedScaleFactors: unable to find SF calibration for object " << fullName(author, OP, label, true) << endl;
2181  return nullptr;
2182  }
2183  CalibrationDataHistogramContainer* container = dynamic_cast<CalibrationDataHistogramContainer*>(m_objects[index]);
2184  if (! container) return nullptr;
2185 
2186  TH1* result = dynamic_cast<TH1*>(container->GetValue("result"));
2187  TH1* hunc = dynamic_cast<TH1*>(container->GetValue(unc.c_str()));
2188  // another sanity check...
2189  if ((! hunc) || (! result)) return nullptr;
2190  if (hunc->GetDimension() != result->GetDimension() || hunc->GetNbinsX() != result->GetNbinsX() ||
2191  hunc->GetNbinsX() != result->GetNbinsX() || hunc->GetNbinsX() != result->GetNbinsX())
2192  return nullptr;
2193  // also check that the uncertainty is to be treated as correlated from bin to bin
2194  // (for the variation is applied coherently, which isn't appropriate for uncertainties
2195  // that aren't correlated from bin to bin)
2196  if (! container->isBinCorrelated(unc)) return 0;
2197 
2198  // if everything is consistent, the actual operation simply consists of adding histograms...
2199  std::string name(container->GetName()); name += "_"; name += unc; name += "_";
2200  TH1* shifted = dynamic_cast<TH1*>(result->Clone(name.c_str()));
2201  if (not shifted) return nullptr;
2202  shifted->Add(hunc, sigmas);
2203  return shifted;
2204 }

◆ getWeightScaleFactor() [1/3]

Analysis::CalibResult Analysis::CalibrationDataInterfaceROOT::getWeightScaleFactor ( const CalibrationDataVariables variables,
const std::string &  label,
Uncertainty  unc,
unsigned int  numVariation = 0,
unsigned int  mapIndex = 0 
)

efficiency scale factor retrieval by name

Definition at line 1485 of file CalibrationDataInterfaceROOT.cxx.

1488 {
1489  // #1
1490  // Tag weight fraction scale factor retrieval identifying the requested calibration object by name.
1491  // The return value is either a (value, uncertainty) or (if eigenvector or named variations are specified)
1492  // an (up, down) variation pair, and will be a dummy value in case an error occurs.
1493  // Note that in contrast to the "regular" (non-continuous) case, the computation of the scale factor in
1494  // general needs the (selection- or even process-specific) MC tag weight fractions, in order to rescale
1495  // scale factors. This is used to ensure that the tag weight fractions (both in data and in MC) sum up to
1496  // unity for each given kinematic bin.
1497  //
1498  // variables: object holding kinematic (and other) information needed to compute the result
1499  // label: jet flavour label
1500  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
1501  // named variations are to be computed)
1502  // numVariation: variation index (in case of eigenvector or named variations)
1503  // mapIndex: index to the MC efficiency map to be used for scale factor rescaling
1504 
1505  static const string cont("Continuous");
1506 
1507  unsigned int indexSF, indexEff;
1508  if (! (retrieveCalibrationIndex (label, cont, variables.jetAuthor, false, indexEff, mapIndex) &&
1509  retrieveCalibrationIndex (label, cont, variables.jetAuthor, true, indexSF))) {
1510  cerr << "getWeightScaleFactor: unable to find Eff calibration for object "
1511  << fullName(variables.jetAuthor, cont, label, false, mapIndex)
1512  << " or SF calibration for object "
1513  << fullName(variables.jetAuthor, cont, label, true) << endl;
1514  return Analysis::dummyResult;
1515  }
1516 
1518  return (getWeightScaleFactor(variables, indexSF, indexEff, unc, numVariation, result) == Analysis::kError) ? Analysis::dummyResult : result;
1519 }

◆ getWeightScaleFactor() [2/3]

Analysis::CalibrationStatus Analysis::CalibrationDataInterfaceROOT::getWeightScaleFactor ( const CalibrationDataVariables variables,
unsigned int  indexSF,
unsigned int  indexEff,
Uncertainty  unc,
unsigned int  numVariation,
Analysis::CalibResult result 
)

efficiency scale factor retrieval by index, with different signature

Definition at line 1550 of file CalibrationDataInterfaceROOT.cxx.

1554 {
1555  // #3
1556  // Tag weight fraction scale factor retrieval identifying the requested calibration object by index.
1557  // Note that in contrast to the "regular" (non-continuous) case, the computation of the scale factor in
1558  // general needs the (selection- or even process-specific) MC tag weight fractions, in order to rescale
1559  // scale factors. This is used to ensure that the tag weight fractions (both in data and in MC) sum up to
1560  // unity for each given kinematic bin.
1561  //
1562  // variables: object holding kinematic (and other) information needed to compute the result
1563  // indexSF: index to calibration object
1564  // indexEff: index to MC tag weight
1565  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
1566  // named variations are to be computed)
1567  // numVariation: variation index (in case of eigenvector or named variations)
1568  // result: (value, uncertainty) or (up, down) variation pair, depending on the unc value.
1569  // A dummy value will be returned in case of an error.
1570  CalibrationDataContainer* container = m_objects[indexSF];
1571  if (! container) return Analysis::kError;
1572  CalibrationDataContainer* effContainer = m_objects[indexEff];
1573  if (! effContainer) return Analysis::kError;
1574 
1575  // the first time this combination of scale factor and "efficiency" objects is given, check on the
1576  // scale factors that will result from their combination (where the computations reproduce those
1577  // shown below)
1578  checkWeightScaleFactors(indexSF, indexEff);
1579 
1580  // perform out-of-bound check of jet eta
1581  if (!checkAbsEta(variables, indexSF)) {
1582  if (m_verbose)
1583  cerr << "Jet |eta| is outside of the boundary!" << endl;
1584  return Analysis::kRange;
1585  }
1586 
1587  // Always retrieve the result itself
1588  double value;
1590  if (status == Analysis::kError) return status;
1591  if (m_otherStrategy == GiveUp) assert (status != Analysis::kRange);
1593  else if (m_otherStrategy == Flag) {
1594  if (status == Analysis::kRange)
1595  increaseCounter(indexSF);
1597  increaseCounter(indexSF, Extrapolated);
1598  }
1599 
1600  // Retrieve the reference MC tag weight fraction (corresponding to the calibration scale factors)
1601  Analysis::UncertaintyResult refMCResult(0,0);
1602  if (container->getUncertainty("MCreference", variables, refMCResult) == Analysis::kError)
1603  return Analysis::kError;
1604  double fracMCref = refMCResult.first;
1605  // Retrieve the MC reference information, if requested (the initialisation below is to make sure
1606  // that no exceptions in the code will be needed)
1607  double fracSFref = fracMCref, fracEffref = fracMCref;
1608  if (m_useMCMCSF) {
1609  int indexSFref = m_hadronisationReference[indexSF], indexEffref = m_hadronisationReference[indexEff];
1610  if (indexSFref < 0 || indexEffref < 0) {
1611  cerr << "getWeightScaleFactor: error: generator-specific corrections requested but necessary reference containers lacking " << endl;
1612  return Analysis::kError;
1613  } else {
1614  m_objects[indexSFref]->getResult(variables, fracSFref);
1615  m_objects[indexEffref]->getResult(variables, fracEffref);
1616  if (! (fracSFref > 0. && fracEffref > 0.)) {
1617  cerr << "getWeightScaleFactor: error: invalid reference tag weight fraction " <<fracSFref <<" " <<fracEffref << std::endl;
1618  return Analysis::kError;
1619  }
1620  }
1621  }
1622 
1623  // Retrieve the MC tag weight fraction for the sample we need to reweight to
1624  double fracMCnew;
1625  Analysis::CalibrationStatus effStatus = effContainer->getResult(variables, fracMCnew);
1626  if (effStatus == Analysis::kError) return effStatus;
1627  if (m_otherStrategy == GiveUp) assert (effStatus != Analysis::kRange);
1628  else if (m_otherStrategy == Flag)
1629  if (effStatus == Analysis::kRange) increaseCounter(indexEff);
1630  // since we need to divide by this quantity, check that it is well-defined
1631  if (!(fracMCnew > 0.) and m_useTopologyRescaling) {// but we only care if using topology rescaling
1632  cerr << "getWeightScaleFactor: error: null fracMCnew would lead to invalid operation" << endl;
1633  return Analysis::kError;
1634  }
1635 
1636  if (!m_runEigenVectorMethod && (unc == SFEigen || unc == SFNamed)) {
1637  cerr << "getWeightScaleFactor: ERROR. Trying to call eigenvector method but initialization not switched on in b-tagging .env config file." << endl;
1638  cerr << " Please correct your .env config file first. Nominal uncertainties used. " << endl;
1639  }
1640 
1641  if (unc == SFEigen || unc == SFNamed) {
1642  std::shared_ptr<CalibrationDataEigenVariations> eigenVariation;
1643  try {
1644  eigenVariation = m_eigenVariationsMap.at(container);
1645  } catch (const std::out_of_range&) {
1646  cerr << "getWeightScaleFactor: could not retrieve eigenvector variation, while it should have been there." << endl;
1647  return Analysis::kError;
1648  }
1649  unsigned int maxVariations = (unc == SFEigen) ? eigenVariation->getNumberOfEigenVariations() : eigenVariation->getNumberOfNamedVariations();
1650  if (numVariation > maxVariations-1) {
1651  cerr << "getWeightScaleFactor: asked for " << ((unc == SFEigen) ? "eigenvariation" : "named variation") << " number: " << numVariation << " but overall number of available variations is: " << maxVariations << endl;
1652  return Analysis::kError;
1653  }
1654  TH1* up=0;
1655  TH1* down=0;
1656  bool isOK = (unc == SFEigen) ? eigenVariation->getEigenvectorVariation(numVariation,up,down) : eigenVariation->getNamedVariation(numVariation,up,down);
1657  if (!isOK) {
1658  cerr << "getWeightScaleFactor: Eigenvector object is there but cannot retrieve up and down uncertainty histograms." << endl;
1659  return Analysis::kError;
1660  }
1661  // the 'extrapolation' uncertainty (always a named one) needs a somewhat special treatment
1662  bool extrapolate = ( unc == SFNamed ) ? eigenVariation->isExtrapolationVariation(numVariation) : false;
1663 
1664  double valueUp;
1665  double valueDown;
1666  Analysis::CalibrationStatus statusUp = container->getResult(variables, valueUp, up, extrapolate);
1667  Analysis::CalibrationStatus statusDown = container->getResult(variables, valueDown,down, extrapolate);
1668  if (statusUp == Analysis::kError || statusDown == Analysis::kError) return Analysis::kError;
1669 
1670  // now carry out the rescaling. Protect against unphysical or suspiciously large scale factors
1671  double variationUp = valueUp - value;
1672  double variationDown = valueDown - value;
1673  // First step: from the calibration sample to its reference sample
1674  if (m_useTopologyRescaling) value = 1.0 + (value - 1.0) * (fracMCref / fracSFref);
1675  // Second step: from the calibration reference sample to the MC object's reference sample
1676  if (m_useMCMCSF) value *= (fracSFref / fracEffref);
1677  // Third step: from the MC object's reference sample to the MC sample itself
1678  if (m_useTopologyRescaling) value = 1.0 + (value - 1.0) * (fracEffref / fracMCnew);
1679  // Since all transformations of the scale factor itself are linear, the transformation of the variations is simpler.
1680  if (m_useTopologyRescaling) {
1681  double f = (fracMCref / fracMCnew);
1682  variationUp *= f;
1683  variationDown *= f;
1684  } else if (m_useMCMCSF) {
1685  double f = (fracSFref / fracEffref);
1686  variationUp *= f;
1687  variationDown *= f;
1688  }
1689  valueUp = value + variationUp;
1690  valueDown = value + variationDown;
1691  if (valueUp < 0) {
1692  valueUp = 0; increaseCounter(indexSF, TagWeight);
1693  } else if (valueUp > m_maxTagWeight) {
1694  valueUp = m_maxTagWeight; increaseCounter(indexSF, TagWeight);
1695  }
1696  if (valueDown < 0) {
1697  valueDown = 0; increaseCounter(indexSF, TagWeight);
1698  } else if (valueDown > m_maxTagWeight) {
1699  valueDown = m_maxTagWeight; increaseCounter(indexSF, TagWeight);
1700  }
1701 
1702  result.first = valueUp;
1703  result.second = valueDown;
1704  return statusUp;
1705  } //end eigenvector method
1706 
1707  //Proceed with no-eigenvector result
1708 
1709  // retrieve the statistical uncertainty if desired
1710  double stat(0);
1711  if (unc == Total || unc == Statistical) {
1712  if (container->getStatUncertainty(variables, stat) == Analysis::kError) {
1713  cerr << "getWeightScaleFactor: error retrieving Scale factor parameter covariance matrix!" << endl;
1714  return Analysis::kError;
1715  }
1716  }
1717  Analysis::UncertaintyResult uncertaintyResult(0,0);
1718  if (unc == Total || unc == Systematic) {
1719  if (container->getSystUncertainty(variables, uncertaintyResult) == Analysis::kError) {
1720  cerr << "getWeightScaleFactor: error retrieving Scale factor parameter systematic uncertainty!" << endl;
1721  return Analysis::kError;
1722  }
1723  } else if (unc == Extrapolation) {
1724  // this uncertainty is special, since it is not normally to be combined into the overall systematic uncertainty
1725  if (container->getUncertainty("extrapolation", variables, uncertaintyResult) == Analysis::kError)
1726  cerr << "getWeightScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
1727  } else if (unc == TauExtrapolation) {
1728  // also this uncertainty is special, since it it singles out an uncertainty relevant only for tau "jets",
1729  // and some care has to be taken not to duplicate or omit uncertainties
1730  if (container->getUncertainty("extrapolation from charm", variables, uncertaintyResult) == Analysis::kError)
1731  cerr << "getWeightScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
1732  }
1733 
1734  double uncertainty = combinedUncertainty(stat, uncertaintyResult);
1735 
1736  // Now carry out the rescaling. Again protect against unphysical or suspiciously large scale factors
1737  // First step: from the calibration sample to its reference sample
1738  if (m_useTopologyRescaling) value = 1.0 + (value - 1.0) * (fracMCref / fracSFref);
1739  // Second step: from the calibration reference sample to the MC object's reference sample
1740  if (m_useMCMCSF) value *= (fracSFref / fracEffref);
1741  // Third step: from the MC object's reference sample to the MC sample itself
1742  if (m_useTopologyRescaling) value = 1.0 + (value - 1.0) * (fracEffref / fracMCnew);
1743  if (value < 0) {
1744  value = 0; increaseCounter(indexSF, TagWeight);
1745  } else if (value > m_maxTagWeight) {
1747  }
1748  // Since all transformations of the scale factor itself are linear, the transformation of the uncertainty is simpler.
1749  if (m_useTopologyRescaling) {
1750  uncertainty *= (fracMCref / fracMCnew);
1751  } else if (m_useMCMCSF) {
1752  uncertainty *= (fracSFref / fracEffref);
1753  }
1754 
1755  result.first = std::max(0., value);
1756  result.second = uncertainty;
1757  // "Select" the status code for the actual calibration object (it is subject to more constraints)
1758  return status;
1759 }

◆ getWeightScaleFactor() [3/3]

Analysis::CalibResult Analysis::CalibrationDataInterfaceROOT::getWeightScaleFactor ( const CalibrationDataVariables variables,
unsigned int  indexSF,
unsigned int  indexEff,
Uncertainty  unc,
unsigned int  numVariation = 0 
)

efficiency scale factor retrieval by index

Definition at line 1523 of file CalibrationDataInterfaceROOT.cxx.

1526 {
1527  // #2
1528  // Tag weight fraction scale factor retrieval identifying the requested calibration object by index.
1529  // The return value is either a (value, uncertainty) or (if eigenvector or named variations are specified)
1530  // an (up, down) variation pair, and will be a dummy value in case an error occurs.
1531  // Note that in contrast to the "regular" (non-continuous) case, the computation of the scale factor in
1532  // general needs the (selection- or even process-specific) MC tag weight fractions, in order to rescale
1533  // scale factors. This is used to ensure that the tag weight fractions (both in data and in MC) sum up to
1534  // unity for each given kinematic bin.
1535  //
1536  // variables: object holding kinematic (and other) information needed to compute the result
1537  // indexSF: index to calibration object
1538  // indexEff: index to MC tag weight
1539  // unc: keyword indicating what uncertainties to evaluate (or whether eigenvector or
1540  // named variations are to be computed)
1541  // numVariation: variation index (in case of eigenvector or named variations)
1542 
1544  return (getWeightScaleFactor(variables, indexSF, indexEff, unc, numVariation, result) == Analysis::kError) ?
1546 }

◆ increaseCounter()

void Analysis::CalibrationDataInterfaceROOT::increaseCounter ( unsigned int  index,
OutOfBoundsType  oob = Main 
)
private

Definition at line 1959 of file CalibrationDataInterfaceROOT.cxx.

1961 {
1962  // Internal method bumping the relevant counter out-of-bounds counter for the specified object.
1963  //
1964  // oob: further classification of out-of-bounds case
1965  // index: object index
1966 
1967  // make sure the vectors are appropriately dimensioned
1968  if (index >= m_mainCounters.size()) {
1969  unsigned int minsize = (index == 0) ? 2 : 2*index;
1970  m_mainCounters.resize(minsize, 0);
1971  m_etaCounters.resize(minsize, 0);
1972  m_extrapolatedCounters.resize(minsize, 0);
1973  }
1974  switch (oob) {
1975  case Main:
1976  m_mainCounters[index]++; break;
1977  case Eta:
1978  m_etaCounters[index]++; break;
1979  case Extrapolated:
1980  default:
1982  }
1983 }

◆ initialize()

void Analysis::CalibrationDataInterfaceROOT::initialize ( const std::string &  jetauthor,
const std::string &  OP,
Uncertainty  unc 
)

initialization for PROOF usage

Definition at line 2484 of file CalibrationDataInterfaceROOT.cxx.

2485 {
2486  // Preload objects necessary so that the input calibration file can be closed.
2487  // This functionality is only needed when using PROOF.
2488 
2489  if((!m_fileEff)||(!m_fileSF)) {
2490  cerr << "initialize can only be called once per CalibrationDataInterfaceROOT object" << endl;
2491  return;
2492  } else {
2493  cout << "initializing BTagCalibrationDataInterfaceROOT for PROOF with jetAuthor = " << jetauthor << ", tagger = " << m_taggerName << ", operating point = " << OP << ", uncertainty = " << unc << endl;
2494  }
2495 
2496  CalibrationDataVariables BTagVars;
2497  BTagVars.jetAuthor = jetauthor;
2498  BTagVars.jetPt = 100000.; //Irrelevant, just has to be valid to retrieve objects
2499  BTagVars.jetEta = 1.5; //Irrelevant, just has to be valid to retrieve objects
2500 
2501  for(const auto& flavour : m_flavours){
2502  std::pair<double, double> BTagCalibResult;
2503  BTagCalibResult = getScaleFactor(BTagVars, flavour, OP, unc);
2504  std::cout << "CalibrationDataInterfaceROOT->initialize : BTagCalibResult " << std::endl;
2505 
2506  std::pair<double, double> BTagCalibMCEff;
2507  BTagCalibMCEff = getMCEfficiency(BTagVars, flavour, OP, unc);
2508  std::cout << "CalibrationDataInterfaceROOT->initialize : BTagCalibMCEff " << std::endl;
2509  }
2510 
2511  if (m_fileEff != m_fileSF) {
2512  m_fileEff->Close();
2513  delete m_fileEff;
2514  }
2515  m_fileSF->Close();
2516  delete m_fileSF;
2517  m_fileEff = 0; //prevents repeat deletion in destructor
2518  m_fileSF = 0; //prevents repeat deletion in destructor
2519 }

◆ listScaleFactorUncertainties() [1/2]

std::vector< string > Analysis::CalibrationDataInterfaceROOT::listScaleFactorUncertainties ( const std::string &  author,
const std::string &  label,
const std::string &  OP,
bool  named = false 
)

retrieve the list of "uncertainties" relevant to the calibration object.

A few uncertainty names are predetermined: "result", "comment", "statistics", "systematics". Other sources of systematic uncertainty may be added. Note that the "systematics" source does not give access to correlations between bins. If the 'named' argument is true, the list does not include all uncertainties but only those excluded from the eigenvector construction (this option is only relevant if eigenvector use has been switched on to begin with). In this case the order of the uncertainties listed is important since it indicates the index by which the given named uncertainty is identified.

Definition at line 1987 of file CalibrationDataInterfaceROOT.cxx.

1991 {
1992  // Retrieve the sources of uncertainty relevant for the given scale factor calibration object,
1993  // identifying the object by name.
1994  //
1995  // author: jet collection name
1996  // label: jet flavour label
1997  // OP: tagger working point
1998  // named: if false, an unsorted list of sources of uncertainties will be returned.
1999  // if true, only 'named' uncertainties will be returned, and the position in
2000  // the vector that is the return value determines the 'numVariation' index
2001  // that is to be used if named variations are to be retrieved.
2002 
2003  unsigned int index;
2004  if (! retrieveCalibrationIndex (label, OP, author, true, index)) {
2005  // Return a dummy result if the object is not found
2006  cerr << "listScaleFactorUncertainties: unable to find SF calibration for object " << fullName(author, OP, label, true) << endl;
2007  std::vector<string> dummy;
2008  return dummy;
2009  }
2010  return listScaleFactorUncertainties(index, label, named);
2011 }

◆ listScaleFactorUncertainties() [2/2]

std::vector< string > Analysis::CalibrationDataInterfaceROOT::listScaleFactorUncertainties ( unsigned int  index,
const std::string &  flavour,
bool  named = false 
)

retrieve the list of "uncertainties" relevant to the calibration object.

A few uncertainty names are predetermined: "result", "comment", "statistics", "systematics". Other sources of systematic uncertainty may be added. Note that the "systematics" source does not give access to correlations between bins. If the 'named' argument is true, the list does not include all uncertainties but only those excluded from the eigenvector construction (this option is only relevant if eigenvector use has been switched on to begin with). In this case the order of the uncertainties listed is important since it indicates the index by which the given named uncertainty is identified.

Definition at line 2015 of file CalibrationDataInterfaceROOT.cxx.

2017 {
2018  // Note: this method already works on a per-flavour basis, so passing flavour in is a simple addition
2019  // Method is called primarily from within the BTaggingEfficiencyTool - W.L.
2020  // Retrieve the sources of uncertainty relevant for the given scale factor calibration object,
2021  // identifying the object by index.
2022  //
2023  // index: index to scale factor calibration object
2024  // named: if false, an unsorted list of sources of uncertainties will be returned.
2025  // if true, only 'named' uncertainties will be returned, and the position in
2026  // the vector that is the return value determines the 'numVariation' index
2027  // that is to be used if named variations are to be retrieved.
2028 
2029  std::vector<string> dummy;
2031 
2032  if (container) {
2033  if (named) {
2034  // Find out which uncertainties are excluded from eigenvector construction
2035  if (! m_runEigenVectorMethod) return dummy;
2036  std::shared_ptr<CalibrationDataEigenVariations> eigenVariation=m_eigenVariationsMap.at(container);
2038  std::vector<string> unordered = eigenVariation->listNamedVariations(); // this is for the regular EV
2039  std::vector<string> ordered(unordered.size());
2040  for (unsigned int i = 0; i < unordered.size(); ++i) {
2041  ordered[eigenVariation->getNamedVariationIndex(unordered[i])] = unordered[i];
2042  }
2043  return ordered;
2045  // here we want to get the named uncertainties from the global eigenvariations flavour container specifically...
2046  std::shared_ptr<CalibrationDataGlobalEigenVariations> GEV = std::dynamic_pointer_cast<CalibrationDataGlobalEigenVariations>(eigenVariation);
2047  std::vector<std::string> unordered = GEV->listNamedVariations(flavour);
2048  std::vector<std::string> ordered(unordered.size()); // ordered by the NAMED VARIATION (internal) ORDERING
2049  for (unsigned int i = 0; i < unordered.size(); ++i) {
2050  ordered[GEV->getNamedVariationIndex(unordered[i], flavour)] = unordered[i];
2051  }
2052  return ordered;
2053  }
2054  }
2055  return container->listUncertainties(); // return this if not named
2056  }
2057 
2058  return dummy;
2059 }

◆ nameFromIndex()

std::string Analysis::CalibrationDataInterfaceROOT::nameFromIndex ( unsigned int  index) const

Retrieve the name of the calibration object (container) given its index.

Definition at line 1945 of file CalibrationDataInterfaceROOT.cxx.

1946 {
1947  // Return the object name corresponding to the given index.
1948 
1949  for (std::map<std::string, unsigned int>::const_iterator it = m_objectIndices.begin();
1950  it != m_objectIndices.end(); ++it)
1951  if (it->second == index) return it->first;
1952 
1953  // This should never happen..
1954  return string("");
1955 }

◆ retrieveCalibrationIndex()

bool Analysis::CalibrationDataInterfaceROOT::retrieveCalibrationIndex ( const std::string &  label,
const std::string &  OP,
const std::string &  author,
bool  isSF,
unsigned int &  index,
unsigned int  mapIndex = 0 
)

Retrieve the index of the calibration object (container) starting from the label and operating point.

The return value will be false if the requested object cannot be found.

Definition at line 688 of file CalibrationDataInterfaceROOT.cxx.

693 {
694  // Retrieve the integer index corresponding to a given combination of
695  // flavour label / tagger / working point / jet collection name, and separately
696  // for calibration scale factors and MC efficiencies (all these ingredients are needed
697  // to specify fully the calibration object).
698  // In fact this method will also trigger the retrieval of the object itself, if not already
699  // done, and will cache it internally. The absence of the requested calibration object will
700  // be flagged by a false return value.
701  // This method is used internally but should also be called by users in order to exploit the
702  // "code speed-up" features documented above.
703  //
704  // label: jet flavour label
705  // OP: tagger working point
706  // author: jet collection name
707  // isSF: set to true (false) for scale factors (MC efficiencies)
708  // index: resulting index (meaningful only for a 'true' function return value)
709  // mapIndex: index to the MC efficiency map to be used
710 
711  index = 0;
712 
713  // construct the full name from the label, operating point, SF/Eff choice;
714  // then look up this full name
715  string name = fullName(author, OP, label, isSF, mapIndex);
716  std::map<string, unsigned int>::const_iterator it = m_objectIndices.find(name);
717  if (it == m_objectIndices.end()) {
718  // If no container is found, attempt to retrieve it here (this is so that users won't
719  // have to call the named scale factor etc. methods once just to retrieve the container).
720  string flavour = (label == "N/A") ? "Light" : label;
721  string cntname = getContainername(flavour, isSF, mapIndex);
722  if (m_verbose) std::cout << "CalibrationDataInterfaceROOT->retrieveCalibrationIndex : container name is " << cntname << std::endl;
723  retrieveContainer(flavour, OP, author, cntname, isSF, m_verbose); // Only call this if you want to retrieve a currently not available container
724  it = m_objectIndices.find(name);
725  if (it == m_objectIndices.end()) return false;
726  } else {
727  if (m_verbose) std::cout << "CalibrationDataInterfaceROOT->retrieveCalibrationIndex : container " << name << " already cached! " << std::endl;
728  }
729 
730  index = it->second;
731  return true;
732 }

◆ retrieveContainer()

CalibrationDataContainer * Analysis::CalibrationDataInterfaceROOT::retrieveContainer ( const std::string &  label,
const std::string &  OP,
const std::string &  author,
const std::string &  cntname,
bool  isSF,
bool  doPrint = true 
)

utility function taking care of object retrieval

Definition at line 2523 of file CalibrationDataInterfaceROOT.cxx.

2524 {
2525  // Attempt to retrieve the given container from file. Note that also the corresponding
2526  // "hadronisation" reference is retrieved (if possible and not yet done).
2527  //
2528  // dir: name of the directory containing the requested container
2529  // cntname: name of the requested container itself (not including the full path)
2530  // isSF: set to false (true) if the object is to be retrieved from the MC efficiencies
2531  // file (the calibration scale factor file). Note that it is assumed that scale
2532  // factor objects will always be retrieved from the calibration scale factor file.
2533  // doPrint: if true, print out some basic information about the successfully retrieved container
2534  // (note that this is typically steered by the m_verbose setting;
2535  // only for the retrieval of the maps used for MC/MC SF calculations, this printout is always switched off)
2536 
2537  string dir = m_taggerName + "/" + getAlias(author) + "/" + OP + "/" + label;
2538  // construct the full object name
2539  string name = dir + "/" + cntname;
2540 
2541  // If the object cannot be found, then each call will result in a new attempt to
2542  // retrieve the object from the ROOT file. Hopefully this will not happen too often...
2543  unsigned int idx = m_objectIndices[name] = m_objects.size();
2544  // CalibrationDataContainer* cnt =
2545  // dynamic_cast<CalibrationDataContainer*>((isSF ? m_fileSF : m_fileEff) ->Get(name.c_str()));
2547  (isSF ? m_fileSF : m_fileEff)->GetObject(name.c_str(), cnt);
2548  // If the requested object is a MC efficiency container and is not found, make a second attempt
2549  // to retrieve it from the calibration scale factor file. This will avoid the need to duplicate
2550  // efficiency containers so that the MC efficiency file needs to store only those containers
2551  // not already present in the calibration scale factor file. Of course this is meaningful only
2552  // if separate files are used to begin with.
2553  if (!isSF && !cnt && m_fileSF != m_fileEff) m_fileSF->GetObject(name.c_str(), cnt);
2554  m_objects.push_back(cnt);
2555  if (!cnt) {
2556  cerr << "btag Calib: retrieveContainer: failed to retrieve container named " << name.c_str() << " from file" << endl;
2557  return 0;
2558  }
2559 
2560  // For successfully retrieved containers, also print some more information (implemented on user request)
2561  if (doPrint) {
2562  cout << "CalibrationDataInterface: retrieved container " << name << " (with comment: '" << cnt->getComment() << "' and hadronisation setting '" << cnt->getHadronisation() << "')" << endl;
2563  }
2564 
2565 
2566  // If the requested object is a MC efficiency container, make sure to retrieve the corresponding
2567  // calibration scale factor container first (a feature first thought to be necessary, erroneously,
2568  // but left in since this ordering should not hurt in any case).
2569  if (m_refMap.find(dir) == m_refMap.end()) {
2570  if (isSF) {
2571  // Retrieve the mapping objects from both files and merge their information using the 'helper' class.
2572  // The map resulting from this is used to retrieve the information required to compute MC/MC scale factors.
2573  string hadronisationRefs(dir + "/MChadronisation_ref");
2574  TMap* mapSF = 0; m_fileSF->GetObject(hadronisationRefs.c_str(), mapSF);
2575  TMap* mapEff = 0; if (m_fileEff != m_fileSF) m_fileEff->GetObject(hadronisationRefs.c_str(), mapEff);
2576  m_refMap[dir] = new HadronisationReferenceHelper(mapSF, mapEff);
2577  delete mapSF;
2578  delete mapEff;
2579  } else {
2580  string SFCalibName = getContainername(getBasename(dir), true);
2581  if (m_objectIndices.find(SFCalibName) == m_objectIndices.end()) retrieveContainer(label, OP, author, SFCalibName, true, doPrint);
2582  }
2583  }
2584 
2585  // Attempt to find the corresponding hadronisation reference container needed for the application of
2586  // MC/MC scale factors.
2587  if (idx+1 > m_hadronisationReference.size()) m_hadronisationReference.resize(idx+1, -1);
2589  string spec = cnt->getHadronisation();
2590  if (spec != "") {
2591  std::map<string, HadronisationReferenceHelper*>::const_iterator mapit = m_refMap.find(dir);
2592  if (mapit != m_refMap.end()) {
2593  string ref;
2594  if (mapit->second->getReference(spec, ref)) {
2595  // Retrieve the hadronisation reference if not already done. Note that the "isSF" is left unchanged:
2596  // this allows to retrieve the reference from the same file as the scale factor object. An exception
2597  // is the reference for the calibration scale factor object, which should always be obtained from
2598  // the scale factor file.
2599  // An efficiency container can be its own hadronisation reference (this is not "protected" against).
2600  string refname(dir + "/" + ref);
2601  std::map<string, unsigned int>::const_iterator it = m_objectIndices.find(refname);
2602  // If the reference cannot be found, assume that it hasn't yet been retrieved so attempt it now.
2603  if (it == m_objectIndices.end()) {
2604  // Omit the printout of container information here (the idea being that showing MC/MC SF information would confuse rather than help)
2605  retrieveContainer(label, OP, author, ref, isSF, false); it = m_objectIndices.find(refname);
2606  }
2607  m_hadronisationReference[idx] = it->second;
2608  }
2609  } else if (m_useMCMCSF) {
2610  cerr << "btag Calib: retrieveContainer: MC hadronisation reference map not found -- this should not happen!" << endl;
2611  }
2612  }
2614  // Not being able to construct the MC/MC scale factors will lead to a potential bias.
2615  // However, this is not considered sufficiently severe that we will flag it as an error.
2616  if (m_useMCMCSF){
2617  cerr << "btag Calib: retrieveContainer: warning: unable to apply MC/MC scale factors for container " << name << " with hadronisation reference = '" << spec << "'" << endl;
2618  }
2619  }
2620 
2621  // Initialize the Eigenvector variation object corresponding to this object, if applicable. Notes:
2622  // - the dual use of "isSF" (both referring to the file and to the object, see above) requires another protection here
2623  // - the constructor's second argument is used to determine whether to exclude a pre-determined set of uncertainties from the EV decomposition
2624  //
2625  // We also want to separate behavior between SFEigen and SFGlobalEigen systematic strategies
2626  // The former requires a CalibrationDataEigenVariations object to be made per flavour.
2627  // The latter combines all corresponding flavours, so once it's been made for a single flavour, it's cached under all the corresponding "flavour containers"
2628  // simulataneously in m_eigenVariationsMap, and is checked for on each subsequent call to this method.
2629  if (m_runEigenVectorMethod && isSF && name.find("_SF") != string::npos) {
2630  CalibrationDataHistogramContainer* histoContainer=dynamic_cast<CalibrationDataHistogramContainer*>(cnt);
2631  if (histoContainer==0) {
2632  cerr << "Could not cast Container to a HistogramContainer. " << endl;
2633  return 0;
2634  }
2637  std::shared_ptr<CalibrationDataEigenVariations> newEigenVariation(new CalibrationDataEigenVariations(m_filenameSF, m_taggerName, OP, author, histoContainer, m_useRecommendedEVExclusions));
2638  newEigenVariation->setVerbose(m_verbose);
2639 
2640  // At this point we may also want to reduce the number of eigenvector variations.
2641  // The choices are stored with the container object; but first we need to know what flavour we are dealing with.
2642  string flavour = dir.substr(dir.find_last_of("/")+1);
2643 
2644  for (auto entry : m_excludeFromCovMatrix[flavour]) {
2645  newEigenVariation->excludeNamedUncertainty(entry, cnt);
2646  }
2647  newEigenVariation->initialize();
2648  int to_retain = histoContainer->getEigenvectorReduction(m_EVReductions[flavour]); // returns the number of eigenvariations to retain as per the EV reduction strategy
2649  if (to_retain > -1) {
2650  if (m_verbose) cout << "btag Calib: reducing number of eigenvector variations for flavour " << flavour << " to " << to_retain << endl;
2651  // The merged variations will end up as the first entry in the specified list, i.e., as the last of the variations to be "retained"
2652  newEigenVariation->mergeVariationsFrom(size_t(to_retain-1)); // All variations stored with indices larger than this are merged
2653  } else if (m_EVReductions[flavour] != Loose) {
2654  cerr << "btag Calib: unable to retrieve eigenvector reduction information for flavour " << flavour << " and scheme " << m_EVReductions[flavour] << "; not applying any reduction" << endl;
2655  }
2656  m_eigenVariationsMap[cnt]=newEigenVariation;
2657 
2661  std::map<const CalibrationDataContainer*, std::shared_ptr<CalibrationDataEigenVariations> >::iterator evit = m_eigenVariationsMap.find(cnt);
2662  // The global implementation internally combines all the "flavour containers" (containers that correspond to each other, only with different flavours)
2663  // But the CalibrationDataInterfaceROOT object doesn't need to know that, so we want to get all the flavour containers in one go here
2664  // and map them (with m_eigenVariationsMap) to the same CalibrationDataGlobalEigenVariations pointer.
2665  // Then, in methods like getScaleFactor, we call the virtual methods which will give the proper result e.g. if you want the SF for a b-jet, it'll call the
2666 
2667  if (evit == m_eigenVariationsMap.end()){
2668  // now to see if it's completely empty or not
2669  if (m_eigenVariationsMap.empty()){
2670  std::shared_ptr<CalibrationDataGlobalEigenVariations> newEigenVariation(new CalibrationDataGlobalEigenVariations(m_filenameSF, m_taggerName, OP, author, m_flavours, histoContainer, m_useRecommendedEVExclusions));
2671  for (auto entry : m_excludeFromCovMatrix[label]) {
2672  newEigenVariation->excludeNamedUncertainty(entry, label); // <---- custom exclude named uncertainties method for global variations
2673  }
2674 
2675  newEigenVariation->initialize();
2676 
2677  // flavour loop to get the flavour reduction schemes and apply them
2678  for (std::string& flavour : m_flavours){
2679  int to_retain = histoContainer->getEigenvectorReduction(m_EVReductions[flavour]); // returns the number of eigenvariations to retain as per the EV reduction strategy
2680  if (to_retain > -1) {
2681  if (m_verbose) cout << "btag Calib: reducing number of eigenvector variations for flavour " << flavour << " to " << to_retain << endl;
2682  // The merged variations will end up as the first entry in the specified list, i.e., as the last of the variations to be "retained"
2683  newEigenVariation->mergeVariationsFrom(size_t(to_retain-1), flavour); // All variations stored with indices larger than this are merged
2684  } else if (m_EVReductions[flavour] != Loose) {
2685  cerr << "btag Calib: unable to retrieve eigenvector reduction information for flavour " << flavour << " and scheme " << m_EVReductions[flavour] << "; not applying any reduction" << endl;
2686  }
2687  }
2688 
2689  m_eigenVariationsMap.insert({cnt, newEigenVariation});
2690  } else {
2691  // Need to point to the CDGEV object four times in the m_eigenVariationsMap to appease the CDIROOT backend design...
2692  // Ok, turns out I can't retrieve the containers from CDGEV and insert them directly, because I'd have to use the containers directly instead..
2693  // So the strategy is to just take the CGEV objects that are already in the map, and mpa the present container to it
2694  std::shared_ptr<CalibrationDataEigenVariations> previous_eigenvariation = m_eigenVariationsMap.begin()->second;
2695  m_eigenVariationsMap.insert({cnt, previous_eigenvariation});
2696  }
2697 
2698  } else {
2699  std::cout << "CalibrationDataInterfaceROOT->retrieveContainer : the CDGEV object for " << name << " already exists! " << std::endl;
2700  }
2702  }
2703  }
2704 
2705  return cnt;
2706 }

◆ runEigenVectorRecomposition() [1/2]

Analysis::CalibrationStatus Analysis::CalibrationDataInterfaceROOT::runEigenVectorRecomposition ( const std::string &  author,
const std::string &  label,
const std::string &  OP,
unsigned int  mapindex = 0 
)

run EigenVector Recomposition method

Definition at line 2207 of file CalibrationDataInterfaceROOT.cxx.

2210  {
2211  // run eigen vector recomposition method. If success, stored the retrieved coefficient map
2212  // in m_coefficientMap and return success. Otherwise return error and keep m_coefficientMap
2213  // untouched.
2214  // author: jet collection name
2215  // label: jet flavour label
2216  // OP: tagger working point
2217  // mapIndex: index to the MC efficiency map to be used. Should be 0?
2218  // Todo: What is mapindex?
2219  // Todo: Check the way xAODBTaggingTool initialize CDI. Check if that is the as how we are initialize CDI.
2220  if(!m_runEigenVectorMethod) {
2221  cerr << "runEigenVectorRecomposition: Recomposition need to be ran with CalibrationDataInterfaceRoot initialized in eigenvector mode" << endl;
2222  return Analysis::kError;
2223  }
2224 
2225  unsigned int indexSF;
2226  if (! retrieveCalibrationIndex (label, OP, author, true, indexSF, mapIndex)) {
2227  cerr << "runEigenVectorRecomposition: unable to find SF calibration for object "
2228  << fullName(author, OP, label, true) << endl;
2229  return Analysis::kError;
2230  }
2231 
2232  return runEigenVectorRecomposition (label, indexSF);
2233 }

◆ runEigenVectorRecomposition() [2/2]

Analysis::CalibrationStatus Analysis::CalibrationDataInterfaceROOT::runEigenVectorRecomposition ( const std::string &  label,
unsigned int  mapindex = 0 
)

Definition at line 2236 of file CalibrationDataInterfaceROOT.cxx.

2237  {
2238  // run eigen vector recomposition method. If success, stored the retrieved coefficient map
2239  // in m_coefficientMap and return success. Otherwise return error and keep m_coefficientMap
2240  // untouched.
2241  // label: jet flavour label
2242  // indexSF: index to scale factor calibration object
2243  CalibrationDataContainer* container = m_objects[indexSF];
2244  if (! container) {
2245  cerr << "runEigenVectorRecomposition: error retrieving container!" << endl;
2246  return Analysis::kError;
2247  }
2248 
2249  // Retrieve eigenvariation
2250  std::shared_ptr<CalibrationDataEigenVariations> eigenVariation;
2251  try {
2252  eigenVariation = m_eigenVariationsMap.at(container);
2253  } catch (const std::out_of_range&) {
2254  cerr << "runEigenVectorRecomposition: Could not retrieve eigenvector variation, while it should have been there." << endl;
2255  return Analysis::kError;
2256  }
2257  // Doing eigenvector recomposition
2258  std::map<std::string, std::map<std::string, float>> coefficientMap;
2259  if(!eigenVariation->EigenVectorRecomposition(label, coefficientMap))
2260  return Analysis::kError;
2261 
2262  m_coefficientMap = coefficientMap;
2263  return Analysis::kSuccess;
2264 }

◆ setEffCalibrationNames()

void Analysis::CalibrationDataInterfaceBase::setEffCalibrationNames ( const std::map< std::string, std::vector< std::string > > &  names)
inherited

Definition at line 63 of file CalibrationDataInterfaceBase.cxx.

65 {
66  // Set the MC efficiency names.
67 
69 }

◆ setSFCalibrationNames()

void Analysis::CalibrationDataInterfaceBase::setSFCalibrationNames ( const std::map< std::string, std::string > &  names)
inherited

Definition at line 87 of file CalibrationDataInterfaceBase.cxx.

88 {
89  // Set the efficiency scale factor calibration names.
90 
92 }

◆ SFCalibrationName()

const std::string & Analysis::CalibrationDataInterfaceBase::SFCalibrationName ( const std::string &  flavour) const
inherited

Definition at line 72 of file CalibrationDataInterfaceBase.cxx.

73 {
74  // Return the efficiency scale factor calibration name for the given flavour.
75  // Note that no check is performed on the validity of the flavour.
76 
77  try {
78  return m_calibrationSFNames.at(flavour);
79  }
80  catch (const std::out_of_range& e) {
81  std::cerr << "SFCalibrationName: flavour '" << flavour << "' is not known." << std::endl;
82  throw e;
83  }
84 }

Member Data Documentation

◆ m_absEtaStrategy

OutOfBoundsStrategy Analysis::CalibrationDataInterfaceROOT::m_absEtaStrategy {}
private

Definition at line 474 of file CalibrationDataInterfaceROOT.h.

◆ m_aliases

std::map<std::string, std::string> Analysis::CalibrationDataInterfaceROOT::m_aliases
private

Do not attempt to persistify (PROOF)

jet author aliases (there is no single CalibrationBroker object here to take care of this, so we do it in this class)

Definition at line 405 of file CalibrationDataInterfaceROOT.h.

◆ m_calibrationEffNames

std::map<std::string, std::vector<std::string> > Analysis::CalibrationDataInterfaceBase::m_calibrationEffNames
privateinherited

this simply collects the per-flavour properties.

Definition at line 72 of file CalibrationDataInterfaceBase.h.

◆ m_calibrationSFNames

std::map<std::string, std::string> Analysis::CalibrationDataInterfaceBase::m_calibrationSFNames
privateinherited

Definition at line 73 of file CalibrationDataInterfaceBase.h.

◆ m_checkedWeightScaleFactors

std::vector<std::pair<unsigned int, unsigned int> > Analysis::CalibrationDataInterfaceROOT::m_checkedWeightScaleFactors
private

Definition at line 488 of file CalibrationDataInterfaceROOT.h.

◆ m_coefficientMap

std::map<std::string, std::map<std::string, float> > Analysis::CalibrationDataInterfaceROOT::m_coefficientMap
private

Definition at line 466 of file CalibrationDataInterfaceROOT.h.

◆ m_eigenVariationsMap

std::map<const CalibrationDataContainer*, std::shared_ptr<CalibrationDataEigenVariations> > Analysis::CalibrationDataInterfaceROOT::m_eigenVariationsMap
private

store the eigenvector class and associate to its CalibrationDataContainer

Definition at line 426 of file CalibrationDataInterfaceROOT.h.

◆ m_etaCounters

std::vector<unsigned int> Analysis::CalibrationDataInterfaceROOT::m_etaCounters
private

counters for flagging out-of-bound cases

Definition at line 480 of file CalibrationDataInterfaceROOT.h.

◆ m_EVReductions

std::map<std::string, Analysis::EVReductionStrategy> Analysis::CalibrationDataInterfaceROOT::m_EVReductions
private

Eigenvector reduction strategy (per flavour)

Definition at line 433 of file CalibrationDataInterfaceROOT.h.

◆ m_EVStrategy

Uncertainty Analysis::CalibrationDataInterfaceROOT::m_EVStrategy {}
private

Definition at line 430 of file CalibrationDataInterfaceROOT.h.

◆ m_excludeFromCovMatrix

std::map<std::string, std::vector<std::string> > Analysis::CalibrationDataInterfaceROOT::m_excludeFromCovMatrix
private

store the uncertainties which should be excluded from building the full covariance matrix

Definition at line 436 of file CalibrationDataInterfaceROOT.h.

◆ m_extrapolatedCounters

std::vector<unsigned int> Analysis::CalibrationDataInterfaceROOT::m_extrapolatedCounters
private

Definition at line 482 of file CalibrationDataInterfaceROOT.h.

◆ m_fileEff

TFile* Analysis::CalibrationDataInterfaceROOT::m_fileEff {}
private

pointer to the TFile object providing access to the calibrations

Definition at line 400 of file CalibrationDataInterfaceROOT.h.

◆ m_filenameEff

std::string Analysis::CalibrationDataInterfaceROOT::m_filenameEff
private

Definition at line 418 of file CalibrationDataInterfaceROOT.h.

◆ m_filenameSF

std::string Analysis::CalibrationDataInterfaceROOT::m_filenameSF
private

in addition, store also the filenames themselves (needed for the copy constructor)

Definition at line 417 of file CalibrationDataInterfaceROOT.h.

◆ m_fileSF

TFile* Analysis::CalibrationDataInterfaceROOT::m_fileSF {}
private

Do not attempt to persistify (PROOF)

Definition at line 401 of file CalibrationDataInterfaceROOT.h.

◆ m_flavours

std::vector<std::string> Analysis::CalibrationDataInterfaceROOT::m_flavours
private

Definition at line 419 of file CalibrationDataInterfaceROOT.h.

◆ m_hadronisationReference

std::vector<int> Analysis::CalibrationDataInterfaceROOT::m_hadronisationReference
private

store the 'hadronisation' reference for each object (-1 means no reference found)

Definition at line 461 of file CalibrationDataInterfaceROOT.h.

◆ m_mainCounters

std::vector<unsigned int> Analysis::CalibrationDataInterfaceROOT::m_mainCounters
private

Definition at line 481 of file CalibrationDataInterfaceROOT.h.

◆ m_maxAbsEta

double Analysis::CalibrationDataInterfaceROOT::m_maxAbsEta {}
private

|eta| bounds and strategy for dealing with out-of-bounds conditions

Definition at line 473 of file CalibrationDataInterfaceROOT.h.

◆ m_maxTagWeight

double Analysis::CalibrationDataInterfaceROOT::m_maxTagWeight {}
private

Definition at line 489 of file CalibrationDataInterfaceROOT.h.

◆ m_objectIndices

std::map<std::string, unsigned int> Analysis::CalibrationDataInterfaceROOT::m_objectIndices
private

Definition at line 411 of file CalibrationDataInterfaceROOT.h.

◆ m_objects

std::vector<CalibrationDataContainer*> Analysis::CalibrationDataInterfaceROOT::m_objects
private

cache the objects themselves (so that the user will not have to delete them after each call etc.).

The caching is done so that objects can be retrieved by number as well as by (OP, flavour, calibration name) combination.

Definition at line 410 of file CalibrationDataInterfaceROOT.h.

◆ m_otherStrategy

OutOfBoundsStrategy Analysis::CalibrationDataInterfaceROOT::m_otherStrategy {}
private

Definition at line 475 of file CalibrationDataInterfaceROOT.h.

◆ m_refMap

std::map<std::string, HadronisationReferenceHelper*> Analysis::CalibrationDataInterfaceROOT::m_refMap
private

the following maps (one for each directory) specify the name of the container serving as the 'hadronisation' reference for each object

Definition at line 459 of file CalibrationDataInterfaceROOT.h.

◆ m_runEigenVectorMethod

bool Analysis::CalibrationDataInterfaceROOT::m_runEigenVectorMethod {}
private

decide whether to run the eigenvector method or not

Definition at line 429 of file CalibrationDataInterfaceROOT.h.

◆ m_taggerName

std::string Analysis::CalibrationDataInterfaceBase::m_taggerName
protectedinherited

tagging algorithm name

Definition at line 94 of file CalibrationDataInterfaceBase.h.

◆ m_useMCMCSF

bool Analysis::CalibrationDataInterfaceROOT::m_useMCMCSF {}
private

specify whether or not to use MC/MC (hadronisation) scale factors (the fact that this is steerable is intended to be temporary only)

Definition at line 452 of file CalibrationDataInterfaceROOT.h.

◆ m_useRecommendedEVExclusions

bool Analysis::CalibrationDataInterfaceROOT::m_useRecommendedEVExclusions {}
private

if true, exclude pre-recommended lists of uncertainties from the covariance matrix building, in addition to the above user specified lists

Definition at line 441 of file CalibrationDataInterfaceROOT.h.

◆ m_useTopologyRescaling

bool Analysis::CalibrationDataInterfaceROOT::m_useTopologyRescaling {}
private

specify whether or not to use MC/MC (topology) scale factors (also this steering option may be removed)

Definition at line 455 of file CalibrationDataInterfaceROOT.h.

◆ m_verbose

bool Analysis::CalibrationDataInterfaceROOT::m_verbose {}
private

if true, allow also for some informational (and not only error/warning) messages

Definition at line 444 of file CalibrationDataInterfaceROOT.h.


The documentation for this class was generated from the following files:
Analysis::CalibResult
std::pair< double, double > CalibResult
Definition: CalibrationDataInterfaceBase.h:34
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
Analysis::CalibrationDataEigenVariations::isExtrapolationVariation
bool isExtrapolationVariation(unsigned int nameIndex) const
flag whether the given index corresponds to an extrapolation variation
Definition: CalibrationDataEigenVariations.cxx:1099
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
Analysis::GiveUp
@ GiveUp
Definition: CalibrationDataInterfaceROOT.h:82
Analysis::CalibrationDataEigenVariations::getNamedVariationIndex
unsigned int getNamedVariationIndex(const std::string &name) const
retrieve the integer index corresponding to the named variation.
Definition: CalibrationDataEigenVariations.cxx:1088
Analysis::CalibrationDataInterfaceROOT::m_maxAbsEta
double m_maxAbsEta
|eta| bounds and strategy for dealing with out-of-bounds conditions
Definition: CalibrationDataInterfaceROOT.h:473
Analysis::CalibrationDataInterfaceROOT::m_EVReductions
std::map< std::string, Analysis::EVReductionStrategy > m_EVReductions
Eigenvector reduction strategy (per flavour)
Definition: CalibrationDataInterfaceROOT.h:433
Analysis::CalibrationDataContainer::getUncertainty
virtual CalibrationStatus getUncertainty(const std::string &unc, const CalibrationDataVariables &x, UncertaintyResult &result, TObject *obj=0)=0
retrieve the calibration uncertainty due to the given source.
Analysis::CalibrationDataInterfaceROOT::nameFromIndex
std::string nameFromIndex(unsigned int index) const
Retrieve the name of the calibration object (container) given its index.
Definition: CalibrationDataInterfaceROOT.cxx:1945
Analysis::CalibrationDataInterfaceBase::m_calibrationEffNames
std::map< std::string, std::vector< std::string > > m_calibrationEffNames
this simply collects the per-flavour properties.
Definition: CalibrationDataInterfaceBase.h:72
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
Analysis::dummyResult
const CalibResult dummyResult(dummyValue, dummyValue)
Analysis::CalibrationDataInterfaceROOT::m_EVStrategy
Uncertainty m_EVStrategy
Definition: CalibrationDataInterfaceROOT.h:430
get_generator_info.result
result
Definition: get_generator_info.py:21
Analysis::CalibrationDataContainer
Definition: CalibrationDataContainer.h:51
Analysis::CalibrationDataInterfaceROOT::m_useRecommendedEVExclusions
bool m_useRecommendedEVExclusions
if true, exclude pre-recommended lists of uncertainties from the covariance matrix building,...
Definition: CalibrationDataInterfaceROOT.h:441
checkCoolLatestUpdate.variables
variables
Definition: checkCoolLatestUpdate.py:13
Analysis::CalibrationDataInterfaceBase::kAbsEta
@ kAbsEta
Definition: CalibrationDataInterfaceBase.h:67
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
Analysis::CalibrationDataInterfaceROOT::fullName
std::string fullName(const std::string &author, const std::string &OP, const std::string &label, bool isSF, unsigned mapIndex=0) const
@ brief construct the full object pathname from its individual components
Definition: CalibrationDataInterfaceROOT.cxx:2721
Analysis::CalibrationDataInterfaceROOT::m_etaCounters
std::vector< unsigned int > m_etaCounters
counters for flagging out-of-bound cases
Definition: CalibrationDataInterfaceROOT.h:480
Analysis::CalibrationDataInterfaceROOT::m_hadronisationReference
std::vector< int > m_hadronisationReference
store the 'hadronisation' reference for each object (-1 means no reference found)
Definition: CalibrationDataInterfaceROOT.h:461
Analysis::CalibrationDataInterfaceBase
Definition: CalibrationDataInterfaceBase.h:47
Analysis::CalibrationDataEigenVariations::getNumberOfEigenVariations
unsigned int getNumberOfEigenVariations()
retrieve the number of eigenvector variations
Definition: CalibrationDataEigenVariations.cxx:1010
CaloCondBlobAlgs_fillNoiseFromASCII.spec
spec
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:47
index
Definition: index.py:1
Analysis::CalibrationDataEigenVariations::EigenVectorRecomposition
bool EigenVectorRecomposition(const std::string &label, std::map< std::string, std::map< std::string, float >> &coefficientMap)
Eigenvector recomposition method.
Definition: CalibrationDataEigenVariations.cxx:1109
Analysis::SFNamed
@ SFNamed
Definition: CalibrationDataInterfaceROOT.h:70
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
Analysis::CalibrationDataInterfaceROOT::runEigenVectorRecomposition
CalibrationStatus runEigenVectorRecomposition(const std::string &author, const std::string &label, const std::string &OP, unsigned int mapindex=0)
run EigenVector Recomposition method
Definition: CalibrationDataInterfaceROOT.cxx:2207
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
Analysis::CalibrationDataInterfaceBase::m_calibrationSFNames
std::map< std::string, std::string > m_calibrationSFNames
Definition: CalibrationDataInterfaceBase.h:73
Analysis::CalibrationDataInterfaceROOT::getWeightScaleFactor
CalibResult getWeightScaleFactor(const CalibrationDataVariables &variables, const std::string &label, Uncertainty unc, unsigned int numVariation=0, unsigned int mapIndex=0)
efficiency scale factor retrieval by name
Definition: CalibrationDataInterfaceROOT.cxx:1485
Analysis::Statistical
@ Statistical
Definition: CalibrationDataInterfaceROOT.h:70
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
skel.it
it
Definition: skel.GENtoEVGEN.py:396
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
Analysis::TagWeight
@ TagWeight
Definition: CalibrationDataInterfaceROOT.h:85
TRT_PAI_gasdata::SF
const float SF[NF]
Cross sections for Fluor.
Definition: TRT_PAI_gasdata.h:285
PlotCalibFromCool.ib
ib
Definition: PlotCalibFromCool.py:419
athena.value
value
Definition: athena.py:124
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Analysis::CalibrationDataContainer::getSystUncertainty
CalibrationStatus getSystUncertainty(const CalibrationDataVariables &x, UncertaintyResult &result, TObject *obj=0)
retrieve the calibration total systematic uncertainty
Definition: CalibrationDataContainer.cxx:101
x
#define x
Analysis::CalibrationDataInterfaceROOT::m_checkedWeightScaleFactors
std::vector< std::pair< unsigned int, unsigned int > > m_checkedWeightScaleFactors
Definition: CalibrationDataInterfaceROOT.h:488
Analysis::CalibrationDataContainer::getResult
virtual CalibrationStatus getResult(const CalibrationDataVariables &x, double &result, TObject *obj=0, bool extrapolate=false)=0
retrieve the calibration result.
Analysis::TauExtrapolation
@ TauExtrapolation
Definition: CalibrationDataInterfaceROOT.h:70
Analysis::CalibrationDataInterfaceROOT::getNumVariations
unsigned int getNumVariations(const std::string &author, const std::string &label, const std::string &OP, Uncertainty unc)
retrieve the number of variations relevant to the calibration object.
Definition: CalibrationDataInterfaceROOT.cxx:2063
Analysis::dummyValue
const double dummyValue
Definition: CalibrationDataInterfaceBase.h:33
Analysis::CalibrationDataContainer::kAbsEta
@ kAbsEta
Definition: CalibrationDataContainer.h:66
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
Analysis::CalibrationDataInterfaceROOT::m_eigenVariationsMap
std::map< const CalibrationDataContainer *, std::shared_ptr< CalibrationDataEigenVariations > > m_eigenVariationsMap
store the eigenvector class and associate to its CalibrationDataContainer
Definition: CalibrationDataInterfaceROOT.h:426
Analysis::CalibrationDataInterfaceBase::m_taggerName
std::string m_taggerName
tagging algorithm name
Definition: CalibrationDataInterfaceBase.h:94
Analysis::Main
@ Main
Definition: CalibrationDataInterfaceROOT.h:85
Analysis::kSuccess
@ kSuccess
Definition: CalibrationDataVariables.h:57
Analysis::Total
@ Total
Definition: CalibrationDataInterfaceROOT.h:70
MakeFileForReductions.largest
float largest
Definition: MakeFileForReductions.py:95
Analysis::CalibrationDataInterfaceROOT::m_excludeFromCovMatrix
std::map< std::string, std::vector< std::string > > m_excludeFromCovMatrix
store the uncertainties which should be excluded from building the full covariance matrix
Definition: CalibrationDataInterfaceROOT.h:436
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
Analysis::CalibrationDataInterfaceROOT::m_absEtaStrategy
OutOfBoundsStrategy m_absEtaStrategy
Definition: CalibrationDataInterfaceROOT.h:474
Analysis::CalibrationDataInterfaceROOT::retrieveContainer
CalibrationDataContainer * retrieveContainer(const std::string &label, const std::string &OP, const std::string &author, const std::string &cntname, bool isSF, bool doPrint=true)
utility function taking care of object retrieval
Definition: CalibrationDataInterfaceROOT.cxx:2523
Analysis::CalibrationDataInterfaceBase::kEta
@ kEta
Definition: CalibrationDataInterfaceBase.h:67
Analysis::GiveUpExtrapolated
@ GiveUpExtrapolated
Definition: CalibrationDataInterfaceROOT.h:82
Analysis::CalibrationDataContainer::listUncertainties
std::vector< std::string > listUncertainties() const
retrieve the list of "uncertainties" accessible to this object.
Definition: CalibrationDataContainer.cxx:120
Analysis::CalibrationDataInterfaceROOT::getEfficiency
CalibResult getEfficiency(const CalibrationDataVariables &variables, const std::string &label, const std::string &OP, Uncertainty unc, const std::string &flavour, unsigned int numVariation=0, unsigned int mapIndex=0)
efficiency retrieval by name
Definition: CalibrationDataInterfaceROOT.cxx:1071
Analysis::CalibrationDataInterfaceROOT::m_verbose
bool m_verbose
if true, allow also for some informational (and not only error/warning) messages
Definition: CalibrationDataInterfaceROOT.h:444
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:182
Analysis::CalibrationDataInterfaceROOT::m_otherStrategy
OutOfBoundsStrategy m_otherStrategy
Definition: CalibrationDataInterfaceROOT.h:475
Analysis::kExtrapolatedRange
@ kExtrapolatedRange
Definition: CalibrationDataVariables.h:59
lumiFormat.i
int i
Definition: lumiFormat.py:85
Analysis::CalibrationDataContainer::kEta
@ kEta
Definition: CalibrationDataContainer.h:65
Analysis::kError
@ kError
Definition: CalibrationDataVariables.h:60
Analysis::CalibrationDataInterfaceROOT::m_filenameSF
std::string m_filenameSF
in addition, store also the filenames themselves (needed for the copy constructor)
Definition: CalibrationDataInterfaceROOT.h:417
python.subdetectors.mmg.names
names
Definition: mmg.py:8
Analysis::CalibrationDataInterfaceBase::combinedUncertainty
double combinedUncertainty(double stat, const std::pair< double, double > &syst) const
utility function for combination of statistical and (a priori asymmetric) systematic uncertainty.
Definition: CalibrationDataInterfaceBase.cxx:147
Analysis::CalibrationDataInterfaceROOT::m_refMap
std::map< std::string, HadronisationReferenceHelper * > m_refMap
the following maps (one for each directory) specify the name of the container serving as the 'hadroni...
Definition: CalibrationDataInterfaceROOT.h:459
Analysis::CalibrationDataInterfaceROOT::m_flavours
std::vector< std::string > m_flavours
Definition: CalibrationDataInterfaceROOT.h:419
Analysis::CalibrationDataEigenVariations
Definition: CalibrationDataEigenVariations.h:27
Analysis::CalibrationDataInterfaceROOT::m_useTopologyRescaling
bool m_useTopologyRescaling
specify whether or not to use MC/MC (topology) scale factors (also this steering option may be remove...
Definition: CalibrationDataInterfaceROOT.h:455
Analysis::CalibrationDataEigenVariations::getEigenvectorVariation
bool getEigenvectorVariation(unsigned int variation, TH1 *&up, TH1 *&down)
obtain the "up" and "down" variations for the given eigenvector number.
Definition: CalibrationDataEigenVariations.cxx:1018
Analysis::Loose
@ Loose
Definition: CalibrationDataInterfaceROOT.h:73
Analysis::CalibrationDataInterfaceROOT::getMCMCScaleFactor
double getMCMCScaleFactor(const CalibrationDataVariables &variables, unsigned indexSF, unsigned int indexEff) const
MC/MC scale factor retrieval.
Definition: CalibrationDataInterfaceROOT.cxx:1465
CalibCoolCompareRT.up
up
Definition: CalibCoolCompareRT.py:109
Analysis::kRange
@ kRange
Definition: CalibrationDataVariables.h:58
Analysis::SFEigen
@ SFEigen
Definition: CalibrationDataInterfaceROOT.h:70
Analysis::UncertaintyResult
std::pair< double, double > UncertaintyResult
The following typedef is for convenience: most uncertainties can be asymmetric.
Definition: CalibrationDataContainer.h:33
Analysis::CalibrationDataInterfaceROOT::listScaleFactorUncertainties
std::vector< std::string > listScaleFactorUncertainties(const std::string &author, const std::string &label, const std::string &OP, bool named=false)
retrieve the list of "uncertainties" relevant to the calibration object.
Definition: CalibrationDataInterfaceROOT.cxx:1987
python.xAODType.dummy
dummy
Definition: xAODType.py:4
Analysis::CalibrationDataInterfaceROOT::getMCEfficiency
CalibResult getMCEfficiency(const CalibrationDataVariables &variables, const std::string &label, const std::string &OP, Uncertainty unc=None, unsigned int mapIndex=0)
"MC" efficiency retrieval by name
Definition: CalibrationDataInterfaceROOT.cxx:963
hist_file_dump.f
f
Definition: hist_file_dump.py:135
GEV
#define GEV
Definition: PrintPhotonSF.cxx:24
Analysis::CalibrationDataInterfaceROOT::m_aliases
std::map< std::string, std::string > m_aliases
Do not attempt to persistify (PROOF)
Definition: CalibrationDataInterfaceROOT.h:405
Analysis::CalibrationDataInterfaceROOT::retrieveCalibrationIndex
bool retrieveCalibrationIndex(const std::string &label, const std::string &OP, const std::string &author, bool isSF, unsigned int &index, unsigned int mapIndex=0)
Retrieve the index of the calibration object (container) starting from the label and operating point.
Definition: CalibrationDataInterfaceROOT.cxx:688
beamspotman.stat
stat
Definition: beamspotman.py:266
beamspotman.dir
string dir
Definition: beamspotman.py:623
Analysis::CalibrationDataInterfaceBase::setEffCalibrationNames
void setEffCalibrationNames(const std::map< std::string, std::vector< std::string > > &names)
Definition: CalibrationDataInterfaceBase.cxx:63
Analysis::CalibrationDataInterfaceROOT::m_filenameEff
std::string m_filenameEff
Definition: CalibrationDataInterfaceROOT.h:418
Analysis::CalibrationDataEigenVariations::listNamedVariations
std::vector< std::string > listNamedVariations() const
list the named variations
Definition: CalibrationDataEigenVariations.cxx:997
Analysis::CalibrationDataInterfaceROOT::m_coefficientMap
std::map< std::string, std::map< std::string, float > > m_coefficientMap
Definition: CalibrationDataInterfaceROOT.h:466
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
Analysis::CalibrationDataInterfaceROOT::increaseCounter
void increaseCounter(unsigned int index, OutOfBoundsType oob=Main)
Definition: CalibrationDataInterfaceROOT.cxx:1959
Analysis::Extrapolated
@ Extrapolated
Definition: CalibrationDataInterfaceROOT.h:85
Analysis::CalibrationStatus
CalibrationStatus
Definition: CalibrationDataVariables.h:56
python.TriggerEDMRun3.BTagVars
BTagVars
Definition: TriggerEDMRun3.py:150
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Analysis::Eta
@ Eta
Definition: CalibrationDataInterfaceROOT.h:85
Analysis::CalibrationDataContainer::kTagWeight
@ kTagWeight
Definition: CalibrationDataContainer.h:67
find_data.full
full
Definition: find_data.py:27
Analysis::CalibrationDataInterfaceROOT::m_useMCMCSF
bool m_useMCMCSF
specify whether or not to use MC/MC (hadronisation) scale factors (the fact that this is steerable is...
Definition: CalibrationDataInterfaceROOT.h:452
Analysis::CalibrationDataContainer::isNearlyEqual
static bool isNearlyEqual(double a, double b)
utility for comparison of doubles
Definition: CalibrationDataContainer.cxx:1744
python.PyAthena.v
v
Definition: PyAthena.py:154
DeMoScan.index
string index
Definition: DeMoScan.py:364
Analysis::CalibrationDataInterfaceROOT::checkAbsEta
bool checkAbsEta(const CalibrationDataVariables &variables, unsigned int index)
Definition: CalibrationDataInterfaceROOT.cxx:1919
Analysis::CalibrationDataInterfaceROOT::getInefficiency
CalibResult getInefficiency(const CalibrationDataVariables &variables, const std::string &label, const std::string &OP, Uncertainty unc, unsigned int numVariation=0, unsigned int mapIndex=0)
inefficiency retrieval by name
Definition: CalibrationDataInterfaceROOT.cxx:1307
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
Analysis::CalibrationDataInterfaceROOT::m_maxTagWeight
double m_maxTagWeight
Definition: CalibrationDataInterfaceROOT.h:489
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
trigbs_pickEvents.cnt
cnt
Definition: trigbs_pickEvents.py:71
ref
const boost::regex ref(r_ef)
Analysis::SFGlobalEigen
@ SFGlobalEigen
Definition: CalibrationDataInterfaceROOT.h:70
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
Analysis::CalibrationDataInterfaceROOT::m_objectIndices
std::map< std::string, unsigned int > m_objectIndices
Definition: CalibrationDataInterfaceROOT.h:411
Analysis::CalibrationDataInterfaceROOT::m_runEigenVectorMethod
bool m_runEigenVectorMethod
decide whether to run the eigenvector method or not
Definition: CalibrationDataInterfaceROOT.h:429
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:297
Analysis::CalibrationDataInterfaceBase::getContainername
std::string getContainername(const std::string &flavour, bool SF, unsigned int mapIndex=0) const
auxiliary function for retrieval of container name
Definition: CalibrationDataInterfaceBase.cxx:118
Analysis::CalibrationDataInterfaceROOT::getScaleFactor
CalibResult getScaleFactor(const CalibrationDataVariables &variables, const std::string &label, const std::string &OP, Uncertainty unc, unsigned int numVariation=0, unsigned int mapIndex=0)
efficiency scale factor retrieval by name.
Definition: CalibrationDataInterfaceROOT.cxx:736
CaloCondBlobAlgs_fillNoiseFromASCII.author
string author
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:26
Analysis::CalibrationDataInterfaceROOT::checkWeightScaleFactors
void checkWeightScaleFactors(unsigned int indexSF, unsigned int indexEff)
Definition: CalibrationDataInterfaceROOT.cxx:1763
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
Analysis::CalibrationDataInterfaceBase::setSFCalibrationNames
void setSFCalibrationNames(const std::map< std::string, std::string > &names)
Definition: CalibrationDataInterfaceBase.cxx:87
Analysis::Ignore
@ Ignore
Definition: CalibrationDataInterfaceROOT.h:82
MuonHough::extrapolate
float extrapolate(const MuonLayerHough::Maximum &ref, const MuonLayerHough::Maximum &ex, bool doparabolic=false)
Definition: MuonLayerHough.cxx:521
Analysis::CalibrationDataInterfaceROOT::getInefficiencyScaleFactor
CalibResult getInefficiencyScaleFactor(const CalibrationDataVariables &variables, const std::string &label, const std::string &OP, Uncertainty unc, unsigned int numVariation=0, unsigned int mapIndex=0)
"MC" inefficiency scale factor retrieval by name
Definition: CalibrationDataInterfaceROOT.cxx:1186
Analysis::CalibrationDataEigenVariations::getNumberOfNamedVariations
unsigned int getNumberOfNamedVariations() const
retrieve the number of named variations
Definition: CalibrationDataEigenVariations.cxx:988
dqt_zlumi_alleff_HIST.eff
int eff
Definition: dqt_zlumi_alleff_HIST.py:113
Analysis::CalibrationDataContainer::kPt
@ kPt
Definition: CalibrationDataContainer.h:64
merge.status
status
Definition: merge.py:17
Analysis::CalibrationDataEigenVariations::getNamedVariation
bool getNamedVariation(const std::string &name, TH1 *&up, TH1 *&down)
obtain the "up" and "down" variations for the named uncertainty.
Definition: CalibrationDataEigenVariations.cxx:1043
Analysis::CalibrationDataInterfaceROOT::m_fileSF
TFile * m_fileSF
Do not attempt to persistify (PROOF)
Definition: CalibrationDataInterfaceROOT.h:401
Analysis::CalibrationDataInterfaceBase::kPt
@ kPt
Definition: CalibrationDataInterfaceBase.h:67
Analysis::Systematic
@ Systematic
Definition: CalibrationDataInterfaceROOT.h:70
Analysis::Flag
@ Flag
Definition: CalibrationDataInterfaceROOT.h:82
Analysis::Extrapolation
@ Extrapolation
Definition: CalibrationDataInterfaceROOT.h:70
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
Analysis::CalibrationDataInterfaceROOT::getAlias
std::string getAlias(const std::string &author) const
associated alias retrieval method
Definition: CalibrationDataInterfaceROOT.cxx:2710
Analysis::CalibrationDataInterfaceROOT::m_objects
std::vector< CalibrationDataContainer * > m_objects
cache the objects themselves (so that the user will not have to delete them after each call etc....
Definition: CalibrationDataInterfaceROOT.h:410
Analysis::CalibrationDataInterfaceROOT::m_extrapolatedCounters
std::vector< unsigned int > m_extrapolatedCounters
Definition: CalibrationDataInterfaceROOT.h:482
Analysis::CalibrationDataContainer::getStatUncertainty
virtual CalibrationStatus getStatUncertainty(const CalibrationDataVariables &x, double &result)=0
retrieve the calibration statistical uncertainty.
Analysis::CalibZERO
const double CalibZERO
Definition: CalibrationDataInterfaceBase.h:32
Analysis::CalibrationDataInterfaceROOT::m_mainCounters
std::vector< unsigned int > m_mainCounters
Definition: CalibrationDataInterfaceROOT.h:481
Analysis::CalibrationDataInterfaceROOT::m_fileEff
TFile * m_fileEff
pointer to the TFile object providing access to the calibrations
Definition: CalibrationDataInterfaceROOT.h:400
Analysis::CalibrationDataInterfaceBase::getBasename
std::string getBasename(const std::string &name) const
auxiliary function for retrieval of name within the directory
Definition: CalibrationDataInterfaceBase.cxx:138