ATLAS Offline Software
Loading...
Searching...
No Matches
BinsDiffFromStripMedianOnline.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5/* BinsDiffFromStripMedianOnline.cxx is to pick out the problematic bins in 2D histogram assuming that y-axis(the phi direction) be symmetric.
6 Author: Feng TIAN (columbia university)
7 Email: Feng.Tian@cern.ch
8*/
9
10#include <dqm_core/AlgorithmConfig.h>
14#include <dqm_core/AlgorithmManager.h>
15
16#include <TH1.h>
17#include <TF1.h>
18#include <TClass.h>
19#include <cmath>
20
21#include <iostream>
22
24
26 dqm_core::AlgorithmManager::instance().registerAlgorithm("BinsDiffFromStripMedianOnline", this);
27}
28
31
35
36
37dqm_core::Result * dqm_algorithms::BinsDiffFromStripMedianOnline::execute(const std::string & name,
38 const TObject& object,
39 const dqm_core::AlgorithmConfig& config ){
40 const TH1* histogram;
41
42 if( object.IsA()->InheritsFrom( "TH1" ) ) {
43 histogram = static_cast<const TH1*>(&object);
44 if (histogram->GetDimension() > 2 ){
45 throw dqm_core::BadConfig( ERS_HERE, name, "dimension > 2 " );
46 }
47 } else {
48 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
49 }
50
51 const double minstat = dqm_algorithms::tools::GetFirstFromMap( "MinStat", config.getParameters(), -1);
52 const double minstatperstrip = dqm_algorithms::tools::GetFirstFromMap( "MinStatPerstrip", config.getParameters(), -1);
53 const double ignoreval1 = dqm_algorithms::tools::GetFirstFromMap( "ignoreval1", config.getParameters(), -99999);
54 const double ignoreval2 = dqm_algorithms::tools::GetFirstFromMap( "ignoreval2", config.getParameters(), 0.);
55 const bool publish = (bool) dqm_algorithms::tools::GetFirstFromMap( "PublishBins", config.getParameters(), 1);
56 const int Nmaxpublish = (int) dqm_algorithms::tools::GetFirstFromMap( "MaxPublish", config.getParameters(), 20);
57 const bool VisualMode = (bool) dqm_algorithms::tools::GetFirstFromMap( "VisualMode", config.getParameters(), 1);
58 const int NpublishRed = (int) dqm_algorithms::tools::GetFirstFromMap( "PublishRedBins",config.getParameters(), 0);
59 const bool ClusterResult = (bool) dqm_algorithms::tools::GetFirstFromMap( "ClusterResult", config.getParameters(), 0);
60 const double suppressFactor = dqm_algorithms::tools::GetFirstFromMap("SuppressFactor", config.getParameters(), 0.05);
61 const double suppressRedFactor = dqm_algorithms::tools::GetFirstFromMap("SuppressRedFactor", config.getParameters(), 0.01);
62 const bool OnlineMode = (bool) dqm_algorithms::tools::GetFirstFromMap( "OnlineMode", config.getParameters(), 0);
63 const double Nred_red = (double) dqm_algorithms::tools::GetFirstFromMap( "Nred_red", config.getParameters(), 5.);
64 const double Nred_yellow = (double) dqm_algorithms::tools::GetFirstFromMap( "Nred_yellow", config.getParameters(), 3.);
65 const double Nyellow_yellow = (double) dqm_algorithms::tools::GetFirstFromMap( "Nyellow_yellow", config.getParameters(), 5.);
66 const double Nredyellow_yellow = (double) dqm_algorithms::tools::GetFirstFromMap( "Nredyellow_yellow", config.getParameters(), 4.);
67
68 if ( histogram->GetEntries() < minstat ) {
69 dqm_core::Result *result = new dqm_core::Result(dqm_core::Result::Undefined);
70 result->tags_["InsufficientEntries"] = histogram->GetEntries();
71 return result;
72 }
73
74 double gthreshold;
75 double rthreshold;
76 try {
77 rthreshold = dqm_algorithms::tools::GetFromMap( "MaxDeviation", config.getRedThresholds() );
78 gthreshold = dqm_algorithms::tools::GetFromMap( "MaxDeviation", config.getGreenThresholds() );
79 }catch( dqm_core::Exception & ex ) {
80 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
81 }
82
83 std::vector<int> range=dqm_algorithms::tools::GetBinRange(histogram, config.getParameters());
84 std::vector<double> stripsSize;
85 std::vector<double> stripsMedian;
86 std::vector<double> stripsAvg;
87 std::vector<double> stripsVariance;
88 double maxInMap=0;
89
90 if ( (int)range.size() < 4 ){
91 throw dqm_core::BadConfig( ERS_HERE, name, "BinRange vector <4 " );
92 }
93
94 for ( int i = range[0]; i <= range[1]; ++i ) {
95 std::vector<double> onestrip;
96 double stripSum=0;
97 for ( int j = range[2]; j <= range[3]; ++j ) {
98 float binvalue = histogram->GetBinContent(i,j);
99 if (std::abs(binvalue- ignoreval1)<0.0001 || std::abs(binvalue - ignoreval2)<0.0001) continue;
100 onestrip.push_back(binvalue);
101 stripSum += binvalue;
102 if(binvalue > maxInMap) {
103 maxInMap = binvalue;
104 }
105 }
106 if(onestrip.size()!=0 ) {
107 stripsAvg.push_back(stripSum/onestrip.size());
108 }else {
109 stripsAvg.push_back(0);
110 }
111 FindStripMedianOnline(name,onestrip,stripsMedian);
112 stripsSize.push_back(onestrip.size());
113
114 float sumdiff2=0;
115 int counter=0;
116 if ((int)stripsAvg.size() <= i-range[0] ){
117 throw dqm_core::BadConfig( ERS_HERE, name, "out of stripsAvg range " );
118 }
119 float strip_avg = stripsAvg[i-range[0]];
120
121 for ( int j = range[2]; j <= range[3]; ++j ) {
122 if (std::abs(histogram->GetBinContent(i,j)-ignoreval1)<0.0001 || std::abs(histogram->GetBinContent(i,j)-ignoreval2)<0.0001) continue;
123 double binvalue = histogram->GetBinContent(i,j);
124 double diff=binvalue-strip_avg;
125 sumdiff2 +=std::pow(diff,2);
126 counter++;
127 }
128 double variance=-1;
129 if(counter!=0) variance = sumdiff2 / counter ;
130 stripsVariance.push_back(variance);
131 }
132
133 dqm_core::Result* result = new dqm_core::Result();
134 std::vector<binOnline> redbins;
135 std::vector<binOnline> yellowbins;
136 std::vector<binOnline> Allbins;
137 int limit = range[1]-range[0];
138 for ( int q=0; q <= limit; ++q ) {
139 int k=q+range[0];
140 if ((int)stripsSize.size() <= q ){
141 throw dqm_core::BadConfig( ERS_HERE, name, "out of stripsSize range " );
142 }
143 if(stripsSize[q]<minstatperstrip) continue;
144 if ((int)stripsMedian.size() <= q ){
145 throw dqm_core::BadConfig( ERS_HERE, name, "out of stripsMedian range " );
146 }
147 if ((int)stripsVariance.size() <= q){
148 throw dqm_core::BadConfig( ERS_HERE, name, "out of stripsVariance range " );
149 }
150 if ((int)stripsAvg.size() <= q ){
151 throw dqm_core::BadConfig( ERS_HERE, name, "out of stripsAvg range " );
152 }
153 double strip_median = stripsMedian[q];
154 double strip_variance = stripsVariance[q];
155 double strip_avg = stripsAvg[q];
156
157 if(std::abs(strip_median)<0.0001 && std::abs(strip_variance)<0.0001){
158 continue; // skip empty strip
159 }else {
160 if(std::abs(strip_median)<0.0001 && std::abs(strip_variance)>0.0001 && std::abs(strip_avg)>0.0001) {
161 strip_median = strip_avg;
162 } else{
163 if(std::abs(strip_median)<0.0001 && std::abs(strip_variance)>0.0001 && std::abs(strip_avg)<0.0001) continue;
164 }
165 }
166
167
168 for ( int l = range[2]; l <= range[3]; ++l ) {
169 double binvalue = histogram->GetBinContent(k,l);
170 if (std::abs(binvalue-ignoreval1)<0.0001 || std::abs(binvalue-ignoreval2)<0.0001) continue;
171 double outstandingRatio=0;
172 if(std::abs(strip_median) > 0.0001 ){
173 outstandingRatio= /*binvalue/strip_median*/ (binvalue-strip_median)/std::sqrt(std::abs(strip_median));
174 }else{
175 continue;
176 }
177 double eta = histogram->GetXaxis()->GetBinCenter(k);
178 double phi = histogram->GetYaxis()->GetBinCenter(l);
179 binOnline onebin = {eta,phi,k,l,binvalue,outstandingRatio};
180 Allbins.push_back(onebin);
181 if(std::abs(outstandingRatio) > rthreshold ) {
182 if( VisualMode && maxInMap > 0 && (binvalue / maxInMap < suppressRedFactor) ){
183 continue;
184 }
185 redbins.push_back(onebin);
186 }else if(std::abs(outstandingRatio) > gthreshold ){
187 if( VisualMode && maxInMap > 0 && (binvalue / maxInMap < suppressFactor) ){
188 continue;
189 }
190 yellowbins.push_back(onebin);
191 }
192 }
193 }
194 int count_red_c = 0;
195 int count_yellow_c = 0;
196 std::vector<std::vector<colorbinOnline> > ColorBinMap;
197 if(ClusterResult){
198 // initialize ColorBinMap
199 int limit = range[1]-range[0];
200 for ( int q = 0; q <= limit; ++q ) {
201 int k =q+range[0];
202 std::vector<colorbinOnline> oneColorStrip;
203 for ( int l = range[2]; l <= range[3]; ++l ) {
204 colorbinOnline oneColorBin = {-1,-1,k,l,-1,green,1};
205 oneColorStrip.push_back(oneColorBin);
206 }
207 ColorBinMap.push_back(std::move(oneColorStrip));
208 }
209
210 // map redbins and yellowbins to ColorBinMap
211 for(unsigned int i=0;i<redbins.size();i++){
212
213 int q=redbins[i].m_ix - range[0];
214 int p = redbins[i].m_iy-range[2];
215
216 if ((int)ColorBinMap.size() <= q){
217 throw dqm_core::BadConfig( ERS_HERE, name, "out of ColorBinMap range " );
218 }
219
220 if ((int)ColorBinMap[q].size() <= p ){
221 throw dqm_core::BadConfig( ERS_HERE, name, "out of ColorBinMap range " );
222 }
223
224 ColorBinMap[q][p].m_eta = redbins[i].m_eta;
225
226 ColorBinMap[q][p].m_phi = redbins[i].m_phi;
227 ColorBinMap[q][p].m_value = redbins[i].m_value;
228 ColorBinMap[q][p].m_color = red;
229
230 }
231
232
233 for(unsigned int i=0;i<yellowbins.size();i++){
234 int q=yellowbins[i].m_ix - range[0];
235 int p = yellowbins[i].m_iy-range[2];
236
237 if ((int)ColorBinMap.size() <= q ){
238 throw dqm_core::BadConfig( ERS_HERE, name, "out of ColorBinMap range " );
239 }
240
241 if ((int)ColorBinMap[q].size() <= p ){
242 throw dqm_core::BadConfig( ERS_HERE, name, "out of ColorBinMap range " );
243 }
244
245 ColorBinMap[q][p].m_eta = yellowbins[i].m_eta;
246 ColorBinMap[q][p].m_phi = yellowbins[i].m_phi;
247 ColorBinMap[q][p].m_value = yellowbins[i].m_value;
248 ColorBinMap[q][p].m_color = yellow;
249 }
250
251
252 // cluster bad bins
253 std::vector<colorclusterOnline > clusterArray;
254 for(unsigned int i=0;i<redbins.size();i++){
255
256 int q=redbins[i].m_ix - range[0];
257 int p = redbins[i].m_iy-range[2];
258
259 if ((int)ColorBinMap.size() <= q ){
260 throw dqm_core::BadConfig( ERS_HERE, name, "out of ColorBinMap range " );
261 }
262
263 if ((int)ColorBinMap[q].size() <= p ){
264 throw dqm_core::BadConfig( ERS_HERE, name, "out of ColorBinMap range " );
265 }
266
267 if(ColorBinMap[q][p].m_color != green){
268 colorclusterOnline onecluster = MakeClusterOnline(name,range[0],range[2],redbins[i],ColorBinMap);
269 if((int)onecluster.m_size > 1) clusterArray.push_back(onecluster);
270 }
271 }
272 for(unsigned int i=0;i<yellowbins.size();i++){
273 int q=yellowbins[i].m_ix - range[0];
274 int p = yellowbins[i].m_iy-range[2];
275
276 if ((int)ColorBinMap.size() <= q ){
277 throw dqm_core::BadConfig( ERS_HERE, name, "out of ColorBinMap range " );
278 }
279
280 if ((int)ColorBinMap[q].size() <= p ){
281 throw dqm_core::BadConfig( ERS_HERE, name, "out of ColorBinMap range " );
282 }
283
284 if(ColorBinMap[q][p].m_color != green){
285 colorclusterOnline onecluster = MakeClusterOnline(name,range[0],range[2],yellowbins[i],ColorBinMap);
286 if((int)onecluster.m_size > 1) clusterArray.push_back(onecluster);
287 }
288 }
289
290 // publish clusters here:
291 for(unsigned int i=0;i<clusterArray.size();i++){
292 char tmp[500]{};
293 if(clusterArray[i].m_color==red){
294 snprintf(tmp,500,"CR%i-(eta,phi)(r)(size)=(%0.3f,%0.3f)(%0.3f)(%i)",count_red_c,clusterArray[i].m_eta,clusterArray[i].m_phi,clusterArray[i].m_radius,clusterArray[i].m_size);
295 count_red_c++;
296 }else if(clusterArray[i].m_color==yellow){
297 snprintf(tmp,500,"CY%i-(eta,phi)(r)(size)=(%0.3f,%0.3f)(%0.3f)(%i)",count_yellow_c,clusterArray[i].m_eta,clusterArray[i].m_phi,clusterArray[i].m_radius,clusterArray[i].m_size);
298 count_yellow_c++;
299 }
300 std::string tag(tmp);
301 result->tags_[tag] = clusterArray[i].m_value;
302 }
303 result->tags_["NRedClusters"] = count_red_c;
304 result->tags_["NYellowClusters"] = count_yellow_c;
305
306 }
307
308 std::sort(redbins.begin(),redbins.end());
309 std::sort(yellowbins.begin(),yellowbins.end());
310 std::sort(Allbins.begin(),Allbins.end());
311 // publish red bins
312 int count_red=0;
313 for(unsigned int i=0;i<redbins.size();i++){
314
315 int q = redbins[i].m_ix-range[0];
316 int p = redbins[i].m_iy-range[2];
317
318 if(ClusterResult){
319 if(q<(int)ColorBinMap.size()){
320 if(p<(int)ColorBinMap[q].size()){
321 if( ColorBinMap[q][p].m_status==0 ) continue;
322 }
323 }
324 }
325
326 if(publish){
327 char tmp[500]{};
328 snprintf(tmp,500,"R%i-(eta,phi)[OSRatio]=(%0.3f,%0.3f)[%0.2e]",count_red,redbins[i].m_eta,redbins[i].m_phi,redbins[i].m_outstandingRatio);
329 std::string tag(tmp);
330 result->tags_[tag] = redbins[i].m_value;
331 }
332 count_red++;
333 if(NpublishRed > 0){
334 if(count_red > NpublishRed) break;
335 }
336 }
337
338 // publish yellow bins
339 int count_yellow=0;
340 for(unsigned int i=0;i<yellowbins.size();i++){
341 int q = yellowbins[i].m_ix-range[0];
342 int p = yellowbins[i].m_iy-range[2];
343
344 if(ClusterResult){
345 if(q<(int)ColorBinMap.size()){
346 if(p<(int)ColorBinMap[q].size()){
347 if(ColorBinMap[q][p].m_status==0) continue;
348 }
349 }
350 }
351 if(publish && (count_red+count_yellow) < Nmaxpublish ){
352 char tmp[500]{};
353 snprintf(tmp,500,"Y%i-(eta,phi)[OSRatio]=(%0.3f,%0.3f)[%.2e]",count_yellow,yellowbins[i].m_eta,yellowbins[i].m_phi,yellowbins[i].m_outstandingRatio);
354 std::string tag(tmp);
355 result->tags_[tag] = yellowbins[i].m_value;
356 }
357 count_yellow++;
358 }
359 result->tags_["NRedBins"] = count_red; // count_red is the number of red bins printed
360 result->tags_["NYellowBins"] = count_yellow; // count_yellow is the number of yellow bins printed
361
362 if(count_red+count_yellow==0 && (int)Allbins.size()>=5 ){
363 for(int i=0;i<5;i++){
364 char tmptmp[500]{};
365 snprintf(tmptmp,500,"LeadingBin%i-(eta,phi)=(%0.3f,%0.3f)",i,Allbins[i].m_eta,Allbins[i].m_phi);
366 std::string tagtag(tmptmp);
367 result->tags_[tagtag] = Allbins[i].m_value;
368 }
369
370 }
371
372
373 if(!OnlineMode){
374 if(count_red>0 || count_red_c>0) {
375 result->status_ = dqm_core::Result::Red;
376 } else {
377 if (count_yellow>0||count_yellow_c>0) {
378 result->status_ = dqm_core::Result::Yellow;
379 } else { result->status_ = dqm_core::Result::Green; }
380 }
381 } else {
382 if(count_red>=Nred_red){
383 result->status_ = dqm_core::Result::Red;
384 }else if (count_red>=Nred_yellow || count_yellow>=Nyellow_yellow || (count_red+count_yellow)>=Nredyellow_yellow){
385 result->status_ = dqm_core::Result::Yellow;
386 }else{
387 result->status_ = dqm_core::Result::Green;
388 }
389 }
390
391 return result;
392
393}
394
395void dqm_algorithms::BinsDiffFromStripMedianOnline::FindStripMedianOnline(const std::string & name,std::vector<double> onestrip_tmp,std::vector<double>& stripsMedian){
396 double median=0;
397
398 std::sort(onestrip_tmp.begin(),onestrip_tmp.end());
399 int index1=(int)(onestrip_tmp.size()/4.);
400
401 int index2=(int)(onestrip_tmp.size()/2.);
402 int index3=(int) (3.*onestrip_tmp.size()/4.);
403 if(onestrip_tmp.size()>0){
404 if ((int)onestrip_tmp.size() <= index1 || (int)onestrip_tmp.size() <= index2 || (int)onestrip_tmp.size() <= index3){
405 throw dqm_core::BadConfig( ERS_HERE, name, "out of onestrip_tmp range " );
406 }
407
408 median = (onestrip_tmp[index1]+onestrip_tmp[index2]+onestrip_tmp[index3])/3.0;
409 }
410 stripsMedian.push_back(median);
411}
412
413void dqm_algorithms::BinsDiffFromStripMedianOnline::AddToList(const int r0,const int r2,int i,int j,std::vector<std::vector<colorbinOnline> > & ColorBinMap, std::vector<colorbinOnline>& LookAtList){
414
415 if( i-r0<0 || i-r0>=(int)ColorBinMap.size()) return;
416 if( j-r2<0 || j-r2>=(int)ColorBinMap[i-r0].size() ) return;
417
418 std::vector<colorbinOnline> tmp;
419
420 if(i-1-r0>=0 && i-1-r0<(int)ColorBinMap.size()){
421 if(j-1-r2>=0 && j-1-r2<(int)ColorBinMap[i-1-r0].size()){
422 if(ColorBinMap[i-1-r0][j-1-r2].m_status==1){
423 tmp.push_back(ColorBinMap[i-1-r0][j-1-r2]);
424 ColorBinMap[i-1-r0][j-1-r2].m_status=0;
425 }
426 }
427 }
428 if(i-r0>=0 && i-r0<(int)ColorBinMap.size()){
429 if(j-1-r2>=0 && j-1-r2<(int)ColorBinMap[i-r0].size()){
430 if(ColorBinMap[i-r0][j-1-r2].m_status==1){
431 tmp.push_back(ColorBinMap[i-r0][j-1-r2]);
432 ColorBinMap[i-r0][j-1-r2].m_status=0;
433 }
434 }
435 }
436
437 if(i+1-r0>=0 && i+1-r0<(int)ColorBinMap.size()){
438 if(j-1-r2>=0 && j-1-r2<(int)ColorBinMap[i+1-r0].size()){
439 if(ColorBinMap[i+1-r0][j-1-r2].m_status==1){
440 tmp.push_back(ColorBinMap[i+1-r0][j-1-r2]);
441 ColorBinMap[i+1-r0][j-1-r2].m_status=0;
442 }
443 }
444 }
445
446 if(i-1-r0>=0 && i-1-r0<(int)ColorBinMap.size()){
447 if(j-r2>=0 && j-r2<(int)ColorBinMap[i-1-r0].size()){
448 if(ColorBinMap[i-1-r0][j-r2].m_status==1){
449 tmp.push_back(ColorBinMap[i-1-r0][j-r2]);
450 ColorBinMap[i-1-r0][j-r2].m_status=0;
451 }
452 }
453 }
454
455
456 if(i+1-r0>=0 && i+1-r0<(int)ColorBinMap.size()){
457 if(j-r2>=0 && j-r2<(int)ColorBinMap[i+1-r0].size()){
458 if(ColorBinMap[i+1-r0][j-r2].m_status==1){
459 tmp.push_back(ColorBinMap[i+1-r0][j-r2]);
460 ColorBinMap[i+1-r0][j-r2].m_status=0;
461 }
462 }
463 }
464
465
466 if(i-1-r0>=0 && i-1-r0<(int)ColorBinMap.size()){
467 if(j+1-r2>=0 && j+1-r2<(int)ColorBinMap[i-1-r0].size()){
468 if(ColorBinMap[i-1-r0][j+1-r2].m_status==1){
469 tmp.push_back(ColorBinMap[i-1-r0][j+1-r2]);
470 ColorBinMap[i-1-r0][j+1-r2].m_status=0;
471 }
472 }
473 }
474
475 if(i-r0>=0 && i-r0<(int)ColorBinMap.size()){
476 if(j+1-r2>=0 && j+1-r2<(int)ColorBinMap[i-r0].size()){
477 if(ColorBinMap[i-r0][j+1-r2].m_status==1){
478 tmp.push_back(ColorBinMap[i-r0][j+1-r2]);
479 ColorBinMap[i-r0][j+1-r2].m_status=0;
480 }
481 }
482 }
483
484 if(i+1-r0>=0 && i+1-r0<(int)ColorBinMap.size()){
485 if(j+1-r2>=0 && j+1-r2<(int)ColorBinMap[i+1-r0].size()){
486 if(ColorBinMap[i+1-r0][j+1-r2].m_status==1){
487 tmp.push_back(ColorBinMap[i+1-r0][j+1-r2]);
488 ColorBinMap[i+1-r0][j+1-r2].m_status=0;
489 }
490 }
491 }
492
493 for(unsigned int k=0;k<tmp.size();k++){
494 if(tmp[k].m_color!=green){
495 LookAtList.push_back(tmp[k]);
496 AddToList(r0,r2,tmp[k].m_ix,tmp[k].m_iy,ColorBinMap,LookAtList);
497 }
498 }
499 return;
500
501}
502
503double dqm_algorithms::BinsDiffFromStripMedianOnline::CalEta(std::vector<colorbinOnline>& LookAtList){
504 double sumEta=0;
505 double sumN=0;
506 for(unsigned int i=0;i<LookAtList.size();i++){
507 double eta = LookAtList[i].m_eta;
508 double n = LookAtList[i].m_value;
509 sumEta += n*eta;
510 sumN +=n;
511 }
512 if(sumN!=0){
513 return sumEta/sumN;
514 }else{
515 return -99.;
516 }
517}
518
519double dqm_algorithms::BinsDiffFromStripMedianOnline::CalPhi(std::vector<colorbinOnline>& LookAtList){
520 double sumPhi=0;
521 double sumN=0;
522 for(unsigned int i=0;i<LookAtList.size();i++){
523 double phi = LookAtList[i].m_phi;
524 double n = LookAtList[i].m_value;
525 sumPhi += n*phi;
526 sumN +=n;
527 }
528 if(sumN!=0){
529 return sumPhi/sumN;
530 }else{
531 return -99.;
532 }
533}
534
535double dqm_algorithms::BinsDiffFromStripMedianOnline::CalVal(std::vector<colorbinOnline>& LookAtList){
536 double sumN=0;
537 for(unsigned int i=0;i<LookAtList.size();i++){
538 double n = LookAtList[i].m_value;
539 sumN += n;
540 }
541 return sumN;
542}
543double dqm_algorithms::BinsDiffFromStripMedianOnline::CalR(std::vector<colorbinOnline>& LookAtList,double eta, double phi){
544 if(LookAtList.size()<2) return 0;
545 double maxR=0;
546 for(unsigned int i=0;i<LookAtList.size();i++){
547 double distance = std::sqrt(std::pow((LookAtList[i].m_eta-eta),2)+std::pow((LookAtList[i].m_phi-phi),2));
548 maxR=distance>maxR?distance:maxR;
549 }
550 return maxR;
551}
552
554dqm_algorithms::BinsDiffFromStripMedianOnline::MakeClusterOnline(const std::string & name,const int r0,const int r2,binOnline& onebin, std::vector<std::vector<colorbinOnline> > & ColorBinMap){
555 colorclusterOnline onecluster={0,0,0,0,green,-1};
556
557 if ((int)ColorBinMap.size() <= (onebin.m_ix-r0) ){
558 throw dqm_core::BadConfig( ERS_HERE, name, "out of ColorBinMap range " );
559 }
560
561 if ((int)ColorBinMap[onebin.m_ix-r0].size() <= (onebin.m_iy-r2) ){
562 throw dqm_core::BadConfig( ERS_HERE, name, "out of ColorBinMap range " );
563 }
564
565 if(ColorBinMap[onebin.m_ix-r0][onebin.m_iy-r2].m_status==0)
566 return onecluster;
567 std::vector<colorbinOnline> LookAtList;
568 if(ColorBinMap[onebin.m_ix-r0][onebin.m_iy-r2].m_color!=green){
569 LookAtList.push_back(ColorBinMap[onebin.m_ix-r0][onebin.m_iy-r2]);
570 ColorBinMap[onebin.m_ix-r0][onebin.m_iy-r2].m_status=0;
571 AddToList(r0,r2,onebin.m_ix,onebin.m_iy,ColorBinMap, LookAtList);
572 if(LookAtList.size()>1){
573 onecluster.m_size = LookAtList.size();
574 onecluster.m_value = CalVal(LookAtList);
575 if(ColorBinMap[onebin.m_ix-r0][onebin.m_iy-r2].m_color==red){
576 onecluster.m_color = red;
577 }else{
578 onecluster.m_color = yellow;
579 }
580 onecluster.m_eta = CalEta(LookAtList);
581 onecluster.m_phi = CalPhi(LookAtList);
582 onecluster.m_radius = CalR(LookAtList,onecluster.m_eta,onecluster.m_phi);
583 } else {
584 ColorBinMap[onebin.m_ix-r0][onebin.m_iy-r2].m_status=1;
585 }
586 }
587 return onecluster;
588}
589
591
592 out<<"BinsDiffFromStripMedianOnline: Calculates smoothed strip median and then find out bins which are aliens "<<std::endl;
593
594 out<<"Mandatory Green/Red Threshold is the value of outstandingRatio=(bin value)/(strip median) based on which to give Green/Red result\n"<<std::endl;
595
596 out<<"Optional Parameter: MinStat: Minimum histogram statistics needed to perform Algorithm"<<std::endl;
597 out<<"Optional Parameter: MinStatPerstrip: Minimum strip statistics needed to perform Algorithm"<<std::endl;
598 out<<"Optional Parameter: ignoreval0: values to be ignored for being processed"<<std::endl;
599 out<<"Optional Parameter: ignoreval1: values to be ignored for being processed"<<std::endl;
600 out<<"Optional Parameter: PublishBins: Save bins which are different from average in Result (on:1,off:0,default is 1)"<<std::endl;
601 out<<"Optional Parameter: MaxPublish: Max number of bins to save (default 20)"<<std::endl;
602 out<<"Optional Parameter: VisualMode: is to make the evaluation process similar to the shift work, so one will get resonable result efficiently."<<std::endl;
603
604 out<<"Optional Parameter: PublishRedBins: Max number of red bins to save."<<std::endl;
605 out<<"Optional Parameter: ClusterResult: to cluster close bad bins together."<<std::endl;
606 out<<"Optional Parameter: SuppressFactor: if the ratio of the bin contennt to max one in the histogram is smaller than SuppressFactor, don't set the bin as red or yellow ."<<std::endl;
607 out<<"Optional Parameter: SuppressRedFactor: if the ratio of the bin contennt to max one in the histogram is smaller than SuppressRedFactor, don't set the bin as red ."<<std::endl;
608 out<<"Optional Parameter: OnlineMode: switch on when running online."<<std::endl;
609 out<<"Optional Parameter: Nred_red: minimum number of red bins needed to label the histogram as red."<<std::endl;
610 out<<"Optional Parameter: Nyellow_yellow: minimum number of yellow bins needed to label the histogram as yellow."<<std::endl;
611 out<<"Optional Parameter: Nred_yellow: minimum number of red bins needed to label the histogram as yellow."<<std::endl;
612 out<<"Optional Parameter: Nredyellow_yellow: minimum number of yellow+red bins needed to label the histogram as yellow."<<std::endl;
613
614}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
static dqm_algorithms::BinContentComp myInstance
double CalEta(std::vector< colorbin > &LookAtList)
double CalR(std::vector< colorbin > &LookAtList, double eta, double phi)
double CalPhi(std::vector< colorbin > &LookAtList)
void AddToList(const int r0, const int r2, int i, int j, std::vector< std::vector< colorbin > > &ColorBinMap, std::vector< colorbin > &LookAtList)
double CalVal(std::vector< colorbin > &LookAtList)
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Definition Jet.cxx:631
std::string histogram
Definition chains.cxx:52
std::vector< int > GetBinRange(const TH1 *histogram, const std::map< std::string, double > &params)
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
const T & GetFromMap(const std::string &pname, const std::map< std::string, T > &params)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
void AddToList(const int r0, const int r2, int i, int j, std::vector< std::vector< colorbinOnline > > &ColorBinMap, std::vector< colorbinOnline > &LookAtList)
dqm_core::Result * execute(const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
void FindStripMedianOnline(const std::string &, std::vector< double > onestrip, std::vector< double > &stripsMedian)
double CalPhi(std::vector< colorbinOnline > &LookAtList)
double CalVal(std::vector< colorbinOnline > &LookAtList)
double CalR(std::vector< colorbinOnline > &LookAtList, double eta, double phi)
colorclusterOnline MakeClusterOnline(const std::string &name, const int r0, const int r2, binOnline &onebin, std::vector< std::vector< colorbinOnline > > &ColorBinMap)
double CalEta(std::vector< colorbinOnline > &LookAtList)
#define IsA
Declare the TObject style functions.