53 const TObject &
object,
54 const dqm_core::AlgorithmConfig & config )
58 if(
object.
IsA()->InheritsFrom(
"TH1" ) ) {
59 histogram =
static_cast<const TH1*
>(&object);
61 throw dqm_core::BadConfig( ERS_HERE, name,
"dimension > 2 " );
64 throw dqm_core::BadConfig( ERS_HERE, name,
"does not inherit from TH1" );
77 std::vector<std::string> hotRows;
78 std::vector<std::string> hotCols;
79 std::vector<std::pair<std::string,std::string>> hotBins;
84 dqm_core::Result *result =
new dqm_core::Result(dqm_core::Result::Undefined);
85 result->tags_[
"InsufficientEntries"] =
histogram->GetEntries();
97 catch ( dqm_core::Exception & ex ) {
98 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
104 dqm_core::Result* result =
new dqm_core::Result();
108 }
else if (
histogram->InheritsFrom(
"TH1")) {
111 throw dqm_core::BadConfig( ERS_HERE, name,
"does not inherit from TH1" );
114 resulthisto->Reset();
115 if(
m_name.find(
"Median")!=std::string::npos){
116 std::vector<double> bin_vals;
117 for (
int i = range[0]; i <= range[1]; ++i ) {
118 for (
int j = range[2]; j <= range[3]; ++j ) {
119 if(
histogram -> GetBinContent(i,j) > 0) bin_vals . push_back(
histogram -> GetBinContent(i,j) );
122 std::sort(bin_vals.begin(), bin_vals.end());
123 unsigned bin_vals_size = bin_vals.size();
125 if(bin_vals_size%2==0 && bin_vals_size>1) median = (bin_vals.at(bin_vals_size/2-1)+bin_vals.at(bin_vals_size/2))/2;
126 else if(bin_vals_size%2==1 && bin_vals_size>1) median = bin_vals.at(bin_vals_size/2-1);
127 else if(bin_vals_size==1) median = bin_vals.at(0);
131 bin_threshold=median*bin_threshold;
133 bin_threshold = std::max(bin_threshold, min_bin_threshold);
134 if(max_bin_threshold > -1 ) bin_threshold = std::min(bin_threshold, max_bin_threshold);
136 result->tags_[
"Effective_BinThreshold"] = bin_threshold;
142 std::pair<bool,bool> skipBin;
143 std::pair<const char*, const char*> binLabel;
145 for (
int i = range[0]; i <= range[1]; ++i ) {
147 binLabel.first =
nullptr;
148 binLabel.second =
nullptr;
150 if ( !hotCols.empty() ) {
151 for (
const auto& col : hotCols){
154 binLabel.first =
histogram->GetXaxis()->GetBinLabel(i);
155 if ( std::to_string(i)==col || TString(binLabel.first).Contains(TRegexp((col).c_str(),
true)) )
skipCol =
true;
166 for (
int j = range[2]; j <= range[3]; ++j ) {
168 binLabel.first =
nullptr;
169 binLabel.second =
nullptr;
171 if ( !hotRows.empty() ) {
172 for (
const auto& row : hotRows){
175 binLabel.second =
histogram->GetYaxis()->GetBinLabel(j);
176 if ( std::to_string(j)==row || TString(binLabel.second).Contains(TRegexp((row).c_str(),
true)) )
skipRow =
true;
182 skipBin.first =
false;
183 skipBin.second =
false;
184 binLabel.first =
nullptr;
185 binLabel.second =
nullptr;
187 if ( !hotBins.empty() ) {
188 for (
const auto&
bin : hotBins){
191 binLabel.first =
histogram->GetXaxis()->GetBinLabel(i);
192 if ( std::to_string(i)==
bin.first || TString(binLabel.first).Contains(TRegexp((
bin.first).c_str(),
true)) ) skipBin.first =
true;
195 binLabel.second =
histogram->GetYaxis()->GetBinLabel(j);
196 if ( std::to_string(j)==
bin.second || TString(binLabel.second).Contains(TRegexp((
bin.second).c_str(),
true)) ) skipBin.second =
true;
200 if (skipBin.first && skipBin.second)
continue;
207 double content=
histogram -> GetBinContent(i,j);
210 resulthisto->SetBinContent(i,j,content);
211 if (publish &&
count< maxpublish){
218 ERS_DEBUG(1,
"Number of bins " <<
m_name <<
" treshold of " << bin_threshold <<
" is " <<
count );
219 ERS_DEBUG(1,
"Green threshold: "<< gthreshold <<
" bin(s); Red threshold : " << rthreshold <<
" bin(s) ");
225 if(
m_name.find(
"LessThan")!=std::string::npos) result->tags_[
"NBins_%"] = 100.*effectiveCount/TotalBins;
226 else result->tags_[
"NBins_%"] = 100.*
count/TotalBins;
229 result->tags_[
"NBins"] =
count;
230 result->object_ = boost::shared_ptr<TObject>(resulthisto);
231 if (gthreshold > rthreshold) {
232 if (
count >= gthreshold ) {
233 result->status_ = dqm_core::Result::Green;
234 }
else if (
count > rthreshold ) {
235 result->status_ = dqm_core::Result::Yellow;
237 result->status_ = dqm_core::Result::Red;
240 if (
count <= gthreshold ) {
241 result->status_ = dqm_core::Result::Green;
242 }
else if (
count < rthreshold ) {
243 result->status_ = dqm_core::Result::Yellow;
245 result->status_ = dqm_core::Result::Red;
271 std::vector<std::string>& ignoredRows,
272 std::vector<std::string>& ignoredCols,
273 std::vector<std::pair<std::string,std::string>>& ignoredBins) {
275 std::string inputBins_new =
"";
276 for (
char c : inputBins)
if (c !=
'"') inputBins_new+=c;
278 if (!inputBins_new.empty()) {
279 std::stringstream
ss(inputBins_new);
282 while (std::getline(
ss, token,
',')) {
283 std::stringstream pairStream(token);
284 std::string first, second;
286 if (std::getline(pairStream, first,
':') && std::getline(pairStream, second,
':')) {
288 ignoredRows.push_back(std::move(second));
289 }
else if (second ==
"*") {
290 ignoredCols.push_back(std::move(first));
292 ignoredBins.push_back(std::make_pair(first,second));