CMS 3D CMS Logo

PFClient.cc
Go to the documentation of this file.
2 
7 
10 
11 //
12 // -- Constructor
13 //
15  folderNames_ = parameterSet.getParameter<std::vector<std::string>>("FolderNames");
16  histogramNames_ = parameterSet.getParameter<std::vector<std::string>>("HistogramNames");
17  efficiencyFlag_ = parameterSet.getParameter<bool>("CreateEfficiencyPlots");
18  effHistogramNames_ = parameterSet.getParameter<std::vector<std::string>>("HistogramNamesForEfficiencyPlots");
19  projectionHistogramNames_ = parameterSet.getParameter<std::vector<std::string>>("HistogramNamesForProjectionPlots");
20  profileFlag_ = parameterSet.getParameter<bool>("CreateProfilePlots");
21  profileHistogramNames_ = parameterSet.getParameter<std::vector<std::string>>("HistogramNamesForProfilePlots");
22 }
23 
24 //
25 // -- EndJobBegin Run
26 //
28  doSummaries(ibooker, igetter);
29  doProjection(ibooker, igetter);
30  if (efficiencyFlag_)
31  doEfficiency(ibooker, igetter);
32  if (profileFlag_)
33  doProfiles(ibooker, igetter);
34 }
35 
36 //
37 // -- Create Summaries
38 //
40  for (std::vector<std::string>::const_iterator ifolder = folderNames_.begin(); ifolder != folderNames_.end();
41  ifolder++) {
42  std::string path = "ParticleFlow/" + (*ifolder);
43 
44  for (std::vector<std::string>::const_iterator ihist = histogramNames_.begin(); ihist != histogramNames_.end();
45  ihist++) {
46  std::string hname = (*ihist);
47  createResolutionPlots(ibooker, igetter, path, hname);
48  }
49  }
50 }
51 
52 //
53 // -- Create Projection
54 //
56  for (std::vector<std::string>::const_iterator ifolder = folderNames_.begin(); ifolder != folderNames_.end();
57  ifolder++) {
58  std::string path = "ParticleFlow/" + (*ifolder);
59 
60  for (std::vector<std::string>::const_iterator ihist = projectionHistogramNames_.begin();
61  ihist != projectionHistogramNames_.end();
62  ihist++) {
63  std::string hname = (*ihist);
64  createProjectionPlots(ibooker, igetter, path, hname);
65  }
66  }
67 }
68 
69 //
70 // -- Create Profile
71 //
73  for (std::vector<std::string>::const_iterator ifolder = folderNames_.begin(); ifolder != folderNames_.end();
74  ifolder++) {
75  std::string path = "ParticleFlow/" + (*ifolder);
76 
77  for (std::vector<std::string>::const_iterator ihist = profileHistogramNames_.begin();
78  ihist != profileHistogramNames_.end();
79  ihist++) {
80  std::string hname = (*ihist);
81  createProfilePlots(ibooker, igetter, path, hname);
82  }
83  }
84 }
85 
86 //
87 // -- Create Efficiency
88 //
90  for (std::vector<std::string>::const_iterator ifolder = folderNames_.begin(); ifolder != folderNames_.end();
91  ifolder++) {
92  std::string path = "ParticleFlow/" + (*ifolder);
93 
94  for (std::vector<std::string>::const_iterator ihist = effHistogramNames_.begin(); ihist != effHistogramNames_.end();
95  ihist++) {
96  std::string hname = (*ihist);
97  createEfficiencyPlots(ibooker, igetter, path, hname);
98  }
99  }
100 }
101 
102 //
103 // -- Create Resolution Plots
104 //
106  DQMStore::IGetter &igetter,
108  std::string &name) {
109  MonitorElement *me = igetter.get(folder + "/" + name);
110 
111  if (!me)
112  return;
113 
114  MonitorElement *me_average;
115  MonitorElement *me_rms;
116  MonitorElement *me_mean;
117  MonitorElement *me_sigma;
118 
119  if ((me->kind() == MonitorElement::Kind::TH2F) || (me->kind() == MonitorElement::Kind::TH2S) ||
120  (me->kind() == MonitorElement::Kind::TH2D)) {
121  TH2 *th = me->getTH2F();
122  size_t nbinx = me->getNbinsX();
123  size_t nbiny = me->getNbinsY();
124 
125  float ymin = th->GetYaxis()->GetXmin();
126  float ymax = th->GetYaxis()->GetXmax();
127  std::string xtit = th->GetXaxis()->GetTitle();
128  std::string ytit = th->GetYaxis()->GetTitle();
129  float *xbins = new float[nbinx + 1];
130  for (size_t ix = 1; ix < nbinx + 1; ++ix) {
131  xbins[ix - 1] = th->GetXaxis()->GetBinLowEdge(ix);
132  if (ix == nbinx)
133  xbins[ix] = th->GetXaxis()->GetBinUpEdge(ix);
134  }
135  std::string tit_new = ";" + xtit + ";" + ytit;
136  ibooker.setCurrentFolder(folder);
137  MonitorElement *me_slice = ibooker.book1D("PFlowSlice", "PFlowSlice", nbiny, ymin, ymax);
138 
139  tit_new = ";" + xtit + ";Average_" + ytit;
140  me_average = ibooker.book1D("average_" + name, tit_new, nbinx, xbins);
141  me_average->setEfficiencyFlag();
142  tit_new = ";" + xtit + ";RMS_" + ytit;
143  me_rms = ibooker.book1D("rms_" + name, tit_new, nbinx, xbins);
144  me_rms->setEfficiencyFlag();
145  tit_new = ";" + xtit + ";Mean_" + ytit;
146  me_mean = ibooker.book1D("mean_" + name, tit_new, nbinx, xbins);
147  me_mean->setEfficiencyFlag();
148  tit_new = ";" + xtit + ";Sigma_" + ytit;
149  me_sigma = ibooker.book1D("sigma_" + name, tit_new, nbinx, xbins);
150  me_sigma->setEfficiencyFlag();
151 
152  double average, rms, mean, sigma;
153 
154  for (size_t ix = 1; ix < nbinx + 1; ++ix) {
155  me_slice->Reset();
156  for (size_t iy = 1; iy < nbiny + 1; ++iy) {
157  me_slice->setBinContent(iy, th->GetBinContent(ix, iy));
158  }
159  getHistogramParameters(me_slice, average, rms, mean, sigma);
160  me_average->setBinContent(ix, average);
161  me_rms->setBinContent(ix, rms);
162  me_mean->setBinContent(ix, mean);
163  me_sigma->setBinContent(ix, sigma);
164  }
165  delete[] xbins;
166  }
167 }
168 
169 //
170 // -- Create Projection Plots
171 //
173  DQMStore::IGetter &igetter,
175  std::string &name) {
176  MonitorElement *me = igetter.get(folder + "/" + name);
177  if (!me)
178  return;
179 
180  MonitorElement *projection = nullptr;
181 
182  if ((me->kind() == MonitorElement::Kind::TH2F) || (me->kind() == MonitorElement::Kind::TH2S) ||
183  (me->kind() == MonitorElement::Kind::TH2D)) {
184  TH2 *th = me->getTH2F();
185  size_t nbinx = me->getNbinsX();
186  size_t nbiny = me->getNbinsY();
187 
188  float ymin = th->GetYaxis()->GetXmin();
189  float ymax = th->GetYaxis()->GetXmax();
190  std::string xtit = th->GetXaxis()->GetTitle();
191  std::string ytit = th->GetYaxis()->GetTitle();
192  float *xbins = new float[nbinx + 1];
193  for (size_t ix = 1; ix < nbinx + 1; ++ix) {
194  xbins[ix - 1] = th->GetXaxis()->GetBinLowEdge(ix);
195  if (ix == nbinx)
196  xbins[ix] = th->GetXaxis()->GetBinUpEdge(ix);
197  }
198 
199  std::string tit_new;
200  ibooker.setCurrentFolder(folder);
201 
202  if (folder == "ParticleFlow/PFElectronValidation/CompWithGenElectron") {
203  if (name == "delta_et_Over_et_VS_et_")
204  projection = ibooker.book1D("delta_et_Over_et", "E_{T} resolution;#DeltaE_{T}/E_{T}", nbiny, ymin, ymax);
205  if (name == "delta_et_VS_et_")
206  projection = ibooker.book1D("delta_et_", "#DeltaE_{T};#DeltaE_{T}", nbiny, ymin, ymax);
207  if (name == "delta_eta_VS_et_")
208  projection = ibooker.book1D("delta_eta_", "#Delta#eta;#Delta#eta", nbiny, ymin, ymax);
209  if (name == "delta_phi_VS_et_")
210  projection = ibooker.book1D("delta_phi_", "#Delta#phi;#Delta#phi", nbiny, ymin, ymax);
211  }
212 
213  if (projection) {
214  for (size_t iy = 1; iy < nbiny + 1; ++iy) {
215  projection->setBinContent(iy, th->ProjectionY("e")->GetBinContent(iy));
216  }
217  projection->setEntries(me->getEntries());
218  }
219 
220  delete[] xbins;
221  }
222 }
223 
224 //
225 // -- Create Profile Plots
226 //
228  DQMStore::IGetter &igetter,
230  std::string &name) {
231  MonitorElement *me = igetter.get(folder + "/" + name);
232  if (!me)
233  return;
234 
235  if ((me->kind() == MonitorElement::Kind::TH2F) || (me->kind() == MonitorElement::Kind::TH2S) ||
236  (me->kind() == MonitorElement::Kind::TH2D)) {
237  TH2 *th = me->getTH2F();
238  size_t nbinx = me->getNbinsX();
239 
240  float ymin = th->GetYaxis()->GetXmin();
241  float ymax = th->GetYaxis()->GetXmax();
242  std::string xtit = th->GetXaxis()->GetTitle();
243  std::string ytit = th->GetYaxis()->GetTitle();
244  double *xbins = new double[nbinx + 1];
245  for (size_t ix = 1; ix < nbinx + 1; ++ix) {
246  xbins[ix - 1] = th->GetXaxis()->GetBinLowEdge(ix);
247  if (ix == nbinx)
248  xbins[ix] = th->GetXaxis()->GetBinUpEdge(ix);
249  }
250 
251  std::string tit_new;
252  ibooker.setCurrentFolder(folder);
253  // TProfiles
254  MonitorElement *me_profile[2];
255  me_profile[0] = ibooker.bookProfile("profile_" + name, tit_new, nbinx, xbins, ymin, ymax, "");
256  me_profile[1] = ibooker.bookProfile("profileRMS_" + name, tit_new, nbinx, xbins, ymin, ymax, "s");
257  TProfile *profileX = th->ProfileX();
258  // size_t nbiny = me->getNbinsY();
259  // TProfile* profileX = th->ProfileX("",0,nbiny+1); add underflow and
260  // overflow
261  static const Int_t NUM_STAT = 7;
262  Double_t stats[NUM_STAT] = {0};
263  th->GetStats(stats);
264 
265  for (Int_t i = 0; i < 2; i++) {
266  if (me_profile[i]) {
267  for (size_t ix = 0; ix <= nbinx + 1; ++ix) {
268  me_profile[i]->setBinContent(ix, profileX->GetBinContent(ix) * profileX->GetBinEntries(ix));
269  // me_profile[i]->Fill( profileX->GetBinCenter(ix),
270  // profileX->GetBinContent(ix)*profileX->GetBinEntries(ix) ) ;
271  me_profile[i]->setBinEntries(ix, profileX->GetBinEntries(ix));
272  me_profile[i]->getTProfile()->GetSumw2()->fArray[ix] = profileX->GetSumw2()->fArray[ix];
273  // me_profile[i]->getTProfile()->GetBinSumw2()->fArray[ix] =
274  // profileX->GetBinSumw2()->fArray[ix]; // segmentation violation
275  }
276  }
277  me_profile[i]->getTProfile()->PutStats(stats);
278  me_profile[i]->setEntries(profileX->GetEntries());
279  }
280 
281  delete[] xbins;
282  }
283 }
284 
285 //
286 // -- Get Histogram Parameters
287 //
289  MonitorElement *me_slice, double &average, double &rms, double &mean, double &sigma) {
290  average = 0.0;
291  rms = 0.0;
292  mean = 0.0;
293  sigma = 0.0;
294 
295  if (!me_slice)
296  return;
297  if (me_slice->kind() == MonitorElement::Kind::TH1F) {
298  average = me_slice->getMean();
299  rms = me_slice->getRMS();
300  TH1F *th_slice = me_slice->getTH1F();
301  if (th_slice && th_slice->GetEntries() > 0) {
302  // need our own copy for thread safety
303  TF1 gaus("mygaus", "gaus");
304  th_slice->Fit(&gaus, "Q0 SERIAL");
305  sigma = gaus.GetParameter(2);
306  mean = gaus.GetParameter(1);
307  }
308  }
309 }
310 
311 //
312 // -- Create Efficiency Plots
313 //
315  DQMStore::IGetter &igetter,
317  std::string &name) {
318  MonitorElement *me1 = igetter.get(folder + "/" + name + "ref_");
319  MonitorElement *me2 = igetter.get(folder + "/" + name + "gen_");
320  if (!me1 || !me2)
321  return;
322 
323  TH1F *me1_forEff = (TH1F *)me1->getTH1F()->Rebin(2, "me1_forEff");
324  TH1F *me2_forEff = (TH1F *)me2->getTH1F()->Rebin(2, "me2_forEff");
325 
326  MonitorElement *me_eff;
327  if ((me1->kind() == MonitorElement::Kind::TH1F) && (me1->kind() == MonitorElement::Kind::TH1F)) {
328  // TH1* th1 = me1->getTH1F();
329  // size_t nbinx = me1->getNbinsX();
330  size_t nbinx = me1_forEff->GetNbinsX();
331 
332  // float xmin = th1->GetXaxis()->GetXmin();
333  // float xmax = th1->GetXaxis()->GetXmax();
334  float xmin = me1_forEff->GetXaxis()->GetXmin();
335  float xmax = me1_forEff->GetXaxis()->GetXmax();
336  std::string xtit = me1->getAxisTitle(1);
337  std::string tit_new;
338  tit_new = ";" + xtit + ";" + xtit + " efficiency";
339 
340  ibooker.setCurrentFolder(folder);
341  me_eff = ibooker.book1D("efficiency_" + name, tit_new, nbinx, xmin, xmax);
342 
343  me_eff->Reset();
344  me_eff->setEfficiencyFlag();
345  /*
346  double efficiency;
347  for (size_t ix = 1; ix < nbinx+1; ++ix) {
348  float val1 = me1->getBinContent(ix);
349  float val2 = me2->getBinContent(ix);
350  if (val2 > 0.0) efficiency = val1/val2;
351  else efficiency = 0;
352  me_eff->setBinContent(ix,efficiency);
353  }
354  */
355  // Binomial errors "B" asked by Florian
356  /*me1_forEff->Sumw2(); me2_forEff->Sumw2();*/ me_eff->enableSumw2();
357  me_eff->getTH1F()->Divide(me1_forEff, me2_forEff, 1, 1, "B");
358  }
359 }
360 
PFClient::profileHistogramNames_
std::vector< std::string > profileHistogramNames_
Definition: PFClient.h:34
PFClient::dqmEndJob
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: PFClient.cc:27
Handle.h
fw3dlego::xbins
const double xbins[]
Definition: fw3dlego_xbins.cc:16
mps_fire.i
i
Definition: mps_fire.py:428
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
dqm::impl::MonitorElement::setEntries
virtual void setEntries(double nentries)
set # of entries
Definition: MonitorElement.cc:738
PFClient::histogramNames_
std::vector< std::string > histogramNames_
Definition: PFClient.h:31
PFClient::createProfilePlots
void createProfilePlots(DQMStore::IBooker &, DQMStore::IGetter &, std::string &folder, std::string &name)
Definition: PFClient.cc:227
PFClient::doProjection
void doProjection(DQMStore::IBooker &, DQMStore::IGetter &)
Definition: PFClient.cc:55
printsummarytable.folder
folder
Definition: printsummarytable.py:7
MonitorElementData::Kind::TH1F
dqm::impl::MonitorElement::setEfficiencyFlag
void setEfficiencyFlag()
Definition: MonitorElement.h:267
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
PFClient::PFClient
PFClient(const edm::ParameterSet &parameterSet)
Definition: PFClient.cc:14
PFClient::folderNames_
std::vector< std::string > folderNames_
Definition: PFClient.h:30
SiStripPI::rms
Definition: SiStripPayloadInspectorHelper.h:169
dqm::impl::MonitorElement::kind
Kind kind() const
Get the type of the monitor element.
Definition: MonitorElement.h:247
PFClient::projectionHistogramNames_
std::vector< std::string > projectionHistogramNames_
Definition: PFClient.h:33
dqm::legacy::MonitorElement::getTH1F
virtual TH1F * getTH1F() const
Definition: MonitorElement.h:479
MonitorElementData::Kind::TH2D
MonitorElementData::Kind::TH2F
edm::parameterSet
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
PDRates.average
average
Definition: PDRates.py:138
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
L1TOccupancyClient_cfi.ymax
ymax
Definition: L1TOccupancyClient_cfi.py:43
PFClient::getHistogramParameters
void getHistogramParameters(MonitorElement *me_slice, double &avarage, double &rms, double &mean, double &sigma)
Definition: PFClient.cc:288
hlt_dqm_clientPB-live_cfg.me2
me2
Definition: hlt_dqm_clientPB-live_cfg.py:78
PFClient::doSummaries
void doSummaries(DQMStore::IBooker &, DQMStore::IGetter &)
Definition: PFClient.cc:39
Service.h
dqm::impl::MonitorElement::Reset
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
Definition: MonitorElement.cc:354
dqm::implementation::IBooker::bookProfile
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:322
dqm::impl::MonitorElement::getRMS
virtual double getRMS(int axis=1) const
get RMS of histogram along x, y or z axis (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:562
dqm::legacy::MonitorElement::getTProfile
virtual TProfile * getTProfile() const
Definition: MonitorElement.h:507
PFClient::createProjectionPlots
void createProjectionPlots(DQMStore::IBooker &, DQMStore::IGetter &, std::string &folder, std::string &name)
Definition: PFClient.cc:172
PFClient::createEfficiencyPlots
void createEfficiencyPlots(DQMStore::IBooker &, DQMStore::IGetter &, std::string &folder, std::string &name)
Definition: PFClient.cc:314
PFClient
Definition: PFClient.h:12
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
dqm::impl::MonitorElement::setBinEntries
virtual void setBinEntries(int bin, double nentries)
set # of bin entries (to be used for profiles)
Definition: MonitorElement.cc:727
PFClient::efficiencyFlag_
bool efficiencyFlag_
Definition: PFClient.h:35
average
Definition: average.py:1
dqmMemoryStats.stats
stats
Definition: dqmMemoryStats.py:134
hlt_dqm_clientPB-live_cfg.me1
me1
Definition: hlt_dqm_clientPB-live_cfg.py:73
PFClient.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PFClient::doEfficiency
void doEfficiency(DQMStore::IBooker &, DQMStore::IGetter &)
Definition: PFClient.cc:89
InputTag.h
PFClient::effHistogramNames_
std::vector< std::string > effHistogramNames_
Definition: PFClient.h:32
dqm::impl::MonitorElement::setBinContent
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
Definition: MonitorElement.cc:691
MonitorElementData::Kind::TH2S
hlt_dqm_clientPB-live_cfg.profileX
profileX
Definition: hlt_dqm_clientPB-live_cfg.py:76
L1TOccupancyClient_cfi.ymin
ymin
Definition: L1TOccupancyClient_cfi.py:43
dqm::implementation::IGetter
Definition: DQMStore.h:484
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
PFClient::createResolutionPlots
void createResolutionPlots(DQMStore::IBooker &, DQMStore::IGetter &, std::string &folder, std::string &name)
Definition: PFClient.cc:105
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
dqm::impl::MonitorElement::getMean
virtual double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:549
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dqm::implementation::IBooker
Definition: DQMStore.h:43
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
PFClient::profileFlag_
bool profileFlag_
Definition: PFClient.h:36
ParameterSet.h
dqm::impl::MonitorElement::enableSumw2
virtual void enableSumw2()
Definition: MonitorElement.cc:872
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
PFClient::doProfiles
void doProfiles(DQMStore::IBooker &, DQMStore::IGetter &)
Definition: PFClient.cc:72
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98