58{
60 const TH1* refhist=0;
61
62 if(
object.
IsA()->InheritsFrom(
"TH1" ) ) {
65 throw dqm_core::BadConfig( ERS_HERE, name, "dimension >= 2 " );
66 }
67 } else {
68 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
69 }
70
71
72 double minstat;
73 double bin_threshold;
74 double nErr;
75 double LowStatErr;
76 double LowStatThre;
77 double refcheck;
78 double greenTh;
79 double redTh;
80 try {
89 }
90 catch ( dqm_core::Exception & ex ) {
91 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
92 }
93
94
95 if (refcheck>0) {
96 try {
97 refhist =
static_cast<const TH1*
>(
config.getReference() );
98 }
99 catch ( dqm_core::Exception & ex ) {
100 throw dqm_core::BadRefHist(ERS_HERE,name," Could not retreive reference");
101 }
102 if (
histogram->GetDimension() != refhist->GetDimension() ) {
103 throw dqm_core::BadRefHist( ERS_HERE, name, "Reference VS histo: Different dimension!" );
104 }
105 if (
histogram->GetNbinsX() != refhist->GetNbinsX() ) {
106 throw dqm_core::BadRefHist( ERS_HERE, name, "Reference VS histo: Different number of bins!" );
107 }
108 }
109
110
111 if (
histogram->GetEntries() < minstat ) {
112 ERS_INFO(
"Histogram does not satisfy MinStat requirement " <<
histogram->GetName());
113 dqm_core::Result *
result =
new dqm_core::Result(dqm_core::Result::Undefined);
116 }
117 ERS_DEBUG(1,
"Statistics: "<<
histogram->GetEntries()<<
" entries ");
118
120 std::vector<int>
range;
123 } else {
124 ERS_INFO(
"Histogram has not dimension 1 : " <<
histogram->GetName());
125 throw dqm_core::Exception( ERS_HERE,
histogram->GetName() );
126 }
127 if (range[1] == 0) {
128 ERS_INFO(
"Empty histogram: " <<
histogram->GetName());
129 dqm_core::Result*
result =
new dqm_core::Result();
130 result->status_ = dqm_core::Result::Undefined;
131 ERS_DEBUG(1,"Undefined");
133 }
134
135 std::vector<int> Tubes;
136 int EmptyTubes =0;
137 int LowStatTubes =0;
138 for (
int i = range[0];
i <=
range[1]; ++
i ) {
139 double Content =
histogram->GetBinContent(i);
140 double ErrCont =
histogram->GetBinError(i);
141 if (ErrCont > LowStatErr) LowStatTubes++;
142 if (Content+std::abs(ErrCont) != 0.) {
143 if ((Content + nErr*ErrCont) < bin_threshold ) {
144 if (refcheck>0) {
145 double RefCont = refhist->GetBinContent(i);
146 double RefErrCont = refhist->GetBinError(i);
147 double Diff = std::abs(Content - RefCont);
148 double ErrDiff = sqrt(ErrCont*ErrCont + RefErrCont*RefErrCont);
149 if (Diff > nErr*ErrDiff) {
151 Tubes.push_back(i);
152 }
153 } else {
155 Tubes.push_back(i);
156 }
157 }
158 } else { ++EmptyTubes; }
159 }
160 ERS_DEBUG(1,
"Number of bins " << name <<
" different from a treshold of " << bin_threshold <<
" is " <<
count );
161
162 dqm_core::Result*
result =
new dqm_core::Result();
164 if (Tubes.size()>0) {
165 for (
int k=0;
k<(
int)Tubes.size();
k++) {
166 std::string ToDB="ChangedStatusTube_";
167 ToDB += std::to_string(k+1);
168 result->tags_[ToDB] = Tubes[
k];
169 ERS_DEBUG(1,"MDT Tube which changed status: "<<ToDB<<" = "<<Tubes[k] );
170 }
171 }
172
173 if ((EmptyTubes == range[1]) || ((static_cast<double>(LowStatTubes)/range[1]) > LowStatThre)) {
174 result->status_ = dqm_core::Result::Undefined;
175 ERS_DEBUG(1,"Undefined");
176 }
else if (
count >= redTh) {
177 result->status_ = dqm_core::Result::Red;
178 ERS_DEBUG(1,"Red");
179 }
else if (
count > greenTh) {
180 result->status_ = dqm_core::Result::Yellow;
181 ERS_DEBUG(1,"Yellow");
182 } else {
183 result->status_ = dqm_core::Result::Green;
184 ERS_DEBUG(1,"Green");
185 }
187}
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
#define IsA
Declare the TObject style functions.