CMS 3D CMS Logo

PFClient_JetRes.cc
Go to the documentation of this file.
2 
7 
10 
11 #include "TCanvas.h"
12 #include "TGraph.h"
13 
14 //
15 // -- Constructor
16 //
18  folderNames_ = parameterSet.getParameter<std::vector<std::string>>("FolderNames");
19  histogramNames_ = parameterSet.getParameter<std::vector<std::string>>("HistogramNames");
20  efficiencyFlag_ = parameterSet.getParameter<bool>("CreateEfficiencyPlots");
21  effHistogramNames_ = parameterSet.getParameter<std::vector<std::string>>("HistogramNamesForEfficiencyPlots");
22  PtBins_ = parameterSet.getParameter<std::vector<int>>("VariablePtBins");
23 }
24 
25 //
26 // -- EndJobBegin Run
27 //
29  doSummaries(ibooker, igetter);
30  if (efficiencyFlag_)
31  doEfficiency(ibooker, igetter);
32 }
33 
34 //
35 // -- Create Summaries
36 //
38  for (std::vector<std::string>::const_iterator ifolder = folderNames_.begin(); ifolder != folderNames_.end();
39  ifolder++) {
40  std::string path = "ParticleFlow/" + (*ifolder);
41 
42  for (std::vector<std::string>::const_iterator ihist = histogramNames_.begin(); ihist != histogramNames_.end();
43  ihist++) {
44  std::string hname = (*ihist);
45  createResolutionPlots(ibooker, igetter, path, hname);
46  }
47  }
48 }
49 
50 //
51 // -- Create Efficiency
52 //
54  for (std::vector<std::string>::const_iterator ifolder = folderNames_.begin(); ifolder != folderNames_.end();
55  ifolder++) {
56  std::string path = "ParticleFlow/" + (*ifolder);
57 
58  for (std::vector<std::string>::const_iterator ihist = effHistogramNames_.begin(); ihist != effHistogramNames_.end();
59  ihist++) {
60  std::string hname = (*ihist);
61  createEfficiencyPlots(ibooker, igetter, path, hname);
62  }
63  }
64 }
65 
66 //
67 // -- Create Resolution Plots
68 //
70  DQMStore::IGetter &igetter,
72  std::string &name) {
73  MonitorElement *me = igetter.get(folder + "/" + name);
74  if (!me)
75  return;
76 
77  MonitorElement *pT[PtBins_.size() - 1];
78  std::vector<double> pTEntries(PtBins_.size() - 1, 0);
79 
80  // std::vector<std::string> pTRange (PtBins_.size() -1) ;
81  // char* pTRange[PtBins_.size() -1] ;
82  std::vector<TString> pTRange(PtBins_.size() - 1);
83  // float pTCenter[PtBins_.size() -1] ;
84 
85  MonitorElement *me_average;
86  MonitorElement *me_rms;
87  MonitorElement *me_mean;
88  MonitorElement *me_sigma;
89 
90  if ((me->kind() == MonitorElement::Kind::TH2F) || (me->kind() == MonitorElement::Kind::TH2S) ||
91  (me->kind() == MonitorElement::Kind::TH2D)) {
92  TH2 *th = me->getTH2F();
93  // size_t nbinx = me->getNbinsX();
94  size_t nbinx = PtBins_.size() - 1;
95  size_t nbiny = me->getNbinsY();
96 
97  float ymin = th->GetYaxis()->GetXmin();
98  float ymax = th->GetYaxis()->GetXmax();
99  std::string xtit = th->GetXaxis()->GetTitle();
100  // std::string ytit = th->GetYaxis()->GetTitle();
101  std::string ytit = "#Deltap_{T}/p_{T}";
102 
103  float *xbins = new float[nbinx + 1];
104  for (size_t ix = 1; ix < nbinx + 1; ++ix) {
105  // xbins[ix-1] = th->GetBinLowEdge(ix);
106  xbins[ix - 1] = PtBins_[ix - 1];
107  // snprintf(pTRange[ix-1].data(), 15, "Pt%d_%d", PtBins_[ix-1],
108  // PtBins_[ix]);
109  pTRange[ix - 1] = TString::Format("Pt%d_%d", PtBins_[ix - 1], PtBins_[ix]);
110  if (name == "BRdelta_et_Over_et_VS_et_")
111  pTRange[ix - 1] = TString::Format("BRPt%d_%d", PtBins_[ix - 1], PtBins_[ix]);
112  else if (name == "ERdelta_et_Over_et_VS_et_")
113  pTRange[ix - 1] = TString::Format("ERPt%d_%d", PtBins_[ix - 1], PtBins_[ix]);
114 
115  // pTCenter[ix-1] = (PtBins_[ix] - PtBins_[ix-1]) / 2. ;
116  if (ix == nbinx) {
117  // xbins[ix] = th->GetXaxis()->GetBinUpEdge(ix);
118  xbins[ix] = PtBins_[ix];
119  }
120  }
121 
122  std::string tit_new;
123  ibooker.setCurrentFolder(folder);
124  // MonitorElement* me_slice = ibooker.book1D("PFlowSlice", "PFlowSlice",
125  // nbiny, ymin, ymax);
126 
127  tit_new = "Average " + ytit + ";" + xtit + ";Average_" + ytit;
128  me_average = ibooker.book1D("average_" + name, tit_new, nbinx, xbins);
129  me_average->setEfficiencyFlag();
130  tit_new = "RMS " + ytit + ";" + xtit + ";RMS_" + ytit;
131  me_rms = ibooker.book1D("rms_" + name, tit_new, nbinx, xbins);
132  me_rms->setEfficiencyFlag();
133  tit_new = ";" + xtit + ";Mean_" + ytit;
134  me_mean = ibooker.book1D("mean_" + name, tit_new, nbinx, xbins);
135  me_mean->setEfficiencyFlag();
136  tit_new = ";" + xtit + ";Sigma_" + ytit;
137  me_sigma = ibooker.book1D("sigma_" + name, tit_new, nbinx, xbins);
138  me_sigma->setEfficiencyFlag();
139 
140  double average, rms, mean, sigma;
141  for (size_t ix = 1; ix < nbinx + 1; ++ix) {
142  // me_slice->Reset();
143  if (name == "delta_et_Over_et_VS_et_")
144  pT[ix - 1] = ibooker.book1D(
145  pTRange[ix - 1], TString::Format("Total %s;%s;Events", ytit.data(), ytit.data()), nbiny, ymin, ymax);
146  if (name == "BRdelta_et_Over_et_VS_et_")
147  pT[ix - 1] = ibooker.book1D(
148  pTRange[ix - 1], TString::Format("Barrel %s;%s;Events", ytit.data(), ytit.data()), nbiny, ymin, ymax);
149  else if (name == "ERdelta_et_Over_et_VS_et_")
150  pT[ix - 1] = ibooker.book1D(
151  pTRange[ix - 1], TString::Format("Endcap %s;%s;Events", ytit.data(), ytit.data()), nbiny, ymin, ymax);
152 
153  for (size_t iy = 0; iy <= nbiny + 1; ++iy) // add under and overflow
154  if (th->GetBinContent(ix, iy)) {
155  // me_slice->setBinContent(iy,th->GetBinContent(ix,iy));
156  pT[ix - 1]->setBinContent(iy, th->GetBinContent(ix, iy));
157  pT[ix - 1]->setBinError(iy, th->GetBinError(ix, iy));
158  pTEntries[ix - 1] += th->GetBinContent(ix, iy);
159  }
160 
161  pT[ix - 1]->setEntries(pTEntries[ix - 1]);
162 
163  // getHistogramParameters(me_slice, average, rms, mean, sigma);
164  getHistogramParameters(pT[ix - 1], average, rms, mean, sigma);
165  me_average->setBinContent(ix, average);
166  me_rms->setBinContent(ix, rms);
167  me_mean->setBinContent(ix, mean);
168  me_sigma->setBinContent(ix, sigma);
169  }
170  delete[] xbins;
171  }
172 }
173 
174 //
175 // -- Get Histogram Parameters
176 //
178  MonitorElement *me_slice, double &average, double &rms, double &mean, double &sigma) {
179  average = 0.0;
180  rms = 0.0;
181  mean = 0.0;
182  sigma = 0.0;
183 
184  if (!me_slice)
185  return;
186  if (me_slice->kind() == MonitorElement::Kind::TH1F) {
187  average = me_slice->getMean();
188  rms = me_slice->getRMS();
189  TH1F *th_slice = me_slice->getTH1F();
190  if (th_slice && th_slice->GetEntries() > 0) {
191  // need our own copy for thread safety
192  TF1 gaus("mygaus", "gaus");
193  th_slice->Fit(&gaus, "Q0 SERIAL");
194  sigma = gaus.GetParameter(2);
195  mean = gaus.GetParameter(1);
196  }
197  }
198 }
199 
200 //
201 // -- Create Resolution Plots
202 //
204  DQMStore::IGetter &igetter,
206  std::string &name) {
207  MonitorElement *me1 = igetter.get(folder + "/" + name);
208  MonitorElement *me2 = igetter.get(folder + "/" + name + "ref_");
209  if (!me1 || !me2)
210  return;
211  MonitorElement *me_eff;
212  if ((me1->kind() == MonitorElement::Kind::TH1F) && (me1->kind() == MonitorElement::Kind::TH1F)) {
213  TH1 *th1 = me1->getTH1F();
214  size_t nbinx = me1->getNbinsX();
215 
216  float xmin = th1->GetXaxis()->GetXmin();
217  float xmax = th1->GetXaxis()->GetXmax();
218  std::string xtit = me1->getAxisTitle(1);
219  std::string tit_new;
220  tit_new = ";" + xtit + ";Efficiency";
221 
222  ibooker.setCurrentFolder(folder);
223  me_eff = ibooker.book1D("efficiency_" + name, tit_new, nbinx, xmin, xmax);
224 
225  double efficiency;
226  me_eff->Reset();
227  me_eff->setEfficiencyFlag();
228  for (size_t ix = 1; ix < nbinx + 1; ++ix) {
229  float val1 = me1->getBinContent(ix);
230  float val2 = me2->getBinContent(ix);
231  if (val2 > 0.0)
232  efficiency = val1 / val2;
233  else
234  efficiency = 0;
235  me_eff->setBinContent(ix, efficiency);
236  }
237  }
238 }
239 
PFClient_JetRes::dqmEndJob
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: PFClient_JetRes.cc:28
Handle.h
fw3dlego::xbins
const double xbins[]
Definition: fw3dlego_xbins.cc:16
PFClient_JetRes::effHistogramNames_
std::vector< std::string > effHistogramNames_
Definition: PFClient_JetRes.h:27
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
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
PFClient_JetRes::folderNames_
std::vector< std::string > folderNames_
Definition: PFClient_JetRes.h:25
PFClient_JetRes.h
DQMStore.h
PFClient_JetRes::PtBins_
std::vector< int > PtBins_
Definition: PFClient_JetRes.h:28
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
L1TObjectsTimingClient_cff.efficiency
efficiency
Definition: L1TObjectsTimingClient_cff.py:10
PFClient_JetRes::doEfficiency
void doEfficiency(DQMStore::IBooker &, DQMStore::IGetter &)
Definition: PFClient_JetRes.cc:53
SiStripPI::rms
Definition: SiStripPayloadInspectorHelper.h:169
dqm::impl::MonitorElement::kind
Kind kind() const
Get the type of the monitor element.
Definition: MonitorElement.h:247
dqm::legacy::MonitorElement::getTH1F
virtual TH1F * getTH1F() const
Definition: MonitorElement.h:479
MonitorElementData::Kind::TH2D
PFClient_JetRes
Definition: PFClient_JetRes.h:12
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
hlt_dqm_clientPB-live_cfg.me2
me2
Definition: hlt_dqm_clientPB-live_cfg.py:78
PFClient_JetRes::efficiencyFlag_
bool efficiencyFlag_
Definition: PFClient_JetRes.h:30
PFClient_JetRes::histogramNames_
std::vector< std::string > histogramNames_
Definition: PFClient_JetRes.h:26
Service.h
PVValHelper::pT
Definition: PVValidationHelpers.h:71
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::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
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
average
Definition: average.py:1
hlt_dqm_clientPB-live_cfg.me1
me1
Definition: hlt_dqm_clientPB-live_cfg.py:73
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
InputTag.h
PFClient_JetRes::doSummaries
void doSummaries(DQMStore::IBooker &, DQMStore::IGetter &)
Definition: PFClient_JetRes.cc:37
dqm::impl::MonitorElement::setBinContent
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
Definition: MonitorElement.cc:691
MonitorElementData::Kind::TH2S
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
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
ParameterSet.h
PFClient_JetRes::PFClient_JetRes
PFClient_JetRes(const edm::ParameterSet &parameterSet)
Definition: PFClient_JetRes.cc:17
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_JetRes::createResolutionPlots
void createResolutionPlots(DQMStore::IBooker &, DQMStore::IGetter &, std::string &folder, std::string &name)
Definition: PFClient_JetRes.cc:69
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
PFClient_JetRes::createEfficiencyPlots
void createEfficiencyPlots(DQMStore::IBooker &, DQMStore::IGetter &, std::string &folder, std::string &name)
Definition: PFClient_JetRes.cc:203
PFClient_JetRes::getHistogramParameters
void getHistogramParameters(MonitorElement *me_slice, double &avarage, double &rms, double &mean, double &sigma)
Definition: PFClient_JetRes.cc:177