5 #include "TEfficiency.h"
15 const TH1F*
passed,
const TH1F*
total,
const char*
name,
const char*
title,
const double confidence_level) {
16 if (not TEfficiency::CheckConsistency(*
passed, *
total)) {
21 const TAxis* total_x =
total->GetXaxis();
23 TProfile* eff_profile =
new TProfile(
name,
title, total_x->GetNbins(), total_x->GetXmin(), total_x->GetXmax());
24 eff_profile->GetXaxis()->SetTitle(total_x->GetTitle());
25 eff_profile->GetYaxis()->SetTitle(
"#epsilon");
28 double num_passed =
passed->GetBinContent(
bin);
29 double num_total =
total->GetBinContent(
bin);
32 eff_profile->SetBinEntries(
bin, 0);
38 double lower_bound = TEfficiency::ClopperPearson(num_total, num_passed, confidence_level,
false);
39 double upper_bound = TEfficiency::ClopperPearson(num_total, num_passed, confidence_level,
true);
45 eff_profile->SetBinError(
bin,
error);
46 eff_profile->SetBinEntries(
bin, 1);
56 if (not TEfficiency::CheckConsistency(*
passed, *
total)) {
62 TH2F* eff_hist = dynamic_cast<TH2F*>(eff.CreateHistogram());
63 eff_hist->SetName(
name);
64 eff_hist->SetTitle(
title);
66 const TAxis* total_x =
total->GetXaxis();
67 TAxis* eff_hist_x = eff_hist->GetXaxis();
68 eff_hist_x->SetTitle(total_x->GetTitle());
70 const char*
label = total_x->GetBinLabel(
bin);
74 const TAxis* total_y =
total->GetYaxis();
75 TAxis* eff_hist_y = eff_hist->GetYaxis();
76 eff_hist_y->SetTitle(total_y->GetTitle());
78 const char*
label = total_y->GetBinLabel(
bin);
90 std::map<std::string, std::pair<const MonitorElement*, const MonitorElement*> > me_pairs;
102 const bool is_matched =
name.find(
matched) != std::string::npos;
108 if (me_pairs.find(
key) == me_pairs.end()) {
109 me_pairs[
key] = {
nullptr,
nullptr};
113 me_pairs[
key].first =
me;
115 me_pairs[
key].second =
me;
118 for (
auto&& [
key,
value] : me_pairs) {
119 const auto& [me_passed, me_total] =
value;
120 if (me_passed ==
nullptr) {
124 if (me_total ==
nullptr) {
129 if (me_passed->kind() != me_total->kind()) {
138 TH1F* h_passed = me_passed->getTH1F();
139 if (h_passed ==
nullptr) {
145 TH1F* h_total = me_total->getTH1F();
146 if (h_total ==
nullptr) {
153 if (eff ==
nullptr) {
161 TH2F* h_passed = me_passed->
getTH2F();
162 if (h_passed ==
nullptr) {
168 TH2F* h_total = me_total->getTH2F();
169 if (h_total ==
nullptr) {
176 if (eff ==
nullptr) {
191 std::vector<std::string> tokens;
192 size_t delimiter_pos;
193 size_t delimiter_len =
delimiter.length();
194 while ((delimiter_pos =
name.find(
'_')) != std::string::npos) {
195 tokens.push_back(
name.substr(0, delimiter_pos));
196 name.erase(0, delimiter_pos + delimiter_len);
198 tokens.push_back(
name);
212 const size_t num_tokens = tokens.size();
214 if ((num_tokens != 2) and (num_tokens != 3)) {
215 return std::make_tuple(
"", -1,
false, -1);
219 std::string region_sign = tokens.front().substr(0, 1);
221 TString station_str = tokens.front().substr(1, 1);
222 TString ieta_str = tokens.back().substr(4, 1);
223 TString superchamber_str = (num_tokens == 3) ? tokens[1] :
"";
225 int station = station_str.IsDigit() ? station_str.Atoi() : -1;
226 int ieta = ieta_str.IsDigit() ? ieta_str.Atoi() : -1;
230 if (superchamber_str.EqualTo(
"odd"))
232 else if (superchamber_str.EqualTo(
"even"))
235 return std::make_tuple(
"", -1,
false, -1);
240 return std::make_tuple(region_sign,
station, is_odd,
ieta);
251 std::map<std::tuple<std::string, int, bool>, std::vector<std::pair<int, TH1F*> > > res_data;
264 TH1F*
hist =
me->getTH1F();
265 if (
hist ==
nullptr) {
276 const std::tuple<std::string, int, bool>
key{region_sign,
station, is_odd};
278 if (res_data.find(
key) == res_data.end()) {
279 res_data.insert({
key, std::vector<std::pair<int, TH1F*> >()});
287 for (
auto [
key, ieta_data] : res_data) {
288 if (ieta_data.empty()) {
292 TString tmp_title{ieta_data.front().second->GetTitle()};
293 const TObjArray* tokens = tmp_title.Tokenize(
":");
294 TString
title = dynamic_cast<TObjString*>(tokens->At(0))->GetString();
297 TString&&
name = TString::Format(
"%s_ge%s%d1",
prefix.data(), region_sign.c_str(),
station);
298 title += TString::Format(
"GE %s%d/1", region_sign.c_str(),
station);
300 name += (is_odd ?
"_odd" :
"_even");
301 title += (is_odd ?
", Odd Superchambers" :
", Even Superchambers");
304 const int num_etas = ieta_data.size();
306 TH2F*
profile =
new TH2F(
name,
title, num_etas, 0.5, num_etas + 0.5, 2, -0.5, 1.5);
307 auto x_axis =
profile->GetXaxis();
309 x_axis->SetTitle(
"i#eta");
312 x_axis->SetBinLabel(
ieta,
label.c_str());
315 profile->GetYaxis()->SetBinLabel(1,
"Mean");
316 profile->GetYaxis()->SetBinLabel(2,
"Std. Dev.");
318 for (
auto [
ieta,
hist] : ieta_data) {