19 #include "dqm_core/exceptions.h"
20 #include "dqm_core/AlgorithmConfig.h"
21 #include "dqm_core/AlgorithmManager.h"
22 #include "dqm_core/Result.h"
43 : m_name(
"MDTMLoverview")
67 if(
object.
IsA()->InheritsFrom(
"TH1" ) ) {
69 if (
hist->GetDimension() >= 2 ){
70 throw dqm_core::BadConfig( ERS_HERE,
name,
"dimension >= 2 " );
73 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH1" );
89 catch ( dqm_core::Exception & ex ) {
90 throw dqm_core::BadConfig( ERS_HERE,
name, ex.what(), ex );
96 ref =
static_cast<const TH1*
>(
config.getReference() );
98 catch ( dqm_core::Exception & ex ) {
99 throw dqm_core::BadRefHist(ERS_HERE,
name,
" Could not retrieve reference");
102 if (
hist->GetDimension() !=
ref->GetDimension() ) {
103 throw dqm_core::BadRefHist( ERS_HERE,
name,
"Reference VS histo: Different dimension!" );
105 if (
hist->GetNbinsX() !=
ref->GetNbinsX() ) {
106 throw dqm_core::BadRefHist( ERS_HERE,
name,
"Reference VS histo: Different bin number in X axis!" );
110 if (
hist->GetEntries() < minstat ) {
111 ERS_INFO(
"Histogram does not satisfy MinStat requirement " <<
hist->GetName());
113 result->tags_[
"InsufficientEntries"] =
hist->GetEntries();
116 ERS_DEBUG(1,
"Statistics: "<<
hist->GetEntries()<<
" entries ");
124 std::vector<int> hist_buffer;
125 std::vector<int> ref_buffer;
127 std::vector< double > new_empty_bins;
130 for(
int x_index=1; x_index<=
binX; x_index++){
131 if(
hist->GetBinContent(x_index) != 0 ) hist_buffer.push_back((
int)
hist->GetBinContent(x_index));
133 if(
ref->GetBinContent(x_index) != 0 ) ref_buffer.push_back((
int)
ref->GetBinContent(x_index));
139 auto median=[](std::vector<int> &
v)->
int {
140 const auto midPoint =
v.begin()+
v.size()/2;
141 std::nth_element(
v.begin(), midPoint,
v.end());
142 return v[
v.size()/2];
146 double percentThreshold =
thresh*0.01;
147 const int mediana_hist =
median(hist_buffer);
150 const int mediana_ref =
median(ref_buffer);
151 for(
int xi=1; xi<=
binX; xi++){
152 if(
hist->GetBinContent(xi) < mediana_hist*percentThreshold &&
ref->GetBinContent(xi) >= mediana_ref*percentThreshold){
154 new_empty_bins.push_back(
hist->GetBinCenter(xi));
157 }
else if(ref_y_n==0){
158 for(
int xi=1; xi<=
binX; xi++){
159 if(
hist->GetBinContent(xi) < mediana_hist*percentThreshold){
161 new_empty_bins.push_back(
hist->GetBinCenter(xi));
175 std::string eta=
"ETA_";
176 std::string ml=
"__ML";
182 int empty_bin_number=new_empty_bins.size();
184 for(
int i=0;
i<empty_bin_number;
i++){
189 }
while(std::abs(
counter-new_empty_bins[
i])>0.3);
191 snprintf(eta_num,
sizeof(eta_num),
"%d",
counter);
192 if( (
counter-new_empty_bins[
i])>=0)ml_num=
"1";
193 if( (
counter-new_empty_bins[
i])<0) ml_num=
"2";
194 message=eta+(std::string)eta_num+ml+ml_num;
204 ERS_DEBUG(1,
"Green");
206 result->status_ = dqm_core::Result::Yellow;
207 ERS_DEBUG(1,
"Yellow");
208 }
else if (
count>=redTh) {
222 message +=
"Description: compare the histo with reference and check if there are any ML switched off\n";
223 message +=
"Mandatory Green/Red Threshold: Limits: number of new ML switched off while are on in reference\n";
224 message +=
" thresh = % of the mean entries per ML under which the algo will set ML off\n";
225 message +=
"Optional Parameters: MinStat = Minimum histogram statistics needed to perform Algorithm\n";
226 message +=
" ref = Bool value: 1 if you want perform the check comparing with ref\n";
227 message +=
" 0 if you want perform the check without the comparison with ref\n";