CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/DQM/EcalEndcapMonitorClient/src/EEPedestalClient.cc

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