CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/DQM/EcalBarrelMonitorClient/src/EBCosmicClient.cc

Go to the documentation of this file.
00001 /*
00002  * \file EBCosmicClient.cc
00003  *
00004  * $Date: 2012/04/27 13:45:58 $
00005  * $Revision: 1.130 $
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 <vector>
00016 
00017 #include "FWCore/ServiceRegistry/interface/Service.h"
00018 
00019 #include "DQMServices/Core/interface/DQMStore.h"
00020 #include "DQMServices/Core/interface/MonitorElement.h"
00021 
00022 #ifdef WITH_ECAL_COND_DB
00023 #include "OnlineDB/EcalCondDB/interface/MonOccupancyDat.h"
00024 #include "OnlineDB/EcalCondDB/interface/EcalCondDBInterface.h"
00025 #include "DQM/EcalCommon/interface/LogicID.h"
00026 #endif
00027 
00028 #include "DQM/EcalCommon/interface/UtilsClient.h"
00029 #include "DQM/EcalCommon/interface/Numbers.h"
00030 
00031 #include "DQM/EcalBarrelMonitorClient/interface/EBCosmicClient.h"
00032 
00033 EBCosmicClient::EBCosmicClient(const edm::ParameterSet& ps) {
00034 
00035   // cloneME switch
00036   cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00037 
00038   // verbose switch
00039   verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
00040 
00041   // debug switch
00042   debug_ = ps.getUntrackedParameter<bool>("debug", false);
00043 
00044   // prefixME path
00045   prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00046 
00047   // enableCleanup_ switch
00048   enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00049 
00050   // vector of selected Super Modules (Defaults to all 36).
00051   superModules_.reserve(36);
00052   for ( unsigned int i = 1; i <= 36; i++ ) superModules_.push_back(i);
00053   superModules_ = ps.getUntrackedParameter<std::vector<int> >("superModules", superModules_);
00054 
00055   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00056 
00057     int ism = superModules_[i];
00058 
00059     h01_[ism-1] = 0;
00060     h02_[ism-1] = 0;
00061     h03_[ism-1] = 0;
00062 
00063     meh01_[ism-1] = 0;
00064     meh02_[ism-1] = 0;
00065     meh03_[ism-1] = 0;
00066 
00067   }
00068 
00069 }
00070 
00071 EBCosmicClient::~EBCosmicClient() {
00072 
00073 }
00074 
00075 void EBCosmicClient::beginJob(void) {
00076 
00077   dqmStore_ = edm::Service<DQMStore>().operator->();
00078 
00079   if ( debug_ ) std::cout << "EBCosmicClient: beginJob" << std::endl;
00080 
00081   ievt_ = 0;
00082   jevt_ = 0;
00083 
00084 }
00085 
00086 void EBCosmicClient::beginRun(void) {
00087 
00088   if ( debug_ ) std::cout << "EBCosmicClient: beginRun" << std::endl;
00089 
00090   jevt_ = 0;
00091 
00092   this->setup();
00093 
00094 }
00095 
00096 void EBCosmicClient::endJob(void) {
00097 
00098   if ( debug_ ) std::cout << "EBCosmicClient: endJob, ievt = " << ievt_ << std::endl;
00099 
00100   this->cleanup();
00101 
00102 }
00103 
00104 void EBCosmicClient::endRun(void) {
00105 
00106   if ( debug_ ) std::cout << "EBCosmicClient: endRun, jevt = " << jevt_ << std::endl;
00107 
00108   this->cleanup();
00109 
00110 }
00111 
00112 void EBCosmicClient::setup(void) {
00113 
00114 }
00115 
00116 void EBCosmicClient::cleanup(void) {
00117 
00118   if ( ! enableCleanup_ ) return;
00119 
00120   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00121 
00122     int ism = superModules_[i];
00123 
00124     if ( cloneME_ ) {
00125       if ( h01_[ism-1] ) delete h01_[ism-1];
00126       if ( h02_[ism-1] ) delete h02_[ism-1];
00127       if ( h03_[ism-1] ) delete h03_[ism-1];
00128     }
00129 
00130     h01_[ism-1] = 0;
00131     h02_[ism-1] = 0;
00132     h03_[ism-1] = 0;
00133 
00134     meh01_[ism-1] = 0;
00135     meh02_[ism-1] = 0;
00136     meh03_[ism-1] = 0;
00137 
00138   }
00139 
00140 }
00141 
00142 #ifdef WITH_ECAL_COND_DB
00143 bool EBCosmicClient::writeDb(EcalCondDBInterface* econn, RunIOV* runiov, MonRunIOV* moniov, bool& status) {
00144 
00145   status = true;
00146 
00147   return true;
00148 
00149 }
00150 #endif
00151 
00152 void EBCosmicClient::analyze(void) {
00153 
00154   ievt_++;
00155   jevt_++;
00156   if ( ievt_ % 10 == 0 ) {
00157     if ( debug_ ) std::cout << "EBCosmicClient: ievt/jevt = " << ievt_ << "/" << jevt_ << std::endl;
00158   }
00159 
00160   MonitorElement* me;
00161 
00162   for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00163 
00164     int ism = superModules_[i];
00165 
00166     me = dqmStore_->get( prefixME_ + "/EBCosmicTask/Sel/EBCT energy sel " + Numbers::sEB(ism) );
00167     h01_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, h01_[ism-1] );
00168     meh01_[ism-1] = me;
00169 
00170     me = dqmStore_->get( prefixME_ + "/EBCosmicTask/Spectrum/EBCT 1x1 energy spectrum " + Numbers::sEB(ism) );
00171     h02_[ism-1] = UtilsClient::getHisto<TH1F*>( me, cloneME_, h02_[ism-1] );
00172     meh02_[ism-1] = me;
00173 
00174     me = dqmStore_->get( prefixME_ + "/EBCosmicTask/Spectrum/EBCT 3x3 energy spectrum " + Numbers::sEB(ism) );
00175     h03_[ism-1] = UtilsClient::getHisto<TH1F*>( me, cloneME_, h03_[ism-1] );
00176     meh03_[ism-1] = me;
00177 
00178   }
00179 
00180 }
00181