CMS 3D CMS Logo

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

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