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",
"")); m_filenameEff =
trimWhiteSpaces(m_filenameEff);
312 m_filenameSF = string(env.GetValue(
"FileSF",
"")); m_filenameSF =
trimWhiteSpaces(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"));
364 setSFCalibrationNames(SFNames);
370 string AL(env.GetValue(
"aliases",
""));
374 string alias = AL.substr(0, end);
378 string::size_type arrow = alias.find(
"->");
379 if (arrow == string::npos)
continue;
380 string target = alias.substr(0,arrow); target =
trimWhiteSpaces(target);
381 m_aliases[target] = alias.substr(arrow+2);
383 if (end != string::npos) AL = AL.substr(end+1);
384 }
while (end != string::npos);
388 string test=
"runEigenVectorMethod";
389 m_runEigenVectorMethod=(bool)env.GetValue(test.c_str(),0);
391 if (m_runEigenVectorMethod) {
396 test =
"excludeFromCovMatrix";
397 std::vector<std::string> to_exclude =
split(env.GetValue(test.c_str(),
""));
399 for (
auto const& flavour : m_flavours) {
400 m_excludeFromCovMatrix[flavour] = to_exclude;
402 for (
auto const& flavour : m_flavours) {
403 test =
"excludeFrom"; test += flavour; test +=
"CovMatrix";
404 to_exclude =
split(env.GetValue(test.c_str(),
""));
406 m_excludeFromCovMatrix[flavour].insert(m_excludeFromCovMatrix[flavour].end(), to_exclude.begin(), to_exclude.end());
409 unsigned int n_excluded = 0;
410 for (
auto const& flavour : m_flavours) {
411 n_excluded += m_excludeFromCovMatrix[flavour].size();
414 cout <<
" List of uncertainties to exclude:";
415 if (n_excluded == 0) cout <<
" none";
416 for (
auto const& flavour : m_flavours) {
417 if (m_excludeFromCovMatrix[flavour].
size() > 0) {
418 cout <<
"\n\t" << flavour <<
":\t";
419 for (
unsigned int i = 0; i < m_excludeFromCovMatrix[flavour].size(); ++i) {
420 cout << m_excludeFromCovMatrix[flavour].at(i);
421 if (i+1 == m_excludeFromCovMatrix[flavour].
size()) cout <<
"; ";
431 m_useRecommendedEVExclusions = (bool) env.GetValue(
"ExcludeRecommendedFromEigenVectorTreatment",
false);
434 std::map<string, EVReductionStrategy> mappings;
435 mappings[
"Loose"] = Loose;
436 mappings[
"Medium"] = Medium;
437 mappings[
"Tight"] = Tight;
438 for (
auto const& flavour : m_flavours) {
439 test = testPrefix; test +=
"EigenvectorReduction"; test += flavour;
440 std::string reduction = string(env.GetValue(test.c_str(),
"Loose"));
442 m_EVReductions[flavour] = mappings.find(reduction) == mappings.end() ? mappings[
"Loose"] : mappings.find(reduction)->second;
447 m_maxAbsEta = env.GetValue(
"MaxAbsEta", 2.5);
448 if (m_maxAbsEta < 0) m_maxAbsEta = 2.5;
451 string strategy = string(env.GetValue(
"OutOfBoundsEta",
"GiveUp"));
453 if (strategy ==
"GiveUp") m_absEtaStrategy = GiveUp;
454 else if (strategy ==
"Flag") m_absEtaStrategy = Flag;
455 else if (strategy ==
"Ignore") m_absEtaStrategy = Ignore;
457 cerr <<
"unknown |eta| extrapolation strategy: " << strategy <<
", setting to GiveUp" << endl;
458 m_absEtaStrategy = GiveUp;
462 strategy = string(env.GetValue(
"OutOfBoundsOther",
"Flag"));
464 if (strategy ==
"GiveUp") m_otherStrategy = GiveUp;
465 else if (strategy ==
"GiveUpExtrapolated") m_otherStrategy = GiveUpExtrapolated;
466 else if (strategy ==
"Flag") m_otherStrategy = Flag;
467 else if (strategy ==
"Ignore") m_otherStrategy = Ignore;
469 cerr <<
"unknown general extrapolation strategy: " << strategy <<
", setting to Flag" << endl;
470 m_otherStrategy = Flag;
474 m_maxTagWeight = env.GetValue(
"MaxTagWeight", 10.0);
477 m_useMCMCSF = (bool) env.GetValue(
"useMCMCSF", 1);
479 m_useTopologyRescaling = (bool) env.GetValue(
"useTopologySF", 0);
481 if (m_verbose) cout <<
"======= end of CalibrationDataInterfaceROOT instantiation ========" << endl;
487 const char* fileSF,
const char* fileEff,
488 const std::vector<std::string>& jetAliases,
489 const std::map<std::string, std::string>& SFNames,
490 const std::map<std::string, std::vector<std::string> >& EffNames,
491 const std::map<std::string, std::vector<std::string> >& excludeFromEV,
492 const std::map<std::string, EVReductionStrategy>& EVReductions,
493 bool useEV,
Uncertainty strat,
bool useMCMCSF,
bool useTopologyRescaling,
494 bool useRecommendedEEVExclusions,
bool verbose,
495 std::vector<std::string> flavours) :
534 cout <<
"=== CalibrationDataInterfaceROOT::CalibrationDataInterfaceROOT ===" << endl;
535 cout <<
" taggerName : " << taggerName << endl;
536 cout <<
" Systematic strategy : ";
538 cout <<
"SFEigen" << endl;
539 }
else if (
m_EVStrategy == Analysis::Uncertainty::SFGlobalEigen){
540 cout <<
"SFGlobalEigen" << endl;
542 cout <<
" Other" << endl;
544 if (fileEff) cout <<
" Efficiency file name : " << fileEff << endl;
545 cout <<
" SF file name : " << fileSF << endl
551 m_fileSF = TFile::Open(fileSF,
"READ");
552 if (fileEff && strcmp(fileSF, fileEff) != 0) {
554 m_fileEff = TFile::Open(fileEff,
"READ");
560 m_fileSF->GetObject(
"VersionInfo/BuildNumber", s);
561 if (s) cout <<
" CDI file build number: " << s->GetName() << endl;
565 for (
unsigned int i = 0; i < jetAliases.size(); ++i) {
568 string::size_type arrow = jetAliases[i].find(
"->");
569 if (arrow == string::npos)
continue;
570 m_aliases[jetAliases[i].substr(0,arrow)] = jetAliases[i].substr(arrow+2);
582 unsigned int n_excluded = 0;
587 cout <<
" List of uncertainties to exclude:";
588 if (n_excluded == 0) cout <<
" none";
591 cout <<
"\n\t" << flavour <<
":\t";
604 if (
m_verbose) cout <<
"======= end of CalibrationDataInterfaceROOT instantiation ========" << endl;
653 for (std::vector<CalibrationDataContainer*>::iterator it =
m_objects.begin(); it !=
m_objects.end(); ++it) {
659 for (std::map<std::string, HadronisationReferenceHelper*>::iterator it =
m_refMap.begin();
662 {
delete it->second; it->second=
nullptr; }
668 cout <<
"\t\tCalibrationDataInterfaceROOT |eta| out-of-bounds summary:" << endl;
674 if (!found) cout <<
"\t\t\tNo issues found" << endl;
678 cout <<
"\t\tCalibrationDataInterfaceROOT object out-of-bounds summary:" << endl;
687 if (!found) cout <<
"\t\t\tNo issues found" << endl;
694 const std::string& OP,
695 const std::string& author,
696 bool isSF,
unsigned int&
index,
697 unsigned int mapIndex)
721 std::map<string, unsigned int>::const_iterator it =
m_objectIndices.find(name);
725 string flavour = (
label ==
"N/A") ?
"Light" :
label;
727 if (
m_verbose) std::cout <<
"CalibrationDataInterfaceROOT->retrieveCalibrationIndex : container name is " << cntname << std::endl;
732 if (
m_verbose) std::cout <<
"CalibrationDataInterfaceROOT->retrieveCalibrationIndex : container " << name <<
" already cached! " << std::endl;
742 const string&
label,
const string& OP,
744 unsigned int mapIndex)
758 unsigned int indexEff, indexSF;
760 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;
773 unsigned int indexSF,
unsigned int indexEff,
774 Uncertainty unc,
const std::string& flavour,
unsigned int numVariation)
794 unsigned int indexSF,
unsigned int indexEff,
811 cerr <<
"getScaleFactor: error retrieving container!" << endl;
818 cerr <<
"Jet |eta| is outside of the boundary!" << endl;
827 cerr <<
" ERROR. Trying to call eigenvector method but initialization not switched on in b-tagging configuration." << endl;
828 cerr <<
" Please correct your configuration first. Nominal uncertainties used. " << endl;
833 std::shared_ptr<CalibrationDataEigenVariations> eigenVariation;
836 }
catch (
const std::out_of_range&) {
837 cerr <<
" Could not retrieve eigenvector variation, while it should have been there." << endl;
842 bool extrapolate =
false;
844 unsigned int maxVariations = (unc ==
SFEigen) ? eigenVariation->getNumberOfEigenVariations() : eigenVariation->getNumberOfNamedVariations();
845 if (numVariation > maxVariations-1) {
846 cerr <<
"Asked for " << ((unc ==
SFEigen) ?
"eigenvariation" :
"named variation") <<
" number: " << numVariation <<
" but overall number of available variations is: " << maxVariations << endl;
849 bool isOK = eigenVariation->getEigenvectorVariation(numVariation,up,down);
851 cerr <<
"Eigenvector object is there but cannot retrieve up and down uncertainty histograms." << endl;
855 extrapolate = (unc ==
SFNamed) ? eigenVariation->isExtrapolationVariation(numVariation) :
false;
858 std::shared_ptr<CalibrationDataGlobalEigenVariations>
GEV = std::dynamic_pointer_cast<CalibrationDataGlobalEigenVariations>(eigenVariation);
860 cerr <<
"Analysis::CalibrationDataInterfaceROOT::getScaleFactor: dynamic cast failed\n";
863 unsigned int maxVariations =
GEV->getNumberOfEigenVariations(flavour);
864 if (maxVariations == 0){
865 cerr <<
"Overall number of available variations is 0!" << endl;
868 if (numVariation > maxVariations-1) {
869 cerr <<
"Asked for global eigenvariation number: " << numVariation <<
" but overall number of available variations is: " << maxVariations << endl;
872 bool isOK =
GEV->getEigenvectorVariation(flavour, numVariation,up,down);
874 cerr <<
"Eigenvector object is there but cannot retrieve up and down uncertainty histograms." << endl;
878 extrapolate =
GEV->isExtrapolationVariation(numVariation, flavour);
880 std::cerr <<
"ERROR: you requested " << unc <<
" but that isn't in the set of (SFEigen, SFGlobalEigen, SFNamed) for eigenvariations. " << std::endl;
902 result.first = MCMCSF*valueUp;
903 result.second = MCMCSF*valueDown;
919 cerr <<
"getScaleFactor: error retrieving result in non-EV context!" << endl;
938 cerr <<
"getScaleFactor: error retrieving Scale factor parameter covariance matrix!" << endl;
945 if (container->getSystUncertainty(variables, resSyst) ==
Analysis::kError) {
946 cerr <<
"getScaleFactor: error retrieving Scale factor parameter systematic uncertainty!" << endl;
951 if (container->getUncertainty(
"extrapolation", variables, resSyst) ==
Analysis::kError)
952 cerr <<
"getScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
956 if (container->getUncertainty(
"extrapolation from charm", variables, resSyst) ==
Analysis::kError)
957 cerr <<
"getScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
961 result.first = MCMCSF*value;
962 result.second = MCMCSF*uncertainty;
973 const string&
label,
const string& OP,
988 cerr <<
"getMCEfficiency: unable to find Eff calibration for object " <<
fullName(variables.jetAuthor, OP,
label,
false, mapIndex) << endl;
1036 cerr <<
"Jet |eta| is outside of the boundary!" << endl;
1055 cerr <<
"getMCEfficiency: error retrieving MC efficiency parameter covariance matrix!" << endl;
1069 double uncertainty = stat;
1070 result.first = std::max(0., std::min(1., value));
1071 result.second = uncertainty;
1081 const string&
label,
1082 const string& OP,
Uncertainty unc,
const std::string& flavour,
1083 unsigned int numVariation,
unsigned int mapIndex)
1098 unsigned int indexSF, indexEff;
1101 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;
1113 unsigned int indexSF,
unsigned int indexEff,
1114 Uncertainty unc,
const std::string& flavour,
unsigned int numVariation)
1136 unsigned int indexSF,
unsigned int indexEff,
1158 double relative = 0;
1159 double value = effResult.first;
1161 value = std::min(effResult.first*sfResult.first, 1.);
1166 double valueDown = effResult.first*sfResult.second;
1167 result.first = value;
1168 result.second = valueDown;
1172 relative = effResult.second/effResult.first;
1173 double sfRelative = sfResult.second/sfResult.first;
1178 relative = TMath::Sqrt(sfRelative*sfRelative + relative*relative);
1182 cerr <<
"ERROR: CalibrationDataInterfaceROOT::getEfficiency: SF null result, SF=" << sfResult.first <<
" MC eff=" << effResult.first <<
"; setting SF=1." << endl;
1186 result.first = value;
1187 result.second = value*relative;
1196 const string&
label,
1198 unsigned int numVariation,
unsigned int mapIndex)
1214 unsigned int indexSF, indexEff;
1217 cerr <<
"getInefficiencyScaleFactor: unable to find Eff calibration for object "
1218 <<
fullName(variables.jetAuthor, OP,
label,
false, mapIndex)
1219 <<
" or SF calibration for object "
1233 unsigned int indexSF,
unsigned int indexEff,
1234 Uncertainty unc,
const std::string& flavour,
unsigned int numVariation)
1257 unsigned int indexSF,
unsigned int indexEff,
1281 double eff = std::min(effResult.first, 1.);
1283 double sf = sfResult.first;
1284 double sferr = sfResult.second;
1290 val = std::max((1. - eff*sf),
CalibZERO) / (1. - eff);
1294 double valDown = std::max((1. - eff*sferr),
CalibZERO) / (1. - eff);
1296 result.second = valDown;
1302 err = pow(eff*sferr, 2);
1304 err = 1./(1. - eff) * TMath::Sqrt(err);
1308 result.first = std::max(
CalibZERO, val);
1309 result.second = err;
1317 const string&
label,
1319 unsigned int numVariation,
unsigned int mapIndex)
1335 unsigned int indexSF, indexEff;
1338 cerr <<
"getInefficiency: unable to find Eff calibration for object "
1339 <<
fullName(variables.jetAuthor, OP,
label,
false, mapIndex)
1340 <<
" or SF calibration for object "
1354 unsigned int indexSF,
unsigned int indexEff,
1355 Uncertainty unc,
const std::string& flavour,
unsigned int numVariation)
1378 unsigned int indexSF,
unsigned int indexEff,
1402 double val = std::max(0., 1. - effResult.first * sfResult.first);
1406 if (effResult.first <= 0. || sfResult.first <= 0.)
return Analysis::kError;
1411 double valDown = std::max(0., 1. - effResult.first*sfResult.second);
1414 result.second = valDown;
1417 err = effResult.second/effResult.first*effResult.second/effResult.first
1418 + sfResult.second/sfResult.first*sfResult.second/sfResult.first;
1419 err = val*TMath::Sqrt(err);
1421 result.first = std::max(0., std::min(1., val));
1422 result.second = err;
1432 const string&
label,
const string& OP,
1449 return std::make_pair(std::max(0., 1. - effResult.first), effResult.second);
1469 return std::make_pair(std::max(0., 1. - effResult.first), effResult.second);
1475 unsigned indexSF,
unsigned int indexEff)
const
1484 if (indexSFRef < 0 || indexEffRef < 0 || indexSFRef == indexEffRef)
return 1;
1487 double effSFRef;
m_objects[indexSFRef]->getResult(variables, effSFRef);
1488 double effEffRef;
m_objects[indexEffRef]->getResult(variables, effEffRef);
1489 return (effSFRef > 0 && effEffRef > 0) ? effSFRef/effEffRef : 1;
1496 unsigned int numVariation,
unsigned int mapIndex)
1514 static const string cont(
"Continuous");
1516 unsigned int indexSF, indexEff;
1519 cerr <<
"getWeightScaleFactor: unable to find Eff calibration for object "
1520 <<
fullName(variables.jetAuthor, cont,
label,
false, mapIndex)
1521 <<
" or SF calibration for object "
1522 <<
fullName(variables.jetAuthor, cont,
label,
true) << endl;
1533 unsigned int indexSF,
unsigned int indexEff,
1560 unsigned int indexSF,
unsigned int indexEff,
1592 cerr <<
"Jet |eta| is outside of the boundary!" << endl;
1611 if (container->getUncertainty(
"MCreference", variables, refMCResult) ==
Analysis::kError)
1613 double fracMCref = refMCResult.first;
1616 double fracSFref = fracMCref, fracEffref = fracMCref;
1619 if (indexSFref < 0 || indexEffref < 0) {
1620 cerr <<
"getWeightScaleFactor: error: generator-specific corrections requested but necessary reference containers lacking " << endl;
1623 m_objects[indexSFref]->getResult(variables, fracSFref);
1624 m_objects[indexEffref]->getResult(variables, fracEffref);
1625 if (! (fracSFref > 0. && fracEffref > 0.)) {
1626 cerr <<
"getWeightScaleFactor: error: invalid reference tag weight fraction " <<fracSFref <<
" " <<fracEffref << std::endl;
1641 cerr <<
"getWeightScaleFactor: error: null fracMCnew would lead to invalid operation" << endl;
1646 cerr <<
"getWeightScaleFactor: ERROR. Trying to call eigenvector method but initialization not switched on in b-tagging .env config file." << endl;
1647 cerr <<
" Please correct your .env config file first. Nominal uncertainties used. " << endl;
1651 std::shared_ptr<CalibrationDataEigenVariations> eigenVariation;
1654 }
catch (
const std::out_of_range&) {
1655 cerr <<
"getWeightScaleFactor: could not retrieve eigenvector variation, while it should have been there." << endl;
1658 unsigned int maxVariations = (unc ==
SFEigen) ? eigenVariation->getNumberOfEigenVariations() : eigenVariation->getNumberOfNamedVariations();
1659 if (numVariation > maxVariations-1) {
1660 cerr <<
"getWeightScaleFactor: asked for " << ((unc ==
SFEigen) ?
"eigenvariation" :
"named variation") <<
" number: " << numVariation <<
" but overall number of available variations is: " << maxVariations << endl;
1665 bool isOK = (unc ==
SFEigen) ? eigenVariation->getEigenvectorVariation(numVariation,up,down) : eigenVariation->getNamedVariation(numVariation,up,down);
1667 cerr <<
"getWeightScaleFactor: Eigenvector object is there but cannot retrieve up and down uncertainty histograms." << endl;
1671 bool extrapolate = ( unc ==
SFNamed ) ? eigenVariation->isExtrapolationVariation(numVariation) :
false;
1680 double variationUp = valueUp - value;
1681 double variationDown = valueDown - value;
1685 if (
m_useMCMCSF) value *= (fracSFref / fracEffref);
1690 double f = (fracMCref / fracMCnew);
1694 double f = (fracSFref / fracEffref);
1698 valueUp = value + variationUp;
1699 valueDown = value + variationDown;
1705 if (valueDown < 0) {
1711 result.first = valueUp;
1712 result.second = valueDown;
1722 cerr <<
"getWeightScaleFactor: error retrieving Scale factor parameter covariance matrix!" << endl;
1728 if (container->getSystUncertainty(variables, uncertaintyResult) ==
Analysis::kError) {
1729 cerr <<
"getWeightScaleFactor: error retrieving Scale factor parameter systematic uncertainty!" << endl;
1734 if (container->getUncertainty(
"extrapolation", variables, uncertaintyResult) ==
Analysis::kError)
1735 cerr <<
"getWeightScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
1739 if (container->getUncertainty(
"extrapolation from charm", variables, uncertaintyResult) ==
Analysis::kError)
1740 cerr <<
"getWeightScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
1749 if (
m_useMCMCSF) value *= (fracSFref / fracEffref);
1759 uncertainty *= (fracMCref / fracMCnew);
1761 uncertainty *= (fracSFref / fracEffref);
1764 result.first = std::max(0., value);
1765 result.second = uncertainty;
1773 unsigned int indexEff)
1789 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: error: container for object " <<
nameFromIndex(indexSF) <<
" not found!" << endl;
1791 }
else if (! container->GetValue(
"MCreference")) {
1792 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: error: no MCreference histogram for object " <<
nameFromIndex(indexSF) <<
"!" << endl;
1796 if (! effContainer) {
1797 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: error: container for object " <<
nameFromIndex(indexEff) <<
" not found!" << endl;
1802 std::vector<unsigned int> vars = container->getVariableTypes();
1805 std::map<unsigned int, std::vector<double> > boundaries, effBoundaries, mergedBoundaries;
1806 for (
unsigned int t = 0; t < vars.size(); ++t)
1807 boundaries[vars[t]] = container->getBinBoundaries(vars[t]);
1808 for (
unsigned int t = 0; t < effVars.size(); ++t)
1823 if (v[0] < 0 && vEff[0] >= 0) {
1825 std::vector<double> vtmp(vEff);
1826 for (std::vector<double>::iterator it = vtmp.begin(); it != vtmp.end(); ++it)
1827 if (*it > 0) vEff.insert(vEff.begin(), -(*it));
1828 }
else if (v[0] >= 0 && vEff[0] < 0) {
1830 std::vector<double> vtmp(v);
1831 for (std::vector<double>::iterator it = vtmp.begin(); it != vtmp.end(); ++it)
1832 if (*it > 0) v.insert(v.begin(), -(*it));
1837 for (
unsigned int t = 0; t < vars.size(); ++t) {
1838 if (effBoundaries.find(vars[t]) == effBoundaries.end())
1840 mergedBoundaries[vars[t]] = boundaries[vars[t]];
1844 mergedBoundaries[vars[t]] = effBoundaries[vars[t]];
1846 for (std::vector<double>::iterator it = boundaries[vars[t]].begin(); it != boundaries[vars[t]].end(); ++it) {
1847 std::vector<double>::iterator itcmp = mergedBoundaries[vars[t]].begin();
1850 while (itcmp != mergedBoundaries[vars[t]].end() &&
1852 *itcmp < *it) ++itcmp;
1857 mergedBoundaries[vars[t]].insert(itcmp, *it);
1862 for (
unsigned int t = 0; t < effVars.size(); ++t)
1863 if (boundaries.find(effVars[t]) == boundaries.end())
1864 mergedBoundaries[effVars[t]] = effBoundaries[effVars[t]];
1869 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: " <<
"no tag weight axis found for object " <<
nameFromIndex(indexSF) << endl;
1871 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: " <<
"no tag weight axis found for object " <<
nameFromIndex(indexEff) << endl;
1873 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: " <<
"different tag weight binning for objects " <<
nameFromIndex(indexSF) <<
" (";
1875 for (
unsigned int ib = 0; ib < v.size()-1; ++ib) cerr << v[ib] <<
",";
1876 cerr << v[v.size()-1] <<
") and " <<
nameFromIndex(indexEff) <<
" (";
1878 for (
unsigned int ib = 0; ib < v.size()-1; ++ib) cerr << v[ib] <<
",";
1879 cerr << v[v.size()-1] <<
") do not match!" << endl;
1889 cout <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: cross-checking scale factors for objects " <<
nameFromIndex(indexSF) <<
" and " <<
nameFromIndex(indexEff) <<
"\n" << std::setfill(
'-') << std::setw(100) <<
"-" << endl;
1890 cout << std::setfill(
' ');
1894 const std::string mcRefStr{
"MCreference"};
1895 for (
unsigned int ipt = 0; ipt < vPt.size()-1; ++ipt) {
1896 x.jetPt = (vPt[ipt] + vPt[ipt+1]) * 500.;
1897 for (
unsigned int ieta = 0; ieta < vEta.size()-1; ++ieta) {
1898 x.jetEta = (vEta[ieta] + vEta[ieta+1]) / 2.;
1899 for (
unsigned int iwt = 0; iwt < vTagWeight.size()-1; ++iwt) {
1900 x.jetTagWeight = (vTagWeight[iwt] + vTagWeight[iwt+1]) / 2.;
1903 container->getResult(
x, value);
1905 container->getUncertainty(mcRefStr,
x, uncertaintyResult);
1906 double fracMCref = uncertaintyResult.first;
1910 if (!(fracMCnew > 0.)) {
1911 cout <<
"\tfor (pt=" <<
x.jetPt <<
",eta=" <<
x.jetEta <<
",tagweight=" <<
x.jetTagWeight <<
"): invalid new MC fraction: " << fracMCnew << endl;
1913 double newvalue = 1.0 + (value - 1.0) * fracMCref/fracMCnew;
1914 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;
1956 for (std::map<std::string, unsigned int>::const_iterator it =
m_objectIndices.begin();
1958 if (it->second ==
index)
return it->first;
1976 unsigned int minsize = (
index == 0) ? 2 : 2*
index;
1995 const string&
label,
2013 cerr <<
"listScaleFactorUncertainties: unable to find SF calibration for object " <<
fullName(author, OP,
label,
true) << endl;
2014 std::vector<string> dummy;
2023 const std::string& flavour,
bool named)
2036 std::vector<string> dummy;
2043 std::shared_ptr<CalibrationDataEigenVariations> eigenVariation=
m_eigenVariationsMap.at(container);
2045 std::vector<string> unordered = eigenVariation->listNamedVariations();
2046 std::vector<string> ordered(unordered.size());
2047 for (
unsigned int i = 0; i < unordered.size(); ++i) {
2048 ordered[eigenVariation->getNamedVariationIndex(unordered[i])] = unordered[i];
2051 }
else if (
m_EVStrategy == Analysis::Uncertainty::SFGlobalEigen){
2053 std::shared_ptr<CalibrationDataGlobalEigenVariations>
GEV = std::dynamic_pointer_cast<CalibrationDataGlobalEigenVariations>(eigenVariation);
2054 std::vector<std::string> unordered =
GEV->listNamedVariations(flavour);
2055 std::vector<std::string> ordered(unordered.size());
2056 for (
unsigned int i = 0; i < unordered.size(); ++i) {
2057 ordered[
GEV->getNamedVariationIndex(unordered[i], flavour)] = unordered[i];
2062 return container->listUncertainties();
2071 const std::string&
label,
2072 const std::string& OP,
2104 if (! container)
return 0;
2105 std::shared_ptr<CalibrationDataEigenVariations> eigenVariation=
m_eigenVariationsMap.at(container);
2107 std::shared_ptr<CalibrationDataGlobalEigenVariations>
GEV = std::dynamic_pointer_cast<CalibrationDataGlobalEigenVariations>(eigenVariation);
2108 return GEV->getNumberOfEigenVariations(flavour);
2110 return (unc ==
SFEigen) ? eigenVariation->getNumberOfEigenVariations() : eigenVariation->getNumberOfNamedVariations();
2116 const std::string&
label,
2117 const std::string& OP)
2128 cerr <<
"getBinnedScaleFactors: unable to find SF calibration for object " <<
fullName(author, OP,
label,
true) << endl;
2132 return (container) ?
dynamic_cast<TH1*
>(container->GetValue(
"result")) : 0;
2138 const std::string&
label,
2139 const std::string& OP,
2140 unsigned int mapIndex)
2153 cerr <<
"getMCEfficiencyObject: unable to find efficiency calibration for object "
2158 return (container) ? container->GetValue(
"result") : 0;
2166 const std::string&
label,
2167 const std::string& OP,
2168 const std::string& unc,
2182 if (unc ==
"comment" || unc ==
"result" || unc ==
"combined" || unc ==
"statistics")
return 0;
2187 cerr <<
"getShiftedScaleFactors: unable to find SF calibration for object " <<
fullName(author, OP,
label,
true) << endl;
2191 if (! container)
return nullptr;
2193 TH1* result =
dynamic_cast<TH1*
>(container->GetValue(
"result"));
2194 TH1* hunc =
dynamic_cast<TH1*
>(container->GetValue(unc.c_str()));
2196 if ((! hunc) || (! result))
return nullptr;
2197 if (hunc->GetDimension() != result->GetDimension() || hunc->GetNbinsX() != result->GetNbinsX() ||
2198 hunc->GetNbinsX() != result->GetNbinsX() || hunc->GetNbinsX() != result->GetNbinsX())
2203 if (! container->isBinCorrelated(unc))
return 0;
2206 std::string name(container->GetName()); name +=
"_"; name += unc; name +=
"_";
2207 TH1* shifted =
dynamic_cast<TH1*
>(result->Clone(name.c_str()));
2208 if (not shifted)
return nullptr;
2209 shifted->Add(hunc, sigmas);
2215 const std::string&
label,
2216 const std::string& OP,
2217 unsigned int mapIndex){
2228 cerr <<
"runEigenVectorRecomposition: Recomposition need to be ran with CalibrationDataInterfaceRoot initialized in eigenvector mode" << endl;
2232 unsigned int indexSF;
2234 cerr <<
"runEigenVectorRecomposition: unable to find SF calibration for object "
2244 unsigned int indexSF){
2252 cerr <<
"runEigenVectorRecomposition: error retrieving container!" << endl;
2257 std::shared_ptr<CalibrationDataEigenVariations> eigenVariation;
2260 }
catch (
const std::out_of_range&) {
2261 cerr <<
"runEigenVectorRecomposition: Could not retrieve eigenvector variation, while it should have been there." << endl;
2265 std::map<std::string, std::map<std::string, float>> coefficientMap;
2266 if(!eigenVariation->EigenVectorRecomposition(
label, coefficientMap))
2273std::map<std::string, std::map<std::string, float>>
2276 cerr <<
"getCoefficientMap: Call runEigenVectorRecomposition() before retrieving coefficient map! " <<endl;
2285 TMatrixDSym getStatCovarianceMatrix(
const TH1* hist) {
2286 Int_t nbinx = hist->GetNbinsX()+2, nbiny = hist->GetNbinsY()+2, nbinz = hist->GetNbinsZ()+2;
2288 if (hist->GetDimension() > 1) rows *= nbiny;
2289 if (hist->GetDimension() > 2) rows *= nbinz;
2290 TMatrixDSym stat(rows);
2291 for (Int_t binx = 1; binx < nbinx; ++binx){
2292 for (Int_t biny = 1; biny < nbiny; ++biny){
2293 for (Int_t binz = 1; binz < nbinz; ++binz) {
2294 Int_t
bin = hist->GetBin(binx, biny, binz);
2295 double err = hist->GetBinError(
bin);
2296 stat(
bin,
bin) = err*err;
2306 TMatrixDSym getSystCovarianceMatrix(
const TH1*
ref,
const TH1* unc,
bool doCorrelated,
const std::string& uncname,
int tagWeightAxis) {
2307 Int_t nbinx =
ref->GetNbinsX()+2, nbiny =
ref->GetNbinsY()+2, nbinz =
ref->GetNbinsZ()+2;
2309 if (
ref->GetDimension() > 1)
rows *= nbiny;
2310 if (
ref->GetDimension() > 2)
rows *= nbinz;
2311 TMatrixDSym
cov(rows);
2313 for(
int i=0 ;
i<10 ;
i++){
2314 Int_t
bin = unc->GetBin(1,i,1);
2315 double uncval = unc->GetBinContent(bin);
2316 cout << uncval <<
", ";
2320 if (unc->GetNbinsX()+2 != nbinx || unc->GetNbinsY()+2 != nbiny || unc->GetNbinsZ()+2 != nbinz || unc->GetDimension() !=
ref->GetDimension()) {
2321 std::cout <<
"getSystCovarianceMatrix: inconsistency found in histograms " <<
ref->GetName() <<
" and " << unc->GetName() <<
" : " << uncname << std::endl;
2332 if (! doCorrelated) {
2333 if (tagWeightAxis < 0) {
2335 for (Int_t binx = 1; binx < nbinx-1; ++binx){
2336 for (Int_t biny = 1; biny < nbiny-1; ++biny){
2337 for (Int_t binz = 1; binz < nbinz-1; ++binz) {
2338 Int_t
bin =
ref->GetBin(binx, biny, binz);
2339 double err = unc->GetBinContent(bin);
2345 }
else if (tagWeightAxis == 0) {
2347 for (Int_t biny = 1; biny < nbiny-1; ++biny){
2348 for (Int_t binz = 1; binz < nbinz-1; ++binz){
2349 for (Int_t binx = 1; binx < nbinx-1; ++binx) {
2350 Int_t
bin =
ref->GetBin(binx, biny, binz);
2351 double err = unc->GetBinContent(bin);
2352 for (Int_t binx2 = 1; binx2 < nbinx-1; ++binx2) {
2353 Int_t
bin2 =
ref->GetBin(binx2, biny, binz);
2354 double err2 = unc->GetBinContent(bin2);
2355 cov(bin,bin2) =
err*err2;
2361 }
else if (tagWeightAxis == 1) {
2363 for (Int_t binx = 1; binx < nbinx-1; ++binx){
2364 for (Int_t binz = 1; binz < nbinz-1; ++binz){
2365 for (Int_t biny = 1; biny < nbiny-1; ++biny) {
2366 Int_t
bin =
ref->GetBin(binx, biny, binz);
2367 double err = unc->GetBinContent(bin);
2368 for (Int_t biny2 = 1; biny2 < nbiny-1; ++biny2) {
2369 Int_t
bin2 =
ref->GetBin(binx, biny2, binz);
2370 double err2 = unc->GetBinContent(bin2);
2371 cov(bin,bin2) =
err*err2;
2377 }
else if (tagWeightAxis == 2) {
2379 for (Int_t binx = 1; binx < nbinx-1; ++binx){
2380 for (Int_t biny = 1; biny < nbiny-1; ++biny){
2381 for (Int_t binz = 1; binz < nbinz-1; ++binz) {
2382 Int_t
bin =
ref->GetBin(binx, biny, binz);
2383 double err = unc->GetBinContent(bin);
2384 for (Int_t binz2 = 1; binz2 < nbinz-1; ++binz2) {
2385 Int_t
bin2 =
ref->GetBin(binx, biny, binz2);
2386 double err2 = unc->GetBinContent(bin2);
2387 cov(bin,bin2) =
err*err2;
2396 for (Int_t binx = 1; binx < nbinx-1; ++binx){
2397 for (Int_t biny = 1; biny < nbiny-1; ++biny){
2398 for (Int_t binz = 1; binz < nbinz-1; ++binz) {
2399 Int_t
bin =
ref->GetBin(binx, biny, binz);
2400 double err = unc->GetBinContent(bin);
2401 for (Int_t binx2 = 1; binx2 < nbinx-1; ++binx2){
2402 for (Int_t biny2 = 1; biny2 < nbiny-1; ++biny2){
2403 for (Int_t binz2 = 1; binz2 < nbinz-1; ++binz2) {
2404 Int_t
bin2 =
ref->GetBin(binx2, biny2, binz2);
2405 double err2 = unc->GetBinContent(bin2);
2406 cov(bin, bin2) =
err*err2;
2423 const std::string&
label,
2424 const std::string& OP,
2425 const std::string& unc)
2437 if (unc ==
"comment" || unc ==
"result" || unc ==
"combined")
return dummy;
2442 cerr <<
"getScaleFactorCovarianceMatrix: unable to find SF calibration for object " <<
fullName(author, OP,
label,
true) << endl;
2446 if (!container)
return dummy;
2449 TH1* result =
dynamic_cast<TH1*
>(container->GetValue(
"result"));
2450 if (! result)
return dummy;
2453 if (unc ==
"statistics") {
2454 return getStatCovarianceMatrix(result);
2456 TH1* hunc =
dynamic_cast<TH1*
>(container->GetValue(unc.c_str()));
2458 cout <<
"getScaleFactorCovarianceMatrix: no uncertainty object found "
2459 <<
"corresponding to name " << unc << endl;
2462 return getSystCovarianceMatrix(result, hunc, container->isBinCorrelated(unc), unc, container->getTagWeightAxis());
2469 TMatrixDSym cov = getStatCovarianceMatrix(result);
2472 std::vector<string> uncs = container->listUncertainties();
2473 for (
unsigned int t = 0; t < uncs.size(); ++t) {
2474 if (uncs[t] ==
"comment" || uncs[t] ==
"result" || uncs[t] ==
"combined" ||
2475 uncs[t] ==
"statistics" || uncs[t]==
"extrapolation" || uncs[t]==
"MChadronisation" ||
2476 uncs[t]==
"ReducedSets" || uncs[t]==
"systematics")
continue;
2477 TH1* hunc =
dynamic_cast<TH1*
>(container->GetValue(uncs[t].c_str()));
2479 std::cerr<<
"Analysis::CalibrationDataInterfaceROOT::getScaleFactorCovarianceMatrix : dynamic cast failed\n";
2482 TMatrixDSym syst_cov = getSystCovarianceMatrix(result, hunc, container->isBinCorrelated(uncs[t]), uncs[t], container->getTagWeightAxis());
2497 cerr <<
"initialize can only be called once per CalibrationDataInterfaceROOT object" << endl;
2500 cout <<
"initializing BTagCalibrationDataInterfaceROOT for PROOF with jetAuthor = " << jetauthor <<
", tagger = " <<
m_taggerName <<
", operating point = " << OP <<
", uncertainty = " << unc << endl;
2504 BTagVars.jetAuthor = jetauthor;
2505 BTagVars.jetPt = 100000.;
2506 BTagVars.jetEta = 1.5;
2509 std::pair<double, double> BTagCalibResult;
2511 std::cout <<
"CalibrationDataInterfaceROOT->initialize : BTagCalibResult " << std::endl;
2513 std::pair<double, double> BTagCalibMCEff;
2515 std::cout <<
"CalibrationDataInterfaceROOT->initialize : BTagCalibMCEff " << std::endl;
2546 string name = dir +
"/" + cntname;
2563 cerr <<
"btag Calib: retrieveContainer: failed to retrieve container named " << name <<
" from file" << endl;
2569 cout <<
"CalibrationDataInterface: retrieved container " << name <<
" (with comment: '" << cnt->getComment() <<
"' and hadronisation setting '" << cnt->getHadronisation() <<
"')" << endl;
2596 string spec = cnt->getHadronisation();
2598 std::map<string, HadronisationReferenceHelper*>::const_iterator mapit =
m_refMap.find(dir);
2601 if (mapit->second->getReference(spec,
ref)) {
2607 string refname(dir +
"/" +
ref);
2608 std::map<string, unsigned int>::const_iterator it =
m_objectIndices.find(refname);
2620 cerr <<
"btag Calib: retrieveContainer: MC hadronisation reference map not found -- this should not happen!" << endl;
2627 cerr <<
"btag Calib: retrieveContainer: warning: unable to apply MC/MC scale factors for container " << name <<
" with hadronisation reference = '" << spec <<
"'" << endl;
2641 if (histoContainer==0) {
2642 cerr <<
"Could not cast Container to a HistogramContainer. " << endl;
2648 newEigenVariation->setVerbose(
m_verbose);
2652 string flavour = dir.substr(dir.find_last_of(
"/")+1);
2655 newEigenVariation->excludeNamedUncertainty(entry, cnt);
2657 newEigenVariation->initialize();
2659 if (to_retain > -1) {
2660 if (
m_verbose) cout <<
"btag Calib: reducing number of eigenvector variations for flavour " << flavour <<
" to " << to_retain << endl;
2662 newEigenVariation->mergeVariationsFrom(
size_t(to_retain-1));
2664 cerr <<
"btag Calib: unable to retrieve eigenvector reduction information for flavour " << flavour <<
" and scheme " <<
m_EVReductions[flavour] <<
"; not applying any reduction" << endl;
2669 }
else if (
m_EVStrategy == Analysis::Uncertainty::SFGlobalEigen) {
2682 newEigenVariation->excludeNamedUncertainty(entry,
label);
2685 newEigenVariation->initialize();
2690 if (to_retain > -1) {
2691 if (
m_verbose) cout <<
"btag Calib: reducing number of eigenvector variations for flavour " << flavour <<
" to " << to_retain << endl;
2693 newEigenVariation->mergeVariationsFrom(
size_t(to_retain-1), flavour);
2695 cerr <<
"btag Calib: unable to retrieve eigenvector reduction information for flavour " << flavour <<
" and scheme " <<
m_EVReductions[flavour] <<
"; not applying any reduction" << endl;
2704 std::shared_ptr<CalibrationDataEigenVariations> previous_eigenvariation =
m_eigenVariationsMap.begin()->second;
2709 std::cout <<
"CalibrationDataInterfaceROOT->retrieveContainer : the CDGEV object for " << name <<
" already exists! " << std::endl;
2725 std::map<string,string>::const_iterator it =
m_aliases.find(author);
2726 return (it ==
m_aliases.end()) ? author : it->second;
2732 const string&
label,
bool isSF,
2733 unsigned mapIndex)
const
2743 string flavour = (
label ==
"N/A") ?
"Light" :
label;
2766 TMapIter next(mapSF); TObjString* spec;
2767 while ((spec = (TObjString*) next())) {
2768 TObjString*
ref = (TObjString*) mapSF->GetValue(spec);
2769 m_refs[string(spec->GetName())] = string(
ref->GetName());
2776 TMapIter next(mapEff); TObjString* spec;
2777 while ((spec = (TObjString*) next())) {
2778 TObjString*
ref = (TObjString*) mapEff->GetValue(spec);
2779 m_refs[string(spec->GetName())] = string(
ref->GetName());
2795 std::map<string, string>::const_iterator it =
m_refs.find(spec);
2796 if (it ==
m_refs.end())
return false;
const std::regex ref(r_ef)
static const std::string hadronisationRefs("MChadronisation_ref")
std::string_view trimWhiteSpaces(std::string_view str) noexcept
Removes all trailing and starting whitespaces from a string.
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,...
size_t size() const
Number of registered mappings.
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 retrieval of container name
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
std::string_view trimWhiteSpaces(std::string_view str) noexcept
Removes all trailing and starting whitespaces from a string.