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