CMS 3D CMS Logo

L1TdeCSCTPGClient.cc
Go to the documentation of this file.
2 
9 #include "TRandom.h"
10 using namespace edm;
11 using namespace std;
12 
14  : monitorDir_(ps.getParameter<string>("monitorDir")),
15  chambers_(ps.getParameter<std::vector<std::string>>("chambers")),
16  // variables
17  alctVars_(ps.getParameter<std::vector<std::string>>("alctVars")),
18  clctVars_(ps.getParameter<std::vector<std::string>>("clctVars")),
19  lctVars_(ps.getParameter<std::vector<std::string>>("lctVars")),
20  // binning
21  alctNBin_(ps.getParameter<std::vector<unsigned>>("alctNBin")),
22  clctNBin_(ps.getParameter<std::vector<unsigned>>("clctNBin")),
23  lctNBin_(ps.getParameter<std::vector<unsigned>>("lctNBin")),
24  alctMinBin_(ps.getParameter<std::vector<double>>("alctMinBin")),
25  clctMinBin_(ps.getParameter<std::vector<double>>("clctMinBin")),
26  lctMinBin_(ps.getParameter<std::vector<double>>("lctMinBin")),
27  alctMaxBin_(ps.getParameter<std::vector<double>>("alctMaxBin")),
28  clctMaxBin_(ps.getParameter<std::vector<double>>("clctMaxBin")),
29  lctMaxBin_(ps.getParameter<std::vector<double>>("lctMaxBin")),
30  useB904ME11_(ps.getParameter<bool>("useB904ME11")),
31  useB904ME21_(ps.getParameter<bool>("useB904ME21")),
32  useB904ME234s2_(ps.getParameter<bool>("useB904ME234s2")),
33  isRun3_(ps.getParameter<bool>("isRun3")),
34  // by default the DQM will make 2D summary plots. Do you also want
35  // the very large number of 1D plots? Typically only for testing at B904 or
36  // on select P5 data
37  make1DPlots_(ps.getParameter<bool>("make1DPlots")) {
39 }
40 
42 
44  DQMStore::IGetter &igetter,
45  const edm::LuminosityBlock &lumiSeg,
46  const edm::EventSetup &c) {
47  book(ibooker);
48  processHistograms(igetter);
49 }
50 
51 //--------------------------------------------------------
53  book(ibooker);
54  processHistograms(igetter);
55 }
56 
59 
60  // remove the non-ME1/1 chambers from the list when useB904ME11 is set to true
61  if (useB904ME11_) {
62  chambers_.resize(1);
63  }
64  // similar for ME2/1
65  else if (useB904ME21_) {
66  auto temp = chambers_[3];
67  chambers_.resize(1);
68  chambers_[0] = temp;
69  }
70  // similar for ME4/2
71  else if (useB904ME234s2_) {
72  auto temp = chambers_.back();
73  chambers_.resize(1);
74  chambers_[0] = temp;
75  }
76  // collision data in Run-3
77  else if (isRun3_) {
78  clctVars_.resize(9);
79  lctVars_.resize(9);
80  }
81  // do not analyze Run-3 properties in Run-1 and Run-2 eras
82  else {
83  clctVars_.resize(4);
84  lctVars_.resize(5);
85  }
86 
87  // 1D plots for experts
89  // chamber type
90  for (unsigned iType = 0; iType < chambers_.size(); iType++) {
91  // alct variable
92  for (unsigned iVar = 0; iVar < alctVars_.size(); iVar++) {
93  const std::string key("alct_" + alctVars_[iVar] + "_diff");
94  const std::string histName(key + "_" + chambers_[iType]);
95  const std::string histTitle(chambers_[iType] + " ALCT " + alctVars_[iVar] + " (Emul - Data)");
96  if (chamberHistos_[iType][key] == nullptr)
97  chamberHistos_[iType][key] =
98  iBooker.book1D(histName, histTitle, alctNBin_[iVar], alctMinBin_[iVar], alctMaxBin_[iVar]);
99  else
100  chamberHistos_[iType][key]->Reset();
101  }
102 
103  // clct variable
104  for (unsigned iVar = 0; iVar < clctVars_.size(); iVar++) {
105  const std::string key("clct_" + clctVars_[iVar] + "_diff");
106  const std::string histName(key + "_" + chambers_[iType]);
107  const std::string histTitle(chambers_[iType] + " CLCT " + clctVars_[iVar] + " (Emul - Data)");
108  if (chamberHistos_[iType][key] == nullptr)
109  chamberHistos_[iType][key] =
110  iBooker.book1D(histName, histTitle, clctNBin_[iVar], clctMinBin_[iVar], clctMaxBin_[iVar]);
111  else
112  chamberHistos_[iType][key]->Reset();
113  }
114 
115  // lct variable
116  for (unsigned iVar = 0; iVar < lctVars_.size(); iVar++) {
117  const std::string key("lct_" + lctVars_[iVar] + "_diff");
118  const std::string histName(key + "_" + chambers_[iType]);
119  const std::string histTitle(chambers_[iType] + " LCT " + lctVars_[iVar] + " (Emul - Data)");
120  if (chamberHistos_[iType][key] == nullptr)
121  chamberHistos_[iType][key] =
122  iBooker.book1D(histName, histTitle, lctNBin_[iVar], lctMinBin_[iVar], lctMaxBin_[iVar]);
123  else
124  chamberHistos_[iType][key]->Reset();
125  }
126  }
127  }
128 
129  // 2D summary plots
130  lctDataSummary_eff_ = iBooker.book2D(
131  "lct_csctp_data_summary_eff", "Efficiency of data LCT being correctly emulated", 36, 1, 37, 18, 0, 18);
132  alctDataSummary_eff_ = iBooker.book2D(
133  "alct_csctp_data_summary_eff", "Efficiency of data ALCT being correctly emulated", 36, 1, 37, 18, 0, 18);
134  clctDataSummary_eff_ = iBooker.book2D(
135  "clct_csctp_data_summary_eff", "Efficiency of data CLCT being correctly emulated", 36, 1, 37, 18, 0, 18);
136 
137  lctEmulSummary_eff_ = iBooker.book2D(
138  "lct_csctp_emul_summary_eff", "Fraction of emulated LCT without matching data LCT", 36, 1, 37, 18, 0, 18);
139  alctEmulSummary_eff_ = iBooker.book2D(
140  "alct_csctp_emul_summary_eff", "Fraction of emulated ALCT without matching data ALCT", 36, 1, 37, 18, 0, 18);
141  clctEmulSummary_eff_ = iBooker.book2D(
142  "clct_csctp_emul_summary_eff", "Fraction of emulated CLCT without matching data CLCT", 36, 1, 37, 18, 0, 18);
143 
144  // x labels
145  lctDataSummary_eff_->setAxisTitle("Chamber", 1);
146  alctDataSummary_eff_->setAxisTitle("Chamber", 1);
147  clctDataSummary_eff_->setAxisTitle("Chamber", 1);
148 
149  lctEmulSummary_eff_->setAxisTitle("Chamber", 1);
150  alctEmulSummary_eff_->setAxisTitle("Chamber", 1);
151  clctEmulSummary_eff_->setAxisTitle("Chamber", 1);
152 
153  // plotting option
157 
161 
162  // summary plots
163  const std::array<std::string, 9> suffix_label{{"4/2", "4/1", "3/2", "3/1", " 2/2", "2/1", "1/3", "1/2", "1/1"}};
164 
165  // y labels
166  for (int ybin = 1; ybin <= 9; ++ybin) {
167  lctDataSummary_eff_->setBinLabel(ybin, "ME-" + suffix_label[ybin - 1], 2);
168  alctDataSummary_eff_->setBinLabel(ybin, "ME-" + suffix_label[ybin - 1], 2);
169  clctDataSummary_eff_->setBinLabel(ybin, "ME-" + suffix_label[ybin - 1], 2);
170 
171  lctEmulSummary_eff_->setBinLabel(ybin, "ME-" + suffix_label[ybin - 1], 2);
172  alctEmulSummary_eff_->setBinLabel(ybin, "ME-" + suffix_label[ybin - 1], 2);
173  clctEmulSummary_eff_->setBinLabel(ybin, "ME-" + suffix_label[ybin - 1], 2);
174 
175  lctDataSummary_eff_->setBinLabel(19 - ybin, "ME+" + suffix_label[ybin - 1], 2);
176  alctDataSummary_eff_->setBinLabel(19 - ybin, "ME+" + suffix_label[ybin - 1], 2);
177  clctDataSummary_eff_->setBinLabel(19 - ybin, "ME+" + suffix_label[ybin - 1], 2);
178 
179  lctEmulSummary_eff_->setBinLabel(19 - ybin, "ME+" + suffix_label[ybin - 1], 2);
180  alctEmulSummary_eff_->setBinLabel(19 - ybin, "ME+" + suffix_label[ybin - 1], 2);
181  clctEmulSummary_eff_->setBinLabel(19 - ybin, "ME+" + suffix_label[ybin - 1], 2);
182  }
183 }
184 
186  MonitorElement *dataMon;
187  MonitorElement *emulMon;
188 
189  // 1D plots for experts
191  // chamber type
192  for (unsigned iType = 0; iType < chambers_.size(); iType++) {
193  // alct variable
194  for (unsigned iVar = 0; iVar < alctVars_.size(); iVar++) {
195  const std::string key("alct_" + alctVars_[iVar]);
196  const std::string histData(key + "_data_" + chambers_[iType]);
197  const std::string histEmul(key + "_emul_" + chambers_[iType]);
198 
199  dataMon = igetter.get(monitorDir_ + "/" + histData);
200  emulMon = igetter.get(monitorDir_ + "/" + histEmul);
201 
202  if (dataMon == nullptr or emulMon == nullptr) {
203  edm::LogWarning("L1TdeCSCTPGClient")
204  << __PRETTY_FUNCTION__ << " could not load the necessary histograms for harvesting " << histData << " / "
205  << histEmul;
206  continue;
207  }
208 
209  TH1F *hDiff = chamberHistos_[iType][key + "_diff"]->getTH1F();
210 
211  if (dataMon && emulMon) {
212  TH1F *hData = dataMon->getTH1F();
213  TH1F *hEmul = emulMon->getTH1F();
214  hDiff->Add(hEmul, hData, 1, -1);
215  }
216  }
217 
218  // clct variable
219  for (unsigned iVar = 0; iVar < clctVars_.size(); iVar++) {
220  const std::string key("clct_" + clctVars_[iVar]);
221  const std::string histData(key + "_data_" + chambers_[iType]);
222  const std::string histEmul(key + "_emul_" + chambers_[iType]);
223 
224  dataMon = igetter.get(monitorDir_ + "/" + histData);
225  emulMon = igetter.get(monitorDir_ + "/" + histEmul);
226 
227  if (dataMon == nullptr or emulMon == nullptr) {
228  edm::LogWarning("L1TdeCSCTPGClient")
229  << __PRETTY_FUNCTION__ << " could not load the necessary histograms for harvesting " << histData << " / "
230  << histEmul;
231  continue;
232  }
233 
234  TH1F *hDiff = chamberHistos_[iType][key + "_diff"]->getTH1F();
235 
236  if (dataMon && emulMon) {
237  TH1F *hData = dataMon->getTH1F();
238  TH1F *hEmul = emulMon->getTH1F();
239  hDiff->Add(hEmul, hData, 1, -1);
240  }
241  }
242 
243  // lct variable
244  for (unsigned iVar = 0; iVar < lctVars_.size(); iVar++) {
245  const std::string key("lct_" + lctVars_[iVar]);
246  const std::string histData(key + "_data_" + chambers_[iType]);
247  const std::string histEmul(key + "_emul_" + chambers_[iType]);
248 
249  dataMon = igetter.get(monitorDir_ + "/" + histData);
250  emulMon = igetter.get(monitorDir_ + "/" + histEmul);
251 
252  if (dataMon == nullptr or emulMon == nullptr) {
253  edm::LogWarning("L1TdeCSCTPGClient")
254  << __PRETTY_FUNCTION__ << " could not load the necessary histograms for harvesting " << histData << " / "
255  << histEmul;
256  continue;
257  }
258 
259  TH1F *hDiff = chamberHistos_[iType][key + "_diff"]->getTH1F();
260 
261  if (dataMon && emulMon) {
262  TH1F *hData = dataMon->getTH1F();
263  TH1F *hEmul = emulMon->getTH1F();
264  hDiff->Add(hEmul, hData, 1, -1);
265  }
266  }
267  }
268  }
269 
270  // 2D summary plot
271  MonitorElement *lctDataSummary_denom_ = igetter.get(monitorDir_ + "/lct_csctp_data_summary_denom");
272  MonitorElement *lctDataSummary_num_ = igetter.get(monitorDir_ + "/lct_csctp_data_summary_num");
273  MonitorElement *alctDataSummary_denom_ = igetter.get(monitorDir_ + "/alct_csctp_data_summary_denom");
274  MonitorElement *alctDataSummary_num_ = igetter.get(monitorDir_ + "/alct_csctp_data_summary_num");
275  MonitorElement *clctDataSummary_denom_ = igetter.get(monitorDir_ + "/clct_csctp_data_summary_denom");
276  MonitorElement *clctDataSummary_num_ = igetter.get(monitorDir_ + "/clct_csctp_data_summary_num");
277 
278  if (lctDataSummary_denom_ == nullptr or lctDataSummary_num_ == nullptr or alctDataSummary_denom_ == nullptr or
279  alctDataSummary_num_ == nullptr or clctDataSummary_denom_ == nullptr or clctDataSummary_num_ == nullptr) {
280  edm::LogWarning("L1TdeCSCTPGClient") << __PRETTY_FUNCTION__
281  << " could not load the necessary data histograms for 2D summary plots";
282  return;
283  }
284 
285  MonitorElement *lctEmulSummary_denom_ = igetter.get(monitorDir_ + "/lct_csctp_emul_summary_denom");
286  MonitorElement *lctEmulSummary_num_ = igetter.get(monitorDir_ + "/lct_csctp_emul_summary_num");
287  MonitorElement *alctEmulSummary_denom_ = igetter.get(monitorDir_ + "/alct_csctp_emul_summary_denom");
288  MonitorElement *alctEmulSummary_num_ = igetter.get(monitorDir_ + "/alct_csctp_emul_summary_num");
289  MonitorElement *clctEmulSummary_denom_ = igetter.get(monitorDir_ + "/clct_csctp_emul_summary_denom");
290  MonitorElement *clctEmulSummary_num_ = igetter.get(monitorDir_ + "/clct_csctp_emul_summary_num");
291 
292  if (lctEmulSummary_denom_ == nullptr or lctEmulSummary_num_ == nullptr or alctEmulSummary_denom_ == nullptr or
293  alctEmulSummary_num_ == nullptr or clctEmulSummary_denom_ == nullptr or clctEmulSummary_num_ == nullptr) {
294  edm::LogWarning("L1TdeCSCTPGClient")
295  << __PRETTY_FUNCTION__ << " could not load the necessary emulation histograms for the 2D summary plots";
296  return;
297  }
298 
299  lctDataSummary_eff_->getTH2F()->Divide(lctDataSummary_num_->getTH2F(), lctDataSummary_denom_->getTH2F(), 1, 1, "");
300  alctDataSummary_eff_->getTH2F()->Divide(alctDataSummary_num_->getTH2F(), alctDataSummary_denom_->getTH2F(), 1, 1, "");
301  clctDataSummary_eff_->getTH2F()->Divide(clctDataSummary_num_->getTH2F(), clctDataSummary_denom_->getTH2F(), 1, 1, "");
302 
303  lctEmulSummary_eff_->getTH2F()->Divide(lctEmulSummary_num_->getTH2F(), lctEmulSummary_denom_->getTH2F(), 1, 1, "");
304  alctEmulSummary_eff_->getTH2F()->Divide(alctEmulSummary_num_->getTH2F(), alctEmulSummary_denom_->getTH2F(), 1, 1, "");
305  clctEmulSummary_eff_->getTH2F()->Divide(clctEmulSummary_num_->getTH2F(), clctEmulSummary_denom_->getTH2F(), 1, 1, "");
306 
307  // set minima to 0.95 so the contrast comes out better!
308  lctDataSummary_eff_->getTH2F()->GetZaxis()->SetRangeUser(0.95, 1);
309  alctDataSummary_eff_->getTH2F()->GetZaxis()->SetRangeUser(0.95, 1);
310  clctDataSummary_eff_->getTH2F()->GetZaxis()->SetRangeUser(0.95, 1);
311 }
std::vector< double > alctMaxBin_
MonitorElement * clctDataSummary_eff_
std::vector< double > clctMaxBin_
L1TdeCSCTPGClient(const edm::ParameterSet &ps)
Constructor.
~L1TdeCSCTPGClient() override
Destructor.
MonitorElement * lctDataSummary_eff_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
std::vector< std::string > lctVars_
std::vector< double > lctMinBin_
std::vector< std::string > alctVars_
virtual void setOption(const char *option)
std::string monitorDir_
MonitorElement * alctEmulSummary_eff_
std::vector< unsigned > alctNBin_
virtual TH2F * getTH2F() const
void book(DQMStore::IBooker &ibooker)
void processHistograms(DQMStore::IGetter &)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
std::vector< double > alctMinBin_
MonitorElement * clctEmulSummary_eff_
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)
std::vector< unsigned > lctNBin_
std::vector< double > clctMinBin_
virtual TH1F * getTH1F() const
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:212
MonitorElement * lctEmulSummary_eff_
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:712
std::vector< double > lctMaxBin_
HLT enums.
std::vector< std::string > chambers_
Log< level::Warning, false > LogWarning
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MonitorElement * alctDataSummary_eff_
std::vector< std::string > clctVars_
std::vector< unsigned > clctNBin_
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
std::map< uint32_t, std::map< std::string, MonitorElement * > > chamberHistos_