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 &,
32  DQMStore::IGetter &,
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 refineSummaryHistogram(edm::Service<DQMStore> &);
38  void refineSummaryHistogramCore(TH3F *, std::string &, TH2F *&, std::string strTmpPrefix = "tmp_");
39 
40  void fillUnderOverflowBunchCrossing(edm::Service<DQMStore> &, std::string);
41 
44 };
45 
47  m_fReportSummary = -1.0;
48  strOutFile_ = cfg.getParameter<std::string>("fromFile");
49 }
50 
53  desc.add<std::string>("fromFile", "");
54  descriptions.add("GEMDQMHarvester", desc);
55 }
56 
57 void GEMDQMHarvester::dqmEndLuminosityBlock(DQMStore::IBooker &,
58  DQMStore::IGetter &,
59  edm::LuminosityBlock const &,
60  edm::EventSetup const &) {
62  refineSummaryHistogram(store);
63 
64  store->setCurrentFolder("GEM/StatusDigi");
65  auto listME = store->getMEs();
66 
67  for (auto strName : listME) {
68  if (strName.find("vfatStatus_BC_") != std::string::npos) {
69  fillUnderOverflowBunchCrossing(store, strName);
70  }
71  }
72 }
73 
75  std::string strDirCurr = "GEM/EventInfo";
76  std::string strNameSrc = "reportSummaryMapPreliminary";
77  std::string strNewName = "reportSummaryMap";
78 
79  store->setCurrentFolder(strDirCurr);
80 
81  MonitorElement *h3Curr = store->get(strDirCurr + "/" + strNameSrc);
82  TH2F *h2New = nullptr;
83 
84  refineSummaryHistogramCore(h3Curr->getTH3F(), strNewName, h2New);
85  store->book2D(strNewName, h2New);
86 
87  store->bookFloat("reportSummary")->Fill(m_fReportSummary);
88 }
89 
91  std::string &strNewName,
92  TH2F *&h2New,
93  std::string strTmpPrefix) {
94  Int_t i, j;
95 
96  Int_t nNBinX = h3Src->GetNbinsX();
97  Int_t nNBinY = h3Src->GetNbinsY();
98 
99  Float_t arrfBinX[128], arrfBinY[32];
100 
101  Float_t fNumPass, fNumError, fNumTotal;
102 
103  for (i = 0; i <= nNBinX; i++)
104  arrfBinX[i] = h3Src->GetXaxis()->GetBinLowEdge(i + 1);
105  for (i = 0; i <= nNBinY; i++)
106  arrfBinY[i] = h3Src->GetYaxis()->GetBinLowEdge(i + 1);
107 
108  h2New = new TH2F(strNewName.c_str(), h3Src->GetTitle(), nNBinX, arrfBinX, nNBinY, arrfBinY);
109 
110  fNumTotal = fNumPass = fNumError = 0.0;
111 
112  for (i = 0; i < nNBinX; i++) {
113  h2New->GetXaxis()->SetBinLabel(i + 1, h3Src->GetXaxis()->GetBinLabel(i + 1));
114  for (j = 0; j < nNBinY; j++) {
115  h2New->GetYaxis()->SetBinLabel(j + 1, h3Src->GetYaxis()->GetBinLabel(j + 1));
116 
117  if (h3Src->GetBinContent(i + 1, j + 1, 2) != 0) {
118  h2New->SetBinContent(i + 1, j + 1, 2);
119  fNumError += 1.0;
120  } else if (h3Src->GetBinContent(i + 1, j + 1, 1) != 0) {
121  h2New->SetBinContent(i + 1, j + 1, 1);
122  fNumPass += 1.0;
123  }
124 
125  fNumTotal += 1.0;
126  }
127  }
128 
129  if (fNumPass > 0.0 || fNumError > 0.0)
130  m_fReportSummary = fNumPass / fNumTotal;
131 }
132 
134  std::string strDirCurr = "GEM/StatusDigi";
135 
136  store->setCurrentFolder(strDirCurr);
137  MonitorElement *h2Curr = store->get(strDirCurr + "/" + strNameSrc);
138 
139  Int_t nNBinX = h2Curr->getNbinsX();
140  Int_t nNBinY = h2Curr->getNbinsY();
141 
142  for (Int_t i = 0; i < nNBinY; i++) {
143  h2Curr->setBinContent(1, i, h2Curr->getBinContent(0, i) + h2Curr->getBinContent(1, i));
144  h2Curr->setBinContent(nNBinX, i, h2Curr->getBinContent(nNBinX, i) + h2Curr->getBinContent(nNBinX + 1, i));
145  }
146 }
147 
T getParameter(std::string const &) const
std::string strOutFile_
virtual int getNbinsY() const
get # of bins in Y-axis
~GEMDQMHarvester() override
void fillUnderOverflowBunchCrossing(edm::Service< DQMStore > &, std::string)
void refineSummaryHistogramCore(TH3F *, std::string &, TH2F *&, std::string strTmpPrefix="tmp_")
Float_t m_fReportSummary
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
virtual int getNbinsX() const
get # of bins in X-axis
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
void refineSummaryHistogram(edm::Service< DQMStore > &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
virtual double getBinContent(int binx) const
get content of bin (1-D)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
GEMDQMHarvester(const edm::ParameterSet &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
virtual TH3F * getTH3F() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override