38 const TObject&
object,
39 const dqm_core::AlgorithmConfig&
config ){
42 if(
object.
IsA()->InheritsFrom(
"TH1" ) ) {
45 throw dqm_core::BadConfig( ERS_HERE, name,
"dimension > 2 " );
48 throw dqm_core::BadConfig( ERS_HERE, name,
"does not inherit from TH1" );
68 if (
histogram->GetEntries() < minstat ) {
69 dqm_core::Result *
result =
new dqm_core::Result(dqm_core::Result::Undefined);
79 }
catch( dqm_core::Exception & ex ) {
80 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
84 std::vector<double> stripsSize;
85 std::vector<double> stripsMedian;
86 std::vector<double> stripsAvg;
87 std::vector<double> stripsVariance;
90 if ( (
int)range.size() < 4 ){
91 throw dqm_core::BadConfig( ERS_HERE, name,
"BinRange vector <4 " );
94 for (
int i = range[0]; i <= range[1]; ++i ) {
95 std::vector<double> onestrip;
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) {
106 if(onestrip.size()!=0 ) {
107 stripsAvg.push_back(stripSum/onestrip.size());
109 stripsAvg.push_back(0);
112 stripsSize.push_back(onestrip.size());
116 if ((
int)stripsAvg.size() <= i-range[0] ){
117 throw dqm_core::BadConfig( ERS_HERE, name,
"out of stripsAvg range " );
119 float strip_avg = stripsAvg[i-range[0]];
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);
129 if(counter!=0) variance = sumdiff2 / counter ;
130 stripsVariance.push_back(variance);
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 ) {
140 if ((
int)stripsSize.size() <= q ){
141 throw dqm_core::BadConfig( ERS_HERE, name,
"out of stripsSize range " );
143 if(stripsSize[q]<minstatperstrip)
continue;
144 if ((
int)stripsMedian.size() <= q ){
145 throw dqm_core::BadConfig( ERS_HERE, name,
"out of stripsMedian range " );
147 if ((
int)stripsVariance.size() <= q){
148 throw dqm_core::BadConfig( ERS_HERE, name,
"out of stripsVariance range " );
150 if ((
int)stripsAvg.size() <= q ){
151 throw dqm_core::BadConfig( ERS_HERE, name,
"out of stripsAvg range " );
153 double strip_median = stripsMedian[q];
154 double strip_variance = stripsVariance[q];
155 double strip_avg = stripsAvg[q];
157 if(std::abs(strip_median)<0.0001 && std::abs(strip_variance)<0.0001){
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;
163 if(std::abs(strip_median)<0.0001 && std::abs(strip_variance)>0.0001 && std::abs(strip_avg)<0.0001)
continue;
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)/std::sqrt(std::abs(strip_median));
180 Allbins.push_back(onebin);
181 if(std::abs(outstandingRatio) > rthreshold ) {
182 if( VisualMode && maxInMap > 0 && (binvalue / maxInMap < suppressRedFactor) ){
185 redbins.push_back(onebin);
186 }
else if(std::abs(outstandingRatio) > gthreshold ){
187 if( VisualMode && maxInMap > 0 && (binvalue / maxInMap < suppressFactor) ){
190 yellowbins.push_back(onebin);
195 int count_yellow_c = 0;
196 std::vector<std::vector<colorbinOnline> > ColorBinMap;
199 int limit = range[1]-range[0];
200 for (
int q = 0; q <= limit; ++q ) {
202 std::vector<colorbinOnline> oneColorStrip;
203 for (
int l = range[2]; l <= range[3]; ++l ) {
205 oneColorStrip.push_back(oneColorBin);
207 ColorBinMap.push_back(std::move(oneColorStrip));
211 for(
unsigned int i=0;i<redbins.size();i++){
213 int q=redbins[i].m_ix - range[0];
214 int p = redbins[i].m_iy-range[2];
216 if ((
int)ColorBinMap.size() <= q){
217 throw dqm_core::BadConfig( ERS_HERE, name,
"out of ColorBinMap range " );
220 if ((
int)ColorBinMap[q].size() <= p ){
221 throw dqm_core::BadConfig( ERS_HERE, name,
"out of ColorBinMap range " );
224 ColorBinMap[q][p].m_eta = redbins[i].m_eta;
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;
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];
237 if ((
int)ColorBinMap.size() <= q ){
238 throw dqm_core::BadConfig( ERS_HERE, name,
"out of ColorBinMap range " );
241 if ((
int)ColorBinMap[q].size() <= p ){
242 throw dqm_core::BadConfig( ERS_HERE, name,
"out of ColorBinMap range " );
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;
253 std::vector<colorclusterOnline > clusterArray;
254 for(
unsigned int i=0;i<redbins.size();i++){
256 int q=redbins[i].m_ix - range[0];
257 int p = redbins[i].m_iy-range[2];
259 if ((
int)ColorBinMap.size() <= q ){
260 throw dqm_core::BadConfig( ERS_HERE, name,
"out of ColorBinMap range " );
263 if ((
int)ColorBinMap[q].size() <= p ){
264 throw dqm_core::BadConfig( ERS_HERE, name,
"out of ColorBinMap range " );
267 if(ColorBinMap[q][p].m_color !=
green){
269 if((
int)onecluster.
m_size > 1) clusterArray.push_back(onecluster);
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];
276 if ((
int)ColorBinMap.size() <= q ){
277 throw dqm_core::BadConfig( ERS_HERE, name,
"out of ColorBinMap range " );
280 if ((
int)ColorBinMap[q].size() <= p ){
281 throw dqm_core::BadConfig( ERS_HERE, name,
"out of ColorBinMap range " );
284 if(ColorBinMap[q][p].m_color !=
green){
286 if((
int)onecluster.
m_size > 1) clusterArray.push_back(onecluster);
291 for(
unsigned int i=0;i<clusterArray.size();i++){
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);
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);
300 std::string tag(tmp);
301 result->tags_[tag] = clusterArray[i].m_value;
303 result->tags_[
"NRedClusters"] = count_red_c;
304 result->tags_[
"NYellowClusters"] = count_yellow_c;
308 std::sort(redbins.begin(),redbins.end());
309 std::sort(yellowbins.begin(),yellowbins.end());
310 std::sort(Allbins.begin(),Allbins.end());
313 for(
unsigned int i=0;i<redbins.size();i++){
315 int q = redbins[i].m_ix-range[0];
316 int p = redbins[i].m_iy-range[2];
319 if(q<(
int)ColorBinMap.size()){
320 if(p<(
int)ColorBinMap[q].size()){
321 if( ColorBinMap[q][p].m_status==0 )
continue;
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;
334 if(count_red > NpublishRed)
break;
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];
345 if(q<(
int)ColorBinMap.size()){
346 if(p<(
int)ColorBinMap[q].size()){
347 if(ColorBinMap[q][p].m_status==0)
continue;
351 if(publish && (count_red+count_yellow) < Nmaxpublish ){
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;
359 result->tags_[
"NRedBins"] = count_red;
360 result->tags_[
"NYellowBins"] = count_yellow;
362 if(count_red+count_yellow==0 && (
int)Allbins.size()>=5 ){
363 for(
int i=0;i<5;i++){
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;
374 if(count_red>0 || count_red_c>0) {
375 result->status_ = dqm_core::Result::Red;
377 if (count_yellow>0||count_yellow_c>0) {
378 result->status_ = dqm_core::Result::Yellow;
379 }
else {
result->status_ = dqm_core::Result::Green; }
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;
387 result->status_ = dqm_core::Result::Green;
415 if( i-r0<0 || i-r0>=(
int)ColorBinMap.size())
return;
416 if( j-r2<0 || j-r2>=(
int)ColorBinMap[i-r0].size() )
return;
418 std::vector<colorbinOnline> tmp;
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;
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;
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;
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;
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;
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;
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;
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;
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);