19 static const std::vector<std::string> qualities {
"HighPt",
"Tight",
"Medium",
"Loose" };
20 static const std::vector<std::string> types {
"data",
"mc" };
21 static const std::vector<std::string> regions {
"barrel",
"endcap" };
22 static const std::vector<std::string>
bins {
"coarse",
"fine" };
23 static const std::vector<std::string>
systematics {
"nominal",
"stat_up",
"stat_down",
"syst_up",
"syst_down" };
30 Error(
APP_NAME,
"No scale factors or configuration file name received!");
35 std::ifstream confFileStream(
argv[1], std::ifstream::in);
36 if (!confFileStream.good()) {
41 std::map<std::string, std::set<std::string>> triggersByPeriods;
43 while (std::getline(confFileStream,
periodInfo,
';')) {
52 if (!std::getline(
ss,
period,
':')) {
56 if (triggersByPeriods.find(
period) != triggersByPeriods.end()) {
57 Error(
APP_NAME,
" Period %s is defined multiple times in configuration file",
period.c_str());
62 while (std::getline(
ss, trigger,
',')) {
67 confFileStream.close();
76 for (
size_t i = 0;
i < qualities.size();
i++) {
77 TDirectory* qualityDirectory =
file->GetDirectory(qualities[
i].c_str());
78 if (!qualityDirectory) {
79 Error(
APP_NAME,
" Directory for quality %s is missing", qualities[
i].c_str());
83 TIter nextPeriod(qualityDirectory->GetListOfKeys());
84 while ((periodKey = (TKey*)nextPeriod())) {
85 if (triggersByPeriods.find(periodKey->GetName()) == triggersByPeriods.end()) {
86 Error(
APP_NAME,
" Quality %s contains period %s, which is not defined in configuration file", qualities[
i].c_str(), periodKey->GetName());
90 for (
auto const&
x : triggersByPeriods)
93 std::set<std::string>
triggers =
x.second;
94 TDirectory* periodDirectory = qualityDirectory->GetDirectory(
period.c_str());
95 if (!periodDirectory) {
96 Error(
APP_NAME,
" Configuration file contains period %s, but this is missing in scale factors file under quality %s",
period.c_str(), qualities[
i].c_str());
101 TIter nextTrigger(periodDirectory->GetListOfKeys());
102 while ((triggerKey = (TKey*)nextTrigger())) {
104 Error(
APP_NAME,
" Period %s under quality %s contains trigger %s, which is not defined in configuration file",
period.c_str(), qualities[
i].c_str(), triggerKey->GetName());
108 for (
auto const& trigger :
triggers)
110 TDirectory* triggerDirectory = periodDirectory->GetDirectory(trigger.c_str());
111 if (!triggerDirectory) {
112 Error(
APP_NAME,
" Configuration file contains trigger %s under period %s, but this is missing in scale factors file under quality %s", trigger.c_str(),
period.c_str(), qualities[
i].c_str());
116 for (
size_t ibins = 0; ibins < bins.size(); ++ibins) {
117 for (
size_t iregion = 0; iregion < regions.size(); ++iregion) {
118 for (
size_t itype = 0; itype < types.size(); ++itype) {
119 for (
size_t isys = 0; isys < systematics.size(); ++isys) {
120 if (types[itype].
find(
"data") != std::string::npos && systematics[isys].
find(
"syst") != std::string::npos)
continue;
121 std::string
path =
"eff_etaphi_" + bins[ibins] +
"_" + regions[iregion] +
"_" + types[itype] +
"_" + systematics[isys];
122 TH2*
hist =
dynamic_cast<TH2*
>(triggerDirectory->Get(
path.c_str()));
124 Error(
APP_NAME,
" Histogram %s not found under trigger %s, period %s and quality %s",
path.c_str(), trigger.c_str(),
period.c_str(), qualities[
i].c_str());
127 if (
hist->GetEntries() == 0) {
128 Error(
APP_NAME,
" Histogram %s under trigger %s, period %s and quality %s is empty",
path.c_str(), trigger.c_str(),
period.c_str(), qualities[
i].c_str());