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;
941 cerr <<
"getScaleFactor: error retrieving Scale factor parameter systematic uncertainty!" << endl;
947 cerr <<
"getScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
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;
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;
1724 cerr <<
"getWeightScaleFactor: error retrieving Scale factor parameter systematic uncertainty!" << endl;
1730 cerr <<
"getWeightScaleFactor: error retrieving Scale factor parameter extrapolation uncertainty!" << endl;
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;
1800 std::map<unsigned int, std::vector<double> > boundaries, effBoundaries, mergedBoundaries;
1801 for (
unsigned int t = 0; t < vars.size(); ++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 for (
unsigned int ipt = 0; ipt < vPt.size()-1; ++ipt) {
1890 x.jetPt = (vPt[ipt] + vPt[ipt+1]) * 500.;
1891 for (
unsigned int ieta = 0; ieta < vEta.size()-1; ++ieta) {
1892 x.jetEta = (vEta[ieta] + vEta[ieta+1]) / 2.;
1893 for (
unsigned int iwt = 0; iwt < vTagWeight.size()-1; ++iwt) {
1894 x.jetTagWeight = (vTagWeight[iwt] + vTagWeight[iwt+1]) / 2.;
1900 double fracMCref = uncertaintyResult.first;
1904 if (!(fracMCnew > 0.)) {
1905 cout <<
"\tfor (pt=" <<
x.jetPt <<
",eta=" <<
x.jetEta <<
",tagweight=" <<
x.jetTagWeight <<
"): invalid new MC fraction: " << fracMCnew << endl;
1907 double newvalue = 1.0 + (value - 1.0) * fracMCref/fracMCnew;
1908 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;
1950 for (std::map<std::string, unsigned int>::const_iterator it =
m_objectIndices.begin();
1952 if (it->second ==
index)
return it->first;
1970 unsigned int minsize = (
index == 0) ? 2 : 2*
index;
1989 const string&
label,
2007 cerr <<
"listScaleFactorUncertainties: unable to find SF calibration for object " <<
fullName(author, OP,
label,
true) << endl;
2008 std::vector<string> dummy;
2017 const std::string& flavour,
bool named)
2030 std::vector<string> dummy;
2037 std::shared_ptr<CalibrationDataEigenVariations> eigenVariation=
m_eigenVariationsMap.at(container);
2039 std::vector<string> unordered = eigenVariation->listNamedVariations();
2040 std::vector<string> ordered(unordered.size());
2041 for (
unsigned int i = 0; i < unordered.size(); ++i) {
2042 ordered[eigenVariation->getNamedVariationIndex(unordered[i])] = unordered[i];
2045 }
else if (
m_EVStrategy == Analysis::Uncertainty::SFGlobalEigen){
2047 std::shared_ptr<CalibrationDataGlobalEigenVariations>
GEV = std::dynamic_pointer_cast<CalibrationDataGlobalEigenVariations>(eigenVariation);
2048 std::vector<std::string> unordered =
GEV->listNamedVariations(flavour);
2049 std::vector<std::string> ordered(unordered.size());
2050 for (
unsigned int i = 0; i < unordered.size(); ++i) {
2051 ordered[
GEV->getNamedVariationIndex(unordered[i], flavour)] = unordered[i];
2065 const std::string&
label,
2066 const std::string& OP,
2098 if (! container)
return 0;
2099 std::shared_ptr<CalibrationDataEigenVariations> eigenVariation=
m_eigenVariationsMap.at(container);
2101 std::shared_ptr<CalibrationDataGlobalEigenVariations>
GEV = std::dynamic_pointer_cast<CalibrationDataGlobalEigenVariations>(eigenVariation);
2102 return GEV->getNumberOfEigenVariations(flavour);
2104 return (unc ==
SFEigen) ? eigenVariation->getNumberOfEigenVariations() : eigenVariation->getNumberOfNamedVariations();
2110 const std::string&
label,
2111 const std::string& OP)
2122 cerr <<
"getBinnedScaleFactors: unable to find SF calibration for object " <<
fullName(author, OP,
label,
true) << endl;
2126 return (container) ?
dynamic_cast<TH1*
>(container->GetValue(
"result")) : 0;
2132 const std::string&
label,
2133 const std::string& OP,
2134 unsigned int mapIndex)
2147 cerr <<
"getMCEfficiencyObject: unable to find efficiency calibration for object "
2152 return (container) ? container->GetValue(
"result") : 0;
2160 const std::string&
label,
2161 const std::string& OP,
2162 const std::string& unc,
2176 if (unc ==
"comment" || unc ==
"result" || unc ==
"combined" || unc ==
"statistics")
return 0;
2181 cerr <<
"getShiftedScaleFactors: unable to find SF calibration for object " <<
fullName(author, OP,
label,
true) << endl;
2185 if (! container)
return nullptr;
2187 TH1* result =
dynamic_cast<TH1*
>(container->GetValue(
"result"));
2188 TH1* hunc =
dynamic_cast<TH1*
>(container->GetValue(unc.c_str()));
2190 if ((! hunc) || (! result))
return nullptr;
2191 if (hunc->GetDimension() != result->GetDimension() || hunc->GetNbinsX() != result->GetNbinsX() ||
2192 hunc->GetNbinsX() != result->GetNbinsX() || hunc->GetNbinsX() != result->GetNbinsX())
2200 std::string name(container->GetName()); name +=
"_"; name += unc; name +=
"_";
2201 TH1* shifted =
dynamic_cast<TH1*
>(result->Clone(name.c_str()));
2202 if (not shifted)
return nullptr;
2203 shifted->Add(hunc, sigmas);
2209 const std::string&
label,
2210 const std::string& OP,
2211 unsigned int mapIndex){
2222 cerr <<
"runEigenVectorRecomposition: Recomposition need to be ran with CalibrationDataInterfaceRoot initialized in eigenvector mode" << endl;
2226 unsigned int indexSF;
2228 cerr <<
"runEigenVectorRecomposition: unable to find SF calibration for object "
2238 unsigned int indexSF){
2246 cerr <<
"runEigenVectorRecomposition: error retrieving container!" << endl;
2251 std::shared_ptr<CalibrationDataEigenVariations> eigenVariation;
2254 }
catch (
const std::out_of_range&) {
2255 cerr <<
"runEigenVectorRecomposition: Could not retrieve eigenvector variation, while it should have been there." << endl;
2259 std::map<std::string, std::map<std::string, float>> coefficientMap;
2260 if(!eigenVariation->EigenVectorRecomposition(
label, coefficientMap))
2267std::map<std::string, std::map<std::string, float>>
2270 cerr <<
"getCoefficientMap: Call runEigenVectorRecomposition() before retrieving coefficient map! " <<endl;
2279 TMatrixDSym getStatCovarianceMatrix(
const TH1* hist) {
2280 Int_t nbinx = hist->GetNbinsX()+2, nbiny = hist->GetNbinsY()+2, nbinz = hist->GetNbinsZ()+2;
2282 if (hist->GetDimension() > 1) rows *= nbiny;
2283 if (hist->GetDimension() > 2) rows *= nbinz;
2284 TMatrixDSym stat(rows);
2285 for (Int_t binx = 1; binx < nbinx; ++binx){
2286 for (Int_t biny = 1; biny < nbiny; ++biny){
2287 for (Int_t binz = 1; binz < nbinz; ++binz) {
2288 Int_t
bin = hist->GetBin(binx, biny, binz);
2289 double err = hist->GetBinError(
bin);
2290 stat(
bin,
bin) = err*err;
2300 TMatrixDSym getSystCovarianceMatrix(
const TH1*
ref,
const TH1* unc,
bool doCorrelated,
const std::string& uncname,
int tagWeightAxis) {
2301 Int_t nbinx =
ref->GetNbinsX()+2, nbiny =
ref->GetNbinsY()+2, nbinz =
ref->GetNbinsZ()+2;
2303 if (
ref->GetDimension() > 1)
rows *= nbiny;
2304 if (
ref->GetDimension() > 2)
rows *= nbinz;
2305 TMatrixDSym
cov(rows);
2307 for(
int i=0 ;
i<10 ;
i++){
2308 Int_t
bin = unc->GetBin(1,i,1);
2309 double uncval = unc->GetBinContent(bin);
2310 cout << uncval <<
", ";
2314 if (unc->GetNbinsX()+2 != nbinx || unc->GetNbinsY()+2 != nbiny || unc->GetNbinsZ()+2 != nbinz || unc->GetDimension() !=
ref->GetDimension()) {
2315 std::cout <<
"getSystCovarianceMatrix: inconsistency found in histograms " <<
ref->GetName() <<
" and " << unc->GetName() <<
" : " << uncname << std::endl;
2326 if (! doCorrelated) {
2327 if (tagWeightAxis < 0) {
2329 for (Int_t binx = 1; binx < nbinx-1; ++binx){
2330 for (Int_t biny = 1; biny < nbiny-1; ++biny){
2331 for (Int_t binz = 1; binz < nbinz-1; ++binz) {
2332 Int_t
bin =
ref->GetBin(binx, biny, binz);
2333 double err = unc->GetBinContent(bin);
2339 }
else if (tagWeightAxis == 0) {
2341 for (Int_t biny = 1; biny < nbiny-1; ++biny){
2342 for (Int_t binz = 1; binz < nbinz-1; ++binz){
2343 for (Int_t binx = 1; binx < nbinx-1; ++binx) {
2344 Int_t
bin =
ref->GetBin(binx, biny, binz);
2345 double err = unc->GetBinContent(bin);
2346 for (Int_t binx2 = 1; binx2 < nbinx-1; ++binx2) {
2347 Int_t
bin2 =
ref->GetBin(binx2, biny, binz);
2348 double err2 = unc->GetBinContent(bin2);
2349 cov(bin,bin2) =
err*err2;
2355 }
else if (tagWeightAxis == 1) {
2357 for (Int_t binx = 1; binx < nbinx-1; ++binx){
2358 for (Int_t binz = 1; binz < nbinz-1; ++binz){
2359 for (Int_t biny = 1; biny < nbiny-1; ++biny) {
2360 Int_t
bin =
ref->GetBin(binx, biny, binz);
2361 double err = unc->GetBinContent(bin);
2362 for (Int_t biny2 = 1; biny2 < nbiny-1; ++biny2) {
2363 Int_t
bin2 =
ref->GetBin(binx, biny2, binz);
2364 double err2 = unc->GetBinContent(bin2);
2365 cov(bin,bin2) =
err*err2;
2371 }
else if (tagWeightAxis == 2) {
2373 for (Int_t binx = 1; binx < nbinx-1; ++binx){
2374 for (Int_t biny = 1; biny < nbiny-1; ++biny){
2375 for (Int_t binz = 1; binz < nbinz-1; ++binz) {
2376 Int_t
bin =
ref->GetBin(binx, biny, binz);
2377 double err = unc->GetBinContent(bin);
2378 for (Int_t binz2 = 1; binz2 < nbinz-1; ++binz2) {
2379 Int_t
bin2 =
ref->GetBin(binx, biny, binz2);
2380 double err2 = unc->GetBinContent(bin2);
2381 cov(bin,bin2) =
err*err2;
2390 for (Int_t binx = 1; binx < nbinx-1; ++binx){
2391 for (Int_t biny = 1; biny < nbiny-1; ++biny){
2392 for (Int_t binz = 1; binz < nbinz-1; ++binz) {
2393 Int_t
bin =
ref->GetBin(binx, biny, binz);
2394 double err = unc->GetBinContent(bin);
2395 for (Int_t binx2 = 1; binx2 < nbinx-1; ++binx2){
2396 for (Int_t biny2 = 1; biny2 < nbiny-1; ++biny2){
2397 for (Int_t binz2 = 1; binz2 < nbinz-1; ++binz2) {
2398 Int_t
bin2 =
ref->GetBin(binx2, biny2, binz2);
2399 double err2 = unc->GetBinContent(bin2);
2400 cov(bin, bin2) =
err*err2;
2417 const std::string&
label,
2418 const std::string& OP,
2419 const std::string& unc)
2431 if (unc ==
"comment" || unc ==
"result" || unc ==
"combined")
return dummy;
2436 cerr <<
"getScaleFactorCovarianceMatrix: unable to find SF calibration for object " <<
fullName(author, OP,
label,
true) << endl;
2440 if (!container)
return dummy;
2443 TH1* result =
dynamic_cast<TH1*
>(container->GetValue(
"result"));
2444 if (! result)
return dummy;
2447 if (unc ==
"statistics") {
2448 return getStatCovarianceMatrix(result);
2450 TH1* hunc =
dynamic_cast<TH1*
>(container->GetValue(unc.c_str()));
2452 cout <<
"getScaleFactorCovarianceMatrix: no uncertainty object found "
2453 <<
"corresponding to name " << unc << endl;
2463 TMatrixDSym cov = getStatCovarianceMatrix(result);
2467 for (
unsigned int t = 0; t < uncs.size(); ++t) {
2468 if (uncs[t] ==
"comment" || uncs[t] ==
"result" || uncs[t] ==
"combined" ||
2469 uncs[t] ==
"statistics" || uncs[t]==
"extrapolation" || uncs[t]==
"MChadronisation" ||
2470 uncs[t]==
"ReducedSets" || uncs[t]==
"systematics")
continue;
2471 TH1* hunc =
dynamic_cast<TH1*
>(container->GetValue(uncs[t].c_str()));
2473 std::cerr<<
"Analysis::CalibrationDataInterfaceROOT::getScaleFactorCovarianceMatrix : dynamic cast failed\n";
2491 cerr <<
"initialize can only be called once per CalibrationDataInterfaceROOT object" << endl;
2494 cout <<
"initializing BTagCalibrationDataInterfaceROOT for PROOF with jetAuthor = " << jetauthor <<
", tagger = " <<
m_taggerName <<
", operating point = " << OP <<
", uncertainty = " << unc << endl;
2498 BTagVars.jetAuthor = jetauthor;
2499 BTagVars.jetPt = 100000.;
2500 BTagVars.jetEta = 1.5;
2503 std::pair<double, double> BTagCalibResult;
2505 std::cout <<
"CalibrationDataInterfaceROOT->initialize : BTagCalibResult " << std::endl;
2507 std::pair<double, double> BTagCalibMCEff;
2509 std::cout <<
"CalibrationDataInterfaceROOT->initialize : BTagCalibMCEff " << std::endl;
2540 string name = dir +
"/" + cntname;
2557 cerr <<
"btag Calib: retrieveContainer: failed to retrieve container named " << name <<
" from file" << endl;
2563 cout <<
"CalibrationDataInterface: retrieved container " << name <<
" (with comment: '" << cnt->getComment() <<
"' and hadronisation setting '" << cnt->getHadronisation() <<
"')" << endl;
2590 string spec = cnt->getHadronisation();
2592 std::map<string, HadronisationReferenceHelper*>::const_iterator mapit =
m_refMap.find(dir);
2595 if (mapit->second->getReference(spec,
ref)) {
2601 string refname(dir +
"/" +
ref);
2602 std::map<string, unsigned int>::const_iterator it =
m_objectIndices.find(refname);
2614 cerr <<
"btag Calib: retrieveContainer: MC hadronisation reference map not found -- this should not happen!" << endl;
2621 cerr <<
"btag Calib: retrieveContainer: warning: unable to apply MC/MC scale factors for container " << name <<
" with hadronisation reference = '" << spec <<
"'" << endl;
2635 if (histoContainer==0) {
2636 cerr <<
"Could not cast Container to a HistogramContainer. " << endl;
2642 newEigenVariation->setVerbose(
m_verbose);
2646 string flavour = dir.substr(dir.find_last_of(
"/")+1);
2649 newEigenVariation->excludeNamedUncertainty(entry, cnt);
2651 newEigenVariation->initialize();
2653 if (to_retain > -1) {
2654 if (
m_verbose) cout <<
"btag Calib: reducing number of eigenvector variations for flavour " << flavour <<
" to " << to_retain << endl;
2656 newEigenVariation->mergeVariationsFrom(
size_t(to_retain-1));
2658 cerr <<
"btag Calib: unable to retrieve eigenvector reduction information for flavour " << flavour <<
" and scheme " <<
m_EVReductions[flavour] <<
"; not applying any reduction" << endl;
2663 }
else if (
m_EVStrategy == Analysis::Uncertainty::SFGlobalEigen) {
2676 newEigenVariation->excludeNamedUncertainty(entry,
label);
2679 newEigenVariation->initialize();
2684 if (to_retain > -1) {
2685 if (
m_verbose) cout <<
"btag Calib: reducing number of eigenvector variations for flavour " << flavour <<
" to " << to_retain << endl;
2687 newEigenVariation->mergeVariationsFrom(
size_t(to_retain-1), flavour);
2689 cerr <<
"btag Calib: unable to retrieve eigenvector reduction information for flavour " << flavour <<
" and scheme " <<
m_EVReductions[flavour] <<
"; not applying any reduction" << endl;
2698 std::shared_ptr<CalibrationDataEigenVariations> previous_eigenvariation =
m_eigenVariationsMap.begin()->second;
2703 std::cout <<
"CalibrationDataInterfaceROOT->retrieveContainer : the CDGEV object for " << name <<
" already exists! " << std::endl;
2719 std::map<string,string>::const_iterator it =
m_aliases.find(author);
2720 return (it ==
m_aliases.end()) ? author : it->second;
2726 const string&
label,
bool isSF,
2727 unsigned mapIndex)
const
2737 string flavour = (
label ==
"N/A") ?
"Light" :
label;
2760 TMapIter next(mapSF); TObjString* spec;
2761 while ((spec = (TObjString*) next())) {
2762 TObjString*
ref = (TObjString*) mapSF->GetValue(spec);
2763 m_refs[string(spec->GetName())] = string(
ref->GetName());
2770 TMapIter next(mapEff); TObjString* spec;
2771 while ((spec = (TObjString*) next())) {
2772 TObjString*
ref = (TObjString*) mapEff->GetValue(spec);
2773 m_refs[string(spec->GetName())] = string(
ref->GetName());
2789 std::map<string, string>::const_iterator it =
m_refs.find(spec);
2790 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,...
This is the interface for the objects to be stored in the calibration ROOT file.
virtual CalibrationStatus getUncertainty(const std::string &unc, const CalibrationDataVariables &x, UncertaintyResult &result, TObject *obj=0)=0
retrieve the calibration uncertainty due to the given source.
virtual CalibrationStatus getStatUncertainty(const CalibrationDataVariables &x, double &result)=0
retrieve the calibration statistical uncertainty.
CalibrationStatus getSystUncertainty(const CalibrationDataVariables &x, UncertaintyResult &result, TObject *obj=0)
retrieve the calibration total systematic uncertainty
static bool isNearlyEqual(double a, double b)
utility for comparison of doubles
std::vector< unsigned int > getVariableTypes()
utility to retrieve variable types
std::vector< std::string > listUncertainties() const
retrieve the list of "uncertainties" accessible to this object.
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 CalibrationStatus getUncertainty(const std::string &unc, const CalibrationDataVariables &x, UncertaintyResult &result, TObject *obj=0)
retrieve the calibration uncertainty due to the given source.
virtual std::vector< double > getBinBoundaries(unsigned int vartype)
Retrieve the bin boundaries for the specified variable type (which should be a CalibrationParametriza...
virtual int getTagWeightAxis()
Test whether this calibration object is one for "continuous" calibration (this has some subtle conseq...
virtual CalibrationStatus getResult(const CalibrationDataVariables &x, double &result, TObject *obj=0, bool extrapolate=false)
retrieve the calibration result.
bool isBinCorrelated(const std::string &unc) const
Indicate whether the given uncertainty is correlated from bin to bin or not (note that this function ...
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