264#include <boost/algorithm/string.hpp>
269#include "TObjString.h"
294 m_runEigenVectorMethod(false), m_EVStrategy(
SFEigen), m_useRecommendedEVExclusions(false), m_verbose(true),
295 m_absEtaStrategy(GiveUp), m_otherStrategy(Flag)
303 m_taggerName = taggerName;
306 env.ReadFile(configname.c_str(),kEnvGlobal);
310 TString filename = env.GetValue(
"File",
"BTaggingPerformanceCalibrations.root");
311 m_filenameEff =
string(env.GetValue(
"FileEff",
""));
trim(m_filenameEff);
312 m_filenameSF = string(env.GetValue(
"FileSF",
""));
trim(m_filenameSF);
313 if (m_filenameEff ==
"") {
314 m_filenameEff = pathname + filename.Data();
316 if (m_filenameSF ==
"") {
317 m_filenameSF = pathname + filename.Data();
321 cout <<
"=== CalibrationDataInterfaceROOT::CalibrationDataInterfaceROOT ===" << endl;
322 cout <<
" Config name : " << configname << endl;
323 cout <<
" taggerName : " << taggerName << endl;
324 cout <<
" Efficiency file name : " << m_filenameEff << endl
325 <<
" SF file name : " << m_filenameSF << endl;
328 m_fileEff = TFile::Open(m_filenameEff.c_str(),
"READ");
329 if (m_filenameEff == m_filenameSF)
330 m_fileSF = m_fileEff;
332 m_fileSF = TFile::Open(m_filenameSF.c_str(),
"READ");
336 m_fileSF->GetObject(
"VersionInfo/BuildNumber", s);
337 if (s) cout <<
" CDI file build number: " << s->GetName() << endl;
341 m_flavours = {
"B",
"C",
"T",
"Light" };
342 string testPrefix(taggerName); testPrefix +=
".";
347 string::size_type end;
350 std::map<string, std::vector<string> > effNames;
351 for (
auto const& flavour : m_flavours) {
352 string test(testPrefix); test +=
"EfficiencyCalibration"; test += flavour; test +=
"Name";
353 effNames[flavour] =
split(
string(env.GetValue(test.c_str(),
"default")));
355 setEffCalibrationNames(effNames);
358 std::map<string, string> SFNames;
359 for (
auto const& flavour : m_flavours) {
360 string test(testPrefix); test +=
"ScaleFactorCalibration"; test += flavour; test +=
"Name";
361 SFNames[flavour] = string(env.GetValue(test.c_str(),
"default"));
trim(SFNames[flavour]);
363 setSFCalibrationNames(SFNames);
369 string AL(env.GetValue(
"aliases",
""));
373 string alias = AL.substr(0, end);
377 string::size_type arrow = alias.find(
"->");
378 if (arrow == string::npos)
continue;
379 string target = alias.substr(0,arrow);
trim(target);
380 m_aliases[target] = alias.substr(arrow+2);
trim(m_aliases[target]);
381 if (end != string::npos) AL = AL.substr(end+1);
382 }
while (end != string::npos);
386 string test=
"runEigenVectorMethod";
387 m_runEigenVectorMethod=(bool)env.GetValue(test.c_str(),0);
389 if (m_runEigenVectorMethod) {
394 test =
"excludeFromCovMatrix";
395 std::vector<std::string> to_exclude =
split(env.GetValue(test.c_str(),
""));
397 for (
auto const& flavour : m_flavours) {
398 m_excludeFromCovMatrix[flavour] = to_exclude;
400 for (
auto const& flavour : m_flavours) {
401 test =
"excludeFrom"; test += flavour; test +=
"CovMatrix";
402 to_exclude =
split(env.GetValue(test.c_str(),
""));
404 m_excludeFromCovMatrix[flavour].insert(m_excludeFromCovMatrix[flavour].end(), to_exclude.begin(), to_exclude.end());
407 unsigned int n_excluded = 0;
408 for (
auto const& flavour : m_flavours) {
409 n_excluded += m_excludeFromCovMatrix[flavour].size();
412 cout <<
" List of uncertainties to exclude:";
413 if (n_excluded == 0) cout <<
" none";
414 for (
auto const& flavour : m_flavours) {
415 if (m_excludeFromCovMatrix[flavour].size() > 0) {
416 cout <<
"\n\t" << flavour <<
":\t";
417 for (
unsigned int i = 0; i < m_excludeFromCovMatrix[flavour].size(); ++i) {
418 cout << m_excludeFromCovMatrix[flavour].at(i);
419 if (i+1 == m_excludeFromCovMatrix[flavour].size()) cout <<
"; ";
429 m_useRecommendedEVExclusions = (bool) env.GetValue(
"ExcludeRecommendedFromEigenVectorTreatment",
false);
432 std::map<string, EVReductionStrategy> mappings;
433 mappings[
"Loose"] = Loose;
434 mappings[
"Medium"] = Medium;
435 mappings[
"Tight"] = Tight;
436 for (
auto const& flavour : m_flavours) {
437 test = testPrefix; test +=
"EigenvectorReduction"; test += flavour;
438 std::string reduction = string(env.GetValue(test.c_str(),
"Loose"));
trim(reduction);
439 m_EVReductions[flavour] = mappings.find(reduction) == mappings.end() ? mappings[
"Loose"] : mappings.find(reduction)->second;
444 m_maxAbsEta = env.GetValue(
"MaxAbsEta", 2.5);
445 if (m_maxAbsEta < 0) m_maxAbsEta = 2.5;
448 string strategy = string(env.GetValue(
"OutOfBoundsEta",
"GiveUp"));
trim(strategy);
449 if (strategy ==
"GiveUp") m_absEtaStrategy = GiveUp;
450 else if (strategy ==
"Flag") m_absEtaStrategy = Flag;
451 else if (strategy ==
"Ignore") m_absEtaStrategy = Ignore;
453 cerr <<
"unknown |eta| extrapolation strategy: " << strategy <<
", setting to GiveUp" << endl;
454 m_absEtaStrategy = GiveUp;
458 strategy = string(env.GetValue(
"OutOfBoundsOther",
"Flag"));
trim(strategy);
459 if (strategy ==
"GiveUp") m_otherStrategy = GiveUp;
460 else if (strategy ==
"GiveUpExtrapolated") m_otherStrategy = GiveUpExtrapolated;
461 else if (strategy ==
"Flag") m_otherStrategy = Flag;
462 else if (strategy ==
"Ignore") m_otherStrategy = Ignore;
464 cerr <<
"unknown general extrapolation strategy: " << strategy <<
", setting to Flag" << endl;
465 m_otherStrategy = Flag;
469 m_maxTagWeight = env.GetValue(
"MaxTagWeight", 10.0);
472 m_useMCMCSF = (bool) env.GetValue(
"useMCMCSF", 1);
474 m_useTopologyRescaling = (bool) env.GetValue(
"useTopologySF", 0);
476 if (m_verbose) cout <<
"======= end of CalibrationDataInterfaceROOT instantiation ========" << endl;
482 const char* fileSF,
const char* fileEff,
483 const std::vector<std::string>& jetAliases,
484 const std::map<std::string, std::string>& SFNames,
485 const std::map<std::string, std::vector<std::string> >& EffNames,
486 const std::map<std::string, std::vector<std::string> >& excludeFromEV,
487 const std::map<std::string, EVReductionStrategy>& EVReductions,
488 bool useEV,
Uncertainty strat,
bool useMCMCSF,
bool useTopologyRescaling,
489 bool useRecommendedEEVExclusions,
bool verbose,
490 std::vector<std::string> flavours) :
529 cout <<
"=== CalibrationDataInterfaceROOT::CalibrationDataInterfaceROOT ===" << endl;
530 cout <<
" taggerName : " << taggerName.c_str() << endl;
531 cout <<
" Systematic strategy : ";
533 cout <<
"SFEigen" << endl;
534 }
else if (
m_EVStrategy == Analysis::Uncertainty::SFGlobalEigen){
535 cout <<
"SFGlobalEigen" << endl;
537 cout <<
" Other" << endl;
539 if (fileEff) cout <<
" Efficiency file name : " << fileEff << endl;
540 cout <<
" SF file name : " << fileSF << endl
546 m_fileSF = TFile::Open(fileSF,
"READ");
547 if (fileEff && strcmp(fileSF, fileEff) != 0) {
549 m_fileEff = TFile::Open(fileEff,
"READ");
555 m_fileSF->GetObject(
"VersionInfo/BuildNumber", s);
556 if (s) cout <<
" CDI file build number: " << s->GetName() << endl;
560 for (
unsigned int i = 0; i < jetAliases.size(); ++i) {
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);
577 unsigned int n_excluded = 0;
582 cout <<
" List of uncertainties to exclude:";
583 if (n_excluded == 0) cout <<
" none";
586 cout <<
"\n\t" << flavour <<
":\t";
599 if (
m_verbose) cout <<
"======= end of CalibrationDataInterfaceROOT instantiation ========" << endl;
648 for (std::vector<CalibrationDataContainer*>::iterator it =
m_objects.begin(); it !=
m_objects.end(); ++it) {
654 for (std::map<std::string, HadronisationReferenceHelper*>::iterator it =
m_refMap.begin();
657 {
delete it->second; it->second=
nullptr; }
663 cout <<
"\t\tCalibrationDataInterfaceROOT |eta| out-of-bounds summary:" << endl;
669 if (!found) cout <<
"\t\t\tNo issues found" << endl;
673 cout <<
"\t\tCalibrationDataInterfaceROOT object out-of-bounds summary:" << endl;
682 if (!found) cout <<
"\t\t\tNo issues found" << endl;
689 const std::string& OP,
690 const std::string& author,
691 bool isSF,
unsigned int&
index,
692 unsigned int mapIndex)
716 std::map<string, unsigned int>::const_iterator it =
m_objectIndices.find(name);
720 string flavour = (
label ==
"N/A") ?
"Light" :
label;
722 if (
m_verbose) std::cout <<
"CalibrationDataInterfaceROOT->retrieveCalibrationIndex : container name is " << cntname << std::endl;
727 if (
m_verbose) std::cout <<
"CalibrationDataInterfaceROOT->retrieveCalibrationIndex : container " << name <<
" already cached! " << std::endl;
737 const string&
label,
const string& OP,
739 unsigned int mapIndex)
753 unsigned int indexEff, 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;
768 unsigned int indexSF,
unsigned int indexEff,
769 Uncertainty unc,
const std::string& flavour,
unsigned int numVariation)
789 unsigned int indexSF,
unsigned int indexEff,
806 cerr <<
"getScaleFactor: error retrieving container!" << endl;
813 cerr <<
"Jet |eta| is outside of the boundary!" << endl;
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;
828 std::shared_ptr<CalibrationDataEigenVariations> eigenVariation;
831 }
catch (
const std::out_of_range&) {
832 cerr <<
" Could not retrieve eigenvector variation, while it should have been there." << endl;
837 bool extrapolate =
false;
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;
844 bool isOK = eigenVariation->getEigenvectorVariation(numVariation,up,down);
846 cerr <<
"Eigenvector object is there but cannot retrieve up and down uncertainty histograms." << endl;
850 extrapolate = (unc ==
SFNamed) ? eigenVariation->isExtrapolationVariation(numVariation) :
false;
853 std::shared_ptr<CalibrationDataGlobalEigenVariations>
GEV = std::dynamic_pointer_cast<CalibrationDataGlobalEigenVariations>(eigenVariation);
855 cerr <<
"Analysis::CalibrationDataInterfaceROOT::getScaleFactor: dynamic cast failed\n";
858 unsigned int maxVariations =
GEV->getNumberOfEigenVariations(flavour);
859 if (numVariation > maxVariations-1) {
860 cerr <<
"Asked for global eigenvariation number: " << numVariation <<
" but overall number of available variations is: " << maxVariations << endl;
863 bool isOK =
GEV->getEigenvectorVariation(flavour, numVariation,up,down);
865 cerr <<
"Eigenvector object is there but cannot retrieve up and down uncertainty histograms." << endl;
869 extrapolate =
GEV->isExtrapolationVariation(numVariation, flavour);
871 std::cerr <<
"ERROR: you requested " << unc <<
" but that isn't in the set of (SFEigen, SFGlobalEigen, SFNamed) for eigenvariations. " << std::endl;
893 result.first = MCMCSF*valueUp;
894 result.second = MCMCSF*valueDown;
910 cerr <<
"getScaleFactor: error retrieving result in non-EV context!" << endl;
929 cerr <<
"getScaleFactor: error retrieving Scale factor parameter covariance matrix!" << endl;
937 cerr <<
"getScaleFactor: error retrieving Scale factor parameter systematic uncertainty!" << endl;
943 cerr <<
"getScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
948 cerr <<
"getScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
952 result.first = MCMCSF*value;
953 result.second = MCMCSF*uncertainty;
964 const string&
label,
const string& OP,
979 cerr <<
"getMCEfficiency: unable to find Eff calibration for object " <<
fullName(variables.jetAuthor, OP,
label,
false, mapIndex) << endl;
1027 cerr <<
"Jet |eta| is outside of the boundary!" << endl;
1046 cerr <<
"getMCEfficiency: error retrieving MC efficiency parameter covariance matrix!" << endl;
1060 double uncertainty = stat;
1061 result.first = std::max(0., std::min(1., value));
1062 result.second = uncertainty;
1072 const string&
label,
1073 const string& OP,
Uncertainty unc,
const std::string& flavour,
1074 unsigned int numVariation,
unsigned int mapIndex)
1089 unsigned int indexSF, indexEff;
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;
1104 unsigned int indexSF,
unsigned int indexEff,
1105 Uncertainty unc,
const std::string& flavour,
unsigned int numVariation)
1127 unsigned int indexSF,
unsigned int indexEff,
1149 double relative = 0;
1150 double value = effResult.first;
1152 value = std::min(effResult.first*sfResult.first, 1.);
1157 double valueDown = effResult.first*sfResult.second;
1159 result.second = valueDown;
1163 relative = effResult.second/effResult.first;
1164 double sfRelative = sfResult.second/sfResult.first;
1169 relative = TMath::Sqrt(sfRelative*sfRelative + relative*relative);
1173 cerr <<
"ERROR: CalibrationDataInterfaceROOT::getEfficiency: SF null result, SF=" << sfResult.first <<
" MC eff=" << effResult.first <<
"; setting SF=1." << endl;
1178 result.second = value*relative;
1187 const string&
label,
1189 unsigned int numVariation,
unsigned int mapIndex)
1205 unsigned int indexSF, indexEff;
1208 cerr <<
"getInefficiencyScaleFactor: unable to find Eff calibration for object "
1209 <<
fullName(variables.jetAuthor, OP,
label,
false, mapIndex)
1210 <<
" or SF calibration for object "
1224 unsigned int indexSF,
unsigned int indexEff,
1225 Uncertainty unc,
const std::string& flavour,
unsigned int numVariation)
1248 unsigned int indexSF,
unsigned int indexEff,
1272 double eff = std::min(effResult.first, 1.);
1274 double sf = sfResult.first;
1275 double sferr = sfResult.second;
1281 val = std::max((1. - eff*sf),
CalibZERO) / (1. - eff);
1285 double valDown = std::max((1. - eff*sferr),
CalibZERO) / (1. - eff);
1293 err =
pow(eff*sferr, 2);
1295 err = 1./(1. - eff) * TMath::Sqrt(err);
1308 const string&
label,
1310 unsigned int numVariation,
unsigned int mapIndex)
1326 unsigned int indexSF, indexEff;
1329 cerr <<
"getInefficiency: unable to find Eff calibration for object "
1330 <<
fullName(variables.jetAuthor, OP,
label,
false, mapIndex)
1331 <<
" or SF calibration for object "
1345 unsigned int indexSF,
unsigned int indexEff,
1346 Uncertainty unc,
const std::string& flavour,
unsigned int numVariation)
1369 unsigned int indexSF,
unsigned int indexEff,
1393 double val = std::max(0., 1. - effResult.first * sfResult.first);
1397 if (effResult.first <= 0. || sfResult.first <= 0.)
return Analysis::kError;
1402 double valDown = std::max(0., 1. - effResult.first*sfResult.second);
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);
1412 result.first = std::max(0., std::min(1., val));
1423 const string&
label,
const string& OP,
1440 return std::make_pair(std::max(0., 1. - effResult.first), effResult.second);
1460 return std::make_pair(std::max(0., 1. - effResult.first), effResult.second);
1466 unsigned indexSF,
unsigned int indexEff)
const
1475 if (indexSFRef < 0 || indexEffRef < 0 || indexSFRef == indexEffRef)
return 1;
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;
1487 unsigned int numVariation,
unsigned int mapIndex)
1505 static const string cont(
"Continuous");
1507 unsigned int indexSF, indexEff;
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;
1524 unsigned int indexSF,
unsigned int indexEff,
1551 unsigned int indexSF,
unsigned int indexEff,
1583 cerr <<
"Jet |eta| is outside of the boundary!" << endl;
1604 double fracMCref = refMCResult.first;
1607 double fracSFref = fracMCref, fracEffref = fracMCref;
1610 if (indexSFref < 0 || indexEffref < 0) {
1611 cerr <<
"getWeightScaleFactor: error: generator-specific corrections requested but necessary reference containers lacking " << endl;
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;
1632 cerr <<
"getWeightScaleFactor: error: null fracMCnew would lead to invalid operation" << endl;
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;
1642 std::shared_ptr<CalibrationDataEigenVariations> eigenVariation;
1645 }
catch (
const std::out_of_range&) {
1646 cerr <<
"getWeightScaleFactor: could not retrieve eigenvector variation, while it should have been there." << endl;
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;
1656 bool isOK = (unc ==
SFEigen) ? eigenVariation->getEigenvectorVariation(numVariation,up,down) : eigenVariation->getNamedVariation(numVariation,up,down);
1658 cerr <<
"getWeightScaleFactor: Eigenvector object is there but cannot retrieve up and down uncertainty histograms." << endl;
1662 bool extrapolate = ( unc ==
SFNamed ) ? eigenVariation->isExtrapolationVariation(numVariation) :
false;
1671 double variationUp = valueUp - value;
1672 double variationDown = valueDown - value;
1676 if (
m_useMCMCSF) value *= (fracSFref / fracEffref);
1681 double f = (fracMCref / fracMCnew);
1685 double f = (fracSFref / fracEffref);
1689 valueUp = value + variationUp;
1690 valueDown = value + variationDown;
1696 if (valueDown < 0) {
1703 result.second = valueDown;
1713 cerr <<
"getWeightScaleFactor: error retrieving Scale factor parameter covariance matrix!" << endl;
1720 cerr <<
"getWeightScaleFactor: error retrieving Scale factor parameter systematic uncertainty!" << endl;
1726 cerr <<
"getWeightScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
1731 cerr <<
"getWeightScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
1740 if (
m_useMCMCSF) value *= (fracSFref / fracEffref);
1750 uncertainty *= (fracMCref / fracMCnew);
1752 uncertainty *= (fracSFref / fracEffref);
1755 result.first = std::max(0., value);
1756 result.second = uncertainty;
1764 unsigned int indexEff)
1780 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: error: container for object " <<
nameFromIndex(indexSF) <<
" not found!" << endl;
1782 }
else if (!
container->GetValue(
"MCreference")) {
1783 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: error: no MCreference histogram for object " <<
nameFromIndex(indexSF) <<
"!" << endl;
1787 if (! effContainer) {
1788 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: error: container for object " <<
nameFromIndex(indexEff) <<
" not found!" << endl;
1793 std::vector<unsigned int> vars =
container->getVariableTypes();
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)
1814 if (v[0] < 0 && vEff[0] >= 0) {
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) {
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));
1828 for (
unsigned int t = 0; t < vars.size(); ++t) {
1829 if (effBoundaries.find(vars[t]) == effBoundaries.end())
1831 mergedBoundaries[vars[t]] = boundaries[vars[t]];
1835 mergedBoundaries[vars[t]] = effBoundaries[vars[t]];
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();
1841 while (itcmp != mergedBoundaries[vars[t]].end() &&
1843 *itcmp < *it) ++itcmp;
1848 mergedBoundaries[vars[t]].insert(itcmp, *it);
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]];
1860 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: " <<
"no tag weight axis found for object " <<
nameFromIndex(indexSF) << endl;
1862 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: " <<
"no tag weight axis found for object " <<
nameFromIndex(indexEff) << endl;
1864 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: " <<
"different tag weight binning for objects " <<
nameFromIndex(indexSF) <<
" (";
1866 for (
unsigned int ib = 0; ib < v.size()-1; ++ib) cerr << v[ib] <<
",";
1867 cerr << v[v.size()-1] <<
") and " <<
nameFromIndex(indexEff) <<
" (";
1869 for (
unsigned int ib = 0; ib < v.size()-1; ++ib) cerr << v[ib] <<
",";
1870 cerr << v[v.size()-1] <<
") do not match!" << endl;
1880 cout <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: cross-checking scale factors for objects " <<
nameFromIndex(indexSF) <<
" and " <<
nameFromIndex(indexEff) <<
"\n" << std::setfill(
'-') << std::setw(100) <<
"-" << endl;
1881 cout << std::setfill(
' ');
1885 for (
unsigned int ipt = 0; ipt < vPt.size()-1; ++ipt) {
1886 x.jetPt = (vPt[ipt] + vPt[ipt+1]) * 500.;
1887 for (
unsigned int ieta = 0; ieta < vEta.size()-1; ++ieta) {
1888 x.jetEta = (vEta[ieta] + vEta[ieta+1]) / 2.;
1889 for (
unsigned int iwt = 0; iwt < vTagWeight.size()-1; ++iwt) {
1890 x.jetTagWeight = (vTagWeight[iwt] + vTagWeight[iwt+1]) / 2.;
1895 container->getUncertainty(
"MCreference",
x, uncertaintyResult);
1896 double fracMCref = uncertaintyResult.first;
1900 if (!(fracMCnew > 0.)) {
1901 cout <<
"\tfor (pt=" <<
x.jetPt <<
",eta=" <<
x.jetEta <<
",tagweight=" <<
x.jetTagWeight <<
"): invalid new MC fraction: " << fracMCnew << endl;
1903 double newvalue = 1.0 + (value - 1.0) * fracMCref/fracMCnew;
1904 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;
1946 for (std::map<std::string, unsigned int>::const_iterator it =
m_objectIndices.begin();
1948 if (it->second ==
index)
return it->first;
1966 unsigned int minsize = (
index == 0) ? 2 : 2*
index;
1985 const string&
label,
2003 cerr <<
"listScaleFactorUncertainties: unable to find SF calibration for object " <<
fullName(author, OP,
label,
true) << endl;
2004 std::vector<string> dummy;
2013 const std::string& flavour,
bool named)
2026 std::vector<string> dummy;
2035 std::vector<string> unordered = eigenVariation->listNamedVariations();
2036 std::vector<string> ordered(unordered.size());
2037 for (
unsigned int i = 0; i < unordered.size(); ++i) {
2038 ordered[eigenVariation->getNamedVariationIndex(unordered[i])] = unordered[i];
2041 }
else if (
m_EVStrategy == Analysis::Uncertainty::SFGlobalEigen){
2043 std::shared_ptr<CalibrationDataGlobalEigenVariations>
GEV = std::dynamic_pointer_cast<CalibrationDataGlobalEigenVariations>(eigenVariation);
2044 std::vector<std::string> unordered =
GEV->listNamedVariations(flavour);
2045 std::vector<std::string> ordered(unordered.size());
2046 for (
unsigned int i = 0; i < unordered.size(); ++i) {
2047 ordered[
GEV->getNamedVariationIndex(unordered[i], flavour)] = unordered[i];
2061 const std::string&
label,
2062 const std::string& OP,
2097 std::shared_ptr<CalibrationDataGlobalEigenVariations>
GEV = std::dynamic_pointer_cast<CalibrationDataGlobalEigenVariations>(eigenVariation);
2098 return GEV->getNumberOfEigenVariations(flavour);
2100 return (unc ==
SFEigen) ? eigenVariation->getNumberOfEigenVariations() : eigenVariation->getNumberOfNamedVariations();
2106 const std::string&
label,
2107 const std::string& OP)
2118 cerr <<
"getBinnedScaleFactors: unable to find SF calibration for object " <<
fullName(author, OP,
label,
true) << endl;
2128 const std::string&
label,
2129 const std::string& OP,
2130 unsigned int mapIndex)
2143 cerr <<
"getMCEfficiencyObject: unable to find efficiency calibration for object "
2156 const std::string&
label,
2157 const std::string& OP,
2158 const std::string& unc,
2172 if (unc ==
"comment" || unc ==
"result" || unc ==
"combined" || unc ==
"statistics")
return 0;
2177 cerr <<
"getShiftedScaleFactors: unable to find SF calibration for object " <<
fullName(author, OP,
label,
true) << endl;
2184 TH1* hunc =
dynamic_cast<TH1*
>(
container->GetValue(unc.c_str()));
2186 if ((! hunc) || (!
result))
return nullptr;
2187 if (hunc->GetDimension() !=
result->GetDimension() || hunc->GetNbinsX() !=
result->GetNbinsX() ||
2188 hunc->GetNbinsX() !=
result->GetNbinsX() || hunc->GetNbinsX() !=
result->GetNbinsX())
2193 if (!
container->isBinCorrelated(unc))
return 0;
2196 std::string name(
container->GetName()); name +=
"_"; name += unc; name +=
"_";
2197 TH1* shifted =
dynamic_cast<TH1*
>(
result->Clone(name.c_str()));
2198 if (not shifted)
return nullptr;
2199 shifted->Add(hunc, sigmas);
2205 const std::string&
label,
2206 const std::string& OP,
2207 unsigned int mapIndex){
2218 cerr <<
"runEigenVectorRecomposition: Recomposition need to be ran with CalibrationDataInterfaceRoot initialized in eigenvector mode" << endl;
2222 unsigned int indexSF;
2224 cerr <<
"runEigenVectorRecomposition: unable to find SF calibration for object "
2234 unsigned int indexSF){
2242 cerr <<
"runEigenVectorRecomposition: error retrieving container!" << endl;
2247 std::shared_ptr<CalibrationDataEigenVariations> eigenVariation;
2250 }
catch (
const std::out_of_range&) {
2251 cerr <<
"runEigenVectorRecomposition: Could not retrieve eigenvector variation, while it should have been there." << endl;
2255 std::map<std::string, std::map<std::string, float>> coefficientMap;
2256 if(!eigenVariation->EigenVectorRecomposition(
label, coefficientMap))
2263std::map<std::string, std::map<std::string, float>>
2266 cerr <<
"getCoefficientMap: Call runEigenVectorRecomposition() before retrieving coefficient map! " <<endl;
2275 TMatrixDSym getStatCovarianceMatrix(
const TH1* hist) {
2276 Int_t nbinx = hist->GetNbinsX()+2, nbiny = hist->GetNbinsY()+2, nbinz = hist->GetNbinsZ()+2;
2278 if (hist->GetDimension() > 1) rows *= nbiny;
2279 if (hist->GetDimension() > 2) rows *= nbinz;
2280 TMatrixDSym stat(rows);
2281 for (Int_t binx = 1; binx < nbinx; ++binx){
2282 for (Int_t biny = 1; biny < nbiny; ++biny){
2283 for (Int_t binz = 1; binz < nbinz; ++binz) {
2284 Int_t
bin = hist->GetBin(binx, biny, binz);
2285 double err = hist->GetBinError(
bin);
2286 stat(
bin,
bin) = err*err;
2296 TMatrixDSym getSystCovarianceMatrix(
const TH1*
ref,
const TH1* unc,
bool doCorrelated,
const std::string& uncname,
int tagWeightAxis) {
2297 Int_t nbinx =
ref->GetNbinsX()+2, nbiny =
ref->GetNbinsY()+2, nbinz =
ref->GetNbinsZ()+2;
2299 if (
ref->GetDimension() > 1)
rows *= nbiny;
2300 if (
ref->GetDimension() > 2)
rows *= nbinz;
2301 TMatrixDSym
cov(rows);
2303 for(
int i=0 ;
i<10 ;
i++){
2304 Int_t
bin = unc->GetBin(1,i,1);
2305 double uncval = unc->GetBinContent(bin);
2306 cout << uncval <<
", ";
2310 if (unc->GetNbinsX()+2 != nbinx || unc->GetNbinsY()+2 != nbiny || unc->GetNbinsZ()+2 != nbinz || unc->GetDimension() !=
ref->GetDimension()) {
2311 std::cout <<
"getSystCovarianceMatrix: inconsistency found in histograms " <<
ref->GetName() <<
" and " << unc->GetName() <<
" : " << uncname << std::endl;
2322 if (! doCorrelated) {
2323 if (tagWeightAxis < 0) {
2325 for (Int_t binx = 1; binx < nbinx-1; ++binx){
2326 for (Int_t biny = 1; biny < nbiny-1; ++biny){
2327 for (Int_t binz = 1; binz < nbinz-1; ++binz) {
2328 Int_t
bin =
ref->GetBin(binx, biny, binz);
2329 double err = unc->GetBinContent(bin);
2335 }
else if (tagWeightAxis == 0) {
2337 for (Int_t biny = 1; biny < nbiny-1; ++biny){
2338 for (Int_t binz = 1; binz < nbinz-1; ++binz){
2339 for (Int_t binx = 1; binx < nbinx-1; ++binx) {
2340 Int_t
bin =
ref->GetBin(binx, biny, binz);
2341 double err = unc->GetBinContent(bin);
2342 for (Int_t binx2 = 1; binx2 < nbinx-1; ++binx2) {
2343 Int_t
bin2 =
ref->GetBin(binx2, biny, binz);
2344 double err2 = unc->GetBinContent(bin2);
2345 cov(bin,bin2) =
err*err2;
2351 }
else if (tagWeightAxis == 1) {
2353 for (Int_t binx = 1; binx < nbinx-1; ++binx){
2354 for (Int_t binz = 1; binz < nbinz-1; ++binz){
2355 for (Int_t biny = 1; biny < nbiny-1; ++biny) {
2356 Int_t
bin =
ref->GetBin(binx, biny, binz);
2357 double err = unc->GetBinContent(bin);
2358 for (Int_t biny2 = 1; biny2 < nbiny-1; ++biny2) {
2359 Int_t
bin2 =
ref->GetBin(binx, biny2, binz);
2360 double err2 = unc->GetBinContent(bin2);
2361 cov(bin,bin2) =
err*err2;
2367 }
else if (tagWeightAxis == 2) {
2369 for (Int_t binx = 1; binx < nbinx-1; ++binx){
2370 for (Int_t biny = 1; biny < nbiny-1; ++biny){
2371 for (Int_t binz = 1; binz < nbinz-1; ++binz) {
2372 Int_t
bin =
ref->GetBin(binx, biny, binz);
2373 double err = unc->GetBinContent(bin);
2374 for (Int_t binz2 = 1; binz2 < nbinz-1; ++binz2) {
2375 Int_t
bin2 =
ref->GetBin(binx, biny, binz2);
2376 double err2 = unc->GetBinContent(bin2);
2377 cov(bin,bin2) =
err*err2;
2386 for (Int_t binx = 1; binx < nbinx-1; ++binx){
2387 for (Int_t biny = 1; biny < nbiny-1; ++biny){
2388 for (Int_t binz = 1; binz < nbinz-1; ++binz) {
2389 Int_t
bin =
ref->GetBin(binx, biny, binz);
2390 double err = unc->GetBinContent(bin);
2391 for (Int_t binx2 = 1; binx2 < nbinx-1; ++binx2){
2392 for (Int_t biny2 = 1; biny2 < nbiny-1; ++biny2){
2393 for (Int_t binz2 = 1; binz2 < nbinz-1; ++binz2) {
2394 Int_t
bin2 =
ref->GetBin(binx2, biny2, binz2);
2395 double err2 = unc->GetBinContent(bin2);
2396 cov(bin, bin2) =
err*err2;
2413 const std::string&
label,
2414 const std::string& OP,
2415 const std::string& unc)
2427 if (unc ==
"comment" || unc ==
"result" || unc ==
"combined")
return dummy;
2432 cerr <<
"getScaleFactorCovarianceMatrix: unable to find SF calibration for object " <<
fullName(author, OP,
label,
true) << endl;
2440 if (!
result)
return dummy;
2443 if (unc ==
"statistics") {
2444 return getStatCovarianceMatrix(
result);
2446 TH1* hunc =
dynamic_cast<TH1*
>(
container->GetValue(unc.c_str()));
2448 cout <<
"getScaleFactorCovarianceMatrix: no uncertainty object found "
2449 <<
"corresponding to name " << unc << endl;
2459 TMatrixDSym cov = getStatCovarianceMatrix(
result);
2462 std::vector<string> uncs =
container->listUncertainties();
2463 for (
unsigned int t = 0; t < uncs.size(); ++t) {
2464 if (uncs[t] ==
"comment" || uncs[t] ==
"result" || uncs[t] ==
"combined" ||
2465 uncs[t] ==
"statistics" || uncs[t]==
"extrapolation" || uncs[t]==
"MChadronisation" ||
2466 uncs[t]==
"ReducedSets" || uncs[t]==
"systematics")
continue;
2467 TH1* hunc =
dynamic_cast<TH1*
>(
container->GetValue(uncs[t].c_str()));
2469 std::cerr<<
"Analysis::CalibrationDataInterfaceROOT::getScaleFactorCovarianceMatrix : dynamic cast failed\n";
2472 TMatrixDSym syst_cov = getSystCovarianceMatrix(
result, hunc,
container->isBinCorrelated(uncs[t]), uncs[t],
container->getTagWeightAxis());
2487 cerr <<
"initialize can only be called once per CalibrationDataInterfaceROOT object" << endl;
2490 cout <<
"initializing BTagCalibrationDataInterfaceROOT for PROOF with jetAuthor = " << jetauthor <<
", tagger = " <<
m_taggerName <<
", operating point = " << OP <<
", uncertainty = " << unc << endl;
2494 BTagVars.jetAuthor = jetauthor;
2495 BTagVars.jetPt = 100000.;
2496 BTagVars.jetEta = 1.5;
2499 std::pair<double, double> BTagCalibResult;
2501 std::cout <<
"CalibrationDataInterfaceROOT->initialize : BTagCalibResult " << std::endl;
2503 std::pair<double, double> BTagCalibMCEff;
2505 std::cout <<
"CalibrationDataInterfaceROOT->initialize : BTagCalibMCEff " << std::endl;
2536 string name = dir +
"/" + cntname;
2553 cerr <<
"btag Calib: retrieveContainer: failed to retrieve container named " << name.c_str() <<
" from file" << endl;
2559 cout <<
"CalibrationDataInterface: retrieved container " << name <<
" (with comment: '" << cnt->getComment() <<
"' and hadronisation setting '" << cnt->getHadronisation() <<
"')" << endl;
2586 string spec = cnt->getHadronisation();
2588 std::map<string, HadronisationReferenceHelper*>::const_iterator mapit =
m_refMap.find(dir);
2591 if (mapit->second->getReference(spec,
ref)) {
2597 string refname(dir +
"/" +
ref);
2598 std::map<string, unsigned int>::const_iterator it =
m_objectIndices.find(refname);
2607 cerr <<
"btag Calib: retrieveContainer: MC hadronisation reference map not found -- this should not happen!" << endl;
2614 cerr <<
"btag Calib: retrieveContainer: warning: unable to apply MC/MC scale factors for container " << name <<
" with hadronisation reference = '" << spec <<
"'" << endl;
2628 if (histoContainer==0) {
2629 cerr <<
"Could not cast Container to a HistogramContainer. " << endl;
2635 newEigenVariation->setVerbose(
m_verbose);
2639 string flavour = dir.substr(dir.find_last_of(
"/")+1);
2642 newEigenVariation->excludeNamedUncertainty(entry, cnt);
2644 newEigenVariation->initialize();
2646 if (to_retain > -1) {
2647 if (
m_verbose) cout <<
"btag Calib: reducing number of eigenvector variations for flavour " << flavour <<
" to " << to_retain << endl;
2649 newEigenVariation->mergeVariationsFrom(
size_t(to_retain-1));
2651 cerr <<
"btag Calib: unable to retrieve eigenvector reduction information for flavour " << flavour <<
" and scheme " <<
m_EVReductions[flavour] <<
"; not applying any reduction" << endl;
2656 }
else if (
m_EVStrategy == Analysis::Uncertainty::SFGlobalEigen) {
2669 newEigenVariation->excludeNamedUncertainty(entry,
label);
2672 newEigenVariation->initialize();
2677 if (to_retain > -1) {
2678 if (
m_verbose) cout <<
"btag Calib: reducing number of eigenvector variations for flavour " << flavour <<
" to " << to_retain << endl;
2680 newEigenVariation->mergeVariationsFrom(
size_t(to_retain-1), flavour);
2682 cerr <<
"btag Calib: unable to retrieve eigenvector reduction information for flavour " << flavour <<
" and scheme " <<
m_EVReductions[flavour] <<
"; not applying any reduction" << endl;
2691 std::shared_ptr<CalibrationDataEigenVariations> previous_eigenvariation =
m_eigenVariationsMap.begin()->second;
2696 std::cout <<
"CalibrationDataInterfaceROOT->retrieveContainer : the CDGEV object for " << name <<
" already exists! " << std::endl;
2712 std::map<string,string>::const_iterator it =
m_aliases.find(author);
2713 return (it ==
m_aliases.end()) ? author : it->second;
2719 const string&
label,
bool isSF,
2720 unsigned mapIndex)
const
2730 string flavour = (
label ==
"N/A") ?
"Light" :
label;
2753 TMapIter next(mapSF); TObjString* spec;
2754 while ((spec = (TObjString*) next())) {
2755 TObjString*
ref = (TObjString*) mapSF->GetValue(spec);
2756 m_refs[string(spec->GetName())] = string(
ref->GetName());
2763 TMapIter next(mapEff); TObjString* spec;
2764 while ((spec = (TObjString*) next())) {
2765 TObjString*
ref = (TObjString*) mapEff->GetValue(spec);
2766 m_refs[string(spec->GetName())] = string(
ref->GetName());
2782 std::map<string, string>::const_iterator it =
m_refs.find(spec);
2783 if (it ==
m_refs.end())
return false;
const boost::regex ref(r_ef)
static const std::string hadronisationRefs("MChadronisation_ref")
ClassImp(Analysis::CalibrationDataInterfaceROOT) Analysis
std::vector< std::string > split(const std::string &str, const char token=';')
local utility function: split string into a vector of substrings separated by a specified separator,...
constexpr int pow(int base, int exp) noexcept
This is the interface for the objects to be stored in the calibration ROOT file.
static bool isNearlyEqual(double a, double b)
utility for comparison of doubles
std::vector< unsigned int > getVariableTypes()
utility to retrieve variable types
virtual CalibrationStatus getResult(const CalibrationDataVariables &x, double &result, TObject *obj=0, bool extrapolate=false)=0
retrieve the calibration result.
This is the class holding information for histogram-based calibration results.
virtual int getEigenvectorReduction(unsigned int choice) const
Retrieve the number of eigenvectors to be retained for the purpose of eigenvector variation reduction...
virtual std::vector< double > getBinBoundaries(unsigned int vartype)
Retrieve the bin boundaries for the specified variable type (which should be a CalibrationParametriza...
virtual CalibrationStatus getResult(const CalibrationDataVariables &x, double &result, TObject *obj=0, bool extrapolate=false)
retrieve the calibration result.
std::string m_taggerName
tagging algorithm name
CalibrationDataInterfaceBase()
void setEffCalibrationNames(const std::map< std::string, std::vector< std::string > > &names)
std::string getContainername(const std::string &flavour, bool SF, unsigned int mapIndex=0) const
auxiliary function for string concatenation
void setSFCalibrationNames(const std::map< std::string, std::string > &names)
std::string getBasename(const std::string &name) const
auxiliary function for retrieval of name within the directory
double combinedUncertainty(double stat, const std::pair< double, double > &syst) const
utility function for combination of statistical and (a priori asymmetric) systematic uncertainty.
bool getReference(const std::string &spec, std::string &ref) const
Retrieve the (full) name of the reference histogram, given the hadronisation specification.
HadronisationReferenceHelper()
std::map< std::string, std::string > m_refs
map from hadronisation specification to container name
This tool provides an interface to flavour tagging performance estimates.
bool m_verbose
if true, allow also for some informational (and not only error/warning) messages
std::vector< std::pair< unsigned int, unsigned int > > m_checkedWeightScaleFactors
bool m_useTopologyRescaling
specify whether or not to use MC/MC (topology) scale factors (also this steering option may be remove...
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
std::map< std::string, unsigned int > m_objectIndices
std::map< std::string, std::string > m_aliases
Do not attempt to persistify (PROOF)
TFile * m_fileSF
Do not attempt to persistify (PROOF)
void increaseCounter(unsigned int index, OutOfBoundsType oob=Main)
bool m_useRecommendedEVExclusions
if true, exclude pre-recommended lists of uncertainties from the covariance matrix building,...
std::map< std::string, HadronisationReferenceHelper * > m_refMap
the following maps (one for each directory) specify the name of the container serving as the 'hadroni...
TFile * m_fileEff
pointer to the TFile object providing access to the calibrations
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
std::string nameFromIndex(unsigned int index) const
Retrieve the name of the calibration object (container) given its index.
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.
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
OutOfBoundsStrategy m_otherStrategy
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.
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.
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
bool m_runEigenVectorMethod
decide whether to run the eigenvector method or not
virtual ~CalibrationDataInterfaceROOT()
default destructor
OutOfBoundsStrategy m_absEtaStrategy
CalibrationDataInterfaceROOT()
default constructor for PROOF object retrieval
std::map< std::string, std::map< std::string, float > > m_coefficientMap
CalibrationStatus runEigenVectorRecomposition(const std::string &author, const std::string &label, const std::string &OP, unsigned int mapindex=0)
run EigenVector Recomposition method
std::vector< unsigned int > m_extrapolatedCounters
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
std::map< std::string, Analysis::EVReductionStrategy > m_EVReductions
Eigenvector reduction strategy (per flavour)
std::vector< std::string > m_flavours
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.
bool m_useMCMCSF
specify whether or not to use MC/MC (hadronisation) scale factors (the fact that this is steerable is...
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.
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.
std::map< std::string, std::map< std::string, float > > getEigenVectorRecompositionCoefficientMap()
Get Eigenvector recomposition map after running runEigenVectorRecomposition()
std::vector< int > m_hadronisationReference
store the 'hadronisation' reference for each object (-1 means no reference found)
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.
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
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,...
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
std::string getAlias(const std::string &author) const
associated alias retrieval method
std::map< std::string, std::vector< std::string > > m_excludeFromCovMatrix
store the uncertainties which should be excluded from building the full covariance matrix
double getMCMCScaleFactor(const CalibrationDataVariables &variables, unsigned indexSF, unsigned int indexEff) const
MC/MC scale factor retrieval.
std::vector< CalibrationDataContainer * > m_objects
cache the objects themselves (so that the user will not have to delete them after each call etc....
double m_maxAbsEta
|eta| bounds and strategy for dealing with out-of-bounds conditions
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
void initialize(const std::string &jetauthor, const std::string &OP, Uncertainty unc)
initialization for PROOF usage
std::vector< unsigned int > m_mainCounters
std::vector< unsigned int > m_etaCounters
counters for flagging out-of-bound cases
std::map< const CalibrationDataContainer *, std::shared_ptr< CalibrationDataEigenVariations > > m_eigenVariationsMap
store the eigenvector class and associate to its CalibrationDataContainer
bool checkAbsEta(const CalibrationDataVariables &variables, unsigned int index)
void checkWeightScaleFactors(unsigned int indexSF, unsigned int indexEff)
std::string m_filenameEff
std::string m_filenameSF
in addition, store also the filenames themselves (needed for the copy constructor)
This class (struct, actually) is nothing but a light-weight container of (kinematic or other) variabl...
std::string label(const std::string &format, int i)
std::vector< std::string > split(const std::string &str, const char token=';')
local utility function: split string into a vector of substrings separated by a specified separator,...
The namespace of all packages in PhysicsAnalysis/JetTagging.
OutOfBoundsType
counter types (to be used when flagging out-of-bounds cases)
const CalibResult dummyResult(dummyValue, dummyValue)
std::pair< double, double > CalibResult
std::pair< double, double > UncertaintyResult
The following typedef is for convenience: most uncertainties can be asymmetric.
Uncertainty
specification of type information requested by the user