CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/DQM/EcalBarrelMonitorDbModule/src/EcalBarrelMonitorDbModule.cc

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