CMS 3D CMS Logo

ConversionPostprocessing.cc
Go to the documentation of this file.
1 #include <iostream>
2 //
3 
5 
6 //
7 
18 using namespace std;
19 
21  dbe_ = nullptr;
22  dbe_ = edm::Service<DQMStore>().operator->();
23  parameters_ = pset;
24 
25  standAlone_ = pset.getParameter<bool>("standAlone");
26  batch_ = pset.getParameter<bool>("batch");
27  outputFileName_ = pset.getParameter<string>("OutputFileName");
28  inputFileName_ = pset.getParameter<std::string>("InputFileName");
29 
30  etMin = parameters_.getParameter<double>("etMin");
31  etMax = parameters_.getParameter<double>("etMax");
32  etBin = parameters_.getParameter<int>("etBin");
33 
34  etaMin = parameters_.getParameter<double>("etaMin");
35  etaMax = parameters_.getParameter<double>("etaMax");
36  etaBin = parameters_.getParameter<int>("etaBin");
37  etaBin2 = parameters_.getParameter<int>("etaBin2");
38 
39  phiMin = parameters_.getParameter<double>("phiMin");
40  phiMax = parameters_.getParameter<double>("phiMax");
41  phiBin = parameters_.getParameter<int>("phiBin");
42 
43  rMin = parameters_.getParameter<double>("rMin");
44  rMax = parameters_.getParameter<double>("rMax");
45  rBin = parameters_.getParameter<int>("rBin");
46 
47  zMin = parameters_.getParameter<double>("zMin");
48  zMax = parameters_.getParameter<double>("zMax");
49  zBin = parameters_.getParameter<int>("zBin");
50 }
51 
53 
55 
57 
59  if (standAlone_)
60  runPostprocessing();
61 }
62 
64  if (!standAlone_)
65  runPostprocessing();
66 }
67 
69  std::string simInfoPathName = "EgammaV/ConversionValidator/SimulationInfo/";
70  std::string convPathName = "EgammaV/ConversionValidator/ConversionInfo/";
71  std::string effPathName = "EgammaV/ConversionValidator/EfficienciesAndFakeRate/";
72 
73  if (batch_)
74  dbe_->open(inputFileName_);
75 
76  dbe_->setCurrentFolder(effPathName);
77  // Conversion reconstruction efficiency
78  std::string histname = "convEffVsEtaTwoTracks";
79  convEffEtaTwoTracks_ = dbe_->book1D(histname, histname, etaBin2, etaMin, etaMax);
80 
81  histname = "convEffVsPhiTwoTracks";
82  convEffPhiTwoTracks_ = dbe_->book1D(histname, histname, phiBin, phiMin, phiMax);
83 
84  histname = "convEffVsRTwoTracks";
85  convEffRTwoTracks_ = dbe_->book1D(histname, histname, rBin, rMin, rMax);
86 
87  histname = "convEffVsZTwoTracks";
88  convEffZTwoTracks_ = dbe_->book1D(histname, histname, zBin, zMin, zMax);
89 
90  histname = "convEffVsEtTwoTracks";
91  convEffEtTwoTracks_ = dbe_->book1D(histname, histname, etBin, etMin, etMax);
92  //
93  histname = "convEffVsEtaTwoTracksAndVtxProbGT0";
94  convEffEtaTwoTracksAndVtxProbGT0_ = dbe_->book1D(histname, histname, etaBin2, etaMin, etaMax);
95  histname = "convEffVsEtaTwoTracksAndVtxProbGT0005";
96  convEffEtaTwoTracksAndVtxProbGT0005_ = dbe_->book1D(histname, histname, etaBin2, etaMin, etaMax);
97  histname = "convEffVsRTwoTracksAndVtxProbGT0";
98  convEffRTwoTracksAndVtxProbGT0_ = dbe_->book1D(histname, histname, rBin, rMin, rMax);
99  histname = "convEffVsRTwoTracksAndVtxProbGT0005";
100  convEffRTwoTracksAndVtxProbGT0005_ = dbe_->book1D(histname, histname, rBin, rMin, rMax);
101  //
102  // Fake rate
103  histname = "convFakeRateVsEtaTwoTracks";
104  convFakeRateEtaTwoTracks_ = dbe_->book1D(histname, histname, etaBin2, etaMin, etaMax);
105  histname = "convFakeRateVsPhiTwoTracks";
106  convFakeRatePhiTwoTracks_ = dbe_->book1D(histname, histname, phiBin, phiMin, phiMax);
107  histname = "convFakeRateVsRTwoTracks";
108  convFakeRateRTwoTracks_ = dbe_->book1D(histname, histname, rBin, rMin, rMax);
109  histname = "convFakeRateVsZTwoTracks";
110  convFakeRateZTwoTracks_ = dbe_->book1D(histname, histname, zBin, zMin, zMax);
111  histname = "convFakeRateVsEtTwoTracks";
112  convFakeRateEtTwoTracks_ = dbe_->book1D(histname, histname, etBin, etMin, etMax);
113 
114  // efficiencies
115  dividePlots(dbe_->get(effPathName + "convEffVsEtaTwoTracks"),
116  dbe_->get(simInfoPathName + "h_SimConvTwoMTracksEta"),
117  dbe_->get(simInfoPathName + "h_VisSimConvEta"),
118  "effic");
119  dividePlots(dbe_->get(effPathName + "convEffVsPhiTwoTracks"),
120  dbe_->get(simInfoPathName + "h_SimConvTwoMTracksPhi"),
121  dbe_->get(simInfoPathName + "h_VisSimConvPhi"),
122  "effic");
123  dividePlots(dbe_->get(effPathName + "convEffVsRTwoTracks"),
124  dbe_->get(simInfoPathName + "h_SimConvTwoMTracksR"),
125  dbe_->get(simInfoPathName + "h_VisSimConvR"),
126  "effic");
127  dividePlots(dbe_->get(effPathName + "convEffVsZTwoTracks"),
128  dbe_->get(simInfoPathName + "h_SimConvTwoMTracksZ"),
129  dbe_->get(simInfoPathName + "h_VisSimConvZ"),
130  "effic");
131  dividePlots(dbe_->get(effPathName + "convEffVsEtTwoTracks"),
132  dbe_->get(simInfoPathName + "h_SimConvTwoMTracksEt"),
133  dbe_->get(simInfoPathName + "h_VisSimConvEt"),
134  "effic");
135  dividePlots(dbe_->get(effPathName + "convEffVsEtaTwoTracksAndVtxProbGT0"),
136  dbe_->get(simInfoPathName + "h_SimConvTwoMTracksEtaAndVtxPGT0"),
137  dbe_->get(simInfoPathName + "h_SimConvTwoMTracksEta"),
138  "effic");
139  dividePlots(dbe_->get(effPathName + "convEffVsEtaTwoTracksAndVtxProbGT0005"),
140  dbe_->get(simInfoPathName + "h_SimConvTwoMTracksEtaAndVtxPGT0005"),
141  dbe_->get(simInfoPathName + "h_SimConvTwoMTracksEta"),
142  "effic");
143  dividePlots(dbe_->get(effPathName + "convEffVsRTwoTracksAndVtxProbGT0"),
144  dbe_->get(simInfoPathName + "h_SimConvTwoMTracksRAndVtxPGT0"),
145  dbe_->get(simInfoPathName + "h_SimConvTwoMTracksR"),
146  "effic");
147  dividePlots(dbe_->get(effPathName + "convEffVsRTwoTracksAndVtxProbGT0005"),
148  dbe_->get(simInfoPathName + "h_SimConvTwoMTracksRAndVtxPGT0005"),
149  dbe_->get(simInfoPathName + "h_SimConvTwoMTracksR"),
150  "effic");
151 
152  // fake rate
153  dividePlots(dbe_->get(effPathName + "convFakeRateVsEtaTwoTracks"),
154  dbe_->get(convPathName + "convEtaAss2"),
155  dbe_->get(convPathName + "convEta2"),
156  "fakerate");
157  dividePlots(dbe_->get(effPathName + "convFakeRateVsPhiTwoTracks"),
158  dbe_->get(convPathName + "convPhiAss"),
159  dbe_->get(convPathName + "convPhi"),
160  "fakerate");
161  dividePlots(dbe_->get(effPathName + "convFakeRateVsRTwoTracks"),
162  dbe_->get(convPathName + "convRAss"),
163  dbe_->get(convPathName + "convR"),
164  "fakerate");
165  dividePlots(dbe_->get(effPathName + "convFakeRateVsZTwoTracks"),
166  dbe_->get(convPathName + "convZAss"),
167  dbe_->get(convPathName + "convZ"),
168  "fakerate");
169  dividePlots(dbe_->get(effPathName + "convFakeRateVsEtTwoTracks"),
170  dbe_->get(convPathName + "convPtAss"),
171  dbe_->get(convPathName + "convPt"),
172  "fakerate");
173 
174  if (standAlone_)
175  dbe_->save(outputFileName_);
176  else if (batch_)
177  dbe_->save(inputFileName_);
178 }
179 
183  std::string type) {
184  double value, err;
185 
186  //quick fix to avoid seg. faults due to null pointers.
187  if (dividend == nullptr || numerator == nullptr || denominator == nullptr)
188  return;
189 
190  for (int j = 1; j <= numerator->getNbinsX(); j++) {
191  if (denominator->getBinContent(j) != 0) {
192  if (type == "effic")
193  value = ((double)numerator->getBinContent(j)) / ((double)denominator->getBinContent(j));
194  else if (type == "fakerate")
195  value = 1 - ((double)numerator->getBinContent(j)) / ((double)denominator->getBinContent(j));
196  else
197  return;
198  err = sqrt(value * (1 - value) / ((double)denominator->getBinContent(j)));
199  dividend->setBinContent(j, value);
200  if (err != 0)
201  dividend->setBinError(j, err);
202  } else {
203  dividend->setBinContent(j, 0);
204  dividend->setBinError(j, 0);
205  }
206  }
207 }
208 
210  double value, err;
211 
212  //quick fix to avoid seg. faults due to null pointers.
213  if (dividend == nullptr || numerator == nullptr)
214  return;
215 
216  for (int j = 1; j <= numerator->getNbinsX(); j++) {
217  if (denominator != 0) {
218  value = ((double)numerator->getBinContent(j)) / denominator;
219  err = sqrt(value * (1 - value) / denominator);
220  dividend->setBinContent(j, value);
221  dividend->setBinError(j, err);
222  } else {
223  dividend->setBinContent(j, 0);
224  }
225  }
226 }
photonAnalyzer_cfi.rMax
rMax
Definition: photonAnalyzer_cfi.py:91
photonAnalyzer_cfi.etMin
etMin
Definition: photonAnalyzer_cfi.py:54
ALCARECOTkAlBeamHalo_cff.etaMin
etaMin
GeV.
Definition: ALCARECOTkAlBeamHalo_cff.py:32
photonAnalyzer_cfi.zMax
zMax
Definition: photonAnalyzer_cfi.py:95
ConversionPostprocessing::runPostprocessing
virtual void runPostprocessing()
Definition: ConversionPostprocessing.cc:68
etaBin
int etaBin(const l1t::HGCalMulticluster *cl)
Definition: L1EGammaEEProducer.cc:19
photonAnalyzer_cfi.zBin
zBin
Definition: photonAnalyzer_cfi.py:93
ConversionPostprocessing::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: ConversionPostprocessing.cc:56
edm::Run
Definition: Run.h:45
BeamMonitor_cff.phiBin
phiBin
Definition: BeamMonitor_cff.py:75
ConversionPostprocessing::~ConversionPostprocessing
~ConversionPostprocessing() override
Definition: ConversionPostprocessing.cc:52
ConversionPostprocessing::dividePlots
void dividePlots(MonitorElement *dividend, MonitorElement *numerator, MonitorElement *denominator, std::string type)
Definition: ConversionPostprocessing.cc:180
ConversionPostprocessing::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: ConversionPostprocessing.cc:63
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
conversionPostprocessing_cfi.etaBin2
etaBin2
Definition: conversionPostprocessing_cfi.py:19
ConversionPostprocessing.h
ConversionPostprocessing::endJob
void endJob() override
Definition: ConversionPostprocessing.cc:58
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
AlignmentTrackSelector_cfi.phiMin
phiMin
Definition: AlignmentTrackSelector_cfi.py:18
AlignmentTrackSelector_cfi.phiMax
phiMax
Definition: AlignmentTrackSelector_cfi.py:17
dqm::implementation::DQMStore::setCurrentFolder
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
dbe_
dqm::legacy::DQMStore * dbe_
Definition: PFJetBenchmarkAnalyzer.cc:77
dqm::implementation::DQMStore::save
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:760
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:36
runTheMatrix.err
err
Definition: runTheMatrix.py:288
ConversionPostprocessing::ConversionPostprocessing
ConversionPostprocessing(const edm::ParameterSet &pset)
Definition: ConversionPostprocessing.cc:20
photonAnalyzer_cfi.zMin
zMin
Definition: photonAnalyzer_cfi.py:94
edm::Service
Definition: Service.h:30
photonAnalyzer_cfi.rBin
rBin
Definition: photonAnalyzer_cfi.py:89
value
Definition: value.py:1
HLTTauDQMOffline_cfi.numerator
numerator
Definition: HLTTauDQMOffline_cfi.py:194
edm::EventSetup
Definition: EventSetup.h:57
ConversionPostprocessing::beginJob
void beginJob() override
Definition: ConversionPostprocessing.cc:54
cosmicPhotonAnalyzer_cfi.etMax
etMax
Definition: cosmicPhotonAnalyzer_cfi.py:11
HLTTauDQMOffline_cfi.denominator
denominator
Definition: HLTTauDQMOffline_cfi.py:195
dqm::impl::MonitorElement::setBinContent
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
Definition: MonitorElement.cc:691
type
type
Definition: HCALResponse.h:21
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
relativeConstraints.value
value
Definition: relativeConstraints.py:53
dqm::impl::MonitorElement::setBinError
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
Definition: MonitorElement.cc:709
ALCARECOTkAlBeamHalo_cff.etaMax
etaMax
Definition: ALCARECOTkAlBeamHalo_cff.py:33
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
dqm::implementation::DQMStore::open
DQM_DEPRECATED bool open(std::string const &filename, bool overwrite=false, std::string const &path="", std::string const &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:766
photonAnalyzer_cfi.rMin
rMin
Definition: photonAnalyzer_cfi.py:90
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
photonAnalyzer_cfi.etBin
etBin
Definition: photonAnalyzer_cfi.py:53
edm::Event
Definition: Event.h:73
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
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
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37