CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/DQM/EcalEndcapMonitorClient/src/EECosmicClient.cc

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