37 {
38
39 if ( !
object.
IsA()->InheritsFrom(
"TEfficiency" ) ) {
40 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TEfficiency" );
41 }
42
43 auto efficiency_object =
static_cast<const TEfficiency*
>( &
object );
44
45 const TH1* h_total = efficiency_object->GetTotalHistogram();
46 if (h_total->GetEntries() == 0) {
47 auto result =
new dqm_core::Result();
48 result->status_ = dqm_core::Result::Undefined;
50 }
51
52
53 int MIN_STATISTICS_CUT = 50.0;
54 float EFF_THRESH_low = 0.50;
55 float EFF_THRESH_medium = 0.80;
56 float EFF_THRESH_high = 0.90;
57 int N_Sect_low_max = 4;
58 int N_Sect_medium = 5;
59 int N_Sect_high_min = 6;
60 try {
67 }catch ( dqm_core::Exception & ex ) {
68 MIN_STATISTICS_CUT = 50;
69 EFF_THRESH_low = 0.50;
70 EFF_THRESH_medium = 0.80;
71 EFF_THRESH_high = 0.90;
72 N_Sect_low_max = 4;
73 N_Sect_medium = 5;
74 N_Sect_high_min = 6;
75 }
76
77
78 int nLBs = h_total->GetNbinsX();
79 int nSectors = h_total->GetNbinsY();
80
81 bool red_flag_triggered = false;
82
84
85
86 for (int x_lb_bin = 1; x_lb_bin <= nLBs; ++x_lb_bin) {
87
88 int count_eff_lt_50 = 0;
89 int count_eff_lt_80 = 0;
90 int count_eff_lt_90 = 0;
91
92
93 for (int y_sector_bin = 1; y_sector_bin <= nSectors; ++y_sector_bin) {
94
95 int bin_idx = h_total->GetBin(x_lb_bin, y_sector_bin);
96 double total_events = h_total->GetBinContent(bin_idx);
97
98
99 if (total_events > MIN_STATISTICS_CUT) {
100
101 double bin_eff = efficiency_object->GetEfficiency(bin_idx);
102
103 if (bin_eff < EFF_THRESH_high) {
104 count_eff_lt_90++;
105 }
106 if (bin_eff < EFF_THRESH_medium) {
107 count_eff_lt_80++;
108 }
109 if (bin_eff < EFF_THRESH_low) {
110 count_eff_lt_50++;
111 total_low_eff_bins++;
112 }
113 }
114 }
115
116
117
118 if (count_eff_lt_90 >= N_Sect_high_min) {
119 red_flag_triggered = true;
120 break;
121 }
122 else if (count_eff_lt_80 == N_Sect_medium) {
123 red_flag_triggered = true;
124 break;
125 }
126 else if (count_eff_lt_50 >= 2 && count_eff_lt_50 <= N_Sect_low_max) {
127 red_flag_triggered = true;
128 break;
129 }
130
131 }
132
133 auto result =
new dqm_core::Result();
134
135 if (red_flag_triggered) {
136 result->status_ = dqm_core::Result::Red;
137 } else {
138 result->status_ = dqm_core::Result::Green;
139 }
140
141
142 result->tags_[
"N_Bad_Bins_Lt_50_Percent" ] = (
double)total_low_eff_bins;
143 result->tags_[
"Red_Flag_Triggered" ] = (
double)(red_flag_triggered ? 1.0 : 0.0);
144
145
147}
#define IsA
Declare the TObject style functions.