CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DQM/EcalEndcapMonitorClient/src/EEStatusFlagsClient.cc

Go to the documentation of this file.
00001 /*
00002  * \file EEStatusFlagsClient.cc
00003  *
00004  * $Date: 2011/09/02 13:55:02 $
00005  * $Revision: 1.48 $
00006  * \author G. Della Ricca
00007  *
00008 */
00009 
00010 #include <memory>
00011 #include <iostream>
00012 #include <fstream>
00013 #include <iomanip>
00014 
00015 #include "FWCore/ServiceRegistry/interface/Service.h"
00016 
00017 #include "DQMServices/Core/interface/DQMStore.h"
00018 #include "DQMServices/Core/interface/MonitorElement.h"
00019 
00020 #ifdef WITH_ECAL_COND_DB
00021 #include "OnlineDB/EcalCondDB/interface/RunTTErrorsDat.h"
00022 #include "DQM/EcalCommon/interface/LogicID.h"
00023 #endif
00024 
00025 #include "DQM/EcalCommon/interface/Masks.h"
00026 
00027 #include "DQM/EcalCommon/interface/UtilsClient.h"
00028 #include "DQM/EcalCommon/interface/Numbers.h"
00029 
00030 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00031 
00032 #include "DQM/EcalEndcapMonitorClient/interface/EEStatusFlagsClient.h"
00033 
00034 EEStatusFlagsClient::EEStatusFlagsClient(const edm::ParameterSet& ps) {
00035 
00036   // cloneME switch
00037   cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00038 
00039   // verbose switch
00040   verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
00041 
00042   // debug switch
00043   debug_ = ps.getUntrackedParameter<bool>("debug", false);
00044 
00045   // prefixME path
00046   prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00047 
00048   // enableCleanup_ switch
00049   enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00050 
00051   // vector of selected Super Modules (Defaults to all 18).
00052   superModules_.reserve(18);
00053   for ( unsigned int i = 1; i <= 18; i++ ) superModules_.push_back(i);
00054   superModules_ = ps.getUntrackedParameter<std::vector<int> >("superModules", superModules_);
00055 
00056   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00057 
00058     int ism = superModules_[i];
00059 
00060     h01_[ism-1] = 0;
00061 
00062     meh01_[ism-1] = 0;
00063 
00064     h02_[ism-1] = 0;
00065 
00066     meh02_[ism-1] = 0;
00067 
00068     h03_[ism-1] = 0;
00069 
00070     meh03_[ism-1] = 0;
00071 
00072   }
00073 
00074 }
00075 
00076 EEStatusFlagsClient::~EEStatusFlagsClient() {
00077 
00078 }
00079 
00080 void EEStatusFlagsClient::beginJob(void) {
00081 
00082   dqmStore_ = edm::Service<DQMStore>().operator->();
00083 
00084   if ( debug_ ) std::cout << "EEStatusFlagsClient: beginJob" << std::endl;
00085 
00086   ievt_ = 0;
00087   jevt_ = 0;
00088 
00089 }
00090 
00091 void EEStatusFlagsClient::beginRun(void) {
00092 
00093   if ( debug_ ) std::cout << "EEStatusFlagsClient: beginRun" << std::endl;
00094 
00095   jevt_ = 0;
00096 
00097   this->setup();
00098 
00099 }
00100 
00101 void EEStatusFlagsClient::endJob(void) {
00102 
00103   if ( debug_ ) std::cout << "EEStatusFlagsClient: endJob, ievt = " << ievt_ << std::endl;
00104 
00105   this->cleanup();
00106 
00107 }
00108 
00109 void EEStatusFlagsClient::endRun(void) {
00110 
00111   if ( debug_ ) std::cout << "EEStatusFlagsClient: endRun, jevt = " << jevt_ << std::endl;
00112 
00113   this->cleanup();
00114 
00115 }
00116 
00117 void EEStatusFlagsClient::setup(void) {
00118 
00119   dqmStore_->setCurrentFolder( prefixME_ + "/EEStatusFlagsClient" );
00120 
00121 }
00122 
00123 void EEStatusFlagsClient::cleanup(void) {
00124 
00125   if ( ! enableCleanup_ ) return;
00126 
00127   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00128 
00129     int ism = superModules_[i];
00130 
00131     if ( cloneME_ ) {
00132       if ( h01_[ism-1] ) delete h01_[ism-1];
00133       if ( h02_[ism-1] ) delete h02_[ism-1];
00134       if ( h03_[ism-1] ) delete h03_[ism-1];
00135     }
00136 
00137     h01_[ism-1] = 0;
00138     h02_[ism-1] = 0;
00139     h03_[ism-1] = 0;
00140 
00141     meh01_[ism-1] = 0;
00142     meh02_[ism-1] = 0;
00143     meh03_[ism-1] = 0;
00144 
00145   }
00146 
00147   dqmStore_->setCurrentFolder( prefixME_ + "/EEStatusFlagsClient" );
00148 
00149 }
00150 
00151 #ifdef WITH_ECAL_COND_DB
00152 bool EEStatusFlagsClient::writeDb(EcalCondDBInterface* econn, RunIOV* runiov, MonRunIOV* moniov, bool& status) {
00153 
00154   status = true;
00155 
00156   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00157 
00158     int ism = superModules_[i];
00159 
00160     if ( verbose_ ) {
00161       std::cout << " " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
00162       std::cout << std::endl;
00163       UtilsClient::printBadChannels(meh01_[ism-1], UtilsClient::getHisto<TH2F*>(meh01_[ism-1]), true);
00164     }
00165 
00166     if ( meh01_[ism-1] ) {
00167       if ( meh01_[ism-1]->getEntries() != 0 ) status = false;
00168     }
00169 
00170   }
00171 
00172   return true;
00173 
00174 }
00175 #endif
00176 
00177 void EEStatusFlagsClient::analyze(void) {
00178 
00179   ievt_++;
00180   jevt_++;
00181   if ( ievt_ % 10 == 0 ) {
00182     if ( debug_ ) std::cout << "EEStatusFlagsClient: ievt/jevt = " << ievt_ << "/" << jevt_ << std::endl;
00183   }
00184 
00185   uint32_t bits01 = 0;
00186   bits01 |= 1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR;
00187 
00188   MonitorElement* me;
00189 
00190   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00191 
00192     int ism = superModules_[i];
00193 
00194     me = dqmStore_->get( prefixME_ + "/EEStatusFlagsTask/FEStatus/EESFT front-end status " + Numbers::sEE(ism) );
00195     h01_[ism-1] = UtilsClient::getHisto<TH2F*>( me, cloneME_, h01_[ism-1] );
00196     meh01_[ism-1] = me;
00197 
00198     me = dqmStore_->get( prefixME_ + "/EEStatusFlagsTask/FEStatus/EESFT front-end status bits " + Numbers::sEE(ism) );
00199     h02_[ism-1] = UtilsClient::getHisto<TH1F*>( me, cloneME_, h02_[ism-1] );
00200     meh02_[ism-1] = me;
00201 
00202     me = dqmStore_->get( prefixME_ + "/EEStatusFlagsTask/FEStatus/EESFT MEM front-end status " + Numbers::sEE(ism) );
00203     h03_[ism-1] = UtilsClient::getHisto<TH2F*>( me, cloneME_, h01_[ism-1] );
00204     meh03_[ism-1] = me;
00205 
00206     for ( int ix = 1; ix <= 50; ix++ ) {
00207       for ( int iy = 1; iy <= 50; iy++ ) {
00208         if ( Masks::maskChannel(ism, ix, iy, bits01, EcalEndcap) ) {
00209           if ( meh01_[ism-1] ) meh01_[ism-1]->setBinError( ix, iy, 0.01 );
00210         }
00211       }
00212     }
00213 
00214     for ( int i = 1; i <= 10; i++ ) {
00215       if ( Masks::maskPn(ism, i, bits01, EcalEndcap) ) {
00216         int it = (i-1)/5 + 1;
00217         if ( meh03_[ism-1] ) meh03_[ism-1]->setBinError( it, 1, 0.01 );
00218       }
00219     }
00220 
00221   }
00222 
00223 }
00224