12 #include <dqm_core/AlgorithmManager.h>
13 #include "dqm_core/exceptions.h"
14 #include <dqm_core/AlgorithmConfig.h>
15 #include <dqm_core/Result.h>
38 const dqm_core::AlgorithmConfig&
config) {
50 if(
object.
IsA()->InheritsFrom(
"TH1" ) ) {
54 throw dqm_core::BadConfig( ERS_HERE,
name,
"dimension > 2 " );
57 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH1" );
66 result->tags_[
"Not enough Signal Statistics"] = minstat;
74 if ((checkZeroContent > 0) && (
histogram->Integral() == 0) && (
histogram->GetEntries() > 0)) {
75 ERS_DEBUG(1,
"Histogram " <<
histogram->GetName()<<
" is filled with zeroes!");
84 int checkSigmaDev = 1;
85 int dontCountSigmaOutliers = 0;
103 catch( dqm_core::Exception & ex ) {
104 throw dqm_core::BadConfig( ERS_HERE,
name, ex.what(), ex );
109 const int xminBin =
range[0];
110 const int xmaxBin =
range[1];
114 for (
int i = xminBin;
i <= xmaxBin;
i++) {
115 if (
histogram->GetBinContent(
i) == 0) zeroBins++;
119 int totalBadBins = 0;
127 for(
int i=xminBin;
i <= xmaxBin;
i++){
128 if(
histogram->GetBinContent(
i) != 0 || ignore0 ==
false) {
141 double absdev_test = 0;
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){
156 int totalBadBins_all = 0;
161 double sum_all=0,sum2_all=0;
165 if(
histogram->GetBinContent(
i) != 0 || ignore0 ==
false) {
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;
178 double absdev_test_all = 0;
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){
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;
211 out << m_name <<
": derivation of OutlierAndFlatnessTest, slimmed and optimized for L1Calo needs"
212 "Checks TH1-inherited histograms for bins which lie either Nsigma or AbsDev away from the mean (by default excludes bins with zero entries). Can also check mean itself\n"
213 "Config Parameters:\n"
214 "\tCheckSigmaDev:\tCheck for deviation in units of standard deviations from mean (default 1).\n"
215 "\tMinStat:\tMinimum Statistics for the histogram to be checked (default 1).\n"
216 "\txmin and/or xmax:\tRestrict all counting to this x-axis interval (default: full axis range).\n"
217 "\txmin and/or xmax:\tThere is a second output parameter (Number_of_outlier_bins_all), which always uses the full range.\n"
218 "\tIgnore0:\tBins with 0 content are ignored for outlier/mean computation (default 1).\n"
219 "\tSigmaDev:\tNumber of Standard Deviations a single bin has to differ from the mean of the distribution to be classified as outlier. Has to be given if \"CheckSigmaDev\" is set to 1. (default 5)\n"
220 "\tAbsDev:\tAbsolute value a single bin has to differ from the mean of the distribution to be classified as outlier. Has to be given if \"CheckAbsDev\" is set to 1.\n"
221 "\tDontCountSigmaDev:\tBins deviating by a given number of standard deviations are not counted as outliers (default 0)."
222 "\tDontCountSigmaDev:\t(Not recommended to be switched on in current config)\n"
223 "Threshold Parameters:\n"
224 "\tStandard_deviation: \tStandard Deviation of distribution.\n"
225 "\tNumber_of_outlier_bins:\tNumber of bins classified as outliers using the given thresholds (in chosen histogram range).\n"
226 "\tNumber_of_outlier_bins_all:\tNumber of bins classified as outliers using the given thresholds (in full histogram range).\n"
227 "\tMean:\tMean of distribution.\n"
228 "\tNumber_of_bins_equal_zero:\tNumber of Bins with zero content." << std::endl;