9 #include <dqm_core/AlgorithmConfig.h>
13 #include <TEfficiency.h>
18 #include <dqm_core/AlgorithmManager.h>
42 const TObject &
object,
43 const dqm_core::AlgorithmConfig &
config )
47 TH1* passed_histogram = 0;
48 TH1* total_histogram = 0;
50 if(
object.
IsA()->InheritsFrom(
"TH1" )) {
53 throw dqm_core::BadConfig( ERS_HERE,
name,
"dimension > 2 " );
55 }
else if(
object.
IsA()->InheritsFrom(
"TEfficiency" )) {
59 throw dqm_core::BadConfig( ERS_HERE,
name,
"dimension > 2 " );
62 passed_histogram =
efficiency->GetCopyPassedHisto();
63 total_histogram =
efficiency->GetCopyTotalHisto();
64 passed_histogram->Divide(total_histogram);
67 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH1 or TEfficiency");
71 double current_stat = 0;
73 if(
object.
IsA()->InheritsFrom(
"TH1" )) {
75 }
else if(
object.
IsA()->InheritsFrom(
"TEfficiency" )){
76 current_stat = total_histogram->GetEntries();
79 if(current_stat < minstat ) {
81 result->tags_[
"InsufficientEntries"] = current_stat;
91 std::string thresholdname=
"P";
92 if (m_name ==
"Chi2_per_NDF") {
94 thresholdname=
"Chi2_per_NDF";
95 }
else if (m_name ==
"Prob" ) {
97 }
else if (m_name ==
"ProbUW") {
99 }
else if (m_name ==
"ProbWW") {
101 }
else if (m_name ==
"Chi2") {
103 thresholdname=
"Chi2";
105 throw dqm_core::BadConfig( ERS_HERE,
"None", m_name );
111 catch ( dqm_core::Exception & ex ) {
112 throw dqm_core::BadConfig( ERS_HERE,
name, ex.what(), ex );
116 if(
object.
IsA()->InheritsFrom(
"TH1" )) {
118 refhist =
dynamic_cast<TH1 *
>(
config.getReference() );
120 catch ( dqm_core::Exception & ex ) {
121 throw dqm_core::BadRefHist(ERS_HERE,
name,
" Could not retreive reference");
123 }
else if(
object.
IsA()->InheritsFrom(
"TEfficiency" )){
125 refeff =
dynamic_cast<TEfficiency *
>(
config.getReference() );
127 catch ( dqm_core::Exception & ex ) {
128 throw dqm_core::BadRefHist(ERS_HERE,
name,
" Could not retreive reference");
131 refhist = refeff->GetCopyPassedHisto();
132 ref_total_hist = refeff->GetCopyTotalHisto();
133 refhist->Divide(ref_total_hist);
136 if (!refhist) {
throw dqm_core::BadRefHist(ERS_HERE,
name,
"Bad reference type"); }
139 if(
object.
IsA()->InheritsFrom(
"TH1" )) {
141 if (
histogram->GetDimension() != refhist->GetDimension() ) {
142 throw dqm_core::BadRefHist( ERS_HERE,
"Dimension",
name );
145 if ((
histogram->GetNbinsX() != refhist->GetNbinsX()) || (
histogram->GetNbinsY() != refhist->GetNbinsY())) {
146 throw dqm_core::BadRefHist( ERS_HERE,
"number of bins",
name );
151 }
else if(
object.
IsA()->InheritsFrom(
"TEfficiency" )){
153 if (passed_histogram->GetDimension() != refhist->GetDimension() ) {
154 throw dqm_core::BadRefHist( ERS_HERE,
"Dimension",
name );
157 if ((passed_histogram->GetNbinsX() != refhist->GetNbinsX()) || (passed_histogram->GetNbinsY() != refhist->GetNbinsY())) {
158 throw dqm_core::BadRefHist( ERS_HERE,
"number of bins",
name );
161 value = passed_histogram->Chi2Test( refhist, option.c_str() );
164 ERS_DEBUG(1,
"Green threshold: "<< gthresho <<
"; Red threshold: " << rthresho );
165 ERS_DEBUG(1,
"Chi2 Test with Option " << option <<
" is " <<
value );
170 if (thresholdname ==
"P") {
171 if (
value >= gthresho ) {
173 }
else if (
value > rthresho ) {
174 result->status_ = dqm_core::Result::Yellow;
179 if (
value <= gthresho ) {
181 }
else if (
value < rthresho ) {
182 result->status_ = dqm_core::Result::Yellow;
189 ERS_DEBUG(2,
"Result: "<<*
result);
197 std::string thresholdname =
"P";
198 if (m_name ==
"Chi2_per_NDF") {
200 thresholdname=
"Chi2_per_NDF";
201 }
else if (m_name ==
"Prob") {
203 }
else if (m_name ==
"ProbUW") {
205 }
else if (m_name ==
"ProbWW") {
207 }
else if (m_name ==
"Chi2") {
209 thresholdname=
"Chi2";
212 out<<
"Chi2Test_"+ m_name+
": Gives back "+thresholdname+
" after performing Chi2 test on histogram against referece histogram with option: "<<m_option<<
" (see TH1::GetChi2Test)"<<std::endl;
215 out<<
"Mandatory Green/Red Threshold: "+ thresholdname+
" : "+thresholdname+
" to give Green/Red result\n"<<std::endl;
217 out<<
"Optional Parameter: MinStat: Minimum histogram statistics needed to perform Algorithm\n"<<std::endl;