CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/DQM/EcalEndcapMonitorDbModule/src/EcalEndcapMonitorDbModule.cc

Go to the documentation of this file.
00001 /*
00002  * \file EcalEndcapMonitorDbModule.cc
00003  *
00004  * $Date: 2012/02/28 16:38:16 $
00005  * $Revision: 1.16 $
00006  * \author G. Della Ricca
00007  *
00008 */
00009 
00010 #include <unistd.h>
00011 
00012 #include <iostream>
00013 #include <cmath>
00014 
00015 #include "FWCore/ServiceRegistry/interface/Service.h"
00016 #include "DQMServices/Core/interface/DQMStore.h"
00017 
00018 #include "RelationalAccess/IConnectionService.h"
00019 #include "RelationalAccess/IConnectionServiceConfiguration.h"
00020 
00021 #include "CoralBase/Attribute.h"
00022 #include "CoralKernel/Context.h"
00023 
00024 #include "DQM/EcalBarrelMonitorDbModule/interface/MonitorElementsDb.h"
00025 
00026 #include "DQM/EcalEndcapMonitorDbModule/interface/EcalEndcapMonitorDbModule.h"
00027 
00028 EcalEndcapMonitorDbModule::EcalEndcapMonitorDbModule(const edm::ParameterSet& ps){
00029 
00030   dqmStore_ = edm::Service<DQMStore>().operator->();
00031 
00032   prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00033 
00034   xmlFile_ = ps.getUntrackedParameter<std::string>( "xmlFile", "" );
00035   if ( xmlFile_.size() != 0 ) {
00036     std::cout << "Monitor Elements from DB xml source file is " << xmlFile_ << std::endl;
00037   }
00038 
00039   sleepTime_ = ps.getUntrackedParameter<int>( "sleepTime", 0 );
00040   std::cout << "Sleep time is " << sleepTime_ << " second(s)." << std::endl;
00041 
00042   // html output directory
00043   htmlDir_ = ps.getUntrackedParameter<std::string>("htmlDir", ".");
00044 
00045   if ( htmlDir_.size() != 0 ) {
00046     std::cout << " HTML output will go to"
00047               << " htmlDir = " << htmlDir_ << std::endl;
00048   } else {
00049     std::cout << " HTML output is disabled" << std::endl;
00050   }
00051 
00052   ME_Db_ = new MonitorElementsDb( ps, xmlFile_ );
00053 
00054   if ( dqmStore_ ) dqmStore_->showDirStructure();
00055 
00056   icycle_ = 0;
00057   session_ = 0;
00058 
00059 }
00060 
00061 EcalEndcapMonitorDbModule::~EcalEndcapMonitorDbModule(){
00062 
00063   if ( ME_Db_ ) delete ME_Db_;
00064 
00065 }
00066 
00067 void EcalEndcapMonitorDbModule::beginJob(void){
00068 
00069   icycle_ = 0;
00070 
00071   if ( ME_Db_ ) ME_Db_->beginJob();
00072 
00073 }
00074 
00075 void EcalEndcapMonitorDbModule::endJob(void) {
00076 
00077   if ( ME_Db_ ) ME_Db_->endJob();
00078 
00079   std::cout << "EcalEndcapMonitorDbModule: endJob, icycle = " << icycle_ << std::endl;
00080 
00081 }
00082 
00083 void EcalEndcapMonitorDbModule::analyze(const edm::Event& e, const edm::EventSetup& c){
00084 
00085   icycle_++;
00086 
00087   std::cout << "EcalEndcapMonitorDbModule: icycle = " << icycle_ << std::endl;
00088 
00089   try {
00090     coral::Context& context = coral::Context::instance();
00091     context.loadComponent("CORAL/Services/ConnectionService");
00092     context.loadComponent("CORAL/Services/EnvironmentAuthenticationService");
00093     coral::IHandle<coral::IConnectionService> connectionService = context.query<coral::IConnectionService>("CORAL/Services/ConnectionService");
00094     context.loadComponent("CORAL/RelationalPlugins/oracle");
00095 
00096     // Set configuration parameters
00097     coral::IConnectionServiceConfiguration& config = connectionService->configuration();
00098     config.setConnectionRetrialPeriod(1);
00099     config.setConnectionRetrialTimeOut(10);
00100 
00101     session_ = connectionService->connect("ECAL CondDB", coral::ReadOnly);
00102 
00103     if ( ME_Db_ ) ME_Db_->analyze(e, c, session_ );
00104 
00105   } catch (coral::Exception& e) {
00106     std::cerr << "CORAL Exception : " << e.what() << std::endl;
00107   } catch (std::exception& e) {
00108     std::cerr << "Standard C++ exception : " << e.what() << std::endl;
00109   }
00110 
00111   if ( htmlDir_.size() != 0 ) {
00112 
00113     ME_Db_->htmlOutput( htmlDir_ );
00114 
00115   }
00116 
00117   delete session_;
00118 
00119   sleep( sleepTime_ );
00120 
00121 }
00122