CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DQM/EcalBarrelMonitorClient/src/EBIntegrityClient.cc

Go to the documentation of this file.
00001 
00002 /*
00003  * \file EBIntegrityClient.cc
00004  *
00005  * $Date: 2011/09/02 13:55:01 $
00006  * $Revision: 1.232 $
00007  * \author G. Della Ricca
00008  * \author G. Franzoni
00009  *
00010  */
00011 
00012 #include <memory>
00013 #include <iostream>
00014 #include <fstream>
00015 #include <iomanip>
00016 
00017 #include "FWCore/ServiceRegistry/interface/Service.h"
00018 
00019 #include "DQMServices/Core/interface/DQMStore.h"
00020 #include "DQMServices/Core/interface/MonitorElement.h"
00021 
00022 #ifdef WITH_ECAL_COND_DB
00023 #include "OnlineDB/EcalCondDB/interface/RunTag.h"
00024 #include "OnlineDB/EcalCondDB/interface/RunIOV.h"
00025 #include "OnlineDB/EcalCondDB/interface/MonCrystalConsistencyDat.h"
00026 #include "OnlineDB/EcalCondDB/interface/MonTTConsistencyDat.h"
00027 #include "OnlineDB/EcalCondDB/interface/MonMemChConsistencyDat.h"
00028 #include "OnlineDB/EcalCondDB/interface/MonMemTTConsistencyDat.h"
00029 #include "OnlineDB/EcalCondDB/interface/RunCrystalErrorsDat.h"
00030 #include "OnlineDB/EcalCondDB/interface/RunTTErrorsDat.h"
00031 #include "OnlineDB/EcalCondDB/interface/RunPNErrorsDat.h"
00032 #include "OnlineDB/EcalCondDB/interface/RunMemChErrorsDat.h"
00033 #include "OnlineDB/EcalCondDB/interface/RunMemTTErrorsDat.h"
00034 #include "OnlineDB/EcalCondDB/interface/EcalCondDBInterface.h"
00035 #include "DQM/EcalCommon/interface/LogicID.h"
00036 #endif
00037 
00038 #include "DQM/EcalCommon/interface/Masks.h"
00039 
00040 #include "DQM/EcalCommon/interface/UtilsClient.h"
00041 #include "DQM/EcalCommon/interface/Numbers.h"
00042 
00043 #include "DQM/EcalBarrelMonitorClient/interface/EBIntegrityClient.h"
00044 
00045 EBIntegrityClient::EBIntegrityClient(const edm::ParameterSet& ps) {
00046 
00047   // cloneME switch
00048   cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00049 
00050   // verbose switch
00051   verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
00052 
00053   // debug switch
00054   debug_ = ps.getUntrackedParameter<bool>("debug", false);
00055 
00056   // prefixME path
00057   prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00058 
00059   // enableCleanup_ switch
00060   enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00061 
00062   // vector of selected Super Modules (Defaults to all 36).
00063   superModules_.reserve(36);
00064   for ( unsigned int i = 1; i <= 36; i++ ) superModules_.push_back(i);
00065   superModules_ = ps.getUntrackedParameter<std::vector<int> >("superModules", superModules_);
00066 
00067   h00_ = 0;
00068 
00069   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00070 
00071     int ism = superModules_[i];
00072 
00073     h_[ism-1] = 0;
00074     hmem_[ism-1] = 0;
00075 
00076     h01_[ism-1] = 0;
00077     h02_[ism-1] = 0;
00078     h03_[ism-1] = 0;
00079     h04_[ism-1] = 0;
00080     h05_[ism-1] = 0;
00081     h06_[ism-1] = 0;
00082     h07_[ism-1] = 0;
00083     h08_[ism-1] = 0;
00084     h09_[ism-1] = 0;
00085 
00086   }
00087 
00088   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00089 
00090     int ism = superModules_[i];
00091 
00092     // integrity summary histograms
00093     meg01_[ism-1] = 0;
00094     meg02_[ism-1] = 0;
00095 
00096   }
00097 
00098   threshCry_ = 0.01;
00099 
00100 }
00101 
00102 EBIntegrityClient::~EBIntegrityClient() {
00103 
00104 }
00105 
00106 void EBIntegrityClient::beginJob(void) {
00107 
00108   dqmStore_ = edm::Service<DQMStore>().operator->();
00109 
00110   if ( debug_ ) std::cout << "EBIntegrityClient: beginJob" << std::endl;
00111 
00112   ievt_ = 0;
00113   jevt_ = 0;
00114 
00115 }
00116 
00117 void EBIntegrityClient::beginRun(void) {
00118 
00119   if ( debug_ ) std::cout << "EBIntegrityClient: beginRun" << std::endl;
00120 
00121   jevt_ = 0;
00122 
00123   this->setup();
00124 
00125 }
00126 
00127 void EBIntegrityClient::endJob(void) {
00128 
00129   if ( debug_ ) std::cout << "EBIntegrityClient: endJob, ievt = " << ievt_ << std::endl;
00130 
00131   this->cleanup();
00132 
00133 }
00134 
00135 void EBIntegrityClient::endRun(void) {
00136 
00137   if ( debug_ ) std::cout << "EBIntegrityClient: endRun, jevt = " << jevt_ << std::endl;
00138 
00139   this->cleanup();
00140 
00141 }
00142 
00143 void EBIntegrityClient::setup(void) {
00144 
00145   std::string name;
00146 
00147   dqmStore_->setCurrentFolder( prefixME_ + "/EBIntegrityClient" );
00148 
00149   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00150 
00151     int ism = superModules_[i];
00152 
00153     if ( meg01_[ism-1] ) dqmStore_->removeElement( meg01_[ism-1]->getName() );
00154     name = "EBIT data integrity quality " + Numbers::sEB(ism);
00155     meg01_[ism-1] = dqmStore_->book2D(name, name, 85, 0., 85., 20, 0., 20.);
00156     meg01_[ism-1]->setAxisTitle("ieta", 1);
00157     meg01_[ism-1]->setAxisTitle("iphi", 2);
00158 
00159     if ( meg02_[ism-1] ) dqmStore_->removeElement( meg02_[ism-1]->getName() );
00160     name = "EBIT data integrity quality MEM " + Numbers::sEB(ism);
00161     meg02_[ism-1] = dqmStore_->book2D(name, name, 10, 0., 10., 5, 0.,5.);
00162     meg02_[ism-1]->setAxisTitle("pseudo-strip", 1);
00163     meg02_[ism-1]->setAxisTitle("channel", 2);
00164 
00165   }
00166 
00167   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00168 
00169     int ism = superModules_[i];
00170 
00171     if ( meg01_[ism-1] ) meg01_[ism-1]->Reset();
00172     if ( meg02_[ism-1] ) meg02_[ism-1]->Reset();
00173 
00174     for ( int ie = 1; ie <= 85; ie++ ) {
00175       for ( int ip = 1; ip <= 20; ip++ ) {
00176 
00177         if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ie, ip, 2. );
00178 
00179       }
00180     }
00181 
00182     for ( int ie = 1; ie <= 10; ie++ ) {
00183       for ( int ip = 1; ip <= 5; ip++ ) {
00184 
00185         if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ie, ip, 2. );
00186 
00187       }
00188     }
00189 
00190   }
00191 
00192 }
00193 
00194 void EBIntegrityClient::cleanup(void) {
00195 
00196   if ( ! enableCleanup_ ) return;
00197 
00198   if ( cloneME_ ) {
00199     if ( h00_ ) delete h00_;
00200   }
00201 
00202   h00_ = 0;
00203 
00204   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00205 
00206     int ism = superModules_[i];
00207 
00208     if ( cloneME_ ) {
00209       if ( h_[ism-1] )    delete h_[ism-1];
00210       if ( hmem_[ism-1] ) delete hmem_[ism-1];
00211 
00212       if ( h01_[ism-1] ) delete h01_[ism-1];
00213       if ( h02_[ism-1] ) delete h02_[ism-1];
00214       if ( h03_[ism-1] ) delete h03_[ism-1];
00215       if ( h04_[ism-1] ) delete h04_[ism-1];
00216       if ( h05_[ism-1] ) delete h05_[ism-1];
00217       if ( h06_[ism-1] ) delete h06_[ism-1];
00218       if ( h07_[ism-1] ) delete h07_[ism-1];
00219       if ( h08_[ism-1] ) delete h08_[ism-1];
00220       if ( h09_[ism-1] ) delete h09_[ism-1];
00221     }
00222 
00223     h_[ism-1] = 0;
00224     hmem_[ism-1] = 0;
00225 
00226     h01_[ism-1] = 0;
00227     h02_[ism-1] = 0;
00228     h03_[ism-1] = 0;
00229     h04_[ism-1] = 0;
00230     h05_[ism-1] = 0;
00231     h06_[ism-1] = 0;
00232     h07_[ism-1] = 0;
00233     h08_[ism-1] = 0;
00234     h09_[ism-1] = 0;
00235 
00236   }
00237 
00238   dqmStore_->setCurrentFolder( prefixME_ + "/EBIntegrityClient" );
00239 
00240   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00241 
00242     int ism = superModules_[i];
00243 
00244     if ( meg01_[ism-1] ) dqmStore_->removeElement( meg01_[ism-1]->getName() );
00245     meg01_[ism-1] = 0;
00246 
00247     if ( meg02_[ism-1] ) dqmStore_->removeElement( meg02_[ism-1]->getName() );
00248     meg02_[ism-1] = 0;
00249 
00250   }
00251 
00252 }
00253 
00254 #ifdef WITH_ECAL_COND_DB
00255 bool EBIntegrityClient::writeDb(EcalCondDBInterface* econn, RunIOV* runiov, MonRunIOV* moniov, bool& status) {
00256 
00257   status = true;
00258 
00259   EcalLogicID ecid;
00260 
00261   MonCrystalConsistencyDat c1;
00262   std::map<EcalLogicID, MonCrystalConsistencyDat> dataset1;
00263   MonTTConsistencyDat c2;
00264   std::map<EcalLogicID, MonTTConsistencyDat> dataset2;
00265   MonMemChConsistencyDat c3;
00266   std::map<EcalLogicID, MonMemChConsistencyDat> dataset3;
00267   MonMemTTConsistencyDat c4;
00268   std::map<EcalLogicID, MonMemTTConsistencyDat> dataset4;
00269 
00270   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00271 
00272     int ism = superModules_[i];
00273 
00274     if ( h00_ && h00_->GetBinContent(ism) != 0 ) {
00275       std::cerr << " DCC failed " << h00_->GetBinContent(ism) << " times" << std::endl;
00276       std::cerr << std::endl;
00277     }
00278 
00279     if ( verbose_ ) {
00280       std::cout << " " << Numbers::sEB(ism) << " (ism=" << ism << ")" << std::endl;
00281       std::cout << std::endl;
00282       UtilsClient::printBadChannels(meg01_[ism-1], h01_[ism-1], true);
00283       UtilsClient::printBadChannels(meg01_[ism-1], h02_[ism-1], true);
00284       UtilsClient::printBadChannels(meg01_[ism-1], h03_[ism-1], true);
00285       UtilsClient::printBadChannels(meg01_[ism-1], h04_[ism-1], true);
00286       UtilsClient::printBadChannels(meg01_[ism-1], h05_[ism-1], true);
00287 
00288       UtilsClient::printBadChannels(meg02_[ism-1], h06_[ism-1], true);
00289       UtilsClient::printBadChannels(meg02_[ism-1], h07_[ism-1], true);
00290       UtilsClient::printBadChannels(meg02_[ism-1], h08_[ism-1], true);
00291       UtilsClient::printBadChannels(meg02_[ism-1], h09_[ism-1], true);
00292     }
00293 
00294     float num00;
00295 
00296     num00 = 0.;
00297 
00298     bool update0 = false;
00299 
00300     if ( h00_ ) {
00301       num00 = h00_->GetBinContent(ism);
00302       if ( num00 > 0 ) update0 = true;
00303     }
00304 
00305     float num01, num02, num03;
00306 
00307     for ( int ie = 1; ie <= 85; ie++ ) {
00308       for ( int ip = 1; ip <= 20; ip++ ) {
00309 
00310         num01 = num02 = num03 = 0.;
00311 
00312         bool update1 = false;
00313 
00314         float numTot = -1.;
00315 
00316         if ( h_[ism-1] ) numTot = h_[ism-1]->GetBinContent(ie, ip);
00317 
00318         if ( h01_[ism-1] ) {
00319           num01  = h01_[ism-1]->GetBinContent(ie, ip);
00320           if ( num01 > 0 ) update1 = true;
00321         }
00322 
00323         if ( h02_[ism-1] ) {
00324           num02  = h02_[ism-1]->GetBinContent(ie, ip);
00325           if ( num02 > 0 ) update1 = true;
00326         }
00327 
00328         if ( h03_[ism-1] ) {
00329           num03  = h03_[ism-1]->GetBinContent(ie, ip);
00330           if ( num03 > 0 ) update1 = true;
00331         }
00332 
00333         if ( update0 || update1 ) {
00334 
00335           if ( Numbers::icEB(ism, ie, ip) == 1 ) {
00336 
00337             if ( verbose_ ) {
00338               std::cout << "Preparing dataset for " << Numbers::sEB(ism) << " (ism=" << ism << ")" << std::endl;
00339               std::cout << "(" << ie << "," << ip << ") " << num00 << " " << num01 << " " << num02 << " " << num03 << std::endl;
00340               std::cout << std::endl;
00341             }
00342 
00343           }
00344 
00345           c1.setProcessedEvents(int(numTot));
00346           c1.setProblematicEvents(int(num01+num02+num03));
00347           c1.setProblemsGainZero(int(num01));
00348           c1.setProblemsID(int(num02));
00349           c1.setProblemsGainSwitch(int(num03));
00350 
00351           bool val;
00352 
00353           val = false;
00354           if ( numTot > 0 ) {
00355             float errorRate1 = num00 / ( numTot + num01 + num02 + num03 );
00356             if ( errorRate1 > threshCry_ )
00357               val = true;
00358             errorRate1 = ( num01 + num02 + num03 ) / ( numTot + num01 + num02 + num03 ) / 3.;
00359             if ( errorRate1 > threshCry_ )
00360               val = true;
00361           } else {
00362             if ( num00 > 0 )
00363               val = true;
00364             if ( ( num01 + num02 + num03 ) > 0 )
00365               val = true;
00366           }
00367           c1.setTaskStatus(val);
00368 
00369           int ic = Numbers::indexEB(ism, ie, ip);
00370 
00371           if ( econn ) {
00372             ecid = LogicID::getEcalLogicID("EB_crystal_number", Numbers::iSM(ism, EcalBarrel), ic);
00373             dataset1[ecid] = c1;
00374           }
00375 
00376           status = status && !val;
00377 
00378         }
00379 
00380       }
00381     }
00382 
00383     float num04, num05;
00384 
00385     for ( int iet = 1; iet <= 17; iet++ ) {
00386       for ( int ipt = 1; ipt <= 4; ipt++ ) {
00387 
00388         num04 = num05 = 0.;
00389 
00390         bool update1 = false;
00391 
00392         float numTot = -1.;
00393 
00394         if ( h_[ism-1] ) {
00395           numTot = 0.;
00396           for ( int ie = 1 + 5*(iet-1); ie <= 5*iet; ie++ ) {
00397             for ( int ip = 1 + 5*(ipt-1); ip <= 5*ipt; ip++ ) {
00398               numTot += h_[ism-1]->GetBinContent(ie, ip);
00399             }
00400           }
00401         }
00402 
00403         if ( h04_[ism-1] ) {
00404           num04  = h04_[ism-1]->GetBinContent(iet, ipt);
00405           if ( num04 > 0 ) update1 = true;
00406         }
00407 
00408         if ( h05_[ism-1] ) {
00409           num05  = h05_[ism-1]->GetBinContent(iet, ipt);
00410           if ( num05 > 0 ) update1 = true;
00411         }
00412 
00413         if ( update0 || update1 ) {
00414 
00415           if ( Numbers::iSC(ism, EcalBarrel, 1+5*(iet-1), 1+5*(ipt-1)) == 1 ) {
00416 
00417             if ( verbose_ ) {
00418               std::cout << "Preparing dataset for " << Numbers::sEB(ism) << " (ism=" << ism << ")" << std::endl;
00419               std::cout << "(" << iet << "," << ipt << ") " << num00 << " " << num04 << " " << num05 << std::endl;
00420               std::cout << std::endl;
00421             }
00422 
00423           }
00424 
00425           c2.setProcessedEvents(int(numTot));
00426           c2.setProblematicEvents(int(num04+num05));
00427           c2.setProblemsID(int(num04));
00428           c2.setProblemsSize(int(num05));
00429           c2.setProblemsLV1(int(-1.));
00430           c2.setProblemsBunchX(int(-1.));
00431 
00432           bool val;
00433 
00434           val = false;
00435           if ( numTot > 0 ) {
00436             float errorRate2 = num00 / ( numTot/25. + num04 + num05 );
00437             if ( errorRate2 > threshCry_ )
00438               val = true;
00439             errorRate2 = ( num04 + num05 ) / ( numTot/25. + num04 + num05 ) / 2.;
00440             if ( errorRate2 > threshCry_ )
00441               val = true;
00442           } else {
00443             if ( num00 > 0 )
00444               val = true;
00445             if ( ( num04 + num05 ) > 0 )
00446               val = true;
00447           }
00448           c2.setTaskStatus(val);
00449 
00450           int itt = Numbers::iSC(ism, EcalBarrel, 1+5*(iet-1), 1+5*(ipt-1));
00451 
00452           if ( econn ) {
00453             ecid = LogicID::getEcalLogicID("EB_trigger_tower", Numbers::iSM(ism, EcalBarrel), itt);
00454             dataset2[ecid] = c2;
00455           }
00456 
00457           status = status && !val;
00458 
00459         }
00460 
00461       }
00462     }
00463 
00464     float num06, num07;
00465 
00466     for ( int ie = 1; ie <= 10; ie++ ) {
00467       for ( int ip = 1; ip <= 5; ip++ ) {
00468 
00469         num06 = num07 = 0.;
00470 
00471         bool update1 = false;
00472 
00473         float numTot = -1.;
00474 
00475         if ( hmem_[ism-1] ) numTot = hmem_[ism-1]->GetBinContent(ie, ip);
00476 
00477         if ( h06_[ism-1] ) {
00478           num06  = h06_[ism-1]->GetBinContent(ie, ip);
00479           if ( num06 > 0 ) update1 = true;
00480         }
00481 
00482         if ( h07_[ism-1] ) {
00483           num07  = h07_[ism-1]->GetBinContent(ie, ip);
00484           if ( num07 > 0 ) update1 = true;
00485         }
00486 
00487         if ( update0 || update1 ) {
00488 
00489           if ( ie ==1 && ip == 1 ) {
00490 
00491             if ( verbose_ ) {
00492               std::cout << "Preparing dataset for mem of SM=" << ism << std::endl;
00493               std::cout << "(" << ie << "," << ip << ") " << num06 << " " << num07 << std::endl;
00494               std::cout << std::endl;
00495             }
00496 
00497           }
00498 
00499           c3.setProcessedEvents( int (numTot));
00500           c3.setProblematicEvents(int (num06+num07));
00501           c3.setProblemsID(int (num06) );
00502           c3.setProblemsGainZero(int (num07));
00503           // c3.setProblemsGainSwitch(int prob);
00504 
00505           bool val;
00506 
00507           val = false;
00508           if ( numTot > 0 ) {
00509             float errorRate1 = num00 / ( numTot + num06 + num07 );
00510             if ( errorRate1 > threshCry_ )
00511               val = true;
00512             errorRate1 = ( num06 + num07 ) / ( numTot + num06 + num07 ) / 2.;
00513             if ( errorRate1 > threshCry_ )
00514               val = true;
00515           } else {
00516             if ( num00 > 0 )
00517              val = true;
00518             if ( ( num06 + num07 ) > 0 )
00519               val = true;
00520           }
00521           c3. setTaskStatus(val);
00522 
00523           int ic = EBIntegrityClient::chNum[ (ie-1)%5 ][ (ip-1) ] + (ie-1)/5 * 25;
00524 
00525           if ( econn ) {
00526             ecid = LogicID::getEcalLogicID("EB_mem_channel", Numbers::iSM(ism, EcalBarrel), ic);
00527             dataset3[ecid] = c3;
00528           }
00529 
00530           status = status && !val;
00531 
00532         }
00533 
00534       }
00535     }
00536 
00537     float num08, num09;
00538 
00539     for ( int iet = 1; iet <= 2; iet++ ) {
00540 
00541       num08 = num09 = 0.;
00542 
00543       bool update1 = false;
00544 
00545       float numTot = -1.;
00546 
00547       if ( hmem_[ism-1] ) {
00548         numTot = 0.;
00549         for ( int ie = 1 + 5*(iet-1); ie <= 5*iet; ie++ ) {
00550           for ( int ip = 1 ; ip <= 5; ip++ ) {
00551             numTot += hmem_[ism-1]->GetBinContent(ie, ip);
00552           }
00553         }
00554       }
00555 
00556       if ( h08_[ism-1] ) {
00557         num08  = h08_[ism-1]->GetBinContent(iet, 1);
00558         if ( num08 > 0 ) update1 = true;
00559       }
00560 
00561       if ( h09_[ism-1] ) {
00562         num09  = h09_[ism-1]->GetBinContent(iet, 1);
00563         if ( num09 > 0 ) update1 = true;
00564       }
00565 
00566       if ( update0 || update1 ) {
00567 
00568         if ( iet == 1 ) {
00569 
00570           if ( verbose_ ) {
00571             std::cout << "Preparing dataset for " << Numbers::sEB(ism) << " (ism=" << ism << ")" << std::endl;
00572             std::cout << "(" << iet <<  ") " << num08 << " " << num09 << std::endl;
00573             std::cout << std::endl;
00574           }
00575 
00576         }
00577 
00578         c4.setProcessedEvents( int(numTot) );
00579         c4.setProblematicEvents( int(num08 + num09) );
00580         c4.setProblemsID( int(num08) );
00581         c4.setProblemsSize(int (num09) );
00582         // setProblemsLV1(int LV1);
00583         // setProblemsBunchX(int bunchX);
00584 
00585         bool val;
00586 
00587         val = false;
00588         if ( numTot > 0 ) {
00589           float errorRate2 = num00 / ( numTot/25. + num08 + num09 );
00590           if ( errorRate2 > threshCry_ )
00591             val = true;
00592           errorRate2 = ( num08 + num09 ) / ( numTot/25. + num08 + num09 ) / 2.;
00593           if ( errorRate2 > threshCry_ )
00594             val = true;
00595         } else {
00596           if ( num00 > 0 )
00597             val = true;
00598           if ( ( num08 + num09 ) > 0 )
00599             val = true;
00600         }
00601         c4.setTaskStatus(val);
00602 
00603         int itt = 68 + iet;
00604 
00605         if ( econn ) {
00606           ecid = LogicID::getEcalLogicID("EB_mem_TT", Numbers::iSM(ism, EcalBarrel), itt);
00607           dataset4[ecid] = c4;
00608         }
00609 
00610         status = status && !val;
00611 
00612       }
00613 
00614     }
00615 
00616   }
00617 
00618   if ( econn ) {
00619     try {
00620       if ( verbose_ ) std::cout << "Inserting MonConsistencyDat ..." << std::endl;
00621       if ( dataset1.size() != 0 ) econn->insertDataArraySet(&dataset1, moniov);
00622       if ( dataset2.size() != 0 ) econn->insertDataArraySet(&dataset2, moniov);
00623       if ( dataset3.size() != 0 ) econn->insertDataArraySet(&dataset3, moniov);
00624       if ( dataset4.size() != 0 ) econn->insertDataArraySet(&dataset4, moniov);
00625       if ( verbose_ ) std::cout << "done." << std::endl;
00626     } catch (std::runtime_error &e) {
00627       std::cerr << e.what() << std::endl;
00628     }
00629   }
00630 
00631   return true;
00632 
00633 }
00634 #endif
00635 
00636 void EBIntegrityClient::analyze(void) {
00637 
00638   ievt_++;
00639   jevt_++;
00640   if ( ievt_ % 10 == 0 ) {
00641     if ( debug_ ) std::cout << "EBIntegrityClient: ievt/jevt = " << ievt_ << "/" << jevt_ << std::endl;
00642   }
00643 
00644   uint32_t bits01 = 0;
00645   bits01 |= 1 << EcalDQMStatusHelper::CH_ID_ERROR;
00646   bits01 |= 1 << EcalDQMStatusHelper::CH_GAIN_ZERO_ERROR;
00647   bits01 |= 1 << EcalDQMStatusHelper::CH_GAIN_SWITCH_ERROR;
00648   bits01 |= 1 << EcalDQMStatusHelper::TT_ID_ERROR;
00649   bits01 |= 1 << EcalDQMStatusHelper::TT_SIZE_ERROR;
00650 
00651 
00652   MonitorElement* me;
00653 
00654   me = dqmStore_->get( prefixME_ + "/EBIntegrityTask/EBIT DCC size error" );
00655   h00_ = UtilsClient::getHisto( me, cloneME_, h00_ );
00656 
00657   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00658 
00659     int ism = superModules_[i];
00660 
00661     me = dqmStore_->get( prefixME_ + "/EBOccupancyTask/EBOT digi occupancy " + Numbers::sEB(ism) );
00662     h_[ism-1] = UtilsClient::getHisto( me, cloneME_, h_[ism-1] );
00663 
00664     me = dqmStore_->get( prefixME_ + "/EBOccupancyTask/EBOT MEM digi occupancy " + Numbers::sEB(ism) );
00665     hmem_[ism-1] = UtilsClient::getHisto( me, cloneME_, hmem_[ism-1] );
00666 
00667     me = dqmStore_->get( prefixME_ + "/EBIntegrityTask/Gain/EBIT gain " + Numbers::sEB(ism) );
00668     h01_[ism-1] = UtilsClient::getHisto( me, cloneME_, h01_[ism-1] );
00669 
00670     me = dqmStore_->get( prefixME_ + "/EBIntegrityTask/ChId/EBIT ChId " + Numbers::sEB(ism) );
00671     h02_[ism-1] = UtilsClient::getHisto( me, cloneME_, h02_[ism-1] );
00672 
00673     me = dqmStore_->get( prefixME_ + "/EBIntegrityTask/GainSwitch/EBIT gain switch " + Numbers::sEB(ism) );
00674     h03_[ism-1] = UtilsClient::getHisto( me, cloneME_, h03_[ism-1] );
00675 
00676     me = dqmStore_->get( prefixME_ + "/EBIntegrityTask/TTId/EBIT TTId " + Numbers::sEB(ism) );
00677     h04_[ism-1] = UtilsClient::getHisto( me, cloneME_, h04_[ism-1] );
00678 
00679     me = dqmStore_->get( prefixME_ + "/EBIntegrityTask/TTBlockSize/EBIT TTBlockSize " + Numbers::sEB(ism) );
00680     h05_[ism-1] = UtilsClient::getHisto( me, cloneME_, h05_[ism-1] );
00681 
00682     me = dqmStore_->get( prefixME_ + "/EBIntegrityTask/MemChId/EBIT MemChId " + Numbers::sEB(ism) );
00683     h06_[ism-1] = UtilsClient::getHisto( me, cloneME_, h06_[ism-1] );
00684 
00685     me = dqmStore_->get( prefixME_ + "/EBIntegrityTask/MemGain/EBIT MemGain " + Numbers::sEB(ism) );
00686     h07_[ism-1] = UtilsClient::getHisto( me, cloneME_, h07_[ism-1] );
00687 
00688     me = dqmStore_->get( prefixME_ + "/EBIntegrityTask/MemTTId/EBIT MemTTId " + Numbers::sEB(ism) );
00689     h08_[ism-1] = UtilsClient::getHisto( me, cloneME_, h08_[ism-1] );
00690 
00691     me = dqmStore_->get( prefixME_ + "/EBIntegrityTask/MemSize/EBIT MemSize " + Numbers::sEB(ism) );
00692     h09_[ism-1] = UtilsClient::getHisto( me, cloneME_, h09_[ism-1] );
00693 
00694     float num00;
00695 
00696     // integrity summary histograms
00697     if ( meg01_[ism-1] ) meg01_[ism-1]->Reset();
00698     if ( meg02_[ism-1] ) meg02_[ism-1]->Reset();
00699 
00700     num00 = 0.;
00701 
00702     bool update0 = false;
00703 
00704     // dcc size errors
00705     if ( h00_ ) {
00706       num00  = h00_->GetBinContent(ism);
00707       update0 = true;
00708     }
00709 
00710     float num01, num02, num03, num04, num05;
00711 
00712     for ( int ie = 1; ie <= 85; ie++ ) {
00713       for ( int ip = 1; ip <= 20; ip++ ) {
00714 
00715         num01 = num02 = num03 = num04 = num05 = 0.;
00716 
00717         if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ie, ip, 2. );
00718 
00719         bool update1 = false;
00720         bool update2 = false;
00721 
00722         float numTot = -1.;
00723 
00724         if ( h_[ism-1] ) numTot = h_[ism-1]->GetBinContent(ie, ip);
00725 
00726         if ( h01_[ism-1] ) {
00727           num01  = h01_[ism-1]->GetBinContent(ie, ip);
00728           update1 = true;
00729         }
00730 
00731         if ( h02_[ism-1] ) {
00732           num02  = h02_[ism-1]->GetBinContent(ie, ip);
00733           update1 = true;
00734         }
00735 
00736         if ( h03_[ism-1] ) {
00737           num03  = h03_[ism-1]->GetBinContent(ie, ip);
00738           update1 = true;
00739         }
00740 
00741         int iet = 1 + ((ie-1)/5);
00742         int ipt = 1 + ((ip-1)/5);
00743 
00744         if ( h04_[ism-1] ) {
00745           num04  = h04_[ism-1]->GetBinContent(iet, ipt);
00746           update2 = true;
00747         }
00748 
00749         if ( h05_[ism-1] ) {
00750           num05  = h05_[ism-1]->GetBinContent(iet, ipt);
00751           update2 = true;
00752         }
00753 
00754         if ( update0 || update1 || update2 ) {
00755 
00756           float val;
00757 
00758           val = 1.;
00759           // number of events on a channel
00760           if ( numTot > 0 ) {
00761             float errorRate1 =  num00 / ( numTot + num01 + num02 + num03 );
00762             if ( errorRate1 > threshCry_ )
00763               val = 0.;
00764             errorRate1 = ( num01 + num02 + num03 ) / ( numTot + num01 + num02 + num03 ) / 3.;
00765             if ( errorRate1 > threshCry_ )
00766               val = 0.;
00767             float errorRate2 = ( num04 + num05 ) / ( numTot/25. + num04 + num05 ) / 2.;
00768             if ( errorRate2 > threshCry_ )
00769               val = 0.;
00770           } else {
00771             val = 2.;
00772             if ( num00 > 0 )
00773               val = 0.;
00774             if ( ( num01 + num02 + num03 ) > 0 )
00775               val = 0.;
00776             if ( ( num04 + num05 ) > 0 )
00777               val = 0.;
00778           }
00779 
00780           // filling the summary for SM channels
00781           if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ie, ip, val );
00782 
00783         }
00784 
00785         if ( Masks::maskChannel(ism, ie, ip, bits01, EcalBarrel) ) UtilsClient::maskBinContent( meg01_[ism-1], ie, ip );
00786 
00787       }
00788     } // end of loop on crystals
00789 
00790     // summaries for mem channels
00791     float num06, num07, num08, num09;
00792 
00793     for ( int ie = 1; ie <= 10; ie++ ) {
00794       for ( int ip = 1; ip <= 5; ip++ ) {
00795 
00796         num06 = num07 = num08 = num09 = 0.;
00797 
00798         // initialize summary histo for mem
00799         if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ie, ip, 2. );
00800 
00801         bool update1 = false;
00802         bool update2 = false;
00803 
00804         float numTotmem = -1.;
00805 
00806         if ( hmem_[ism-1] ) numTotmem = hmem_[ism-1]->GetBinContent(ie, ip);
00807 
00808         if ( h06_[ism-1] ) {
00809           num06  = h06_[ism-1]->GetBinContent(ie, ip);
00810           update1 = true;
00811         }
00812 
00813         if ( h07_[ism-1] ) {
00814           num07  = h07_[ism-1]->GetBinContent(ie, ip);
00815           update1 = true;
00816         }
00817 
00818         int iet = 1 + ((ie-1)/5);
00819         int ipt = 1;
00820 
00821         if ( h08_[ism-1] ) {
00822           num08  = h08_[ism-1]->GetBinContent(iet, ipt);
00823           update2 = true;
00824         }
00825 
00826         if ( h09_[ism-1] ) {
00827           num09  = h09_[ism-1]->GetBinContent(iet, ipt);
00828           update2 = true;
00829         }
00830 
00831         if ( update0 || update1 || update2 ) {
00832 
00833           float val;
00834 
00835           val = 1.;
00836           // number of events on a channel
00837           if ( numTotmem > 0 ) {
00838             float errorRate1 = ( num06 + num07 ) / ( numTotmem + num06 + num07 ) / 2.;
00839             if ( errorRate1 > threshCry_ )
00840               val = 0.;
00841             float errorRate2 = ( num08 + num09 ) / ( numTotmem/25. + num08 + num09 ) / 2.;
00842             if ( errorRate2 > threshCry_ )
00843               val = 0.;
00844           } else {
00845             val = 2.;
00846             if ( ( num06 + num07 ) > 0 )
00847               val = 0.;
00848             if ( ( num08 + num09 ) > 0 )
00849               val = 0.;
00850           }
00851 
00852           // filling summary for mem channels
00853           if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ie, ip, val );
00854 
00855         }
00856 
00857         if ( Masks::maskPn(ism, ie, bits01, EcalBarrel) ) UtilsClient::maskBinContent( meg02_[ism-1], ie, ip );
00858 
00859       }
00860     }  // end loop on mem channels
00861 
00862   } // end loop on supermodules
00863 
00864 }
00865 
00866 const int EBIntegrityClient::chNum[5][5] = {
00867   { 1,  2,  3,  4,  5},
00868   {10,  9,  8,  7,  6},
00869   {11, 12, 13, 14, 15},
00870   {20, 19, 18, 17, 16},
00871   {21, 22, 23, 24, 25}
00872 };
00873