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;
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
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;
188 if (ndf == 0){
189 throw dqm_core::BadConfig( ERS_HERE, name, "ndf is zero!" );
190 }
192 dqm_core::Result*
result =
new dqm_core::Result();
193
195
196
197
198
199 std::sort(ChisqValues.begin(),ChisqValues.end());
200
201
202
203 std::vector<double>::iterator
p;
205
206
208
209
210 std::map<double,int>::iterator
p2;
211
212
213char ctag[256];
215int global_bin=0;
216int xbinnumber;
217int ybinnumber;
218int zbinnumber;
219int& xBin = xbinnumber;
220int& yBin = ybinnumber;
221int& zBin = zbinnumber;
222int globalbinint=0;
225
226
228
229
230
231if(mymap.size()==0)
232{
result->tags_[
"No flagged bins were found"]=1.0;
233}
234
235
236while(mymap.size()>0)
237{
238
239
240
241
243 if(p2 !=mymap.end())
244 { global_bin=
p2->second;
245 globalbinint= (
int) global_bin;
246 inputgraph->GetBinXYZ(globalbinint,xBin,yBin,zBin);
247 eta=inputgraph->GetXaxis()->GetBinCenter(xBin);
248 phi=inputgraph->GetYaxis()->GetBinCenter(yBin);
249
250
251 sprintf(ctag,
" (eta,phi)=(%f,%f) ",
eta,
phi);
253
254 if(*p>=MaxSigma)
256
257 }
258
259 else
260 {
261 sprintf(ctag,"eta_%i_error",k);
263 sprintf(ctag,"phi_%i_error",k);
265 }
266
267
268 if(p==ChisqValues.begin()||k>Num_to_print)
269 {break;}
270
273 }
274
275
276
277result->tags_[
"MaxSigma"]=MaxSigma;
278result->tags_[
"NSigma"]=NSigma;
279result->tags_[
"Max Bins to Publish"]=Num_to_print;
280
281
282
283 int BinsOver=ChisqValues.size();
284 result->tags_[
"NBinsOver"]=BinsOver;
285
286
287
288 if ( (BinsOver <= gthresho) &&
veto==0 ) {
289 result->status_ = dqm_core::Result::Green;
290 }
else if ( (BinsOver < rthresho) &&
veto==0 ) {
291 result->status_ = dqm_core::Result::Yellow;
292 } else {
293 result->status_ = dqm_core::Result::Red;
294 }
295
296 ERS_DEBUG(2,"Result: "<<*result);
297
299
300}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
std::vector< std::string > veto
these patterns are anded
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
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.