12 #include <dqm_core/AlgorithmConfig.h>
15 #include <dqm_core/AlgorithmManager.h>
39 if(
object.
IsA()->InheritsFrom(
"TH2") ){
41 if(
histogram->GetDimension() != 2 ){
throw dqm_core::BadConfig( ERS_HERE,
name,
"Not a 2D-histogram" ); }
42 }
else {
throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH1/TH2" ); }
57 double gthreshold = 0., rthreshold = 0.;
61 }
catch( dqm_core::Exception & ex ) {
62 throw dqm_core::BadConfig( ERS_HERE,
name, ex.what(), ex );
68 std::vector<bin2> redbins;
69 std::vector<bin2> yellowbins;
70 std::vector<bin2> Allbins;
73 TH1D* projected_strip = NULL;
78 double binval = 0., maxval = 0.;
80 double stripavg = 0.,striperr = 0.,striperr2 = 0.,testval = 0.;
89 double eta =
histogram->GetXaxis()->GetBinCenter(ix);
109 if(
nmax==0)
for(iy=1;iy<=projected_strip->GetXaxis()->GetNbins();iy++)
if(projected_strip->GetBinContent(iy)>0)
nbins += 1;
112 projected_strip->GetMaximumBin(binphi,biny,binz);
113 maxval = projected_strip->GetBinContent(binphi);
120 stripavg = projected_strip->Integral()/(
double)
nbins;
123 if(
nbins<=poissonLimit){
126 striperr = std::sqrt(stripavg);
131 for(iy=1;iy<=projected_strip->GetXaxis()->GetNbins();iy++)
if(projected_strip->GetBinContent(iy)>0) striperr2 +=
std::pow((projected_strip->GetBinContent(iy)-stripavg),2);
133 striperr = std::sqrt(striperr2)/std::sqrt((
double)
nbins);
138 if(striperr>0.) testval = std::abs(maxval-stripavg)/striperr;
143 double phi = projected_strip->GetXaxis()->GetBinCenter(binphi);
144 bin2 onebin = {eta,phi,ix,binphi,binval,testval};
145 if(testval > rthreshold) redbins.push_back(onebin);
146 else if(testval > gthreshold) yellowbins.push_back(onebin);
148 Allbins.push_back(onebin);
158 projected_strip->SetBinContent(binphi,0);
164 delete projected_strip;
170 std::sort(redbins.begin(),redbins.end(),
mySortfunc);
171 std::sort(yellowbins.begin(),yellowbins.end(),
mySortfunc);
174 int count_red=0,count_yellow=0;
177 for(
unsigned int i=0;
i<redbins.size();
i++){
178 if(VisualMode)
continue;
180 sprintf(tmpstr,
"R%i-(eta,phi)[OSRatio]=(%0.3f,%0.3f)[%0.2e]",count_red,redbins[
i].m_eta,redbins[
i].m_phi,redbins[
i].m_deviation);
181 std::string
tag = tmpstr;
186 if(count_red > NpublishRed)
break;
191 for(
unsigned int i=0;
i<yellowbins.size();
i++){
192 if(VisualMode)
continue;
193 if(publish && (count_red+count_yellow) < Nmaxpublish ){
194 sprintf(tmpstr,
"Y%i-(eta,phi)[OSRatio]=(%0.3f,%0.3f)[%.2e]",count_yellow,yellowbins[
i].m_eta,yellowbins[
i].m_phi,yellowbins[
i].m_deviation);
195 std::string
tag = tmpstr;
200 result->tags_[
"NRedBins"] = count_red;
201 result->tags_[
"NYellowBins"] = count_yellow;
203 if(count_red+count_yellow==0 && Allbins.size()>0){
204 for(
unsigned int i=0;
i<Allbins.size();
i++){
205 sprintf(tmpstr,
"LeadingBin%u-(eta,phi)=(%0.3f,%0.3f)",
i,Allbins[
i].m_eta,Allbins[
i].m_phi);
206 std::string tagtag = tmpstr;
207 result->tags_[tagtag] = Allbins[
i].m_value;
212 else if(count_yellow>0)
result->status_ = dqm_core::Result::Yellow;
221 out<<
"KillBinsByStrip: Selects out outlier bins from a 2D histogram, by strip, by gradually re-calculating the strip average without those bins."<<std::endl;
222 out<<
" Assumes that y-axis (phi coordinates) is symmetric from detector design."<<std::endl;
224 out<<
"Optional Parameter: MinStat: Minimum histogram statistics needed to perform Algorithm"<<std::endl;
225 out<<
"Optional Parameter: ignoreval: valued to be ignored for being processed"<<std::endl;
226 out<<
"Optional Parameter: PublishBins: Save bins which are different from average in Result (on:1,off:0,default is 1)"<<std::endl;
227 out<<
"Optional Parameter: MaxPublish: Max number of bins to save (default 20)"<<std::endl;
228 out<<
"Optional Parameter: VisualMode: is to make the evaluation process similar to the shift work, so one will get resonable result efficiently."<<std::endl;