41 const TObject &
object,
42 const dqm_core::AlgorithmConfig &
config )
46 if(
object.
IsA()->InheritsFrom(
"TH2" )) {
49 throw dqm_core::BadConfig( ERS_HERE, name,
"dimension != 2 " );
52 throw dqm_core::BadConfig( ERS_HERE, name,
"does not inherit from TH2");
65 std::set<int> ignoredBins;
66 for (
const std::pair<std::string,double> keyValuePair :
config.getParameters()) {
67 if (keyValuePair.first.compare(0, 9,
"IgnoreBin") == 0) {
68 ignoredBins.insert(keyValuePair.second);
74 refhist =
static_cast<TH2 *
>(
config.getReference() );
78 if(refhist->InheritsFrom(
"TH2" )) {
79 if (refhist->GetDimension() != 2 ){
80 throw dqm_core::BadConfig( ERS_HERE, name,
"reference histogram dimension != 2 " );
83 throw dqm_core::BadConfig( ERS_HERE, name,
"reference does not inherit from TH2");
85 if ((
histogram->GetNbinsX() != refhist->GetNbinsX()) || (
histogram->GetNbinsY() != refhist->GetNbinsY())) {
86 throw dqm_core::BadRefHist( ERS_HERE,
"number of bins", name );
93 if ( !testrows && okbin >
histogram->GetNbinsX() ) {
94 throw dqm_core::BadConfig( ERS_HERE, name,
" MaskedBin is outside range" );
96 if ( testrows && okbin >
histogram->GetNbinsY() ) {
97 throw dqm_core::BadConfig( ERS_HERE, name,
" MaskedBin is outside range" );
106 catch( dqm_core::Exception & ex ) {
107 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
115 int totalEntries = 0;
117 if (useTotalEntries) {
119 if (totalEntries == 0) {
125 if (entriesBin > -1) {
126 totalEntries =
histogram->GetBinContent(entriesBin);
127 useTotalEntries = (totalEntries == 0) ? 0 : 1;
130 dqm_core::Result*
result =
new dqm_core::Result();
133 std::vector<float> rowtotal;
136 if (dorate && !useTotalEntries) {
137 for(
int i =0; i<
max; ++i){ rowtotal.push_back(0.0); }
139 for(
int i =1; i<
histogram->GetNbinsX()+1; ++i){
140 for(
int j =1; j<
histogram->GetNbinsY()+1; ++j){
141 if(testrows==0 && j == maskedbin )
continue;
142 if(testrows==1 && i == maskedbin )
continue;
144 rowtotal[j-1] +=
histogram->GetBinContent(i,j);
146 rowtotal[i-1] +=
histogram->GetBinContent(i,j);
156 for(
int i =1; i<
histogram->GetNbinsX()+1; ++i){
157 for(
int j =1; j<
histogram->GetNbinsY()+1; ++j){
158 float bincontent=
histogram->GetBinContent(i,j);
160 if (useTotalEntries) {
161 bincontent /= totalEntries;
162 }
else if (testrows) {
163 bincontent /= rowtotal[j - 1];
165 bincontent /= rowtotal[i - 1];
169 if(bincontent>gthreshold){
170 if( testrows==1 &&
histogram->GetBinContent(maskedbin,j) != 0)
continue;
171 if( testrows==0 &&
histogram->GetBinContent(i,maskedbin) != 0)
continue;
174 if (ignoredBins.count(
bin))
continue;
177 if( refhist->GetBinContent(i,j) != 0){
178 if(bincontent < 1.0-gthreshold && bincontent > 1.0-rthreshold ) ++yellowrows;
179 if(bincontent < 1.0-rthreshold ) ++redrows;
183 if( testrows==0 && j == okbin){
184 if(bincontent < 1.0-gthreshold && bincontent > 1.0-rthreshold ) ++yellowrows;
185 if(bincontent < 1.0-rthreshold ) redrows++;
187 if( testrows==1 && i == okbin){
188 if(bincontent < 1.0-gthreshold && bincontent > 1.0-rthreshold ) ++yellowrows;
189 if(bincontent < 1.0-rthreshold ) ++redrows;
192 ERS_DEBUG(1,
"Found bin : ("<< i<<
","<<j<<
" ) = " << bincontent ) ;
195 if(bincontent>rthreshold){
209 result->tags_[
"RedRows"] = redrows;
210 result->status_ = dqm_core::Result::Red;
212 }
else if (yellowrows > 0 ){
213 result->tags_[
"YellowRows"] = yellowrows;
214 result->status_ = dqm_core::Result::Yellow;
221 result->tags_[
"RedBins"] = redcount;
222 result->status_ = dqm_core::Result::Red;
224 }
else if(yellowcount > 0 ) {
225 result->tags_[
"YellowBins"] = yellowcount;
226 result->status_ = dqm_core::Result::Yellow;
232 result->status_ = dqm_core::Result::Green;
static dqm_algorithms::BinContentComp myInstance