CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ConversionPostprocessing.cc
Go to the documentation of this file.
1 #include <iostream>
2 //
3 
5 
6 //
7 
21 using namespace std;
22 
23 
25 {
26 
27  dbe_ = 0;
29  dbe_->setVerbose(0);
30  parameters_ = pset;
31 
32 
33  standAlone_ = pset.getParameter<bool>("standAlone");
34  batch_ = pset.getParameter<bool>("batch");
35  outputFileName_ = pset.getParameter<string>("OutputFileName");
36  inputFileName_ = pset.getParameter<std::string>("InputFileName");
37 
38 
39  etMin = parameters_.getParameter<double>("etMin");
40  etMax = parameters_.getParameter<double>("etMax");
41  etBin = parameters_.getParameter<int>("etBin");
42 
43  etaMin = parameters_.getParameter<double>("etaMin");
44  etaMax = parameters_.getParameter<double>("etaMax");
45  etaBin = parameters_.getParameter<int>("etaBin");
46  etaBin2 = parameters_.getParameter<int>("etaBin2");
47 
48  phiMin = parameters_.getParameter<double>("phiMin");
49  phiMax = parameters_.getParameter<double>("phiMax");
50  phiBin = parameters_.getParameter<int>("phiBin");
51 
52  rMin = parameters_.getParameter<double>("rMin");
53  rMax = parameters_.getParameter<double>("rMax");
54  rBin = parameters_.getParameter<int>("rBin");
55 
56  zMin = parameters_.getParameter<double>("zMin");
57  zMax = parameters_.getParameter<double>("zMax");
58  zBin = parameters_.getParameter<int>("zBin");
59 
60 
61 
62 }
63 
64 
65 
67 {}
68 
70 {
71 
72 }
73 
75 {}
76 
77 
79 
80 if(standAlone_) runPostprocessing();
81 
82 }
83 
85 
86  if(!standAlone_) runPostprocessing();
87 
88 }
89 
90 
91 
93 {
94 
95 
96 
97  std::string simInfoPathName = "EgammaV/ConversionValidator/SimulationInfo/";
98  std::string convPathName = "EgammaV/ConversionValidator/ConversionInfo/";
99  std::string effPathName = "EgammaV/ConversionValidator/EfficienciesAndFakeRate/";
100 
101 
102  if(batch_) dbe_->open(inputFileName_);
103 
104  dbe_->setCurrentFolder(effPathName);
105  // Conversion reconstruction efficiency
106  std::string histname = "convEffVsEtaTwoTracks";
107  convEffEtaTwoTracks_ = dbe_->book1D(histname,histname,etaBin2,etaMin, etaMax);
108 
109  histname = "convEffVsPhiTwoTracks";
110  convEffPhiTwoTracks_ = dbe_->book1D(histname,histname,phiBin,phiMin,phiMax);
111 
112  histname = "convEffVsRTwoTracks";
113  convEffRTwoTracks_ = dbe_->book1D(histname,histname,rBin,rMin, rMax);
114 
115  histname = "convEffVsZTwoTracks";
116  convEffZTwoTracks_ = dbe_->book1D(histname,histname,zBin,zMin,zMax);
117 
118  histname = "convEffVsEtTwoTracks";
119  convEffEtTwoTracks_ = dbe_->book1D(histname,histname,etBin,etMin, etMax);
120  //
121  histname = "convEffVsEtaTwoTracksAndVtxProbGT0";
122  convEffEtaTwoTracksAndVtxProbGT0_ = dbe_->book1D(histname,histname,etaBin2,etaMin, etaMax);
123  histname = "convEffVsEtaTwoTracksAndVtxProbGT0005";
124  convEffEtaTwoTracksAndVtxProbGT0005_ = dbe_->book1D(histname,histname,etaBin2,etaMin, etaMax);
125  histname = "convEffVsRTwoTracksAndVtxProbGT0";
126  convEffRTwoTracksAndVtxProbGT0_ = dbe_->book1D(histname,histname,rBin,rMin,rMax);
127  histname = "convEffVsRTwoTracksAndVtxProbGT0005";
128  convEffRTwoTracksAndVtxProbGT0005_ = dbe_->book1D(histname,histname,rBin,rMin,rMax);
129  //
130  // Fake rate
131  histname = "convFakeRateVsEtaTwoTracks";
132  convFakeRateEtaTwoTracks_ = dbe_->book1D(histname,histname,etaBin2,etaMin, etaMax);
133  histname = "convFakeRateVsPhiTwoTracks";
134  convFakeRatePhiTwoTracks_ = dbe_->book1D(histname,histname,phiBin,phiMin,phiMax);
135  histname = "convFakeRateVsRTwoTracks";
136  convFakeRateRTwoTracks_ = dbe_->book1D(histname,histname,rBin,rMin, rMax);
137  histname = "convFakeRateVsZTwoTracks";
138  convFakeRateZTwoTracks_ = dbe_->book1D(histname,histname,zBin,zMin,zMax);
139  histname = "convFakeRateVsEtTwoTracks";
140  convFakeRateEtTwoTracks_ = dbe_->book1D(histname,histname,etBin,etMin, etMax);
141 
142  // efficiencies
143  dividePlots(dbe_->get(effPathName+"convEffVsEtaTwoTracks"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEta"),dbe_->get(simInfoPathName+"h_VisSimConvEta"),"effic");
144  dividePlots(dbe_->get(effPathName+"convEffVsPhiTwoTracks"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksPhi"),dbe_->get(simInfoPathName+"h_VisSimConvPhi"),"effic");
145  dividePlots(dbe_->get(effPathName+"convEffVsRTwoTracks"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksR"),dbe_->get(simInfoPathName+"h_VisSimConvR"),"effic");
146  dividePlots(dbe_->get(effPathName+"convEffVsZTwoTracks"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksZ"),dbe_->get(simInfoPathName+"h_VisSimConvZ"),"effic");
147  dividePlots(dbe_->get(effPathName+"convEffVsEtTwoTracks"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEt"),dbe_->get(simInfoPathName+"h_VisSimConvEt"),"effic");
148  dividePlots(dbe_->get(effPathName+"convEffVsEtaTwoTracksAndVtxProbGT0"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEtaAndVtxPGT0"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEta"),"effic");
149  dividePlots(dbe_->get(effPathName+"convEffVsEtaTwoTracksAndVtxProbGT0005"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEtaAndVtxPGT0005"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEta"),"effic");
150  dividePlots(dbe_->get(effPathName+"convEffVsRTwoTracksAndVtxProbGT0"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksRAndVtxPGT0"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksR"),"effic");
151  dividePlots(dbe_->get(effPathName+"convEffVsRTwoTracksAndVtxProbGT0005"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksRAndVtxPGT0005"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksR"),"effic");
152 
153 
154  // fake rate
155  dividePlots(dbe_->get(effPathName+"convFakeRateVsEtaTwoTracks"),dbe_->get(convPathName+"convEtaAss2"),dbe_->get(convPathName+"convEta2"),"fakerate");
156  dividePlots(dbe_->get(effPathName+"convFakeRateVsPhiTwoTracks"),dbe_->get(convPathName+"convPhiAss"),dbe_->get(convPathName+"convPhi"),"fakerate");
157  dividePlots(dbe_->get(effPathName+"convFakeRateVsRTwoTracks"),dbe_->get(convPathName+"convRAss"),dbe_->get(convPathName+"convR"),"fakerate");
158  dividePlots(dbe_->get(effPathName+"convFakeRateVsZTwoTracks"),dbe_->get(convPathName+"convZAss"),dbe_->get(convPathName+"convZ"),"fakerate");
159  dividePlots(dbe_->get(effPathName+"convFakeRateVsEtTwoTracks"),dbe_->get(convPathName+"convPtAss"),dbe_->get(convPathName+"convPt"),"fakerate");
160 
161 
162 
163  if(standAlone_) dbe_->save(outputFileName_);
164  else if(batch_) dbe_->save(inputFileName_);
165 }
166 
167 
169 {
170 
171 
172 }
173 
174 
175 
177  double value,err;
178 
179  //quick fix to avoid seg. faults due to null pointers.
180  if (dividend==0 || numerator==0 || denominator==0)return;
181 
182  for (int j=1; j<=numerator->getNbinsX(); j++){
183 
184  if (denominator->getBinContent(j)!=0){
185  if (type=="effic")
186  value = ((double) numerator->getBinContent(j))/((double) denominator->getBinContent(j));
187  else if (type=="fakerate")
188  value = 1-((double) numerator->getBinContent(j))/((double) denominator->getBinContent(j));
189  else return;
190  err = sqrt( value*(1-value) / ((double) denominator->getBinContent(j)) );
191  dividend->setBinContent(j, value);
192  if ( err !=0 ) dividend->setBinError(j,err);
193  }
194  else {
195  dividend->setBinContent(j, 0);
196  dividend->setBinError(j,0);
197  }
198 
199  }
200 
201 
202 }
203 
204 
206  double value,err;
207 
208  //quick fix to avoid seg. faults due to null pointers.
209  if (dividend==0 || numerator==0 )return;
210 
211  for (int j=1; j<=numerator->getNbinsX(); j++){
212  if (denominator!=0){
213  value = ((double) numerator->getBinContent(j))/denominator;
214  err = sqrt( value*(1-value) / denominator);
215  dividend->setBinContent(j, value);
216  dividend->setBinError(j,err);
217  }
218  else {
219  dividend->setBinContent(j, 0);
220  }
221  }
222 
223 }
224 
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
void setBinContent(int binx, double content)
set content of bin (1-D)
list numerator
Definition: cuy.py:483
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
tuple lumi
Definition: fjr2json.py:35
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2118
void dividePlots(MonitorElement *dividend, MonitorElement *numerator, MonitorElement *denominator, std::string type)
virtual void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
virtual void endRun(const edm::Run &, const edm::EventSetup &)
list denominator
Definition: cuy.py:484
T sqrt(T t)
Definition: SSEVec.h:48
int j
Definition: DBlmapReader.cc:9
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
void setVerbose(unsigned level)
Definition: DQMStore.cc:398
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1473
DQMStore * dbe_
bool etMin(const PFCandidate &cand, double cut)
ConversionPostprocessing(const edm::ParameterSet &pset)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
double getBinContent(int binx) const
get content of bin (1-D)
int getNbinsX(void) const
get # of bins in X-axis
bool open(const std::string &filename, bool overwrite=false, const std::string &path="", const std::string &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:2437
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
Definition: Run.h:36