File indexing completed on 2023-03-17 10:54:30
0001
0002
0003
0004
0005
0006
0007
0008 #include "DQM/EcalMonitorDbModule/interface/EcalBarrelMonitorDbModule.h"
0009
0010 #include <unistd.h>
0011
0012 #include <cmath>
0013 #include <iostream>
0014
0015 #include "DQMServices/Core/interface/DQMStore.h"
0016 #include "FWCore/ServiceRegistry/interface/Service.h"
0017
0018 #include "RelationalAccess/IConnectionService.h"
0019 #include "RelationalAccess/IConnectionServiceConfiguration.h"
0020
0021 #include "CoralBase/Attribute.h"
0022 #include "CoralKernel/Context.h"
0023
0024 #include "DQM/EcalMonitorDbModule/interface/MonitorElementsDb.h"
0025
0026 #include "FWCore/Framework/interface/MakerMacros.h"
0027
0028 EcalBarrelMonitorDbModule::EcalBarrelMonitorDbModule(const edm::ParameterSet &ps) {
0029 usesResource("DQMStore");
0030 dqmStore_ = edm::Service<DQMStore>().operator->();
0031
0032 prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
0033
0034 xmlFile_ = ps.getUntrackedParameter<std::string>("xmlFile", "");
0035 if (!xmlFile_.empty()) {
0036 std::cout << "Monitor Elements from DB xml source file is " << xmlFile_ << std::endl;
0037 }
0038
0039 sleepTime_ = ps.getUntrackedParameter<int>("sleepTime", 0);
0040 std::cout << "Sleep time is " << sleepTime_ << " second(s)." << std::endl;
0041
0042
0043 htmlDir_ = ps.getUntrackedParameter<std::string>("htmlDir", ".");
0044
0045 if (!htmlDir_.empty()) {
0046 std::cout << " HTML output will go to"
0047 << " htmlDir = " << htmlDir_ << std::endl;
0048 } else {
0049 std::cout << " HTML output is disabled" << std::endl;
0050 }
0051
0052 ME_Db_ = new MonitorElementsDb(ps, xmlFile_);
0053
0054 icycle_ = 0;
0055 session_ = nullptr;
0056 }
0057
0058 EcalBarrelMonitorDbModule::~EcalBarrelMonitorDbModule() {
0059 if (ME_Db_)
0060 delete ME_Db_;
0061 }
0062
0063 void EcalBarrelMonitorDbModule::beginJob(void) {
0064 icycle_ = 0;
0065
0066 if (ME_Db_)
0067 ME_Db_->beginJob();
0068 }
0069
0070 void EcalBarrelMonitorDbModule::endJob(void) {
0071 if (ME_Db_)
0072 ME_Db_->endJob();
0073
0074 std::cout << "EcalBarrelMonitorDbModule: endJob, icycle = " << icycle_ << std::endl;
0075 }
0076
0077 void EcalBarrelMonitorDbModule::analyze(const edm::Event &e, const edm::EventSetup &c) {
0078 icycle_++;
0079
0080 std::cout << "EcalBarrelMonitorDbModule: icycle = " << icycle_ << std::endl;
0081
0082 try {
0083 coral::Context &context = coral::Context::instance();
0084 context.loadComponent("CORAL/Services/ConnectionService");
0085 context.loadComponent("CORAL/Services/EnvironmentAuthenticationService");
0086 coral::IHandle<coral::IConnectionService> connectionService =
0087 context.query<coral::IConnectionService>("CORAL/Services/ConnectionService");
0088 context.loadComponent("CORAL/RelationalPlugins/oracle");
0089
0090
0091 coral::IConnectionServiceConfiguration &config = connectionService->configuration();
0092 config.setConnectionRetrialPeriod(1);
0093 config.setConnectionRetrialTimeOut(10);
0094
0095 session_ = connectionService->connect("ECAL CondDB", coral::ReadOnly);
0096
0097 if (ME_Db_)
0098 ME_Db_->analyze(e, c, session_);
0099
0100 } catch (coral::Exception &e) {
0101 std::cerr << "CORAL Exception : " << e.what() << std::endl;
0102 } catch (std::exception &e) {
0103 std::cerr << "Standard C++ exception : " << e.what() << std::endl;
0104 }
0105
0106 if (!htmlDir_.empty()) {
0107 ME_Db_->htmlOutput(htmlDir_);
0108 }
0109
0110 delete session_;
0111
0112 sleep(sleepTime_);
0113 }
0114
0115 DEFINE_FWK_MODULE(EcalBarrelMonitorDbModule);