CMS 3D CMS Logo

GEMDQMHarvester.cc
Go to the documentation of this file.
10 
11 //DQM services
16 
17 #include <TH2F.h>
18 #include <TFile.h>
19 #include <TDirectoryFile.h>
20 #include <TKey.h>
21 
22 using namespace edm;
23 
25 public:
27  ~GEMDQMHarvester() override{};
28  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
29 
30 protected:
31  void dqmEndLuminosityBlock(DQMStore::IBooker &,
33  edm::LuminosityBlock const &,
34  edm::EventSetup const &) override;
35  void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override{}; // Cannot use; it is called after dqmSaver
36 
37  void drawSummaryHistogram(edm::Service<DQMStore> &store);
38  void copyLabels(MonitorElement *h2Src, MonitorElement *h2Dst);
39  void createSummaryHist(edm::Service<DQMStore> &store,
40  MonitorElement *h2Src,
41  MonitorElement *&h2Sum,
42  std::vector<std::string> &listLayers);
43  void createSummaryVFAT(edm::Service<DQMStore> &store,
44  MonitorElement *h2Src,
45  std::string strSuffix,
46  MonitorElement *&h2Sum);
47  Float_t refineSummaryHistogram(MonitorElement *h2Sum,
48  MonitorElement *h2SrcOcc,
49  MonitorElement *h2SrcStatusE,
50  MonitorElement *h2SrcStatusW = nullptr,
51  Bool_t bVarXBin = false);
52 
53  Float_t fReportSummary_;
55 
59 
60  std::vector<std::string> listLayer_;
61 };
62 
64  fReportSummary_ = -1.0;
65  strOutFile_ = cfg.getParameter<std::string>("fromFile");
66  strDirSummary_ = "GEM/EventInfo";
67  strDirRecHit_ = "GEM/RecHits";
68  strDirStatus_ = "GEM/DAQStatus";
69 }
70 
73  desc.add<std::string>("fromFile", "");
74  descriptions.add("GEMDQMHarvester", desc);
75 }
76 
79  edm::LuminosityBlock const &,
80  edm::EventSetup const &) {
82  drawSummaryHistogram(store);
83 }
84 
86  std::string strSrcDigiOcc = "GEM/Digis/summaryOccDigi";
87  std::string strSrcStatusW = "GEM/DAQStatus/chamberWarnings";
88  std::string strSrcStatusE = "GEM/DAQStatus/chamberErrors";
89 
90  std::string strSrcVFATOcc = "GEM/Digis/det";
91  std::string strSrcVFATStatusW = "GEM/DAQStatus/vfat_statusWarnSum";
92  std::string strSrcVFATStatusE = "GEM/DAQStatus/vfat_statusErrSum";
93 
94  store->setCurrentFolder(strDirSummary_);
95 
96  MonitorElement *h2SrcDigiOcc = store->get(strSrcDigiOcc);
97  MonitorElement *h2SrcStatusW = store->get(strSrcStatusW);
98  MonitorElement *h2SrcStatusE = store->get(strSrcStatusE);
99 
100  if (h2SrcDigiOcc != nullptr && h2SrcStatusW != nullptr && h2SrcStatusE != nullptr) {
101  MonitorElement *h2Sum = nullptr;
102  createSummaryHist(store, h2SrcStatusE, h2Sum, listLayer_);
103  fReportSummary_ = refineSummaryHistogram(h2Sum, h2SrcDigiOcc, h2SrcStatusE, h2SrcStatusW, true);
104 
105  for (const auto &strSuffix : listLayer_) {
106  MonitorElement *h2SrcVFATOcc = store->get(strSrcVFATOcc + strSuffix);
107  MonitorElement *h2SrcVFATStatusW = store->get(strSrcVFATStatusW + strSuffix);
108  MonitorElement *h2SrcVFATStatusE = store->get(strSrcVFATStatusE + strSuffix);
109  if (h2SrcVFATOcc == nullptr || h2SrcVFATStatusW == nullptr || h2SrcVFATStatusE == nullptr)
110  continue;
111  MonitorElement *h2SumVFAT = nullptr;
112  createSummaryVFAT(store, h2SrcVFATStatusE, strSuffix, h2SumVFAT);
113  refineSummaryHistogram(h2SumVFAT, h2SrcVFATOcc, h2SrcVFATStatusE, h2SrcVFATStatusW);
114  TString strNewTitle = h2SrcVFATStatusE->getTitle();
115  h2SumVFAT->setTitle((const char *)strNewTitle.ReplaceAll("errors", "errors/warnings"));
116  h2SumVFAT->setXTitle(h2SrcVFATStatusE->getAxisTitle(1));
117  h2SumVFAT->setYTitle(h2SrcVFATStatusE->getAxisTitle(2));
118  }
119  }
120 
121  store->bookFloat("reportSummary")->Fill(fReportSummary_);
122 }
123 
125  Int_t nBinX = h2Src->getNbinsX(), nBinY = h2Src->getNbinsY();
126 
127  for (Int_t i = 1; i <= nBinX; i++) {
128  h2Dst->setBinLabel(i, h2Src->getTH2F()->GetXaxis()->GetBinLabel(i), 1);
129  }
130  for (Int_t i = 1; i <= nBinY; i++) {
131  h2Dst->setBinLabel(i, h2Src->getTH2F()->GetYaxis()->GetBinLabel(i), 2);
132  }
133  h2Dst->setTitle(h2Src->getTitle());
134  h2Dst->setXTitle(h2Src->getAxisTitle(1));
135  h2Dst->setYTitle(h2Src->getAxisTitle(2));
136 }
137 
139  MonitorElement *h2Src,
140  MonitorElement *&h2Sum,
141  std::vector<std::string> &listLayers) {
142  //store->setCurrentFolder(strDirSummary_);
143 
144  Int_t nBinX = h2Src->getNbinsX(), nBinY = h2Src->getNbinsY();
145  h2Sum = store->book2D("reportSummaryMap", "", nBinX, 0.5, nBinX + 0.5, nBinY, 0.5, nBinY + 0.5);
146  h2Sum->setTitle("Summary plot");
147  h2Sum->setXTitle("Chamber");
148  h2Sum->setYTitle("Layer");
149 
150  listLayers.clear();
151  for (Int_t i = 1; i <= nBinX; i++)
152  h2Sum->setBinLabel(i, h2Src->getTH2F()->GetXaxis()->GetBinLabel(i), 1);
153  for (Int_t i = 1; i <= nBinY; i++) {
154  std::string strLabelFull = h2Src->getTH2F()->GetYaxis()->GetBinLabel(i);
155  auto nPos = strLabelFull.find(';');
156  auto strLabel = strLabelFull.substr(0, nPos);
157  listLayers.push_back(strLabelFull.substr(nPos + 1));
158  h2Sum->setBinLabel(i, strLabel, 2);
159  }
160 }
161 
163  MonitorElement *h2Src,
164  std::string strSuffix,
165  MonitorElement *&h2Sum) {
166  //store->setCurrentFolder(strDirStatus_);
167  //store->setCurrentFolder(strDirSummary_);
168 
169  Int_t nBinX = h2Src->getNbinsX(), nBinY = h2Src->getNbinsY();
170  h2Sum = store->book2D("vfat_statusSummary" + strSuffix, "", nBinX, 0.5, nBinX + 0.5, nBinY, -0.5, nBinY - 0.5);
171  copyLabels(h2Src, h2Sum);
172 }
173 
174 // FIXME: Need more study about how to summarize
176  MonitorElement *h2SrcOcc,
177  MonitorElement *h2SrcStatusE,
178  MonitorElement *h2SrcStatusW,
179  Bool_t bVarXBin) {
180  Int_t nBinY = h2Sum->getNbinsY();
181  Int_t nAllBin = 0, nFineBin = 0;
182  for (Int_t j = 1; j <= nBinY; j++) {
183  Int_t nBinX = h2Sum->getNbinsX();
184  if (bVarXBin) {
185  nBinX = (Int_t)(h2SrcOcc->getBinContent(0, j) + 0.5);
186  h2Sum->setBinContent(0, j, nBinX);
187  }
188  for (Int_t i = 1; i <= nBinX; i++) {
189  Float_t fOcc = h2SrcOcc->getBinContent(i, j);
190  Float_t fStatusWarn = (h2SrcStatusW != nullptr ? h2SrcStatusW->getBinContent(i, j) : 0.0);
191  Float_t fStatusErr = h2SrcStatusE->getBinContent(i, j);
192 
193  Float_t fRes = 0;
194  if (fStatusErr > 0)
195  fRes = 2;
196  else if (fStatusWarn > 0)
197  fRes = 3;
198  else if (fOcc > 0) {
199  fRes = 1;
200  nFineBin++;
201  }
202 
203  h2Sum->setBinContent(i, j, fRes);
204  nAllBin++;
205  }
206  }
207 
208  return ((Float_t)nFineBin) / nAllBin;
209 }
210 
DQMEDHarvester.h
GEMDQMHarvester::drawSummaryHistogram
void drawSummaryHistogram(edm::Service< DQMStore > &store)
Definition: GEMDQMHarvester.cc:85
GEMDQMHarvester::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: GEMDQMHarvester.cc:71
mps_fire.i
i
Definition: mps_fire.py:428
GEMDQMHarvester::fReportSummary_
Float_t fReportSummary_
Definition: GEMDQMHarvester.cc:53
MessageLogger.h
dqm::implementation::IBooker::bookFloat
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
dqm::impl::MonitorElement::setTitle
virtual void setTitle(const std::string &title)
set (ie. change) histogram/profile title
Definition: MonitorElement.cc:809
GEMDQMHarvester::strOutFile_
std::string strOutFile_
Definition: GEMDQMHarvester.cc:54
ESHandle.h
GEMDQMHarvester::dqmEndLuminosityBlock
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: GEMDQMHarvester.cc:77
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm
HLT enums.
Definition: AlignableModifier.h:19
dqm::impl::MonitorElement::getAxisTitle
virtual std::string getAxisTitle(int axis=1) const
get x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:668
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
EDAnalyzer.h
GEMDQMHarvester
Definition: GEMDQMHarvester.cc:24
GEMDQMHarvester::strDirRecHit_
std::string strDirRecHit_
Definition: GEMDQMHarvester.cc:57
MakerMacros.h
GEMDQMHarvester::strDirSummary_
std::string strDirSummary_
Definition: GEMDQMHarvester.cc:56
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
GEMDQMHarvester::refineSummaryHistogram
Float_t refineSummaryHistogram(MonitorElement *h2Sum, MonitorElement *h2SrcOcc, MonitorElement *h2SrcStatusE, MonitorElement *h2SrcStatusW=nullptr, Bool_t bVarXBin=false)
Definition: GEMDQMHarvester.cc:175
Service.h
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
GEMDQMHarvester::~GEMDQMHarvester
~GEMDQMHarvester() override
Definition: GEMDQMHarvester.cc:27
Run.h
GEMDQMHarvester::strDirStatus_
std::string strDirStatus_
Definition: GEMDQMHarvester.cc:58
dqm::implementation::DQMStore::setCurrentFolder
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
dqm::impl::MonitorElement::setXTitle
virtual void setXTitle(std::string const &title)
Definition: MonitorElement.cc:852
GEMDQMHarvester::createSummaryVFAT
void createSummaryVFAT(edm::Service< DQMStore > &store, MonitorElement *h2Src, std::string strSuffix, MonitorElement *&h2Sum)
Definition: GEMDQMHarvester.cc:162
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
GEMDQMHarvester::GEMDQMHarvester
GEMDQMHarvester(const edm::ParameterSet &)
Definition: GEMDQMHarvester.cc:63
anotherprimaryvertexanalyzer_cfi.nBinY
nBinY
Definition: anotherprimaryvertexanalyzer_cfi.py:13
MonitorElement.h
edm::ParameterSet
Definition: ParameterSet.h:47
dqm::impl::MonitorElement::getNbinsY
virtual int getNbinsY() const
get # of bins in Y-axis
Definition: MonitorElement.cc:571
Event.h
edm::Service
Definition: Service.h:30
dqm::impl::MonitorElement::setYTitle
virtual void setYTitle(std::string const &title)
Definition: MonitorElement.cc:857
dqm::impl::MonitorElement::setBinLabel
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:762
GEMDQMHarvester::createSummaryHist
void createSummaryHist(edm::Service< DQMStore > &store, MonitorElement *h2Src, MonitorElement *&h2Sum, std::vector< std::string > &listLayers)
Definition: GEMDQMHarvester.cc:138
edm::EventSetup
Definition: EventSetup.h:58
dqm::impl::MonitorElement::getTitle
virtual std::string getTitle() const
get MonitorElement title
Definition: MonitorElement.cc:674
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
looper.cfg
cfg
Definition: looper.py:296
DQMEDHarvester
Definition: DQMEDHarvester.py:1
dqm::impl::MonitorElement::setBinContent
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
Definition: MonitorElement.cc:682
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
Frameworkfwd.h
dqm::implementation::IGetter
Definition: DQMStore.h:484
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
dqm::impl::MonitorElement::getNbinsX
virtual int getNbinsX() const
get # of bins in X-axis
Definition: MonitorElement.cc:565
anotherprimaryvertexanalyzer_cfi.nBinX
nBinX
Definition: anotherprimaryvertexanalyzer_cfi.py:12
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
EventSetup.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
GEMDQMHarvester::listLayer_
std::vector< std::string > listLayer_
Definition: GEMDQMHarvester.cc:60
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
GEMDQMHarvester::dqmEndJob
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: GEMDQMHarvester.cc:35
dqm::impl::MonitorElement::getBinContent
virtual double getBinContent(int binx) const
get content of bin (1-D)
Definition: MonitorElement.cc:583
GEMDQMHarvester::copyLabels
void copyLabels(MonitorElement *h2Src, MonitorElement *h2Dst)
Definition: GEMDQMHarvester.cc:124
dqm::legacy::MonitorElement::getTH2F
virtual TH2F * getTH2F() const
Definition: MonitorElement.h:491