35{
36
37
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" ); }
43
45
50
52 dqm_core::Result *
result =
new dqm_core::Result(dqm_core::Result::Undefined);
55 }
56
57 double gthreshold = 0., rthreshold = 0.;
58 try {
61 } catch( dqm_core::Exception & ex ) {
62 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
63 }
64
65
67 dqm_core::Result*
result =
new dqm_core::Result();
68 std::vector<bin2> redbins;
69 std::vector<bin2> yellowbins;
70 std::vector<bin2> Allbins;
71
72
73 TH1D* projected_strip = NULL;
75 int ix,iy;
76 int binphi,biny,binz;
78 double binval = 0., maxval = 0.;
79
80 double stripavg = 0.,striperr = 0.,striperr2 = 0.,testval = 0.;
81
82
83 int poissonLimit = 5;
84
85
86
87 for(ix = range[0]; ix <=
range[1]; ++ix){
88
90
91
92 sprintf(hname,
"%s_py_bin%d",
histogram->GetName(),ix);
93 projected_strip =
histogram->ProjectionY(hname,ix,ix);
96
97
98
99
100
101
102
103 while(true){
104
105 striperr = 0.;
106 striperr2 = 0.;
107
108
109 if(
nmax==0)
for(iy=1;iy<=projected_strip->GetXaxis()->GetNbins();iy++)
if(projected_strip->GetBinContent(iy)>0)
nbins += 1;
110
111
112 projected_strip->GetMaximumBin(binphi,biny,binz);
113 maxval = projected_strip->GetBinContent(binphi);
114 binval = maxval;
115
116
117 if(nbins<=0) break;
118
119
120 stripavg = projected_strip->Integral()/(
double)nbins;
121
122
123 if(nbins<=poissonLimit){
124
125
126 striperr = std::sqrt(stripavg);
127
128 } else {
129
130
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);
132
133 striperr = std::sqrt(striperr2)/std::sqrt((double)nbins);
134
135 }
136
137
138 if(striperr>0.) testval = std::abs(maxval-stripavg)/striperr;
139 else testval = 0.;
140
141
142 bool die = false;
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);
147 else {
148 Allbins.push_back(onebin);
149 die = true;
150 }
151
152
153
154
155 if(die) break;
156
157
158 projected_strip->SetBinContent(binphi,0);
161
162 }
163
164 delete projected_strip;
165
166 }
167
168
169
173 char tmpstr[500];
174 int count_red=0,count_yellow=0;
175
176
177 for(
unsigned int i=0;
i<redbins.size();
i++){
178 if(VisualMode) continue;
179 if(publish){
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;
183 }
184 count_red++;
185 if(NpublishRed > 0){
186 if(count_red > NpublishRed) break;
187 }
188 }
189
190
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;
197 }
198 count_yellow++;
199 }
200 result->tags_[
"NRedBins"] = count_red;
201 result->tags_[
"NYellowBins"] = count_yellow;
202
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;
208 }
209 }
210
211 if(count_red>0)
result->status_ = dqm_core::Result::Red;
212 else if(count_yellow>0)
result->status_ = dqm_core::Result::Yellow;
213 else result->status_ = dqm_core::Result::Green;
214
216}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
setBGCode setTAP setLVL2ErrorBits bool
#define IsA
Declare the TObject style functions.