21 #include "RelationalAccess/ITransaction.h"
22 #include "RelationalAccess/ISchema.h"
23 #include "RelationalAccess/IQuery.h"
24 #include "RelationalAccess/ICursor.h"
26 #include "CoralBase/Attribute.h"
27 #include "CoralBase/AttributeList.h"
53 }
catch(
const std::runtime_error
e ) {
56 std::cerr <<
"Error loading parser: " << e.what() << std::endl;
61 for(
unsigned int i=0;
i<
MEinfo_.size();
i++ ) {
68 else if( strcmp(
MEinfo_[
i].
type.c_str(),
"th2d") == 0 ) {
72 else if( strcmp(
MEinfo_[
i].
type.c_str(),
"tprofile") == 0 ) {
76 else if( strcmp(
MEinfo_[
i].
type.c_str(),
"tprofile2d") == 0 ) {
82 MEs_.push_back( tmp );
105 std::cout <<
"MonitorElementsDb: analyzed " <<
ievt_ <<
" events" << std::endl;
106 for(
unsigned int i = 0;
i<
MEs_.size();
i++ ) {
117 atLeastAQuery =
false;
119 std::vector<std::string> vars;
123 for(
unsigned int i=0;
i<
MEinfo_.size();
i++ ) {
135 atLeastAQuery =
true;
137 session->transaction().start(
true);
139 coral::ISchema&
schema = session->nominalSchema();
141 coral::IQuery*
query = schema.newQuery();
143 for(
unsigned int j=0;
j<
MEinfo_[
i].queries.size();
j++ ) {
144 if( strcmp(
MEinfo_[
i].queries[
j].query.c_str(),
"addToTableList") == 0 ) {
147 else if( strcmp(
MEinfo_[
i].queries[
j].query.c_str(),
"addToOutputList") == 0 ) {
149 vars.push_back(
MEinfo_[
i].queries[
j].alias );
151 else if( strcmp(
MEinfo_[
i].queries[
j].query.c_str(),
"setCondition") == 0 ) {
152 query->setCondition(
MEinfo_[
i].queries[
j].
arg, coral::AttributeList() );
154 else if( strcmp(
MEinfo_[
i].queries[
j].query.c_str(),
"addToOrderList") == 0 ) {
159 coral::ICursor& cursor = query->execute();
163 while ( cursor.next() && k <
MEinfo_[
i].loop ) {
166 const coral::AttributeList& row = cursor.currentRow();
168 std::vector<float> vvars;
170 for(
unsigned int l=0;
l<vars.size();
l++ ) {
172 vvars.push_back( row[vars[
l].c_str()].data<float>() );
175 if( vvars.size() == 2 ) {
177 MEs_[
i]->Fill( vvars[0], vvars[1] );
179 else if( vvars.size() == 3 ) {
181 MEs_[
i]->Fill( vvars[0], vvars[1], vvars[2] );
183 else if( vvars.size() == 4 ) {
185 MEs_[
i]->Fill( vvars[0], vvars[1], vvars[2], vvars[3] );
188 std::cerr <<
"Too many variables to plot..." << std::endl;
199 std::cerr <<
"CORAL Exception : " << e.what() << std::endl;
201 std::cerr <<
"Standard C++ exception : " << e.what() << std::endl;
207 if( atLeastAQuery ) session->transaction().commit();
215 gStyle->SetOptStat(0);
217 gStyle->SetPalette(1,0);
219 for(
unsigned int i=0;
i<
MEinfo_.size();
i++ ) {
227 c1 =
new TCanvas(
"c1",
"dummy", 400*n, 400 );
230 c1 =
new TCanvas(
"c1",
"dummy", 400, 400*n );
235 const double histMax = 1.e15;
239 if( dynamic_cast<TH1F*>( ob ) ) {
240 TH1F*
h =
dynamic_cast<TH1F*
> ( ob );
243 else if( dynamic_cast<TH2F*>( ob ) ) {
244 TH2F*
h =
dynamic_cast<TH2F*
>( ob );
245 if( h->GetMaximum(histMax) > 1.e4 ) {
252 else if( dynamic_cast<TProfile*>( ob ) ) {
253 TProfile*
h =
dynamic_cast<TProfile*
>( ob );
254 if( h->GetMaximum(histMax) > 1.e4 ) {
265 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")