CMS 3D CMS Logo

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