CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DQM/EcalBarrelMonitorClient/src/EBPedestalClient.cc

Go to the documentation of this file.
00001 /*
00002  * \file EBPedestalClient.cc
00003  *
00004  * $Date: 2010/10/17 18:06:34 $
00005  * $Revision: 1.227 $
00006  * \author G. Della Ricca
00007  * \author F. Cossutti
00008  *
00009 */
00010 
00011 #include <memory>
00012 #include <iostream>
00013 #include <fstream>
00014 #include <iomanip>
00015 #include <math.h>
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/MonPedestalsDat.h"
00023 #include "OnlineDB/EcalCondDB/interface/MonPNPedDat.h"
00024 #include "OnlineDB/EcalCondDB/interface/RunCrystalErrorsDat.h"
00025 #include "OnlineDB/EcalCondDB/interface/RunTTErrorsDat.h"
00026 #include "OnlineDB/EcalCondDB/interface/RunPNErrorsDat.h"
00027 #include "OnlineDB/EcalCondDB/interface/EcalCondDBInterface.h"
00028 #include "DQM/EcalCommon/interface/LogicID.h"
00029 #endif
00030 
00031 #include "DQM/EcalCommon/interface/Masks.h"
00032 
00033 #include "DQM/EcalCommon/interface/UtilsClient.h"
00034 #include "DQM/EcalCommon/interface/Numbers.h"
00035 
00036 #include "DQM/EcalBarrelMonitorClient/interface/EBPedestalClient.h"
00037 
00038 // #define COMMON_NOISE_ANALYSIS
00039 
00040 EBPedestalClient::EBPedestalClient(const edm::ParameterSet& ps) {
00041 
00042   // cloneME switch
00043   cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00044 
00045   // verbose switch
00046   verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
00047 
00048   // debug switch
00049   debug_ = ps.getUntrackedParameter<bool>("debug", false);
00050 
00051   // prefixME path
00052   prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00053 
00054   // enableCleanup_ switch
00055   enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00056 
00057   // vector of selected Super Modules (Defaults to all 36).
00058   superModules_.reserve(36);
00059   for ( unsigned int i = 1; i <= 36; i++ ) superModules_.push_back(i);
00060   superModules_ = ps.getUntrackedParameter<std::vector<int> >("superModules", superModules_);
00061 
00062   MGPAGains_.reserve(3);
00063   for ( unsigned int i = 1; i <= 3; i++ ) MGPAGains_.push_back(i);
00064   MGPAGains_ = ps.getUntrackedParameter<std::vector<int> >("MGPAGains", MGPAGains_);
00065 
00066   MGPAGainsPN_.reserve(2);
00067   for ( unsigned int i = 1; i <= 3; i++ ) MGPAGainsPN_.push_back(i);
00068   MGPAGainsPN_ = ps.getUntrackedParameter<std::vector<int> >("MGPAGainsPN", MGPAGainsPN_);
00069 
00070   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00071 
00072     int ism = superModules_[i];
00073 
00074     h01_[ism-1] = 0;
00075     h02_[ism-1] = 0;
00076     h03_[ism-1] = 0;
00077 
00078     j01_[ism-1] = 0;
00079     j02_[ism-1] = 0;
00080     j03_[ism-1] = 0;
00081 
00082     k01_[ism-1] = 0;
00083     k02_[ism-1] = 0;
00084     k03_[ism-1] = 0;
00085 
00086     i01_[ism-1] = 0;
00087     i02_[ism-1] = 0;
00088 
00089   }
00090 
00091   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00092 
00093     int ism = superModules_[i];
00094 
00095     meg01_[ism-1] = 0;
00096     meg02_[ism-1] = 0;
00097     meg03_[ism-1] = 0;
00098 
00099     meg04_[ism-1] = 0;
00100     meg05_[ism-1] = 0;
00101 
00102     mep01_[ism-1] = 0;
00103     mep02_[ism-1] = 0;
00104     mep03_[ism-1] = 0;
00105 
00106     mer01_[ism-1] = 0;
00107     mer02_[ism-1] = 0;
00108     mer03_[ism-1] = 0;
00109 
00110     mer04_[ism-1] = 0;
00111     mer05_[ism-1] = 0;
00112 
00113 #ifdef COMMON_NOISE_ANALYSIS
00114     mes01_[ism-1] = 0;
00115     mes02_[ism-1] = 0;
00116     mes03_[ism-1] = 0;
00117 
00118     met01_[ism-1] = 0;
00119     met02_[ism-1] = 0;
00120     met03_[ism-1] = 0;
00121 #endif
00122 
00123   }
00124 
00125   expectedMean_[0] = 200.0;
00126   expectedMean_[1] = 200.0;
00127   expectedMean_[2] = 200.0;
00128 
00129   discrepancyMean_[0] = 25.0;
00130   discrepancyMean_[1] = 25.0;
00131   discrepancyMean_[2] = 25.0;
00132 
00133   RMSThreshold_[0] = 1.0;
00134   RMSThreshold_[1] = 1.2;
00135   RMSThreshold_[2] = 2.0;
00136 
00137   expectedMeanPn_[0] = 750.0;
00138   expectedMeanPn_[1] = 750.0;
00139 
00140   discrepancyMeanPn_[0] = 100.0;
00141   discrepancyMeanPn_[1] = 100.0;
00142 
00143   RMSThresholdPn_[0] = 999.;
00144   RMSThresholdPn_[1] = 999.;
00145 
00146 }
00147 
00148 EBPedestalClient::~EBPedestalClient() {
00149 
00150 }
00151 
00152 void EBPedestalClient::beginJob(void) {
00153 
00154   dqmStore_ = edm::Service<DQMStore>().operator->();
00155 
00156   if ( debug_ ) std::cout << "EBPedestalClient: beginJob" << std::endl;
00157 
00158   ievt_ = 0;
00159   jevt_ = 0;
00160 
00161 }
00162 
00163 void EBPedestalClient::beginRun(void) {
00164 
00165   if ( debug_ ) std::cout << "EBPedestalClient: beginRun" << std::endl;
00166 
00167   jevt_ = 0;
00168 
00169   this->setup();
00170 
00171 }
00172 
00173 void EBPedestalClient::endJob(void) {
00174 
00175   if ( debug_ ) std::cout << "EBPedestalClient: endJob, ievt = " << ievt_ << std::endl;
00176 
00177   this->cleanup();
00178 
00179 }
00180 
00181 void EBPedestalClient::endRun(void) {
00182 
00183   if ( debug_ ) std::cout << "EBPedestalClient: endRun, jevt = " << jevt_ << std::endl;
00184 
00185   this->cleanup();
00186 
00187 }
00188 
00189 void EBPedestalClient::setup(void) {
00190 
00191   char histo[200];
00192 
00193   dqmStore_->setCurrentFolder( prefixME_ + "/EBPedestalClient" );
00194 
00195   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00196 
00197     int ism = superModules_[i];
00198 
00199     if (find(MGPAGains_.begin(), MGPAGains_.end(), 1) != MGPAGains_.end() ) {
00200       if ( meg01_[ism-1] ) dqmStore_->removeElement( meg01_[ism-1]->getName() );
00201       sprintf(histo, "EBPT pedestal quality G01 %s", Numbers::sEB(ism).c_str());
00202       meg01_[ism-1] = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00203       meg01_[ism-1]->setAxisTitle("ieta", 1);
00204       meg01_[ism-1]->setAxisTitle("iphi", 2);
00205     }
00206     if (find(MGPAGains_.begin(), MGPAGains_.end(), 6) != MGPAGains_.end() ) {
00207       if ( meg02_[ism-1] ) dqmStore_->removeElement( meg02_[ism-1]->getName() );
00208       sprintf(histo, "EBPT pedestal quality G06 %s", Numbers::sEB(ism).c_str());
00209       meg02_[ism-1] = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00210       meg02_[ism-1]->setAxisTitle("ieta", 1);
00211       meg02_[ism-1]->setAxisTitle("iphi", 2);
00212     }
00213     if (find(MGPAGains_.begin(), MGPAGains_.end(), 12) != MGPAGains_.end() ) {
00214       if ( meg03_[ism-1] ) dqmStore_->removeElement( meg03_[ism-1]->getName() );
00215       sprintf(histo, "EBPT pedestal quality G12 %s", Numbers::sEB(ism).c_str());
00216       meg03_[ism-1] = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00217       meg03_[ism-1]->setAxisTitle("ieta", 1);
00218       meg03_[ism-1]->setAxisTitle("iphi", 2);
00219     }
00220 
00221     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 1) != MGPAGainsPN_.end() ) {
00222       if ( meg04_[ism-1] ) dqmStore_->removeElement( meg04_[ism-1]->getName() );
00223       sprintf(histo, "EBPT pedestal quality PNs G01 %s", Numbers::sEB(ism).c_str());
00224       meg04_[ism-1] = dqmStore_->book2D(histo, histo, 10, 0., 10., 1, 0., 5.);
00225       meg04_[ism-1]->setAxisTitle("pseudo-strip", 1);
00226       meg04_[ism-1]->setAxisTitle("channel", 2);
00227     }
00228     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 16) != MGPAGainsPN_.end() ) {
00229       if ( meg05_[ism-1] ) dqmStore_->removeElement( meg05_[ism-1]->getName() );
00230       sprintf(histo, "EBPT pedestal quality PNs G16 %s", Numbers::sEB(ism).c_str());
00231       meg05_[ism-1] = dqmStore_->book2D(histo, histo, 10, 0., 10., 1, 0., 5.);
00232       meg05_[ism-1]->setAxisTitle("pseudo-strip", 1);
00233       meg05_[ism-1]->setAxisTitle("channel", 2);
00234     }
00235 
00236     if (find(MGPAGains_.begin(), MGPAGains_.end(), 1) != MGPAGains_.end() ) {
00237       if ( mep01_[ism-1] ) dqmStore_->removeElement( mep01_[ism-1]->getName() );
00238       sprintf(histo, "EBPT pedestal mean G01 %s", Numbers::sEB(ism).c_str());
00239       mep01_[ism-1] = dqmStore_->book1D(histo, histo, 100, 150., 250.);
00240       mep01_[ism-1]->setAxisTitle("mean", 1);
00241     }
00242     if (find(MGPAGains_.begin(), MGPAGains_.end(), 6) != MGPAGains_.end() ) {
00243       if ( mep02_[ism-1] ) dqmStore_->removeElement( mep02_[ism-1]->getName() );
00244       sprintf(histo, "EBPT pedestal mean G06 %s", Numbers::sEB(ism).c_str());
00245       mep02_[ism-1] = dqmStore_->book1D(histo, histo, 100, 150., 250.);
00246       mep02_[ism-1]->setAxisTitle("mean", 1);
00247     }
00248     if (find(MGPAGains_.begin(), MGPAGains_.end(), 12) != MGPAGains_.end() ) {
00249       if ( mep03_[ism-1] ) dqmStore_->removeElement( mep03_[ism-1]->getName() );
00250       sprintf(histo, "EBPT pedestal mean G12 %s", Numbers::sEB(ism).c_str());
00251       mep03_[ism-1] = dqmStore_->book1D(histo, histo, 100, 150., 250.);
00252       mep03_[ism-1]->setAxisTitle("mean", 1);
00253     }
00254 
00255     if (find(MGPAGains_.begin(), MGPAGains_.end(), 1) != MGPAGains_.end() ) {
00256       if ( mer01_[ism-1] ) dqmStore_->removeElement( mer01_[ism-1]->getName() );
00257       sprintf(histo, "EBPT pedestal rms G01 %s", Numbers::sEB(ism).c_str());
00258       mer01_[ism-1] = dqmStore_->book1D(histo, histo, 100, 0., 10.);
00259       mer01_[ism-1]->setAxisTitle("rms", 1);
00260     }
00261     if (find(MGPAGains_.begin(), MGPAGains_.end(), 6) != MGPAGains_.end() ) {
00262       if ( mer02_[ism-1] ) dqmStore_->removeElement( mer02_[ism-1]->getName() );
00263       sprintf(histo, "EBPT pedestal rms G06 %s", Numbers::sEB(ism).c_str());
00264       mer02_[ism-1] = dqmStore_->book1D(histo, histo, 100, 0., 10.);
00265       mer02_[ism-1]->setAxisTitle("rms", 1);
00266     }
00267     if (find(MGPAGains_.begin(), MGPAGains_.end(), 12) != MGPAGains_.end() ) {
00268       if ( mer03_[ism-1] ) dqmStore_->removeElement( mer03_[ism-1]->getName() );
00269       sprintf(histo, "EBPT pedestal rms G12 %s", Numbers::sEB(ism).c_str());
00270       mer03_[ism-1] = dqmStore_->book1D(histo, histo, 100, 0., 10.);
00271       mer03_[ism-1]->setAxisTitle("rms", 1);
00272     }
00273 
00274     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 1) != MGPAGainsPN_.end() ) {
00275       if ( mer04_[ism-1] ) dqmStore_->removeElement( mer04_[ism-1]->getName() );
00276       sprintf(histo, "EBPDT PNs pedestal rms %s G01", Numbers::sEB(ism).c_str());
00277       mer04_[ism-1] = dqmStore_->book1D(histo, histo, 100, 0., 10.);
00278       mer04_[ism-1]->setAxisTitle("rms", 1);
00279     }
00280     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 16) != MGPAGainsPN_.end() ) {
00281       if ( mer05_[ism-1] ) dqmStore_->removeElement( mer05_[ism-1]->getName() );
00282       sprintf(histo, "EBPDT PNs pedestal rms %s G16", Numbers::sEB(ism).c_str());
00283       mer05_[ism-1] = dqmStore_->book1D(histo, histo, 100, 0., 10.);
00284       mer05_[ism-1]->setAxisTitle("rms", 1);
00285     }
00286 
00287 #ifdef COMMON_NOISE_ANALYSIS
00288     if (find(MGPAGains_.begin(), MGPAGains_.end(), 1) != MGPAGains_.end() ) {
00289       if ( mes01_[ism-1] ) dqmStore_->removeElement( mes01_[ism-1]->getName() );
00290       sprintf(histo, "EBPT pedestal 3sum G01 %s", Numbers::sEB(ism).c_str());
00291       mes01_[ism-1] = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00292       mes01_[ism-1]->setAxisTitle("ieta", 1);
00293       mes01_[ism-1]->setAxisTitle("iphi", 2);
00294     }
00295     if (find(MGPAGains_.begin(), MGPAGains_.end(), 6) != MGPAGains_.end() ) {
00296       if ( mes02_[ism-1] ) dqmStore_->removeElement( mes02_[ism-1]->getName() );
00297       sprintf(histo, "EBPT pedestal 3sum G06 %s", Numbers::sEB(ism).c_str());
00298       mes02_[ism-1] = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00299       mes02_[ism-1]->setAxisTitle("ieta", 1);
00300       mes02_[ism-1]->setAxisTitle("iphi", 2);
00301     }
00302     if (find(MGPAGains_.begin(), MGPAGains_.end(), 12) != MGPAGains_.end() ) {
00303       if ( mes03_[ism-1] ) dqmStore_->removeElement( mes03_[ism-1]->getName() );
00304       sprintf(histo, "EBPT pedestal 3sum G12 %s", Numbers::sEB(ism).c_str());
00305       mes03_[ism-1] = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00306       mes03_[ism-1]->setAxisTitle("ieta", 1);
00307       mes03_[ism-1]->setAxisTitle("iphi", 2);
00308     }
00309 
00310     if (find(MGPAGains_.begin(), MGPAGains_.end(), 1) != MGPAGains_.end() ) {
00311       if ( met01_[ism-1] ) dqmStore_->removeElement( met01_[ism-1]->getName() );
00312       sprintf(histo, "EBPT pedestal 5sum G01 %s", Numbers::sEB(ism).c_str());
00313       met01_[ism-1] = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00314       met01_[ism-1]->setAxisTitle("ieta", 1);
00315       met01_[ism-1]->setAxisTitle("iphi", 2);
00316     }
00317     if (find(MGPAGains_.begin(), MGPAGains_.end(), 6) != MGPAGains_.end() ) {
00318       if ( met02_[ism-1] ) dqmStore_->removeElement( met02_[ism-1]->getName() );
00319       sprintf(histo, "EBPT pedestal 5sum G06 %s", Numbers::sEB(ism).c_str());
00320       met02_[ism-1] = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00321       met02_[ism-1]->setAxisTitle("ieta", 1);
00322       met02_[ism-1]->setAxisTitle("iphi", 2);
00323     }
00324     if (find(MGPAGains_.begin(), MGPAGains_.end(), 12) != MGPAGains_.end() ) {
00325       if ( met03_[ism-1] ) dqmStore_->removeElement( met03_[ism-1]->getName() );
00326       sprintf(histo, "EBPT pedestal 5sum G12 %s", Numbers::sEB(ism).c_str());
00327       met03_[ism-1] = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00328       met03_[ism-1]->setAxisTitle("ieta", 1);
00329       met03_[ism-1]->setAxisTitle("iphi", 2);
00330     }
00331 #endif
00332 
00333   }
00334 
00335   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00336 
00337     int ism = superModules_[i];
00338 
00339     if ( meg01_[ism-1] ) meg01_[ism-1]->Reset();
00340     if ( meg02_[ism-1] ) meg02_[ism-1]->Reset();
00341     if ( meg03_[ism-1] ) meg03_[ism-1]->Reset();
00342 
00343     if ( meg04_[ism-1] ) meg04_[ism-1]->Reset();
00344     if ( meg05_[ism-1] ) meg05_[ism-1]->Reset();
00345 
00346     for ( int ie = 1; ie <= 85; ie++ ) {
00347       for ( int ip = 1; ip <= 20; ip++ ) {
00348 
00349         if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ie, ip, 2. );
00350         if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ie, ip, 2. );
00351         if ( meg03_[ism-1] ) meg03_[ism-1]->setBinContent( ie, ip, 2. );
00352 
00353       }
00354     }
00355 
00356     for ( int i = 1; i <= 10; i++ ) {
00357 
00358       if ( meg04_[ism-1] ) meg04_[ism-1]->setBinContent( i, 1, 2. );
00359       if ( meg05_[ism-1] ) meg05_[ism-1]->setBinContent( i, 1, 2. );
00360 
00361     }
00362 
00363     if ( mep01_[ism-1] ) mep01_[ism-1]->Reset();
00364     if ( mep02_[ism-1] ) mep02_[ism-1]->Reset();
00365     if ( mep03_[ism-1] ) mep03_[ism-1]->Reset();
00366 
00367     if ( mer01_[ism-1] ) mer01_[ism-1]->Reset();
00368     if ( mer02_[ism-1] ) mer02_[ism-1]->Reset();
00369     if ( mer03_[ism-1] ) mer03_[ism-1]->Reset();
00370 
00371     if ( mer04_[ism-1] ) mer04_[ism-1]->Reset();
00372     if ( mer05_[ism-1] ) mer05_[ism-1]->Reset();
00373 
00374 #ifdef COMMON_NOISE_ANALYSIS
00375     if ( mes01_[ism-1] ) mes01_[ism-1]->Reset();
00376     if ( mes02_[ism-1] ) mes02_[ism-1]->Reset();
00377     if ( mes03_[ism-1] ) mes03_[ism-1]->Reset();
00378 
00379     if ( met01_[ism-1] ) met01_[ism-1]->Reset();
00380     if ( met02_[ism-1] ) met02_[ism-1]->Reset();
00381     if ( met03_[ism-1] ) met03_[ism-1]->Reset();
00382 
00383     for ( int ie = 1; ie <= 85; ie++ ) {
00384       for ( int ip = 1; ip <= 20; ip++ ) {
00385 
00386         if ( mes01_[ism-1] ) mes01_[ism-1]->setBinContent( ie, ip, -999. );
00387         if ( mes02_[ism-1] ) mes02_[ism-1]->setBinContent( ie, ip, -999. );
00388         if ( mes03_[ism-1] ) mes03_[ism-1]->setBinContent( ie, ip, -999. );
00389 
00390         if ( met01_[ism-1] ) met01_[ism-1]->setBinContent( ie, ip, -999. );
00391         if ( met02_[ism-1] ) met02_[ism-1]->setBinContent( ie, ip, -999. );
00392         if ( met03_[ism-1] ) met03_[ism-1]->setBinContent( ie, ip, -999. );
00393 
00394       }
00395     }
00396 #endif
00397 
00398   }
00399 
00400 }
00401 
00402 void EBPedestalClient::cleanup(void) {
00403 
00404   if ( ! enableCleanup_ ) return;
00405 
00406   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00407 
00408     int ism = superModules_[i];
00409 
00410     if ( cloneME_ ) {
00411       if ( h01_[ism-1] ) delete h01_[ism-1];
00412       if ( h02_[ism-1] ) delete h02_[ism-1];
00413       if ( h03_[ism-1] ) delete h03_[ism-1];
00414 
00415       if ( j01_[ism-1] ) delete j01_[ism-1];
00416       if ( j02_[ism-1] ) delete j02_[ism-1];
00417       if ( j03_[ism-1] ) delete j03_[ism-1];
00418 
00419       if ( k01_[ism-1] ) delete k01_[ism-1];
00420       if ( k02_[ism-1] ) delete k02_[ism-1];
00421       if ( k03_[ism-1] ) delete k03_[ism-1];
00422 
00423       if ( i01_[ism-1] ) delete i01_[ism-1];
00424       if ( i02_[ism-1] ) delete i02_[ism-1];
00425     }
00426 
00427     h01_[ism-1] = 0;
00428     h02_[ism-1] = 0;
00429     h03_[ism-1] = 0;
00430 
00431     j01_[ism-1] = 0;
00432     j02_[ism-1] = 0;
00433     j03_[ism-1] = 0;
00434 
00435     k01_[ism-1] = 0;
00436     k02_[ism-1] = 0;
00437     k03_[ism-1] = 0;
00438 
00439     i01_[ism-1] = 0;
00440     i02_[ism-1] = 0;
00441 
00442   }
00443 
00444   dqmStore_->setCurrentFolder( prefixME_ + "/EBPedestalClient" );
00445 
00446   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00447 
00448     int ism = superModules_[i];
00449 
00450     if ( meg01_[ism-1] ) dqmStore_->removeElement( meg01_[ism-1]->getName() );
00451     meg01_[ism-1] = 0;
00452     if ( meg02_[ism-1] ) dqmStore_->removeElement( meg02_[ism-1]->getName() );
00453     meg02_[ism-1] = 0;
00454     if ( meg03_[ism-1] ) dqmStore_->removeElement( meg03_[ism-1]->getName() );
00455     meg03_[ism-1] = 0;
00456 
00457     if ( meg04_[ism-1] ) dqmStore_->removeElement( meg04_[ism-1]->getName() );
00458     meg04_[ism-1] = 0;
00459     if ( meg05_[ism-1] ) dqmStore_->removeElement( meg05_[ism-1]->getName() );
00460     meg05_[ism-1] = 0;
00461 
00462     if ( mep01_[ism-1] ) dqmStore_->removeElement( mep01_[ism-1]->getName() );
00463     mep01_[ism-1] = 0;
00464     if ( mep02_[ism-1] ) dqmStore_->removeElement( mep02_[ism-1]->getName() );
00465     mep02_[ism-1] = 0;
00466     if ( mep03_[ism-1] ) dqmStore_->removeElement( mep03_[ism-1]->getName() );
00467     mep03_[ism-1] = 0;
00468 
00469     if ( mer01_[ism-1] ) dqmStore_->removeElement( mer01_[ism-1]->getName() );
00470     mer01_[ism-1] = 0;
00471     if ( mer02_[ism-1] ) dqmStore_->removeElement( mer02_[ism-1]->getName() );
00472     mer02_[ism-1] = 0;
00473     if ( mer03_[ism-1] ) dqmStore_->removeElement( mer03_[ism-1]->getName() );
00474     mer03_[ism-1] = 0;
00475 
00476     if ( mer04_[ism-1] ) dqmStore_->removeElement( mer04_[ism-1]->getName() );
00477     mer04_[ism-1] = 0;
00478     if ( mer05_[ism-1] ) dqmStore_->removeElement( mer05_[ism-1]->getName() );
00479     mer05_[ism-1] = 0;
00480 
00481 #ifdef COMMON_NOISE_ANALYSIS
00482     if ( mes01_[ism-1] ) dqmStore_->removeElement( mes01_[ism-1]->getName() );
00483     mes01_[ism-1] = 0;
00484     if ( mes02_[ism-1] ) dqmStore_->removeElement( mes02_[ism-1]->getName() );
00485     mes02_[ism-1] = 0;
00486     if ( mes03_[ism-1] ) dqmStore_->removeElement( mes03_[ism-1]->getName() );
00487     mes03_[ism-1] = 0;
00488 
00489     if ( met01_[ism-1] ) dqmStore_->removeElement( met01_[ism-1]->getName() );
00490     met01_[ism-1] = 0;
00491     if ( met02_[ism-1] ) dqmStore_->removeElement( met02_[ism-1]->getName() );
00492     met02_[ism-1] = 0;
00493     if ( met03_[ism-1] ) dqmStore_->removeElement( met03_[ism-1]->getName() );
00494     met03_[ism-1] = 0;
00495 #endif
00496 
00497   }
00498 
00499 }
00500 
00501 #ifdef WITH_ECAL_COND_DB
00502 bool EBPedestalClient::writeDb(EcalCondDBInterface* econn, RunIOV* runiov, MonRunIOV* moniov, bool& status) {
00503 
00504   status = true;
00505 
00506   EcalLogicID ecid;
00507 
00508   MonPedestalsDat p;
00509   std::map<EcalLogicID, MonPedestalsDat> dataset1;
00510 
00511   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00512 
00513     int ism = superModules_[i];
00514 
00515     if ( verbose_ ) {
00516       std::cout << " " << Numbers::sEB(ism) << " (ism=" << ism << ")" << std::endl;
00517       std::cout << std::endl;
00518       if (find(MGPAGains_.begin(), MGPAGains_.end(), 1) != MGPAGains_.end() ) {
00519         UtilsClient::printBadChannels(meg01_[ism-1], h01_[ism-1]);
00520       }
00521       if (find(MGPAGains_.begin(), MGPAGains_.end(), 6) != MGPAGains_.end() ) {
00522         UtilsClient::printBadChannels(meg02_[ism-1], h02_[ism-1]);
00523       }
00524       if (find(MGPAGains_.begin(), MGPAGains_.end(), 12) != MGPAGains_.end() ) {
00525         UtilsClient::printBadChannels(meg03_[ism-1], h03_[ism-1]);
00526       }
00527     }
00528 
00529     for ( int ie = 1; ie <= 85; ie++ ) {
00530       for ( int ip = 1; ip <= 20; ip++ ) {
00531 
00532         bool update01;
00533         bool update02;
00534         bool update03;
00535 
00536         float num01, num02, num03;
00537         float mean01, mean02, mean03;
00538         float rms01, rms02, rms03;
00539 
00540         update01 = UtilsClient::getBinStatistics(h01_[ism-1], ie, ip, num01, mean01, rms01);
00541         update02 = UtilsClient::getBinStatistics(h02_[ism-1], ie, ip, num02, mean02, rms02);
00542         update03 = UtilsClient::getBinStatistics(h03_[ism-1], ie, ip, num03, mean03, rms03);
00543 
00544         if ( update01 || update02 || update03 ) {
00545 
00546           if ( Numbers::icEB(ism, ie, ip) == 1 ) {
00547 
00548             if ( verbose_ ) {
00549               std::cout << "Preparing dataset for " << Numbers::sEB(ism) << " (ism=" << ism << ")" << std::endl;
00550               std::cout << "G01 (" << ie << "," << ip << ") " << num01  << " " << mean01 << " " << rms01  << std::endl;
00551               std::cout << "G06 (" << ie << "," << ip << ") " << num02  << " " << mean02 << " " << rms02  << std::endl;
00552               std::cout << "G12 (" << ie << "," << ip << ") " << num03  << " " << mean03 << " " << rms03  << std::endl;
00553               std::cout << std::endl;
00554             }
00555 
00556           }
00557 
00558           p.setPedMeanG1(mean01);
00559           p.setPedRMSG1(rms01);
00560 
00561           p.setPedMeanG6(mean02);
00562           p.setPedRMSG6(rms02);
00563 
00564           p.setPedMeanG12(mean03);
00565           p.setPedRMSG12(rms03);
00566 
00567           if ( UtilsClient::getBinStatus(meg01_[ism-1], ie, ip) &&
00568                UtilsClient::getBinStatus(meg02_[ism-1], ie, ip) &&
00569                UtilsClient::getBinStatus(meg03_[ism-1], ie, ip) ) {
00570             p.setTaskStatus(true);
00571           } else {
00572             p.setTaskStatus(false);
00573           }
00574 
00575           status = status && UtilsClient::getBinQuality(meg01_[ism-1], ie, ip) &&
00576             UtilsClient::getBinQuality(meg02_[ism-1], ie, ip) &&
00577             UtilsClient::getBinQuality(meg03_[ism-1], ie, ip);
00578 
00579           int ic = Numbers::indexEB(ism, ie, ip);
00580 
00581           if ( econn ) {
00582             ecid = LogicID::getEcalLogicID("EB_crystal_number", Numbers::iSM(ism, EcalBarrel), ic);
00583             dataset1[ecid] = p;
00584           }
00585 
00586         }
00587 
00588       }
00589     }
00590 
00591   }
00592 
00593   if ( econn ) {
00594     try {
00595       if ( verbose_ ) std::cout << "Inserting MonPedestalsDat ..." << std::endl;
00596       if ( dataset1.size() != 0 ) econn->insertDataArraySet(&dataset1, moniov);
00597       if ( verbose_ ) std::cout << "done." << std::endl;
00598     } catch (std::runtime_error &e) {
00599       std::cerr << e.what() << std::endl;
00600     }
00601   }
00602 
00603   if ( verbose_ ) std::cout << std::endl;
00604 
00605   MonPNPedDat pn;
00606   std::map<EcalLogicID, MonPNPedDat> dataset2;
00607 
00608   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00609 
00610     int ism = superModules_[i];
00611 
00612     if ( verbose_ ) {
00613       std::cout << " " << Numbers::sEB(ism) << " (ism=" << ism << ")" << std::endl;
00614       std::cout << std::endl;
00615       if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 1) != MGPAGainsPN_.end() ) {
00616         UtilsClient::printBadChannels(meg04_[ism-1], i01_[ism-1]);
00617       }
00618       if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 16) != MGPAGainsPN_.end() ) {
00619         UtilsClient::printBadChannels(meg05_[ism-1], i02_[ism-1]);
00620       }
00621     }
00622 
00623     for ( int i = 1; i <= 10; i++ ) {
00624 
00625       bool update01;
00626       bool update02;
00627 
00628       float num01, num02;
00629       float mean01, mean02;
00630       float rms01, rms02;
00631 
00632       update01 = UtilsClient::getBinStatistics(i01_[ism-1], i, 0, num01, mean01, rms01);
00633       update02 = UtilsClient::getBinStatistics(i02_[ism-1], i, 0, num02, mean02, rms02);
00634 
00635       if ( update01 || update02 ) {
00636 
00637         if ( i == 1 ) {
00638 
00639           if ( verbose_ ) {
00640             std::cout << "Preparing dataset for " << Numbers::sEB(ism) << " (ism=" << ism << ")" << std::endl;
00641             std::cout << "PNs (" << i << ") G01 " << num01  << " " << mean01 << " " << rms01  << std::endl;
00642             std::cout << "PNs (" << i << ") G16 " << num01  << " " << mean01 << " " << rms01  << std::endl;
00643             std::cout << std::endl;
00644           }
00645 
00646         }
00647 
00648         pn.setPedMeanG1(mean01);
00649         pn.setPedRMSG1(rms01);
00650 
00651         pn.setPedMeanG16(mean02);
00652         pn.setPedRMSG16(rms02);
00653 
00654         if ( UtilsClient::getBinStatus(meg04_[ism-1], i, 1) &&
00655              UtilsClient::getBinStatus(meg05_[ism-1], i, 1) ) {
00656           pn.setTaskStatus(true);
00657         } else {
00658           pn.setTaskStatus(false);
00659         }
00660 
00661         status = status && UtilsClient::getBinQuality(meg04_[ism-1], i, 1) &&
00662           UtilsClient::getBinQuality(meg05_[ism-1], i, 1);
00663 
00664         if ( econn ) {
00665           ecid = LogicID::getEcalLogicID("EB_LM_PN", Numbers::iSM(ism, EcalBarrel), i-1);
00666           dataset2[ecid] = pn;
00667         }
00668 
00669       }
00670 
00671     }
00672 
00673   }
00674 
00675   if ( econn ) {
00676     try {
00677       if ( verbose_ ) std::cout << "Inserting MonPNPedDat ..." << std::endl;
00678       if ( dataset2.size() != 0 ) econn->insertDataArraySet(&dataset2, 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 EBPedestalClient::analyze(void) {
00691 
00692   ievt_++;
00693   jevt_++;
00694   if ( ievt_ % 10 == 0 ) {
00695     if ( debug_ ) std::cout << "EBPedestalClient: ievt/jevt = " << ievt_ << "/" << jevt_ << std::endl;
00696   }
00697 
00698   uint32_t bits01 = 0;
00699   bits01 |= 1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR;
00700   bits01 |= 1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_RMS_ERROR;
00701 
00702   uint32_t bits02 = 0;
00703   bits02 |= 1 << EcalDQMStatusHelper::PEDESTAL_MIDDLE_GAIN_MEAN_ERROR;
00704   bits02 |= 1 << EcalDQMStatusHelper::PEDESTAL_MIDDLE_GAIN_RMS_ERROR;
00705 
00706   uint32_t bits03 = 0;
00707   bits03 |= 1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR;
00708   bits03 |= 1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_RMS_ERROR;
00709 
00710   char histo[200];
00711 
00712   MonitorElement* me;
00713 
00714   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00715 
00716     int ism = superModules_[i];
00717 
00718     if (find(MGPAGains_.begin(), MGPAGains_.end(), 1) != MGPAGains_.end() ) {
00719 
00720       sprintf(histo, (prefixME_ + "/EBPedestalTask/Gain01/EBPT pedestal %s G01").c_str(), Numbers::sEB(ism).c_str());
00721       me = dqmStore_->get(histo);
00722       h01_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, h01_[ism-1] );
00723 
00724     }
00725 
00726     if (find(MGPAGains_.begin(), MGPAGains_.end(), 6) != MGPAGains_.end() ) {
00727 
00728       sprintf(histo, (prefixME_ + "/EBPedestalTask/Gain06/EBPT pedestal %s G06").c_str(), Numbers::sEB(ism).c_str());
00729       me = dqmStore_->get(histo);
00730       h02_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, h02_[ism-1] );
00731 
00732     }
00733 
00734     if (find(MGPAGains_.begin(), MGPAGains_.end(), 12) != MGPAGains_.end() ) {
00735 
00736       sprintf(histo, (prefixME_ + "/EBPedestalTask/Gain12/EBPT pedestal %s G12").c_str(), Numbers::sEB(ism).c_str());
00737       me = dqmStore_->get(histo);
00738       h03_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, h03_[ism-1] );
00739 
00740     }
00741 
00742 #ifdef COMMON_NOISE_ANALYSIS
00743     if (find(MGPAGains_.begin(), MGPAGains_.end(), 1) != MGPAGains_.end() ) {
00744 
00745       sprintf(histo, (prefixME_ + "/EBPedestalTask/Gain01/EBPT pedestal 3sum %s G01").c_str(), Numbers::sEB(ism).c_str());
00746       me = dqmStore_->get(histo);
00747       j01_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, j01_[ism-1] );
00748 
00749     }
00750 
00751     if (find(MGPAGains_.begin(), MGPAGains_.end(), 6) != MGPAGains_.end() ) {
00752 
00753       sprintf(histo, (prefixME_ + "/EBPedestalTask/Gain06/EBPT pedestal 3sum %s G06").c_str(), Numbers::sEB(ism).c_str());
00754       me = dqmStore_->get(histo);
00755       j02_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, j02_[ism-1] );
00756 
00757     }
00758 
00759     if (find(MGPAGains_.begin(), MGPAGains_.end(), 12) != MGPAGains_.end() ) {
00760 
00761       sprintf(histo, (prefixME_ + "/EBPedestalTask/Gain12/EBPT pedestal 3sum %s G12").c_str(), Numbers::sEB(ism).c_str());
00762       me = dqmStore_->get(histo);
00763       j03_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, j03_[ism-1] );
00764 
00765     }
00766 
00767     if (find(MGPAGains_.begin(), MGPAGains_.end(), 1) != MGPAGains_.end() ) {
00768 
00769       sprintf(histo, (prefixME_ + "/EBPedestalTask/Gain01/EBPT pedestal 5sum %s G01").c_str(), Numbers::sEB(ism).c_str());
00770       me = dqmStore_->get(histo);
00771       k01_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, k01_[ism-1] );
00772 
00773     }
00774 
00775     if (find(MGPAGains_.begin(), MGPAGains_.end(), 6) != MGPAGains_.end() ) {
00776 
00777       sprintf(histo, (prefixME_ + "/EBPedestalTask/Gain06/EBPT pedestal 5sum %s G06").c_str(), Numbers::sEB(ism).c_str());
00778       me = dqmStore_->get(histo);
00779       k02_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, k02_[ism-1] );
00780 
00781     }
00782 
00783     if (find(MGPAGains_.begin(), MGPAGains_.end(), 12) != MGPAGains_.end() ) {
00784 
00785       sprintf(histo, (prefixME_ + "/EBPedestalTask/Gain12/EBPT pedestal 5sum %s G12").c_str(), Numbers::sEB(ism).c_str());
00786       me = dqmStore_->get(histo);
00787       k03_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, k03_[ism-1] );
00788 
00789     }
00790 #endif
00791 
00792     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 1) != MGPAGainsPN_.end() ) {
00793 
00794       sprintf(histo, (prefixME_ + "/EBPedestalTask/PN/Gain01/EBPDT PNs pedestal %s G01").c_str(), Numbers::sEB(ism).c_str());
00795       me = dqmStore_->get(histo);
00796       i01_[ism-1] = UtilsClient::getHisto<TProfile*>( me, cloneME_, i01_[ism-1] );
00797 
00798     }
00799 
00800     if (find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), 6) != MGPAGainsPN_.end() ) {
00801 
00802       sprintf(histo, (prefixME_ + "/EBPedestalTask/PN/Gain16/EBPDT PNs pedestal %s G16").c_str(), Numbers::sEB(ism).c_str());
00803       me = dqmStore_->get(histo);
00804       i02_[ism-1] = UtilsClient::getHisto<TProfile*>( me, cloneME_, i02_[ism-1] );
00805 
00806     }
00807 
00808     if ( meg01_[ism-1] ) meg01_[ism-1]->Reset();
00809     if ( meg02_[ism-1] ) meg02_[ism-1]->Reset();
00810     if ( meg03_[ism-1] ) meg03_[ism-1]->Reset();
00811 
00812     if ( meg04_[ism-1] ) meg04_[ism-1]->Reset();
00813     if ( meg05_[ism-1] ) meg05_[ism-1]->Reset();
00814 
00815     if ( mep01_[ism-1] ) mep01_[ism-1]->Reset();
00816     if ( mep02_[ism-1] ) mep02_[ism-1]->Reset();
00817     if ( mep03_[ism-1] ) mep03_[ism-1]->Reset();
00818 
00819     if ( mer01_[ism-1] ) mer01_[ism-1]->Reset();
00820     if ( mer02_[ism-1] ) mer02_[ism-1]->Reset();
00821     if ( mer03_[ism-1] ) mer03_[ism-1]->Reset();
00822 
00823     if ( mer04_[ism-1] ) mer04_[ism-1]->Reset();
00824     if ( mer05_[ism-1] ) mer05_[ism-1]->Reset();
00825 
00826 #ifdef COMMON_NOISE_ANALYSIS
00827     if ( mes01_[ism-1] ) mes01_[ism-1]->Reset();
00828     if ( mes02_[ism-1] ) mes02_[ism-1]->Reset();
00829     if ( mes03_[ism-1] ) mes03_[ism-1]->Reset();
00830 
00831     if ( met01_[ism-1] ) met01_[ism-1]->Reset();
00832     if ( met02_[ism-1] ) met02_[ism-1]->Reset();
00833     if ( met03_[ism-1] ) met03_[ism-1]->Reset();
00834 #endif
00835 
00836     for ( int ie = 1; ie <= 85; ie++ ) {
00837       for ( int ip = 1; ip <= 20; ip++ ) {
00838 
00839         if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent(ie, ip, 2.);
00840         if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent(ie, ip, 2.);
00841         if ( meg03_[ism-1] ) meg03_[ism-1]->setBinContent(ie, ip, 2.);
00842 
00843         bool update01;
00844         bool update02;
00845         bool update03;
00846 
00847         float num01, num02, num03;
00848         float mean01, mean02, mean03;
00849         float rms01, rms02, rms03;
00850 
00851         update01 = UtilsClient::getBinStatistics(h01_[ism-1], ie, ip, num01, mean01, rms01);
00852         update02 = UtilsClient::getBinStatistics(h02_[ism-1], ie, ip, num02, mean02, rms02);
00853         update03 = UtilsClient::getBinStatistics(h03_[ism-1], ie, ip, num03, mean03, rms03);
00854 
00855         if ( update01 ) {
00856 
00857           float val;
00858 
00859           val = 1.;
00860           if ( std::abs(mean01 - expectedMean_[0]) > discrepancyMean_[0] )
00861             val = 0.;
00862           if ( rms01 > RMSThreshold_[0] )
00863             val = 0.;
00864           if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent(ie, ip, val);
00865 
00866           if ( mep01_[ism-1] ) mep01_[ism-1]->Fill(mean01);
00867           if ( mer01_[ism-1] ) mer01_[ism-1]->Fill(rms01);
00868 
00869         }
00870 
00871         if ( update02 ) {
00872 
00873           float val;
00874 
00875           val = 1.;
00876           if ( std::abs(mean02 - expectedMean_[1]) > discrepancyMean_[1] )
00877             val = 0.;
00878           if ( rms02 > RMSThreshold_[1] )
00879             val = 0.;
00880           if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent(ie, ip, val);
00881 
00882           if ( mep02_[ism-1] ) mep02_[ism-1]->Fill(mean02);
00883           if ( mer02_[ism-1] ) mer02_[ism-1]->Fill(rms02);
00884 
00885         }
00886 
00887         if ( update03 ) {
00888 
00889           float val;
00890 
00891           val = 1.;
00892           if ( std::abs(mean03 - expectedMean_[2]) > discrepancyMean_[2] )
00893             val = 0.;
00894           if ( rms03 > RMSThreshold_[2] )
00895             val = 0.;
00896           if ( meg03_[ism-1] ) meg03_[ism-1]->setBinContent(ie, ip, val);
00897 
00898           if ( mep03_[ism-1] ) mep03_[ism-1]->Fill(mean03);
00899           if ( mer03_[ism-1] ) mer03_[ism-1]->Fill(rms03);
00900 
00901         }
00902 
00903         if ( Masks::maskChannel(ism, ie, ip, bits01, EcalBarrel) ) UtilsClient::maskBinContent( meg01_[ism-1], ie, ip );
00904         if ( Masks::maskChannel(ism, ie, ip, bits02, EcalBarrel) ) UtilsClient::maskBinContent( meg02_[ism-1], ie, ip );
00905         if ( Masks::maskChannel(ism, ie, ip, bits03, EcalBarrel) ) UtilsClient::maskBinContent( meg03_[ism-1], ie, ip );
00906 
00907       }
00908     }
00909 
00910     // PN diodes
00911 
00912     for ( int i = 1; i <= 10; i++ ) {
00913 
00914       if ( meg04_[ism-1] ) meg04_[ism-1]->setBinContent( i, 1, 2. );
00915       if ( meg05_[ism-1] ) meg05_[ism-1]->setBinContent( i, 1, 2. );
00916 
00917       bool update01;
00918       bool update02;
00919 
00920       float num01, num02;
00921       float mean01, mean02;
00922       float rms01, rms02;
00923 
00924       update01 = UtilsClient::getBinStatistics(i01_[ism-1], i, 0, num01, mean01, rms01);
00925       update02 = UtilsClient::getBinStatistics(i02_[ism-1], i, 0, num02, mean02, rms02);
00926 
00927       // filling projections
00928       if ( mer04_[ism-1] )  mer04_[ism-1]->Fill(rms01);
00929       if ( mer05_[ism-1] )  mer05_[ism-1]->Fill(rms02);
00930 
00931       if ( update01 ) {
00932 
00933         float val;
00934 
00935         val = 1.;
00936         if ( mean01 < (expectedMeanPn_[0] - discrepancyMeanPn_[0])
00937              || (expectedMeanPn_[0] + discrepancyMeanPn_[0]) <  mean01)
00938           val = 0.;
00939         if ( rms01 >  RMSThresholdPn_[0])
00940           val = 0.;
00941 
00942         if ( meg04_[ism-1] ) meg04_[ism-1]->setBinContent(i, 1, val);
00943 
00944       }
00945 
00946       if ( update02 ) {
00947 
00948         float val;
00949 
00950         val = 1.;
00951         if ( mean02 < (expectedMeanPn_[1] - discrepancyMeanPn_[1])
00952              || (expectedMeanPn_[1] + discrepancyMeanPn_[1]) <  mean02)
00953           val = 0.;
00954         if ( rms02 >  RMSThresholdPn_[1])
00955           val = 0.;
00956 
00957         if ( meg05_[ism-1] ) meg05_[ism-1]->setBinContent(i, 1, val);
00958       }
00959 
00960       if ( Masks::maskPn(ism, i, bits01, EcalBarrel) ) UtilsClient::maskBinContent( meg04_[ism-1], i, 1 );
00961       if ( Masks::maskPn(ism, i, bits03, EcalBarrel) ) UtilsClient::maskBinContent( meg05_[ism-1], i, 1 );
00962 
00963     }
00964 
00965 #ifdef COMMON_NOISE_ANALYSIS
00966     for ( int ie = 1; ie <= 85; ie++ ) {
00967       for ( int ip = 1; ip <= 20; ip++ ) {
00968 
00969         float x3val01;
00970         float x3val02;
00971         float x3val03;
00972 
00973         float y3val01;
00974         float y3val02;
00975         float y3val03;
00976 
00977         float z3val01;
00978         float z3val02;
00979         float z3val03;
00980 
00981         float x5val01;
00982         float x5val02;
00983         float x5val03;
00984 
00985         float y5val01;
00986         float y5val02;
00987         float y5val03;
00988 
00989         float z5val01;
00990         float z5val02;
00991         float z5val03;
00992 
00993         if ( mes01_[ism-1] ) mes01_[ism-1]->setBinContent(ie, ip, -999.);
00994         if ( mes02_[ism-1] ) mes02_[ism-1]->setBinContent(ie, ip, -999.);
00995         if ( mes03_[ism-1] ) mes03_[ism-1]->setBinContent(ie, ip, -999.);
00996 
00997         if ( met01_[ism-1] ) met01_[ism-1]->setBinContent(ie, ip, -999.);
00998         if ( met02_[ism-1] ) met02_[ism-1]->setBinContent(ie, ip, -999.);
00999         if ( met03_[ism-1] ) met03_[ism-1]->setBinContent(ie, ip, -999.);
01000 
01001         if ( ie >= 2 && ie <= 84 && ip >= 2 && ip <= 19 ) {
01002 
01003           x3val01 = 0.;
01004           x3val02 = 0.;
01005           x3val03 = 0.;
01006           for ( int i = -1; i <= +1; i++ ) {
01007             for ( int j = -1; j <= +1; j++ ) {
01008 
01009               if ( h01_[ism-1] ) x3val01 = x3val01 + h01_[ism-1]->GetBinError(ie+i, ip+j) *
01010                                    h01_[ism-1]->GetBinError(ie+i, ip+j);
01011 
01012               if ( h02_[ism-1] ) x3val02 = x3val02 + h02_[ism-1]->GetBinError(ie+i, ip+j) *
01013                                    h02_[ism-1]->GetBinError(ie+i, ip+j);
01014 
01015               if ( h03_[ism-1] ) x3val03 = x3val03 + h03_[ism-1]->GetBinError(ie+i, ip+j) *
01016                                    h03_[ism-1]->GetBinError(ie+i, ip+j);
01017 
01018             }
01019           }
01020           x3val01 = x3val01 / (9.*9.);
01021           x3val02 = x3val02 / (9.*9.);
01022           x3val03 = x3val03 / (9.*9.);
01023 
01024           y3val01 = 0.;
01025           if ( j01_[ism-1] ) y3val01 = j01_[ism-1]->GetBinError(ie, ip) *
01026                                j01_[ism-1]->GetBinError(ie, ip);
01027 
01028           y3val02 = 0.;
01029           if ( j02_[ism-1] ) y3val02 = j02_[ism-1]->GetBinError(ie, ip) *
01030                                j02_[ism-1]->GetBinError(ie, ip);
01031 
01032           y3val03 = 0.;
01033           if ( j03_[ism-1] ) y3val03 = j03_[ism-1]->GetBinError(ie, ip) *
01034                                j03_[ism-1]->GetBinError(ie, ip);
01035 
01036           z3val01 = -999.;
01037           if ( x3val01 != 0 && y3val01 != 0 ) z3val01 = sqrt(std::abs(x3val01 - y3val01));
01038           if ( (x3val01 - y3val01) < 0 ) z3val01 = -z3val01;
01039 
01040           if ( mes01_[ism-1] ) mes01_[ism-1]->setBinContent(ie, ip, z3val01);
01041 
01042           z3val02 = -999.;
01043           if ( x3val02 != 0 && y3val02 != 0 ) z3val02 = sqrt(std::abs(x3val02 - y3val02));
01044           if ( (x3val02 - y3val02) < 0 ) z3val02 = -z3val02;
01045 
01046           if ( mes02_[ism-1] ) mes02_[ism-1]->setBinContent(ie, ip, z3val02);
01047 
01048           z3val03 = -999.;
01049           if ( x3val03 != 0 && y3val03 != 0 ) z3val03 = sqrt(std::abs(x3val03 - y3val03));
01050           if ( (x3val03 - y3val03) < 0 ) z3val03 = -z3val03;
01051 
01052           if ( mes03_[ism-1] ) mes03_[ism-1]->setBinContent(ie, ip, z3val03);
01053 
01054         }
01055 
01056         if ( ie >= 3 && ie <= 83 && ip >= 3 && ip <= 18 ) {
01057 
01058           x5val01 = 0.;
01059           x5val02 = 0.;
01060           x5val03 = 0.;
01061           for ( int i = -2; i <= +2; i++ ) {
01062             for ( int j = -2; j <= +2; j++ ) {
01063 
01064               if ( h01_[ism-1] ) x5val01 = x5val01 + h01_[ism-1]->GetBinError(ie+i, ip+j) *
01065                                    h01_[ism-1]->GetBinError(ie+i, ip+j);
01066 
01067               if ( h02_[ism-1] ) x5val02 = x5val02 + h02_[ism-1]->GetBinError(ie+i, ip+j) *
01068                                    h02_[ism-1]->GetBinError(ie+i, ip+j);
01069 
01070               if ( h03_[ism-1] ) x5val03 = x5val03 + h03_[ism-1]->GetBinError(ie+i, ip+j) *
01071                                    h03_[ism-1]->GetBinError(ie+i, ip+j);
01072 
01073             }
01074           }
01075           x5val01 = x5val01 / (25.*25.);
01076           x5val02 = x5val02 / (25.*25.);
01077           x5val03 = x5val03 / (25.*25.);
01078 
01079           y5val01 = 0.;
01080           if ( k01_[ism-1] ) y5val01 = k01_[ism-1]->GetBinError(ie, ip) *
01081                                k01_[ism-1]->GetBinError(ie, ip);
01082 
01083           y5val02 = 0.;
01084           if ( k02_[ism-1] ) y5val02 = k02_[ism-1]->GetBinError(ie, ip) *
01085                                k02_[ism-1]->GetBinError(ie, ip);
01086 
01087           y5val03 = 0.;
01088           if ( k03_[ism-1] ) y5val03 = k03_[ism-1]->GetBinError(ie, ip) *
01089                                k03_[ism-1]->GetBinError(ie, ip);
01090 
01091           z5val01 = -999.;
01092           if ( x5val01 != 0 && y5val01 != 0 ) z5val01 = sqrt(std::abs(x5val01 - y5val01));
01093           if ( (x5val01 - y5val01) < 0 ) z5val01 = -z5val01;
01094 
01095           if ( met01_[ism-1] ) met01_[ism-1]->setBinContent(ie, ip, z5val01);
01096 
01097           z5val02 = -999.;
01098           if ( x5val02 != 0 && y5val02 != 0 ) z5val02 = sqrt(std::abs(x5val02 - y5val02));
01099           if ( (x5val02 - y5val02) < 0 ) z5val02 = -z5val02;
01100 
01101           if ( met02_[ism-1] ) met02_[ism-1]->setBinContent(ie, ip, z5val02);
01102 
01103           z5val03 = -999.;
01104           if ( x5val03 != 0 && y5val03 != 0 ) z5val03 = sqrt(std::abs(x5val03 - y5val03));
01105           if ( (x5val03 - y5val03) < 0 ) z5val03 = -z5val03;
01106 
01107           if ( met03_[ism-1] ) met03_[ism-1]->setBinContent(ie, ip, z5val03);
01108 
01109         }
01110 
01111       }
01112     }
01113 #endif
01114 
01115   }
01116 
01117 }
01118