17 #include "RelationalAccess/ICursor.h" 18 #include "RelationalAccess/IQuery.h" 19 #include "RelationalAccess/ISchema.h" 20 #include "RelationalAccess/ITransaction.h" 22 #include "CoralBase/Attribute.h" 23 #include "CoralBase/AttributeList.h" 47 }
catch (std::runtime_error
const &
e) {
50 std::cerr <<
"Error loading parser: " << e.what() << std::endl;
56 for (
unsigned int i = 0;
i <
MEinfo_.size();
i++) {
61 }
else if (strcmp(
MEinfo_[
i].
type.c_str(),
"th2d") == 0) {
70 }
else if (strcmp(
MEinfo_[
i].
type.c_str(),
"tprofile") == 0) {
79 }
else if (strcmp(
MEinfo_[
i].
type.c_str(),
"tprofile2d") == 0) {
105 std::cout <<
"MonitorElementsDb: analyzed " <<
ievt_ <<
" events" << std::endl;
106 for (
unsigned int i = 0;
i <
MEs_.size();
i++) {
107 if (
MEs_[
i] !=
nullptr)
116 atLeastAQuery =
false;
118 std::vector<std::string> vars;
121 for (
unsigned int i = 0;
i <
MEinfo_.size();
i++) {
130 atLeastAQuery =
true;
132 session->transaction().start(
true);
134 coral::ISchema &
schema = session->nominalSchema();
136 coral::IQuery *
query = schema.newQuery();
138 for (
unsigned int j = 0; j <
MEinfo_[
i].queries.size(); j++) {
139 if (strcmp(
MEinfo_[
i].queries[j].query.c_str(),
"addToTableList") == 0) {
141 }
else if (strcmp(
MEinfo_[
i].queries[j].query.c_str(),
"addToOutputList") == 0) {
143 vars.push_back(
MEinfo_[
i].queries[j].alias);
144 }
else if (strcmp(
MEinfo_[
i].queries[j].query.c_str(),
"setCondition") == 0) {
145 query->setCondition(
MEinfo_[
i].queries[j].
arg, coral::AttributeList());
146 }
else if (strcmp(
MEinfo_[
i].queries[j].query.c_str(),
"addToOrderList") == 0) {
151 coral::ICursor &cursor = query->execute();
155 while (cursor.next() && k <
MEinfo_[
i].loop) {
158 const coral::AttributeList &row = cursor.currentRow();
160 std::vector<float> vvars;
162 for (
unsigned int l = 0;
l < vars.size();
l++) {
164 vvars.push_back(row[vars[
l]].data<float>());
167 if (vvars.size() == 2) {
170 MEs_[
i]->Fill(vvars[0], vvars[1]);
171 }
else if (vvars.size() == 3) {
174 MEs_[
i]->Fill(vvars[0], vvars[1], vvars[2]);
175 }
else if (vvars.size() == 4) {
178 MEs_[
i]->Fill(vvars[0], vvars[1], vvars[2], vvars[3]);
180 std::cerr <<
"Too many variables to plot..." << std::endl;
190 std::cerr <<
"CORAL Exception : " << e.what() << std::endl;
192 std::cerr <<
"Standard C++ exception : " << e.what() << std::endl;
198 session->transaction().commit();
203 gStyle->SetOptStat(0);
205 gStyle->SetPalette(1,
nullptr);
207 for (
unsigned int i = 0;
i <
MEinfo_.size();
i++) {
213 c1 =
new TCanvas(
"c1",
"dummy", 400 * n, 400);
215 c1 =
new TCanvas(
"c1",
"dummy", 400, 400 * n);
220 const double histMax = 1.e15;
224 if (dynamic_cast<TH1F *>(ob)) {
225 TH1F *
h =
dynamic_cast<TH1F *
>(ob);
227 }
else if (dynamic_cast<TH2F *>(ob)) {
228 TH2F *
h =
dynamic_cast<TH2F *
>(ob);
229 if (h->GetMaximum(histMax) > 1.e4) {
235 }
else if (dynamic_cast<TProfile *>(ob)) {
236 TProfile *
h =
dynamic_cast<TProfile *
>(ob);
237 if (h->GetMaximum(histMax) > 1.e4) {
248 c1->SaveAs(name.c_str());
MonitorElement * book2D(char_string const &name, char_string const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
MonitorElement * bookProfile2D(char_string const &name, char_string const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, double lowZ, double highZ, char const *option="s")
T getUntrackedParameter(std::string const &, T const &) const
MonitorElementsDb(const edm::ParameterSet &ps, std::string &xmlFile)
Constructors.
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void removeElement(std::string const &name)
const std::vector< DB_ME > & getDB_ME(void) const
MonitorElement * book1D(char_string const &name, char_string const &title, int const nchX, double const lowX, double const highX)
Book 1D histogram.
Generate a Monitor Element from DB data.
def query(query_str, verbose=False)
void analyze(const edm::Event &e, const edm::EventSetup &c, coral::ISessionProxy *s)
Analyze.
void load() noexcept(false)
std::vector< MonitorElement * > MEs_
std::vector< DB_ME > MEinfo_
TString getName(TString structure, int layer, TString geometry)
void setCurrentFolder(std::string const &fullpath)
MonitorElement * bookProfile(char_string const &name, char_string const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, char const *option="s")
std::vector< std::vector< double > > tmp
virtual ~MonitorElementsDb()
Destructor.
void htmlOutput(std::string &htmlDir)
MonitorXMLParser * parser_