38 {
39
40
41
42
43
44
45
46
47
48
50 if(
object.
IsA()->InheritsFrom(
"TH1" ) ) {
52
54 throw dqm_core::BadConfig( ERS_HERE, name, "dimension > 2 " );
55 }
56 } else {
57 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
58 }
59
61
62
64 dqm_core::Result*
result =
new dqm_core::Result();
65 result->status_ = dqm_core::Result::Green;
66 result->tags_[
"Not enough Signal Statistics"] = minstat;
67
69 }
70
71
73
74 if ((checkZeroContent > 0) && (
histogram->Integral() == 0) && (
histogram->GetEntries() > 0)) {
75 ERS_DEBUG(1,
"Histogram " <<
histogram->GetName()<<
" is filled with zeroes!");
76 dqm_core::Result*
result =
new dqm_core::Result();
77 result->status_ = dqm_core::Result::Red;
79
81 }
82
83
84 int checkSigmaDev = 1;
85 int dontCountSigmaOutliers = 0;
86 int ignore0 = 1;
87 double sigmaDev = 0;
88 double absDev = 0;
89
90
91 try {
93
95
97
98 if (checkSigmaDev) {
101 }
102 }
103 catch( dqm_core::Exception & ex ) {
104 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
105 }
106
107
109 const int xminBin =
range[0];
110 const int xmaxBin =
range[1];
111
112
113 int zeroBins = 0;
114 for (
int i = xminBin;
i <= xmaxBin;
i++) {
115 if (
histogram->GetBinContent(i) == 0) zeroBins++;
116 }
117
118
119 int totalBadBins = 0;
121 double stdev=0;
122
123
126
127 for(
int i=xminBin;
i <= xmaxBin;
i++){
128 if(
histogram->GetBinContent(i) != 0 || ignore0 ==
false) {
132 }
133 }
134
136 stdev =
counter > 0 ? std::sqrt( sum2/
static_cast<double>(counter) -
mean*
mean) : 0;
137
138
139
140 double dev;
141 double absdev_test = 0;
142 if (checkSigmaDev) {
143 for (
int i = xminBin;
i <= xmaxBin;
i++) {
144 if ((
histogram->GetBinContent(i) != 0) || (ignore0 == 0)) {
147 if ((dev > sigmaDev) && (absdev_test > absDev)) {
148 if (!dontCountSigmaOutliers){
149 totalBadBins++;
150 }
151 }
152 }
153 }
154 }
155
156 int totalBadBins_all = 0;
157 double mean_all=0;
158 double stdev_all=0;
159
160
161 double sum_all=0,sum2_all=0;
162 int counter_all = 0;
163
165 if(
histogram->GetBinContent(i) != 0 || ignore0 ==
false) {
168 counter_all++;
169 }
170 }
171
172 mean_all = counter_all > 0 ? sum_all/(
double)counter_all : 0;
173 stdev_all = counter_all > 0 ? std::sqrt( sum2_all/static_cast<double>(counter_all) - mean_all*mean_all) : 0;
174
175
176
177 double dev_all;
178 double absdev_test_all = 0;
179 if (checkSigmaDev) {
181 if ((
histogram->GetBinContent(i) != 0) || (ignore0 == 0)) {
182 dev_all=std::abs(
histogram->GetBinContent(i) - mean_all)/stdev_all;
183 absdev_test_all=std::abs(
histogram->GetBinContent(i) - mean_all);
184 if ((dev_all > sigmaDev) && (absdev_test_all > absDev)) {
185 if (!dontCountSigmaOutliers){
186 totalBadBins_all++;
187 }
188 }
189 }
190 }
191 }
192
193
194
195 std::map<std::string,double> algparams;
196 algparams["Number_of_outlier_bins"] = totalBadBins;
197 algparams["Number_of_outlier_bins_all"] = totalBadBins_all;
198 algparams[
"Mean"] =
mean;
199 algparams["Standard_deviation"] = stdev;
200 algparams["Number_of_bins_equal_zero"] = zeroBins;
201
202
203
205
206
208}
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
#define IsA
Declare the TObject style functions.