55{
57
58
59 if (
object.
IsA()->InheritsFrom(
"TH2") ) {
60 throw dqm_core::BadConfig( ERS_HERE , name , " dimension > 1 ");
61 }
62
63
64 if (
object.
IsA()->InheritsFrom(
"TH1") ) {
66 } else {
67 throw dqm_core::BadConfig( ERS_HERE ,name , " does not inherit from TH1");
68 }
69
70
71 double grThr, reThr;
72
73
75 if (skipmod < 1) {
76 std::ostringstream
msg;
77 msg <<
" Parameter \"SkipBinModulo\" is out of bounds. Value given = " << skipmod;
78 msg <<
"\n Range of values acceptable: integer >= 1";
79 msg <<
"\n Default Value: skip none. Do not set \"SkipBinModulo\" in your config to use default";
80 throw dqm_core::BadConfig(ERS_HERE,name,
msg.str());
81 }
82
83
85 if (signL < 0.01 || signL > 0.95) {
86 std::ostringstream
msg;
87 msg <<
" Parameter \"Significance\" is out of bounds. Value given = " << signL;
88 msg <<
"\n Range of values acceptable: floating point number [0.01, 0.95]";
89 msg <<
"\n Default Value: 0.04. Do not set \"Significance\" in your config to use default";
90 throw dqm_core::BadConfig(ERS_HERE,name,
msg.str());
91 }
92
93
95 if (minStat < 0) {
96 std::ostringstream
msg;
97 msg <<
" Parameter \"MinStatPerBin\" is out of bounds. Value given = " << signL;
98 msg <<
"\n Range of values acceptable: integer >= 0";
99 msg <<
"\n Default Value: 10. Do not set \"MinStatPerBin\" in your config to use default";
100 throw dqm_core::BadConfig(ERS_HERE,name,
msg.str());
101 }
102
103
104
105 const double notFound = -99999;
110 ERS_DEBUG(1,
"xmin = " <<
xmin <<
", xmax = " <<
xmax <<
" , minbin = " << minbin <<
", maxbin = " << maxbin);
111
112
114 ERS_DEBUG(1, "useMinStat = " << useMinStat);
115
116
117 try {
118
121
122 } catch ( dqm_core::Exception & ex ) {
123 throw dqm_core::BadConfig(ERS_HERE,name,"Paramter: 'Threshold' is mandatory, cannot continue");
124 }
125
126 if ( grThr > 1.0 || reThr > 1.0) {
127 throw dqm_core::BadConfig(ERS_HERE,
m_name,
"Configuration Error: Threshold>100%");
128 }
129
130
131 int binc = 0;
132 std::vector<float> binCountVec;
133 std::vector<size_t> binIndices;
134
135
136 for(
int k = minbin;
k < maxbin;
k++) {
137
138 if (k % skipmod == 0) {}
139 else {
140 float binval =
histogram->GetBinContent(k);
141 binCountVec.push_back(binval);
142 if((binval <= minStat) && useMinStat) {
143 binIndices.push_back(binc);
144 }
145 binc++;
146 }
147 }
148
149
150 int minOutliers = binIndices.size();
151 int maxOutliers, nOutliers = minOutliers;
152 int nbinsDenominator = binCountVec.size();
153
154 dqm_core::Result *
result =
new dqm_core::Result;
155
156 std::ostringstream
msg;
157 try {
158
159 maxOutliers =
GrubbsTest(binCountVec,binIndices,signL);
160
161
162 msg<<
"maxOutliers = " << maxOutliers <<
"\t bincountVecsize = " << nbinsDenominator <<
"\t";
163 if(binIndices.size() <= binCountVec.size())
164 for(
size_t g= 0;
g < binIndices.size();
g++)
165 msg << binIndices[g] <<
":" << binCountVec[binIndices[g]] <<
"\n";
166 ERS_DEBUG(1,
msg.str());
167
168 } catch ( dqm_core::Exception & ex ) {
169 msg <<
" Exception caught in GrubbsTest \n";
170 throw dqm_core::BadConfig(ERS_HERE,name,
msg.str());
171 }
172
173
174 if(maxOutliers >= 0) {
175 nOutliers += (useMinStat ? maxOutliers : 0);
176 }
177 result->tags_.insert(std::make_pair(
"NumOfOutliers",nOutliers));
178
179
180 float totalBins = nbinsDenominator > 0 ? nbinsDenominator :
histogram->GetNbinsX();
181 float outlierFraction = 0.;
182#ifndef __APPLE__
183 bool IsInf = isinf(float(nOutliers) / totalBins);
184 bool IsNaN = isnan(float(nOutliers) / totalBins);
185#else
186 bool IsInf = std::isinf(float(nOutliers) / totalBins);
187 bool IsNaN = std::isnan(float(nOutliers) / totalBins);
188#endif
189 if(!IsInf || !IsNaN)
190 outlierFraction =
float(nOutliers) / totalBins;
191
192 result->tags_.insert(std::make_pair(
"OutlierFraction",outlierFraction));
194 msg <<
"Outlier fraction = "<< nOutliers <<
"/" << totalBins <<
" = " << outlierFraction;
195 ERS_DEBUG(1,
msg.str());
196
197
198
199
200 if (reThr> grThr) {
201 if ( outlierFraction>reThr )
202 {
203 ERS_DEBUG(1,"[RED] Result : "<<outlierFraction);
204 result->status_=dqm_core::Result::Red;
206 }
207 else if ( outlierFraction > grThr )
208 {
209 ERS_DEBUG(1,"[YELLOW] Result : "<<outlierFraction);
210 result->status_=dqm_core::Result::Yellow;
212 }
213 }else {
214 if ( outlierFraction < reThr )
215 {
216 ERS_DEBUG(1,"[RED] Result : "<<outlierFraction);
217 result->status_=dqm_core::Result::Red;
219 }
220 else if ( outlierFraction < grThr )
221 {
222 ERS_DEBUG(1,"[YELLOW] Result : "<<outlierFraction);
223 result->status_=dqm_core::Result::Yellow;
225 }
226 }
227
228
229 ERS_DEBUG(1,"[GREEN] Result");
230 result->status_=dqm_core::Result::Green;
232
233}
dqm_algorithms::GrubbsOutlierTest GrubbsTest("Grubbs")
Int_t FindBin(const TAxis *axis, const double x)
#define IsA
Declare the TObject style functions.