CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/DQM/EcalBarrelMonitorClient/src/EBIntegrityClient.cc

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