CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 /*
00002  * \file EELedClient.cc
00003  *
00004  * $Date: 2010/10/17 18:07:57 $
00005  * $Revision: 1.127 $
00006  * \author G. Della Ricca
00007  * \author G. Franzoni
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/MonLed1Dat.h"
00023 #include "OnlineDB/EcalCondDB/interface/MonLed2Dat.h"
00024 #include "OnlineDB/EcalCondDB/interface/MonPNLed1Dat.h"
00025 #include "OnlineDB/EcalCondDB/interface/MonPNLed2Dat.h"
00026 #include "OnlineDB/EcalCondDB/interface/MonTimingLed2CrystalDat.h"
00027 #include "OnlineDB/EcalCondDB/interface/MonTimingLed1CrystalDat.h"
00028 #include "OnlineDB/EcalCondDB/interface/RunCrystalErrorsDat.h"
00029 #include "OnlineDB/EcalCondDB/interface/RunTTErrorsDat.h"
00030 #include "OnlineDB/EcalCondDB/interface/RunPNErrorsDat.h"
00031 #include "OnlineDB/EcalCondDB/interface/EcalCondDBInterface.h"
00032 #include "DQM/EcalCommon/interface/LogicID.h"
00033 #endif
00034 
00035 #include "DQM/EcalCommon/interface/Masks.h"
00036 
00037 #include "DQM/EcalCommon/interface/UtilsClient.h"
00038 #include "DQM/EcalCommon/interface/Numbers.h"
00039 
00040 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00041 
00042 #include "DQM/EcalEndcapMonitorClient/interface/EELedClient.h"
00043 
00044 EELedClient::EELedClient(const edm::ParameterSet& ps) {
00045 
00046   // cloneME switch
00047   cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00048 
00049   // verbose switch
00050   verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
00051 
00052   // debug switch
00053   debug_ = ps.getUntrackedParameter<bool>("debug", false);
00054 
00055   // prefixME path
00056   prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00057 
00058   // enableCleanup_ switch
00059   enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00060 
00061   // vector of selected Super Modules (Defaults to all 18).
00062   superModules_.reserve(18);
00063   for ( unsigned int i = 1; i <= 18; i++ ) superModules_.push_back(i);
00064   superModules_ = ps.getUntrackedParameter<std::vector<int> >("superModules", superModules_);
00065 
00066   ledWavelengths_.reserve(2);
00067   for ( unsigned int i = 1; i <= 2; i++ ) ledWavelengths_.push_back(i);
00068   ledWavelengths_ = ps.getUntrackedParameter<std::vector<int> >("ledWavelengths", ledWavelengths_);
00069 
00070   if ( verbose_ ) {
00071     std::cout << " Led wavelengths:" << std::endl;
00072     for ( unsigned int i = 0; i < ledWavelengths_.size(); i++ ) {
00073       std::cout << " " << ledWavelengths_[i];
00074     }
00075     std::cout << std::endl;
00076   }
00077 
00078   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00079 
00080     int ism = superModules_[i];
00081 
00082     h01_[ism-1] = 0;
00083     h02_[ism-1] = 0;
00084     h03_[ism-1] = 0;
00085     h04_[ism-1] = 0;
00086 
00087     h09_[ism-1] = 0;
00088     h10_[ism-1] = 0;
00089 
00090     hs01_[ism-1] = 0;
00091     hs02_[ism-1] = 0;
00092 
00093     i01_[ism-1] = 0;
00094     i02_[ism-1] = 0;
00095 
00096     i05_[ism-1] = 0;
00097     i06_[ism-1] = 0;
00098 
00099     i09_[ism-1] = 0;
00100     i10_[ism-1] = 0;
00101 
00102     i13_[ism-1] = 0;
00103     i14_[ism-1] = 0;
00104 
00105   }
00106 
00107   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00108 
00109     int ism = superModules_[i];
00110 
00111     meg01_[ism-1] = 0;
00112     meg02_[ism-1] = 0;
00113 
00114     meg05_[ism-1] = 0;
00115     meg06_[ism-1] = 0;
00116 
00117     meg09_[ism-1] = 0;
00118     meg10_[ism-1] = 0;
00119 
00120     mea01_[ism-1] = 0;
00121     mea02_[ism-1] = 0;
00122 
00123     met01_[ism-1] = 0;
00124     met02_[ism-1] = 0;
00125 
00126     metav01_[ism-1] = 0;
00127     metav02_[ism-1] = 0;
00128 
00129     metrms01_[ism-1] = 0;
00130     metrms02_[ism-1] = 0;
00131 
00132     meaopn01_[ism-1] = 0;
00133     meaopn02_[ism-1] = 0;
00134 
00135     mepnprms01_[ism-1] = 0;
00136     mepnprms02_[ism-1] = 0;
00137 
00138     mepnprms05_[ism-1] = 0;
00139     mepnprms06_[ism-1] = 0;
00140 
00141     me_hs01_[ism-1] = 0;
00142     me_hs02_[ism-1] = 0;
00143 
00144   }
00145 
00146   percentVariation01_ = 999.; // not used nor not normalized VPTs
00147   percentVariation03_ = 999.; // not used nor not normalized VPTs
00148 
00149   amplitudeThreshold01_ = 2.;
00150   amplitudeThreshold03_ = 2.;
00151 
00152   rmsThreshold01_ = 10.;
00153   rmsThreshold03_ = 10.;
00154 
00155   amplitudeThresholdPnG01_ = 100.;
00156   amplitudeThresholdPnG16_ = 100.;
00157 
00158   pedPnExpectedMean_[0] = 750.0;
00159   pedPnExpectedMean_[1] = 750.0;
00160 
00161   pedPnDiscrepancyMean_[0] = 100.0;
00162   pedPnDiscrepancyMean_[1] = 100.0;
00163 
00164   pedPnRMSThreshold_[0] = 10.;
00165   pedPnRMSThreshold_[1] = 10.;
00166 
00167 }
00168 
00169 EELedClient::~EELedClient() {
00170 
00171 }
00172 
00173 void EELedClient::beginJob(void) {
00174 
00175   dqmStore_ = edm::Service<DQMStore>().operator->();
00176 
00177   if ( debug_ ) std::cout << "EELedClient: beginJob" << std::endl;
00178 
00179   ievt_ = 0;
00180   jevt_ = 0;
00181 
00182 }
00183 
00184 void EELedClient::beginRun(void) {
00185 
00186   if ( debug_ ) std::cout << "EELedClient: beginRun" << std::endl;
00187 
00188   jevt_ = 0;
00189 
00190   this->setup();
00191 
00192 }
00193 
00194 void EELedClient::endJob(void) {
00195 
00196   if ( debug_ ) std::cout << "EELedClient: endJob, ievt = " << ievt_ << std::endl;
00197 
00198   this->cleanup();
00199 
00200 }
00201 
00202 void EELedClient::endRun(void) {
00203 
00204   if ( debug_ ) std::cout << "EELedClient: endRun, jevt = " << jevt_ << std::endl;
00205 
00206   this->cleanup();
00207 
00208 }
00209 
00210 void EELedClient::setup(void) {
00211 
00212   char histo[200];
00213 
00214   dqmStore_->setCurrentFolder( prefixME_ + "/EELedClient" );
00215 
00216   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00217 
00218     int ism = superModules_[i];
00219 
00220     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00221       if ( meg01_[ism-1] ) dqmStore_->removeElement( meg01_[ism-1]->getName() );
00222       sprintf(histo, "EELDT led quality L1 %s", Numbers::sEE(ism).c_str());
00223       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.);
00224       meg01_[ism-1]->setAxisTitle("ix", 1);
00225       if ( ism >= 1 && ism <= 9 ) meg01_[ism-1]->setAxisTitle("101-ix", 1);
00226       meg01_[ism-1]->setAxisTitle("iy", 2);
00227     }
00228     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00229       if ( meg02_[ism-1] ) dqmStore_->removeElement( meg02_[ism-1]->getName() );
00230       sprintf(histo, "EELDT led quality L2 %s", Numbers::sEE(ism).c_str());
00231       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.);
00232       meg02_[ism-1]->setAxisTitle("ix", 1);
00233       if ( ism >= 1 && ism <= 9 ) meg02_[ism-1]->setAxisTitle("101-ix", 1);
00234       meg02_[ism-1]->setAxisTitle("iy", 2);
00235     }
00236 
00237     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00238       if ( meg05_[ism-1] ) dqmStore_->removeElement( meg05_[ism-1]->getName() );
00239       sprintf(histo, "EELDT led quality L1 PNs G01 %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     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00245       if ( meg06_[ism-1] ) dqmStore_->removeElement( meg06_[ism-1]->getName() );
00246       sprintf(histo, "EELDT led quality L2 PNs G01 %s", Numbers::sEE(ism).c_str());
00247       meg06_[ism-1] = dqmStore_->book2D(histo, histo, 10, 0., 10., 1, 0., 5.);
00248       meg06_[ism-1]->setAxisTitle("pseudo-strip", 1);
00249       meg06_[ism-1]->setAxisTitle("channel", 2);
00250     }
00251 
00252     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00253       if ( meg09_[ism-1] ) dqmStore_->removeElement( meg09_[ism-1]->getName() );
00254       sprintf(histo, "EELDT led quality L1 PNs G16 %s", Numbers::sEE(ism).c_str());
00255       meg09_[ism-1] = dqmStore_->book2D(histo, histo, 10, 0., 10., 1, 0., 5.);
00256       meg09_[ism-1]->setAxisTitle("pseudo-strip", 1);
00257       meg09_[ism-1]->setAxisTitle("channel", 2);
00258     }
00259     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00260       if ( meg10_[ism-1] ) dqmStore_->removeElement( meg10_[ism-1]->getName() );
00261       sprintf(histo, "EELDT led quality L2 PNs G16 %s", Numbers::sEE(ism).c_str());
00262       meg10_[ism-1] = dqmStore_->book2D(histo, histo, 10, 0., 10., 1, 0., 5.);
00263       meg10_[ism-1]->setAxisTitle("pseudo-strip", 1);
00264       meg10_[ism-1]->setAxisTitle("channel", 2);
00265     }
00266 
00267     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00268       if ( mea01_[ism-1] ) dqmStore_->removeElement( mea01_[ism-1]->getName() );;
00269       sprintf(histo, "EELDT amplitude L1 %s", Numbers::sEE(ism).c_str());
00270       mea01_[ism-1] = dqmStore_->book1D(histo, histo, 850, 0., 850.);
00271       mea01_[ism-1]->setAxisTitle("channel", 1);
00272       mea01_[ism-1]->setAxisTitle("amplitude", 2);
00273     }
00274     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00275       if ( mea02_[ism-1] ) dqmStore_->removeElement( mea02_[ism-1]->getName() );
00276       sprintf(histo, "EELDT amplitude L2 %s", Numbers::sEE(ism).c_str());
00277       mea02_[ism-1] = dqmStore_->book1D(histo, histo, 850, 0., 850.);
00278       mea02_[ism-1]->setAxisTitle("channel", 1);
00279       mea02_[ism-1]->setAxisTitle("amplitude", 2);
00280     }
00281 
00282     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00283       if ( met01_[ism-1] ) dqmStore_->removeElement( met01_[ism-1]->getName() );
00284       sprintf(histo, "EELDT led timing L1 %s", Numbers::sEE(ism).c_str());
00285       met01_[ism-1] = dqmStore_->book1D(histo, histo, 850, 0., 850.);
00286       met01_[ism-1]->setAxisTitle("channel", 1);
00287       met01_[ism-1]->setAxisTitle("jitter", 2);
00288     }
00289     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00290       if ( met02_[ism-1] ) dqmStore_->removeElement( met02_[ism-1]->getName() );
00291       sprintf(histo, "EELDT led timing L2 %s", Numbers::sEE(ism).c_str());
00292       met02_[ism-1] = dqmStore_->book1D(histo, histo, 850, 0., 850.);
00293       met02_[ism-1]->setAxisTitle("channel", 1);
00294       met02_[ism-1]->setAxisTitle("jitter", 2);
00295     }
00296 
00297     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00298       if ( metav01_[ism-1] ) dqmStore_->removeElement( metav01_[ism-1]->getName() );
00299       sprintf(histo, "EELDT led timing mean L1 %s", Numbers::sEE(ism).c_str());
00300       metav01_[ism-1] = dqmStore_->book1D(histo, histo, 100, 0., 10.);
00301       metav01_[ism-1]->setAxisTitle("mean", 1);
00302     }
00303     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00304       if ( metav02_[ism-1] ) dqmStore_->removeElement( metav02_[ism-1]->getName() );
00305       sprintf(histo, "EELDT led timing mean L2 %s", Numbers::sEE(ism).c_str());
00306       metav02_[ism-1] = dqmStore_->book1D(histo, histo, 100, 0., 10.);
00307       metav02_[ism-1]->setAxisTitle("mean", 1);
00308     }
00309 
00310     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00311       if ( metrms01_[ism-1] ) dqmStore_->removeElement( metrms01_[ism-1]->getName() );
00312       sprintf(histo, "EELDT led timing rms L1 %s", Numbers::sEE(ism).c_str());
00313       metrms01_[ism-1] = dqmStore_->book1D(histo, histo, 100, 0., 0.5);
00314       metrms01_[ism-1]->setAxisTitle("rms", 1);
00315     }
00316     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00317       if ( metrms02_[ism-1] ) dqmStore_->removeElement( metrms02_[ism-1]->getName() );
00318       sprintf(histo, "EELDT led timing rms L2 %s", Numbers::sEE(ism).c_str());
00319       metrms02_[ism-1] = dqmStore_->book1D(histo, histo, 100, 0., 0.5);
00320       metrms02_[ism-1]->setAxisTitle("rms", 1);
00321     }
00322 
00323     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00324       if ( meaopn01_[ism-1] ) dqmStore_->removeElement( meaopn01_[ism-1]->getName() );
00325       sprintf(histo, "EELDT amplitude over PN L1 %s", Numbers::sEE(ism).c_str());
00326       meaopn01_[ism-1] = dqmStore_->book1D(histo, histo, 850, 0., 850.);
00327       meaopn01_[ism-1]->setAxisTitle("channel", 1);
00328       meaopn01_[ism-1]->setAxisTitle("amplitude/PN", 2);
00329     }
00330     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00331       if ( meaopn02_[ism-1] ) dqmStore_->removeElement( meaopn02_[ism-1]->getName() );
00332       sprintf(histo, "EELDT amplitude over PN L2 %s", Numbers::sEE(ism).c_str());
00333       meaopn02_[ism-1] = dqmStore_->book1D(histo, histo, 850, 0., 850.);
00334       meaopn02_[ism-1]->setAxisTitle("channel", 1);
00335       meaopn02_[ism-1]->setAxisTitle("amplitude/PN", 2);
00336     }
00337 
00338     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00339       if ( mepnprms01_[ism-1] ) dqmStore_->removeElement( mepnprms01_[ism-1]->getName() );
00340       sprintf(histo, "EELDT PNs pedestal rms %s G01 L1", Numbers::sEE(ism).c_str());
00341       mepnprms01_[ism-1] = dqmStore_->book1D(histo, histo, 100, 0., 10.);
00342       mepnprms01_[ism-1]->setAxisTitle("rms", 1);
00343     }
00344     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00345       if ( mepnprms02_[ism-1] ) dqmStore_->removeElement( mepnprms02_[ism-1]->getName() );
00346       sprintf(histo, "EELDT PNs pedestal rms %s G01 L2", Numbers::sEE(ism).c_str());
00347       mepnprms02_[ism-1] = dqmStore_->book1D(histo, histo, 100, 0., 10.);
00348       mepnprms02_[ism-1]->setAxisTitle("rms", 1);
00349     }
00350 
00351     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00352       if ( mepnprms05_[ism-1] ) dqmStore_->removeElement( mepnprms05_[ism-1]->getName() );
00353       sprintf(histo, "EELDT PNs pedestal rms %s G16 L1", Numbers::sEE(ism).c_str());
00354       mepnprms05_[ism-1] = dqmStore_->book1D(histo, histo, 100, 0., 10.);
00355       mepnprms05_[ism-1]->setAxisTitle("rms", 1);
00356     }
00357     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00358       if ( mepnprms06_[ism-1] ) dqmStore_->removeElement( mepnprms06_[ism-1]->getName() );
00359       sprintf(histo, "EELDT PNs pedestal rms %s G16 L2", Numbers::sEE(ism).c_str());
00360       mepnprms06_[ism-1] = dqmStore_->book1D(histo, histo, 100, 0., 10.);
00361       mepnprms06_[ism-1]->setAxisTitle("rms", 1);
00362     }
00363 
00364     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00365       if ( me_hs01_[ism-1] ) dqmStore_->removeElement( me_hs01_[ism-1]->getName() );
00366       sprintf(histo, "EELDT led shape L1 %s", Numbers::sEE(ism).c_str());
00367       me_hs01_[ism-1] = dqmStore_->book1D(histo, histo, 10, 0., 10.);
00368       me_hs01_[ism-1]->setAxisTitle("sample", 1);
00369       me_hs01_[ism-1]->setAxisTitle("amplitude", 2);
00370     }
00371     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00372       if ( me_hs02_[ism-1] ) dqmStore_->removeElement( me_hs02_[ism-1]->getName() );
00373       sprintf(histo, "EELDT led shape L2 %s", Numbers::sEE(ism).c_str());
00374       me_hs02_[ism-1] = dqmStore_->book1D(histo, histo, 10, 0., 10.);
00375       me_hs02_[ism-1]->setAxisTitle("sample", 1);
00376       me_hs02_[ism-1]->setAxisTitle("amplitude", 2);
00377     }
00378 
00379   }
00380 
00381   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00382 
00383     int ism = superModules_[i];
00384 
00385     if ( meg01_[ism-1] ) meg01_[ism-1]->Reset();
00386     if ( meg02_[ism-1] ) meg02_[ism-1]->Reset();
00387 
00388     if ( meg05_[ism-1] ) meg05_[ism-1]->Reset();
00389     if ( meg06_[ism-1] ) meg06_[ism-1]->Reset();
00390 
00391     if ( meg09_[ism-1] ) meg09_[ism-1]->Reset();
00392     if ( meg10_[ism-1] ) meg10_[ism-1]->Reset();
00393 
00394     for ( int ix = 1; ix <= 50; ix++ ) {
00395       for ( int iy = 1; iy <= 50; iy++ ) {
00396 
00397         if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ix, iy, 6. );
00398         if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ix, iy, 6. );
00399 
00400         int jx = ix + Numbers::ix0EE(ism);
00401         int jy = iy + Numbers::iy0EE(ism);
00402 
00403         if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
00404 
00405         if ( Numbers::validEE(ism, jx, jy) ) {
00406           if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ix, iy, 2. );
00407           if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ix, iy, 2. );
00408         }
00409 
00410       }
00411     }
00412 
00413     for ( int i = 1; i <= 10; i++ ) {
00414 
00415         if ( meg05_[ism-1] ) meg05_[ism-1]->setBinContent( i, 1, 6. );
00416         if ( meg06_[ism-1] ) meg06_[ism-1]->setBinContent( i, 1, 6. );
00417 
00418         if ( meg09_[ism-1] ) meg09_[ism-1]->setBinContent( i, 1, 6. );
00419         if ( meg10_[ism-1] ) meg10_[ism-1]->setBinContent( i, 1, 6. );
00420 
00421         // non-existing mem
00422         if ( (ism >=  3 && ism <=  4) || (ism >=  7 && ism <=  9) ) continue;
00423         if ( (ism >= 12 && ism <= 13) || (ism >= 16 && ism <= 18) ) continue;
00424 
00425         if ( meg05_[ism-1] ) meg05_[ism-1]->setBinContent( i, 1, 2. );
00426         if ( meg06_[ism-1] ) meg06_[ism-1]->setBinContent( i, 1, 2. );
00427 
00428         if ( meg09_[ism-1] ) meg09_[ism-1]->setBinContent( i, 1, 2. );
00429         if ( meg10_[ism-1] ) meg10_[ism-1]->setBinContent( i, 1, 2. );
00430 
00431     }
00432 
00433     if ( mea01_[ism-1] ) mea01_[ism-1]->Reset();
00434     if ( mea02_[ism-1] ) mea02_[ism-1]->Reset();
00435 
00436     if ( met01_[ism-1] ) met01_[ism-1]->Reset();
00437     if ( met02_[ism-1] ) met02_[ism-1]->Reset();
00438 
00439     if ( metav01_[ism-1] ) metav01_[ism-1]->Reset();
00440     if ( metav02_[ism-1] ) metav02_[ism-1]->Reset();
00441 
00442     if ( metrms01_[ism-1] ) metrms01_[ism-1]->Reset();
00443     if ( metrms02_[ism-1] ) metrms02_[ism-1]->Reset();
00444 
00445     if ( meaopn01_[ism-1] ) meaopn01_[ism-1]->Reset();
00446     if ( meaopn02_[ism-1] ) meaopn02_[ism-1]->Reset();
00447 
00448     if ( mepnprms01_[ism-1] ) mepnprms01_[ism-1]->Reset();
00449     if ( mepnprms02_[ism-1] ) mepnprms02_[ism-1]->Reset();
00450 
00451     if ( mepnprms05_[ism-1] ) mepnprms05_[ism-1]->Reset();
00452     if ( mepnprms06_[ism-1] ) mepnprms06_[ism-1]->Reset();
00453 
00454     if ( me_hs01_[ism-1] ) me_hs01_[ism-1]->Reset();
00455     if ( me_hs02_[ism-1] ) me_hs02_[ism-1]->Reset();
00456 
00457   }
00458 
00459 }
00460 
00461 void EELedClient::cleanup(void) {
00462 
00463   if ( ! enableCleanup_ ) return;
00464 
00465   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00466 
00467     int ism = superModules_[i];
00468 
00469     if ( cloneME_ ) {
00470       if ( h01_[ism-1] ) delete h01_[ism-1];
00471       if ( h02_[ism-1] ) delete h02_[ism-1];
00472       if ( h03_[ism-1] ) delete h03_[ism-1];
00473       if ( h04_[ism-1] ) delete h04_[ism-1];
00474 
00475       if ( h09_[ism-1] ) delete h09_[ism-1];
00476       if ( h10_[ism-1] ) delete h10_[ism-1];
00477 
00478       if ( hs01_[ism-1] ) delete hs01_[ism-1];
00479       if ( hs02_[ism-1] ) delete hs02_[ism-1];
00480 
00481       if ( i01_[ism-1] ) delete i01_[ism-1];
00482       if ( i02_[ism-1] ) delete i02_[ism-1];
00483 
00484       if ( i05_[ism-1] ) delete i05_[ism-1];
00485       if ( i06_[ism-1] ) delete i06_[ism-1];
00486 
00487       if ( i09_[ism-1] ) delete i09_[ism-1];
00488       if ( i10_[ism-1] ) delete i10_[ism-1];
00489 
00490       if ( i13_[ism-1] ) delete i13_[ism-1];
00491       if ( i14_[ism-1] ) delete i14_[ism-1];
00492     }
00493 
00494     h01_[ism-1] = 0;
00495     h02_[ism-1] = 0;
00496     h03_[ism-1] = 0;
00497     h04_[ism-1] = 0;
00498 
00499     h09_[ism-1] = 0;
00500     h10_[ism-1] = 0;
00501 
00502     hs01_[ism-1] = 0;
00503     hs02_[ism-1] = 0;
00504 
00505     i01_[ism-1] = 0;
00506     i02_[ism-1] = 0;
00507 
00508     i05_[ism-1] = 0;
00509     i06_[ism-1] = 0;
00510 
00511     i09_[ism-1] = 0;
00512     i10_[ism-1] = 0;
00513 
00514     i13_[ism-1] = 0;
00515     i14_[ism-1] = 0;
00516 
00517   }
00518 
00519   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00520 
00521     int ism = superModules_[i];
00522 
00523     dqmStore_->setCurrentFolder( prefixME_ + "/EELedClient" );
00524 
00525     if ( meg01_[ism-1] ) dqmStore_->removeElement( meg01_[ism-1]->getName() );
00526     meg01_[ism-1] = 0;
00527     if ( meg02_[ism-1] ) dqmStore_->removeElement( meg02_[ism-1]->getName() );
00528     meg02_[ism-1] = 0;
00529 
00530     if ( meg05_[ism-1] ) dqmStore_->removeElement( meg05_[ism-1]->getName() );
00531     meg05_[ism-1] = 0;
00532     if ( meg06_[ism-1] ) dqmStore_->removeElement( meg06_[ism-1]->getName() );
00533     meg06_[ism-1] = 0;
00534 
00535     if ( meg09_[ism-1] ) dqmStore_->removeElement( meg09_[ism-1]->getName() );
00536     meg09_[ism-1] = 0;
00537     if ( meg10_[ism-1] ) dqmStore_->removeElement( meg10_[ism-1]->getName() );
00538     meg10_[ism-1] = 0;
00539 
00540     if ( mea01_[ism-1] ) dqmStore_->removeElement( mea01_[ism-1]->getName() );
00541     mea01_[ism-1] = 0;
00542     if ( mea02_[ism-1] ) dqmStore_->removeElement( mea02_[ism-1]->getName() );
00543     mea02_[ism-1] = 0;
00544 
00545     if ( met01_[ism-1] ) dqmStore_->removeElement( met01_[ism-1]->getName() );
00546     met01_[ism-1] = 0;
00547     if ( met02_[ism-1] ) dqmStore_->removeElement( met02_[ism-1]->getName() );
00548     met02_[ism-1] = 0;
00549 
00550     if ( metav01_[ism-1] ) dqmStore_->removeElement( metav01_[ism-1]->getName() );
00551     metav01_[ism-1] = 0;
00552     if ( metav02_[ism-1] ) dqmStore_->removeElement( metav02_[ism-1]->getName() );
00553     metav02_[ism-1] = 0;
00554 
00555     if ( metrms01_[ism-1] ) dqmStore_->removeElement( metrms01_[ism-1]->getName() );
00556     metrms01_[ism-1] = 0;
00557     if ( metrms02_[ism-1] ) dqmStore_->removeElement( metrms02_[ism-1]->getName() );
00558     metrms02_[ism-1] = 0;
00559 
00560     if ( meaopn01_[ism-1] ) dqmStore_->removeElement( meaopn01_[ism-1]->getName() );
00561     meaopn01_[ism-1] = 0;
00562     if ( meaopn02_[ism-1] ) dqmStore_->removeElement( meaopn02_[ism-1]->getName() );
00563     meaopn02_[ism-1] = 0;
00564 
00565     if ( mepnprms01_[ism-1] ) dqmStore_->removeElement( mepnprms01_[ism-1]->getName() );
00566     mepnprms01_[ism-1] = 0;
00567     if ( mepnprms02_[ism-1] ) dqmStore_->removeElement( mepnprms02_[ism-1]->getName() );
00568     mepnprms02_[ism-1] = 0;
00569 
00570     if ( mepnprms05_[ism-1] ) dqmStore_->removeElement( mepnprms05_[ism-1]->getName() );
00571     mepnprms05_[ism-1] = 0;
00572     if ( mepnprms06_[ism-1] ) dqmStore_->removeElement( mepnprms06_[ism-1]->getName() );
00573     mepnprms06_[ism-1] = 0;
00574 
00575     if ( me_hs01_[ism-1] ) dqmStore_->removeElement( me_hs01_[ism-1]->getName() );
00576     me_hs01_[ism-1] = 0;
00577     if ( me_hs02_[ism-1] ) dqmStore_->removeElement( me_hs02_[ism-1]->getName() );
00578     me_hs02_[ism-1] = 0;
00579 
00580   }
00581 
00582 }
00583 
00584 #ifdef WITH_ECAL_COND_DB
00585 bool EELedClient::writeDb(EcalCondDBInterface* econn, RunIOV* runiov, MonRunIOV* moniov, bool& status) {
00586 
00587   status = true;
00588 
00589   EcalLogicID ecid;
00590 
00591   MonLed1Dat vpt_l1;
00592   std::map<EcalLogicID, MonLed1Dat> dataset1_l1;
00593   MonLed2Dat vpt_l2;
00594   std::map<EcalLogicID, MonLed2Dat> dataset1_l2;
00595 
00596   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00597 
00598     int ism = superModules_[i];
00599 
00600     if ( verbose_ ) {
00601       std::cout << " " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
00602       std::cout << std::endl;
00603     }
00604 
00605     if ( verbose_ ) {
00606       if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00607         UtilsClient::printBadChannels(meg01_[ism-1], h01_[ism-1]);
00608       }
00609       if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00610         UtilsClient::printBadChannels(meg02_[ism-1], h03_[ism-1]);
00611       }
00612     }
00613 
00614     for ( int ix = 1; ix <= 50; ix++ ) {
00615       for ( int iy = 1; iy <= 50; iy++ ) {
00616 
00617         int jx = ix + Numbers::ix0EE(ism);
00618         int jy = iy + Numbers::iy0EE(ism);
00619 
00620         if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
00621 
00622         if ( ! Numbers::validEE(ism, jx, jy) ) continue;
00623 
00624         bool update01;
00625         bool update02;
00626         bool update03;
00627         bool update04;
00628 
00629         float num01, num02, num03, num04;
00630         float mean01, mean02, mean03, mean04;
00631         float rms01, rms02, rms03, rms04;
00632 
00633         update01 = UtilsClient::getBinStatistics(h01_[ism-1], ix, iy, num01, mean01, rms01);
00634         update02 = UtilsClient::getBinStatistics(h02_[ism-1], ix, iy, num02, mean02, rms02);
00635         update03 = UtilsClient::getBinStatistics(h03_[ism-1], ix, iy, num03, mean03, rms03);
00636         update04 = UtilsClient::getBinStatistics(h04_[ism-1], ix, iy, num04, mean04, rms04);
00637 
00638         if ( update01 || update02 ) {
00639 
00640           if ( Numbers::icEE(ism, jx, jy) == 1 ) {
00641 
00642             if ( verbose_ ) {
00643               std::cout << "Preparing dataset for " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
00644               std::cout << "L1 (" << Numbers::ix0EE(i+1)+ix << "," << Numbers::iy0EE(i+1)+iy << ") " << num01 << " " << mean01 << " " << rms01 << std::endl;
00645               std::cout << std::endl;
00646             }
00647 
00648           }
00649 
00650           vpt_l1.setVPTMean(mean01);
00651           vpt_l1.setVPTRMS(rms01);
00652 
00653           vpt_l1.setVPTOverPNMean(mean02);
00654           vpt_l1.setVPTOverPNRMS(rms02);
00655 
00656           if ( UtilsClient::getBinStatus(meg01_[ism-1], ix, iy) ) {
00657             vpt_l1.setTaskStatus(true);
00658           } else {
00659             vpt_l1.setTaskStatus(false);
00660           }
00661 
00662           status = status && UtilsClient::getBinQuality(meg01_[ism-1], ix, iy);
00663 
00664           int ic = Numbers::indexEE(ism, jx, jy);
00665 
00666           if ( ic == -1 ) continue;
00667 
00668           if ( econn ) {
00669             ecid = LogicID::getEcalLogicID("EE_crystal_number", Numbers::iSM(ism, EcalEndcap), ic);
00670             dataset1_l1[ecid] = vpt_l1;
00671           }
00672 
00673         }
00674 
00675         if ( update03 || update04 ) {
00676 
00677           if ( Numbers::icEE(ism, jx, jy) == 1 ) {
00678 
00679             if ( verbose_ ) {
00680               std::cout << "Preparing dataset for " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
00681               std::cout << "L2 (" << Numbers::ix0EE(i+1)+ix << "," << Numbers::iy0EE(i+1)+iy << ") " << num03 << " " << mean03 << " " << rms03 << std::endl;
00682               std::cout << std::endl;
00683             }
00684 
00685           }
00686 
00687           vpt_l2.setVPTMean(mean03);
00688           vpt_l2.setVPTRMS(rms03);
00689 
00690           vpt_l2.setVPTOverPNMean(mean04);
00691           vpt_l2.setVPTOverPNRMS(rms04);
00692 
00693           if ( UtilsClient::getBinStatus(meg02_[ism-1], ix, iy) ) {
00694             vpt_l2.setTaskStatus(true);
00695           } else {
00696             vpt_l2.setTaskStatus(false);
00697           }
00698 
00699           status = status && UtilsClient::getBinQuality(meg02_[ism-1], ix, iy);
00700 
00701           int ic = Numbers::indexEE(ism, jx, jy);
00702 
00703           if ( ic == -1 ) continue;
00704 
00705           if ( econn ) {
00706             ecid = LogicID::getEcalLogicID("EE_crystal_number", Numbers::iSM(ism, EcalEndcap), ic);
00707             dataset1_l2[ecid] = vpt_l2;
00708           }
00709 
00710         }
00711 
00712       }
00713     }
00714 
00715   }
00716 
00717   if ( econn ) {
00718     try {
00719       if ( verbose_ ) std::cout << "Inserting MonLedDat ..." << std::endl;
00720       if ( dataset1_l1.size() != 0 ) econn->insertDataArraySet(&dataset1_l1, moniov);
00721       if ( dataset1_l2.size() != 0 ) econn->insertDataArraySet(&dataset1_l2, moniov);
00722       if ( verbose_ ) std::cout << "done." << std::endl;
00723     } catch (std::runtime_error &e) {
00724       std::cerr << e.what() << std::endl;
00725     }
00726   }
00727 
00728   if ( verbose_ ) std::cout << std::endl;
00729 
00730   MonPNLed1Dat pn_l1;
00731   std::map<EcalLogicID, MonPNLed1Dat> dataset2_l1;
00732   MonPNLed2Dat pn_l2;
00733   std::map<EcalLogicID, MonPNLed2Dat> dataset2_l2;
00734 
00735   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00736 
00737     int ism = superModules_[i];
00738 
00739     if ( verbose_ ) {
00740       std::cout << " " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
00741       std::cout << std::endl;
00742     }
00743 
00744     if ( verbose_ ) {
00745       if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00746         UtilsClient::printBadChannels(meg05_[ism-1], i01_[ism-1]);
00747         UtilsClient::printBadChannels(meg05_[ism-1], i05_[ism-1]);
00748       }
00749       if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00750         UtilsClient::printBadChannels(meg06_[ism-1], i02_[ism-1]);
00751         UtilsClient::printBadChannels(meg06_[ism-1], i06_[ism-1]);
00752       }
00753 
00754       if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
00755         UtilsClient::printBadChannels(meg09_[ism-1], i09_[ism-1]);
00756         UtilsClient::printBadChannels(meg09_[ism-1], i13_[ism-1]);
00757       }
00758       if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
00759         UtilsClient::printBadChannels(meg10_[ism-1], i10_[ism-1]);
00760         UtilsClient::printBadChannels(meg10_[ism-1], i14_[ism-1]);
00761       }
00762     }
00763 
00764     for ( int i = 1; i <= 10; i++ ) {
00765 
00766       bool update01;
00767       bool update02;
00768 
00769       bool update05;
00770       bool update06;
00771 
00772       bool update09;
00773       bool update10;
00774 
00775       bool update13;
00776       bool update14;
00777 
00778       float num01, num02, num05, num06;
00779       float num09, num10, num13, num14;
00780       float mean01, mean02, mean05, mean06;
00781       float mean09, mean10, mean13, mean14;
00782       float rms01, rms02, rms05, rms06;
00783       float rms09, rms10, rms13, rms14;
00784 
00785       update01 = UtilsClient::getBinStatistics(i01_[ism-1], i, 0, num01, mean01, rms01);
00786       update02 = UtilsClient::getBinStatistics(i02_[ism-1], i, 0, num02, mean02, rms02);
00787 
00788       update05 = UtilsClient::getBinStatistics(i05_[ism-1], i, 0, num05, mean05, rms05);
00789       update06 = UtilsClient::getBinStatistics(i06_[ism-1], i, 0, num06, mean06, rms06);
00790 
00791       update09 = UtilsClient::getBinStatistics(i09_[ism-1], i, 0, num09, mean09, rms09);
00792       update10 = UtilsClient::getBinStatistics(i10_[ism-1], i, 0, num10, mean10, rms10);
00793 
00794       update13 = UtilsClient::getBinStatistics(i13_[ism-1], i, 0, num13, mean13, rms13);
00795       update14 = UtilsClient::getBinStatistics(i14_[ism-1], i, 0, num14, mean14, rms14);
00796 
00797       if ( update01 || update05 || update09 || update13 ) {
00798 
00799         if ( i == 1 ) {
00800 
00801           if ( verbose_ ) {
00802             std::cout << "Preparing dataset for " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
00803             std::cout << "PNs (" << i << ") L1 G01 " << num01  << " " << mean01 << " " << rms01  << std::endl;
00804             std::cout << "PNs (" << i << ") L1 G16 " << num09  << " " << mean09 << " " << rms09  << std::endl;
00805             std::cout << std::endl;
00806           }
00807 
00808         }
00809 
00810         pn_l1.setADCMeanG1(mean01);
00811         pn_l1.setADCRMSG1(rms01);
00812 
00813         pn_l1.setPedMeanG1(mean05);
00814         pn_l1.setPedRMSG1(rms05);
00815 
00816         pn_l1.setADCMeanG16(mean09);
00817         pn_l1.setADCRMSG16(rms09);
00818 
00819         pn_l1.setPedMeanG16(mean13);
00820         pn_l1.setPedRMSG16(rms13);
00821 
00822         if ( UtilsClient::getBinStatus(meg05_[ism-1], i, 1) ||
00823              UtilsClient::getBinStatus(meg09_[ism-1], i, 1) ) {
00824           pn_l1.setTaskStatus(true);
00825         } else {
00826           pn_l1.setTaskStatus(false);
00827         }
00828 
00829         status = status && ( UtilsClient::getBinQuality(meg05_[ism-1], i, 1) ||
00830                              UtilsClient::getBinQuality(meg09_[ism-1], i, 1) );
00831 
00832         if ( econn ) {
00833           ecid = LogicID::getEcalLogicID("EE_LM_PN", Numbers::iSM(ism, EcalEndcap), i-1);
00834           dataset2_l1[ecid] = pn_l1;
00835         }
00836 
00837       }
00838 
00839       if ( update02 || update06 || update10 || update14 ) {
00840 
00841         if ( i == 1 ) {
00842 
00843           if ( verbose_ ) {
00844             std::cout << "Preparing dataset for " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
00845             std::cout << "PNs (" << i << ") L2 G01 " << num02  << " " << mean02 << " " << rms02  << std::endl;
00846             std::cout << "PNs (" << i << ") L2 G16 " << num10  << " " << mean10 << " " << rms10  << std::endl;
00847             std::cout << std::endl;
00848           }
00849 
00850         }
00851 
00852         pn_l2.setADCMeanG1(mean02);
00853         pn_l2.setADCRMSG1(rms02);
00854 
00855         pn_l2.setPedMeanG1(mean06);
00856         pn_l2.setPedRMSG1(rms06);
00857 
00858         pn_l2.setADCMeanG16(mean10);
00859         pn_l2.setADCRMSG16(rms10);
00860 
00861         pn_l2.setPedMeanG16(mean14);
00862         pn_l2.setPedRMSG16(rms14);
00863 
00864         if ( UtilsClient::getBinStatus(meg06_[ism-1], i, 1) ||
00865              UtilsClient::getBinStatus(meg10_[ism-1], i, 1) ) {
00866           pn_l2.setTaskStatus(true);
00867         } else {
00868           pn_l2.setTaskStatus(false);
00869         }
00870 
00871         status = status && ( UtilsClient::getBinQuality(meg06_[ism-1], i, 1) ||
00872                              UtilsClient::getBinQuality(meg10_[ism-1], i, 1) );
00873 
00874         if ( econn ) {
00875           ecid = LogicID::getEcalLogicID("EE_LM_PN", Numbers::iSM(ism, EcalEndcap), i-1);
00876           dataset2_l2[ecid] = pn_l2;
00877         }
00878 
00879       }
00880 
00881     }
00882 
00883   }
00884 
00885   if ( econn ) {
00886     try {
00887       if ( verbose_ ) std::cout << "Inserting MonPnDat ..." << std::endl;
00888       if ( dataset2_l1.size() != 0 ) econn->insertDataArraySet(&dataset2_l1, moniov);
00889       if ( dataset2_l2.size() != 0 ) econn->insertDataArraySet(&dataset2_l2, moniov);
00890       if ( verbose_ ) std::cout << "done." << std::endl;
00891     } catch (std::runtime_error &e) {
00892       std::cerr << e.what() << std::endl;
00893     }
00894   }
00895 
00896   if ( verbose_ ) std::cout << std::endl;
00897 
00898   MonTimingLed1CrystalDat t_l1;
00899   std::map<EcalLogicID, MonTimingLed1CrystalDat> dataset3_l1;
00900   MonTimingLed2CrystalDat t_l2;
00901   std::map<EcalLogicID, MonTimingLed2CrystalDat> dataset3_l2;
00902 
00903   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00904 
00905     int ism = superModules_[i];
00906 
00907     if ( verbose_ ) {
00908       std::cout << " " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
00909       std::cout << std::endl;
00910     }
00911 
00912     for ( int ix = 1; ix <= 50; ix++ ) {
00913       for ( int iy = 1; iy <= 50; iy++ ) {
00914 
00915         int jx = ix + Numbers::ix0EE(ism);
00916         int jy = iy + Numbers::iy0EE(ism);
00917 
00918         if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
00919 
00920         if ( ! Numbers::validEE(ism, jx, jy) ) continue;
00921 
00922         bool update01;
00923         bool update02;
00924 
00925         float num01, num02;
00926         float mean01, mean02;
00927         float rms01, rms02;
00928 
00929         update01 = UtilsClient::getBinStatistics(h09_[ism-1], ix, iy, num01, mean01, rms01);
00930         update02 = UtilsClient::getBinStatistics(h10_[ism-1], ix, iy, num02, mean02, rms02);
00931 
00932         if ( update01 ) {
00933 
00934           if ( Numbers::icEE(ism, ix, iy) == 1 ) {
00935 
00936             if ( verbose_ ) {
00937               std::cout << "Preparing dataset for " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
00938               std::cout << "L1 crystal (" << Numbers::ix0EE(i+1)+ix << "," << Numbers::iy0EE(i+1)+iy << ") " << num01  << " " << mean01 << " " << rms01  << std::endl;
00939               std::cout << std::endl;
00940             }
00941 
00942           }
00943 
00944           t_l1.setTimingMean(mean01);
00945           t_l1.setTimingRMS(rms01);
00946 
00947           if ( UtilsClient::getBinStatus(meg01_[ism-1], ix, iy) ) {
00948             t_l1.setTaskStatus(true);
00949           } else {
00950             t_l1.setTaskStatus(false);
00951           }
00952 
00953           status = status && UtilsClient::getBinQuality(meg01_[ism-1], ix, iy);
00954 
00955           int ic = Numbers::indexEE(ism, ix, iy);
00956 
00957           if ( ic == -1 ) continue;
00958 
00959           if ( econn ) {
00960             ecid = LogicID::getEcalLogicID("EE_crystal_number", Numbers::iSM(ism, EcalEndcap), ic);
00961             dataset3_l1[ecid] = t_l1;
00962           }
00963 
00964         }
00965 
00966         if ( update02 ) {
00967 
00968           if ( Numbers::icEE(ism, ix, iy) == 1 ) {
00969 
00970             if ( verbose_ ) {
00971               std::cout << "Preparing dataset for " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
00972               std::cout << "L2 crystal (" << Numbers::ix0EE(i+1)+ix << "," << Numbers::iy0EE(i+1)+iy << ") " << num02  << " " << mean02 << " " << rms02  << std::endl;
00973               std::cout << std::endl;
00974             }
00975 
00976           }
00977 
00978           t_l2.setTimingMean(mean02);
00979           t_l2.setTimingRMS(rms02);
00980 
00981           if ( UtilsClient::getBinStatus(meg02_[ism-1], ix, iy) ) {
00982             t_l2.setTaskStatus(true);
00983           } else {
00984             t_l2.setTaskStatus(false);
00985           }
00986 
00987           status = status && UtilsClient::getBinQuality(meg02_[ism-1], ix, iy);
00988 
00989           int ic = Numbers::indexEE(ism, ix, iy);
00990 
00991           if ( ic == -1 ) continue;
00992 
00993           if ( econn ) {
00994             ecid = LogicID::getEcalLogicID("EE_crystal_number", Numbers::iSM(ism, EcalEndcap), ic);
00995             dataset3_l2[ecid] = t_l2;
00996           }
00997 
00998         }
00999 
01000       }
01001     }
01002 
01003   }
01004 
01005   if ( econn ) {
01006     try {
01007       if ( verbose_ ) std::cout << "Inserting MonTimingLaserCrystalDat ..." << std::endl;
01008       if ( dataset3_l1.size() != 0 ) econn->insertDataArraySet(&dataset3_l1, moniov);
01009       if ( dataset3_l2.size() != 0 ) econn->insertDataArraySet(&dataset3_l2, moniov);
01010       if ( verbose_ ) std::cout << "done." << std::endl;
01011     } catch (std::runtime_error &e) {
01012       std::cerr << e.what() << std::endl;
01013     }
01014   }
01015 
01016   return true;
01017 
01018 }
01019 #endif
01020 
01021 void EELedClient::analyze(void) {
01022 
01023   ievt_++;
01024   jevt_++;
01025   if ( ievt_ % 10 == 0 ) {
01026     if ( debug_ ) std::cout << "EELedClient: ievt/jevt = " << ievt_ << "/" << jevt_ << std::endl;
01027   }
01028 
01029   uint32_t bits01 = 0;
01030   bits01 |= 1 << EcalDQMStatusHelper::LED_MEAN_ERROR;
01031   bits01 |= 1 << EcalDQMStatusHelper::LED_RMS_ERROR;
01032 
01033   uint32_t bits02 = 0;
01034   bits02 |= 1 << EcalDQMStatusHelper::LED_TIMING_MEAN_ERROR;
01035   bits02 |= 1 << EcalDQMStatusHelper::LED_TIMING_RMS_ERROR;
01036 
01037   uint32_t bits03 = 0;
01038   bits03 |= 1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR;
01039   bits03 |= 1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_RMS_ERROR;
01040 
01041   uint32_t bits04 = 0;
01042   bits04 |= 1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR;
01043   bits04 |= 1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_RMS_ERROR;
01044 
01045   char histo[200];
01046 
01047   MonitorElement* me;
01048 
01049   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
01050 
01051     int ism = superModules_[i];
01052 
01053     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
01054 
01055       sprintf(histo, (prefixME_ + "/EELedTask/Led1/EELDT amplitude %s L1").c_str(), Numbers::sEE(ism).c_str());
01056       me = dqmStore_->get(histo);
01057       h01_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, h01_[ism-1] );
01058 
01059       sprintf(histo, (prefixME_ + "/EELedTask/Led1/EELDT amplitude over PN %s L1").c_str(), Numbers::sEE(ism).c_str());
01060       me = dqmStore_->get(histo);
01061       h02_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, h02_[ism-1] );
01062 
01063     }
01064 
01065     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
01066 
01067       sprintf(histo, (prefixME_ + "/EELedTask/Led2/EELDT amplitude %s L2").c_str(), Numbers::sEE(ism).c_str());
01068       me = dqmStore_->get(histo);
01069       h03_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, h03_[ism-1] );
01070 
01071       sprintf(histo, (prefixME_ + "/EELedTask/Led2/EELDT amplitude over PN %s L2").c_str(), Numbers::sEE(ism).c_str());
01072       me = dqmStore_->get(histo);
01073       h04_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, h04_[ism-1] );
01074 
01075     }
01076 
01077     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
01078 
01079       sprintf(histo, (prefixME_ + "/EELedTask/Led1/EELDT timing %s L1").c_str(), Numbers::sEE(ism).c_str());
01080       me = dqmStore_->get(histo);
01081       h09_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, h09_[ism-1] );
01082 
01083     }
01084 
01085     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
01086 
01087       sprintf(histo, (prefixME_ + "/EELedTask/Led2/EELDT timing %s L2").c_str(), Numbers::sEE(ism).c_str());
01088       me = dqmStore_->get(histo);
01089       h10_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, h10_[ism-1] );
01090 
01091     }
01092 
01093     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
01094 
01095       sprintf(histo, (prefixME_ + "/EELedTask/Led1/EELDT shape %s L1").c_str(), Numbers::sEE(ism).c_str());
01096       me = dqmStore_->get(histo);
01097       hs01_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, hs01_[ism-1] );
01098 
01099     }
01100 
01101     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
01102 
01103       sprintf(histo, (prefixME_ + "/EELedTask/Led2/EELDT shape %s L2").c_str(), Numbers::sEE(ism).c_str());
01104       me = dqmStore_->get(histo);
01105       hs02_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, hs02_[ism-1] );
01106 
01107     }
01108 
01109     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
01110 
01111       sprintf(histo, (prefixME_ + "/EELedTask/Led1/PN/Gain01/EELDT PNs amplitude %s G01 L1").c_str(), Numbers::sEE(ism).c_str());
01112       me = dqmStore_->get(histo);
01113       i01_[ism-1] = UtilsClient::getHisto<TProfile*>( me, cloneME_, i01_[ism-1] );
01114 
01115     }
01116 
01117     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
01118 
01119       sprintf(histo, (prefixME_ + "/EELedTask/Led2/PN/Gain01/EELDT PNs amplitude %s G01 L2").c_str(), Numbers::sEE(ism).c_str());
01120       me = dqmStore_->get(histo);
01121       i02_[ism-1] = UtilsClient::getHisto<TProfile*>( me, cloneME_, i02_[ism-1] );
01122 
01123     }
01124 
01125     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
01126 
01127       sprintf(histo, (prefixME_ + "/EELedTask/Led1/PN/Gain01/EELDT PNs pedestal %s G01 L1").c_str(), Numbers::sEE(ism).c_str());
01128       me = dqmStore_->get(histo);
01129       i05_[ism-1] = UtilsClient::getHisto<TProfile*>( me, cloneME_, i05_[ism-1] );
01130 
01131     }
01132 
01133     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
01134 
01135       sprintf(histo, (prefixME_ + "/EELedTask/Led2/PN/Gain01/EELDT PNs pedestal %s G01 L2").c_str(), Numbers::sEE(ism).c_str());
01136       me = dqmStore_->get(histo);
01137       i06_[ism-1] = UtilsClient::getHisto<TProfile*>( me, cloneME_, i06_[ism-1] );
01138 
01139     }
01140 
01141     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
01142 
01143       sprintf(histo, (prefixME_ + "/EELedTask/Led1/PN/Gain16/EELDT PNs amplitude %s G16 L1").c_str(), Numbers::sEE(ism).c_str());
01144       me = dqmStore_->get(histo);
01145       i09_[ism-1] = UtilsClient::getHisto<TProfile*>( me, cloneME_, i09_[ism-1] );
01146 
01147     }
01148 
01149     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
01150 
01151       sprintf(histo, (prefixME_ + "/EELedTask/Led2/PN/Gain16/EELDT PNs amplitude %s G16 L2").c_str(), Numbers::sEE(ism).c_str());
01152       me = dqmStore_->get(histo);
01153       i10_[ism-1] = UtilsClient::getHisto<TProfile*>( me, cloneME_, i10_[ism-1] );
01154 
01155     }
01156 
01157     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 1) != ledWavelengths_.end() ) {
01158 
01159       sprintf(histo, (prefixME_ + "/EELedTask/Led1/PN/Gain16/EELDT PNs pedestal %s G16 L1").c_str(), Numbers::sEE(ism).c_str());
01160       me = dqmStore_->get(histo);
01161       i13_[ism-1] = UtilsClient::getHisto<TProfile*>( me, cloneME_, i13_[ism-1] );
01162 
01163     }
01164 
01165     if ( find(ledWavelengths_.begin(), ledWavelengths_.end(), 2) != ledWavelengths_.end() ) {
01166 
01167       sprintf(histo, (prefixME_ + "/EELedTask/Led2/PN/Gain16/EELDT PNs pedestal %s G16 L2").c_str(), Numbers::sEE(ism).c_str());
01168       me = dqmStore_->get(histo);
01169       i14_[ism-1] = UtilsClient::getHisto<TProfile*>( me, cloneME_, i14_[ism-1] );
01170 
01171     }
01172 
01173     if ( meg01_[ism-1] ) meg01_[ism-1]->Reset();
01174     if ( meg02_[ism-1] ) meg02_[ism-1]->Reset();
01175 
01176     if ( meg05_[ism-1] ) meg05_[ism-1]->Reset();
01177     if ( meg06_[ism-1] ) meg06_[ism-1]->Reset();
01178 
01179     if ( meg09_[ism-1] ) meg09_[ism-1]->Reset();
01180     if ( meg10_[ism-1] ) meg10_[ism-1]->Reset();
01181 
01182     if ( mea01_[ism-1] ) mea01_[ism-1]->Reset();
01183     if ( mea02_[ism-1] ) mea02_[ism-1]->Reset();
01184 
01185     if ( met01_[ism-1] ) met01_[ism-1]->Reset();
01186     if ( met02_[ism-1] ) met02_[ism-1]->Reset();
01187 
01188     if ( metav01_[ism-1] ) metav01_[ism-1]->Reset();
01189     if ( metav02_[ism-1] ) metav02_[ism-1]->Reset();
01190 
01191     if ( metrms01_[ism-1] ) metrms01_[ism-1]->Reset();
01192     if ( metrms02_[ism-1] ) metrms02_[ism-1]->Reset();
01193 
01194     if ( meaopn01_[ism-1] ) meaopn01_[ism-1]->Reset();
01195     if ( meaopn02_[ism-1] ) meaopn02_[ism-1]->Reset();
01196 
01197     if ( mepnprms01_[ism-1] ) mepnprms01_[ism-1]->Reset();
01198     if ( mepnprms02_[ism-1] ) mepnprms02_[ism-1]->Reset();
01199 
01200     if ( me_hs01_[ism-1] ) me_hs01_[ism-1]->Reset();
01201     if ( me_hs02_[ism-1] ) me_hs02_[ism-1]->Reset();
01202 
01203     float meanAmplL1, meanAmplL2;
01204 
01205     int nCryL1, nCryL2;
01206 
01207     meanAmplL1 = meanAmplL2 = 0.;
01208 
01209     nCryL1 = nCryL2 = 0;
01210 
01211     for ( int ix = 1; ix <= 50; ix++ ) {
01212       for ( int iy = 1; iy <= 50; iy++ ) {
01213 
01214         bool update01;
01215         bool update02;
01216 
01217         float num01, num02;
01218         float mean01, mean02;
01219         float rms01, rms02;
01220 
01221         update01 = UtilsClient::getBinStatistics(h01_[ism-1], ix, iy, num01, mean01, rms01);
01222         update02 = UtilsClient::getBinStatistics(h03_[ism-1], ix, iy, num02, mean02, rms02);
01223 
01224         if ( update01 ) {
01225           meanAmplL1 += mean01;
01226           nCryL1++;
01227         }
01228 
01229         if ( update02 ) {
01230           meanAmplL2 += mean02;
01231           nCryL2++;
01232         }
01233 
01234       }
01235     }
01236 
01237     if ( nCryL1 > 0 ) meanAmplL1 /= float (nCryL1);
01238     if ( nCryL2 > 0 ) meanAmplL2 /= float (nCryL2);
01239 
01240     for ( int ix = 1; ix <= 50; ix++ ) {
01241       for ( int iy = 1; iy <= 50; iy++ ) {
01242 
01243         if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ix, iy, 6.);
01244         if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ix, iy, 6.);
01245 
01246         int jx = ix + Numbers::ix0EE(ism);
01247         int jy = iy + Numbers::iy0EE(ism);
01248 
01249         if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
01250 
01251         if ( Numbers::validEE(ism, jx, jy) ) {
01252           if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ix, iy, 2.);
01253           if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ix, iy, 2.);
01254         }
01255 
01256         bool update01;
01257         bool update02;
01258         bool update03;
01259         bool update04;
01260 
01261         bool update09;
01262         bool update10;
01263 
01264         float num01, num02, num03, num04;
01265         float num09, num10;
01266         float mean01, mean02, mean03, mean04;
01267         float mean09, mean10;
01268         float rms01, rms02, rms03, rms04;
01269         float rms09, rms10;
01270 
01271         update01 = UtilsClient::getBinStatistics(h01_[ism-1], ix, iy, num01, mean01, rms01);
01272         update02 = UtilsClient::getBinStatistics(h02_[ism-1], ix, iy, num02, mean02, rms02);
01273         update03 = UtilsClient::getBinStatistics(h03_[ism-1], ix, iy, num03, mean03, rms03);
01274         update04 = UtilsClient::getBinStatistics(h04_[ism-1], ix, iy, num04, mean04, rms04);
01275 
01276         update09 = UtilsClient::getBinStatistics(h09_[ism-1], ix, iy, num09, mean09, rms09);
01277         update10 = UtilsClient::getBinStatistics(h10_[ism-1], ix, iy, num10, mean10, rms10);
01278 
01279         if ( update01 ) {
01280 
01281           float val;
01282 
01283           val = 1.;
01284           if ( mean01 < amplitudeThreshold01_ || rms01 > rmsThreshold01_ )
01285             val = 0.;
01286           if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ix, iy, val );
01287 
01288           int ic = Numbers::icEE(ism, jx, jy);
01289 
01290           if ( ic != -1 ) {
01291             if ( mea01_[ism-1] ) {
01292               if ( mean01 > 0. ) {
01293                 mea01_[ism-1]->setBinContent( ic, mean01 );
01294                 mea01_[ism-1]->setBinError( ic, rms01 );
01295               } else {
01296                 mea01_[ism-1]->setEntries( 1.+mea01_[ism-1]->getEntries() );
01297               }
01298             }
01299           }
01300 
01301         }
01302 
01303         if ( update03 ) {
01304 
01305           float val;
01306 
01307           val = 1.;
01308           if (  mean03 < amplitudeThreshold03_ || rms03 > rmsThreshold03_ )
01309             val = 0.;
01310           if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ix, iy, val );
01311 
01312           int ic = Numbers::icEE(ism, jx, jy);
01313 
01314           if ( ic != -1 ) {
01315             if ( mea02_[ism-1] ) {
01316               if ( mean03 > 0. ) {
01317                 mea02_[ism-1]->setBinContent( ic, mean03 );
01318                 mea02_[ism-1]->setBinError( ic, rms03 );
01319               } else {
01320                 mea02_[ism-1]->setEntries( 1.+mea02_[ism-1]->getEntries() );
01321               }
01322             }
01323           }
01324 
01325         }
01326 
01327         if ( Masks::maskChannel(ism, ix, iy, bits01, EcalEndcap) ) {
01328           UtilsClient::maskBinContent( meg01_[ism-1], ix, iy );
01329           UtilsClient::maskBinContent( meg02_[ism-1], ix, iy );
01330         }
01331 
01332         if ( update02 ) {
01333 
01334           int ic = Numbers::icEE(ism, jx, jy);
01335 
01336           if ( ic != -1 ) {
01337             if ( meaopn01_[ism-1] ) {
01338               if ( mean02 > 0. ) {
01339                 meaopn01_[ism-1]->setBinContent( ic, mean02 );
01340                 meaopn01_[ism-1]->setBinError( ic, rms02 );
01341               } else {
01342                 meaopn01_[ism-1]->setEntries( 1.+meaopn01_[ism-1]->getEntries() );
01343               }
01344             }
01345           }
01346 
01347         }
01348 
01349         if ( update04 ) {
01350 
01351           int ic = Numbers::icEE(ism, jx, jy);
01352 
01353           if ( ic != -1 ) {
01354             if ( meaopn02_[ism-1] ) {
01355               if ( mean04 > 0. ) {
01356                 meaopn02_[ism-1]->setBinContent( ic, mean04 );
01357                 meaopn02_[ism-1]->setBinError( ic, rms04 );
01358               } else {
01359                 meaopn02_[ism-1]->setEntries( 1.+meaopn02_[ism-1]->getEntries() );
01360               }
01361             }
01362           }
01363 
01364         }
01365 
01366         if ( update09 ) {
01367 
01368           int ic = Numbers::icEE(ism, jx, jy);
01369 
01370           if ( ic != -1 ) {
01371             if ( met01_[ism-1] ) {
01372               if ( mean09 > 0. ) {
01373                 met01_[ism-1]->setBinContent( ic, mean09 );
01374                 met01_[ism-1]->setBinError( ic, rms09 );
01375               } else {
01376                 met01_[ism-1]->setEntries(1.+met01_[ism-1]->getEntries());
01377               }
01378             }
01379 
01380             if ( metav01_[ism-1] ) metav01_[ism-1] ->Fill(mean09);
01381             if ( metrms01_[ism-1] ) metrms01_[ism-1]->Fill(rms09);
01382           }
01383 
01384         }
01385 
01386         if ( update10 ) {
01387 
01388           int ic = Numbers::icEE(ism, jx, jy);
01389 
01390           if ( ic != -1 ) {
01391             if ( met02_[ism-1] ) {
01392               if ( mean10 > 0. ) {
01393                 met02_[ism-1]->setBinContent( ic, mean10 );
01394                 met02_[ism-1]->setBinError( ic, rms10 );
01395               } else {
01396                 met02_[ism-1]->setEntries(1.+met02_[ism-1]->getEntries());
01397               }
01398             }
01399 
01400             if ( metav02_[ism-1] ) metav02_[ism-1] ->Fill(mean10);
01401             if ( metrms02_[ism-1] ) metrms02_[ism-1]->Fill(rms10);
01402           }
01403 
01404         }
01405 
01406       }
01407     }
01408 
01409     for ( int i = 1; i <= 10; i++ ) {
01410 
01411       if ( meg05_[ism-1] ) meg05_[ism-1]->setBinContent( i, 1, 6. );
01412       if ( meg06_[ism-1] ) meg06_[ism-1]->setBinContent( i, 1, 6. );
01413 
01414       if ( meg09_[ism-1] ) meg09_[ism-1]->setBinContent( i, 1, 6. );
01415       if ( meg10_[ism-1] ) meg10_[ism-1]->setBinContent( i, 1, 6. );
01416 
01417       // non-existing mem
01418       if ( (ism >=  3 && ism <=  4) || (ism >=  7 && ism <=  9) ) continue;
01419       if ( (ism >= 12 && ism <= 13) || (ism >= 16 && ism <= 18) ) continue;
01420 
01421       if ( meg05_[ism-1] ) meg05_[ism-1]->setBinContent( i, 1, 2. );
01422       if ( meg06_[ism-1] ) meg06_[ism-1]->setBinContent( i, 1, 2. );
01423 
01424       if ( meg09_[ism-1] ) meg09_[ism-1]->setBinContent( i, 1, 2. );
01425       if ( meg10_[ism-1] ) meg10_[ism-1]->setBinContent( i, 1, 2. );
01426 
01427       bool update01;
01428       bool update02;
01429 
01430       bool update05;
01431       bool update06;
01432 
01433       bool update09;
01434       bool update10;
01435 
01436       bool update13;
01437       bool update14;
01438 
01439       float num01, num02, num05, num06;
01440       float num09, num10, num13, num14;
01441       float mean01, mean02, mean05, mean06;
01442       float mean09, mean10, mean13, mean14;
01443       float rms01, rms02, rms05, rms06;
01444       float rms09, rms10, rms13, rms14;
01445 
01446       update01 = UtilsClient::getBinStatistics(i01_[ism-1], i, 0, num01, mean01, rms01);
01447       update02 = UtilsClient::getBinStatistics(i02_[ism-1], i, 0, num02, mean02, rms02);
01448 
01449       update05 = UtilsClient::getBinStatistics(i05_[ism-1], i, 0, num05, mean05, rms05);
01450       update06 = UtilsClient::getBinStatistics(i06_[ism-1], i, 0, num06, mean06, rms06);
01451 
01452       update09 = UtilsClient::getBinStatistics(i09_[ism-1], i, 0, num09, mean09, rms09);
01453       update10 = UtilsClient::getBinStatistics(i10_[ism-1], i, 0, num10, mean10, rms10);
01454 
01455       update13 = UtilsClient::getBinStatistics(i13_[ism-1], i, 0, num13, mean13, rms13);
01456       update14 = UtilsClient::getBinStatistics(i14_[ism-1], i, 0, num14, mean14, rms14);
01457 
01458       if ( update01 && update05 ) {
01459 
01460         float val;
01461 
01462         val = 1.;
01463         if ( mean01 < amplitudeThresholdPnG01_ )
01464           val = 0.;
01465         if ( mean05 <  pedPnExpectedMean_[0] - pedPnDiscrepancyMean_[0] ||
01466              pedPnExpectedMean_[0] + pedPnDiscrepancyMean_[0] < mean05)
01467           val = 0.;
01468         if ( rms05 > pedPnRMSThreshold_[0] )
01469           val = 0.;
01470 
01471         if ( meg05_[ism-1] ) meg05_[ism-1]->setBinContent(i, 1, val);
01472         if ( mepnprms01_[ism-1] ) mepnprms01_[ism-1]->Fill(rms05);
01473 
01474       }
01475 
01476       if ( update02 && update06 ) {
01477 
01478         float val;
01479 
01480         val = 1.;
01481         if ( mean02 < amplitudeThresholdPnG01_ )
01482           val = 0.;
01483         if ( mean06 <  pedPnExpectedMean_[0] - pedPnDiscrepancyMean_[0] ||
01484              pedPnExpectedMean_[0] + pedPnDiscrepancyMean_[0] < mean06)
01485           val = 0.;
01486         if ( rms06 > pedPnRMSThreshold_[0] )
01487           val = 0.;
01488 
01489         if ( meg06_[ism-1] )           meg06_[ism-1]->setBinContent(i, 1, val);
01490         if ( mepnprms02_[ism-1] ) mepnprms02_[ism-1]->Fill(rms06);
01491 
01492       }
01493 
01494       if ( update09 && update13 ) {
01495 
01496         float val;
01497 
01498         val = 1.;
01499         if ( mean09 < amplitudeThresholdPnG16_ )
01500           val = 0.;
01501         if ( mean13 <  pedPnExpectedMean_[1] - pedPnDiscrepancyMean_[1] ||
01502              pedPnExpectedMean_[1] + pedPnDiscrepancyMean_[1] < mean13)
01503           val = 0.;
01504         if ( rms13 > pedPnRMSThreshold_[1] )
01505           val = 0.;
01506 
01507         if ( meg09_[ism-1] )           meg09_[ism-1]->setBinContent(i, 1, val);
01508         if ( mepnprms05_[ism-1] ) mepnprms05_[ism-1]->Fill(rms13);
01509 
01510       }
01511 
01512       if ( update10 && update14 ) {
01513 
01514         float val;
01515 
01516         val = 1.;
01517         if ( mean10 < amplitudeThresholdPnG16_ )
01518           val = 0.;
01519         //        if ( mean14 < pedestalThresholdPn_ )
01520        if ( mean14 <  pedPnExpectedMean_[1] - pedPnDiscrepancyMean_[1] ||
01521             pedPnExpectedMean_[1] + pedPnDiscrepancyMean_[1] < mean14)
01522            val = 0.;
01523        if ( rms14 > pedPnRMSThreshold_[1] )
01524           val = 0.;
01525 
01526        if ( meg10_[ism-1] )           meg10_[ism-1]->setBinContent(i, 1, val);
01527        if ( mepnprms06_[ism-1] ) mepnprms06_[ism-1]->Fill(rms14);
01528 
01529       }
01530 
01531       if ( Masks::maskPn(ism, i, bits01|bits03, EcalEndcap) ) {
01532         UtilsClient::maskBinContent( meg05_[ism-1], i, 1 );
01533         UtilsClient::maskBinContent( meg06_[ism-1], i, 1 );
01534       }
01535 
01536       if ( Masks::maskPn(ism, i, bits01|bits04, EcalEndcap) ) {
01537         UtilsClient::maskBinContent( meg09_[ism-1], i, 1 );
01538         UtilsClient::maskBinContent( meg10_[ism-1], i, 1 );
01539       }
01540 
01541     }
01542 
01543     for ( int i = 1; i <= 10; i++ ) {
01544 
01545       if ( hs01_[ism-1] ) {
01546         int ic = UtilsClient::getFirstNonEmptyChannel( hs01_[ism-1] );
01547         if ( me_hs01_[ism-1] ) {
01548           me_hs01_[ism-1]->setBinContent( i, hs01_[ism-1]->GetBinContent(ic, i) );
01549           me_hs01_[ism-1]->setBinError( i, hs01_[ism-1]->GetBinError(ic, i) );
01550         }
01551       }
01552 
01553       if ( hs02_[ism-1] ) {
01554         int ic = UtilsClient::getFirstNonEmptyChannel( hs02_[ism-1] );
01555         if ( me_hs02_[ism-1] ) {
01556           me_hs02_[ism-1]->setBinContent( i, hs02_[ism-1]->GetBinContent(ic, i) );
01557           me_hs02_[ism-1]->setBinError( i, hs02_[ism-1]->GetBinError(ic, i) );
01558         }
01559       }
01560 
01561     }
01562 
01563   }
01564 
01565 }
01566