CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EEIntegrityClient.cc
Go to the documentation of this file.
1 
2 /*
3  * \file EEIntegrityClient.cc
4  *
5  * \author G. Della Ricca
6  * \author G. Franzoni
7  *
8  */
9 
10 #include <memory>
11 #include <iostream>
12 #include <fstream>
13 #include <iomanip>
14 
16 
19 
20 #ifdef WITH_ECAL_COND_DB
34 #endif
35 
37 
40 
42 
44 
46 
47  // cloneME switch
48  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
49 
50  // verbose switch
51  verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
52 
53  // debug switch
54  debug_ = ps.getUntrackedParameter<bool>("debug", false);
55 
56  // prefixME path
57  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
58 
59  subfolder_ = ps.getUntrackedParameter<std::string>("subfolder", "");
60 
61  // enableCleanup_ switch
62  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
63 
64  // vector of selected Super Modules (Defaults to all 18).
65  superModules_.reserve(18);
66  for ( unsigned int i = 1; i <= 18; i++ ) superModules_.push_back(i);
67  superModules_ = ps.getUntrackedParameter<std::vector<int> >("superModules", superModules_);
68 
69  h00_ = 0;
70 
71  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
72 
73  int ism = superModules_[i];
74 
75  h_[ism-1] = 0;
76  hmem_[ism-1] = 0;
77 
78  h01_[ism-1] = 0;
79  h02_[ism-1] = 0;
80  h03_[ism-1] = 0;
81  h04_[ism-1] = 0;
82  h05_[ism-1] = 0;
83  h06_[ism-1] = 0;
84  h07_[ism-1] = 0;
85  h08_[ism-1] = 0;
86  h09_[ism-1] = 0;
87 
88  }
89 
90  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
91 
92  int ism = superModules_[i];
93 
94  // integrity summary histograms
95  meg01_[ism-1] = 0;
96  meg02_[ism-1] = 0;
97 
98  }
99 
100  threshCry_ = 0.01;
101 
102 }
103 
105 
106 }
107 
109 
111 
112  if ( debug_ ) std::cout << "EEIntegrityClient: beginJob" << std::endl;
113 
114  ievt_ = 0;
115  jevt_ = 0;
116 
117 }
118 
120 
121  if ( debug_ ) std::cout << "EEIntegrityClient: beginRun" << std::endl;
122 
123  jevt_ = 0;
124 
125  this->setup();
126 
127 }
128 
130 
131  if ( debug_ ) std::cout << "EEIntegrityClient: endJob, ievt = " << ievt_ << std::endl;
132 
133  this->cleanup();
134 
135 }
136 
138 
139  if ( debug_ ) std::cout << "EEIntegrityClient: endRun, jevt = " << jevt_ << std::endl;
140 
141  this->cleanup();
142 
143 }
144 
146 
148 
149  dqmStore_->setCurrentFolder( prefixME_ + "/EEIntegrityClient" );
150 
151  if(subfolder_.size())
152  dqmStore_->setCurrentFolder(prefixME_ + "/EEIntegrityClient/" + subfolder_);
153 
154  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
155 
156  int ism = superModules_[i];
157 
158  if ( meg01_[ism-1] ) dqmStore_->removeElement( meg01_[ism-1]->getName() );
159  name = "EEIT data integrity quality " + Numbers::sEE(ism);
160  meg01_[ism-1] = dqmStore_->book2D(name, name, 50, Numbers::ix0EE(ism)+0., Numbers::ix0EE(ism)+50., 50, Numbers::iy0EE(ism)+0., Numbers::iy0EE(ism)+50.);
161  meg01_[ism-1]->setAxisTitle("ix", 1);
162  if ( ism >= 1 && ism <= 9 ) meg01_[ism-1]->setAxisTitle("101-ix", 1);
163  meg01_[ism-1]->setAxisTitle("iy", 2);
164 
165  if ( meg02_[ism-1] ) dqmStore_->removeElement( meg02_[ism-1]->getName() );
166  name = "EEIT data integrity quality MEM " + Numbers::sEE(ism);
167  meg02_[ism-1] = dqmStore_->book2D(name, name, 10, 0., 10., 5, 0.,5.);
168  meg02_[ism-1]->setAxisTitle("pseudo-strip", 1);
169  meg02_[ism-1]->setAxisTitle("channel", 2);
170 
171  }
172 
173  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
174 
175  int ism = superModules_[i];
176 
177  if ( meg01_[ism-1] ) meg01_[ism-1]->Reset();
178  if ( meg02_[ism-1] ) meg02_[ism-1]->Reset();
179 
180  for ( int ix = 1; ix <= 50; ix++ ) {
181  for ( int iy = 1; iy <= 50; iy++ ) {
182 
183  if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ix, iy, 6. );
184 
185  int jx = ix + Numbers::ix0EE(ism);
186  int jy = iy + Numbers::iy0EE(ism);
187 
188  if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
189 
190  if ( Numbers::validEE(ism, jx, jy) ) {
191  if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ix, iy, 2. );
192  }
193 
194  }
195  }
196 
197  for ( int ie = 1; ie <= 10; ie++ ) {
198  for ( int ip = 1; ip <= 5; ip++ ) {
199 
200  if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ie, ip, 6. );
201 
202  // non-existing mem
203  if ( (ism >= 3 && ism <= 4) || (ism >= 7 && ism <= 9) ) continue;
204  if ( (ism >= 12 && ism <= 3) || (ism >= 16 && ism <= 18) ) continue;
205 
206  if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ie, ip, 2. );
207 
208  }
209  }
210 
211  }
212 
213 }
214 
216 
217  if ( ! enableCleanup_ ) return;
218 
219  if ( cloneME_ ) {
220  if ( h00_ ) delete h00_;
221  }
222 
223  h00_ = 0;
224 
225  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
226 
227  int ism = superModules_[i];
228 
229  if ( cloneME_ ) {
230  if ( h_[ism-1] ) delete h_[ism-1];
231  if ( hmem_[ism-1] ) delete hmem_[ism-1];
232 
233  if ( h01_[ism-1] ) delete h01_[ism-1];
234  if ( h02_[ism-1] ) delete h02_[ism-1];
235  if ( h03_[ism-1] ) delete h03_[ism-1];
236  if ( h04_[ism-1] ) delete h04_[ism-1];
237  if ( h05_[ism-1] ) delete h05_[ism-1];
238  if ( h06_[ism-1] ) delete h06_[ism-1];
239  if ( h07_[ism-1] ) delete h07_[ism-1];
240  if ( h08_[ism-1] ) delete h08_[ism-1];
241  if ( h09_[ism-1] ) delete h09_[ism-1];
242  }
243 
244  h_[ism-1] = 0;
245  hmem_[ism-1] = 0;
246 
247  h01_[ism-1] = 0;
248  h02_[ism-1] = 0;
249  h03_[ism-1] = 0;
250  h04_[ism-1] = 0;
251  h05_[ism-1] = 0;
252  h06_[ism-1] = 0;
253  h07_[ism-1] = 0;
254  h08_[ism-1] = 0;
255  h09_[ism-1] = 0;
256 
257  }
258 
259  dqmStore_->setCurrentFolder( prefixME_ + "/EEIntegrityClient" );
260 
261  if(subfolder_.size())
262  dqmStore_->setCurrentFolder(prefixME_ + "/EEIntegrityClient/" + subfolder_);
263 
264  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
265 
266  int ism = superModules_[i];
267 
268  if ( meg01_[ism-1] ) dqmStore_->removeElement( meg01_[ism-1]->getName() );
269  meg01_[ism-1] = 0;
270 
271  if ( meg02_[ism-1] ) dqmStore_->removeElement( meg02_[ism-1]->getName() );
272  meg02_[ism-1] = 0;
273 
274  }
275 
276 }
277 
278 #ifdef WITH_ECAL_COND_DB
279 bool EEIntegrityClient::writeDb(EcalCondDBInterface* econn, RunIOV* runiov, MonRunIOV* moniov, bool& status) {
280 
281  status = true;
282 
283  EcalLogicID ecid;
284 
286  std::map<EcalLogicID, MonCrystalConsistencyDat> dataset1;
288  std::map<EcalLogicID, MonTTConsistencyDat> dataset2;
290  std::map<EcalLogicID, MonMemChConsistencyDat> dataset3;
292  std::map<EcalLogicID, MonMemTTConsistencyDat> dataset4;
293 
294  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
295 
296  int ism = superModules_[i];
297 
298  if ( h00_ && h00_->GetBinContent(ism) != 0 ) {
299  std::cerr << std::endl;
300  std::cerr << " DCC failed " << h00_->GetBinContent(ism) << " times" << std::endl;
301  std::cerr << std::endl;
302  }
303 
304  if ( verbose_ ) {
305  std::cout << " " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
306  std::cout << std::endl;
307  UtilsClient::printBadChannels(meg01_[ism-1], h01_[ism-1], true);
308  UtilsClient::printBadChannels(meg01_[ism-1], h02_[ism-1], true);
309  UtilsClient::printBadChannels(meg01_[ism-1], h03_[ism-1], true);
310  UtilsClient::printBadChannels(meg01_[ism-1], h04_[ism-1], true);
311  UtilsClient::printBadChannels(meg01_[ism-1], h05_[ism-1], true);
312 
313  UtilsClient::printBadChannels(meg02_[ism-1], h06_[ism-1], true);
314  UtilsClient::printBadChannels(meg02_[ism-1], h07_[ism-1], true);
315  UtilsClient::printBadChannels(meg02_[ism-1], h08_[ism-1], true);
316  UtilsClient::printBadChannels(meg02_[ism-1], h09_[ism-1], true);
317  }
318 
319  float num00;
320 
321  num00 = 0.;
322 
323  bool update0 = false;
324 
325  if ( h00_ ) {
326  num00 = h00_->GetBinContent(ism);
327  if ( num00 > 0 ) update0 = true;
328  }
329 
330  float num01, num02, num03;
331 
332  for ( int ix = 1; ix <= 50; ix++ ) {
333  for ( int iy = 1; iy <= 50; iy++ ) {
334 
335  int jx = ix + Numbers::ix0EE(ism);
336  int jy = iy + Numbers::iy0EE(ism);
337 
338  if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
339 
340  if ( ! Numbers::validEE(ism, jx, jy) ) continue;
341 
342  num01 = num02 = num03 = 0.;
343 
344  bool update1 = false;
345 
346  float numTot = -1.;
347 
348  if ( h_[ism-1] ) numTot = h_[ism-1]->GetBinContent(ix, iy);
349 
350  if ( h01_[ism-1] ) {
351  num01 = h01_[ism-1]->GetBinContent(ix, iy);
352  if ( num01 > 0 ) update1 = true;
353  }
354 
355  if ( h02_[ism-1] ) {
356  num02 = h02_[ism-1]->GetBinContent(ix, iy);
357  if ( num02 > 0 ) update1 = true;
358  }
359 
360  if ( h03_[ism-1] ) {
361  num03 = h03_[ism-1]->GetBinContent(ix, iy);
362  if ( num03 > 0 ) update1 = true;
363  }
364 
365  if ( update0 || update1 ) {
366 
367  if ( Numbers::icEE(ism, jx, jy) == 1 ) {
368 
369  if ( verbose_ ) {
370  std::cout << "Preparing dataset for " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
371  std::cout << "(" << Numbers::ix0EE(i+1)+ix << "," << Numbers::iy0EE(i+1)+iy << ") " << num00 << " " << num01 << " " << num02 << " " << num03 << std::endl;
372  std::cout << std::endl;
373  }
374 
375  }
376 
377  c1.setProcessedEvents(int(numTot));
378  c1.setProblematicEvents(int(num01+num02+num03));
379  c1.setProblemsGainZero(int(num01));
380  c1.setProblemsID(int(num02));
381  c1.setProblemsGainSwitch(int(num03));
382 
383  bool val;
384 
385  val = false;
386  if ( numTot > 0 ) {
387  float errorRate1 = num00 / ( numTot + num01 + num02 + num03 );
388  if ( errorRate1 > threshCry_ )
389  val = true;
390  errorRate1 = ( num01 + num02 + num03 ) / ( numTot + num01 + num02 + num03 ) / 3.;
391  if ( errorRate1 > threshCry_ )
392  val = true;
393  } else {
394  if ( num00 > 0 )
395  val = true;
396  if ( ( num01 + num02 + num03 ) > 0 )
397  val = true;
398  }
399  c1.setTaskStatus(val);
400 
401  int ic = Numbers::indexEE(ism, jx, jy);
402 
403  if ( ic == -1 ) continue;
404 
405  if ( econn ) {
406  ecid = LogicID::getEcalLogicID("EE_crystal_number", Numbers::iSM(ism, EcalEndcap), ic);
407  dataset1[ecid] = c1;
408  }
409 
410  status = status && !val;
411 
412  }
413 
414  }
415  }
416 
417  float num04, num05;
418 
419  for ( int ixt = 1; ixt <= 10; ixt++ ) {
420  for ( int iyt = 1; iyt <= 10; iyt++ ) {
421 
422  int jxt = Numbers::ix0EE(ism) + 1 + 5*(ixt-1);
423  int jyt = Numbers::iy0EE(ism) + 1 + 5*(iyt-1);
424 
425  if ( ism >= 1 && ism <= 9 ) jxt = 101 - jxt;
426 
427  num04 = num05 = 0.;
428 
429  bool update1 = false;
430 
431  float numTot = -1.;
432 
433  if ( h_[ism-1] ) {
434  numTot = 0.;
435  for ( int ix = 1 + 5*(ixt-1); ix <= 5*ixt; ix++ ) {
436  for ( int iy = 1 + 5*(iyt-1); iy <= 5*iyt; iy++ ) {
437  int jx = ix + Numbers::ix0EE(ism);
438  int jy = iy + Numbers::iy0EE(ism);
439  if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
440  if ( ! Numbers::validEE(ism, jx, jy) ) continue;
441  numTot += h_[ism-1]->GetBinContent(ix, iy);
442  }
443  }
444  }
445 
446  if ( h04_[ism-1] ) {
447  for ( int ix = 1 + 5*(ixt-1); ix <= 5*ixt; ix++ ) {
448  for ( int iy = 1 + 5*(iyt-1); iy <= 5*iyt; iy++ ) {
449  int jx = ix + Numbers::ix0EE(ism);
450  int jy = iy + Numbers::iy0EE(ism);
451  if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
452  if ( ! Numbers::validEE(ism, jx, jy) ) continue;
453  num04 = h04_[ism-1]->GetBinContent(ix, iy);
454  if ( num04 > 0 ) update1 = true;
455  }
456  }
457  }
458 
459  if ( h05_[ism-1] ) {
460  for ( int ix = 1 + 5*(ixt-1); ix <= 5*ixt; ix++ ) {
461  for ( int iy = 1 + 5*(iyt-1); iy <= 5*iyt; iy++ ) {
462  int jx = ix + Numbers::ix0EE(ism);
463  int jy = iy + Numbers::iy0EE(ism);
464  if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
465  if ( ! Numbers::validEE(ism, jx, jy) ) continue;
466  num05 = h05_[ism-1]->GetBinContent(ix, iy);
467  if ( num05 > 0 ) update1 = true;
468  }
469  }
470  }
471 
472  if ( update0 || update1 ) {
473 
474  if ( Numbers::iSC(ism, EcalEndcap, jxt, jyt) == 1 ) {
475 
476  if ( verbose_ ) {
477  std::cout << "Preparing dataset for " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
478  std::cout << "(" << 1+(Numbers::ix0EE(ism)+1+5*(ixt-1))/5 << "," << 1+(Numbers::iy0EE(ism)+1+5*(iyt-1))/5 << ") " << num00 << " " << num04 << " " << num05 << std::endl;
479  std::cout << std::endl;
480  }
481 
482  }
483 
484  c2.setProcessedEvents(int(numTot));
485  c2.setProblematicEvents(int(num04+num05));
486  c2.setProblemsID(int(num04));
487  c2.setProblemsSize(int(num05));
488  c2.setProblemsLV1(int(-1.));
489  c2.setProblemsBunchX(int(-1.));
490 
491  bool val;
492 
493  val = false;
494  if ( numTot > 0 ) {
495  float errorRate2 = num00 / ( numTot + num04 + num05 );
496  if ( errorRate2 > threshCry_ )
497  val = true;
498  errorRate2 = ( num04 + num05 ) / ( numTot + num04 + num05 ) / 2.;
499  if ( errorRate2 > threshCry_ )
500  val = true;
501  } else {
502  if ( num00 > 0 )
503  val = true;
504  if ( ( num04 + num05 ) > 0 )
505  val = true;
506  }
507  c2.setTaskStatus(val);
508 
509  int itt = Numbers::iSC(ism, EcalEndcap, jxt, jyt);
510 
511  if ( itt == -1 ) continue;
512 
513  if ( econn ) {
514  ecid = LogicID::getEcalLogicID("EE_readout_tower", Numbers::iSM(ism, EcalEndcap), itt);
515  dataset2[ecid] = c2;
516  }
517 
518  status = status && !val;
519 
520  }
521 
522  }
523  }
524 
525  float num06, num07;
526 
527  for ( int ix = 1; ix <= 10; ix++ ) {
528  for ( int iy = 1; iy <= 5; iy++ ) {
529 
530  num06 = num07 = 0.;
531 
532  bool update1 = false;
533 
534  float numTot = -1.;
535 
536  if ( hmem_[ism-1] ) numTot = hmem_[ism-1]->GetBinContent(ix, iy);
537 
538  if ( h06_[ism-1] ) {
539  num06 = h06_[ism-1]->GetBinContent(ix, iy);
540  if ( num06 > 0 ) update1 = true;
541  }
542 
543  if ( h07_[ism-1] ) {
544  num07 = h07_[ism-1]->GetBinContent(ix, iy);
545  if ( num07 > 0 ) update1 = true;
546  }
547 
548  if ( update0 || update1 ) {
549 
550  if ( ix ==1 && iy == 1 ) {
551 
552  if ( verbose_ ) {
553  std::cout << "Preparing dataset for mem of SM=" << ism << std::endl;
554  std::cout << "(" << ix << "," << iy << ") " << num06 << " " << num07 << std::endl;
555  std::cout << std::endl;
556  }
557 
558  }
559 
560  c3.setProcessedEvents( int (numTot));
561  c3.setProblematicEvents(int (num06+num07));
562  c3.setProblemsID(int (num06) );
563  c3.setProblemsGainZero(int (num07));
564  // c3.setProblemsGainSwitch(int prob);
565 
566  bool val;
567 
568  val = false;
569  if ( numTot > 0 ) {
570  float errorRate1 = num00 / ( numTot + num06 + num07 );
571  if ( errorRate1 > threshCry_ )
572  val = true;
573  errorRate1 = ( num06 + num07 ) / ( numTot + num06 + num07 ) / 2.;
574  if ( errorRate1 > threshCry_ )
575  val = true;
576  } else {
577  if ( num00 > 0 )
578  val = true;
579  if ( ( num06 + num07 ) > 0 )
580  val = true;
581  }
582  c3. setTaskStatus(val);
583 
584  int ic = EEIntegrityClient::chNum[ (ix-1)%5 ][ (iy-1) ] + (ix-1)/5 * 25;
585 
586  if ( econn ) {
587  ecid = LogicID::getEcalLogicID("EE_mem_channel", Numbers::iSM(ism, EcalEndcap), ic);
588  dataset3[ecid] = c3;
589  }
590 
591  status = status && !val;
592 
593  }
594 
595  }
596  }
597 
598  float num08, num09;
599 
600  for ( int ixt = 1; ixt <= 2; ixt++ ) {
601 
602  num08 = num09 = 0.;
603 
604  bool update1 = false;
605 
606  float numTot = -1.;
607 
608  if ( hmem_[ism-1] ) {
609  numTot = 0.;
610  for ( int ix = 1 + 5*(ixt-1); ix <= 5*ixt; ix++ ) {
611  for ( int iy = 1 ; iy <= 5; iy++ ) {
612  numTot += hmem_[ism-1]->GetBinContent(ix, iy);
613  }
614  }
615  }
616 
617  if ( h08_[ism-1] ) {
618  num08 = h08_[ism-1]->GetBinContent(ixt, 1);
619  if ( num08 > 0 ) update1 = true;
620  }
621 
622  if ( h09_[ism-1] ) {
623  num09 = h09_[ism-1]->GetBinContent(ixt, 1);
624  if ( num09 > 0 ) update1 = true;
625  }
626 
627  if ( update0 || update1 ) {
628 
629  if ( ixt == 1 ) {
630 
631  if ( verbose_ ) {
632  std::cout << "Preparing dataset for " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
633  std::cout << "(" << ixt << ") " << num08 << " " << num09 << std::endl;
634  std::cout << std::endl;
635  }
636 
637  }
638 
639  c4.setProcessedEvents( int(numTot) );
640  c4.setProblematicEvents( int(num08 + num09) );
641  c4.setProblemsID( int(num08) );
642  c4.setProblemsSize(int (num09) );
643  // setProblemsLV1(int LV1);
644  // setProblemsBunchX(int bunchX);
645 
646  bool val;
647 
648  val = false;
649  if ( numTot > 0 ) {
650  float errorRate2 = num00 / ( numTot + num08 + num09 );
651  if ( errorRate2 > threshCry_ )
652  val = true;
653  errorRate2 = ( num08 + num09 ) / ( numTot/25. + num08 + num09 ) / 2.;
654  if ( errorRate2 > threshCry_ )
655  val = true;
656  } else {
657  if ( num00 > 0 )
658  val = true;
659  if ( ( num08 + num09 ) > 0 )
660  val = true;
661  }
662  c4.setTaskStatus(val);
663 
664  int itt = 68 + ixt;
665 
666  if ( econn ) {
667  ecid = LogicID::getEcalLogicID("EE_mem_TT", Numbers::iSM(ism, EcalEndcap), itt);
668  dataset4[ecid] = c4;
669  }
670 
671  status = status && !val;
672 
673  }
674 
675  }
676 
677  }
678 
679  if ( econn ) {
680  try {
681  if ( verbose_ ) std::cout << "Inserting MonConsistencyDat ..." << std::endl;
682  if ( dataset1.size() != 0 ) econn->insertDataArraySet(&dataset1, moniov);
683  if ( dataset2.size() != 0 ) econn->insertDataArraySet(&dataset2, moniov);
684  if ( dataset3.size() != 0 ) econn->insertDataArraySet(&dataset3, moniov);
685  if ( dataset4.size() != 0 ) econn->insertDataArraySet(&dataset4, moniov);
686  if ( verbose_ ) std::cout << "done." << std::endl;
687  } catch (std::runtime_error &e) {
688  std::cerr << e.what() << std::endl;
689  }
690  }
691 
692  return true;
693 
694 }
695 #endif
696 
698 
699  ievt_++;
700  jevt_++;
701  if ( ievt_ % 10 == 0 ) {
702  if ( debug_ ) std::cout << "EEIntegrityClient: ievt/jevt = " << ievt_ << "/" << jevt_ << std::endl;
703  }
704 
705  uint32_t bits01 = 0;
706  bits01 |= 1 << EcalDQMStatusHelper::CH_ID_ERROR;
709  bits01 |= 1 << EcalDQMStatusHelper::TT_ID_ERROR;
710  bits01 |= 1 << EcalDQMStatusHelper::TT_SIZE_ERROR;
711 
712  std::string subdir(subfolder_.size() ? subfolder_ + "/" : "");
713 
714  MonitorElement* me;
715 
716  me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "EEIT DCC size error" );
718 
719  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
720 
721  int ism = superModules_[i];
722 
723  me = dqmStore_->get( prefixME_ + "/EEOccupancyTask/" + subdir + "EEOT digi occupancy " + Numbers::sEE(ism) );
724  h_[ism-1] = UtilsClient::getHisto( me, cloneME_, h_[ism-1] );
725 
726  me = dqmStore_->get( prefixME_ + "/EEOccupancyTask/" + subdir + "EEOT MEM digi occupancy " + Numbers::sEE(ism) );
727  hmem_[ism-1] = UtilsClient::getHisto( me, cloneME_, hmem_[ism-1] );
728 
729  me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "Gain/EEIT gain " + Numbers::sEE(ism) );
730  h01_[ism-1] = UtilsClient::getHisto( me, cloneME_, h01_[ism-1] );
731 
732  me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "ChId/EEIT ChId " + Numbers::sEE(ism) );
733  h02_[ism-1] = UtilsClient::getHisto( me, cloneME_, h02_[ism-1] );
734 
735  me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "GainSwitch/EEIT gain switch " + Numbers::sEE(ism) );
736  h03_[ism-1] = UtilsClient::getHisto( me, cloneME_, h03_[ism-1] );
737 
738  me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "TTId/EEIT TTId " + Numbers::sEE(ism) );
739  h04_[ism-1] = UtilsClient::getHisto( me, cloneME_, h04_[ism-1] );
740 
741  me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "TTBlockSize/EEIT TTBlockSize " + Numbers::sEE(ism) );
742  h05_[ism-1] = UtilsClient::getHisto( me, cloneME_, h05_[ism-1] );
743 
744  me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "MemChId/EEIT MemChId " + Numbers::sEE(ism) );
745  h06_[ism-1] = UtilsClient::getHisto( me, cloneME_, h06_[ism-1] );
746 
747  me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "MemGain/EEIT MemGain " + Numbers::sEE(ism) );
748  h07_[ism-1] = UtilsClient::getHisto( me, cloneME_, h07_[ism-1] );
749 
750  me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "MemTTId/EEIT MemTTId " + Numbers::sEE(ism) );
751  h08_[ism-1] = UtilsClient::getHisto( me, cloneME_, h08_[ism-1] );
752 
753  me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "MemSize/EEIT MemSize " + Numbers::sEE(ism) );
754  h09_[ism-1] = UtilsClient::getHisto( me, cloneME_, h09_[ism-1] );
755 
756  float num00;
757 
758  // integrity summary histograms
759  if ( meg01_[ism-1] ) meg01_[ism-1]->Reset();
760  if ( meg01_[ism-1] ) meg02_[ism-1]->Reset();
761 
762  num00 = 0.;
763 
764  bool update0 = false;
765 
766  // dcc size errors
767  if ( h00_ ) {
768  num00 = h00_->GetBinContent(ism);
769  update0 = true;
770  }
771 
772  float num01, num02, num03, num04, num05;
773 
774  for ( int ix = 1; ix <= 50; ix++ ) {
775  for ( int iy = 1; iy <= 50; iy++ ) {
776 
777  num01 = num02 = num03 = num04 = num05 = 0.;
778 
779  if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ix, iy, 6. );
780 
781  bool update1 = false;
782  bool update2 = false;
783 
784  float numTot = -1.;
785 
786  if ( h_[ism-1] ) numTot = h_[ism-1]->GetBinContent(ix, iy);
787 
788  if ( h01_[ism-1] ) {
789  num01 = h01_[ism-1]->GetBinContent(ix, iy);
790  update1 = true;
791  }
792 
793  if ( h02_[ism-1] ) {
794  num02 = h02_[ism-1]->GetBinContent(ix, iy);
795  update1 = true;
796  }
797 
798  if ( h03_[ism-1] ) {
799  num03 = h03_[ism-1]->GetBinContent(ix, iy);
800  update1 = true;
801  }
802 
803  if ( h04_[ism-1] ) {
804  num04 = h04_[ism-1]->GetBinContent(ix, iy);
805  update2 = true;
806  }
807 
808  if ( h05_[ism-1] ) {
809  num05 = h05_[ism-1]->GetBinContent(ix, iy);
810  update2 = true;
811  }
812 
813  if ( update0 || update1 || update2 ) {
814 
815  float val;
816 
817  val = 1.;
818  // number of events on a channel
819  if ( numTot > 0 ) {
820  float errorRate1 = num00 / ( numTot + num01 + num02 + num03 );
821  if ( errorRate1 > threshCry_ )
822  val = 0.;
823  errorRate1 = ( num01 + num02 + num03 ) / ( numTot + num01 + num02 + num03 ) / 3.;
824  if ( errorRate1 > threshCry_ )
825  val = 0.;
826  float errorRate2 = ( num04 + num05 ) / ( numTot + num04 + num05 ) / 2.;
827  if ( errorRate2 > threshCry_ )
828  val = 0.;
829  } else {
830  val = 2.;
831  if ( num00 > 0 )
832  val = 0.;
833  if ( ( num01 + num02 + num03 ) > 0 )
834  val = 0.;
835  if ( ( num04 + num05 ) > 0 )
836  val = 0.;
837  }
838 
839  int jx = ix + Numbers::ix0EE(ism);
840  int jy = iy + Numbers::iy0EE(ism);
841 
842  if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
843 
844  // filling the summary for SM channels
845  if ( Numbers::validEE(ism, jx, jy) ) {
846  if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ix, iy, val );
847  }
848 
849  }
850 
851  if ( Masks::maskChannel(ism, ix, iy, bits01, EcalEndcap) ) UtilsClient::maskBinContent( meg01_[ism-1], ix, iy );
852 
853  }
854  } // end of loop on crystals to fill summary plot
855 
856  // summaries for mem channels
857  float num06, num07, num08, num09;
858 
859  for ( int ie = 1; ie <= 10; ie++ ) {
860  for ( int ip = 1; ip <= 5; ip++ ) {
861 
862  num06 = num07 = num08 = num09 = 0.;
863 
864  // initialize summary histo for mem
865  if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ie, ip, 6. );
866 
867  // non-existing mem
868  if ( (ism >= 3 && ism <= 4) || (ism >= 7 && ism <= 9) ) continue;
869  if ( (ism >= 12 && ism <= 13) || (ism >= 16 && ism <= 18) ) continue;
870 
871  if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ie, ip, 2. );
872 
873  bool update1 = false;
874  bool update2 = false;
875 
876  float numTotmem = -1.;
877 
878  if ( hmem_[ism-1] ) numTotmem = hmem_[ism-1]->GetBinContent(ie, ip);
879 
880  if ( h06_[ism-1] ) {
881  num06 = h06_[ism-1]->GetBinContent(ie, ip);
882  update1 = true;
883  }
884 
885  if ( h07_[ism-1] ) {
886  num07 = h07_[ism-1]->GetBinContent(ie, ip);
887  update1 = true;
888  }
889 
890  int iet = 1 + ((ie-1)/5);
891  int ipt = 1;
892 
893  if ( h08_[ism-1] ) {
894  num08 = h08_[ism-1]->GetBinContent(iet, ipt);
895  update2 = true;
896  }
897 
898  if ( h09_[ism-1] ) {
899  num09 = h09_[ism-1]->GetBinContent(iet, ipt);
900  update2 = true;
901  }
902 
903  if ( update0 || update1 || update2 ) {
904 
905  float val;
906 
907  val = 1.;
908  // number of events on a channel
909  if ( numTotmem > 0 ) {
910  float errorRate1 = ( num06 + num07 ) / ( numTotmem + num06 + num07 )/ 2.;
911  if ( errorRate1 > threshCry_ )
912  val = 0.;
913  float errorRate2 = ( num08 + num09 ) / ( numTotmem/25. + num08 + num09 ) / 2.;
914  if ( errorRate2 > threshCry_ )
915  val = 0.;
916  } else {
917  val = 2.;
918  if ( ( num06 + num07 ) > 0 )
919  val = 0.;
920  if ( ( num08 + num09 ) > 0 )
921  val = 0.;
922  }
923 
924  // filling summary for mem channels
925  if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ie, ip, val );
926 
927  }
928 
929  if ( Masks::maskPn(ism, ie, bits01, EcalEndcap) ) UtilsClient::maskBinContent( meg02_[ism-1], ie, ip );
930 
931  }
932  } // end loop on mem channels
933 
934  } // end loop on supermodules
935 
936 }
937 
938 const int EEIntegrityClient::chNum[5][5] = {
939  { 1, 2, 3, 4, 5},
940  {10, 9, 8, 7, 6},
941  {11, 12, 13, 14, 15},
942  {20, 19, 18, 17, 16},
943  {21, 22, 23, 24, 25}
944 };
945 
Cache logicID vector from database.
T getUntrackedParameter(std::string const &, T const &) const
static std::string sEE(const unsigned ism)
Definition: Numbers.cc:223
int i
Definition: DBlmapReader.cc:9
static bool validEE(const unsigned ism, const unsigned ix, const unsigned iy)
Definition: Numbers.cc:829
void setup(void)
Setup.
void setBinContent(int binx, double content)
set content of bin (1-D)
static bool maskChannel(int ism, int i1, int i2, uint32_t bits, const EcalSubdetector subdet)
Definition: Masks.cc:57
void setProblematicEvents(int prob)
static unsigned icEE(const unsigned ism, const unsigned ix, const unsigned iy)
Definition: Numbers.cc:736
static T getHisto(const MonitorElement *me, bool clone=false, T ret=0)
Returns the histogram contained by the Monitor Element.
Definition: UtilsClient.h:89
void endJob(void)
EndJob.
std::string subfolder_
Some &quot;id&quot; conversions.
void endRun(void)
EndRun.
void setProblemsLV1(int LV1)
static const int TT_SIZE_ERROR
static int ix0EE(const unsigned ism)
Definition: Numbers.cc:770
static const int CH_GAIN_SWITCH_ERROR
void setProblemsSize(int size)
static void maskBinContent(const MonitorElement *me, const int ix, const int iy)
Mask the bin content.
Definition: UtilsClient.cc:231
void cleanup(void)
Cleanup.
static bool maskPn(int ism, int i1, uint32_t bits, const EcalSubdetector subdet)
Definition: Masks.cc:109
static int iy0EE(const unsigned ism)
Definition: Numbers.cc:809
MonitorElement * meg02_[18]
void setProcessedEvents(int proc)
std::vector< int > superModules_
virtual ~EEIntegrityClient()
Destructor.
static unsigned iSC(const EcalScDetId &id)
Definition: Numbers.cc:434
void removeElement(const std::string &name)
Definition: DQMStore.cc:2772
channel masking
void setProblemsBunchX(int bunchX)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1623
Ecal Monitor Utils for Client.
void beginRun(void)
BeginRun.
static const int CH_GAIN_ZERO_ERROR
void analyze(void)
Analyze.
void beginJob(void)
BeginJob.
void setTaskStatus(bool status)
void setTaskStatus(bool status)
static unsigned indexEE(const unsigned ism, const unsigned ix, const unsigned iy)
Definition: Numbers.cc:709
static unsigned iSM(const unsigned ism, const EcalSubdetector subdet)
Definition: Numbers.cc:243
static const int chNum[5][5]
static const int TT_ID_ERROR
void insertDataArraySet(const std::map< EcalLogicID, DATT > *data, IOVT *iov)
tuple cout
Definition: gather_cfg.py:121
EEIntegrityClient(const edm::ParameterSet &ps)
Constructor.
MonitorElement * meg01_[18]
tuple status
Definition: ntuplemaker.py:245
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1000
static EcalLogicID getEcalLogicID(const char *name, const int id1=EcalLogicID::NULLID, const int id2=EcalLogicID::NULLID, const int id3=EcalLogicID::NULLID)
Definition: LogicID.h:29
Definition: RunIOV.h:13
static const int CH_ID_ERROR
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
static void printBadChannels(const MonitorElement *me, TH1 *hi, bool positive_only=false)
Print the bad channels.
Definition: UtilsClient.cc:14
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584