CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DQM/EcalEndcapMonitorDbModule/src/EcalEndcapMonitorDbModule.cc

Go to the documentation of this file.
00001 /*
00002  * \file EcalEndcapMonitorDbModule.cc
00003  *
00004  * $Date: 2010/08/08 08:46:08 $
00005  * $Revision: 1.15 $
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 }
00057 
00058 EcalEndcapMonitorDbModule::~EcalEndcapMonitorDbModule(){
00059 
00060   if ( ME_Db_ ) delete ME_Db_;
00061 
00062 }
00063 
00064 void EcalEndcapMonitorDbModule::beginJob(void){
00065 
00066   icycle_ = 0;
00067 
00068   if ( ME_Db_ ) ME_Db_->beginJob();
00069 
00070 }
00071 
00072 void EcalEndcapMonitorDbModule::endJob(void) {
00073 
00074   if ( ME_Db_ ) ME_Db_->endJob();
00075 
00076   std::cout << "EcalEndcapMonitorDbModule: endJob, icycle = " << icycle_ << std::endl;
00077 
00078 }
00079 
00080 void EcalEndcapMonitorDbModule::analyze(const edm::Event& e, const edm::EventSetup& c){
00081 
00082   icycle_++;
00083 
00084   std::cout << "EcalEndcapMonitorDbModule: icycle = " << icycle_ << std::endl;
00085 
00086   try {
00087     coral::Context& context = coral::Context::instance();
00088     context.loadComponent("CORAL/Services/ConnectionService");
00089     context.loadComponent("CORAL/Services/EnvironmentAuthenticationService");
00090     coral::IHandle<coral::IConnectionService> connectionService = context.query<coral::IConnectionService>("CORAL/Services/ConnectionService");
00091     context.loadComponent("CORAL/RelationalPlugins/oracle");
00092 
00093     // Set configuration parameters
00094     coral::IConnectionServiceConfiguration& config = connectionService->configuration();
00095     config.setConnectionRetrialPeriod(1);
00096     config.setConnectionRetrialTimeOut(10);
00097 
00098     session_ = connectionService->connect("ECAL CondDB", coral::ReadOnly);
00099 
00100     if ( ME_Db_ ) ME_Db_->analyze(e, c, session_ );
00101 
00102   } catch (coral::Exception& e) {
00103     std::cerr << "CORAL Exception : " << e.what() << std::endl;
00104   } catch (std::exception& e) {
00105     std::cerr << "Standard C++ exception : " << e.what() << std::endl;
00106   }
00107 
00108   if ( htmlDir_.size() != 0 ) {
00109 
00110     ME_Db_->htmlOutput( htmlDir_ );
00111 
00112   }
00113 
00114   delete session_;
00115 
00116   sleep( sleepTime_ );
00117 
00118 }
00119