CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalEndcapMonitorDbModule.cc
Go to the documentation of this file.
1 /*
2  * \file EcalEndcapMonitorDbModule.cc
3  *
4  * $Date: 2012/02/28 16:38:16 $
5  * $Revision: 1.16 $
6  * \author G. Della Ricca
7  *
8 */
9 
10 #include <unistd.h>
11 
12 #include <iostream>
13 #include <cmath>
14 
17 
18 #include "RelationalAccess/IConnectionService.h"
19 #include "RelationalAccess/IConnectionServiceConfiguration.h"
20 
21 #include "CoralBase/Attribute.h"
22 #include "CoralKernel/Context.h"
23 
25 
27 
29 
31 
32  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
33 
34  xmlFile_ = ps.getUntrackedParameter<std::string>( "xmlFile", "" );
35  if ( xmlFile_.size() != 0 ) {
36  std::cout << "Monitor Elements from DB xml source file is " << xmlFile_ << std::endl;
37  }
38 
39  sleepTime_ = ps.getUntrackedParameter<int>( "sleepTime", 0 );
40  std::cout << "Sleep time is " << sleepTime_ << " second(s)." << std::endl;
41 
42  // html output directory
43  htmlDir_ = ps.getUntrackedParameter<std::string>("htmlDir", ".");
44 
45  if ( htmlDir_.size() != 0 ) {
46  std::cout << " HTML output will go to"
47  << " htmlDir = " << htmlDir_ << std::endl;
48  } else {
49  std::cout << " HTML output is disabled" << std::endl;
50  }
51 
52  ME_Db_ = new MonitorElementsDb( ps, xmlFile_ );
53 
55 
56  icycle_ = 0;
57  session_ = 0;
58 
59 }
60 
62 
63  if ( ME_Db_ ) delete ME_Db_;
64 
65 }
66 
68 
69  icycle_ = 0;
70 
71  if ( ME_Db_ ) ME_Db_->beginJob();
72 
73 }
74 
76 
77  if ( ME_Db_ ) ME_Db_->endJob();
78 
79  std::cout << "EcalEndcapMonitorDbModule: endJob, icycle = " << icycle_ << std::endl;
80 
81 }
82 
84 
85  icycle_++;
86 
87  std::cout << "EcalEndcapMonitorDbModule: icycle = " << icycle_ << std::endl;
88 
89  try {
90  coral::Context& context = coral::Context::instance();
91  context.loadComponent("CORAL/Services/ConnectionService");
92  context.loadComponent("CORAL/Services/EnvironmentAuthenticationService");
93  coral::IHandle<coral::IConnectionService> connectionService = context.query<coral::IConnectionService>("CORAL/Services/ConnectionService");
94  context.loadComponent("CORAL/RelationalPlugins/oracle");
95 
96  // Set configuration parameters
97  coral::IConnectionServiceConfiguration& config = connectionService->configuration();
98  config.setConnectionRetrialPeriod(1);
99  config.setConnectionRetrialTimeOut(10);
100 
101  session_ = connectionService->connect("ECAL CondDB", coral::ReadOnly);
102 
103  if ( ME_Db_ ) ME_Db_->analyze(e, c, session_ );
104 
105  } catch (coral::Exception& e) {
106  std::cerr << "CORAL Exception : " << e.what() << std::endl;
107  } catch (std::exception& e) {
108  std::cerr << "Standard C++ exception : " << e.what() << std::endl;
109  }
110 
111  if ( htmlDir_.size() != 0 ) {
112 
114 
115  }
116 
117  delete session_;
118 
119  sleep( sleepTime_ );
120 
121 }
122 
T getUntrackedParameter(std::string const &, T const &) const
static PFTauRenderPlugin instance
Generate a Monitor Element from DB data.
void sleep(Duration_t)
Definition: Utils.h:163
void analyze(const edm::Event &e, const edm::EventSetup &c, coral::ISessionProxy *s)
Analyze.
virtual ~EcalEndcapMonitorDbModule()
Destructor.
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
EcalEndcapMonitorDbModule(const edm::ParameterSet &ps)
Constructor.
tuple cout
Definition: gather_cfg.py:121
void showDirStructure(void) const
Definition: DQMStore.cc:2761
void htmlOutput(std::string &htmlDir)