9 #include <dqm_core/AlgorithmConfig.h>
19 #include <dqm_core/AlgorithmManager.h>
52 const TObject &
object,
53 const dqm_core::AlgorithmConfig &
config )
57 if(
object.
IsA()->InheritsFrom(
"TH1" ) ) {
60 throw dqm_core::BadConfig( ERS_HERE,
name,
"dimension > 2 " );
63 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH1" );
84 catch ( dqm_core::Exception & ex ) {
85 throw dqm_core::BadConfig( ERS_HERE,
name, ex.what(), ex );
95 }
else if (
histogram->InheritsFrom(
"TH1")) {
98 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH1" );
101 resulthisto->Reset();
102 if(m_name.find(
"Median")!=std::string::npos){
103 std::vector<double> bin_vals;
105 for (
int j =
range[2]; j <=
range[3]; ++j ) {
106 if(
histogram -> GetBinContent(
i,j) > 0) bin_vals . push_back(
histogram -> GetBinContent(
i,j) );
109 std::sort(bin_vals.begin(), bin_vals.end());
110 unsigned bin_vals_size = bin_vals.size();
112 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;
113 else if(bin_vals_size%2==1 && bin_vals_size>1)
median = bin_vals.at(bin_vals_size/2-1);
114 else if(bin_vals_size==1)
median = bin_vals.at(0);
118 bin_threshold=
median*bin_threshold;
120 bin_threshold =
std::max(bin_threshold, min_bin_threshold);
121 if(max_bin_threshold > -1 ) bin_threshold =
std::min(bin_threshold, max_bin_threshold);
123 result->tags_[
"Effective_BinThreshold"] = bin_threshold;
127 for (
int j =
range[2]; j <=
range[3]; ++j ) {
129 if ( CompareBinThreshold(m_name,
content, bin_threshold )) {
131 resulthisto->SetBinContent(
i,j,
content);
132 if (publish &&
count< maxpublish){
139 ERS_DEBUG(1,
"Number of bins " << m_name <<
" treshold of " << bin_threshold <<
" is " <<
count );
140 ERS_DEBUG(1,
"Green threshold: "<< gthreshold <<
" bin(s); Red threshold : " << rthreshold <<
" bin(s) ");
146 if(m_name.find(
"LessThan")!=std::string::npos)
result->tags_[
"NBins_%"] = 100.*effectiveCount/TotalBins;
147 else result->tags_[
"NBins_%"] = 100.*
count/TotalBins;
151 result->object_ = (boost::shared_ptr<TObject>)(TObject*)(resulthisto);
152 if (gthreshold > rthreshold) {
153 if (
count >= gthreshold ) {
155 }
else if (
count > rthreshold ) {
156 result->status_ = dqm_core::Result::Yellow;
161 if (
count <= gthreshold ) {
163 }
else if (
count < rthreshold ) {
164 result->status_ = dqm_core::Result::Yellow;
178 if (
type ==
"GreaterThanAbs")
return (std::abs(bincontent) >
threshold);
179 if (
type ==
"GreaterThanNonZeroMedian")
return (bincontent >
threshold);
181 if (
type ==
"LessThanAbs")
return (std::abs(bincontent) <
threshold);
182 if (
type ==
"LessThanNonZeroMedian")
return (bincontent <
threshold);
183 if (
type ==
"LessThanEqual")
return (bincontent <=
threshold);
184 if (
type ==
"GreaterThanEqual")
return (bincontent >=
threshold);
196 out<<
"Bins_"+m_name+
"_Threshold: Checks for number of bins "+m_name+
" threshold value\n"<<std::endl;
198 out<<
"Mandatory Parameter: BinThreshold: Look for bins "+m_name+
" BinTreshold; Count number of bins satifying requirement \n"<<std::endl;
200 out<<
"Mandatory Green/Red Threshold: NBins: Number of bins satifying "+m_name+
" BinThreshold constraint to give Green/Red result\n"<<std::endl;
202 out<<
"Optional Parameter: PublishBins: Save bins which are different from average in Result (set to 1)\n"<<std::endl;
203 out<<
"Optional Parameter: MaxPublish: Max number of bins to save (default 20)"<<std::endl;
204 out<<
"Optional Parameter: MinStat: Minimum histogram statistics needed to perform Algorithm"<<std::endl;
205 out<<
"Optional Parameter: xmin: minimum x range"<<std::endl;
206 out<<
"Optional Parameter: xmax: maximum x range"<<std::endl;
207 out<<
"Optional Parameter: ymin: minimum y range"<<std::endl;
208 out<<
"Optional Parameter: ymax: maximum y range\n"<<std::endl;