CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Attributes | Friends
MonitorElementsDb Class Reference

#include <MonitorElementsDb.h>

Public Types

typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 

Public Member Functions

 MonitorElementsDb (const edm::ParameterSet &ps, std::string &xmlFile)
 Constructors. More...
 
virtual ~MonitorElementsDb ()
 Destructor. More...
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c, coral::ISessionProxy *s)
 Analyze. More...
 
void beginJob (void)
 
void endJob (void)
 
void htmlOutput (std::string &htmlDir)
 
void startSession (void)
 

Private Attributes

DQMStoredqmStore_
 
int ievt_
 
std::vector< DB_MEMEinfo_
 
std::vector< MonitorElement * > MEs_
 
MonitorXMLParserparser_
 
std::string prefixME_
 
std::string xmlFile_
 

Friends

class EcalBarrelMonitorDbModule
 

Detailed Description

Definition at line 24 of file MonitorElementsDb.h.

Member Typedef Documentation

◆ DQMStore

Definition at line 29 of file MonitorElementsDb.h.

◆ MonitorElement

Definition at line 28 of file MonitorElementsDb.h.

Constructor & Destructor Documentation

◆ MonitorElementsDb()

MonitorElementsDb::MonitorElementsDb ( const edm::ParameterSet ps,
std::string &  xmlFile 
)

Constructors.

Definition at line 32 of file MonitorElementsDb.cc.

References dqm::implementation::IBooker::book1D(), dqm::implementation::IBooker::book2D(), dqm::implementation::IBooker::bookProfile(), dqm::implementation::IBooker::bookProfile2D(), DMR_cfg::cerr, dqmStore_, MillePedeFileConverter_cfg::e, MonitorXMLParser::getDB_ME(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, ievt_, MonitorXMLParser::load(), MEinfo_, MEs_, Utilities::operator, parser_, prefixME_, dqm::implementation::DQMStore::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, runGCPTkAlMap::title, createJobs::tmp, fw3dlego::xbins, xmlFile_, and globals_cff::zbins.

32  {
33  xmlFile_ = xmlFile;
34 
36 
37  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
38 
39  if (dqmStore_) {
41 
43  try {
44  parser_->load();
45  } catch (std::runtime_error const &e) {
46  delete parser_;
47  parser_ = nullptr;
48  std::cerr << "Error loading parser: " << e.what() << std::endl;
49  }
50 
51  if (parser_)
53 
54  for (unsigned int i = 0; i < MEinfo_.size(); i++) {
56  tmp = nullptr;
57  if (strcmp(MEinfo_[i].type.c_str(), "th1d") == 0) {
59  } else if (strcmp(MEinfo_[i].type.c_str(), "th2d") == 0) {
61  MEinfo_[i].title,
62  MEinfo_[i].xbins,
63  MEinfo_[i].xfrom,
64  MEinfo_[i].xto,
65  MEinfo_[i].ybins,
66  MEinfo_[i].yfrom,
67  MEinfo_[i].yto);
68  } else if (strcmp(MEinfo_[i].type.c_str(), "tprofile") == 0) {
70  MEinfo_[i].title,
71  MEinfo_[i].xbins,
72  MEinfo_[i].xfrom,
73  MEinfo_[i].xto,
74  MEinfo_[i].ybins,
75  MEinfo_[i].yfrom,
76  MEinfo_[i].yto);
77  } else if (strcmp(MEinfo_[i].type.c_str(), "tprofile2d") == 0) {
79  MEinfo_[i].title,
80  MEinfo_[i].xbins,
81  MEinfo_[i].xfrom,
82  MEinfo_[i].xto,
83  MEinfo_[i].ybins,
84  MEinfo_[i].yfrom,
85  MEinfo_[i].yto,
86  MEinfo_[i].zbins,
87  MEinfo_[i].zfrom,
88  MEinfo_[i].zto);
89  }
90 
91  MEs_.push_back(tmp);
92  }
93  }
94 
95  ievt_ = 0;
96 }
MonitorElement * bookProfile2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, double lowZ, double highZ, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:476
const double xbins[]
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:647
T getUntrackedParameter(std::string const &, T const &) const
const std::vector< DB_ME > & getDB_ME(void) const
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:399
void load() noexcept(false)
std::vector< MonitorElement * > MEs_
std::vector< DB_ME > MEinfo_
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
tmp
align.sh
Definition: createJobs.py:716
MonitorXMLParser * parser_

◆ ~MonitorElementsDb()

MonitorElementsDb::~MonitorElementsDb ( )
virtual

Destructor.

Definition at line 98 of file MonitorElementsDb.cc.

References parser_.

98 { delete parser_; }
MonitorXMLParser * parser_

Member Function Documentation

◆ analyze()

void MonitorElementsDb::analyze ( const edm::Event e,
const edm::EventSetup c,
coral::ISessionProxy *  s 
)
protected

Analyze.

Definition at line 104 of file MonitorElementsDb.cc.

References SiStripOfflineCRack_cfg::alias, DMR_cfg::cerr, MillePedeFileConverter_cfg::e, relativeConstraints::empty, cppFunctionSkipper::exception, Exception, beamvalidation::exit(), mps_fire::i, ievt_, dqmiolumiharvest::j, dqmdumpme::k, MainPageGenerator::l, MEinfo_, MEs_, and contentValuesFiles::query.

Referenced by EcalBarrelMonitorDbModule::analyze().

104  {
105  ievt_++;
106 
107  bool atLeastAQuery;
108  atLeastAQuery = false;
109 
110  std::vector<std::string> vars;
111 
112  if (session) {
113  for (unsigned int i = 0; i < MEinfo_.size(); i++) {
114  // i-th ME...
115 
116  if (MEs_[i] != nullptr && (ievt_ % MEinfo_[i].ncycle) == 0) {
117  MEs_[i]->Reset();
118 
119  vars.clear();
120 
121  try {
122  atLeastAQuery = true;
123 
124  session->transaction().start(true);
125 
126  coral::ISchema &schema = session->nominalSchema();
127 
128  coral::IQuery *query = schema.newQuery();
129 
130  for (unsigned int j = 0; j < MEinfo_[i].queries.size(); j++) {
131  if (strcmp(MEinfo_[i].queries[j].query.c_str(), "addToTableList") == 0) {
132  query->addToTableList(MEinfo_[i].queries[j].arg);
133  } else if (strcmp(MEinfo_[i].queries[j].query.c_str(), "addToOutputList") == 0) {
134  query->addToOutputList(MEinfo_[i].queries[j].arg, MEinfo_[i].queries[j].alias);
135  vars.push_back(MEinfo_[i].queries[j].alias);
136  } else if (strcmp(MEinfo_[i].queries[j].query.c_str(), "setCondition") == 0) {
137  query->setCondition(MEinfo_[i].queries[j].arg, coral::AttributeList());
138  } else if (strcmp(MEinfo_[i].queries[j].query.c_str(), "addToOrderList") == 0) {
139  query->addToOrderList(MEinfo_[i].queries[j].arg);
140  }
141  }
142 
143  coral::ICursor &cursor = query->execute();
144 
145  unsigned int k = 0;
146 
147  while (cursor.next() && k < MEinfo_[i].loop) {
148  // while ( cursor.next() ) {
149 
150  const coral::AttributeList &row = cursor.currentRow();
151 
152  std::vector<float> vvars;
153  vvars.clear();
154  for (unsigned int l = 0; l < vars.size(); l++) {
155  if (!vars[l].empty()) {
156  vvars.push_back(row[vars[l]].data<float>());
157  }
158  }
159  if (vvars.size() == 2) {
160  // std::cout << k << " -- " << vvars[0] << " -- " << vvars[1] <<
161  // std::endl;
162  MEs_[i]->Fill(vvars[0], vvars[1]);
163  } else if (vvars.size() == 3) {
164  // std::cout << k << " -- " << vvars[0] << " -- " << vvars[1] << "
165  // -- " << vvars[2] << std::endl;
166  MEs_[i]->Fill(vvars[0], vvars[1], vvars[2]);
167  } else if (vvars.size() == 4) {
168  // std::cout << k << " -- " << vvars[0] << " -- " << vvars[1] << "
169  // -- " << vvars[2] << " -- " << vvars[3] << std::endl;
170  MEs_[i]->Fill(vvars[0], vvars[1], vvars[2], vvars[3]);
171  } else {
172  std::cerr << "Too many variables to plot..." << std::endl;
173  exit(1);
174  }
175 
176  k++;
177  }
178 
179  delete query;
180 
181  } catch (coral::Exception &e) {
182  std::cerr << "CORAL Exception : " << e.what() << std::endl;
183  } catch (std::exception &e) {
184  std::cerr << "Standard C++ exception : " << e.what() << std::endl;
185  }
186  }
187  }
188 
189  if (atLeastAQuery)
190  session->transaction().commit();
191  }
192 }
vars
Definition: DeepTauIdBase.h:60
A arg
Definition: Factorize.h:31
Definition: query.py:1
std::vector< MonitorElement * > MEs_
std::vector< DB_ME > MEinfo_
def exit(msg="")

◆ beginJob()

void MonitorElementsDb::beginJob ( void  )
protected

Definition at line 100 of file MonitorElementsDb.cc.

References ievt_.

Referenced by EcalBarrelMonitorDbModule::beginJob().

100 { ievt_ = 0; }

◆ endJob()

void MonitorElementsDb::endJob ( void  )
protected

Definition at line 102 of file MonitorElementsDb.cc.

References gather_cfg::cout, and ievt_.

Referenced by EcalBarrelMonitorDbModule::endJob().

102 { std::cout << "MonitorElementsDb: analyzed " << ievt_ << " events" << std::endl; }

◆ htmlOutput()

void MonitorElementsDb::htmlOutput ( std::string &  htmlDir)
protected

Definition at line 194 of file MonitorElementsDb.cc.

References alignmentValidation::c1, h, mps_fire::i, ievt_, createfilelist::int, MEinfo_, MEs_, dqmiodumpmetadata::n, Skims_PA_cff::name, AlCaHLTBitMon_QueryRunRegistry::string, and fw3dlego::xbins.

Referenced by EcalBarrelMonitorDbModule::analyze().

194  {
195  gStyle->SetOptStat(0);
196  gStyle->SetOptFit();
197  gStyle->SetPalette(1, nullptr);
198 
199  for (unsigned int i = 0; i < MEinfo_.size(); i++) {
200  if (MEs_[i] != nullptr && (ievt_ % MEinfo_[i].ncycle) == 0) {
201  TCanvas *c1;
202  int n = MEinfo_[i].xbins > MEinfo_[i].ybins ? int(round(float(MEinfo_[i].xbins) / float(MEinfo_[i].ybins)))
203  : int(round(float(MEinfo_[i].ybins) / float(MEinfo_[i].xbins)));
204  if (MEinfo_[i].xbins > MEinfo_[i].ybins) {
205  c1 = new TCanvas("c1", "dummy", 400 * n, 400);
206  } else {
207  c1 = new TCanvas("c1", "dummy", 400, 400 * n);
208  }
209  c1->SetGrid();
210  c1->cd();
211 
212  const double histMax = 1.e15;
213 
214  TObject *ob = const_cast<MonitorElement *>(MEs_[i])->getRootObject();
215  if (ob) {
216  if (dynamic_cast<TH1F *>(ob)) {
217  TH1F *h = dynamic_cast<TH1F *>(ob);
218  h->Draw();
219  } else if (dynamic_cast<TH2F *>(ob)) {
220  TH2F *h = dynamic_cast<TH2F *>(ob);
221  if (h->GetMaximum(histMax) > 1.e4) {
222  gPad->SetLogz(1);
223  } else {
224  gPad->SetLogz(0);
225  }
226  h->Draw("colz");
227  } else if (dynamic_cast<TProfile *>(ob)) {
228  TProfile *h = dynamic_cast<TProfile *>(ob);
229  if (h->GetMaximum(histMax) > 1.e4) {
230  gPad->SetLogz(1);
231  } else {
232  gPad->SetLogz(0);
233  }
234  h->Draw("colz");
235  }
236  }
237 
238  c1->Update();
239  std::string name = htmlDir + "/" + MEinfo_[i].title + ".png";
240  c1->SaveAs(name.c_str());
241 
242  delete c1;
243  }
244  }
245 }
const double xbins[]
std::vector< MonitorElement * > MEs_
std::vector< DB_ME > MEinfo_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ startSession()

void MonitorElementsDb::startSession ( void  )
protected

Friends And Related Function Documentation

◆ EcalBarrelMonitorDbModule

friend class EcalBarrelMonitorDbModule
friend

Definition at line 25 of file MonitorElementsDb.h.

Member Data Documentation

◆ dqmStore_

DQMStore* MonitorElementsDb::dqmStore_
private

Definition at line 59 of file MonitorElementsDb.h.

Referenced by MonitorElementsDb().

◆ ievt_

int MonitorElementsDb::ievt_
private

Definition at line 58 of file MonitorElementsDb.h.

Referenced by analyze(), beginJob(), endJob(), htmlOutput(), and MonitorElementsDb().

◆ MEinfo_

std::vector<DB_ME> MonitorElementsDb::MEinfo_
private

Definition at line 56 of file MonitorElementsDb.h.

Referenced by analyze(), htmlOutput(), and MonitorElementsDb().

◆ MEs_

std::vector<MonitorElement *> MonitorElementsDb::MEs_
private

Definition at line 57 of file MonitorElementsDb.h.

Referenced by analyze(), htmlOutput(), and MonitorElementsDb().

◆ parser_

MonitorXMLParser* MonitorElementsDb::parser_
private

◆ prefixME_

std::string MonitorElementsDb::prefixME_
private

Definition at line 53 of file MonitorElementsDb.h.

Referenced by MonitorElementsDb().

◆ xmlFile_

std::string MonitorElementsDb::xmlFile_
private

Definition at line 54 of file MonitorElementsDb.h.

Referenced by MonitorElementsDb().