22 #include "dqm_core/exceptions.h"
23 #include "dqm_core/AlgorithmConfig.h"
24 #include "dqm_core/AlgorithmManager.h"
25 #include "dqm_core/Result.h"
63 if(
object.
IsA()->InheritsFrom(
"TH1" ) ) {
65 if (
hist->GetDimension() >= 2 ){
66 throw dqm_core::BadConfig( ERS_HERE,
name,
"dimension >= 2 " );
69 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH1" );
81 catch ( dqm_core::Exception & ex ) {
82 throw dqm_core::BadConfig( ERS_HERE,
name, ex.what(), ex );
88 ref =
static_cast<const TH1*
>(
config.getReference() );
90 catch ( dqm_core::Exception & ex ) {
91 throw dqm_core::BadRefHist(ERS_HERE,
name,
" Could not retreive reference");
93 if (
hist->GetDimension() !=
ref->GetDimension() ) {
94 throw dqm_core::BadRefHist( ERS_HERE,
name,
"Reference VS histo: Different dimension!" );
96 if (
hist->GetNbinsX() !=
ref->GetNbinsX() ) {
97 throw dqm_core::BadRefHist( ERS_HERE,
name,
"Reference VS histo: Different bin numbre in X axis!" );
101 if (
hist->GetEntries() < minstat ) {
102 ERS_INFO(
"Histogram does not satisfy MinStat requirement " <<
hist->GetName());
104 result->tags_[
"InsufficientEntries"] =
hist->GetEntries();
107 ERS_DEBUG(1,
"Statistics: "<<
hist->GetEntries()<<
" entries ");
117 int max_bin =
hist -> GetNbinsX();
122 ERS_INFO(
"Histogram has no entries" <<
hist->GetName());
124 result->tags_[
"InsufficientEntries"] =
hist->GetEntries();
129 ERS_INFO(
"Reference histogram has no entries" <<
hist->GetName());
131 result->tags_[
"InsufficientRefEntries"] =
ref->GetEntries();
139 if(N_ref != 0) norm_ref=1/N_ref;
141 for(
i=1;
i<=max_bin;
i++){
142 n =
hist->GetBinContent(
i);
143 n_ref =
ref->GetBinContent(
i);
144 if(
n != 0 || n_ref != 0)
chi2+=(
n*
norm-n_ref*norm_ref)*(
n*
norm-n_ref*norm_ref)/(
n*
norm*
norm+n_ref*norm_ref*norm_ref);
145 if(
n == 0 && n_ref == 0)
count++;
159 ERS_DEBUG(1,
"Green");
160 }
else if ( prob<=greenTh && prob>redTh ) {
161 result->status_ = dqm_core::Result::Yellow;
162 ERS_DEBUG(1,
"Yellow");
163 }
else if (
prob<=redTh) {
177 message +=
"Description: Perform a chi square check between input istogram and reference\n";
178 message +=
"Mandatory Green/Red Threshold: Limits: chi square probability limits\n";
179 message +=
"Optional Parameters: MinStat = Minimum histogram statistics needed to perform Algorithm\n";