39 {
41
42 if(
object.
IsA()->InheritsFrom(
"TH1" ) ) {
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
67
68 if (
histogram->GetEntries() < minstat ) {
69 dqm_core::Result *
result =
new dqm_core::Result(dqm_core::Result::Undefined);
72 }
73
74 double gthreshold;
75 double rthreshold;
76 try {
79 }catch( dqm_core::Exception & ex ) {
80 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
81 }
82
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 }
112 stripsSize.push_back(onestrip.size());
113
114 float sumdiff2=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);
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;
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 " );
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;
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)/std::sqrt(std::abs(strip_median));
174 }else{
175 continue;
176 }
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
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);
206 }
207 ColorBinMap.push_back(std::move(oneColorStrip));
208 }
209
210
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;
249 }
250
251
252
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){
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){
286 if((int)onecluster.m_size > 1) clusterArray.push_back(onecluster);
287 }
288 }
289
290
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);
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);
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
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){
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);
331 }
332 count_red++;
333 if(NpublishRed > 0){
334 if(count_red > NpublishRed) break;
335 }
336 }
337
338
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 ){
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);
356 }
357 count_yellow++;
358 }
359 result->tags_[
"NRedBins"] = count_red;
360 result->tags_[
"NYellowBins"] = count_yellow;
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
392
393}
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
l
Printing final latex table to .tex output file.
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.