44{
47 TH1* passed_histogram = 0;
48 TH1* total_histogram = 0;
49
50 if(
object.
IsA()->InheritsFrom(
"TH1" )) {
53 throw dqm_core::BadConfig( ERS_HERE, name, "dimension > 2 " );
54 }
55 }
else if(
object.
IsA()->InheritsFrom(
"TEfficiency" )) {
56
59 throw dqm_core::BadConfig( ERS_HERE, name, "dimension > 2 " );
60 }
61
62 passed_histogram =
efficiency->GetCopyPassedHisto();
63 total_histogram =
efficiency->GetCopyTotalHisto();
64 passed_histogram->Divide(total_histogram);
65
66 } else {
67 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1 or TEfficiency");
68 }
69
71 double current_stat = 0;
72
73 if(
object.
IsA()->InheritsFrom(
"TH1" )) {
75 }
else if(
object.
IsA()->InheritsFrom(
"TEfficiency" )){
76 current_stat = total_histogram->GetEntries();
77 }
78
79 if(current_stat < minstat ) {
80 dqm_core::Result *
result =
new dqm_core::Result(dqm_core::Result::Undefined);
81 result->tags_[
"InsufficientEntries"] = current_stat;
83 }
84
85 TH1 * refhist = 0;
86 TH1 * ref_total_hist;
87 TEfficiency * refeff;
88 double gthresho;
89 double rthresho;
90 std::string option;
91 std::string thresholdname="P";
92 if (
m_name ==
"Chi2_per_NDF") {
93 option="Chi2/ndfUU";
94 thresholdname="Chi2_per_NDF";
95 }
else if (
m_name ==
"Prob" ) {
96 option="UU";
97 }
else if (
m_name ==
"ProbUW") {
98 option="UW";
99 }
else if (
m_name ==
"ProbWW") {
100 option="WW";
101 }
else if (
m_name ==
"Chi2") {
102 option="CHI2UU";
103 thresholdname="Chi2";
104 } else {
105 throw dqm_core::BadConfig( ERS_HERE,
"None",
m_name );
106 }
107 try {
110 }
111 catch ( dqm_core::Exception & ex ) {
112 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
113
114 }
115
116 if(
object.
IsA()->InheritsFrom(
"TH1" )) {
117 try {
118 refhist =
dynamic_cast<TH1 *
>(
config.getReference() );
119 }
120 catch ( dqm_core::Exception & ex ) {
121 throw dqm_core::BadRefHist(ERS_HERE,name," Could not retreive reference");
122 }
123 }
else if(
object.
IsA()->InheritsFrom(
"TEfficiency" )){
124 try {
125 refeff =
dynamic_cast<TEfficiency *
>(
config.getReference() );
126 }
127 catch ( dqm_core::Exception & ex ) {
128 throw dqm_core::BadRefHist(ERS_HERE,name," Could not retreive reference");
129 }
130
131 refhist = refeff->GetCopyPassedHisto();
132 ref_total_hist = refeff->GetCopyTotalHisto();
133 refhist->Divide(ref_total_hist);
134 }
135
136 if (!refhist) { throw dqm_core::BadRefHist(ERS_HERE,name,"Bad reference type"); }
137
139 if(
object.
IsA()->InheritsFrom(
"TH1" )) {
140
141 if (
histogram->GetDimension() != refhist->GetDimension() ) {
142 throw dqm_core::BadRefHist( ERS_HERE, "Dimension", name );
143 }
144
145 if ((
histogram->GetNbinsX() != refhist->GetNbinsX()) || (
histogram->GetNbinsY() != refhist->GetNbinsY())) {
146 throw dqm_core::BadRefHist( ERS_HERE, "number of bins", name );
147 }
148
150
151 }
else if(
object.
IsA()->InheritsFrom(
"TEfficiency" )){
152
153 if (passed_histogram->GetDimension() != refhist->GetDimension() ) {
154 throw dqm_core::BadRefHist( ERS_HERE, "Dimension", name );
155 }
156
157 if ((passed_histogram->GetNbinsX() != refhist->GetNbinsX()) || (passed_histogram->GetNbinsY() != refhist->GetNbinsY())) {
158 throw dqm_core::BadRefHist( ERS_HERE, "number of bins", name );
159 }
160
161 value = passed_histogram->Chi2Test( refhist, option.c_str() );
162 }
163
164 ERS_DEBUG(1,"Green threshold: "<< gthresho << "; Red threshold: " << rthresho );
165 ERS_DEBUG(1,"Chi2 Test with Option " << option << " is " << value );
166
167 dqm_core::Result*
result =
new dqm_core::Result();
169
170 if (thresholdname == "P") {
171 if ( value >= gthresho ) {
172 result->status_ = dqm_core::Result::Green;
173 } else if ( value > rthresho ) {
174 result->status_ = dqm_core::Result::Yellow;
175 } else {
176 result->status_ = dqm_core::Result::Red;
177 }
178 } else {
179 if ( value <= gthresho ) {
180 result->status_ = dqm_core::Result::Green;
181 } else if ( value < rthresho ) {
182 result->status_ = dqm_core::Result::Yellow;
183 } else {
184 result->status_ = dqm_core::Result::Red;
185 }
186
187 }
188
189 ERS_DEBUG(2,"Result: "<<*result);
191
192}
void efficiency(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
#define IsA
Declare the TObject style functions.