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 << 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 (maxVariations == 0){
860 cerr <<
"Overall number of available variations is 0!" << endl;
863 if (numVariation > maxVariations-1) {
864 cerr <<
"Asked for global eigenvariation number: " << numVariation <<
" but overall number of available variations is: " << maxVariations << endl;
867 bool isOK =
GEV->getEigenvectorVariation(flavour, numVariation,up,down);
869 cerr <<
"Eigenvector object is there but cannot retrieve up and down uncertainty histograms." << endl;
873 extrapolate =
GEV->isExtrapolationVariation(numVariation, flavour);
875 std::cerr <<
"ERROR: you requested " << unc <<
" but that isn't in the set of (SFEigen, SFGlobalEigen, SFNamed) for eigenvariations. " << std::endl;
897 result.first = MCMCSF*valueUp;
898 result.second = MCMCSF*valueDown;
914 cerr <<
"getScaleFactor: error retrieving result in non-EV context!" << endl;
933 cerr <<
"getScaleFactor: error retrieving Scale factor parameter covariance matrix!" << endl;
940 if (container->getSystUncertainty(variables, resSyst) ==
Analysis::kError) {
941 cerr <<
"getScaleFactor: error retrieving Scale factor parameter systematic uncertainty!" << endl;
946 if (container->getUncertainty(
"extrapolation", variables, resSyst) ==
Analysis::kError)
947 cerr <<
"getScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
951 if (container->getUncertainty(
"extrapolation from charm", variables, resSyst) ==
Analysis::kError)
952 cerr <<
"getScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
956 result.first = MCMCSF*value;
957 result.second = MCMCSF*uncertainty;
968 const string&
label,
const string& OP,
983 cerr <<
"getMCEfficiency: unable to find Eff calibration for object " <<
fullName(variables.jetAuthor, OP,
label,
false, mapIndex) << endl;
1031 cerr <<
"Jet |eta| is outside of the boundary!" << endl;
1050 cerr <<
"getMCEfficiency: error retrieving MC efficiency parameter covariance matrix!" << endl;
1064 double uncertainty = stat;
1065 result.first = std::max(0., std::min(1., value));
1066 result.second = uncertainty;
1076 const string&
label,
1077 const string& OP,
Uncertainty unc,
const std::string& flavour,
1078 unsigned int numVariation,
unsigned int mapIndex)
1093 unsigned int indexSF, indexEff;
1096 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;
1108 unsigned int indexSF,
unsigned int indexEff,
1109 Uncertainty unc,
const std::string& flavour,
unsigned int numVariation)
1131 unsigned int indexSF,
unsigned int indexEff,
1153 double relative = 0;
1154 double value = effResult.first;
1156 value = std::min(effResult.first*sfResult.first, 1.);
1161 double valueDown = effResult.first*sfResult.second;
1162 result.first = value;
1163 result.second = valueDown;
1167 relative = effResult.second/effResult.first;
1168 double sfRelative = sfResult.second/sfResult.first;
1173 relative = TMath::Sqrt(sfRelative*sfRelative + relative*relative);
1177 cerr <<
"ERROR: CalibrationDataInterfaceROOT::getEfficiency: SF null result, SF=" << sfResult.first <<
" MC eff=" << effResult.first <<
"; setting SF=1." << endl;
1181 result.first = value;
1182 result.second = value*relative;
1191 const string&
label,
1193 unsigned int numVariation,
unsigned int mapIndex)
1209 unsigned int indexSF, indexEff;
1212 cerr <<
"getInefficiencyScaleFactor: unable to find Eff calibration for object "
1213 <<
fullName(variables.jetAuthor, OP,
label,
false, mapIndex)
1214 <<
" or SF calibration for object "
1228 unsigned int indexSF,
unsigned int indexEff,
1229 Uncertainty unc,
const std::string& flavour,
unsigned int numVariation)
1252 unsigned int indexSF,
unsigned int indexEff,
1276 double eff = std::min(effResult.first, 1.);
1278 double sf = sfResult.first;
1279 double sferr = sfResult.second;
1285 val = std::max((1. - eff*sf),
CalibZERO) / (1. - eff);
1289 double valDown = std::max((1. - eff*sferr),
CalibZERO) / (1. - eff);
1291 result.second = valDown;
1297 err = pow(eff*sferr, 2);
1299 err = 1./(1. - eff) * TMath::Sqrt(err);
1303 result.first = std::max(
CalibZERO, val);
1304 result.second = err;
1312 const string&
label,
1314 unsigned int numVariation,
unsigned int mapIndex)
1330 unsigned int indexSF, indexEff;
1333 cerr <<
"getInefficiency: unable to find Eff calibration for object "
1334 <<
fullName(variables.jetAuthor, OP,
label,
false, mapIndex)
1335 <<
" or SF calibration for object "
1349 unsigned int indexSF,
unsigned int indexEff,
1350 Uncertainty unc,
const std::string& flavour,
unsigned int numVariation)
1373 unsigned int indexSF,
unsigned int indexEff,
1397 double val = std::max(0., 1. - effResult.first * sfResult.first);
1401 if (effResult.first <= 0. || sfResult.first <= 0.)
return Analysis::kError;
1406 double valDown = std::max(0., 1. - effResult.first*sfResult.second);
1409 result.second = valDown;
1412 err = effResult.second/effResult.first*effResult.second/effResult.first
1413 + sfResult.second/sfResult.first*sfResult.second/sfResult.first;
1414 err = val*TMath::Sqrt(err);
1416 result.first = std::max(0., std::min(1., val));
1417 result.second = err;
1427 const string&
label,
const string& OP,
1444 return std::make_pair(std::max(0., 1. - effResult.first), effResult.second);
1464 return std::make_pair(std::max(0., 1. - effResult.first), effResult.second);
1470 unsigned indexSF,
unsigned int indexEff)
const
1479 if (indexSFRef < 0 || indexEffRef < 0 || indexSFRef == indexEffRef)
return 1;
1482 double effSFRef;
m_objects[indexSFRef]->getResult(variables, effSFRef);
1483 double effEffRef;
m_objects[indexEffRef]->getResult(variables, effEffRef);
1484 return (effSFRef > 0 && effEffRef > 0) ? effSFRef/effEffRef : 1;
1491 unsigned int numVariation,
unsigned int mapIndex)
1509 static const string cont(
"Continuous");
1511 unsigned int indexSF, indexEff;
1514 cerr <<
"getWeightScaleFactor: unable to find Eff calibration for object "
1515 <<
fullName(variables.jetAuthor, cont,
label,
false, mapIndex)
1516 <<
" or SF calibration for object "
1517 <<
fullName(variables.jetAuthor, cont,
label,
true) << endl;
1528 unsigned int indexSF,
unsigned int indexEff,
1555 unsigned int indexSF,
unsigned int indexEff,
1587 cerr <<
"Jet |eta| is outside of the boundary!" << endl;
1606 if (container->getUncertainty(
"MCreference", variables, refMCResult) ==
Analysis::kError)
1608 double fracMCref = refMCResult.first;
1611 double fracSFref = fracMCref, fracEffref = fracMCref;
1614 if (indexSFref < 0 || indexEffref < 0) {
1615 cerr <<
"getWeightScaleFactor: error: generator-specific corrections requested but necessary reference containers lacking " << endl;
1618 m_objects[indexSFref]->getResult(variables, fracSFref);
1619 m_objects[indexEffref]->getResult(variables, fracEffref);
1620 if (! (fracSFref > 0. && fracEffref > 0.)) {
1621 cerr <<
"getWeightScaleFactor: error: invalid reference tag weight fraction " <<fracSFref <<
" " <<fracEffref << std::endl;
1636 cerr <<
"getWeightScaleFactor: error: null fracMCnew would lead to invalid operation" << endl;
1641 cerr <<
"getWeightScaleFactor: ERROR. Trying to call eigenvector method but initialization not switched on in b-tagging .env config file." << endl;
1642 cerr <<
" Please correct your .env config file first. Nominal uncertainties used. " << endl;
1646 std::shared_ptr<CalibrationDataEigenVariations> eigenVariation;
1649 }
catch (
const std::out_of_range&) {
1650 cerr <<
"getWeightScaleFactor: could not retrieve eigenvector variation, while it should have been there." << endl;
1653 unsigned int maxVariations = (unc ==
SFEigen) ? eigenVariation->getNumberOfEigenVariations() : eigenVariation->getNumberOfNamedVariations();
1654 if (numVariation > maxVariations-1) {
1655 cerr <<
"getWeightScaleFactor: asked for " << ((unc ==
SFEigen) ?
"eigenvariation" :
"named variation") <<
" number: " << numVariation <<
" but overall number of available variations is: " << maxVariations << endl;
1660 bool isOK = (unc ==
SFEigen) ? eigenVariation->getEigenvectorVariation(numVariation,up,down) : eigenVariation->getNamedVariation(numVariation,up,down);
1662 cerr <<
"getWeightScaleFactor: Eigenvector object is there but cannot retrieve up and down uncertainty histograms." << endl;
1666 bool extrapolate = ( unc ==
SFNamed ) ? eigenVariation->isExtrapolationVariation(numVariation) :
false;
1675 double variationUp = valueUp - value;
1676 double variationDown = valueDown - value;
1680 if (
m_useMCMCSF) value *= (fracSFref / fracEffref);
1685 double f = (fracMCref / fracMCnew);
1689 double f = (fracSFref / fracEffref);
1693 valueUp = value + variationUp;
1694 valueDown = value + variationDown;
1700 if (valueDown < 0) {
1706 result.first = valueUp;
1707 result.second = valueDown;
1717 cerr <<
"getWeightScaleFactor: error retrieving Scale factor parameter covariance matrix!" << endl;
1723 if (container->getSystUncertainty(variables, uncertaintyResult) ==
Analysis::kError) {
1724 cerr <<
"getWeightScaleFactor: error retrieving Scale factor parameter systematic uncertainty!" << endl;
1729 if (container->getUncertainty(
"extrapolation", variables, uncertaintyResult) ==
Analysis::kError)
1730 cerr <<
"getWeightScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
1734 if (container->getUncertainty(
"extrapolation from charm", variables, uncertaintyResult) ==
Analysis::kError)
1735 cerr <<
"getWeightScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
1744 if (
m_useMCMCSF) value *= (fracSFref / fracEffref);
1754 uncertainty *= (fracMCref / fracMCnew);
1756 uncertainty *= (fracSFref / fracEffref);
1759 result.first = std::max(0., value);
1760 result.second = uncertainty;
1768 unsigned int indexEff)
1784 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: error: container for object " <<
nameFromIndex(indexSF) <<
" not found!" << endl;
1786 }
else if (! container->GetValue(
"MCreference")) {
1787 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: error: no MCreference histogram for object " <<
nameFromIndex(indexSF) <<
"!" << endl;
1791 if (! effContainer) {
1792 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: error: container for object " <<
nameFromIndex(indexEff) <<
" not found!" << endl;
1797 std::vector<unsigned int> vars = container->getVariableTypes();
1800 std::map<unsigned int, std::vector<double> > boundaries, effBoundaries, mergedBoundaries;
1801 for (
unsigned int t = 0; t < vars.size(); ++t)
1802 boundaries[vars[t]] = container->getBinBoundaries(vars[t]);
1803 for (
unsigned int t = 0; t < effVars.size(); ++t)
1818 if (v[0] < 0 && vEff[0] >= 0) {
1820 std::vector<double> vtmp(vEff);
1821 for (std::vector<double>::iterator it = vtmp.begin(); it != vtmp.end(); ++it)
1822 if (*it > 0) vEff.insert(vEff.begin(), -(*it));
1823 }
else if (v[0] >= 0 && vEff[0] < 0) {
1825 std::vector<double> vtmp(v);
1826 for (std::vector<double>::iterator it = vtmp.begin(); it != vtmp.end(); ++it)
1827 if (*it > 0) v.insert(v.begin(), -(*it));
1832 for (
unsigned int t = 0; t < vars.size(); ++t) {
1833 if (effBoundaries.find(vars[t]) == effBoundaries.end())
1835 mergedBoundaries[vars[t]] = boundaries[vars[t]];
1839 mergedBoundaries[vars[t]] = effBoundaries[vars[t]];
1841 for (std::vector<double>::iterator it = boundaries[vars[t]].begin(); it != boundaries[vars[t]].end(); ++it) {
1842 std::vector<double>::iterator itcmp = mergedBoundaries[vars[t]].begin();
1845 while (itcmp != mergedBoundaries[vars[t]].end() &&
1847 *itcmp < *it) ++itcmp;
1852 mergedBoundaries[vars[t]].insert(itcmp, *it);
1857 for (
unsigned int t = 0; t < effVars.size(); ++t)
1858 if (boundaries.find(effVars[t]) == boundaries.end())
1859 mergedBoundaries[effVars[t]] = effBoundaries[effVars[t]];
1864 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: " <<
"no tag weight axis found for object " <<
nameFromIndex(indexSF) << endl;
1866 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: " <<
"no tag weight axis found for object " <<
nameFromIndex(indexEff) << endl;
1868 cerr <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: " <<
"different tag weight binning for objects " <<
nameFromIndex(indexSF) <<
" (";
1870 for (
unsigned int ib = 0; ib < v.size()-1; ++ib) cerr << v[ib] <<
",";
1871 cerr << v[v.size()-1] <<
") and " <<
nameFromIndex(indexEff) <<
" (";
1873 for (
unsigned int ib = 0; ib < v.size()-1; ++ib) cerr << v[ib] <<
",";
1874 cerr << v[v.size()-1] <<
") do not match!" << endl;
1884 cout <<
"CalibrationDataInterfaceROOT::checkWeightScaleFactors: cross-checking scale factors for objects " <<
nameFromIndex(indexSF) <<
" and " <<
nameFromIndex(indexEff) <<
"\n" << std::setfill(
'-') << std::setw(100) <<
"-" << endl;
1885 cout << std::setfill(
' ');
1889 const std::string mcRefStr{
"MCreference"};
1890 for (
unsigned int ipt = 0; ipt < vPt.size()-1; ++ipt) {
1891 x.jetPt = (vPt[ipt] + vPt[ipt+1]) * 500.;
1892 for (
unsigned int ieta = 0; ieta < vEta.size()-1; ++ieta) {
1893 x.jetEta = (vEta[ieta] + vEta[ieta+1]) / 2.;
1894 for (
unsigned int iwt = 0; iwt < vTagWeight.size()-1; ++iwt) {
1895 x.jetTagWeight = (vTagWeight[iwt] + vTagWeight[iwt+1]) / 2.;
1898 container->getResult(
x, value);
1900 container->getUncertainty(mcRefStr,
x, uncertaintyResult);
1901 double fracMCref = uncertaintyResult.first;
1905 if (!(fracMCnew > 0.)) {
1906 cout <<
"\tfor (pt=" <<
x.jetPt <<
",eta=" <<
x.jetEta <<
",tagweight=" <<
x.jetTagWeight <<
"): invalid new MC fraction: " << fracMCnew << endl;
1908 double newvalue = 1.0 + (value - 1.0) * fracMCref/fracMCnew;
1909 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;
1951 for (std::map<std::string, unsigned int>::const_iterator it =
m_objectIndices.begin();
1953 if (it->second ==
index)
return it->first;
1971 unsigned int minsize = (
index == 0) ? 2 : 2*
index;
1990 const string&
label,
2008 cerr <<
"listScaleFactorUncertainties: unable to find SF calibration for object " <<
fullName(author, OP,
label,
true) << endl;
2009 std::vector<string> dummy;
2018 const std::string& flavour,
bool named)
2031 std::vector<string> dummy;
2038 std::shared_ptr<CalibrationDataEigenVariations> eigenVariation=
m_eigenVariationsMap.at(container);
2040 std::vector<string> unordered = eigenVariation->listNamedVariations();
2041 std::vector<string> ordered(unordered.size());
2042 for (
unsigned int i = 0; i < unordered.size(); ++i) {
2043 ordered[eigenVariation->getNamedVariationIndex(unordered[i])] = unordered[i];
2046 }
else if (
m_EVStrategy == Analysis::Uncertainty::SFGlobalEigen){
2048 std::shared_ptr<CalibrationDataGlobalEigenVariations>
GEV = std::dynamic_pointer_cast<CalibrationDataGlobalEigenVariations>(eigenVariation);
2049 std::vector<std::string> unordered =
GEV->listNamedVariations(flavour);
2050 std::vector<std::string> ordered(unordered.size());
2051 for (
unsigned int i = 0; i < unordered.size(); ++i) {
2052 ordered[
GEV->getNamedVariationIndex(unordered[i], flavour)] = unordered[i];
2057 return container->listUncertainties();
2066 const std::string&
label,
2067 const std::string& OP,
2099 if (! container)
return 0;
2100 std::shared_ptr<CalibrationDataEigenVariations> eigenVariation=
m_eigenVariationsMap.at(container);
2102 std::shared_ptr<CalibrationDataGlobalEigenVariations>
GEV = std::dynamic_pointer_cast<CalibrationDataGlobalEigenVariations>(eigenVariation);
2103 return GEV->getNumberOfEigenVariations(flavour);
2105 return (unc ==
SFEigen) ? eigenVariation->getNumberOfEigenVariations() : eigenVariation->getNumberOfNamedVariations();
2111 const std::string&
label,
2112 const std::string& OP)
2123 cerr <<
"getBinnedScaleFactors: unable to find SF calibration for object " <<
fullName(author, OP,
label,
true) << endl;
2127 return (container) ?
dynamic_cast<TH1*
>(container->GetValue(
"result")) : 0;
2133 const std::string&
label,
2134 const std::string& OP,
2135 unsigned int mapIndex)
2148 cerr <<
"getMCEfficiencyObject: unable to find efficiency calibration for object "
2153 return (container) ? container->GetValue(
"result") : 0;
2161 const std::string&
label,
2162 const std::string& OP,
2163 const std::string& unc,
2177 if (unc ==
"comment" || unc ==
"result" || unc ==
"combined" || unc ==
"statistics")
return 0;
2182 cerr <<
"getShiftedScaleFactors: unable to find SF calibration for object " <<
fullName(author, OP,
label,
true) << endl;
2186 if (! container)
return nullptr;
2188 TH1* result =
dynamic_cast<TH1*
>(container->GetValue(
"result"));
2189 TH1* hunc =
dynamic_cast<TH1*
>(container->GetValue(unc.c_str()));
2191 if ((! hunc) || (! result))
return nullptr;
2192 if (hunc->GetDimension() != result->GetDimension() || hunc->GetNbinsX() != result->GetNbinsX() ||
2193 hunc->GetNbinsX() != result->GetNbinsX() || hunc->GetNbinsX() != result->GetNbinsX())
2198 if (! container->isBinCorrelated(unc))
return 0;
2201 std::string name(container->GetName()); name +=
"_"; name += unc; name +=
"_";
2202 TH1* shifted =
dynamic_cast<TH1*
>(result->Clone(name.c_str()));
2203 if (not shifted)
return nullptr;
2204 shifted->Add(hunc, sigmas);
2210 const std::string&
label,
2211 const std::string& OP,
2212 unsigned int mapIndex){
2223 cerr <<
"runEigenVectorRecomposition: Recomposition need to be ran with CalibrationDataInterfaceRoot initialized in eigenvector mode" << endl;
2227 unsigned int indexSF;
2229 cerr <<
"runEigenVectorRecomposition: unable to find SF calibration for object "
2239 unsigned int indexSF){
2247 cerr <<
"runEigenVectorRecomposition: error retrieving container!" << endl;
2252 std::shared_ptr<CalibrationDataEigenVariations> eigenVariation;
2255 }
catch (
const std::out_of_range&) {
2256 cerr <<
"runEigenVectorRecomposition: Could not retrieve eigenvector variation, while it should have been there." << endl;
2260 std::map<std::string, std::map<std::string, float>> coefficientMap;
2261 if(!eigenVariation->EigenVectorRecomposition(
label, coefficientMap))
2268std::map<std::string, std::map<std::string, float>>
2271 cerr <<
"getCoefficientMap: Call runEigenVectorRecomposition() before retrieving coefficient map! " <<endl;
2280 TMatrixDSym getStatCovarianceMatrix(
const TH1* hist) {
2281 Int_t nbinx = hist->GetNbinsX()+2, nbiny = hist->GetNbinsY()+2, nbinz = hist->GetNbinsZ()+2;
2283 if (hist->GetDimension() > 1) rows *= nbiny;
2284 if (hist->GetDimension() > 2) rows *= nbinz;
2285 TMatrixDSym stat(rows);
2286 for (Int_t binx = 1; binx < nbinx; ++binx){
2287 for (Int_t biny = 1; biny < nbiny; ++biny){
2288 for (Int_t binz = 1; binz < nbinz; ++binz) {
2289 Int_t
bin = hist->GetBin(binx, biny, binz);
2290 double err = hist->GetBinError(
bin);
2291 stat(
bin,
bin) = err*err;
2301 TMatrixDSym getSystCovarianceMatrix(
const TH1*
ref,
const TH1* unc,
bool doCorrelated,
const std::string& uncname,
int tagWeightAxis) {
2302 Int_t nbinx =
ref->GetNbinsX()+2, nbiny =
ref->GetNbinsY()+2, nbinz =
ref->GetNbinsZ()+2;
2304 if (
ref->GetDimension() > 1)
rows *= nbiny;
2305 if (
ref->GetDimension() > 2)
rows *= nbinz;
2306 TMatrixDSym
cov(rows);
2308 for(
int i=0 ;
i<10 ;
i++){
2309 Int_t
bin = unc->GetBin(1,i,1);
2310 double uncval = unc->GetBinContent(bin);
2311 cout << uncval <<
", ";
2315 if (unc->GetNbinsX()+2 != nbinx || unc->GetNbinsY()+2 != nbiny || unc->GetNbinsZ()+2 != nbinz || unc->GetDimension() !=
ref->GetDimension()) {
2316 std::cout <<
"getSystCovarianceMatrix: inconsistency found in histograms " <<
ref->GetName() <<
" and " << unc->GetName() <<
" : " << uncname << std::endl;
2327 if (! doCorrelated) {
2328 if (tagWeightAxis < 0) {
2330 for (Int_t binx = 1; binx < nbinx-1; ++binx){
2331 for (Int_t biny = 1; biny < nbiny-1; ++biny){
2332 for (Int_t binz = 1; binz < nbinz-1; ++binz) {
2333 Int_t
bin =
ref->GetBin(binx, biny, binz);
2334 double err = unc->GetBinContent(bin);
2340 }
else if (tagWeightAxis == 0) {
2342 for (Int_t biny = 1; biny < nbiny-1; ++biny){
2343 for (Int_t binz = 1; binz < nbinz-1; ++binz){
2344 for (Int_t binx = 1; binx < nbinx-1; ++binx) {
2345 Int_t
bin =
ref->GetBin(binx, biny, binz);
2346 double err = unc->GetBinContent(bin);
2347 for (Int_t binx2 = 1; binx2 < nbinx-1; ++binx2) {
2348 Int_t
bin2 =
ref->GetBin(binx2, biny, binz);
2349 double err2 = unc->GetBinContent(bin2);
2350 cov(bin,bin2) =
err*err2;
2356 }
else if (tagWeightAxis == 1) {
2358 for (Int_t binx = 1; binx < nbinx-1; ++binx){
2359 for (Int_t binz = 1; binz < nbinz-1; ++binz){
2360 for (Int_t biny = 1; biny < nbiny-1; ++biny) {
2361 Int_t
bin =
ref->GetBin(binx, biny, binz);
2362 double err = unc->GetBinContent(bin);
2363 for (Int_t biny2 = 1; biny2 < nbiny-1; ++biny2) {
2364 Int_t
bin2 =
ref->GetBin(binx, biny2, binz);
2365 double err2 = unc->GetBinContent(bin2);
2366 cov(bin,bin2) =
err*err2;
2372 }
else if (tagWeightAxis == 2) {
2374 for (Int_t binx = 1; binx < nbinx-1; ++binx){
2375 for (Int_t biny = 1; biny < nbiny-1; ++biny){
2376 for (Int_t binz = 1; binz < nbinz-1; ++binz) {
2377 Int_t
bin =
ref->GetBin(binx, biny, binz);
2378 double err = unc->GetBinContent(bin);
2379 for (Int_t binz2 = 1; binz2 < nbinz-1; ++binz2) {
2380 Int_t
bin2 =
ref->GetBin(binx, biny, binz2);
2381 double err2 = unc->GetBinContent(bin2);
2382 cov(bin,bin2) =
err*err2;
2391 for (Int_t binx = 1; binx < nbinx-1; ++binx){
2392 for (Int_t biny = 1; biny < nbiny-1; ++biny){
2393 for (Int_t binz = 1; binz < nbinz-1; ++binz) {
2394 Int_t
bin =
ref->GetBin(binx, biny, binz);
2395 double err = unc->GetBinContent(bin);
2396 for (Int_t binx2 = 1; binx2 < nbinx-1; ++binx2){
2397 for (Int_t biny2 = 1; biny2 < nbiny-1; ++biny2){
2398 for (Int_t binz2 = 1; binz2 < nbinz-1; ++binz2) {
2399 Int_t
bin2 =
ref->GetBin(binx2, biny2, binz2);
2400 double err2 = unc->GetBinContent(bin2);
2401 cov(bin, bin2) =
err*err2;
2418 const std::string&
label,
2419 const std::string& OP,
2420 const std::string& unc)
2432 if (unc ==
"comment" || unc ==
"result" || unc ==
"combined")
return dummy;
2437 cerr <<
"getScaleFactorCovarianceMatrix: unable to find SF calibration for object " <<
fullName(author, OP,
label,
true) << endl;
2441 if (!container)
return dummy;
2444 TH1* result =
dynamic_cast<TH1*
>(container->GetValue(
"result"));
2445 if (! result)
return dummy;
2448 if (unc ==
"statistics") {
2449 return getStatCovarianceMatrix(result);
2451 TH1* hunc =
dynamic_cast<TH1*
>(container->GetValue(unc.c_str()));
2453 cout <<
"getScaleFactorCovarianceMatrix: no uncertainty object found "
2454 <<
"corresponding to name " << unc << endl;
2457 return getSystCovarianceMatrix(result, hunc, container->isBinCorrelated(unc), unc, container->getTagWeightAxis());
2464 TMatrixDSym cov = getStatCovarianceMatrix(result);
2467 std::vector<string> uncs = container->listUncertainties();
2468 for (
unsigned int t = 0; t < uncs.size(); ++t) {
2469 if (uncs[t] ==
"comment" || uncs[t] ==
"result" || uncs[t] ==
"combined" ||
2470 uncs[t] ==
"statistics" || uncs[t]==
"extrapolation" || uncs[t]==
"MChadronisation" ||
2471 uncs[t]==
"ReducedSets" || uncs[t]==
"systematics")
continue;
2472 TH1* hunc =
dynamic_cast<TH1*
>(container->GetValue(uncs[t].c_str()));
2474 std::cerr<<
"Analysis::CalibrationDataInterfaceROOT::getScaleFactorCovarianceMatrix : dynamic cast failed\n";
2477 TMatrixDSym syst_cov = getSystCovarianceMatrix(result, hunc, container->isBinCorrelated(uncs[t]), uncs[t], container->getTagWeightAxis());
2492 cerr <<
"initialize can only be called once per CalibrationDataInterfaceROOT object" << endl;
2495 cout <<
"initializing BTagCalibrationDataInterfaceROOT for PROOF with jetAuthor = " << jetauthor <<
", tagger = " <<
m_taggerName <<
", operating point = " << OP <<
", uncertainty = " << unc << endl;
2499 BTagVars.jetAuthor = jetauthor;
2500 BTagVars.jetPt = 100000.;
2501 BTagVars.jetEta = 1.5;
2504 std::pair<double, double> BTagCalibResult;
2506 std::cout <<
"CalibrationDataInterfaceROOT->initialize : BTagCalibResult " << std::endl;
2508 std::pair<double, double> BTagCalibMCEff;
2510 std::cout <<
"CalibrationDataInterfaceROOT->initialize : BTagCalibMCEff " << std::endl;
2541 string name = dir +
"/" + cntname;
2558 cerr <<
"btag Calib: retrieveContainer: failed to retrieve container named " << name <<
" from file" << endl;
2564 cout <<
"CalibrationDataInterface: retrieved container " << name <<
" (with comment: '" << cnt->getComment() <<
"' and hadronisation setting '" << cnt->getHadronisation() <<
"')" << endl;
2591 string spec = cnt->getHadronisation();
2593 std::map<string, HadronisationReferenceHelper*>::const_iterator mapit =
m_refMap.find(dir);
2596 if (mapit->second->getReference(spec,
ref)) {
2602 string refname(dir +
"/" +
ref);
2603 std::map<string, unsigned int>::const_iterator it =
m_objectIndices.find(refname);
2615 cerr <<
"btag Calib: retrieveContainer: MC hadronisation reference map not found -- this should not happen!" << endl;
2622 cerr <<
"btag Calib: retrieveContainer: warning: unable to apply MC/MC scale factors for container " << name <<
" with hadronisation reference = '" << spec <<
"'" << endl;
2636 if (histoContainer==0) {
2637 cerr <<
"Could not cast Container to a HistogramContainer. " << endl;
2643 newEigenVariation->setVerbose(
m_verbose);
2647 string flavour = dir.substr(dir.find_last_of(
"/")+1);
2650 newEigenVariation->excludeNamedUncertainty(entry, cnt);
2652 newEigenVariation->initialize();
2654 if (to_retain > -1) {
2655 if (
m_verbose) cout <<
"btag Calib: reducing number of eigenvector variations for flavour " << flavour <<
" to " << to_retain << endl;
2657 newEigenVariation->mergeVariationsFrom(
size_t(to_retain-1));
2659 cerr <<
"btag Calib: unable to retrieve eigenvector reduction information for flavour " << flavour <<
" and scheme " <<
m_EVReductions[flavour] <<
"; not applying any reduction" << endl;
2664 }
else if (
m_EVStrategy == Analysis::Uncertainty::SFGlobalEigen) {
2677 newEigenVariation->excludeNamedUncertainty(entry,
label);
2680 newEigenVariation->initialize();
2685 if (to_retain > -1) {
2686 if (
m_verbose) cout <<
"btag Calib: reducing number of eigenvector variations for flavour " << flavour <<
" to " << to_retain << endl;
2688 newEigenVariation->mergeVariationsFrom(
size_t(to_retain-1), flavour);
2690 cerr <<
"btag Calib: unable to retrieve eigenvector reduction information for flavour " << flavour <<
" and scheme " <<
m_EVReductions[flavour] <<
"; not applying any reduction" << endl;
2699 std::shared_ptr<CalibrationDataEigenVariations> previous_eigenvariation =
m_eigenVariationsMap.begin()->second;
2704 std::cout <<
"CalibrationDataInterfaceROOT->retrieveContainer : the CDGEV object for " << name <<
" already exists! " << std::endl;
2720 std::map<string,string>::const_iterator it =
m_aliases.find(author);
2721 return (it ==
m_aliases.end()) ? author : it->second;
2727 const string&
label,
bool isSF,
2728 unsigned mapIndex)
const
2738 string flavour = (
label ==
"N/A") ?
"Light" :
label;
2761 TMapIter next(mapSF); TObjString* spec;
2762 while ((spec = (TObjString*) next())) {
2763 TObjString*
ref = (TObjString*) mapSF->GetValue(spec);
2764 m_refs[string(spec->GetName())] = string(
ref->GetName());
2771 TMapIter next(mapEff); TObjString* spec;
2772 while ((spec = (TObjString*) next())) {
2773 TObjString*
ref = (TObjString*) mapEff->GetValue(spec);
2774 m_refs[string(spec->GetName())] = string(
ref->GetName());
2790 std::map<string, string>::const_iterator it =
m_refs.find(spec);
2791 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,...
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 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