CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/DQM/EcalBarrelMonitorClient/src/EBStatusFlagsClient.cc

Go to the documentation of this file.
00001 /*
00002  * \file EBStatusFlagsClient.cc
00003  *
00004  * $Date: 2011/09/02 13:55:01 $
00005  * $Revision: 1.46 $
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 "DQM/EcalBarrelMonitorClient/interface/EBStatusFlagsClient.h"
00031 
00032 EBStatusFlagsClient::EBStatusFlagsClient(const edm::ParameterSet& ps) {
00033 
00034   // cloneME switch
00035   cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00036 
00037   // verbose switch
00038   verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
00039 
00040   // debug switch
00041   debug_ = ps.getUntrackedParameter<bool>("debug", false);
00042 
00043   // prefixME path
00044   prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00045 
00046   // enableCleanup_ switch
00047   enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00048 
00049   // vector of selected Super Modules (Defaults to all 36).
00050   superModules_.reserve(36);
00051   for ( unsigned int i = 1; i <= 36; i++ ) superModules_.push_back(i);
00052   superModules_ = ps.getUntrackedParameter<std::vector<int> >("superModules", superModules_);
00053 
00054   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00055 
00056     int ism = superModules_[i];
00057 
00058     h01_[ism-1] = 0;
00059 
00060     meh01_[ism-1] = 0;
00061 
00062     h02_[ism-1] = 0;
00063 
00064     meh02_[ism-1] = 0;
00065 
00066     h03_[ism-1] = 0;
00067 
00068     meh03_[ism-1] = 0;
00069 
00070   }
00071 
00072 }
00073 
00074 EBStatusFlagsClient::~EBStatusFlagsClient() {
00075 
00076 }
00077 
00078 void EBStatusFlagsClient::beginJob(void) {
00079 
00080   dqmStore_ = edm::Service<DQMStore>().operator->();
00081 
00082   if ( debug_ ) std::cout << "EBStatusFlagsClient: beginJob" << std::endl;
00083 
00084   ievt_ = 0;
00085   jevt_ = 0;
00086 
00087 }
00088 
00089 void EBStatusFlagsClient::beginRun(void) {
00090 
00091   if ( debug_ ) std::cout << "EBStatusFlagsClient: beginRun" << std::endl;
00092 
00093   jevt_ = 0;
00094 
00095   this->setup();
00096 
00097 }
00098 
00099 void EBStatusFlagsClient::endJob(void) {
00100 
00101   if ( debug_ ) std::cout << "EBStatusFlagsClient: endJob, ievt = " << ievt_ << std::endl;
00102 
00103   this->cleanup();
00104 
00105 }
00106 
00107 void EBStatusFlagsClient::endRun(void) {
00108 
00109   if ( debug_ ) std::cout << "EBStatusFlagsClient: endRun, jevt = " << jevt_ << std::endl;
00110 
00111   this->cleanup();
00112 
00113 }
00114 
00115 void EBStatusFlagsClient::setup(void) {
00116 
00117   dqmStore_->setCurrentFolder( prefixME_ + "/EBStatusFlagsClient" );
00118 
00119 }
00120 
00121 void EBStatusFlagsClient::cleanup(void) {
00122 
00123   if ( ! enableCleanup_ ) return;
00124 
00125   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00126 
00127     int ism = superModules_[i];
00128 
00129     if ( cloneME_ ) {
00130       if ( h01_[ism-1] ) delete h01_[ism-1];
00131       if ( h02_[ism-1] ) delete h02_[ism-1];
00132       if ( h03_[ism-1] ) delete h03_[ism-1];
00133     }
00134 
00135     h01_[ism-1] = 0;
00136     h02_[ism-1] = 0;
00137     h03_[ism-1] = 0;
00138 
00139     meh01_[ism-1] = 0;
00140     meh02_[ism-1] = 0;
00141     meh03_[ism-1] = 0;
00142 
00143   }
00144 
00145   dqmStore_->setCurrentFolder( prefixME_ + "/EBStatusFlagsClient" );
00146 
00147 }
00148 
00149 #ifdef WITH_ECAL_COND_DB
00150 bool EBStatusFlagsClient::writeDb(EcalCondDBInterface* econn, RunIOV* runiov, MonRunIOV* moniov, bool& status) {
00151 
00152   status = true;
00153 
00154   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00155 
00156     int ism = superModules_[i];
00157 
00158     if ( verbose_ ) {
00159       std::cout << " " << Numbers::sEB(ism) << " (ism=" << ism << ")" << std::endl;
00160       std::cout << std::endl;
00161       UtilsClient::printBadChannels(meh01_[ism-1], UtilsClient::getHisto<TH2F*>(meh01_[ism-1]), true);
00162     }
00163 
00164     if ( meh01_[ism-1] ) {
00165       if ( meh01_[ism-1]->getEntries() != 0 ) status = false;
00166     }
00167 
00168   }
00169 
00170   return true;
00171 
00172 }
00173 #endif
00174 
00175 void EBStatusFlagsClient::analyze(void) {
00176 
00177   ievt_++;
00178   jevt_++;
00179   if ( ievt_ % 10 == 0 ) {
00180     if ( debug_ ) std::cout << "EBStatusFlagsClient: ievt/jevt = " << ievt_ << "/" << jevt_ << std::endl;
00181   }
00182 
00183   uint32_t bits01 = 0;
00184   bits01 |= 1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR;
00185 
00186   MonitorElement* me;
00187 
00188   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00189 
00190     int ism = superModules_[i];
00191 
00192     me = dqmStore_->get( prefixME_ + "/EBStatusFlagsTask/FEStatus/EBSFT front-end status " + Numbers::sEB(ism) );
00193     h01_[ism-1] = UtilsClient::getHisto( me, cloneME_, h01_[ism-1] );
00194     meh01_[ism-1] = me;
00195 
00196     me = dqmStore_->get( prefixME_ + "/EBStatusFlagsTask/FEStatus/EBSFT front-end status bits " + Numbers::sEB(ism) );
00197     h02_[ism-1] = UtilsClient::getHisto( me, cloneME_, h02_[ism-1] );
00198     meh02_[ism-1] = me;
00199 
00200     me = dqmStore_->get( prefixME_ + "/EBStatusFlagsTask/FEStatus/EBSFT MEM front-end status " + Numbers::sEB(ism) );
00201     h03_[ism-1] = UtilsClient::getHisto( me, cloneME_, h01_[ism-1] );
00202     meh03_[ism-1] = me;
00203 
00204     for ( int ie = 1; ie <= 85; ie++ ) {
00205       for ( int ip = 1; ip <= 20; ip++ ) {
00206         if ( Masks::maskChannel(ism, ie, ip, bits01, EcalBarrel) ) {
00207           int iet = (ie-1)/5 + 1;
00208           int ipt = (ip-1)/5 + 1;
00209           if ( meh01_[ism-1] ) meh01_[ism-1]->setBinError( iet, ipt, 0.01 );
00210         }
00211       }
00212     }
00213 
00214     for ( int i = 1; i <= 10; i++ ) {
00215       if ( Masks::maskPn(ism, i, bits01, EcalBarrel) ) {
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