46{
47 const TH2 * inputgraph;
48
49 if(
object.
IsA()->InheritsFrom(
"TH1" )) {
50 inputgraph =
static_cast<const TH2*
>( &
object );
51
52 } else {
53 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
54 }
55
56
58
59 if (inputgraph->GetEntries() < minstat ) {
60 dqm_core::Result *
result =
new dqm_core::Result(dqm_core::Result::Undefined);
61 result->tags_[
"InsufficientEntries"] = inputgraph->GetEntries();
63 }
64
65
66 TH2 * refhist;
67 double gthresho;
68 double rthresho;
69 std::string option;
70
71
72
73 std::string thresholdname="NBins";
74
75 try {
78 }
79 catch ( dqm_core::Exception & ex ) {
80 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
81
82 }
83
84
85 try {
86 refhist =
static_cast<TH2 *
>(
config.getReference() );
87 }
88 catch ( dqm_core::Exception & ex ) {
89 throw dqm_core::BadRefHist(ERS_HERE,name," Could not retreive reference");
90 }
91
92 if (inputgraph->GetDimension() != refhist->GetDimension() ) {
93 throw dqm_core::BadRefHist( ERS_HERE, "Dimension", name );
94 }
95
96 if ((inputgraph->GetNbinsX() != refhist->GetNbinsX()) || (inputgraph->GetNbinsY() != refhist->GetNbinsY())) {
97 throw dqm_core::BadRefHist( ERS_HERE, "number of bins", name );
98 }
99
100
101
102
103
104
105
106
107
109
110
112{double ref_entries=refhist->GetEntries();
113 double input_entries=inputgraph->GetEntries();
114
115 const_cast<TH2*>(inputgraph)->Sumw2();
116 refhist->Sumw2();
117
118 refhist->Scale(input_entries/ref_entries);
119}
120
121
122
126
127
128std::vector<int>
range;
129try{
131}
132catch( dqm_core::Exception & ex ) {
133 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
134 }
135
136
138 int j=0;
139 double chisq=0;
140 double errsquared;
141 double inputerr;
142 double referr;
144 double refval;
145 double partsum;
146 int count_ndf=0;
147
148
149
150
151 std::vector<double> ChisqValues;
152 std::map<double,int> mymap;
153
154 for(i=range[0];
i<(
range[1]+1);
i++)
155 {
156 for(j=range[2];j<(
range[3]+1);j++)
157 {
158 val=inputgraph->GetBinContent(i,j);
159 refval=refhist->GetBinContent(i,j);
160 inputerr=inputgraph->GetBinError(i,j);
161 referr=refhist->GetBinError(i,j);
162 errsquared=referr*referr+inputerr*inputerr;
163 if(errsquared > 0.000001)
164 {
165 partsum=((
val-refval)*(
val-refval))/errsquared;
166 }
167 else
168 {partsum=-1;
169 }
170
171 if (partsum != -1)
172 { chisq=chisq+partsum;
173 count_ndf++;
174
175 if(partsum>=NSigma*NSigma)
176 { ChisqValues.push_back(std::sqrt(partsum));
177 mymap.insert(std::pair<double,int>(std::sqrt(partsum),inputgraph->GetBin(i,j)));
178 }
179
180 }
181
182
183 }
184
185 }
186
187 double ndf=count_ndf-1;
189 dqm_core::Result*
result =
new dqm_core::Result();
190
192
193
194
195
196 std::sort(ChisqValues.begin(),ChisqValues.end());
197
198
199
200 std::vector<double>::iterator
p;
202
203
205
206
207 std::map<double,int>::iterator
p2;
208
209
210char ctag[256];
212int global_bin=0;
213int xbinnumber;
214int ybinnumber;
215int zbinnumber;
216int& xBin = xbinnumber;
217int& yBin = ybinnumber;
218int& zBin = zbinnumber;
219int globalbinint=0;
222
223
225
226
227
228if(mymap.size()==0)
229{
result->tags_[
"No flagged bins were found"]=1.0;
230}
231
232
233while(mymap.size()>0)
234{
235
236
237
238
240 if(p2 !=mymap.end())
241 { global_bin=
p2->second;
242 globalbinint= (
int) global_bin;
243 inputgraph->GetBinXYZ(globalbinint,xBin,yBin,zBin);
244 eta=inputgraph->GetXaxis()->GetBinCenter(xBin);
245 phi=inputgraph->GetYaxis()->GetBinCenter(yBin);
246
247
248 sprintf(ctag,
" (eta,phi)=(%f,%f) ",
eta,
phi);
250
251 if(*p>=MaxSigma)
253
254 }
255
256 else
257 {
258 sprintf(ctag,"eta_%i_error",k);
260 sprintf(ctag,"phi_%i_error",k);
262 }
263
264
265 if(p==ChisqValues.begin()||k>Num_to_print)
266 {break;}
267
270 }
271
272
273
274result->tags_[
"MaxSigma"]=MaxSigma;
275result->tags_[
"NSigma"]=NSigma;
276result->tags_[
"Max Bins to Publish"]=Num_to_print;
277
278
279
280 int BinsOver=ChisqValues.size();
281 result->tags_[
"NBinsOver"]=BinsOver;
282
283
284
285 if ( (BinsOver <= gthresho) &&
veto==0 ) {
286 result->status_ = dqm_core::Result::Green;
287 }
else if ( (BinsOver < rthresho) &&
veto==0 ) {
288 result->status_ = dqm_core::Result::Yellow;
289 } else {
290 result->status_ = dqm_core::Result::Red;
291 }
292
293 ERS_DEBUG(2,"Result: "<<*result);
294
296
297}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
std::vector< std::string > veto
these patterns are anded
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
#define IsA
Declare the TObject style functions.