CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Primary4DVertexHarvester.cc
Go to the documentation of this file.
1 #include <string>
2 
7 
10 
12 
14 public:
16  ~Primary4DVertexHarvester() override;
17 
18  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
19 
20 protected:
22 
23 private:
25 
26  // --- Histograms
31 };
32 
33 // ------------ constructor and destructor --------------
35  : folder_(iConfig.getParameter<std::string>("folder")) {}
36 
38 
39 // ------------ endjob tasks ----------------------------
41  // --- Get the monitoring histograms
42  MonitorElement* meMVATrackEffPtTot = igetter.get(folder_ + "MVAEffPtTot");
43  MonitorElement* meMVATrackMatchedEffPtTot = igetter.get(folder_ + "MVAMatchedEffPtTot");
44  MonitorElement* meMVATrackMatchedEffPtMtd = igetter.get(folder_ + "MVAMatchedEffPtMtd");
45  MonitorElement* meMVATrackEffEtaTot = igetter.get(folder_ + "MVAEffEtaTot");
46  MonitorElement* meMVATrackMatchedEffEtaTot = igetter.get(folder_ + "MVAMatchedEffEtaTot");
47  MonitorElement* meMVATrackMatchedEffEtaMtd = igetter.get(folder_ + "MVAMatchedEffEtaMtd");
48  MonitorElement* meRecoVtxVsLineDensity = igetter.get(folder_ + "RecoVtxVsLineDensity");
49  MonitorElement* meRecVerNumber = igetter.get(folder_ + "RecVerNumber");
50 
51  if (!meMVATrackEffPtTot || !meMVATrackMatchedEffPtTot || !meMVATrackMatchedEffPtMtd || !meMVATrackEffEtaTot ||
52  !meMVATrackMatchedEffEtaTot || !meMVATrackMatchedEffEtaMtd || !meRecoVtxVsLineDensity || !meRecVerNumber) {
53  edm::LogError("Primary4DVertexHarvester") << "Monitoring histograms not found!" << std::endl;
54  return;
55  }
56 
57  // Normalize line density plot
58  double nEvt = meRecVerNumber->getEntries();
59  if (nEvt > 0.) {
60  nEvt = 1. / nEvt;
61  double nEntries = meRecoVtxVsLineDensity->getEntries();
62  for (int ibin = 1; ibin <= meRecoVtxVsLineDensity->getNbinsX(); ibin++) {
63  double cont = meRecoVtxVsLineDensity->getBinContent(ibin) * nEvt;
64  double bin_err = meRecoVtxVsLineDensity->getBinError(ibin) * nEvt;
65  meRecoVtxVsLineDensity->setBinContent(ibin, cont);
66  meRecoVtxVsLineDensity->setBinError(ibin, bin_err);
67  }
68  meRecoVtxVsLineDensity->setEntries(nEntries);
69  }
70 
71  // --- Book histograms
72  ibook.cd(folder_);
73  meMVAPtSelEff_ = ibook.book1D("MVAPtSelEff",
74  "Track selected efficiency VS Pt;Pt [GeV];Efficiency",
75  meMVATrackEffPtTot->getNbinsX(),
76  meMVATrackEffPtTot->getTH1()->GetXaxis()->GetXmin(),
77  meMVATrackEffPtTot->getTH1()->GetXaxis()->GetXmax());
78  meMVAEtaSelEff_ = ibook.book1D("MVAEtaSelEff",
79  "Track selected efficiency VS Eta;Eta;Efficiency",
80  meMVATrackEffEtaTot->getNbinsX(),
81  meMVATrackEffEtaTot->getTH1()->GetXaxis()->GetXmin(),
82  meMVATrackEffEtaTot->getTH1()->GetXaxis()->GetXmax());
83  meMVAPtMatchEff_ = ibook.book1D("MVAPtMatchEff",
84  "Track matched to GEN efficiency VS Pt;Pt [GeV];Efficiency",
85  meMVATrackMatchedEffPtTot->getNbinsX(),
86  meMVATrackMatchedEffPtTot->getTH1()->GetXaxis()->GetXmin(),
87  meMVATrackMatchedEffPtTot->getTH1()->GetXaxis()->GetXmax());
88  meMVAEtaMatchEff_ = ibook.book1D("MVAEtaMatchEff",
89  "Track matched to GEN efficiency VS Eta;Eta;Efficiency",
90  meMVATrackMatchedEffEtaTot->getNbinsX(),
91  meMVATrackMatchedEffEtaTot->getTH1()->GetXaxis()->GetXmin(),
92  meMVATrackMatchedEffEtaTot->getTH1()->GetXaxis()->GetXmax());
93 
94  meMVAPtSelEff_->getTH1()->SetMinimum(0.);
95  meMVAEtaSelEff_->getTH1()->SetMinimum(0.);
96  meMVAPtMatchEff_->getTH1()->SetMinimum(0.);
97  meMVAEtaMatchEff_->getTH1()->SetMinimum(0.);
98 
99  for (int ibin = 1; ibin <= meMVATrackEffPtTot->getNbinsX(); ibin++) {
100  double eff = meMVATrackMatchedEffPtTot->getBinContent(ibin) / meMVATrackEffPtTot->getBinContent(ibin);
101  double bin_err = sqrt((meMVATrackMatchedEffPtTot->getBinContent(ibin) *
102  (meMVATrackEffPtTot->getBinContent(ibin) - meMVATrackMatchedEffPtTot->getBinContent(ibin))) /
103  pow(meMVATrackEffPtTot->getBinContent(ibin), 3));
104  if (meMVATrackEffPtTot->getBinContent(ibin) == 0) {
105  eff = 0;
106  bin_err = 0;
107  }
108  meMVAPtSelEff_->setBinContent(ibin, eff);
109  meMVAPtSelEff_->setBinError(ibin, bin_err);
110  }
111 
112  for (int ibin = 1; ibin <= meMVATrackEffEtaTot->getNbinsX(); ibin++) {
113  double eff = meMVATrackMatchedEffEtaTot->getBinContent(ibin) / meMVATrackEffEtaTot->getBinContent(ibin);
114  double bin_err =
115  sqrt((meMVATrackMatchedEffEtaTot->getBinContent(ibin) *
116  (meMVATrackEffEtaTot->getBinContent(ibin) - meMVATrackMatchedEffEtaTot->getBinContent(ibin))) /
117  pow(meMVATrackEffEtaTot->getBinContent(ibin), 3));
118  if (meMVATrackEffEtaTot->getBinContent(ibin) == 0) {
119  eff = 0;
120  bin_err = 0;
121  }
122  meMVAEtaSelEff_->setBinContent(ibin, eff);
123  meMVAEtaSelEff_->setBinError(ibin, bin_err);
124  }
125 
126  for (int ibin = 1; ibin <= meMVATrackMatchedEffPtTot->getNbinsX(); ibin++) {
127  double eff = meMVATrackMatchedEffPtMtd->getBinContent(ibin) / meMVATrackMatchedEffPtTot->getBinContent(ibin);
128  double bin_err =
129  sqrt((meMVATrackMatchedEffPtMtd->getBinContent(ibin) *
130  (meMVATrackMatchedEffPtTot->getBinContent(ibin) - meMVATrackMatchedEffPtMtd->getBinContent(ibin))) /
131  pow(meMVATrackMatchedEffPtTot->getBinContent(ibin), 3));
132  if (meMVATrackMatchedEffPtTot->getBinContent(ibin) == 0) {
133  eff = 0;
134  bin_err = 0;
135  }
136  meMVAPtMatchEff_->setBinContent(ibin, eff);
137  meMVAPtMatchEff_->setBinError(ibin, bin_err);
138  }
139 
140  for (int ibin = 1; ibin <= meMVATrackMatchedEffEtaTot->getNbinsX(); ibin++) {
141  double eff = meMVATrackMatchedEffEtaMtd->getBinContent(ibin) / meMVATrackMatchedEffEtaTot->getBinContent(ibin);
142  double bin_err =
143  sqrt((meMVATrackMatchedEffEtaMtd->getBinContent(ibin) *
144  (meMVATrackMatchedEffEtaTot->getBinContent(ibin) - meMVATrackMatchedEffEtaMtd->getBinContent(ibin))) /
145  pow(meMVATrackMatchedEffEtaTot->getBinContent(ibin), 3));
146  if (meMVATrackMatchedEffEtaTot->getBinContent(ibin) == 0) {
147  eff = 0;
148  bin_err = 0;
149  }
150  meMVAEtaMatchEff_->setBinContent(ibin, eff);
151  meMVAEtaMatchEff_->setBinError(ibin, bin_err);
152  }
153 }
154 
155 // ------------ method fills 'descriptions' with the allowed parameters for the module ----------
158 
159  desc.add<std::string>("folder", "MTD/Vertices/");
160 
161  descriptions.add("Primary4DVertexPostProcessor", desc);
162 }
163 
std::string folder_
tuple cont
load Luminosity info ##
Definition: generateEDF.py:628
virtual void setEntries(double nentries)
set # of entries
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Primary4DVertexHarvester(const edm::ParameterSet &iConfig)
virtual double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
Log< level::Error, false > LogError
virtual int getNbinsX() const
get # of bins in X-axis
virtual double getEntries() const
get # of entries
T sqrt(T t)
Definition: SSEVec.h:19
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
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)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
virtual TH1 * getTH1() const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29