17 #include "RelationalAccess/ITransaction.h"
18 #include "RelationalAccess/ISchema.h"
19 #include "RelationalAccess/IQuery.h"
20 #include "RelationalAccess/ICursor.h"
22 #include "CoralBase/Attribute.h"
23 #include "CoralBase/AttributeList.h"
32 #include "../interface/MonitorElementsDb.h"
49 }
catch(
const std::runtime_error
e ) {
52 std::cerr <<
"Error loading parser: " << e.what() << std::endl;
57 for(
unsigned int i=0;
i<
MEinfo_.size();
i++ ) {
64 else if( strcmp(
MEinfo_[
i].
type.c_str(),
"th2d") == 0 ) {
68 else if( strcmp(
MEinfo_[
i].
type.c_str(),
"tprofile") == 0 ) {
72 else if( strcmp(
MEinfo_[
i].
type.c_str(),
"tprofile2d") == 0 ) {
78 MEs_.push_back( tmp );
101 std::cout <<
"MonitorElementsDb: analyzed " <<
ievt_ <<
" events" << std::endl;
102 for(
unsigned int i = 0;
i<
MEs_.size();
i++ ) {
113 atLeastAQuery =
false;
115 std::vector<std::string> vars;
119 for(
unsigned int i=0;
i<
MEinfo_.size();
i++ ) {
131 atLeastAQuery =
true;
133 session->transaction().start(
true);
135 coral::ISchema&
schema = session->nominalSchema();
137 coral::IQuery*
query = schema.newQuery();
139 for(
unsigned int j=0;
j<
MEinfo_[
i].queries.size();
j++ ) {
140 if( strcmp(
MEinfo_[
i].queries[
j].query.c_str(),
"addToTableList") == 0 ) {
143 else if( strcmp(
MEinfo_[
i].queries[
j].query.c_str(),
"addToOutputList") == 0 ) {
145 vars.push_back(
MEinfo_[
i].queries[
j].alias );
147 else if( strcmp(
MEinfo_[
i].queries[
j].query.c_str(),
"setCondition") == 0 ) {
148 query->setCondition(
MEinfo_[
i].queries[
j].
arg, coral::AttributeList() );
150 else if( strcmp(
MEinfo_[
i].queries[
j].query.c_str(),
"addToOrderList") == 0 ) {
155 coral::ICursor& cursor = query->execute();
159 while ( cursor.next() && k <
MEinfo_[
i].loop ) {
162 const coral::AttributeList& row = cursor.currentRow();
164 std::vector<float> vvars;
166 for(
unsigned int l=0;
l<vars.size();
l++ ) {
168 vvars.push_back( row[vars[
l].c_str()].data<float>() );
171 if( vvars.size() == 2 ) {
173 MEs_[
i]->Fill( vvars[0], vvars[1] );
175 else if( vvars.size() == 3 ) {
177 MEs_[
i]->Fill( vvars[0], vvars[1], vvars[2] );
179 else if( vvars.size() == 4 ) {
181 MEs_[
i]->Fill( vvars[0], vvars[1], vvars[2], vvars[3] );
184 std::cerr <<
"Too many variables to plot..." << std::endl;
195 std::cerr <<
"CORAL Exception : " << e.what() << std::endl;
197 std::cerr <<
"Standard C++ exception : " << e.what() << std::endl;
203 if( atLeastAQuery ) session->transaction().commit();
211 gStyle->SetOptStat(0);
213 gStyle->SetPalette(1,0);
215 for(
unsigned int i=0;
i<
MEinfo_.size();
i++ ) {
223 c1 =
new TCanvas(
"c1",
"dummy", 400*n, 400 );
226 c1 =
new TCanvas(
"c1",
"dummy", 400, 400*n );
231 const double histMax = 1.e15;
235 if( dynamic_cast<TH1F*>( ob ) ) {
236 TH1F*
h =
dynamic_cast<TH1F*
> ( ob );
239 else if( dynamic_cast<TH2F*>( ob ) ) {
240 TH2F*
h =
dynamic_cast<TH2F*
>( ob );
241 if( h->GetMaximum(histMax) > 1.e4 ) {
248 else if( dynamic_cast<TProfile*>( ob ) ) {
249 TProfile*
h =
dynamic_cast<TProfile*
>( ob );
250 if( h->GetMaximum(histMax) > 1.e4 ) {
261 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.
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
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
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_
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")