CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/DQM/EcalEndcapMonitorClient/src/EEIntegrityClient.cc

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