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 createSummaryHist(edm::Service<DQMStore> &store,
39  MonitorElement *h2Src,
40  MonitorElement *&h2Sum,
41  std::vector<std::string> &listLayers);
42  void createSummaryVFAT(edm::Service<DQMStore> &store,
43  MonitorElement *h2Src,
44  std::string strSuffix,
45  MonitorElement *&h2Sum);
46  void refineSummaryHistogram(MonitorElement *h2Sum,
47  MonitorElement *h2SrcOcc,
48  MonitorElement *h2SrcCStatus,
49  MonitorElement *h2SrcMal = nullptr,
50  Bool_t bVarXBin = false);
51 
52  Float_t fReportSummary_;
54 
57 };
58 
60  fReportSummary_ = -1.0;
61  strOutFile_ = cfg.getParameter<std::string>("fromFile");
62  strDirSummary_ = "GEM/EventInfo";
63  strDirStatus_ = "GEM/DAQStatus";
64 }
65 
68  desc.add<std::string>("fromFile", "");
69  descriptions.add("GEMDQMHarvester", desc);
70 }
71 
74  edm::LuminosityBlock const &,
75  edm::EventSetup const &) {
77  drawSummaryHistogram(store);
78 }
79 
81  std::string strSrcDigiOcc = "GEM/digi/summaryOccDigi";
82  std::string strSrcDigiMal = "GEM/digi/summaryMalfuncDigi";
83  std::string strSrcCStatus = "GEM/DAQStatus/summaryStatus";
84 
85  std::string strSrcVFATOcc = "GEM/digi/digi_det";
86  std::string strSrcVFATStatus = "GEM/DAQStatus/vfat_statusSum";
87 
88  store->setCurrentFolder(strDirSummary_);
89 
90  MonitorElement *h2SrcDigiOcc = store->get(strSrcDigiOcc);
91  MonitorElement *h2SrcDigiMal = store->get(strSrcDigiMal);
92  MonitorElement *h2SrcCStatus = store->get(strSrcCStatus);
93 
94  if (h2SrcDigiOcc != nullptr && h2SrcDigiMal != nullptr && h2SrcCStatus != nullptr) {
95  MonitorElement *h2Sum = nullptr;
96  std::vector<std::string> listLayer;
97  createSummaryHist(store, h2SrcCStatus, h2Sum, listLayer);
98  refineSummaryHistogram(h2Sum, h2SrcDigiOcc, h2SrcCStatus, h2SrcDigiMal, true);
99 
100  for (const auto &strSuffix : listLayer) {
101  MonitorElement *h2SrcVFATOcc = store->get(strSrcVFATOcc + strSuffix);
102  MonitorElement *h2SrcVFATStatus = store->get(strSrcVFATStatus + strSuffix);
103  if (h2SrcVFATOcc == nullptr || h2SrcVFATStatus == nullptr)
104  continue;
105  MonitorElement *h2SumVFAT = nullptr;
106  createSummaryVFAT(store, h2SrcVFATStatus, strSuffix, h2SumVFAT);
107  refineSummaryHistogram(h2SumVFAT, h2SrcVFATOcc, h2SrcVFATStatus);
108  h2SumVFAT->setTitle(h2SrcVFATStatus->getTitle());
109  h2SumVFAT->setXTitle(h2SrcVFATStatus->getAxisTitle(1));
110  h2SumVFAT->setYTitle(h2SrcVFATStatus->getAxisTitle(2));
111  }
112  }
113 
114  store->bookFloat("reportSummary")->Fill(fReportSummary_);
115 }
116 
118  MonitorElement *h2Src,
119  MonitorElement *&h2Sum,
120  std::vector<std::string> &listLayers) {
121  store->setCurrentFolder(strDirSummary_);
122 
123  Int_t nBinX = h2Src->getNbinsX(), nBinY = h2Src->getNbinsY();
124  h2Sum = store->book2D("reportSummaryMap", "", nBinX, 0.5, nBinX + 0.5, nBinY, 0.5, nBinY + 0.5);
125 
126  listLayers.clear();
127  for (Int_t i = 1; i <= nBinX; i++)
128  h2Sum->setBinLabel(i, h2Src->getTH2F()->GetXaxis()->GetBinLabel(i), 1);
129  for (Int_t i = 1; i <= nBinY; i++) {
130  std::string strLabelFull = h2Src->getTH2F()->GetYaxis()->GetBinLabel(i);
131  auto nPos = strLabelFull.find(';');
132  auto strLabel = strLabelFull.substr(0, nPos);
133  listLayers.push_back(strLabelFull.substr(nPos + 1));
134  h2Sum->setBinLabel(i, strLabel, 2);
135  }
136 }
137 
139  MonitorElement *h2Src,
140  std::string strSuffix,
141  MonitorElement *&h2Sum) {
142  store->setCurrentFolder(strDirStatus_);
143 
144  Int_t nBinX = h2Src->getNbinsX(), nBinY = h2Src->getNbinsY();
145  h2Sum = store->book2D("vfat_statusSummary" + strSuffix, "", nBinX, 0.5, nBinX + 0.5, nBinY, 0.5, nBinY + 0.5);
146 
147  for (Int_t i = 1; i <= nBinX; i++)
148  h2Sum->setBinLabel(i, h2Src->getTH2F()->GetXaxis()->GetBinLabel(i), 1);
149  for (Int_t i = 1; i <= nBinY; i++)
150  h2Sum->setBinLabel(i, h2Src->getTH2F()->GetYaxis()->GetBinLabel(i), 2);
151 }
152 
153 // FIXME: Need more study about how to summarize
155  MonitorElement *h2SrcOcc,
156  MonitorElement *h2SrcCStatus,
157  MonitorElement *h2SrcMal,
158  Bool_t bVarXBin) {
159  Int_t nBinY = h2Sum->getNbinsY();
160  for (Int_t j = 1; j <= nBinY; j++) {
161  Int_t nBinX = h2Sum->getNbinsX();
162  if (bVarXBin) {
163  nBinX = (Int_t)(h2SrcOcc->getBinContent(0, j) + 0.5);
164  h2Sum->setBinContent(0, j, nBinX);
165  }
166  for (Int_t i = 1; i <= nBinX; i++) {
167  Float_t fOcc = h2SrcOcc->getBinContent(i, j);
168  Float_t fStatus = h2SrcCStatus->getBinContent(i, j);
169  Float_t fMal = (h2SrcMal != nullptr ? h2SrcMal->getBinContent(i, j) : 0.0);
170 
171  Float_t fRes = 0;
172  if (fStatus > 0 || fMal > 0)
173  fRes = 2;
174  else if (fOcc > 0)
175  fRes = 1;
176 
177  h2Sum->setBinContent(i, j, fRes);
178  }
179  }
180 }
181 
DQMEDHarvester.h
GEMDQMHarvester::drawSummaryHistogram
void drawSummaryHistogram(edm::Service< DQMStore > &store)
Definition: GEMDQMHarvester.cc:80
GEMDQMHarvester::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: GEMDQMHarvester.cc:66
mps_fire.i
i
Definition: mps_fire.py:428
GEMDQMHarvester::fReportSummary_
Float_t fReportSummary_
Definition: GEMDQMHarvester.cc:52
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:818
GEMDQMHarvester::strOutFile_
std::string strOutFile_
Definition: GEMDQMHarvester.cc:53
ESHandle.h
GEMDQMHarvester::dqmEndLuminosityBlock
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: GEMDQMHarvester.cc:72
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:677
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
EDAnalyzer.h
GEMDQMHarvester
Definition: GEMDQMHarvester.cc:24
MakerMacros.h
GEMDQMHarvester::strDirSummary_
std::string strDirSummary_
Definition: GEMDQMHarvester.cc:55
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
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:56
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:861
GEMDQMHarvester::createSummaryVFAT
void createSummaryVFAT(edm::Service< DQMStore > &store, MonitorElement *h2Src, std::string strSuffix, MonitorElement *&h2Sum)
Definition: GEMDQMHarvester.cc:138
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
GEMDQMHarvester::GEMDQMHarvester
GEMDQMHarvester(const edm::ParameterSet &)
Definition: GEMDQMHarvester.cc:59
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:580
Event.h
edm::Service
Definition: Service.h:30
dqm::impl::MonitorElement::setYTitle
virtual void setYTitle(std::string const &title)
Definition: MonitorElement.cc:866
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:771
GEMDQMHarvester::createSummaryHist
void createSummaryHist(edm::Service< DQMStore > &store, MonitorElement *h2Src, MonitorElement *&h2Sum, std::vector< std::string > &listLayers)
Definition: GEMDQMHarvester.cc:117
edm::EventSetup
Definition: EventSetup.h:58
dqm::impl::MonitorElement::getTitle
virtual std::string getTitle() const
get MonitorElement title
Definition: MonitorElement.cc:683
looper.cfg
cfg
Definition: looper.py:297
DQMEDHarvester
Definition: DQMEDHarvester.py:1
GEMDQMHarvester::refineSummaryHistogram
void refineSummaryHistogram(MonitorElement *h2Sum, MonitorElement *h2SrcOcc, MonitorElement *h2SrcCStatus, MonitorElement *h2SrcMal=nullptr, Bool_t bVarXBin=false)
Definition: GEMDQMHarvester.cc:154
dqm::impl::MonitorElement::setBinContent
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
Definition: MonitorElement.cc:691
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:574
anotherprimaryvertexanalyzer_cfi.nBinX
nBinX
Definition: anotherprimaryvertexanalyzer_cfi.py:12
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
EventSetup.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
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:592
dqm::legacy::MonitorElement::getTH2F
virtual TH2F * getTH2F() const
Definition: MonitorElement.h:491