CMS 3D CMS Logo

EcalEndcapMonitorDbModule.cc

Go to the documentation of this file.
00001 /*
00002  * \file EcalEndcapMonitorDbModule.cc
00003  *
00004  * $Date: 2008/04/08 18:32:11 $
00005  * $Revision: 1.12 $
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 "SealKernel/Context.h"
00019 #include "SealKernel/ComponentLoader.h"
00020 #include "SealKernel/IMessageService.h"
00021 #include "PluginManager/PluginManager.h"
00022 #include "RelationalAccess/IConnectionService.h"
00023 #include "RelationalAccess/IConnectionServiceConfiguration.h"
00024 
00025 #include "CoralBase/Attribute.h"
00026 
00027 #include <DQM/EcalBarrelMonitorDbModule/interface/MonitorElementsDb.h>
00028 
00029 #include <DQM/EcalEndcapMonitorDbModule/interface/EcalEndcapMonitorDbModule.h>
00030 
00031 EcalEndcapMonitorDbModule::EcalEndcapMonitorDbModule(const edm::ParameterSet& ps){
00032 
00033   dqmStore_ = edm::Service<DQMStore>().operator->();
00034 
00035   prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00036 
00037   xmlFile_ = ps.getUntrackedParameter<std::string>( "xmlFile", "" );
00038   if ( xmlFile_.size() != 0 ) {
00039     std::cout << "Monitor Elements from DB xml source file is " << xmlFile_ << std::endl;
00040   }
00041 
00042   sleepTime_ = ps.getUntrackedParameter<int>( "sleepTime", 0 );
00043   std::cout << "Sleep time is " << sleepTime_ << " second(s)." << std::endl;
00044 
00045   // html output directory
00046   htmlDir_ = ps.getUntrackedParameter<std::string>("htmlDir", ".");
00047 
00048   if ( htmlDir_.size() != 0 ) {
00049     std::cout << " HTML output will go to"
00050               << " htmlDir = " << htmlDir_ << std::endl;
00051   } else {
00052     std::cout << " HTML output is disabled" << std::endl;
00053   }
00054 
00055   ME_Db_ = new MonitorElementsDb( ps, xmlFile_ );
00056 
00057   if ( dqmStore_ ) dqmStore_->showDirStructure();
00058 
00059 }
00060 
00061 EcalEndcapMonitorDbModule::~EcalEndcapMonitorDbModule(){
00062 
00063   if ( ME_Db_ ) delete ME_Db_;
00064 
00065 }
00066 
00067 void EcalEndcapMonitorDbModule::beginJob(const edm::EventSetup& c){
00068 
00069   icycle_ = 0;
00070 
00071   if ( ME_Db_ ) ME_Db_->beginJob(c);
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     seal::Handle<seal::Context> context = new seal::Context;
00091     seal::PluginManager* pm = seal::PluginManager::get();
00092     pm->initialise ();
00093     seal::Handle<seal::ComponentLoader> loader = new seal::ComponentLoader(context.get());
00094 
00095     loader->load("SEAL/Services/MessageService");
00096 
00097     std::vector<seal::Handle<seal::IMessageService> > v_msgSvc;
00098     context->query(v_msgSvc);
00099     if ( ! v_msgSvc.empty() ) {
00100       seal::Handle<seal::IMessageService>& msgSvc = v_msgSvc.front();
00101       msgSvc->setOutputLevel(seal::Msg::Error);
00102       //msgSvc->setOutputLevel(seal::Msg::Debug);
00103     }
00104 
00105     loader->load("CORAL/Services/ConnectionService");
00106 
00107     loader->load("CORAL/Services/EnvironmentAuthenticationService");
00108 
00109     seal::IHandle<coral::IConnectionService> connectionService = context->query<coral::IConnectionService>("CORAL/Services/ConnectionService");
00110 
00111     loader->load("CORAL/RelationalPlugins/oracle");
00112 
00113     // Set configuration parameters
00114     coral::IConnectionServiceConfiguration& config = connectionService->configuration();
00115     config.setConnectionRetrialPeriod(1);
00116     config.setConnectionRetrialTimeOut(10);
00117 
00118     session_ = connectionService->connect("ECAL CondDB", coral::ReadOnly);
00119 
00120     if ( ME_Db_ ) ME_Db_->analyze(e, c, session_ );
00121 
00122   } catch (coral::Exception& e) {
00123     std::cerr << "CORAL Exception : " << e.what() << std::endl;
00124   } catch (std::exception& e) {
00125     std::cerr << "Standard C++ exception : " << e.what() << std::endl;
00126   }
00127 
00128   if ( htmlDir_.size() != 0 ) {
00129 
00130     ME_Db_->htmlOutput( htmlDir_ );
00131 
00132   }
00133 
00134   delete session_;
00135 
00136   sleep( sleepTime_ );
00137 
00138 }
00139 

Generated on Tue Jun 9 17:32:51 2009 for CMSSW by  doxygen 1.5.4