CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ESSummaryClient.cc
Go to the documentation of this file.
1 #include <fstream>
2 #include <iomanip>
3 #include <iostream>
4 #include <memory>
5 
7 
8 using namespace std;
9 
11  : ESClient(ps), meReportSummary_(nullptr), meReportSummaryMap_(nullptr) {
12  for (unsigned iZ(0); iZ != 2; ++iZ)
13  for (unsigned iD(0); iD != 2; ++iD)
14  meReportSummaryContents_[iZ][iD] = nullptr;
15 }
16 
18 
20  if (debug_)
21  cout << "ESSummaryClient: setup" << endl;
22 
23  _ibooker.setCurrentFolder(prefixME_ + "/EventInfo");
24 
25  meReportSummary_ = _ibooker.bookFloat("reportSummary");
26 
27  _ibooker.setCurrentFolder(prefixME_ + "/EventInfo/reportSummaryContents");
28 
29  char histo[200];
30 
31  for (int i = 0; i < 2; ++i) {
32  for (int j = 0; j < 2; ++j) {
33  int iz = (i == 0) ? 1 : -1;
34  sprintf(histo, "EcalPreshower Z %d P %d", iz, j + 1);
35  meReportSummaryContents_[i][j] = _ibooker.bookFloat(histo);
36  }
37  }
38 
39  _ibooker.setCurrentFolder(prefixME_ + "/EventInfo");
40 
41  meReportSummaryMap_ = _ibooker.book2D("reportSummaryMap", "reportSummaryMap", 80, 0.5, 80.5, 80, 0.5, 80.5);
44 }
45 
47  for (int i = 0; i < 80; i++) {
48  for (int j = 0; j < 80; j++) {
49  meReportSummaryMap_->setBinContent(i + 1, j + 1, -1.);
50  }
51  }
52 
53  char histo[200];
54 
55  float nDI_FedErr[80][80];
56  float DCC[80][80];
57  float eCount;
58 
60 
61  for (int i = 0; i < 80; ++i)
62  for (int j = 0; j < 80; ++j) {
63  nDI_FedErr[i][j] = -1;
64  DCC[i][j] = 0;
65  }
66 
67  for (int i = 0; i < 2; ++i) {
68  for (int j = 0; j < 2; ++j) {
69  int iz = (i == 0) ? 1 : -1;
70 
71  sprintf(histo, "ES Integrity Errors Z %d P %d", iz, j + 1);
72  me = _igetter.get(prefixME_ + "/ESIntegrityTask/" + histo);
73  if (me)
74  for (int x = 0; x < 40; ++x)
75  for (int y = 0; y < 40; ++y)
76  nDI_FedErr[i * 40 + x][(1 - j) * 40 + y] = me->getBinContent(x + 1, y + 1);
77 
78  sprintf(histo, "ES Integrity Summary 1 Z %d P %d", iz, j + 1);
79  me = _igetter.get(prefixME_ + "/ESIntegrityClient/" + histo);
80  if (me)
81  for (int x = 0; x < 40; ++x)
82  for (int y = 0; y < 40; ++y)
83  DCC[i * 40 + x][(1 - j) * 40 + y] = me->getBinContent(x + 1, y + 1);
84 
85  sprintf(histo, "ES RecHit 2D Occupancy Z %d P %d", iz, j + 1);
86  me = _igetter.get(prefixME_ + "/ESOccupancyTask/" + histo);
87  if (me)
88  eCount = me->getBinContent(40, 40);
89  else
90  eCount = 1.;
91  }
92  }
93 
94  // The global-summary
95  // ReportSummary Map
96  // ES+F ES-F
97  // ES+R ES-R
98  float nValidChannels = 0;
99  float nGlobalErrors = 0;
100  float nValidChannelsES[2][2] = {};
101  float nGlobalErrorsES[2][2] = {};
102 
103  for (int x = 0; x < 80; ++x) {
104  if (eCount < 1)
105  break; // Fill reportSummaryMap after have 1 event
106  for (int y = 0; y < 80; ++y) {
107  int z = (x < 40) ? 0 : 1;
108  int p = (y >= 40) ? 0 : 1;
109 
110  if (DCC[x][y] == 0.) {
111  meReportSummaryMap_->setBinContent(x + 1, y + 1, -1.);
112  } else {
113  if (nDI_FedErr[x][y] >= 0) {
114  meReportSummaryMap_->setBinContent(x + 1, y + 1, 1 - (nDI_FedErr[x][y] / eCount));
115 
116  nValidChannels++;
117  nGlobalErrors += nDI_FedErr[x][y] / eCount;
118 
119  nValidChannelsES[z][p]++;
120  nGlobalErrorsES[z][p] += nDI_FedErr[x][y] / eCount;
121  } else {
122  meReportSummaryMap_->setBinContent(x + 1, y + 1, -1.);
123  }
124  }
125  }
126  }
127 
128  for (unsigned iZ(0); iZ != 2; ++iZ) {
129  for (unsigned iD(0); iD != 2; ++iD) {
130  float reportSummaryES(-1.);
131  if (nValidChannelsES[iZ][iD] != 0)
132  reportSummaryES = 1. - nGlobalErrorsES[iZ][iD] / nValidChannelsES[iZ][iD];
133 
134  meReportSummaryContents_[iZ][iD]->Fill(reportSummaryES);
135  }
136  }
137 
138  float reportSummary(-1.);
139  if (nValidChannels != 0)
140  reportSummary = 1. - nGlobalErrors / nValidChannels;
141 
142  meReportSummary_->Fill(reportSummary);
143 }
144 
146  fillReportSummary(_igetter);
147 
148  // The following overwrites the report summary if LS-based Good Channel
149  // Fraction histogram is available The source is turned off by default in
150  // ESIntegrityTask
151 
152  MonitorElement *source(_igetter.get(prefixME_ + "/ESIntegrityTask/ES Good Channel Fraction"));
153  if (!source)
154  return;
155 
156  meReportSummary_->Fill(-1.0);
157  for (unsigned iZ(0); iZ != 2; ++iZ)
158  for (unsigned iD(0); iD != 2; ++iD)
159  meReportSummaryContents_[iZ][iD]->Fill(-1.);
160 
161  for (int i = 0; i < 2; ++i)
162  for (int j = 0; j < 2; ++j)
163  meReportSummaryContents_[i][j]->Fill(source->getBinContent(i + 1, j + 1));
164 
165  meReportSummary_->Fill(source->getBinContent(3, 3));
166 }
167 
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
ESSummaryClient(const edm::ParameterSet &ps)
Constructor.
MonitorElement * meReportSummary_
void book(DQMStore::IBooker &) override
void endLumiAnalyze(DQMStore::IGetter &) override
Analyze.
void Fill(long long x)
MonitorElement * meReportSummaryContents_[2][2]
~ESSummaryClient() override
Destructor.
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
std::string prefixME_
Definition: ESClient.h:32
bool debug_
Definition: ESClient.h:35
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
virtual double getBinContent(int binx) const
get content of bin (1-D)
void endJobAnalyze(DQMStore::IGetter &) override
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
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
MonitorElement * meReportSummaryMap_
tuple cout
Definition: gather_cfg.py:144
void fillReportSummary(DQMStore::IGetter &)
static std::string const source
Definition: EdmProvDump.cc:46
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)