18 #include "RelationalAccess/ITransaction.h"
19 #include "RelationalAccess/ISchema.h"
20 #include "RelationalAccess/IQuery.h"
21 #include "RelationalAccess/ICursor.h"
23 #include "CoralBase/Attribute.h"
24 #include "CoralBase/AttributeList.h"
50 }
catch(
const std::runtime_error
e ) {
53 std::cerr <<
"Error loading parser: " << e.what() << std::endl;
58 for(
unsigned int i=0;
i<
MEinfo_.size();
i++ ) {
65 else if( strcmp(
MEinfo_[
i].
type.c_str(),
"th2d") == 0 ) {
69 else if( strcmp(
MEinfo_[
i].
type.c_str(),
"tprofile") == 0 ) {
73 else if( strcmp(
MEinfo_[
i].
type.c_str(),
"tprofile2d") == 0 ) {
79 MEs_.push_back( tmp );
102 std::cout <<
"MonitorElementsDb: analyzed " <<
ievt_ <<
" events" << std::endl;
103 for(
unsigned int i = 0;
i<
MEs_.size();
i++ ) {
114 atLeastAQuery =
false;
116 std::vector<std::string> vars;
120 for(
unsigned int i=0;
i<
MEinfo_.size();
i++ ) {
132 atLeastAQuery =
true;
134 session->transaction().start(
true);
136 coral::ISchema&
schema = session->nominalSchema();
138 coral::IQuery*
query = schema.newQuery();
140 for(
unsigned int j=0;
j<
MEinfo_[
i].queries.size();
j++ ) {
141 if( strcmp(
MEinfo_[
i].queries[
j].query.c_str(),
"addToTableList") == 0 ) {
144 else if( strcmp(
MEinfo_[
i].queries[
j].query.c_str(),
"addToOutputList") == 0 ) {
146 vars.push_back(
MEinfo_[
i].queries[
j].alias );
148 else if( strcmp(
MEinfo_[
i].queries[
j].query.c_str(),
"setCondition") == 0 ) {
149 query->setCondition(
MEinfo_[
i].queries[
j].
arg, coral::AttributeList() );
151 else if( strcmp(
MEinfo_[
i].queries[
j].query.c_str(),
"addToOrderList") == 0 ) {
156 coral::ICursor& cursor = query->execute();
160 while ( cursor.next() && k <
MEinfo_[
i].loop ) {
163 const coral::AttributeList& row = cursor.currentRow();
165 std::vector<float> vvars;
167 for(
unsigned int l=0;
l<vars.size();
l++ ) {
169 vvars.push_back( row[vars[
l].c_str()].data<float>() );
172 if( vvars.size() == 2 ) {
174 MEs_[
i]->Fill( vvars[0], vvars[1] );
176 else if( vvars.size() == 3 ) {
178 MEs_[
i]->Fill( vvars[0], vvars[1], vvars[2] );
180 else if( vvars.size() == 4 ) {
182 MEs_[
i]->Fill( vvars[0], vvars[1], vvars[2], vvars[3] );
185 std::cerr <<
"Too many variables to plot..." << std::endl;
196 std::cerr <<
"CORAL Exception : " << e.what() << std::endl;
198 std::cerr <<
"Standard C++ exception : " << e.what() << std::endl;
204 if( atLeastAQuery ) session->transaction().commit();
212 gStyle->SetOptStat(0);
214 gStyle->SetPalette(1,0);
216 for(
unsigned int i=0;
i<
MEinfo_.size();
i++ ) {
224 c1 =
new TCanvas(
"c1",
"dummy", 400*n, 400 );
227 c1 =
new TCanvas(
"c1",
"dummy", 400, 400*n );
232 const double histMax = 1.e15;
236 if( dynamic_cast<TH1F*>( ob ) ) {
237 TH1F*
h =
dynamic_cast<TH1F*
> ( ob );
240 else if( dynamic_cast<TH2F*>( ob ) ) {
241 TH2F*
h =
dynamic_cast<TH2F*
>( ob );
242 if( h->GetMaximum(histMax) > 1.e4 ) {
249 else if( dynamic_cast<TProfile*>( ob ) ) {
250 TProfile*
h =
dynamic_cast<TProfile*
>( ob );
251 if( h->GetMaximum(histMax) > 1.e4 ) {
262 c1->SaveAs( name.c_str() );
T getUntrackedParameter(std::string const &, T const &) const
MonitorElementsDb(const edm::ParameterSet &ps, std::string &xmlFile)
Constructors.
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Generate a Monitor Element from DB data.
void analyze(const edm::Event &e, const edm::EventSetup &c, coral::ISessionProxy *s)
Analyze.
void removeElement(const std::string &name)
const std::vector< DB_ME > & getDB_ME(void) const
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
std::vector< DB_ME > MEinfo_
std::vector< MonitorElement * > MEs_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
bool xmlFile(const std::string fParam)
std::vector< std::vector< double > > tmp
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
virtual ~MonitorElementsDb()
Destructor.
void htmlOutput(std::string &htmlDir)
void setCurrentFolder(const std::string &fullpath)
MonitorXMLParser * parser_
MonitorElement * bookProfile2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ, const char *option="s")