CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PhotonPostprocessing.cc
Go to the documentation of this file.
1 #include <iostream>
2 //
3 
5 
6 
7 //#define TWOPI 6.283185308
8 //
9 
23 using namespace std;
24 
25 
27 {
28 
29  dbe_ = 0;
31  dbe_->setVerbose(0);
32  parameters_ = pset;
33 
34 
35  standAlone_ = pset.getParameter<bool>("standAlone");
36  batch_ = pset.getParameter<bool>("batch");
37  outputFileName_ = pset.getParameter<string>("OutputFileName");
38  inputFileName_ = pset.getParameter<std::string>("InputFileName");
39 
40 
41 
42  etMin = parameters_.getParameter<double>("etMin");
43  etMax = parameters_.getParameter<double>("etMax");
44  etBin = parameters_.getParameter<int>("etBin");
45 
46 
47  etaMin = parameters_.getParameter<double>("etaMin");
48  etaMax = parameters_.getParameter<double>("etaMax");
49  etaBin = parameters_.getParameter<int>("etaBin");
50  etaBin2 = parameters_.getParameter<int>("etaBin2");
51 
52  phiMin = parameters_.getParameter<double>("phiMin");
53  phiMax = parameters_.getParameter<double>("phiMax");
54  phiBin = parameters_.getParameter<int>("phiBin");
55 
56  rMin = parameters_.getParameter<double>("rMin");
57  rMax = parameters_.getParameter<double>("rMax");
58  rBin = parameters_.getParameter<int>("rBin");
59 
60  zMin = parameters_.getParameter<double>("zMin");
61  zMax = parameters_.getParameter<double>("zMax");
62  zBin = parameters_.getParameter<int>("zBin");
63 
64 
65 
66 }
67 
68 
69 
71 {}
72 
74 {
75 
76 }
77 
79 {}
80 
81 
83 
84 if(standAlone_) runPostprocessing();
85 
86 }
87 
89 
90  if(!standAlone_) runPostprocessing();
91 
92 }
93 
94 
96 {
97 
98 
99  std::string simInfoPathName = "EgammaV/PhotonValidator/SimulationInfo/";
100  std::string convPathName = "EgammaV/PhotonValidator/ConversionInfo/";
101  std::string effPathName = "EgammaV/PhotonValidator/Efficiencies/";
102 
103 
104  if(batch_) dbe_->open(inputFileName_);
105 
106  dbe_->setCurrentFolder(effPathName);
107  // Photon reconstruction efficiencies
108  string histname = "recoEffVsEta";
109  phoRecoEffEta_ = dbe_->book1D(histname,"Photon reconstruction efficiency vs simulated #eta",etaBin,etaMin, etaMax);
110  histname = "recoEffVsPhi";
111  phoRecoEffPhi_ = dbe_->book1D(histname,"Photon reconstruction efficiency vs simulated #phi",phiBin,phiMin, phiMax);
112  histname = "recoEffVsEt";
113  phoRecoEffEt_ = dbe_->book1D(histname,"Photon reconstruction efficiency vs simulated Et",etBin,etMin, etMax) ;
114  // Fraction of photons with at least one dead channel
115  histname = "deadChVsEta";
116  phoDeadChEta_ = dbe_->book1D(histname,"Fraction of photons with >=1 dead Xtal vs simulated #eta",etaBin,etaMin, etaMax);
117  histname = "deadChVsPhi";
118  phoDeadChPhi_ = dbe_->book1D(histname,"Fraction of photons with >=1 dead Xtal vs simulated #phi",phiBin,phiMin, phiMax);
119  histname = "deadChVsEt";
120  phoDeadChEt_ = dbe_->book1D(histname,"Fraction of photons with >=1 dead Xtal vs simulated Et",etBin,etMin, etMax) ;
121 
122  // Conversion reconstruction efficiency
123  histname = "convEffVsEtaTwoTracks";
124  convEffEtaTwoTracks_ = dbe_->book1D(histname,histname,etaBin2,etaMin, etaMax);
125 
126  histname = "convEffVsPhiTwoTracks";
127  convEffPhiTwoTracks_ = dbe_->book1D(histname,histname,phiBin,phiMin,phiMax);
128 
129  histname = "convEffVsRTwoTracks";
130  convEffRTwoTracks_ = dbe_->book1D(histname,histname,rBin,rMin, rMax);
131 
132  histname = "convEffVsZTwoTracks";
133  convEffZTwoTracks_ = dbe_->book1D(histname,histname,zBin,zMin,zMax);
134 
135  histname = "convEffVsEtTwoTracks";
136  convEffEtTwoTracks_ = dbe_->book1D(histname,histname,etBin,etMin, etMax);
137  //
138  histname = "convEffVsEtaTwoTracksAndVtxProbGT0";
139  convEffEtaTwoTracksAndVtxProbGT0_ = dbe_->book1D(histname,histname,etaBin2,etaMin, etaMax);
140  histname = "convEffVsEtaTwoTracksAndVtxProbGT0005";
141  convEffEtaTwoTracksAndVtxProbGT0005_ = dbe_->book1D(histname,histname,etaBin2,etaMin, etaMax);
142  histname = "convEffVsRTwoTracksAndVtxProbGT0";
143  convEffRTwoTracksAndVtxProbGT0_ = dbe_->book1D(histname,histname,rBin,rMin,rMax);
144  histname = "convEffVsRTwoTracksAndVtxProbGT0005";
145  convEffRTwoTracksAndVtxProbGT0005_ = dbe_->book1D(histname,histname,rBin,rMin,rMax);
146  //
147  histname = "convEffVsEtaOneTrack";
148  convEffEtaOneTrack_ = dbe_->book1D(histname,histname,etaBin2,etaMin, etaMax);
149  histname = "convEffVsROneTrack";
150  convEffROneTrack_ = dbe_->book1D(histname,histname,rBin,rMin, rMax);
151  histname = "convEffVsEtOneTrack";
152  convEffEtOneTrack_ = dbe_->book1D(histname,histname,etBin,etMin, etMax);
153  // Fake rate
154  histname = "convFakeRateVsEtaTwoTracks";
155  convFakeRateEtaTwoTracks_ = dbe_->book1D(histname,histname,etaBin2,etaMin, etaMax);
156  histname = "convFakeRateVsPhiTwoTracks";
157  convFakeRatePhiTwoTracks_ = dbe_->book1D(histname,histname,phiBin,phiMin,phiMax);
158  histname = "convFakeRateVsRTwoTracks";
159  convFakeRateRTwoTracks_ = dbe_->book1D(histname,histname,rBin,rMin, rMax);
160  histname = "convFakeRateVsZTwoTracks";
161  convFakeRateZTwoTracks_ = dbe_->book1D(histname,histname,zBin,zMin,zMax);
162  histname = "convFakeRateVsEtTwoTracks";
163  convFakeRateEtTwoTracks_ = dbe_->book1D(histname,histname,etBin,etMin, etMax);
164 
165  histname = "bkgEffVsEta";
166  bkgRecoEffEta_ = dbe_->book1D(histname,"Bkg reconstruction efficiency vs simulated #eta",etaBin,etaMin, etaMax);
167  histname = "bkgEffVsPhi";
168  bkgRecoEffPhi_ = dbe_->book1D(histname,"Bkg reconstruction efficiency vs simulated #phi",phiBin,phiMin, phiMax);
169  histname = "bkgEffVsEt";
170  bkgRecoEffEt_ = dbe_->book1D(histname,"Bkg reconstruction efficiency vs simulated Et",etBin,etMin, etMax) ;
171  // Fraction of photons with at least one dead channel
172  histname = "deadChVsEtaBkg";
173  bkgDeadChEta_ = dbe_->book1D(histname,"Fraction of bkg with >=1 dead Xtal vs simulated #eta",etaBin,etaMin, etaMax);
174  histname = "deadChVsPhiBkg";
175  bkgDeadChPhi_ = dbe_->book1D(histname,"Fraction of bkg with >=1 dead Xtal vs simulated #phi",phiBin,phiMin, phiMax);
176  histname = "deadChVsEtBkg";
177  bkgDeadChEt_ = dbe_->book1D(histname,"Fraction of bkg with >=1 dead Xtal vs simulated Et",etBin,etMin, etMax) ;
178 
179  // efficiencies
180  dividePlots(dbe_->get(effPathName+"recoEffVsEta"),dbe_->get(simInfoPathName+"h_MatchedSimPhoEta"),dbe_->get(simInfoPathName+"h_SimPhoEta"), "effic");
181  dividePlots(dbe_->get(effPathName+"recoEffVsPhi"),dbe_->get(simInfoPathName+"h_MatchedSimPhoPhi"),dbe_->get(simInfoPathName+"h_SimPhoPhi"),"effic");
182  dividePlots(dbe_->get(effPathName+"recoEffVsEt"),dbe_->get(simInfoPathName+"h_MatchedSimPhoEt"),dbe_->get(simInfoPathName+"h_SimPhoEt"),"effic");
183  // fraction of photons with at least one dead channel
184  dividePlots(dbe_->get(effPathName+"deadChVsEta"),dbe_->get(simInfoPathName+"h_MatchedSimPhoBadChEta"),dbe_->get(simInfoPathName+"h_MatchedSimPhoEta"), "effic");
185  dividePlots(dbe_->get(effPathName+"deadChVsPhi"),dbe_->get(simInfoPathName+"h_MatchedSimPhoBadChPhi"),dbe_->get(simInfoPathName+"h_MatchedSimPhoPhi"),"effic");
186  dividePlots(dbe_->get(effPathName+"deadChVsEt"), dbe_->get(simInfoPathName+"h_MatchedSimPhoBadChEt"),dbe_->get(simInfoPathName+"h_MatchedSimPhoEt"),"effic");
187  //
188  dividePlots(dbe_->get(effPathName+"convEffVsEtaTwoTracks"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEta"),dbe_->get(simInfoPathName+"h_VisSimConvEta"),"effic");
189  dividePlots(dbe_->get(effPathName+"convEffVsPhiTwoTracks"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksPhi"),dbe_->get(simInfoPathName+"h_VisSimConvPhi"),"effic");
190  dividePlots(dbe_->get(effPathName+"convEffVsRTwoTracks"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksR"),dbe_->get(simInfoPathName+"h_VisSimConvR"),"effic");
191  dividePlots(dbe_->get(effPathName+"convEffVsZTwoTracks"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksZ"),dbe_->get(simInfoPathName+"h_VisSimConvZ"),"effic");
192  dividePlots(dbe_->get(effPathName+"convEffVsEtTwoTracks"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEt"),dbe_->get(simInfoPathName+"h_VisSimConvEt"),"effic");
193  dividePlots(dbe_->get(effPathName+"convEffVsEtaTwoTracksAndVtxProbGT0"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEtaAndVtxPGT0"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEta"),"effic");
194  dividePlots(dbe_->get(effPathName+"convEffVsEtaTwoTracksAndVtxProbGT0005"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEtaAndVtxPGT0005"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksEta"),"effic");
195  dividePlots(dbe_->get(effPathName+"convEffVsRTwoTracksAndVtxProbGT0"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksRAndVtxPGT0"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksR"),"effic");
196  dividePlots(dbe_->get(effPathName+"convEffVsRTwoTracksAndVtxProbGT0005"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksRAndVtxPGT0005"),dbe_->get(simInfoPathName+"h_SimConvTwoMTracksR"),"effic");
197  //
198  dividePlots(dbe_->get(effPathName+"convEffVsEtaOneTrack"),dbe_->get(simInfoPathName+"h_SimConvOneMTracksEta"),dbe_->get(simInfoPathName+"h_VisSimConvEta"),"effic");
199  dividePlots(dbe_->get(effPathName+"convEffVsROneTrack"),dbe_->get(simInfoPathName+"h_SimConvOneMTracksR"),dbe_->get(simInfoPathName+"h_VisSimConvR"),"effic");
200  dividePlots(dbe_->get(effPathName+"convEffVsEtOneTrack"),dbe_->get(simInfoPathName+"h_SimConvOneMTracksEt"),dbe_->get(simInfoPathName+"h_VisSimConvEt"),"effic");
201  // fake rate
202  dividePlots(dbe_->get(effPathName+"convFakeRateVsEtaTwoTracks"),dbe_->get(convPathName+"h_RecoConvTwoMTracksEta"),dbe_->get(convPathName+"h_RecoConvTwoTracksEta"),"fakerate");
203  dividePlots(dbe_->get(effPathName+"convFakeRateVsPhiTwoTracks"),dbe_->get(convPathName+"h_RecoConvTwoMTracksPhi"),dbe_->get(convPathName+"h_RecoConvTwoTracksPhi"),"fakerate");
204  dividePlots(dbe_->get(effPathName+"convFakeRateVsRTwoTracks"),dbe_->get(convPathName+"h_RecoConvTwoMTracksR"),dbe_->get(convPathName+"h_RecoConvTwoTracksR"),"fakerate");
205  dividePlots(dbe_->get(effPathName+"convFakeRateVsZTwoTracks"),dbe_->get(convPathName+"h_RecoConvTwoMTracksZ"),dbe_->get(convPathName+"h_RecoConvTwoTracksZ"),"fakerate");
206  dividePlots(dbe_->get(effPathName+"convFakeRateVsEtTwoTracks"),dbe_->get(convPathName+"h_RecoConvTwoMTracksEt"),dbe_->get(convPathName+"h_RecoConvTwoTracksEt"),"fakerate");
207  // Background efficiency
208  dividePlots(dbe_->get(effPathName+"bkgEffVsEta"),dbe_->get(simInfoPathName+"h_MatchedSimJetEta"),dbe_->get(simInfoPathName+"h_SimJetEta"), "effic");
209  dividePlots(dbe_->get(effPathName+"bkgEffVsPhi"),dbe_->get(simInfoPathName+"h_MatchedSimJetPhi"),dbe_->get(simInfoPathName+"h_SimJetPhi"),"effic");
210  dividePlots(dbe_->get(effPathName+"bkgEffVsEt"),dbe_->get(simInfoPathName+"h_MatchedSimJetEt"),dbe_->get(simInfoPathName+"h_SimJetEt"),"effic");
211  // fraction of photons with at least one dead channel
212  dividePlots(dbe_->get(effPathName+"deadChVsEtaBkg"),dbe_->get(simInfoPathName+"h_MatchedSimJetBadChEta"),dbe_->get(simInfoPathName+"h_MatchedSimJetEta"), "effic");
213  dividePlots(dbe_->get(effPathName+"deadChVsPhiBkg"),dbe_->get(simInfoPathName+"h_MatchedSimJetBadChPhi"),dbe_->get(simInfoPathName+"h_MatchedSimJetPhi"),"effic");
214  dividePlots(dbe_->get(effPathName+"deadChVsEtBkg"), dbe_->get(simInfoPathName+"h_MatchedSimJetBadChEt"),dbe_->get(simInfoPathName+"h_MatchedSimJetEt"),"effic");
215 
216 
217 
218  if(standAlone_) dbe_->save(outputFileName_);
219  else if(batch_) dbe_->save(inputFileName_);
220 
221 
222 
223 }
224 
225 
227 {
228 
229 
230 }
231 
232 
233 
235  double value,err;
236  for (int j=1; j<=numerator->getNbinsX(); j++){
237 
238  if (denominator->getBinContent(j)!=0){
239  if (type=="effic")
240  value = ((double) numerator->getBinContent(j))/((double) denominator->getBinContent(j));
241  else if (type=="fakerate")
242  value = 1-((double) numerator->getBinContent(j))/((double) denominator->getBinContent(j));
243  else return;
244  err = sqrt( value*(1-value) / ((double) denominator->getBinContent(j)) );
245  dividend->setBinContent(j, value);
246  if ( err !=0 ) dividend->setBinError(j,err);
247  }
248  else {
249  dividend->setBinContent(j, 0);
250  dividend->setBinError(j,0);
251  }
252 
253  }
254 
255 
256 }
257 
258 
260  double value,err;
261 
262  for (int j=1; j<=numerator->getNbinsX(); j++){
263  if (denominator!=0){
264  value = ((double) numerator->getBinContent(j))/denominator;
265  err = sqrt( value*(1-value) / denominator);
266  dividend->setBinContent(j, value);
267  dividend->setBinError(j,err);
268  }
269  else {
270  dividend->setBinContent(j, 0);
271  }
272  }
273 
274 }
275 
type
Definition: HCALResponse.h:22
T getParameter(std::string const &) const
void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:519
tuple lumi
Definition: fjr2json.py:41
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:1883
T sqrt(T t)
Definition: SSEVec.h:28
int j
Definition: DBlmapReader.cc:9
tuple pset
Definition: CrabTask.py:85
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
void setVerbose(unsigned level)
Definition: DQMStore.cc:201
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1270
PhotonPostprocessing(const edm::ParameterSet &pset)
DQMStore * dbe_
virtual void runPostprocessing()
double getBinContent(int binx) const
get content of bin (1-D)
void dividePlots(MonitorElement *dividend, MonitorElement *numerator, MonitorElement *denominator, std::string type)
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:2198
virtual void endRun(const edm::Run &, const edm::EventSetup &)
virtual void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: Run.h:31