10 #include <dqm_core/AlgorithmConfig.h>
19 #include <dqm_core/AlgorithmManager.h>
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 );
117 if (useTotalEntries) {
125 if (entriesBin > -1) {
133 std::vector<float> rowtotal;
136 if (dorate && !useTotalEntries) {
137 for(
int i =0;
i<
max; ++
i){ rowtotal.push_back(0.0); }
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);
157 for(
int j =1; j<
histogram->GetNbinsY()+1; ++j){
158 float bincontent=
histogram->GetBinContent(
i,j);
160 if (useTotalEntries) {
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;
212 }
else if (yellowrows > 0 ){
213 result->tags_[
"YellowRows"] = yellowrows;
214 result->status_ = dqm_core::Result::Yellow;
221 result->tags_[
"RedBins"] = redcount;
224 }
else if(yellowcount > 0 ) {
225 result->tags_[
"YellowBins"] = yellowcount;
226 result->status_ = dqm_core::Result::Yellow;
241 out<<
"MaskedBinRow: Does a bins over threshold test in columns/rows but ignores columns/rows if a 'masked' bin has entries\n"<<std::endl;
243 out<<
"Mandatory Parameter: MaskedBin : This is the row or column that has the 'masked' bins. \n"<<std::endl;
245 out<<
"Optional Parameter: TestRows : If masked bin has entries, ignore entries in row rather than columns when parameter is set to 1. default = 0 "<<std::endl;
246 out<<
"Optional Parameter: OkBin : This is the row or column that has the 'ok' bin and will be ignored when preforming the algorithm "<<std::endl;
247 out<<
"Optional Parameter: DoRate : This tells the algorithm to check the rate of digital errors rather than an absolute number"<<std::endl;
248 out<<
"Optional Parameter: CheckStrip : To be used with DoRate. Rather than check individual bins, it checks that the fraction of events outside the ok bin is below the threshold."<<std::endl;
249 out<<
"Optional Parameter: UseReference : Reference histogram with entries in the 'ok' bins will be used to indicate that these bins should be ignored when parameter is set to 1. default = 0 "<<std::endl;
250 out<<
"Optional Parameter: UseTotalEntries : The rate of digital errors will be checked against total number of entries in histogram : default = 0 "<<std::endl;
251 out<<
"Optional Parameter: EntriesBin : The rate of digital errors will be checked against content of global bin, if it is not negative : default = -1 "<<std::endl;
252 out<<
"Optional Parameter: IgnoreBin* : Ignore during this test specified global bin, where * unique characters (can be used many times to ignore many bins)"<<std::endl;