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 25 of file MonitorElementsDb.h.

Member Typedef Documentation

◆ DQMStore

Definition at line 30 of file MonitorElementsDb.h.

◆ MonitorElement

Definition at line 29 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.

32  {
33  xmlFile_ = xmlFile;
34 
35  dqmStore_ = edm::Service<DQMStore>().operator->();
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 }

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

◆ ~MonitorElementsDb()

MonitorElementsDb::~MonitorElementsDb ( )
virtual

Destructor.

Definition at line 98 of file MonitorElementsDb.cc.

98 { delete parser_; }

References 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.

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 }

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

Referenced by EcalBarrelMonitorDbModule::analyze().

◆ beginJob()

void MonitorElementsDb::beginJob ( void  )
protected

Definition at line 100 of file MonitorElementsDb.cc.

100 { ievt_ = 0; }

References ievt_.

Referenced by EcalBarrelMonitorDbModule::beginJob().

◆ endJob()

void MonitorElementsDb::endJob ( void  )
protected

Definition at line 102 of file MonitorElementsDb.cc.

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

References gather_cfg::cout, and ievt_.

Referenced by EcalBarrelMonitorDbModule::endJob().

◆ htmlOutput()

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

Definition at line 194 of file MonitorElementsDb.cc.

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 }

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

Referenced by EcalBarrelMonitorDbModule::analyze().

◆ startSession()

void MonitorElementsDb::startSession ( void  )
protected

Friends And Related Function Documentation

◆ EcalBarrelMonitorDbModule

friend class EcalBarrelMonitorDbModule
friend

Definition at line 26 of file MonitorElementsDb.h.

Member Data Documentation

◆ dqmStore_

DQMStore* MonitorElementsDb::dqmStore_
private

Definition at line 60 of file MonitorElementsDb.h.

Referenced by MonitorElementsDb().

◆ ievt_

int MonitorElementsDb::ievt_
private

Definition at line 59 of file MonitorElementsDb.h.

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

◆ MEinfo_

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

Definition at line 57 of file MonitorElementsDb.h.

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

◆ MEs_

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

Definition at line 58 of file MonitorElementsDb.h.

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

◆ parser_

MonitorXMLParser* MonitorElementsDb::parser_
private

◆ prefixME_

std::string MonitorElementsDb::prefixME_
private

Definition at line 54 of file MonitorElementsDb.h.

Referenced by MonitorElementsDb().

◆ xmlFile_

std::string MonitorElementsDb::xmlFile_
private

Definition at line 55 of file MonitorElementsDb.h.

Referenced by MonitorElementsDb().

runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
fw3dlego::xbins
const double xbins[]
Definition: fw3dlego_xbins.cc:16
mps_fire.i
i
Definition: mps_fire.py:428
MonitorElementsDb::MEinfo_
std::vector< DB_ME > MEinfo_
Definition: MonitorElementsDb.h:57
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
dqm::implementation::IBooker::bookProfile2D
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:399
gather_cfg.cout
cout
Definition: gather_cfg.py:144
MonitorXMLParser
Definition: MonitorXMLParser.h:154
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
MonitorElementsDb::MEs_
std::vector< MonitorElement * > MEs_
Definition: MonitorElementsDb.h:58
MonitorXMLParser::load
void load() noexcept(false)
Definition: MonitorXMLParser.cc:402
globals_cff.zbins
zbins
Definition: globals_cff.py:17
query
Definition: query.py:1
vars
vars
Definition: DeepTauId.cc:159
dqm::implementation::IBooker::bookProfile
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:322
dqm::implementation::DQMStore::setCurrentFolder
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
h
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
MonitorElementsDb::dqmStore_
DQMStore * dqmStore_
Definition: MonitorElementsDb.h:60
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
edm::Service
Definition: Service.h:30
createfilelist.int
int
Definition: createfilelist.py:10
alignmentValidation.c1
c1
do drawing
Definition: alignmentValidation.py:1025
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
MonitorXMLParser::getDB_ME
const std::vector< DB_ME > & getDB_ME(void) const
Definition: MonitorXMLParser.h:167
dqm::implementation::IBooker::book2D
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:177
SiStripOfflineCRack_cfg.alias
alias
Definition: SiStripOfflineCRack_cfg.py:128
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
Exception
Definition: hltDiff.cc:246
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
funct::arg
A arg
Definition: Factorize.h:31
contentValuesFiles.query
query
Definition: contentValuesFiles.py:38
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
MonitorElementsDb::parser_
MonitorXMLParser * parser_
Definition: MonitorElementsDb.h:56
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
MonitorElementsDb::prefixME_
std::string prefixME_
Definition: MonitorElementsDb.h:54
MonitorElementsDb::xmlFile_
std::string xmlFile_
Definition: MonitorElementsDb.h:55
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
MonitorElementsDb::ievt_
int ievt_
Definition: MonitorElementsDb.h:59