11 #include "dqm_core/AlgorithmManager.h"
12 #include "dqm_core/AlgorithmConfig.h"
41 const TObject &
object,
42 const dqm_core::AlgorithmConfig &
config )
54 if(
object.
IsA()->InheritsFrom(
"TProfile" ))
58 if(
object.
IsA()->InheritsFrom(
"TH1" )) {
61 throw dqm_core::BadConfig( ERS_HERE,
name,
"dimension > 2 " );
64 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH1" );
68 refhist =
static_cast<TH1 *
>(
config.getReference() );
70 catch ( dqm_core::Exception & ex ) {
71 throw dqm_core::BadRefHist(ERS_HERE,
name,
" Could not retreive reference");
74 if (
histogram->GetDimension() != refhist->GetDimension() ) {
75 throw dqm_core::BadRefHist( ERS_HERE,
name,
"Dimension" );
78 if ((
histogram->GetNbinsX() != refhist->GetNbinsX()) || (
histogram->GetNbinsY() != refhist->GetNbinsY())) {
79 throw dqm_core::BadRefHist( ERS_HERE,
name,
"number of bins" );
84 std::string
thresh=
"ChiSqPerNdof";
89 catch ( dqm_core::Exception & ex ) {
90 throw dqm_core::BadConfig( ERS_HERE,
name, ex.what(), ex );
101 prof_ref = (
TProfile*)refhist->Clone();
118 double significance = 0;
128 double uncert = std::sqrt(uncert1*uncert1 + uncert2*uncert2);
135 badbin = prof_hist->GetBinEntries(
i)<2 || prof_ref->GetBinEntries(
i)<2;
144 if(uncert !=0 && badbin ==0){
146 significance += (
diff/uncert)*(
diff/uncert);
152 std::string
out =
"ChiSqPerBin";
153 std::string out1=
"ChiSqTotal";
154 std::string out2=
"ChiSqUsedBins";
158 double value = significance/numchi;
160 result->tags_[out1] = significance;
161 result->tags_[out2] = numchi;
162 if (
value <= gthresho ) {
164 }
else if (
value < rthresho ) {
165 result->status_ = dqm_core::Result::Yellow;
181 result->tags_[
"EntriesReference"] = refhist->GetEntries();
182 result->tags_[
"MeanReference"] = refhist->GetMean();
183 result->tags_[
"RMSReference"] = refhist->GetRMS();
190 out<<
"AlgChiComp_" << m_name <<
": Gives back a Chi Squared like quantity per histogram bin in comparison to a reference histogram. Note that this assumes Gaussian statistics, and handles different numbers of events per histogram correctly. It is also fully compatible with TProfile graphs"<<std::endl;
191 out<<
"Mandatory Green/Red Threshold ChiSqPerNdof: Chi Squared per bin for Green/Red results\n"<<std::endl;