10 #include <dqm_core/AlgorithmConfig.h>
16 #include <TProfile2D.h>
22 #include <dqm_core/AlgorithmManager.h>
44 const TObject &
object,
45 const dqm_core::AlgorithmConfig &
config )
50 if(
object.
IsA()->InheritsFrom(
"TH1" )) {
53 throw dqm_core::BadConfig( ERS_HERE,
name,
"dimension > 2 " );
56 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH1");
61 refhist =
static_cast<TH1*
>(
config.getReference() );
63 catch (dqm_core::BadConfig &ex ) {
68 catch( dqm_core::Exception & ex ) {
69 throw dqm_core::BadConfig( ERS_HERE,
name, ex.what(), ex );
76 catch( dqm_core::Exception & ex ) {
77 throw dqm_core::BadConfig( ERS_HERE,
name, ex.what(), ex );
81 if (
histogram->GetDimension() != refhist->GetDimension() ) {
82 throw dqm_core::BadRefHist( ERS_HERE,
name,
"Dimension" );
85 if ((
histogram->GetNbinsX() != refhist->GetNbinsX()) || (
histogram->GetNbinsY() != refhist->GetNbinsY())) {
86 throw dqm_core::BadRefHist( ERS_HERE,
"number of bins",
name );
98 const TProfile2D* profile2D(
nullptr);
100 if(minBinEntries > 0) {
102 else if (
object.InheritsFrom(
"TProfile2D")) profile2D =
dynamic_cast<const TProfile2D*
>(&
object);
118 if (greaterthan && lessthan) {
119 ERS_INFO(
"Both GreaterThan and LessThan parameters set: Will check for for both");
124 double bin_threshold;
132 catch( dqm_core::Exception & ex ) {
133 throw dqm_core::BadConfig( ERS_HERE,
name, ex.what(), ex );
144 TH1* resulthisto =
nullptr;
145 if (publishHistogram) {
148 }
else if (
histogram->InheritsFrom(
"TH1")) {
151 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH1" );
154 resulthisto->Reset();
157 if (refhist && normref) {
159 refhist->Scale(
ratio);
164 for (
int j =
range[2]; j <=
range[3]; ++j ) {
165 if (minBinEntries > 0) {
168 if (
profile->GetBinEntries(
bin) < minBinEntries) {
172 }
else if (profile2D) {
173 if (profile2D->GetBinEntries(
bin) < minBinEntries) {
183 refcont = refhist->GetBinContent(
i,j);
190 if (increferr && refhist ) {
191 double referr = refhist->GetBinError(
i,j);
201 double inputcont =
histogram->GetBinContent(
i,j);
202 double diff=inputcont - refcont;
207 if (ignorezero && refcont==0)
continue;
208 if (ignorezero && !refhist && inputcont==0)
continue;
209 if (ignoreInputZero && inputcont==0)
continue;
213 if (greaterthan &&
diff < 0. )
continue;
214 if (lessthan &&
diff > 0. )
continue;
216 if ( (std::abs(
sigma) > bin_threshold) && (std::abs(
diff) > maxdiffabs) && (std::abs(
reldiff) > maxdiffrel) ){
217 if (resulthisto) resulthisto->SetBinContent(
i,j,inputcont);
219 if (publish &&
count<maxpublish){
227 if (
value == -99999) {
228 ERS_DEBUG(1,
"Number of bins " << bin_threshold <<
" Sigma away from reference is " <<
count);
230 ERS_DEBUG(1,
"Number of bins " << bin_threshold <<
" Sigma away from "<<
value<<
" is " <<
count);
233 ERS_DEBUG(1,
"Green threshold: "<< gthreshold <<
" bin(s); Red threshold : " << rthreshold <<
" bin(s) ");
237 result->tags_[
"NSkippedBins"] = nSkippedBins;
238 if (resulthisto)
result->object_ = (boost::shared_ptr<TObject>)(TObject*)(resulthisto);
240 if (gthreshold > rthreshold) {
241 if (
count >= gthreshold ) {
243 }
else if (
count > rthreshold ) {
244 result->status_ = dqm_core::Result::Yellow;
249 if (
count <= gthreshold ) {
251 }
else if (
count < rthreshold ) {
252 result->status_ = dqm_core::Result::Yellow;
264 out<<
"BinContentComp: Checks number of bins N sigma away from reference histogram bin value or given Value\n"<<std::endl;
266 out<<
"Mandatory Parameter: NSigma: Number of sigma each bin must be within reference histogram value\n"<<std::endl;
267 out<<
"Mandatory Parameter (If no reference): Value: Value to compare each bin\n"<<std::endl;
270 out<<
"Mandatory Green/Red Threshold: NBins: number of bins N sigma away from reference histogram bin to give Green/Red result\n"<<std::endl;
272 out<<
"Optional Parameter: MinStat: Minimum histogram statistics needed to perform Algorithm"<<std::endl;
273 out<<
"Optional Parameter: Ignore0: Ignore bins which have zero entries in reference histogram"<<std::endl;
274 out<<
"Optional Parameter: IgnoreInput0: Ignore bins which have zero entries in tested histogram"<<std::endl;
275 out<<
"Optional Parameter: xmin: minimum x range"<<std::endl;
276 out<<
"Optional Parameter: xmax: maximum x range"<<std::endl;
277 out<<
"Optional Parameter: ymin: minimum y range"<<std::endl;
278 out<<
"Optional Parameter: ymax: maximum y range\n"<<std::endl;
279 out<<
"Optional Parameter: GreaterThan: check only for bins which are GreaterThan average (set to 1)"<<std::endl;
280 out<<
"Optional Parameter: LessThan: check only for bins which are LessThan average (set to 1)"<<std::endl;
281 out<<
"Optional Parameter: PublishBins: Save bins which are different from average in Result (set to 1)"<<std::endl;
282 out<<
"Optional Parameter: PublishHistogram: Save histogram with bins that are different from average in Result (by default: 1)"<<std::endl;
283 out<<
"Optional Parameter: MaxPublish: Max number of bins to save (default 20)"<<std::endl;
284 out<<
"Optional Parameter: NormRef: Normalize reference histogram to checked histogram statistics before checking bin contents (set to 1)"<<std::endl;
285 out<<
"Optional Parameter: MaxDiffAbs: test fails if NBins more than NSigma away and NBins more than MaxDiffAbs (absolut difference) away"<<std::endl;
286 out<<
"Optional Parameter: MaxDiffRel: test fails if NBins more than NSigma away and NBins more than MaxDiffRel (relative difference) away\n"<<std::endl;
287 out<<
"Optional Parameter: FixedError: override the histogram errors with this value"<<std::endl;
288 out<<
"Optional Parameter: IncludeRefError: use both the histogram and reference histogram errors in calculation"<<std::endl;
289 out<<
"Optional Parameter: MinBinEntries: Minimum bin entries in profile histogram needed to check this bin (by default: -1)"<<std::endl;