CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PhotonValidator.cc
Go to the documentation of this file.
1 #include <iostream>
2 //
5 //
7 
8 //
12 //
18 //
22 //
29 //
33 //
36 #include "CLHEP/Units/GlobalPhysicalConstants.h"
38 
39 //
58 
59 //
68 //
69 //#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
70 //
71 #include "TFile.h"
72 #include "TH1.h"
73 #include "TH2.h"
74 #include "TTree.h"
75 #include "TVector3.h"
76 #include "TProfile.h"
77 //
88 using namespace std;
89 
90 
92  {
93 
94  fName_ = pset.getUntrackedParameter<std::string>("Name");
95  verbosity_ = pset.getUntrackedParameter<int>("Verbosity");
96  parameters_ = pset;
97  fastSim_ = pset.getParameter<bool>("fastSim");
98  isRunCentrally_= pset.getParameter<bool>("isRunCentrally");
99 
100 
101  photonCollectionProducer_ = pset.getParameter<std::string>("phoProducer");
102  photonCollection_ = pset.getParameter<std::string>("photonCollection");
103 
104 
105  label_tp_ = pset.getParameter<edm::InputTag>("label_tp");
106 
107  barrelEcalHits_ = pset.getParameter<edm::InputTag>("barrelEcalHits");
108  endcapEcalHits_ = pset.getParameter<edm::InputTag>("endcapEcalHits");
109 
110  conversionOITrackProducer_ = pset.getParameter<std::string>("conversionOITrackProducer");
111  conversionIOTrackProducer_ = pset.getParameter<std::string>("conversionIOTrackProducer");
112 
113 
114  minPhoEtCut_ = pset.getParameter<double>("minPhoEtCut");
115  convTrackMinPtCut_ = pset.getParameter<double>("convTrackMinPtCut");
116  likelihoodCut_ = pset.getParameter<double>("likelihoodCut");
117 
118  trkIsolExtRadius_ = pset.getParameter<double>("trkIsolExtR");
119  trkIsolInnRadius_ = pset.getParameter<double>("trkIsolInnR");
120  trkPtLow_ = pset.getParameter<double>("minTrackPtCut");
121  lip_ = pset.getParameter<double>("lipCut");
122  ecalIsolRadius_ = pset.getParameter<double>("ecalIsolR");
123  bcEtLow_ = pset.getParameter<double>("minBcEtCut");
124  hcalIsolExtRadius_ = pset.getParameter<double>("hcalIsolExtR");
125  hcalIsolInnRadius_ = pset.getParameter<double>("hcalIsolInnR");
126  hcalHitEtLow_ = pset.getParameter<double>("minHcalHitEtCut");
127 
128  numOfTracksInCone_ = pset.getParameter<int>("maxNumOfTracksInCone");
129  trkPtSumCut_ = pset.getParameter<double>("trkPtSumCut");
130  ecalEtSumCut_ = pset.getParameter<double>("ecalEtSumCut");
131  hcalEtSumCut_ = pset.getParameter<double>("hcalEtSumCut");
132  dCotCutOn_ = pset.getParameter<bool>("dCotCutOn");
133  dCotCutValue_ = pset.getParameter<double>("dCotCutValue");
134  dCotHardCutValue_ = pset.getParameter<double>("dCotHardCutValue");
135 
136  }
137 
138 
139 
140 
141 
143 
144 
145 
146 
148 
149  nEvt_=0;
150  nEntry_=0;
151  nRecConv_=0;
152  nRecConvAss_=0;
153  nRecConvAssWithEcal_=0;
154 
155  nInvalidPCA_=0;
156 
157  dbe_ = 0;
159 
160 
161 
162 
163  double resMin = parameters_.getParameter<double>("resMin");
164  double resMax = parameters_.getParameter<double>("resMax");
165  int resBin = parameters_.getParameter<int>("resBin");
166 
167  double eMin = parameters_.getParameter<double>("eMin");
168  double eMax = parameters_.getParameter<double>("eMax");
169  int eBin = parameters_.getParameter<int>("eBin");
170 
171  double etMin = parameters_.getParameter<double>("etMin");
172  double etMax = parameters_.getParameter<double>("etMax");
173  int etBin = parameters_.getParameter<int>("etBin");
174 
175  double etScale = parameters_.getParameter<double>("etScale");
176 
177  double etaMin = parameters_.getParameter<double>("etaMin");
178  double etaMax = parameters_.getParameter<double>("etaMax");
179  int etaBin = parameters_.getParameter<int>("etaBin");
180  int etaBin2 = parameters_.getParameter<int>("etaBin2");
181 
182  double dEtaMin = parameters_.getParameter<double>("dEtaMin");
183  double dEtaMax = parameters_.getParameter<double>("dEtaMax");
184  int dEtaBin = parameters_.getParameter<int>("dEtaBin");
185 
186  double phiMin = parameters_.getParameter<double>("phiMin");
187  double phiMax = parameters_.getParameter<double>("phiMax");
188  int phiBin = parameters_.getParameter<int>("phiBin");
189 
190  double dPhiMin = parameters_.getParameter<double>("dPhiMin");
191  double dPhiMax = parameters_.getParameter<double>("dPhiMax");
192  int dPhiBin = parameters_.getParameter<int>("dPhiBin");
193 
194  double rMin = parameters_.getParameter<double>("rMin");
195  double rMax = parameters_.getParameter<double>("rMax");
196  int rBin = parameters_.getParameter<int>("rBin");
197 
198  double zMin = parameters_.getParameter<double>("zMin");
199  double zMax = parameters_.getParameter<double>("zMax");
200  int zBin = parameters_.getParameter<int>("zBin");
201 
202 
203 
204  double r9Min = parameters_.getParameter<double>("r9Min");
205  double r9Max = parameters_.getParameter<double>("r9Max");
206  int r9Bin = parameters_.getParameter<int>("r9Bin");
207 
208  double dPhiTracksMin = parameters_.getParameter<double>("dPhiTracksMin");
209  double dPhiTracksMax = parameters_.getParameter<double>("dPhiTracksMax");
210  int dPhiTracksBin = parameters_.getParameter<int>("dPhiTracksBin");
211 
212  double dEtaTracksMin = parameters_.getParameter<double>("dEtaTracksMin");
213  double dEtaTracksMax = parameters_.getParameter<double>("dEtaTracksMax");
214  int dEtaTracksBin = parameters_.getParameter<int>("dEtaTracksBin");
215 
216  double dCotTracksMin = parameters_.getParameter<double>("dCotTracksMin");
217  double dCotTracksMax = parameters_.getParameter<double>("dCotTracksMax");
218  int dCotTracksBin = parameters_.getParameter<int>("dCotTracksBin");
219 
220 
221  double povereMin = parameters_.getParameter<double>("povereMin");
222  double povereMax = parameters_.getParameter<double>("povereMax");
223  int povereBin = parameters_.getParameter<int>("povereBin");
224 
225  double eoverpMin = parameters_.getParameter<double>("eoverpMin");
226  double eoverpMax = parameters_.getParameter<double>("eoverpMax");
227  int eoverpBin = parameters_.getParameter<int>("eoverpBin");
228 
229  double chi2Min = parameters_.getParameter<double>("chi2Min");
230  double chi2Max = parameters_.getParameter<double>("chi2Max");
231 
232  int ggMassBin = parameters_.getParameter<int>("ggMassBin");
233  double ggMassMin = parameters_.getParameter<double>("ggMassMin");
234  double ggMassMax = parameters_.getParameter<double>("ggMassMax");
235 
236 
237  double rMinForXray = parameters_.getParameter<double>("rMinForXray");
238  double rMaxForXray = parameters_.getParameter<double>("rMaxForXray");
239  int rBinForXray = parameters_.getParameter<int>("rBinForXray");
240  double zMinForXray = parameters_.getParameter<double>("zMinForXray");
241  double zMaxForXray = parameters_.getParameter<double>("zMaxForXray");
242  int zBinForXray = parameters_.getParameter<int>("zBinForXray");
243  int zBin2ForXray = parameters_.getParameter<int>("zBin2ForXray");
244 
245 
246 
247  if (dbe_) {
249  // SC from reco photons
250 
251  dbe_->setCurrentFolder("EgammaV/PhotonValidator/SimulationInfo");
252  //
253  // simulation information about all MC photons found
254  std::string histname = "nOfSimPhotons";
255  h_nSimPho_[0] = dbe_->book1D(histname,"# of Sim photons per event ",20,-0.5,19.5);
256  histname = "SimPhoMotherEt";
257  h_SimPhoMotherEt_[0] = dbe_->book1D(histname,"Sim photon Mother tranverse energy spectrum",etBin,etMin,etMax);
258  h_SimPhoMotherEta_[0] = dbe_->book1D("SimPhoMotherEta"," Sim Photon Mother Eta ",etaBin,etaMin, etaMax) ;
259  histname = "SimPhoMotherEtMatched";
260  h_SimPhoMotherEt_[1] = dbe_->book1D(histname,"Sim photon matched by a reco Photon: Mother tranverse energy spectrum",etBin,etMin,etMax);
261  h_SimPhoMotherEta_[1] = dbe_->book1D("SimPhoMotherEtaMatched"," Sim Photon matched by a reco Photon: Mother Eta ",etaBin,etaMin, etaMax) ;
262  //
263  histname = "h_SimPhoEta";
264  h_SimPho_[0] = dbe_->book1D(histname," All photons simulated #eta",etaBin,etaMin, etaMax);
265  histname = "h_SimPhoPhi";
266  h_SimPho_[1] = dbe_->book1D(histname," All photons simulated #phi",phiBin,phiMin, phiMax);
267  histname = "h_SimPhoEt";
268  h_SimPho_[2] = dbe_->book1D(histname," All photons simulated Et",etBin,etMin, etMax);
269  // Numerators
270  histname = "nOfSimPhotonsMatched";
271  h_nSimPho_[1] = dbe_->book1D(histname,"# of Sim photons matched by a reco Photon per event ",20,-0.5,19.5);
272  histname = "h_MatchedSimPhoEta";
273  h_MatchedSimPho_[0] = dbe_->book1D(histname," Matching photons simulated #eta",etaBin,etaMin, etaMax);
274  histname = "h_MatchedSimPhoPhi";
275  h_MatchedSimPho_[1] = dbe_->book1D(histname," Matching photons simulated #phi",phiBin,phiMin, phiMax);
276  histname = "h_MatchedSimPhoEt";
277  h_MatchedSimPho_[2] = dbe_->book1D(histname," Matching photons simulated Et",etBin,etMin, etMax);
278  //
279  histname = "h_MatchedSimPhoBadChEta";
280  h_MatchedSimPhoBadCh_[0] = dbe_->book1D(histname," Matching photons simulated #eta",etaBin,etaMin, etaMax);
281  histname = "h_MatchedSimPhoBadChPhi";
282  h_MatchedSimPhoBadCh_[1] = dbe_->book1D(histname," Matching photons simulated #phi",phiBin,phiMin, phiMax);
283  histname = "h_MatchedSimPhoBadChEt";
284  h_MatchedSimPhoBadCh_[2] = dbe_->book1D(histname," Matching photons simulated Et",etBin,etMin, etMax);
285 
286 
288  histname = "nOfSimConversions";
289  h_nSimConv_[0] = dbe_->book1D(histname,"# of Sim conversions per event ",20,-0.5,19.5);
291  histname = "h_AllSimConvEta";
292  h_AllSimConv_[0] = dbe_->book1D(histname," All conversions: simulated #eta",etaBin2,etaMin,etaMax);
293  histname = "h_AllSimConvPhi";
294  h_AllSimConv_[1] = dbe_->book1D(histname," All conversions: simulated #phi",phiBin,phiMin,phiMax);
295  histname = "h_AllSimConvR";
296  h_AllSimConv_[2] = dbe_->book1D(histname," All conversions: simulated R",rBin,rMin,rMax);
297  histname = "h_AllSimConvZ";
298  h_AllSimConv_[3] = dbe_->book1D(histname," All conversions: simulated Z",zBin,zMin,zMax);
299  histname = "h_AllSimConvEt";
300  h_AllSimConv_[4] = dbe_->book1D(histname," All conversions: simulated Et",etBin,etMin,etMax);
301  //
302  histname = "nOfVisSimConversions";
303  h_nSimConv_[1] = dbe_->book1D(histname,"# of Sim conversions per event ",20,-0.5,19.5);
304  histname = "h_VisSimConvEta";
305  h_VisSimConv_[0] = dbe_->book1D(histname," All vis conversions: simulated #eta",etaBin2,etaMin, etaMax);
306  histname = "h_VisSimConvPhi";
307  h_VisSimConv_[1] = dbe_->book1D(histname," All vis conversions: simulated #phi",phiBin,phiMin, phiMax);
308  histname = "h_VisSimConvR";
309  h_VisSimConv_[2] = dbe_->book1D(histname," All vis conversions: simulated R",rBin,rMin,rMax);
310  histname = "h_VisSimConvZ";
311  h_VisSimConv_[3] = dbe_->book1D(histname," All vis conversions: simulated Z",zBin,zMin, zMax);
312  histname = "h_VisSimConvEt";
313  h_VisSimConv_[4] = dbe_->book1D(histname," All vis conversions: simulated Et",etBin,etMin, etMax);
315  histname = "h_SimConvOneTracksEta";
316  h_SimConvOneTracks_[0] = dbe_->book1D(histname," All vis conversions with 1 reco tracks: simulated #eta",etaBin2,etaMin, etaMax);
317  histname = "h_SimConvOneTracksPhi";
318  h_SimConvOneTracks_[1] = dbe_->book1D(histname," All vis conversions with 1 reco tracks: simulated #phi",phiBin,phiMin, phiMax);
319  histname = "h_SimConvOneTracksR";
320  h_SimConvOneTracks_[2] = dbe_->book1D(histname," All vis conversions with 1 reco tracks: simulated R",rBin,rMin, rMax);
321  histname = "h_SimConvOneTracksZ";
322  h_SimConvOneTracks_[3] = dbe_->book1D(histname," All vis conversions with 1 reco tracks: simulated Z",zBin,zMin, zMax);
323  histname = "h_SimConvOneTracksEt";
324  h_SimConvOneTracks_[4] = dbe_->book1D(histname," All vis conversions with 1 reco tracks: simulated Et",etBin,etMin, etMax);
325  //
326  histname = "h_SimConvTwoMTracksEta";
327  h_SimConvTwoMTracks_[0] = dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated #eta",etaBin2,etaMin, etaMax);
328  histname = "h_SimConvTwoMTracksPhi";
329  h_SimConvTwoMTracks_[1] = dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated #phi",phiBin,phiMin, phiMax);
330  histname = "h_SimConvTwoMTracksR";
331  h_SimConvTwoMTracks_[2] = dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated R",rBin,rMin, rMax);
332  histname = "h_SimConvTwoMTracksZ";
333  h_SimConvTwoMTracks_[3] = dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated Z",zBin,zMin, zMax);
334  histname = "h_SimConvTwoMTracksEt";
335  h_SimConvTwoMTracks_[4] = dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated Et",etBin,etMin, etMax);
336  //
337  histname = "h_SimConvTwoTracksEta";
338  h_SimConvTwoTracks_[0] = dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated #eta",etaBin2,etaMin, etaMax);
339  histname = "h_SimConvTwoTracksPhi";
340  h_SimConvTwoTracks_[1] = dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated #phi",phiBin,phiMin, phiMax);
341  histname = "h_SimConvTwoTracksR";
342  h_SimConvTwoTracks_[2] = dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated R",rBin,rMin, rMax);
343  histname = "h_SimConvTwoTracksZ";
344  h_SimConvTwoTracks_[3] = dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated Z",zBin,zMin, zMax);
345  histname = "h_SimConvTwoTracksEt";
346  h_SimConvTwoTracks_[4] = dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated Et",etBin,etMin, etMax);
347  //
348  histname = "h_SimConvOneMTracksEta";
349  h_SimConvOneMTracks_[0] = dbe_->book1D(histname," All vis conversions with 1 reco-matching tracks: simulated #eta",etaBin2,etaMin, etaMax);
350  histname = "h_SimConvOneMTracksPhi";
351  h_SimConvOneMTracks_[1] = dbe_->book1D(histname," All vis conversions with 1 reco-matching tracks: simulated #phi",phiBin,phiMin, phiMax);
352  histname = "h_SimConvOneMTracksR";
353  h_SimConvOneMTracks_[2] = dbe_->book1D(histname," All vis conversions with 1 reco-matching tracks: simulated R",rBin,rMin, rMax);
354  histname = "h_SimConvOneMTracksZ";
355  h_SimConvOneMTracks_[3] = dbe_->book1D(histname," All vis conversions with 1 reco-matching tracks: simulated Z",zBin,zMin, zMax);
356  histname = "h_SimConvOneMTracksEt";
357  h_SimConvOneMTracks_[4] = dbe_->book1D(histname," All vis conversions with 1 reco-matching tracks: simulated Et",etBin,etMin, etMax);
358  //
359  histname = "h_SimConvTwoMTracksEtaAndVtxPGT0";
360  h_SimConvTwoMTracksAndVtxPGT0_[0] = dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated #eta",etaBin2,etaMin, etaMax);
361  histname = "h_SimConvTwoMTracksPhiAndVtxPGT0";
362  h_SimConvTwoMTracksAndVtxPGT0_[1] = dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated #phi",phiBin,phiMin, phiMax);
363  histname = "h_SimConvTwoMTracksRAndVtxPGT0";
364  h_SimConvTwoMTracksAndVtxPGT0_[2] = dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated R",rBin,rMin, rMax);
365  histname = "h_SimConvTwoMTracksZAndVtxPGT0";
366  h_SimConvTwoMTracksAndVtxPGT0_[3] = dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated Z",zBin,zMin, zMax);
367  histname = "h_SimConvTwoMTracksEtAndVtxPGT0";
368  h_SimConvTwoMTracksAndVtxPGT0_[4] = dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated Et",etBin,etMin, etMax);
369  //
370  histname = "h_SimConvTwoMTracksEtaAndVtxPGT0005";
371  h_SimConvTwoMTracksAndVtxPGT0005_[0] = dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated #eta",etaBin2,etaMin, etaMax);
372  histname = "h_SimConvTwoMTracksPhiAndVtxPGT0005";
373  h_SimConvTwoMTracksAndVtxPGT0005_[1] = dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated #phi",phiBin,phiMin, phiMax);
374  histname = "h_SimConvTwoMTracksRAndVtxPGT0005";
375  h_SimConvTwoMTracksAndVtxPGT0005_[2] = dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated R",rBin,rMin, rMax);
376  histname = "h_SimConvTwoMTracksZAndVtxPGT0005";
377  h_SimConvTwoMTracksAndVtxPGT0005_[3] = dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated Z",zBin,zMin, zMax);
378  histname = "h_SimConvTwoMTracksEtAndVtxPGT0005";
379  h_SimConvTwoMTracksAndVtxPGT0005_[4] = dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated Et",etBin,etMin, etMax);
380 
381 
382  h_SimConvEtaPix_[0] = dbe_->book1D("simConvEtaPix"," sim converted Photon Eta: Pix ",etaBin,etaMin, etaMax) ;
383  h_simTkPt_ = dbe_->book1D("simTkPt","Sim conversion tracks pt ",etBin*3,0.,etMax);
384  h_simTkEta_ = dbe_->book1D("simTkEta","Sim conversion tracks eta ",etaBin,etaMin,etaMax);
385 
386  if ( ! isRunCentrally_ ) {
387  h_simConvVtxRvsZ_[0] = dbe_->book2D("simConvVtxRvsZAll"," Photon Sim conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
388  h_simConvVtxRvsZ_[1] = dbe_->book2D("simConvVtxRvsZBarrel"," Photon Sim conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
389  h_simConvVtxRvsZ_[2] = dbe_->book2D("simConvVtxRvsZEndcap"," Photon Sim conversion vtx position",zBin2ForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
390  h_simConvVtxYvsX_ = dbe_->book2D("simConvVtxYvsXTrkBarrel"," Photon Sim conversion vtx position, (x,y) eta<1 ",100, -80., 80., 100, -80., 80.);
391  }
392 
394  histname = "h_SimJetEta";
395  h_SimJet_[0] = dbe_->book1D(histname," Jet bkg simulated #eta",etaBin,etaMin, etaMax);
396  histname = "h_SimJetPhi";
397  h_SimJet_[1] = dbe_->book1D(histname," Jet bkg simulated #phi",phiBin,phiMin, phiMax);
398  histname = "h_SimJetEt";
399  h_SimJet_[2] = dbe_->book1D(histname," Jet bkg simulated Et",etBin,etMin, etMax);
400  //
401  histname = "h_MatchedSimJetEta";
402  h_MatchedSimJet_[0] = dbe_->book1D(histname," Matching jet simulated #eta",etaBin,etaMin, etaMax);
403  histname = "h_MatchedSimJetPhi";
404  h_MatchedSimJet_[1] = dbe_->book1D(histname," Matching jet simulated #phi",phiBin,phiMin, phiMax);
405  histname = "h_MatchedSimJetEt";
406  h_MatchedSimJet_[2] = dbe_->book1D(histname," Matching jet simulated Et",etBin,etMin, etMax);
407  //
408  histname = "h_MatchedSimJetBadChEta";
409  h_MatchedSimJetBadCh_[0] = dbe_->book1D(histname," Matching jet simulated #eta",etaBin,etaMin, etaMax);
410  histname = "h_MatchedSimJetBadChPhi";
411  h_MatchedSimJetBadCh_[1] = dbe_->book1D(histname," Matching jet simulated #phi",phiBin,phiMin, phiMax);
412  histname = "h_MatchedSimJetBadChEt";
413  h_MatchedSimJetBadCh_[2] = dbe_->book1D(histname," Matching jet simulated Et",etBin,etMin, etMax);
414 
415 
416  dbe_->setCurrentFolder("EgammaV/PhotonValidator/Background");
417 
418  histname = "nOfPhotons";
419  h_nPho_ = dbe_->book1D(histname,"# of Reco photons per event ",20,-0.5,19.5);
420 
421  h_scBkgEta_ = dbe_->book1D("scBkgEta"," SC Bkg Eta ",etaBin,etaMin, etaMax) ;
422  h_scBkgPhi_ = dbe_->book1D("scBkgPhi"," SC Bkg Phi ",phiBin,phiMin,phiMax) ;
423  //
424  h_phoBkgEta_ = dbe_->book1D("phoBkgEta"," Photon Bkg Eta ",etaBin,etaMin, etaMax) ;
425  h_phoBkgPhi_ = dbe_->book1D("phoBkgPhi"," Photon Bkg Phi ",phiBin,phiMin,phiMax) ;
426  //
427  h_phoBkgDEta_ = dbe_->book1D("phoBkgDEta"," Photon Eta(rec)-Eta(true) ",dEtaBin,dEtaMin, dEtaMax) ;
428  h_phoBkgDPhi_ = dbe_->book1D("phoBkgDPhi"," Photon Phi(rec)-Phi(true) ",dPhiBin,dPhiMin,dPhiMax) ;
429  //
430  histname = "phoBkgE";
431  h_phoBkgE_[0]=dbe_->book1D(histname+"All"," Photon Bkg Energy: All ecal ", eBin,eMin, eMax);
432  h_phoBkgE_[1]=dbe_->book1D(histname+"Barrel"," Photon Bkg Energy: barrel ",eBin,eMin, eMax);
433  h_phoBkgE_[2]=dbe_->book1D(histname+"Endcap"," Photon Bkg Energy: Endcap ",eBin,eMin, eMax);
434  //
435  histname = "phoBkgEt";
436  h_phoBkgEt_[0] = dbe_->book1D(histname+"All"," Photon Bkg Transverse Energy: All ecal ", etBin,etMin, etMax);
437  h_phoBkgEt_[1] = dbe_->book1D(histname+"Barrel"," Photon Bkg Transverse Energy: Barrel ",etBin,etMin, etMax);
438  h_phoBkgEt_[2] = dbe_->book1D(histname+"Endcap"," Photon BkgTransverse Energy: Endcap ",etBin,etMin, etMax);
439 
440  //
441  histname = "scBkgE";
442  h_scBkgE_[0] = dbe_->book1D(histname+"All"," SC bkg Energy: All Ecal ",eBin,eMin, eMax);
443  h_scBkgE_[1] = dbe_->book1D(histname+"Barrel"," SC bkg Energy: Barrel ",eBin,eMin, eMax);
444  h_scBkgE_[2] = dbe_->book1D(histname+"Endcap"," SC bkg Energy: Endcap ",eBin,eMin, eMax);
445  histname = "scBkgEt";
446  h_scBkgEt_[0] = dbe_->book1D(histname+"All"," SC bkg Et: All Ecal ",eBin,eMin, eMax);
447  h_scBkgEt_[1] = dbe_->book1D(histname+"Barrel"," SC bkg Et: Barrel ",eBin,eMin, eMax);
448  h_scBkgEt_[2] = dbe_->book1D(histname+"Endcap"," SC bkg Et: Endcap ",eBin,eMin, eMax);
449  //
450  histname = "r9Bkg";
451  h_r9Bkg_[0] = dbe_->book1D(histname+"All", " r9 bkg: All Ecal",r9Bin,r9Min, r9Max) ;
452  h_r9Bkg_[1] = dbe_->book1D(histname+"Barrel"," r9 bkg: Barrel ",r9Bin,r9Min, r9Max) ;
453  h_r9Bkg_[2] = dbe_->book1D(histname+"Endcap"," r9 bkg: Endcap ",r9Bin,r9Min, r9Max) ;
454  //
455  histname="R9VsEtaBkg";
456  h2_r9VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg r9 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
457  //
458  histname="R9VsEtBkg";
459  h2_r9VsEtBkg_ = dbe_->book2D(histname+"All"," Bkg photons r9 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
460  //
461  histname = "r1Bkg";
462  h_r1Bkg_[0] = dbe_->book1D(histname+"All", " Bkg photon e1x5/e5x5: All Ecal",r9Bin,r9Min, r9Max) ;
463  h_r1Bkg_[1] = dbe_->book1D(histname+"Barrel"," Bkg photon e1x5/e5x5: Barrel ",r9Bin,r9Min, r9Max) ;
464  h_r1Bkg_[2] = dbe_->book1D(histname+"Endcap"," Bkg photon e1x5/e5x5: Endcap ",r9Bin,r9Min, r9Max) ;
465  //
466  histname="R1VsEtaBkg";
467  h2_r1VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons e1x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
468  histname="pR1VsEtaBkg";
469  p_r1VsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons e1x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
470  //
471  histname="R1VsEtBkg";
472  h2_r1VsEtBkg_ = dbe_->book2D(histname+"All"," Bkg photons e1x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
473  histname="pR1VsEtBkg";
474  p_r1VsEtBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
475  //
476  histname = "r2Bkg";
477  h_r2Bkg_[0] = dbe_->book1D(histname+"All", " Bkg photon e2x5/e5x5: All Ecal",r9Bin,r9Min, r9Max) ;
478  h_r2Bkg_[1] = dbe_->book1D(histname+"Barrel"," Bkg photon e2x5/e5x5: Barrel ",r9Bin,r9Min, r9Max) ;
479  h_r2Bkg_[2] = dbe_->book1D(histname+"Endcap"," Bkg photon e2x5/e5x5: Endcap ",r9Bin,r9Min, r9Max) ;
480  //
481  histname="R2VsEtaBkg";
482  h2_r2VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons e2x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
483  histname="pR2VsEtaBkg";
484  p_r2VsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons e2x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
485  //
486  histname="R2VsEtBkg";
487  h2_r2VsEtBkg_ = dbe_->book2D(histname+"All"," Bkg photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
488  histname="pR2VsEtBkg";
489  p_r2VsEtBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
490 
491 
492  histname = "sigmaIetaIetaBkg";
493  h_sigmaIetaIetaBkg_[0] = dbe_->book1D(histname+"All", "Bkg sigmaIetaIeta: All Ecal",100,0., 0.1) ;
494  h_sigmaIetaIetaBkg_[1] = dbe_->book1D(histname+"Barrel","Bkg sigmaIetaIeta: Barrel ", 100,0., 0.05) ;
495  h_sigmaIetaIetaBkg_[2] = dbe_->book1D(histname+"Endcap","Bkg sigmaIetaIeta: Endcap ", 100,0., 0.1) ;
496  //
497  histname="sigmaIetaIetaVsEtaBkg";
498  h2_sigmaIetaIetaVsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons sigmaIetaIeta vs #eta: all Ecal ", etaBin2,etaMin, etaMax,100, 0.,0.1);
499  histname="pSigmaIetaIetaVsEtaBkg";
500  p_sigmaIetaIetaVsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons sigmaIetaIeta vs #eta: all Ecal ", etaBin2,etaMin, etaMax,100, 0.,0.1);
501  //
502  histname="sigmaIetaIetaVsEtBkg";
503  h2_sigmaIetaIetaVsEtBkg_[0] = dbe_->book2D(histname+"All"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
504  h2_sigmaIetaIetaVsEtBkg_[1] = dbe_->book2D(histname+"Barrel"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
505  h2_sigmaIetaIetaVsEtBkg_[2] = dbe_->book2D(histname+"Endcap"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
506  //
507  histname="pSigmaIetaIetaVsEtBkg";
508  p_sigmaIetaIetaVsEtBkg_[0] = dbe_->bookProfile(histname+"All"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
509  p_sigmaIetaIetaVsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
510  p_sigmaIetaIetaVsEtBkg_[2] = dbe_->bookProfile(histname+"Endcap"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
511  //
512  histname = "hOverEBkg";
513  h_hOverEBkg_[0] = dbe_->book1D(histname+"All", "H/E bkg: All Ecal",100,0., 1.) ;
514  h_hOverEBkg_[1] = dbe_->book1D(histname+"Barrel","H/E bkg: Barrel ", 100,0., 1.) ;
515  h_hOverEBkg_[2] = dbe_->book1D(histname+"Endcap","H/E bkg: Endcap ", 100,0., 1.) ;
516  //
517  histname="hOverEVsEtaBkg";
518  h2_hOverEVsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg H/E vs #eta: all Ecal ", etaBin2,etaMin, etaMax,100, 0.,0.1);
519  histname="pHOverEVsEtaBkg";
520  p_hOverEVsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg H/E vs #eta: all Ecal ", etaBin2,etaMin, etaMax,100, 0.,0.1);
521  //
522  histname="hOverEVsEtBkg";
523  h2_hOverEVsEtBkg_ = dbe_->book2D(histname+"All"," Bkg photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
524  histname="pHOverEVsEtBkg";
525  p_hOverEVsEtBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
526  //
527  histname = "ecalRecHitSumEtConeDR04Bkg";
528  h_ecalRecHitSumEtConeDR04Bkg_[0] = dbe_->book1D(histname+"All", "bkg ecalRecHitSumEtDR04: All Ecal",etBin,etMin,50.);
529  h_ecalRecHitSumEtConeDR04Bkg_[1] = dbe_->book1D(histname+"Barrel","bkg ecalRecHitSumEtDR04: Barrel ", etBin,etMin,50.);
530  h_ecalRecHitSumEtConeDR04Bkg_[2] = dbe_->book1D(histname+"Endcap","bkg ecalRecHitSumEtDR04: Endcap ", etBin,etMin,50.);
531  //
532  histname="ecalRecHitSumEtConeDR04VsEtaBkg";
533  h2_ecalRecHitSumEtConeDR04VsEtaBkg_ = dbe_->book2D(histname+"All"," bkg ecalRecHitSumEtDR04 vs #eta: all Ecal ", etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale);
534  histname="pEcalRecHitSumEtConeDR04VsEtaBkg";
535  p_ecalRecHitSumEtConeDR04VsEtaBkg_ = dbe_->bookProfile(histname+"All","bkg photons ecalRecHitSumEtDR04 vs #eta: all Ecal ", etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale, "");
536  //
537  histname="ecalRecHitSumEtConeDR04VsEtBkg";
538  h2_ecalRecHitSumEtConeDR04VsEtBkg_[0] = dbe_->book2D(histname+"All"," Bkg ecalRecHitSumEtDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
539  h2_ecalRecHitSumEtConeDR04VsEtBkg_[1] = dbe_->book2D(histname+"Barrel"," Bkg ecalRecHitSumEtDR04 vs Et: Barrel ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
540  h2_ecalRecHitSumEtConeDR04VsEtBkg_[2] = dbe_->book2D(histname+"Endcap"," Bkg ecalRecHitSumEtDR04 vs Et: Endcap ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
541  histname="pEcalRecHitSumEtConeDR04VsEtBkg";
542  p_ecalRecHitSumEtConeDR04VsEtBkg_[0] = dbe_->bookProfile(histname+"All","Bkg ecalRecHitSumEtDR04 vs Et: all Ecal ", etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
543  p_ecalRecHitSumEtConeDR04VsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel","Bkg ecalRecHitSumEtDR04 vs Et: all Ecal ", etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
544  p_ecalRecHitSumEtConeDR04VsEtBkg_[2] = dbe_->bookProfile(histname+"Endcap","Bkg ecalRecHitSumEtDR04 vs Et: all Ecal ", etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
545  //
546  histname = "hcalTowerSumEtConeDR04Bkg";
547  h_hcalTowerSumEtConeDR04Bkg_[0] = dbe_->book1D(histname+"All", "bkg hcalTowerSumEtDR04: All Ecal",etBin,etMin,20.);
548  h_hcalTowerSumEtConeDR04Bkg_[1] = dbe_->book1D(histname+"Barrel","bkg hcalTowerSumEtDR04: Barrel ", etBin,etMin,20.);
549  h_hcalTowerSumEtConeDR04Bkg_[2] = dbe_->book1D(histname+"Endcap","bkg hcalTowerSumEtDR04: Endcap ", etBin,etMin,20.);
550  //
551  histname="hcalTowerSumEtConeDR04VsEtaBkg";
552  h2_hcalTowerSumEtConeDR04VsEtaBkg_ = dbe_->book2D(histname+"All"," bkg hcalTowerSumEtDR04 vs #eta: all Ecal ", etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale);
553  histname="pHcalTowerSumEtConeDR04VsEtaBkg";
554  p_hcalTowerSumEtConeDR04VsEtaBkg_ = dbe_->bookProfile(histname+"All","bkg photons hcalTowerSumEtDR04 vs #eta: all Ecal ", etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale, "");
555  //
556  histname="hcalTowerSumEtConeDR04VsEtBkg";
557  h2_hcalTowerSumEtConeDR04VsEtBkg_[0] = dbe_->book2D(histname+"All"," Bkg hcalTowerSumEtDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
558  h2_hcalTowerSumEtConeDR04VsEtBkg_[1] = dbe_->book2D(histname+"Barrel"," Bkg hcalTowerSumEtDR04 vs Et: Barrel ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
559  h2_hcalTowerSumEtConeDR04VsEtBkg_[2] = dbe_->book2D(histname+"Endcap"," Bkg hcalTowerSumEtDR04 vs Et: Endcap ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
560  histname="pHcalTowerSumEtConeDR04VsEtBkg";
561  p_hcalTowerSumEtConeDR04VsEtBkg_[0] = dbe_->bookProfile(histname+"All","Bkg hcalTowerSumEtDR04 vs Et: all Ecal ", etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
562  p_hcalTowerSumEtConeDR04VsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel","Bkg hcalTowerSumEtDR04 vs Et: all Ecal ", etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
563  p_hcalTowerSumEtConeDR04VsEtBkg_[2] = dbe_->bookProfile(histname+"Endcap","Bkg hcalTowerSumEtDR04 vs Et: all Ecal ", etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
564  //
565  histname = "isoTrkSolidConeDR04Bkg";
566  h_isoTrkSolidConeDR04Bkg_[0] = dbe_->book1D(histname+"All", "isoTrkSolidConeDR04 Bkg: All Ecal",etBin,etMin,etMax*0.1);
567  h_isoTrkSolidConeDR04Bkg_[1] = dbe_->book1D(histname+"Barrel","isoTrkSolidConeDR04 Bkg: Barrel ", etBin,etMin,etMax*0.1);
568  h_isoTrkSolidConeDR04Bkg_[2] = dbe_->book1D(histname+"Endcap","isoTrkSolidConeDR04 Bkg: Endcap ", etBin,etMin,etMax*0.1);
569  //
570  histname="isoTrkSolidConeDR04VsEtaBkg";
571  h2_isoTrkSolidConeDR04VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons isoTrkSolidConeDR04 vs #eta: all Ecal ", etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1);
572  histname="pIsoTrkSolidConeDR04VsEtaBkg";
573  p_isoTrkSolidConeDR04VsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons isoTrkSolidConeDR04 vs #eta: all Ecal ", etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1);
574  //
575  histname="isoTrkSolidConeDR04VsEtBkg";
576  h2_isoTrkSolidConeDR04VsEtBkg_[0] = dbe_->book2D(histname+"All"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
577  h2_isoTrkSolidConeDR04VsEtBkg_[1] = dbe_->book2D(histname+"Barrel"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
578  h2_isoTrkSolidConeDR04VsEtBkg_[2] = dbe_->book2D(histname+"Endcap"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
579  histname="pIsoTrkSolidConeDR04VsEtBkg";
580  p_isoTrkSolidConeDR04VsEtBkg_[0] = dbe_->bookProfile(histname+"All"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
581  p_isoTrkSolidConeDR04VsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
582  p_isoTrkSolidConeDR04VsEtBkg_[2] = dbe_->bookProfile(histname+"Endcap"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
583  //
584  histname = "nTrkSolidConeDR04Bkg";
585  h_nTrkSolidConeDR04Bkg_[0] = dbe_->book1D(histname+"All", "Bkg nTrkSolidConeDR04: All Ecal",20,0., 20) ;
586  h_nTrkSolidConeDR04Bkg_[1] = dbe_->book1D(histname+"Barrel","Bkg nTrkSolidConeDR04: Barrel ", 20,0., 20) ;
587  h_nTrkSolidConeDR04Bkg_[2] = dbe_->book1D(histname+"Endcap","Bkg nTrkSolidConeDR04: Endcap ", 20,0., 20) ;
588  //
589  histname="nTrkSolidConeDR04VsEtaBkg";
590  h2_nTrkSolidConeDR04VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons nTrkSolidConeDR04 vs #eta: all Ecal ", etaBin2,etaMin, etaMax, 20,0., 20) ;
591  histname="p_nTrkSolidConeDR04VsEtaBkg";
592  p_nTrkSolidConeDR04VsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons nTrkSolidConeDR04 vs #eta: all Ecal ", etaBin2,etaMin, etaMax, 20,0., 20) ;
593  //
594  histname="nTrkSolidConeDR04VsEtBkg";
595  h2_nTrkSolidConeDR04VsEtBkg_[0] = dbe_->book2D(histname+"All","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
596  h2_nTrkSolidConeDR04VsEtBkg_[1] = dbe_->book2D(histname+"Barrel","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
597  h2_nTrkSolidConeDR04VsEtBkg_[2] = dbe_->book2D(histname+"Endcap","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
598  //
599  histname="pnTrkSolidConeDR04VsEtBkg";
600  p_nTrkSolidConeDR04VsEtBkg_[0] = dbe_->bookProfile(histname+"All","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
601  p_nTrkSolidConeDR04VsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
602  p_nTrkSolidConeDR04VsEtBkg_[2] = dbe_->bookProfile(histname+"Endcap","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
603  //
604  h_convEtaBkg_ = dbe_->book1D("convEtaBkg"," converted Photon Bkg Eta 2 tracks",etaBin,etaMin, etaMax) ;
605  h_convPhiBkg_ = dbe_->book1D("convPhiBkg"," converted Photon Bkg Phi ",phiBin,phiMin,phiMax) ;
606  //
607  histname="mvaOutBkg";
608  h_mvaOutBkg_[0] = dbe_->book1D(histname+"All"," mvaOut conversions bkg : All Ecal",100, 0., 1.);
609  h_mvaOutBkg_[1] = dbe_->book1D(histname+"Barrel"," mvaOut conversions bkg: Barrel Ecal",100, 0., 1.);
610  h_mvaOutBkg_[2] = dbe_->book1D(histname+"Endcap"," mvaOut conversions bkg: Endcap Ecal",100, 0., 1.);
611 
612  histname="PoverEtracksBkg";
613  h_PoverETracksBkg_[0] = dbe_->book1D(histname+"All"," bkg photons conversion p/E: all Ecal ",povereBin, povereMin, povereMax);
614  h_PoverETracksBkg_[1] = dbe_->book1D(histname+"Barrel","bkg photons conversion p/E: Barrel Ecal",povereBin, povereMin, povereMax);
615  h_PoverETracksBkg_[2] = dbe_->book1D(histname+"Endcap"," bkg photons conversion p/E: Endcap Ecal ",povereBin, povereMin, povereMax);
616 
617  histname="EoverPtracksBkg";
618  h_EoverPTracksBkg_[0] = dbe_->book1D(histname+"All"," bkg photons conversion E/p: all Ecal ",eoverpBin, eoverpMin, eoverpMax);
619  h_EoverPTracksBkg_[1] = dbe_->book1D(histname+"Barrel","bkg photons conversion E/p: Barrel Ecal",eoverpBin, eoverpMin, eoverpMax);
620  h_EoverPTracksBkg_[2] = dbe_->book1D(histname+"Endcap"," bkg photons conversion E/p: Endcap Ecal ",eoverpBin, eoverpMin, eoverpMax);
621 
622  histname="hDCotTracksBkg";
623  h_DCotTracksBkg_[0]= dbe_->book1D(histname+"All"," bkg Photons:Tracks from conversions #delta cotg(#Theta) Tracks: all Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
624  h_DCotTracksBkg_[1]= dbe_->book1D(histname+"Barrel"," bkg Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Barrel Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
625  h_DCotTracksBkg_[2]= dbe_->book1D(histname+"Endcap"," bkg Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Endcap Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
626 
627  histname="hDPhiTracksAtVtxBkg";
628  h_DPhiTracksAtVtxBkg_[0] =dbe_->book1D(histname+"All", " Bkg Photons:Tracks from conversions: #delta#phi Tracks at vertex: all Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
629  h_DPhiTracksAtVtxBkg_[1] =dbe_->book1D(histname+"Barrel", " Bkg Photons:Tracks from conversions: #delta#phi Tracks at vertex: Barrel Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
630  h_DPhiTracksAtVtxBkg_[2] =dbe_->book1D(histname+"Endcap", " Bkg Photons:Tracks from conversions: #delta#phi Tracks at vertex: Endcap Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
631 
632  if ( ! isRunCentrally_ ) {
633  h_convVtxRvsZBkg_[0] = dbe_->book2D("convVtxRvsZAllBkg"," Bkg Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
634  h_convVtxRvsZBkg_[1] = dbe_->book2D("convVtxRvsZBarrelBkg"," Bkg Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
635  h_convVtxYvsXBkg_ = dbe_->book2D("convVtxYvsXTrkBarrelBkg"," Bkg Photon Reco conversion vtx position, (x,y) eta<1 ",100, -80., 80., 100, -80., 80.);
636  }
637 
638  //
639  dbe_->setCurrentFolder("EgammaV/PhotonValidator/Photons");
640 
641  h_phoEta_[0] = dbe_->book1D("phoEta"," Photon Eta ",etaBin,etaMin, etaMax) ;
642  h_phoPhi_[0] = dbe_->book1D("phoPhi"," Photon Phi ",phiBin,phiMin,phiMax) ;
643 
644  h_phoDEta_[0] = dbe_->book1D("phoDEta"," Photon Eta(rec)-Eta(true) ",dEtaBin,dEtaMin, dEtaMax) ;
645  h_phoDPhi_[0] = dbe_->book1D("phoDPhi"," Photon Phi(rec)-Phi(true) ",dPhiBin,dPhiMin,dPhiMax) ;
646 
647  h_scEta_[0] = dbe_->book1D("scEta"," SC Eta ",etaBin,etaMin, etaMax);
648  h_scPhi_[0] = dbe_->book1D("scPhi"," SC Phi ",phiBin,phiMin,phiMax);
649 
650  h_scEtaWidth_[0] = dbe_->book1D("scEtaWidth"," SC Eta Width ",100,0., 0.1);
651  h_scPhiWidth_[0] = dbe_->book1D("scPhiWidth"," SC Phi Width ",100,0., 1.);
652 
653 
654  histname = "scE";
655  h_scE_[0][0] = dbe_->book1D(histname+"All"," SC Energy: All Ecal ",eBin,eMin, eMax);
656  h_scE_[0][1] = dbe_->book1D(histname+"Barrel"," SC Energy: Barrel ",eBin,eMin, eMax);
657  h_scE_[0][2] = dbe_->book1D(histname+"Endcap"," SC Energy: Endcap ",eBin,eMin, eMax);
658 
659  histname = "psE";
660  h_psE_ = dbe_->book1D(histname+"Endcap"," ES Energy ",eBin,eMin, 50.);
661 
662 
663  histname = "scEt";
664  h_scEt_[0][0] = dbe_->book1D(histname+"All"," SC Et: All Ecal ",etBin,etMin, etMax) ;
665  h_scEt_[0][1] = dbe_->book1D(histname+"Barrel"," SC Et: Barrel",etBin,etMin, etMax) ;
666  h_scEt_[0][2] = dbe_->book1D(histname+"Endcap"," SC Et: Endcap",etBin,etMin, etMax) ;
667 
668  histname = "r9";
669  h_r9_[0][0] = dbe_->book1D(histname+"All", " r9: All Ecal",r9Bin,r9Min, r9Max) ;
670  h_r9_[0][1] = dbe_->book1D(histname+"Barrel"," r9: Barrel ",r9Bin,r9Min, r9Max) ;
671  h_r9_[0][2] = dbe_->book1D(histname+"Endcap"," r9: Endcap ",r9Bin,r9Min, r9Max) ;
672  //
673  histname = "r9ConvFromMC";
674  h_r9_[1][0] = dbe_->book1D(histname+"All", " r9: All Ecal",r9Bin,r9Min, r9Max) ;
675  h_r9_[1][1] = dbe_->book1D(histname+"Barrel"," r9: Barrel ",r9Bin,r9Min, r9Max) ;
676  h_r9_[1][2] = dbe_->book1D(histname+"Endcap"," r9: Endcap ",r9Bin,r9Min, r9Max) ;
677  //
678  histname = "r9ConvFromReco";
679  h_r9_[2][0] = dbe_->book1D(histname+"All", " r9: All Ecal",r9Bin,r9Min, r9Max) ;
680  h_r9_[2][1] = dbe_->book1D(histname+"Barrel"," r9: Barrel ",r9Bin,r9Min, r9Max) ;
681  h_r9_[2][2] = dbe_->book1D(histname+"Endcap"," r9: Endcap ",r9Bin,r9Min, r9Max) ;
682  //
683  histname="R9VsEta";
684  h2_r9VsEta_[0] = dbe_->book2D(histname+"All"," All photons r9 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
685  h2_r9VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons r9 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
686  //
687  histname="R9VsEt";
688  h2_r9VsEt_[0] = dbe_->book2D(histname+"All"," All photons r9 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
689  h2_r9VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons r9 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
690  //
691  histname = "r1";
692  h_r1_[0][0] = dbe_->book1D(histname+"All", " e1x5/e5x5: All Ecal",r9Bin,r9Min, r9Max) ;
693  h_r1_[0][1] = dbe_->book1D(histname+"Barrel"," e1x5/e5x5: Barrel ",r9Bin,r9Min, r9Max) ;
694  h_r1_[0][2] = dbe_->book1D(histname+"Endcap"," e1x5/e5x5: Endcap ",r9Bin,r9Min, r9Max) ;
695  //
696  histname="R1VsEta";
697  h2_r1VsEta_[0] = dbe_->book2D(histname+"All"," All photons e1x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
698  h2_r1VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons e1x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
699  //
700  histname="R1VsEt";
701  h2_r1VsEt_[0] = dbe_->book2D(histname+"All"," All photons e1x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
702  h2_r1VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons e1x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
703  //
704  histname = "r2";
705  h_r2_[0][0] = dbe_->book1D(histname+"All", " e2x5/e5x5: All Ecal",r9Bin,r9Min, r9Max) ;
706  h_r2_[0][1] = dbe_->book1D(histname+"Barrel"," e2x5/e5x5: Barrel ",r9Bin,r9Min, r9Max) ;
707  h_r2_[0][2] = dbe_->book1D(histname+"Endcap"," e2x5/e5x5: Endcap ",r9Bin,r9Min, r9Max) ;
708  //
709  histname="R2VsEta";
710  h2_r2VsEta_[0] = dbe_->book2D(histname+"All"," All photons e2x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
711  h2_r2VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons e2x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
712  //
713  histname="R2VsEt";
714  h2_r2VsEt_[0] = dbe_->book2D(histname+"All"," All photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
715  h2_r2VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
716  //
717  histname = "sigmaIetaIeta";
718  h_sigmaIetaIeta_[0][0] = dbe_->book1D(histname+"All", "sigmaIetaIeta: All Ecal",100,0., 0.1) ;
719  h_sigmaIetaIeta_[0][1] = dbe_->book1D(histname+"Barrel","sigmaIetaIeta: Barrel ", 100,0., 0.05) ;
720  h_sigmaIetaIeta_[0][2] = dbe_->book1D(histname+"Endcap","sigmaIetaIeta: Endcap ", 100,0., 0.1) ;
721  //
722  histname="sigmaIetaIetaVsEta";
723  h2_sigmaIetaIetaVsEta_[0] = dbe_->book2D(histname+"All"," All photons sigmaIetaIeta vs #eta: all Ecal ", etaBin2,etaMin, etaMax,100, 0.,0.1);
724  h2_sigmaIetaIetaVsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons sigmaIetaIeta vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,0.1);
725  //
726  histname="sigmaIetaIetaVsEt";
727  h2_sigmaIetaIetaVsEt_[0] = dbe_->book2D(histname+"All"," All photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
728  h2_sigmaIetaIetaVsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
729  //
730  histname = "hOverE";
731  h_hOverE_[0][0] = dbe_->book1D(histname+"All", "H/E: All Ecal",100,0., 0.1) ;
732  h_hOverE_[0][1] = dbe_->book1D(histname+"Barrel","H/E: Barrel ", 100,0., 0.1) ;
733  h_hOverE_[0][2] = dbe_->book1D(histname+"Endcap","H/E: Endcap ", 100,0., 0.1) ;
734  //
735  histname="hOverEVsEta";
736  h2_hOverEVsEta_[0] = dbe_->book2D(histname+"All"," All photons H/E vs #eta: all Ecal ", etaBin2,etaMin, etaMax,100, 0.,0.1);
737  h2_hOverEVsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons H/E vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,0.1);
738  //
739  histname="hOverEVsEt";
740  h2_hOverEVsEt_[0] = dbe_->book2D(histname+"All"," All photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
741  h2_hOverEVsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
742  //
743  histname="pHoverEVsEta";
744  p_hOverEVsEta_[0] = dbe_->bookProfile(histname+"All"," All photons H/E vs #eta: all Ecal ", etaBin2,etaMin, etaMax,100, 0.,0.1);
745  p_hOverEVsEta_[1] = dbe_->bookProfile(histname+"Unconv"," All photons H/E vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,0.1);
746  //
747  histname="pHoverEVsEt";
748  p_hOverEVsEt_[0] = dbe_->bookProfile(histname+"All"," All photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
749  p_hOverEVsEt_[1] = dbe_->bookProfile(histname+"Unconv"," All photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
750 
751  //
752  histname = "ecalRecHitSumEtConeDR04";
753  h_ecalRecHitSumEtConeDR04_[0][0] = dbe_->book1D(histname+"All", "ecalRecHitSumEtDR04: All Ecal",etBin,etMin,20.);
754  h_ecalRecHitSumEtConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","ecalRecHitSumEtDR04: Barrel ", etBin,etMin,20.);
755  h_ecalRecHitSumEtConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","ecalRecHitSumEtDR04: Endcap ", etBin,etMin,20.);
756  //
757  histname="ecalRecHitSumEtConeDR04VsEta";
758  h2_ecalRecHitSumEtConeDR04VsEta_[0] = dbe_->book2D(histname+"All"," All photons ecalRecHitSumEtDR04 vs #eta: all Ecal ", etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale);
759  h2_ecalRecHitSumEtConeDR04VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons ecalRecHitSumEtDR04 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,etBin,etMin,etMax*etScale);
760  histname="pEcalRecHitSumEtConeDR04VsEta";
761  p_ecalRecHitSumEtConeDR04VsEta_[0] = dbe_->bookProfile(histname+"All","All photons ecalRecHitSumEtDR04 vs #eta: all Ecal ", etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale, "");
762  p_ecalRecHitSumEtConeDR04VsEta_[1] = dbe_->bookProfile(histname+"Unconv","All photons ecalRecHitSumEtDR04 vs #eta: all Ecal ", etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale, "");
763  //
764  histname="ecalRecHitSumEtConeDR04VsEt";
765  h2_ecalRecHitSumEtConeDR04VsEt_[0] = dbe_->book2D(histname+"All"," All photons ecalRecHitSumEtDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
766  h2_ecalRecHitSumEtConeDR04VsEt_[1] = dbe_->book2D(histname+"Barrel"," All photons ecalRecHitSumEtDR04 vs Et: Barrel ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
767  h2_ecalRecHitSumEtConeDR04VsEt_[2] = dbe_->book2D(histname+"Endcap"," All photons ecalRecHitSumEtDR04 vs Et: Endcap ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
768  histname="pEcalRecHitSumEtConeDR04VsEt";
769  p_ecalRecHitSumEtConeDR04VsEt_[0] = dbe_->bookProfile(histname+"All","All photons ecalRecHitSumEtDR04 vs Et: all Ecal ", etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
770  p_ecalRecHitSumEtConeDR04VsEt_[1] = dbe_->bookProfile(histname+"Barrel","All photons ecalRecHitSumEtDR04 vs Et: all Ecal ", etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
771  p_ecalRecHitSumEtConeDR04VsEt_[2] = dbe_->bookProfile(histname+"Endcap","All photons ecalRecHitSumEtDR04 vs Et: all Ecal ", etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
772  //
773  histname = "hcalTowerSumEtConeDR04";
774  h_hcalTowerSumEtConeDR04_[0][0] = dbe_->book1D(histname+"All", "hcalTowerSumEtConeDR04: All Ecal",etBin,etMin,20.);
775  h_hcalTowerSumEtConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","hcalTowerSumEtConeDR04: Barrel ", etBin,etMin,20.);
776  h_hcalTowerSumEtConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","hcalTowerSumEtConeDR04: Endcap ", etBin,etMin,20.);
777 
778  //
779  histname="hcalTowerSumEtConeDR04VsEta";
780  h2_hcalTowerSumEtConeDR04VsEta_[0] = dbe_->book2D(histname+"All"," All photons hcalTowerSumEtConeDR04 vs #eta: all Ecal ", etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1);
781  h2_hcalTowerSumEtConeDR04VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons hcalTowerSumEtConeDR04 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,etBin,etMin,etMax*0.1);
782  histname="pHcalTowerSumEtConeDR04VsEta";
783  p_hcalTowerSumEtConeDR04VsEta_[0] = dbe_->bookProfile(histname+"All","All photons hcalTowerSumEtDR04 vs #eta: all Ecal ", etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1, "");
784  p_hcalTowerSumEtConeDR04VsEta_[1] = dbe_->bookProfile(histname+"Unconv","All photons hcalTowerSumEtDR04 vs #eta: all Ecal ", etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1, "");
785  //
786  histname="hcalTowerSumEtConeDR04VsEt";
787  h2_hcalTowerSumEtConeDR04VsEt_[0] = dbe_->book2D(histname+"All"," All photons hcalTowerSumEtConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
788  h2_hcalTowerSumEtConeDR04VsEt_[1] = dbe_->book2D(histname+"Barrel"," All photons hcalTowerSumEtConeDR04 vs Et: Barrel ",etBin,etMin, etMax,etBin,etMin,etMax*0.1);
789  h2_hcalTowerSumEtConeDR04VsEt_[2] = dbe_->book2D(histname+"Endcap"," All photons hcalTowerSumEtConeDR04 vs Et: Endcap ",etBin,etMin, etMax,etBin,etMin,etMax*0.1);
790  histname="pHcalTowerSumEtConeDR04VsEt";
791  p_hcalTowerSumEtConeDR04VsEt_[0] = dbe_->bookProfile(histname+"All","All photons hcalTowerSumEtDR04 vs Et: all Ecal ", etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
792  p_hcalTowerSumEtConeDR04VsEt_[1] = dbe_->bookProfile(histname+"Barrel","All photons hcalTowerSumEtDR04 vs Et: all Ecal ", etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
793  p_hcalTowerSumEtConeDR04VsEt_[2] = dbe_->bookProfile(histname+"Endcap","All photons hcalTowerSumEtDR04 vs Et: all Ecal ", etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
794 
795  //
796  histname = "isoTrkSolidConeDR04";
797  h_isoTrkSolidConeDR04_[0][0] = dbe_->book1D(histname+"All", "isoTrkSolidConeDR04: All Ecal",etBin,etMin,etMax*0.1);
798  h_isoTrkSolidConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","isoTrkSolidConeDR04: Barrel ", etBin,etMin,etMax*0.1);
799  h_isoTrkSolidConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","isoTrkSolidConeDR04: Endcap ", etBin,etMin,etMax*0.1);
800  //
801  histname="isoTrkSolidConeDR04VsEta";
802  h2_isoTrkSolidConeDR04VsEta_[0] = dbe_->book2D(histname+"All"," All photons isoTrkSolidConeDR04 vs #eta: all Ecal ", etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1);
803  h2_isoTrkSolidConeDR04VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons isoTrkSolidConeDR04 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,etBin,etMin,etMax*0.1);
804  //
805  histname="isoTrkSolidConeDR04VsEt";
806  h2_isoTrkSolidConeDR04VsEt_[0] = dbe_->book2D(histname+"All"," All photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
807  h2_isoTrkSolidConeDR04VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
808  //
809  histname = "nTrkSolidConeDR04";
810  h_nTrkSolidConeDR04_[0][0] = dbe_->book1D(histname+"All", "nTrkSolidConeDR04: All Ecal",20,0., 20) ;
811  h_nTrkSolidConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","nTrkSolidConeDR04: Barrel ", 20,0., 20) ;
812  h_nTrkSolidConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","nTrkSolidConeDR04: Endcap ", 20,0., 20) ;
813  //
814  histname="nTrkSolidConeDR04VsEta";
815  h2_nTrkSolidConeDR04VsEta_[0] = dbe_->book2D(histname+"All"," All photons nTrkSolidConeDR04 vs #eta: all Ecal ", etaBin2,etaMin, etaMax, 20,0., 20) ;
816  h2_nTrkSolidConeDR04VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons nTrkSolidConeDR04 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,20,0., 20) ;
817  //
818  histname="nTrkSolidConeDR04VsEt";
819  h2_nTrkSolidConeDR04VsEt_[0] = dbe_->book2D(histname+"All"," All photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
820  h2_nTrkSolidConeDR04VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax,20,0., 20) ;
821  //
822  histname = "phoE";
823  h_phoE_[0][0]=dbe_->book1D(histname+"All"," Photon Energy: All ecal ", eBin,eMin, eMax);
824  h_phoE_[0][1]=dbe_->book1D(histname+"Barrel"," Photon Energy: barrel ",eBin,eMin, eMax);
825  h_phoE_[0][2]=dbe_->book1D(histname+"Endcap"," Photon Energy: Endcap ",eBin,eMin, eMax);
826 
827  histname = "phoEt";
828  h_phoEt_[0][0] = dbe_->book1D(histname+"All"," Photon Transverse Energy: All ecal ", etBin,etMin, etMax);
829  h_phoEt_[0][1] = dbe_->book1D(histname+"Barrel"," Photon Transverse Energy: Barrel ",etBin,etMin, etMax);
830  h_phoEt_[0][2] = dbe_->book1D(histname+"Endcap"," Photon Transverse Energy: Endcap ",etBin,etMin, etMax);
831 
832  histname = "eRes";
833  h_phoERes_[0][0] = dbe_->book1D(histname+"All"," Photon rec/true Energy: All ecal ", resBin,resMin, resMax);
834  h_phoERes_[0][1] = dbe_->book1D(histname+"Barrel"," Photon rec/true Energy: Barrel ",resBin,resMin, resMax);
835  h_phoERes_[0][2] = dbe_->book1D(histname+"Endcap"," Photon rec/true Energy: Endcap ",resBin,resMin, resMax);
836 
837  h_phoERes_[1][0] = dbe_->book1D(histname+"unconvAll"," Photon rec/true Energy if r9>0.93: All ecal ", resBin,resMin, resMax);
838  h_phoERes_[1][1] = dbe_->book1D(histname+"unconvBarrel"," Photon rec/true Energy if r9>0.93: Barrel ",resBin,resMin, resMax);
839  h_phoERes_[1][2] = dbe_->book1D(histname+"unconvEndcap"," Photon rec/true Energyif r9>0.93: Endcap ",resBin,resMin, resMax);
840 
841  h_phoERes_[2][0] = dbe_->book1D(histname+"convAll"," Photon rec/true Energy if r9<0.93: All ecal ", resBin,resMin, resMax);
842  h_phoERes_[2][1] = dbe_->book1D(histname+"convBarrel"," Photon rec/true Energyif r9<0.93: Barrel ",resBin,resMin, resMax);
843  h_phoERes_[2][2] = dbe_->book1D(histname+"convEndcap"," Photon rec/true Energyif r9<0.93: Endcap ",resBin,resMin, resMax);
844 
845 
846  histname="eResVsEta";
847  h2_eResVsEta_[0] = dbe_->book2D(histname+"All"," All photons E/Etrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 2.5);
848  h2_eResVsEta_[1] = dbe_->book2D(histname+"Unconv"," Unconv photons E/Etrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 2.5);
849 
850  histname="pEResVsEta";
851  p_eResVsEta_[0] = dbe_->bookProfile(histname+"All","All photons E/Etrue vs #eta: all Ecal ",etaBin2,etaMin,etaMax,resBin,resMin, resMax,"");
852  p_eResVsEta_[1] = dbe_->bookProfile(histname+"Unconv","Unconv photons E/Etrue vs #eta: all Ecal",etaBin2,etaMin,etaMax,resBin,resMin, resMax,"");
853  p_eResVsEta_[2] = dbe_->bookProfile(histname+"Conv","Conv photons E/Etrue vs #eta: all Ecal",etaBin2,etaMin,etaMax,resBin,resMin, resMax,"");
854 
855  if ( ! isRunCentrally_ ) {
856  histname="eResVsEt";
857  h2_eResVsEt_[0][0] = dbe_->book2D(histname+"All"," All photons E/Etrue vs true Et: all Ecal ",etBin,etMin, etMax,100, 0.9, 1.1);
858  h2_eResVsEt_[0][1] = dbe_->book2D(histname+"unconv"," All photons E/Etrue vs true Et: all Ecal ",etBin,etMin, etMax,100, 0.9, 1.1);
859  h2_eResVsEt_[0][2] = dbe_->book2D(histname+"conv"," All photons E/Etrue vs true Et: all Ecal ",etBin,etMin, etMax,100, 0.9, 1.1);
860  h2_eResVsEt_[1][0] = dbe_->book2D(histname+"Barrel"," All photons E/Etrue vs true Et: Barrel ",etBin,etMin, etMax,100, 0.9, 1.1);
861  h2_eResVsEt_[1][1] = dbe_->book2D(histname+"unconvBarrel"," All photons E/Etrue vs true Et: Barrel ",etBin,etMin, etMax,100, 0.9, 1.1);
862  h2_eResVsEt_[1][2] = dbe_->book2D(histname+"convBarrel"," All photons E/Etrue vs true Et: Barrel ",etBin,etMin, etMax,100, 0.9, 1.1);
863  h2_eResVsEt_[2][0] = dbe_->book2D(histname+"Endcap"," All photons E/Etrue vs true Et: Endcap ",etBin,etMin, etMax,100, 0.9, 1.1);
864  h2_eResVsEt_[2][1] = dbe_->book2D(histname+"unconvEndcap"," All photons E/Etrue vs true Et: Endcap ",etBin,etMin, etMax,100, 0.9, 1.1);
865  h2_eResVsEt_[2][2] = dbe_->book2D(histname+"convEndcap"," All photons E/Etrue vs true Et: Endcap ",etBin,etMin, etMax,100, 0.9, 1.1);
866  }
867 
868  histname="pEResVsEt";
869  p_eResVsEt_[0][0] = dbe_->bookProfile(histname+"All","All photons E/Etrue vs Et: all Ecal ",etBin,etMin,etMax,resBin,resMin, resMax,"");
870  p_eResVsEt_[0][1] = dbe_->bookProfile(histname+"unconv","All photons E/Etrue vs Et: all Ecal ",etBin,etMin,etMax,resBin,resMin, resMax,"");
871  p_eResVsEt_[0][2] = dbe_->bookProfile(histname+"conv","All photons E/Etrue vs Et: all Ecal ",etBin,etMin,etMax,resBin,resMin, resMax,"");
872  p_eResVsEt_[1][0] = dbe_->bookProfile(histname+"Barrel","All photons E/Etrue vs Et: Barrel ",etBin,etMin,etMax,resBin,resMin, resMax,"");
873  p_eResVsEt_[1][1] = dbe_->bookProfile(histname+"unconvBarrel","All photons E/Etrue vs Et: Barrel ",etBin,etMin,etMax,resBin,resMin, resMax,"");
874  p_eResVsEt_[1][2] = dbe_->bookProfile(histname+"convBarrel","All photons E/Etrue vs Et: Barrel ",etBin,etMin,etMax,resBin,resMin, resMax,"");
875  p_eResVsEt_[2][0] = dbe_->bookProfile(histname+"Endcap","All photons E/Etrue vs Et: Endcap ",etBin,etMin,etMax,resBin,resMin, resMax,"");
876  p_eResVsEt_[2][1] = dbe_->bookProfile(histname+"unconvEndcap","All photons E/Etrue vs Et: Endcap ",etBin,etMin,etMax,resBin,resMin, resMax,"");
877  p_eResVsEt_[2][2] = dbe_->bookProfile(histname+"convEndcap","All photons E/Etrue vs Et: Endcap ",etBin,etMin,etMax,resBin,resMin, resMax,"");
878 
879 
880  histname="eResVsR9";
881  h2_eResVsR9_[0] = dbe_->book2D(histname+"All"," All photons E/Etrue vs R9: all Ecal ",r9Bin*2,r9Min, r9Max,100, 0., 2.5);
882  h2_eResVsR9_[1] = dbe_->book2D(histname+"Barrel"," All photons E/Etrue vs R9: Barrel ", r9Bin*2,r9Min, r9Max,100, 0.,2.5);
883  h2_eResVsR9_[2] = dbe_->book2D(histname+"Endcap"," All photons E/Etrue vs R9: Endcap ", r9Bin*2,r9Min, r9Max,100, 0., 2.5);
884  histname="pEResVsR9";
885  p_eResVsR9_[0] = dbe_->bookProfile(histname+"All"," All photons E/Etrue vs R9: all Ecal ",r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
886  p_eResVsR9_[1] = dbe_->bookProfile(histname+"Barrel"," All photons E/Etrue vs R9: Barrel ", r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
887  p_eResVsR9_[2] = dbe_->bookProfile(histname+"Endcap"," All photons E/Etrue vs R9: Endcap ", r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
888  histname="sceResVsR9";
889  h2_sceResVsR9_[0] = dbe_->book2D(histname+"All"," All photons scE/Etrue vs R9: all Ecal ",r9Bin*2,r9Min, r9Max,100, 0., 2.5);
890  h2_sceResVsR9_[1] = dbe_->book2D(histname+"Barrel"," All photons scE/Etrue vs R9: Barrel ", r9Bin*2,r9Min, r9Max,100, 0.,2.5);
891  h2_sceResVsR9_[2] = dbe_->book2D(histname+"Endcap"," All photons scE/Etrue vs R9: Endcap ", r9Bin*2,r9Min, r9Max,100, 0., 2.5);
892  histname="scpEResVsR9";
893  p_sceResVsR9_[0] = dbe_->bookProfile(histname+"All"," All photons scE/Etrue vs R9: all Ecal ",r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
894  p_sceResVsR9_[1] = dbe_->bookProfile(histname+"Barrel"," All photons scE/Etrue vs R9: Barrel ", r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
895  p_sceResVsR9_[2] = dbe_->bookProfile(histname+"Endcap"," All photons scE/Etrue vs R9: Endcap ", r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
896 
897 
898 
899  // Photon pair invariant mass
900  histname = "gamgamMass";
901  h_gamgamMass_[0][0] = dbe_->book1D(histname+"All","2 photons invariant mass: All ecal ", ggMassBin, ggMassMin, ggMassMax);
902  h_gamgamMass_[0][1] = dbe_->book1D(histname+"Barrel","2 photons invariant mass: Barrel ",ggMassBin, ggMassMin, ggMassMax);
903  h_gamgamMass_[0][2] = dbe_->book1D(histname+"Endcap","2 photons invariant mass: Endcap ",ggMassBin, ggMassMin, ggMassMax);
904  //
905  histname = "gamgamMassNoConv";
906  h_gamgamMass_[1][0] = dbe_->book1D(histname+"All","2 photons with no conversion invariant mass: All ecal ",ggMassBin, ggMassMin, ggMassMax);
907  h_gamgamMass_[1][1] = dbe_->book1D(histname+"Barrel","2 photons with no conversion invariant mass: Barrel ",ggMassBin, ggMassMin, ggMassMax);
908  h_gamgamMass_[1][2] = dbe_->book1D(histname+"Endcap","2 photons with no conversion invariant mass: Endcap ",ggMassBin, ggMassMin, ggMassMax);
909  //
910  histname = "gamgamMassConv";
911  h_gamgamMass_[2][0] = dbe_->book1D(histname+"All","2 photons with conversion invariant mass: All ecal ", ggMassBin, ggMassMin, ggMassMax);
912  h_gamgamMass_[2][1] = dbe_->book1D(histname+"Barrel","2 photons with conversion invariant mass: Barrel ",ggMassBin, ggMassMin, ggMassMax);
913  h_gamgamMass_[2][2] = dbe_->book1D(histname+"Endcap","2 photons with conversion invariant mass: Endcap ",ggMassBin, ggMassMin, ggMassMax);
914 
915 
916  dbe_->setCurrentFolder("EgammaV/PhotonValidator/ConversionInfo");
917 
918  histname="nConv";
919  h_nConv_[0][0] = dbe_->book1D(histname+"All","Number Of Conversions per isolated candidates per events: All Ecal ",10,-0.5, 9.5);
920  h_nConv_[0][1] = dbe_->book1D(histname+"Barrel","Number Of Conversions per isolated candidates per events: Ecal Barrel ",10,-0.5, 9.5);
921  h_nConv_[0][2] = dbe_->book1D(histname+"Endcap","Number Of Conversions per isolated candidates per events: Ecal Endcap ",10,-0.5, 9.5);
922 
923  h_convEta_[0] = dbe_->book1D("convEta1"," converted Photon Eta >1 track",etaBin,etaMin, etaMax) ;
924  h_convEta_[1] = dbe_->book1D("convEta2"," converted Photon Eta =2 tracks ",etaBin,etaMin, etaMax) ;
925  h_convEta_[2] = dbe_->book1D("convEta2ass"," converted Photon Eta =2 tracks, both ass ",etaBin,etaMin, etaMax) ;
926  h_convPhi_[0] = dbe_->book1D("convPhi"," converted Photon Phi ",phiBin,phiMin,phiMax) ;
927 
928 
929  histname = "convERes";
930  h_convERes_[0][0] = dbe_->book1D(histname+"All"," Conversion rec/true Energy: All ecal ", resBin,resMin, resMax);
931  h_convERes_[0][1] = dbe_->book1D(histname+"Barrel"," Conversion rec/true Energy: Barrel ",resBin,resMin, resMax);
932  h_convERes_[0][2] = dbe_->book1D(histname+"Endcap"," Conversion rec/true Energy: Endcap ",resBin,resMin, resMax);
933 
934  histname="p_EResVsR";
935  p_eResVsR_ = dbe_->bookProfile(histname+"All"," photons conversion E/Etrue vs R: all Ecal ",rBin,rMin,rMax, 100, 0.,1.5,"");
936 
937 
938  histname = "convPtRes";
939  h_convPtRes_[1][0] = dbe_->book1D(histname+"All"," Conversion Pt rec/true from tracks : All ecal ", resBin,0.,1.5);
940  h_convPtRes_[1][1] = dbe_->book1D(histname+"Barrel"," Conversion Pt rec/true from tracks: Barrel ",resBin,0., 1.5);
941  h_convPtRes_[1][2] = dbe_->book1D(histname+"Endcap"," Conversion Pt rec/true from tracks: Endcap ",resBin,0., 1.5);
942 
943 
944  if ( ! isRunCentrally_ ) {
945  histname="r9VsTracks";
946  h_r9VsNofTracks_[0][0] = dbe_->book2D(histname+"All"," photons r9 vs nTracks from conversions: All Ecal",r9Bin,r9Min, r9Max, 3, -0.5, 2.5) ;
947  h_r9VsNofTracks_[0][1] = dbe_->book2D(histname+"Barrel"," photons r9 vs nTracks from conversions: Barrel Ecal",r9Bin,r9Min, r9Max, 3, -0.5, 2.5) ;
948  h_r9VsNofTracks_[0][2] = dbe_->book2D(histname+"Endcap"," photons r9 vs nTracks from conversions: Endcap Ecal",r9Bin,r9Min, r9Max, 3, -0.5, 2.5) ;
949  }
950 
951  histname="mvaOut";
952  h_mvaOut_[0] = dbe_->book1D(histname+"All"," mvaOut for all conversions : All Ecal",100, 0., 1.);
953  h_mvaOut_[1] = dbe_->book1D(histname+"Barrel"," mvaOut for all conversions : Barrel Ecal",100, 0., 1.);
954  h_mvaOut_[2] = dbe_->book1D(histname+"Endcap"," mvaOut for all conversions : Endcap Ecal",100, 0., 1.);
955 
956 
957 
958  histname="EoverPtracks";
959  h_EoverPTracks_[0][0] = dbe_->book1D(histname+"BarrelPix"," photons conversion E/p: barrel pix",eoverpBin, eoverpMin,eoverpMax);
960  h_EoverPTracks_[0][1] = dbe_->book1D(histname+"BarrelTib"," photons conversion E/p: barrel tib",eoverpBin, eoverpMin,eoverpMax);
961  h_EoverPTracks_[0][2] = dbe_->book1D(histname+"BarrelTob"," photons conversion E/p: barrel tob ",eoverpBin, eoverpMin,eoverpMax);
962 
963  h_EoverPTracks_[1][0] = dbe_->book1D(histname+"All"," photons conversion E/p: all Ecal ",100, 0., 5.);
964  h_EoverPTracks_[1][1] = dbe_->book1D(histname+"Barrel"," photons conversion E/p: Barrel Ecal",100, 0., 5.);
965  h_EoverPTracks_[1][2] = dbe_->book1D(histname+"Endcap"," photons conversion E/p: Endcap Ecal ",100, 0., 5.);
966 
967  histname="PoverEtracks";
968  h_PoverETracks_[1][0] = dbe_->book1D(histname+"All"," photons conversion p/E: all Ecal ",povereBin, povereMin, povereMax);
969  h_PoverETracks_[1][1] = dbe_->book1D(histname+"Barrel"," photons conversion p/E: Barrel Ecal",povereBin, povereMin, povereMax);
970  h_PoverETracks_[1][2] = dbe_->book1D(histname+"Endcap"," photons conversion p/E: Endcap Ecal ",povereBin, povereMin, povereMax);
971 
972  histname="pEoverEtrueVsEta";
973  p_EoverEtrueVsEta_[0] = dbe_->bookProfile(histname+"All"," photons conversion with 2 (associated) reco tracks E/Etrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax, 100,0.,2.5,"");
974 
975  histname="pEoverEtrueVsR";
976  p_EoverEtrueVsR_[0] = dbe_->bookProfile(histname+"All"," photons conversion E/Etrue vs R: all Ecal ",rBin,rMin,rMax, 100, 0., 2.5, "");
977 
978  histname="pEoverEtrueVsEta";
979  p_EoverEtrueVsEta_[1] = dbe_->bookProfile(histname+"All2"," photons conversion 2 reco tracks E/Etrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 2.5,"");
980 
981  histname="pPoverPtrueVsEta";
982  p_PoverPtrueVsEta_[0] = dbe_->bookProfile(histname+"All"," photons conversion P/Ptrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 5.,"");
983 
984  histname="pEoverPVsEta";
985  p_EoverPVsEta_[0] = dbe_->bookProfile(histname+"All"," photons conversion E/P vs #eta: all Ecal ",etaBin2,etaMin, etaMax, 100, 0., 5.,"");
986 
987 
988  if ( ! isRunCentrally_ ) {
989  histname="EoverEtrueVsEoverP";
990  h2_EoverEtrueVsEoverP_[0] = dbe_->book2D(histname+"All"," photons conversion E/Etrue vs E/P: all Ecal ",100, 0., 5., 100, 0.5, 1.5);
991  h2_EoverEtrueVsEoverP_[1] = dbe_->book2D(histname+"Barrel"," photons conversion E/Etrue vs E/: Barrel Ecal",100, 0., 5.,100, 0.5, 1.5);
992  h2_EoverEtrueVsEoverP_[2] = dbe_->book2D(histname+"Endcap"," photons conversion E/Etrue vs E/: Endcap Ecal ",100, 0., 5., 100, 0.5, 1.5);
993  histname="PoverPtrueVsEoverP";
994  h2_PoverPtrueVsEoverP_[0] = dbe_->book2D(histname+"All"," photons conversion P/Ptrue vs E/P: all Ecal ",100, 0., 5., 100, 0., 2.5);
995  h2_PoverPtrueVsEoverP_[1] = dbe_->book2D(histname+"Barrel"," photons conversion P/Ptrue vs E/: Barrel Ecal",100, 0., 5.,100, 0., 2.5);
996  h2_PoverPtrueVsEoverP_[2] = dbe_->book2D(histname+"Endcap"," photons conversion P/Ptrue vs E/: Endcap Ecal ",100, 0., 5., 100, 0., 2.5);
997 
998  histname="EoverEtrueVsEta";
999  h2_EoverEtrueVsEta_[0] = dbe_->book2D(histname+"All"," photons conversion with 2 (associated) reco tracks E/Etrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 2.5);
1000 
1001 
1002  histname="EoverEtrueVsEta";
1003  h2_EoverEtrueVsEta_[1] = dbe_->book2D(histname+"All2"," photons conversion 2 reco tracks E/Etrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 2.5);
1004 
1005  histname="EoverEtrueVsR";
1006  h2_EoverEtrueVsR_[0] = dbe_->book2D(histname+"All"," photons conversion E/Etrue vs R: all Ecal ",rBin,rMin, rMax,100, 0., 2.5);
1007 
1008  histname="PoverPtrueVsEta";
1009  h2_PoverPtrueVsEta_[0] = dbe_->book2D(histname+"All"," photons conversion P/Ptrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 5.);
1010 
1011  histname="EoverPVsEta";
1012  h2_EoverPVsEta_[0] = dbe_->book2D(histname+"All"," photons conversion E/P vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 5.);
1013 
1014  histname="EoverPVsR";
1015  h2_EoverPVsR_[0] = dbe_->book2D(histname+"All"," photons conversion E/P vs R: all Ecal ",rBin,rMin, rMax,100, 0., 5.);
1016 
1017  histname="etaVsRsim";
1018  h2_etaVsRsim_[0] = dbe_->book2D(histname+"All"," eta(sim) vs R (sim) for associated conversions: all Ecal ",etaBin, etaMin, etaMax,rBin,rMin, rMax);
1019  histname="etaVsRreco";
1020  h2_etaVsRreco_[0] = dbe_->book2D(histname+"All"," eta(reco) vs R (reco) for associated conversions: all Ecal ",etaBin, etaMin, etaMax,rBin,rMin, rMax);
1021 
1022  }
1023 
1024  histname="pEoverPVsR";
1025  p_EoverPVsR_[0] = dbe_->bookProfile(histname+"All"," photons conversion E/P vs R: all Ecal ",rBin,rMin,rMax, 100, 0., 5.,"");
1026 
1027 
1028  histname="hInvMass";
1029  h_invMass_[0][0]= dbe_->book1D(histname+"All_AllTracks"," Photons:Tracks from conversion: Pair invariant mass: all Ecal ",100, 0., 1.5);
1030  h_invMass_[0][1]= dbe_->book1D(histname+"Barrel_AllTracks"," Photons:Tracks from conversion: Pair invariant mass: Barrel Ecal ",100, 0., 1.5);
1031  h_invMass_[0][2]= dbe_->book1D(histname+"Endcap_AllTracks"," Photons:Tracks from conversion: Pair invariant mass: Endcap Ecal ",100, 0., 1.5);
1032  histname="hInvMass";
1033  h_invMass_[1][0]= dbe_->book1D(histname+"All_AssTracks"," Photons:Tracks from conversion: Pair invariant mass: all Ecal ",100, 0., 1.5);
1034  h_invMass_[1][1]= dbe_->book1D(histname+"Barrel_AssTracks"," Photons:Tracks from conversion: Pair invariant mass: Barrel Ecal ",100, 0., 1.5);
1035  h_invMass_[1][2]= dbe_->book1D(histname+"Endcap_AssTracks"," Photons:Tracks from conversion: Pair invariant mass: Endcap Ecal ",100, 0., 1.5);
1036 
1037 
1038  histname="hDPhiTracksAtVtx";
1039  h_DPhiTracksAtVtx_[1][0] =dbe_->book1D(histname+"All", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: all Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
1040  h_DPhiTracksAtVtx_[1][1] =dbe_->book1D(histname+"Barrel", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Barrel Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
1041  h_DPhiTracksAtVtx_[1][2] =dbe_->book1D(histname+"Endcap", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Endcap Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
1042 
1043 
1044  if ( ! isRunCentrally_ ) {
1045  histname="hDPhiTracksAtVtxVsEta";
1046  h2_DPhiTracksAtVtxVsEta_ = dbe_->book2D(histname+"All"," Photons:Tracks from conversions: #delta#phi Tracks at vertex vs #eta",etaBin2,etaMin, etaMax,100, -0.5, 0.5);
1047 
1048  histname="hDPhiTracksAtVtxVsR";
1049  h2_DPhiTracksAtVtxVsR_ = dbe_->book2D(histname+"All"," Photons:Tracks from conversions: #delta#phi Tracks at vertex vs R",rBin,rMin, rMax,100, -0.5, 0.5);
1050 
1051  histname="hDCotTracksVsEta";
1052  h2_DCotTracksVsEta_ = dbe_->book2D(histname+"All"," Photons:Tracks from conversions: #delta cotg(#Theta) Tracks vs #eta",etaBin2,etaMin, etaMax,100, -0.2, 0.2);
1053 
1054  histname="hDCotTracksVsR";
1055  h2_DCotTracksVsR_ = dbe_->book2D(histname+"All"," Photons:Tracks from conversions: #delta cotg(#Theta) Tracks at vertex vs R",rBin,rMin, rMax,100, -0.2, 0.2);
1056 
1057  histname="h2_DPhiTracksAtEcalVsR";
1058  h2_DPhiTracksAtEcalVsR_= dbe_->book2D(histname+"All"," Photons:Tracks from conversions: #delta#phi at Ecal vs R : all Ecal ",rBin,rMin, rMax, dPhiTracksBin,0.,dPhiTracksMax);
1059 
1060  histname="h2_DPhiTracksAtEcalVsEta";
1061  h2_DPhiTracksAtEcalVsEta_= dbe_->book2D(histname+"All"," Photons:Tracks from conversions: #delta#phi at Ecal vs #eta : all Ecal ",etaBin2,etaMin, etaMax, dPhiTracksBin,0.,dPhiTracksMax);
1062 
1063 
1064  }
1065 
1066  histname="pDPhiTracksAtVtxVsEta";
1067  p_DPhiTracksAtVtxVsEta_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions: #delta#phi Tracks at vertex vs #eta ",etaBin2,etaMin, etaMax, 100, -0.5, 0.5,"");
1068 
1069  histname="pDPhiTracksAtVtxVsR";
1070  p_DPhiTracksAtVtxVsR_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions: #delta#phi Tracks at vertex vs R ",rBin,rMin, rMax,100, -0.5, 0.5,"");
1071 
1072 
1073  histname="hDCotTracks";
1074  h_DCotTracks_[1][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: all Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
1075  h_DCotTracks_[1][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Barrel Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
1076  h_DCotTracks_[1][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Endcap Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
1077 
1078 
1079  histname="pDCotTracksVsEta";
1080  p_DCotTracksVsEta_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions: #delta cotg(#Theta) Tracks vs #eta ",etaBin2,etaMin, etaMax, 100, -0.2, 0.2,"");
1081 
1082  histname="pDCotTracksVsR";
1083  p_DCotTracksVsR_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions: #delta cotg(#Theta) Tracks at vertex vs R ",rBin,rMin, rMax,100, -0.2, 0.2,"");
1084 
1085 
1086  histname="hDistMinAppTracks";
1087  h_distMinAppTracks_[1][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions Min Approach Dist Tracks: all Ecal ",dEtaTracksBin,-0.1,0.6);
1088  h_distMinAppTracks_[1][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions Min Approach Dist Tracks: Barrel Ecal ",dEtaTracksBin,-0.1,0.6);
1089  h_distMinAppTracks_[1][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions Min Approach Dist Tracks: Endcap Ecal ",dEtaTracksBin,-0.1,0.6);
1090 
1091  histname="hDPhiTracksAtEcal";
1092  h_DPhiTracksAtEcal_[1][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions: #delta#phi at Ecal : all Ecal ",dPhiTracksBin,0.,dPhiTracksMax);
1093  h_DPhiTracksAtEcal_[1][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions: #delta#phi at Ecal : Barrel Ecal ",dPhiTracksBin,0.,dPhiTracksMax);
1094  h_DPhiTracksAtEcal_[1][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions: #delta#phi at Ecal : Endcap Ecal ",dPhiTracksBin,0.,dPhiTracksMax);
1095 
1096  histname="pDPhiTracksAtEcalVsR";
1097  p_DPhiTracksAtEcalVsR_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions: #delta#phi at Ecal vs R ",rBin,rMin, rMax, dPhiTracksBin,0.,dPhiTracksMax,"");
1098 
1099  histname="pDPhiTracksAtEcalVsEta";
1100  p_DPhiTracksAtEcalVsEta_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions: #delta#phi at Ecal vs #eta ",etaBin2,etaMin, etaMax,dPhiTracksBin,0.,dPhiTracksMax,"");
1101 
1102 
1103  histname="hDEtaTracksAtEcal";
1104  h_DEtaTracksAtEcal_[1][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions: #delta#eta at Ecal : all Ecal ",dEtaTracksBin,dEtaTracksMin,dEtaTracksMax);
1105  h_DEtaTracksAtEcal_[1][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions: #delta#eta at Ecal : Barrel Ecal ",dEtaTracksBin,dEtaTracksMin,dEtaTracksMax);
1106  h_DEtaTracksAtEcal_[1][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions: #delta#eta at Ecal : Endcap Ecal ",dEtaTracksBin,dEtaTracksMin,dEtaTracksMax);
1107 
1108 
1109  h_convVtxRvsZ_[0] = dbe_->book2D("convVtxRvsZAll"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
1110  h_convVtxRvsZ_[1] = dbe_->book2D("convVtxRvsZBarrel"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
1111  h_convVtxRvsZ_[2] = dbe_->book2D("convVtxRvsZEndcap"," Photon Reco conversion vtx position",zBin2ForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
1112  h_convVtxYvsX_ = dbe_->book2D("convVtxYvsXTrkBarrel"," Photon Reco conversion vtx position, (x,y) eta<1 ",100, -80., 80., 100, -80., 80.);
1114  if ( ! isRunCentrally_ ) {
1115  h_convVtxRvsZ_zoom_[0] = dbe_->book2D("convVtxRvsZBarrelZoom1"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, -10., 40.);
1116  h_convVtxRvsZ_zoom_[1] = dbe_->book2D("convVtxRvsZBarrelZoom2"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, -10., 20.);
1117  h_convVtxYvsX_zoom_[0] = dbe_->book2D("convVtxYvsXTrkBarrelZoom1"," Photon Reco conversion vtx position, (x,y) eta<1 ",100, -40., 40., 100, -40., 40.);
1118  h_convVtxYvsX_zoom_[1] = dbe_->book2D("convVtxYvsXTrkBarrelZoom2"," Photon Reco conversion vtx position, (x,y) eta<1 ",100, -20., 20., 100, -20., 20.);
1119  }
1120 
1121  h_convVtxdX_ = dbe_->book1D("convVtxdX"," Photon Reco conversion vtx dX",100, -20.,20.);
1122  h_convVtxdY_ = dbe_->book1D("convVtxdY"," Photon Reco conversion vtx dY",100, -20.,20.);
1123  h_convVtxdZ_ = dbe_->book1D("convVtxdZ"," Photon Reco conversion vtx dZ",100, -20.,20.);
1124  h_convVtxdR_ = dbe_->book1D("convVtxdR"," Photon Reco conversion vtx dR",100, -20.,20.);
1125 
1126  h_convVtxdX_barrel_ = dbe_->book1D("convVtxdX_barrel"," Photon Reco conversion vtx dX, |eta|<=1.2",100, -20.,20.);
1127  h_convVtxdY_barrel_ = dbe_->book1D("convVtxdY_barrel"," Photon Reco conversion vtx dY, |eta|<=1.2 ",100, -20.,20.);
1128  h_convVtxdZ_barrel_ = dbe_->book1D("convVtxdZ_barrel"," Photon Reco conversion vtx dZ, |eta|<=1.2,",100, -20.,20.);
1129  h_convVtxdR_barrel_ = dbe_->book1D("convVtxdR_barrel"," Photon Reco conversion vtx dR, |eta|<=1.2",100, -20.,20.);
1130  h_convVtxdX_endcap_ = dbe_->book1D("convVtxdX_endcap"," Photon Reco conversion vtx dX, |eta|>1.2",100, -20.,20.);
1131  h_convVtxdY_endcap_ = dbe_->book1D("convVtxdY_endcap"," Photon Reco conversion vtx dY, |eta|>1.2",100, -20.,20.);
1132  h_convVtxdZ_endcap_ = dbe_->book1D("convVtxdZ_endcap"," Photon Reco conversion vtx dZ, |eta|>1.2",100, -20.,20.);
1133  h_convVtxdR_endcap_ = dbe_->book1D("convVtxdR_endcap"," Photon Reco conversion vtx dR, |eta|>1.2 ",100, -20.,20.);
1134 
1135 
1136  h_convVtxdPhi_ = dbe_->book1D("convVtxdPhi"," Photon Reco conversion vtx dPhi",100, -0.005,0.005);
1137  h_convVtxdEta_ = dbe_->book1D("convVtxdEta"," Photon Reco conversion vtx dEta",100, -0.5,0.5);
1138 
1139  if ( ! isRunCentrally_ ) {
1140  h2_convVtxdRVsR_ = dbe_->book2D("h2ConvVtxdRVsR","Photon Reco conversion vtx dR vsR" ,rBin,rMin, rMax,100, -20.,20.);
1141  h2_convVtxdRVsEta_ = dbe_->book2D("h2ConvVtxdRVsEta","Photon Reco conversion vtx dR vs Eta" ,etaBin2,etaMin, etaMax,100, -20.,20.);
1142  }
1143 
1144  p_convVtxdRVsR_ = dbe_->bookProfile("pConvVtxdRVsR","Photon Reco conversion vtx dR vsR" ,rBin,rMin, rMax ,100, -20.,20., "");
1145  p_convVtxdRVsEta_ = dbe_->bookProfile("pConvVtxdRVsEta","Photon Reco conversion vtx dR vs Eta" ,etaBin2,etaMin, etaMax, 100, -20.,20., "");
1146  p_convVtxdXVsX_ = dbe_->bookProfile("pConvVtxdXVsX","Conversion vtx dX vs X" ,120,-60, 60 ,100, -20.,20., "");
1147  p_convVtxdYVsY_ = dbe_->bookProfile("pConvVtxdYVsY","Conversion vtx dY vs Y" ,120,-60, 60 ,100, -20.,20., "");
1148  p_convVtxdZVsZ_ = dbe_->bookProfile("pConvVtxdZVsZ","Conversion vtx dZ vs Z" ,zBin,zMin,zMax ,100, -20.,20., "");
1149 
1150 
1151  if ( ! isRunCentrally_ ) {
1152  h2_convVtxRrecVsTrue_ = dbe_->book2D("h2ConvVtxRrecVsTrue","Photon Reco conversion vtx R rec vs true" ,rBin,rMin, rMax,rBin,rMin, rMax);
1153  }
1154 
1155  histname="vtxChi2";
1156  h_vtxChi2_[0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 100, chi2Min, chi2Max);
1157  h_vtxChi2_[1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 100, chi2Min, chi2Max);
1158  h_vtxChi2_[2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 100, chi2Min, chi2Max);
1159  histname="vtxChi2Prob";
1160  h_vtxChi2Prob_[0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 100, 0., 1.);
1161  h_vtxChi2Prob_[1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 100, 0., 1.);
1162  h_vtxChi2Prob_[2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 100, 0., 1.);
1163 
1164  histname="zPVFromTracks";
1165  h_zPVFromTracks_[0] = dbe_->book1D(histname+"All"," Photons: PV z from conversion tracks", 100, -30., 30.);
1166  h_zPVFromTracks_[1] = dbe_->book1D(histname+"Barrel"," Photons: PV z from conversion tracks",100, -30., 30.);
1167  h_zPVFromTracks_[2] = dbe_->book1D(histname+"Endcap"," Photons: PV z from conversion tracks",100, -30., 30.);
1168  h_zPVFromTracks_[3] = dbe_->book1D(histname+"EndcapP"," Photons: PV z from conversion tracks",100, -30., 30.);
1169  h_zPVFromTracks_[4] = dbe_->book1D(histname+"EndcapM"," Photons: PV z from conversion tracks",100, -30., 30.);
1170  histname="dzPVFromTracks";
1171  h_dzPVFromTracks_[0] = dbe_->book1D(histname+"All"," Photons: PV Z_rec - Z_true from conversion tracks", 100, -10., 10.);
1172  h_dzPVFromTracks_[1] = dbe_->book1D(histname+"Barrel"," Photons: PV Z_rec - Z_true from conversion tracks",100, -10., 10.);
1173  h_dzPVFromTracks_[2] = dbe_->book1D(histname+"Endcap"," Photons: PV Z_rec - Z_true from conversion tracks",100, -10., 10.);
1174  h_dzPVFromTracks_[3] = dbe_->book1D(histname+"EndcapP"," Photons: PV Z_rec - Z_true from conversion tracks",100, -10., 10.);
1175  h_dzPVFromTracks_[4] = dbe_->book1D(histname+"EndcapM"," Photons: PV Z_rec - Z_true from conversion tracks",100, -10., 10.);
1176  p_dzPVVsR_ = dbe_->bookProfile("pdzPVVsR","Photon Reco conversions: dz(PV) vs R" ,rBin,rMin, rMax, 100, -3.,3.,"");
1177  p_dzPVVsEta_ = dbe_->bookProfile("pdzPVVsEta","Photon Reco conversions: dz(PV) vs Eta" ,etaBin,etaMin, etaMax, 100, -3.,3.,"");
1178 
1179  if ( ! isRunCentrally_ ) {
1180  h2_dzPVVsR_ = dbe_->book2D("h2dzPVVsR","Photon Reco conversions: dz(PV) vs R" ,rBin,rMin, rMax,100, -3.,3.);
1181  }
1182 
1184  if ( ! isRunCentrally_ ) {
1185  histname="nHitsVsEta";
1186  nHitsVsEta_[0] = dbe_->book2D(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs #eta all tracks",etaBin,etaMin, etaMax,25,0., 25.);
1187 
1188  histname="nHitsVsEta";
1189  nHitsVsEta_[1] = dbe_->book2D(histname+"AssTracks","Photons:Tracks from conversions: # of hits vs #eta associated tracks",etaBin,etaMin, etaMax,25,0., 25.);
1190 
1191  histname="nHitsVsR";
1192  nHitsVsR_[0] = dbe_->book2D(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs radius all tracks" ,rBin,rMin, rMax,25,0.,25);
1193 
1194  histname="nHitsVsR";
1195  nHitsVsR_[1] = dbe_->book2D(histname+"AssTracks","Photons:Tracks from conversions: # of hits vs radius associated tracks" ,rBin,rMin, rMax,25,0.,25);
1196 
1197  histname="h2Chi2VsEta";
1198  h2_Chi2VsEta_[0]=dbe_->book2D(histname+"All"," Reco Track #chi^{2} vs #eta: All ",etaBin2,etaMin, etaMax,100, chi2Min, chi2Max);
1199 
1200 
1201  histname="h2Chi2VsR";
1202  h2_Chi2VsR_[0]=dbe_->book2D(histname+"All"," Reco Track #chi^{2} vs R: All ",rBin,rMin, rMax,100,chi2Min, chi2Max);
1203  }
1204 
1205  histname="h_nHitsVsEta";
1206  p_nHitsVsEta_[0] = dbe_->bookProfile(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs #eta all tracks",etaBin,etaMin, etaMax, 25,-0.5, 24.5,"");
1207 
1208  histname="h_nHitsVsEta";
1209  p_nHitsVsEta_[1] = dbe_->bookProfile(histname+"AssTracks","Photons:Tracks from conversions: # of hits vs #eta associated tracks",etaBin,etaMin, etaMax, 25,-0.5, 24.5,"");
1210 
1211 
1212  histname="h_nHitsVsR";
1213  p_nHitsVsR_[0] = dbe_->bookProfile(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs radius all tracks",rBin,rMin, rMax, 25,-0.5, 24.5,"");
1214  histname="tkChi2";
1215  h_tkChi2_[0] = dbe_->book1D(histname+"AllTracks","Photons:Tracks from conversions: #chi^{2} of all tracks", 100, chi2Min, chi2Max);
1216  histname="tkChi2Large";
1217  h_tkChi2Large_[0] = dbe_->book1D(histname+"AllTracks","Photons:Tracks from conversions: #chi^{2} of all tracks", 1000, 0., 5000.0);
1218 
1219  histname="h_nHitsVsR";
1220  p_nHitsVsR_[1] = dbe_->bookProfile(histname+"AssTracks","Photons:Tracks from conversions: # of hits vs radius associated tracks",rBin,rMin, rMax, 25,-0.5, 24.5,"");
1221 
1222  histname="tkChi2";
1223  h_tkChi2_[1] = dbe_->book1D(histname+"AssTracks","Photons:Tracks from conversions: #chi^{2} of associated tracks", 100, chi2Min, chi2Max);
1224  histname="tkChi2Large";
1225  h_tkChi2Large_[1] = dbe_->book1D(histname+"AssTracks","Photons:Tracks from conversions: #chi^{2} of associated tracks", 1000, 0., 5000.0);
1226 
1227  histname="pChi2VsEta";
1228  p_Chi2VsEta_[0]=dbe_->bookProfile(histname+"All"," Reco Track #chi^{2} vs #eta : All ",etaBin2,etaMin, etaMax, 100, chi2Min, chi2Max,"");
1229 
1230  histname="pChi2VsR";
1231  p_Chi2VsR_[0]=dbe_->bookProfile(histname+"All"," Reco Track #chi^{2} vas R : All ",rBin,rMin,rMax, 100,chi2Min, chi2Max,"");
1232 
1233 
1234  histname="hTkD0";
1235  h_TkD0_[0]=dbe_->book1D(histname+"All"," Reco Track D0*q: All ",100,-0.1,0.6);
1236  h_TkD0_[1]=dbe_->book1D(histname+"Barrel"," Reco Track D0*q: Barrel ",100,-0.1,0.6);
1237  h_TkD0_[2]=dbe_->book1D(histname+"Endcap"," Reco Track D0*q: Endcap ",100,-0.1,0.6);
1238 
1239 
1240  histname="hTkPtPull";
1241  h_TkPtPull_[0]=dbe_->book1D(histname+"All"," Reco Track Pt pull: All ",100, -10., 10.);
1242  histname="hTkPtPull";
1243  h_TkPtPull_[1]=dbe_->book1D(histname+"Barrel"," Reco Track Pt pull: Barrel ",100, -10., 10.);
1244  histname="hTkPtPull";
1245  h_TkPtPull_[2]=dbe_->book1D(histname+"Endcap"," Reco Track Pt pull: Endcap ",100, -10., 10.);
1246 
1247  histname="pTkPtPullEta";
1248  p_TkPtPull_[0]=dbe_->bookProfile(histname+"All"," Reco Track Pt pull: All ",etaBin2,etaMin, etaMax, 100, -10., 10., " ");
1249 
1250  if ( ! isRunCentrally_ ) {
1251  histname="h2TkPtPullEta";
1252  h2_TkPtPull_[0]=dbe_->book2D(histname+"All"," Reco Track Pt pull: All ",etaBin2,etaMin, etaMax,100, -10., 10.);
1253 
1254  histname="PtRecVsPtSim";
1255  h2_PtRecVsPtSim_[0]=dbe_->book2D(histname+"All", "Pt Rec vs Pt sim: All ", etBin,etMin,etMax,etBin,etMin, etMax);
1256  h2_PtRecVsPtSim_[1]=dbe_->book2D(histname+"Barrel", "Pt Rec vs Pt sim: Barrel ", etBin,etMin,etMax,etBin,etMin, etMax);
1257  h2_PtRecVsPtSim_[2]=dbe_->book2D(histname+"Endcap", "Pt Rec vs Pt sim: Endcap ", etBin,etMin,etMax,etBin,etMin, etMax);
1258  histname="PtRecVsPtSimMixProv";
1259  h2_PtRecVsPtSimMixProv_ =dbe_->book2D(histname+"All", "Pt Rec vs Pt sim All for mix with general tracks ", etBin,etMin,etMax,etBin,etMin, etMax);
1260  }
1261 
1262 
1263  histname="eBcOverTkPout";
1264  hBCEnergyOverTrackPout_[0] = dbe_->book1D(histname+"All","Matrching BC E/P_out: all Ecal ",100, 0., 5.);
1265  hBCEnergyOverTrackPout_[1] = dbe_->book1D(histname+"Barrel","Matrching BC E/P_out: Barrel ",100, 0., 5.);
1266  hBCEnergyOverTrackPout_[2] = dbe_->book1D(histname+"Endcap","Matrching BC E/P_out: Endcap ",100, 0., 5.);
1267 
1268 
1270  h_OIinnermostHitR_ = dbe_->book1D("OIinnermostHitR"," R innermost hit for OI tracks ",50, 0., 25);
1271  h_IOinnermostHitR_ = dbe_->book1D("IOinnermostHitR"," R innermost hit for IO tracks ",50, 0., 25);
1272 
1274  h_trkProv_[0] = dbe_->book1D("allTrkProv"," Track pair provenance ",4, 0., 4.);
1275  h_trkProv_[1] = dbe_->book1D("assTrkProv"," Track pair provenance ",4, 0., 4.);
1276 
1277  // histos for fake rate
1278  histname = "h_RecoConvTwoTracksEta";
1279  h_RecoConvTwoTracks_[0] = dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated #eta",etaBin2,etaMin, etaMax);
1280  histname = "h_RecoConvTwoTracksPhi";
1281  h_RecoConvTwoTracks_[1] = dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated #phi",phiBin,phiMin, phiMax);
1282  histname = "h_RecoConvTwoTracksR";
1283  h_RecoConvTwoTracks_[2] = dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated R",rBin,rMin, rMax);
1284  histname = "h_RecoConvTwoTracksZ";
1285  h_RecoConvTwoTracks_[3] = dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated Z",zBin,zMin, zMax);
1286  histname = "h_RecoConvTwoTracksEt";
1287  h_RecoConvTwoTracks_[4] = dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated Et",etBin,etMin, etMax);
1288  //
1289  histname = "h_RecoConvTwoMTracksEta";
1290  h_RecoConvTwoMTracks_[0] = dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated #eta",etaBin2,etaMin, etaMax);
1291  histname = "h_RecoConvTwoMTracksPhi";
1292  h_RecoConvTwoMTracks_[1] = dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated #phi",phiBin,phiMin, phiMax);
1293  histname = "h_RecoConvTwoMTracksR";
1294  h_RecoConvTwoMTracks_[2] = dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated R",rBin,rMin, rMax);
1295  histname = "h_RecoConvTwoMTracksZ";
1296  h_RecoConvTwoMTracks_[3] = dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated Z",zBin,zMin, zMax);
1297  histname = "h_RecoConvTwoMTracksEt";
1298  h_RecoConvTwoMTracks_[4] = dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated Et",etBin,etMin, etMax);
1299 
1300 
1301 
1302 
1303  } // if DQM
1304 
1305 
1306 
1307 }
1308 
1309 
1310 
1311  void PhotonValidator::beginRun (edm::Run const & r, edm::EventSetup const & theEventSetup) {
1312 
1313  //get magnetic field
1314  edm::LogInfo("ConvertedPhotonProducer") << " get magnetic field" << "\n";
1315  theEventSetup.get<IdealMagneticFieldRecord>().get(theMF_);
1316 
1317 
1318  edm::ESHandle<TrackAssociatorBase> theHitsAssociator;
1319  theEventSetup.get<TrackAssociatorRecord>().get("trackAssociatorByHitsForPhotonValidation",theHitsAssociator);
1320  theTrackAssociator_ = (TrackAssociatorBase *) theHitsAssociator.product();
1321 
1322  thePhotonMCTruthFinder_ = new PhotonMCTruthFinder();
1323 
1324 }
1325 
1326 void PhotonValidator::endRun (edm::Run& r, edm::EventSetup const & theEventSetup) {
1327 
1328  delete thePhotonMCTruthFinder_;
1329 
1330 }
1331 
1332 
1333 
1334 void PhotonValidator::analyze( const edm::Event& e, const edm::EventSetup& esup ) {
1335 
1336 
1337  using namespace edm;
1338  // const float etaPhiDistance=0.01;
1339  // Fiducial region
1340  // const float TRK_BARL =0.9;
1341  const float BARL = 1.4442; // DAQ TDR p.290
1342  // const float END_LO = 1.566; // unused
1343  const float END_HI = 2.5;
1344  // Electron mass
1345  //const Float_t mElec= 0.000511;
1346 
1347 
1348  nEvt_++;
1349  LogInfo("PhotonValidator") << "PhotonValidator Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n";
1350  // std::cout << "PhotonValidator Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n";
1351 
1352 
1353  // get the geometry from the event setup:
1354  esup.get<CaloGeometryRecord>().get(theCaloGeom_);
1355 
1356 
1357  // Transform Track into TransientTrack (needed by the Vertex fitter)
1359  esup.get<TransientTrackRecord>().get("TransientTrackBuilder",theTTB);
1360 
1361 
1363  Handle<reco::PhotonCollection> photonHandle;
1364  e.getByLabel(photonCollectionProducer_, photonCollection_ , photonHandle);
1365  const reco::PhotonCollection photonCollection = *(photonHandle.product());
1366  if (!photonHandle.isValid()) {
1367  edm::LogError("PhotonProducer") << "Error! Can't get the Photon collection "<< std::endl;
1368  return;
1369  }
1370 
1371  Handle< edm::View<reco::Track> > outInTrkHandle;
1372  Handle< edm::View<reco::Track> > inOutTrkHandle;
1373  if ( !fastSim_) {
1375  e.getByLabel(conversionOITrackProducer_, outInTrkHandle);
1376  //std::cout << "ConvPhoAnalyzerWithOfficialAssociation outInTrack collection size " << (*outInTrkHandle).size() << "\n";
1377 
1379  e.getByLabel(conversionIOTrackProducer_, inOutTrkHandle);
1380  //std::cout << " ConvPhoAnalyzerWithOfficialAssociation inOutTrack collection size " << (*inOutTrkHandle).size() << "\n";
1381 
1382  // Loop over Out In Tracks
1383  int iTrk=0;
1384  int nHits=0;
1385  for( View<reco::Track>::const_iterator iTk = (*outInTrkHandle).begin(); iTk != (*outInTrkHandle).end(); iTk++) {
1386  // std::cout << " Barrel Out In Track charge " << iTk->charge() << " Num of RecHits " << iTk->recHitsSize() << " inner momentum " << sqrt( iTk->innerMomentum().Mag2() ) << "\n";
1387  // std::cout << " Barrel Out In Track Extra inner momentum " << sqrt(iTk->extra()->innerMomentum().Mag2()) << " inner position R " << sqrt( iTk->innerPosition().Perp2() ) << "\n";
1388  h_OIinnermostHitR_ ->Fill ( sqrt( iTk->innerPosition().Perp2() ) );
1389  for ( trackingRecHit_iterator itHits=iTk->extra()->recHitsBegin(); itHits!=iTk->extra()->recHitsEnd(); ++itHits ) {
1390  if ( (*itHits)->isValid() ) {
1391  nHits++;
1392  // cout <<nHits <<") RecHit in GP " << trackerGeom->idToDet((*itHits)->geographicalId())->surface().toGlobal((*itHits)->localPosition()) << " R "<< trackerGeom->idToDet((*itHits)->geographicalId())->surface().toGlobal((*itHits)->localPosition()).perp() << " Z " << trackerGeom->idToDet((*itHits)->geographicalId())->surface().toGlobal((*itHits)->localPosition()).z() << "\n";
1393  }
1394 
1395 
1396  }
1397 
1398  iTrk++;
1399 
1400 
1401  }
1402 
1403  // Loop over In Out Tracks Barrel
1404  iTrk=0;
1405  for( View<reco::Track>::const_iterator iTk = (*inOutTrkHandle).begin(); iTk != (*inOutTrkHandle).end(); iTk++) {
1406  //std::cout << " Barrel In Out Track charge " << iTk->charge() << " Num of RecHits " << iTk->recHitsSize() << " inner momentum " << sqrt( iTk->innerMomentum().Mag2()) << "\n";
1407  // std::cout << " Barrel In Out Track Extra inner momentum " << sqrt(iTk->extra()->innerMomentum().Mag2()) << "\n";
1408  h_IOinnermostHitR_ ->Fill ( sqrt( iTk->innerPosition().Perp2() ) );
1409  nHits=0;
1410  for ( trackingRecHit_iterator itHits=iTk->extra()->recHitsBegin(); itHits!=iTk->extra()->recHitsEnd(); ++itHits ) {
1411  if ( (*itHits)->isValid() ) {
1412  nHits++;
1413  //cout <<nHits <<") RecHit in GP " << trackerGeom->idToDet((*itHits)->geographicalId())->surface().toGlobal((*itHits)->localPosition()) << " R "<< trackerGeom->idToDet((*itHits)->geographicalId())->surface().toGlobal((*itHits)->localPosition()).perp() << " Z " << trackerGeom->idToDet((*itHits)->geographicalId())->surface().toGlobal((*itHits)->localPosition()).z() << "\n";
1414 
1415  }
1416  }
1417 
1418 
1419 
1420  iTrk++;
1421  }
1422 
1423  } // if !fastSim
1424 
1425 
1427  //get simtrack info
1428  std::vector<SimTrack> theSimTracks;
1429  std::vector<SimVertex> theSimVertices;
1432 
1433  if ( ! fastSim_) {
1434  e.getByLabel("g4SimHits",SimTk);
1435  e.getByLabel("g4SimHits",SimVtx);
1436  } else {
1437  e.getByLabel("famosSimHits",SimTk);
1438  e.getByLabel("famosSimHits",SimVtx);
1439 
1440  }
1441 
1442 
1443 
1444  theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
1445  theSimVertices.insert(theSimVertices.end(),SimVtx->begin(),SimVtx->end());
1446  std::vector<PhotonMCTruth> mcPhotons=thePhotonMCTruthFinder_->find (theSimTracks, theSimVertices);
1447 
1449  e.getByLabel("generator",hepMC);
1450  const HepMC::GenEvent *myGenEvent = hepMC->GetEvent();
1451 
1452 
1453  // get generated jets
1454  Handle<reco::GenJetCollection> GenJetsHandle ;
1455  e.getByLabel("iterativeCone5GenJets","",GenJetsHandle);
1456  reco::GenJetCollection genJetCollection = *(GenJetsHandle.product());
1457 
1458 
1459 
1460  // Get electron tracking truth
1461  bool useTP= parameters_.getParameter<bool>("useTP");
1463  edm::Handle<TrackingParticleCollection> ElectronTPHandle;
1464  if ( useTP) {
1465  if ( ! fastSim_) {
1466  e.getByLabel(label_tp_,ElectronTPHandle);
1467  // e.getByLabel("mergedtruth","MergedTrackTruth",ElectronTPHandle);
1468  trackingParticles = *(ElectronTPHandle.product());
1469  }
1470  }
1471 
1473  std::vector<reco::PhotonCollection::const_iterator> StoRMatchedConvertedPhotons;
1474  reco::SimToRecoCollection OISimToReco;
1475  reco::SimToRecoCollection IOSimToReco;
1476  // Reco to Sim
1477  reco::RecoToSimCollection OIRecoToSim;
1478  reco::RecoToSimCollection IORecoToSim;
1479 
1480  if ( useTP) {
1481  if ( ! fastSim_) {
1482  // Sim to Reco
1483  OISimToReco = theTrackAssociator_->associateSimToReco(outInTrkHandle, ElectronTPHandle, &e);
1484  IOSimToReco = theTrackAssociator_->associateSimToReco(inOutTrkHandle, ElectronTPHandle, &e);
1485  // Reco to Sim
1486  OIRecoToSim = theTrackAssociator_->associateRecoToSim(outInTrkHandle, ElectronTPHandle, &e);
1487  IORecoToSim = theTrackAssociator_->associateRecoToSim(inOutTrkHandle, ElectronTPHandle, &e);
1488  }
1489  }
1490  //
1491  vector<reco::SimToRecoCollection*> StoRCollPtrs;
1492  StoRCollPtrs.push_back(&OISimToReco);
1493  StoRCollPtrs.push_back(&IOSimToReco);
1494  vector<reco::RecoToSimCollection*> RtoSCollPtrs;
1495  RtoSCollPtrs.push_back(&OIRecoToSim);
1496  RtoSCollPtrs.push_back(&IORecoToSim);
1497  //
1498  for (int i=0; i<2; i++)
1499  nSimPho_[i]=0;
1500  for (int i=0; i<2; i++)
1501  nSimConv_[i]=0;
1502 
1503 
1504  std::vector<reco::Photon> myPhotons;
1505  for( reco::PhotonCollection::const_iterator iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
1506  if ( fabs(iPho->eta()) > 2.5 ) continue;
1507  myPhotons.push_back(*iPho);
1508  }
1509 
1510  std::sort(myPhotons.begin(), myPhotons.end(), sortPhotons());
1511  if ( myPhotons.size() >=2 ) {
1512  if ( myPhotons[0].et() > 40 && myPhotons[1].et() > 25 ) {
1513 
1514  math::XYZTLorentzVector p12 = myPhotons[0].p4()+myPhotons[1].p4();
1515  float gamgamMass2 = p12.Dot(p12);
1516  if ( gamgamMass2 > 0 ) {
1517 
1518  // total
1519  h_gamgamMass_[0][0] -> Fill(sqrt( gamgamMass2 ));
1520  if ( myPhotons[0].isEB() && myPhotons[1].isEB() )
1521  h_gamgamMass_[0][1] -> Fill(sqrt( gamgamMass2 ));
1522  if ( ( myPhotons[0].isEE() && myPhotons[1].isEE() ) ||
1523  ( myPhotons[0].isEE() && myPhotons[1].isEB() ) ||
1524  ( myPhotons[0].isEB() && myPhotons[1].isEE() ) )
1525  h_gamgamMass_[0][2] -> Fill(sqrt( gamgamMass2 ));
1526 
1527 
1528  // Golden photons
1529  if ( myPhotons[0].r9() > 0.93 && myPhotons[1].r9() > 0.93 ) {
1530  h_gamgamMass_[1][0] -> Fill(sqrt( gamgamMass2 ));
1531  if ( myPhotons[0].isEB() && myPhotons[1].isEB() )
1532  h_gamgamMass_[1][1] -> Fill(sqrt( gamgamMass2 ));
1533  if ( ( myPhotons[0].isEE() && myPhotons[1].isEE() ) ||
1534  ( myPhotons[0].isEE() && myPhotons[1].isEB() ) ||
1535  ( myPhotons[0].isEB() && myPhotons[1].isEE() ) )
1536  h_gamgamMass_[1][2] -> Fill(sqrt( gamgamMass2 ));
1537  }
1538 
1539 
1540  // both photons converted
1541  if ( myPhotons[0].conversions().size() > 0 && myPhotons[1].conversions().size() >0 ) {
1542  if ( myPhotons[0].conversions()[0]->nTracks() ==2 && myPhotons[1].conversions()[0]->nTracks() ==2 ) {
1543  float chi2Prob1 = ChiSquaredProbability( myPhotons[0].conversions()[0]->conversionVertex().chi2(), myPhotons[0].conversions()[0]->conversionVertex().ndof() );
1544  float chi2Prob2 = ChiSquaredProbability( myPhotons[1].conversions()[0]->conversionVertex().chi2(), myPhotons[1].conversions()[0]->conversionVertex().ndof() );
1545  if ( chi2Prob1 > 0.0005 && chi2Prob2 > 0.0005 ) {
1546  h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
1547  if ( myPhotons[0].isEB() && myPhotons[1].isEB() ) {
1548  h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
1549  }
1550  if ( ( myPhotons[0].isEE() && myPhotons[1].isEE() ) ||
1551  ( myPhotons[0].isEE() && myPhotons[1].isEB() ) ||
1552  ( myPhotons[0].isEB() && myPhotons[1].isEE() ) )
1553  h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 )); {
1554  }
1555  }
1556  }
1557 
1558 
1559  } else if ( myPhotons[0].conversions().size() > 0 && myPhotons[1].conversions().size() ==0 && myPhotons[1].r9() > 0.93 ) { // one photon converted
1560  if ( myPhotons[0].conversions()[0]->nTracks() ==2 ) {
1561  float chi2Prob1 = ChiSquaredProbability( myPhotons[0].conversions()[0]->conversionVertex().chi2(), myPhotons[0].conversions()[0]->conversionVertex().ndof() );
1562  if ( chi2Prob1 > 0.0005 ) {
1563  h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
1564  if ( myPhotons[0].isEB() && myPhotons[1].isEB() ) {
1565  h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
1566  }
1567  if ( myPhotons[0].isEE() || myPhotons[1].isEE() ) {
1568  h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 ));
1569  }
1570  }
1571  }
1572 
1573 
1574  } else if ( myPhotons[1].conversions().size() > 0 && myPhotons[0].conversions().size() ==0 && myPhotons[0].r9() > 0.93 ) { // one photon converted
1575  if ( myPhotons[1].conversions()[0]->nTracks() ==2 ) {
1576  float chi2Prob1 = ChiSquaredProbability( myPhotons[1].conversions()[0]->conversionVertex().chi2(), myPhotons[1].conversions()[0]->conversionVertex().ndof() );
1577  if ( chi2Prob1 > 0.0005 ) {
1578  h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
1579  if ( myPhotons[0].isEB() && myPhotons[1].isEB() ) {
1580  h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
1581  }
1582  if ( myPhotons[0].isEE() || myPhotons[1].isEE() ) {
1583  h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 ));
1584  }
1585  }
1586  }
1587  }
1588 
1589 
1590  }
1591  }
1592  }
1593 
1594 
1595  // cout << " PhotonValidator mcPhotons.size() " << mcPhotons.size() << endl;
1596  for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
1597  if ( (*mcPho).fourMomentum().et() < minPhoEtCut_ ) continue;
1598 
1599  for ( HepMC::GenEvent::particle_const_iterator mcIter=myGenEvent->particles_begin(); mcIter != myGenEvent->particles_end(); mcIter++ ) {
1600  if ( (*mcIter)->pdg_id() != 22 ) continue;
1601  bool isTheSame= false;
1602  HepMC::GenParticle* mother = 0;
1603  if ( (*mcIter)->production_vertex() ) {
1604  if ( (*mcIter)->production_vertex()->particles_begin(HepMC::parents) !=
1605  (*mcIter)->production_vertex()->particles_end(HepMC::parents))
1606  mother = *((*mcIter)->production_vertex()->particles_begin(HepMC::parents));
1607  }
1608 
1609 
1610 
1611 
1612  float mcPhi= (*mcPho).fourMomentum().phi();
1613  mcPhi_= phiNormalization(mcPhi);
1614  mcEta_= (*mcPho).fourMomentum().pseudoRapidity();
1615  mcEta_ = etaTransformation(mcEta_, (*mcPho).primaryVertex().z() );
1616  mcConvR_= (*mcPho).vertex().perp();
1617  mcConvX_= (*mcPho).vertex().x();
1618  mcConvY_= (*mcPho).vertex().y();
1619  mcConvZ_= (*mcPho).vertex().z();
1620  mcConvEta_= (*mcPho).vertex().eta();
1621  mcConvPhi_= (*mcPho).vertex().phi();
1622 
1623  if ( fabs(mcEta_) > END_HI ) continue;
1624 
1625 
1626 
1627  if ( mother ==0
1628  || (mother != 0 && mother->pdg_id() == 22)
1629  || (mother != 0 && mother->pdg_id() == 25)
1630  || (mother != 0 && mother->pdg_id() == 35) )
1631  {
1632  //std::cout << " ZERO mother or Higgs or primary photon " << std::endl;
1633  //if (mother !=0) std::cout << mother->pdg_id() << std::endl;
1634  double dPt = fabs((*mcIter)->momentum().perp() - (*mcPho).fourMomentum().et());
1635  float phiMother=(*mcIter)->momentum().phi();
1636  double dPhi = phiNormalization(phiMother) - mcPhi_ ;
1637  double dEta = fabs( (*mcIter)->momentum().eta() - (*mcPho).fourMomentum().pseudoRapidity() );
1638 
1639  //std::cout << " HEP photon pt " << (*mcIter)->momentum().perp() << " eta " << (*mcIter)->momentum().eta() << " phi " << (*mcIter)->momentum().phi() << std::endl;
1640  //std::cout << " (*mcPho).motherType() selection " << (*mcPho).motherType() << " pt " << (*mcPho).fourMomentum().et() << " eta " << (*mcPho).fourMomentum().pseudoRapidity() << " phi " << mcPhi_ << std::endl;
1641  //std::cout << " dPt " << dPt << " dEta " << dEta << " dPhi " << dPhi << std::endl;
1642  if ( dEta <=0.0001 && dPhi <=0.0001 && dPt <=0.0001)
1643  isTheSame = true;
1644 
1645  }
1646  if ( ! isTheSame ) continue;
1647  // std::cout << " HEP photon pt " << (*mcIter)->momentum().perp() << " eta " << (*mcIter)->momentum().eta() << " phi " << (*mcIter)->momentum().phi() << std::endl;
1648  //std::cout << " (*mcPho).motherType() after " << (*mcPho).motherType() << " pt " << (*mcPho).fourMomentum().et() << " eta " << (*mcPho).fourMomentum().pseudoRapidity() << " phi " << mcPhi_ << std::endl;
1649 
1650 
1651 
1652  // if ( ! ( fabs(mcEta_) <= BARL || ( fabs(mcEta_) >= END_LO && fabs(mcEta_) <=END_HI ) ) )
1653  // continue; // all ecal fiducial region
1654 
1655 
1656  nSimPho_[0]++;
1657  h_SimPhoMotherEt_[0]->Fill( (*mcPho).motherMomentum().et() );
1658  h_SimPhoMotherEta_[0]->Fill( (*mcPho).motherMomentum().pseudoRapidity());
1659 
1660  h_SimPho_[0]->Fill ( mcEta_);
1661  h_SimPho_[1]->Fill ( mcPhi_);
1662  h_SimPho_[2]->Fill ( (*mcPho).fourMomentum().et() );
1663 
1664 
1665 
1666 
1668 
1669  bool goodSimConversion=false;
1670  bool visibleConversion=false;
1671  bool visibleConversionsWithTwoSimTracks=false;
1672  if ( (*mcPho).isAConversion() == 1 ) {
1673  nSimConv_[0]++;
1674  h_AllSimConv_[0]->Fill( mcEta_ ) ;
1675  h_AllSimConv_[1]->Fill( mcPhi_ );
1676  h_AllSimConv_[2]->Fill( mcConvR_ );
1677  h_AllSimConv_[3]->Fill( mcConvZ_ );
1678  h_AllSimConv_[4]->Fill( (*mcPho).fourMomentum().et());
1679 
1680  if ( mcConvR_ <15) h_SimConvEtaPix_[0]->Fill( mcEta_ ) ;
1681 
1682  if ( ( fabs(mcEta_) <= BARL && mcConvR_ <85 ) ||
1683  ( fabs(mcEta_) > BARL && fabs(mcEta_) <=END_HI && fabs( (*mcPho).vertex().z() ) < 210 ) ) visibleConversion=true;
1684 
1685 
1686 
1687  theConvTP_.clear();
1688  //std::cout << " PhotonValidator TrackingParticles TrackingParticleCollection size "<< trackingParticles.size() << "\n";
1689  for(size_t i = 0; i < trackingParticles.size(); ++i){
1690  TrackingParticleRef tp (ElectronTPHandle,i);
1691  //std::cout << " Electron pt " << tp -> pt() << " charge " << tp -> charge() << " pdgId " << tp->pdgId() << " Hits for this track: " << tp -> trackPSimHit().size() << std::endl;
1692  //std::cout << " track vertex position x " << tp->vertex().x() << " y " << tp->vertex().y() << " z " << tp->vertex().z() << std::endl;
1693  //std::cout << " track vertex position x " << tp->vx() << " y " << tp->vy() << " z " << tp->vz() << std::endl;
1694  //std::cout << " conversion vertex position x " << (*mcPho).vertex().x() << " y " << (*mcPho).vertex().y() << " z " << (*mcPho).vertex().z() << std::endl;
1695  if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.001 &&
1696  fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.001 &&
1697  fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.001) {
1698 
1699  //std::cout << " From conversion Electron pt " << tp -> pt() << " charge " << tp -> charge() << " pdgId " << tp->pdgId() << " Hits for this track: " << tp -> trackPSimHit().size() << std::endl;
1700  // std::cout << " track vertex position x " << tp->vertex().x() << " y " << tp->vertex().y() << " z " << tp->vertex().z() << std::endl;
1701  //std::cout << " conversion vertex position x " << (*mcPho).vertex().x() << " y " << (*mcPho).vertex().y() << " z " << (*mcPho).vertex().z() << " R " << (*mcPho).vertex().perp() << std::endl;
1702  theConvTP_.push_back( tp );
1703  }
1704  }
1705  // std::cout << " PhotonValidator theConvTP_ size " << theConvTP_.size() << std::endl;
1706 
1707  if ( theConvTP_.size() == 2 ) visibleConversionsWithTwoSimTracks=true;
1708  goodSimConversion=false;
1709 
1710  if ( visibleConversion && visibleConversionsWithTwoSimTracks ) goodSimConversion=true;
1711  if ( goodSimConversion ) {
1712  nSimConv_[1]++;
1713  h_VisSimConv_[0]->Fill( mcEta_ ) ;
1714  h_VisSimConv_[1]->Fill( mcPhi_ );
1715  h_VisSimConv_[2]->Fill( mcConvR_ );
1716  h_VisSimConv_[3]->Fill( mcConvZ_ );
1717  h_VisSimConv_[4]->Fill( (*mcPho).fourMomentum().et());
1718 
1719 
1720  if ( useTP ) {
1721  for ( edm::RefVector<TrackingParticleCollection>::iterator iTrk=theConvTP_.begin(); iTrk!=theConvTP_.end(); ++iTrk) {
1722  h_simTkPt_ -> Fill ( (*iTrk)->pt() );
1723  h_simTkEta_ -> Fill ( (*iTrk)->eta() );
1724  }
1725  }
1726  }
1727  }
1728 
1729 
1730 
1731  float minDelta=10000.;
1732  std::vector<reco::Photon> thePhotons;
1733  int index=0;
1734  int iMatch=-1;
1735  bool matched=false;
1736 
1737  //std::cout << " Reco photon size " << photonCollection.size() << std::endl;
1738  for( reco::PhotonCollection::const_iterator iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
1739  reco::Photon aPho = reco::Photon(*iPho);
1740  thePhotons.push_back(aPho);
1741  float phiPho=aPho.phi();
1742  float etaPho=aPho.eta();
1743  float deltaPhi = phiPho-mcPhi_;
1744  float deltaEta = etaPho-mcEta_;
1745  if ( deltaPhi > pi ) deltaPhi -= twopi;
1746  if ( deltaPhi < -pi) deltaPhi += twopi;
1747  deltaPhi=pow(deltaPhi,2);
1748  deltaEta=pow(deltaEta,2);
1749  float delta = sqrt( deltaPhi+deltaEta);
1750  if ( delta<0.1 && delta < minDelta ) {
1751  minDelta=delta;
1752  iMatch=index;
1753 
1754  }
1755  index++;
1756  } // end loop over reco photons
1757  if ( iMatch>-1 ) matched=true;
1758 
1759 
1760  if ( matched ) {
1761  nSimPho_[1]++;
1762 
1763  h_SimPhoMotherEt_[1]->Fill( (*mcPho).motherMomentum().et() );
1764  h_SimPhoMotherEta_[1]->Fill( (*mcPho).motherMomentum().pseudoRapidity());
1765 
1766  h_MatchedSimPho_[0]->Fill( mcEta_ ) ;
1767  h_MatchedSimPho_[1]->Fill( mcPhi_ );
1768  h_MatchedSimPho_[2]->Fill( (*mcPho).fourMomentum().et());
1769 
1770  }
1771 
1772 
1773 
1774 
1775  if ( ! matched) continue;
1776 
1777  bool phoIsInBarrel=false;
1778  bool phoIsInEndcap=false;
1779  bool phoIsInEndcapP=false;
1780  bool phoIsInEndcapM=false;
1781 
1782  reco::Photon matchingPho = thePhotons[iMatch];
1783 
1784  if ( fabs(matchingPho.superCluster()->position().eta() ) < 1.479 ) {
1785  phoIsInBarrel=true;
1786  } else {
1787  phoIsInEndcap=true;
1788  if ( matchingPho.superCluster()->position().eta() > 0) phoIsInEndcapP=true;
1789  if ( matchingPho.superCluster()->position().eta() < 0) phoIsInEndcapM=true;
1790 
1791  }
1792  edm::Handle<EcalRecHitCollection> ecalRecHitHandle;
1793  if ( phoIsInBarrel ) {
1794  // Get handle to rec hits ecal barrel
1795  e.getByLabel(barrelEcalHits_, ecalRecHitHandle);
1796  if (!ecalRecHitHandle.isValid()) {
1797  edm::LogError("PhotonProducer") << "Error! Can't get the product "<<barrelEcalHits_.label();
1798  return;
1799  }
1800 
1801  } else if ( phoIsInEndcap ) {
1802 
1803  // Get handle to rec hits ecal encap
1804  e.getByLabel(endcapEcalHits_, ecalRecHitHandle);
1805  if (!ecalRecHitHandle.isValid()) {
1806  edm::LogError("PhotonProducer") << "Error! Can't get the product "<<endcapEcalHits_.label();
1807  return;
1808  }
1809 
1810  }
1811 
1812 
1813 
1814  int type=0;
1815  const EcalRecHitCollection ecalRecHitCollection = *(ecalRecHitHandle.product());
1816  float photonE = matchingPho.energy();
1817  float photonEt= matchingPho.energy()/cosh( matchingPho.eta()) ;
1818  float r9 = matchingPho.r9();
1819  float r1 = matchingPho.r1x5();
1820  float r2 = matchingPho.r2x5();
1821  float sigmaIetaIeta = matchingPho.sigmaIetaIeta();
1822  float hOverE = matchingPho.hadronicOverEm();
1823  float ecalIso = matchingPho.ecalRecHitSumEtConeDR04();
1824  float hcalIso = matchingPho.hcalTowerSumEtConeDR04();
1825  float trkIso = matchingPho.trkSumPtSolidConeDR04();
1826  float nIsoTrk = matchingPho.nTrkSolidConeDR04();
1827  std::vector< std::pair<DetId, float> >::const_iterator rhIt;
1828 
1829  bool atLeastOneDeadChannel=false;
1830  for(reco::CaloCluster_iterator bcIt = matchingPho.superCluster()->clustersBegin();bcIt != matchingPho.superCluster()->clustersEnd(); ++bcIt) {
1831  for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
1832 
1833  for(EcalRecHitCollection::const_iterator it = ecalRecHitCollection.begin(); it != ecalRecHitCollection.end(); ++it) {
1834  if (rhIt->first == (*it).id() ) {
1835  if ( (*it).recoFlag() == 9 ) {
1836  atLeastOneDeadChannel=true;
1837  break;
1838  }
1839  }
1840  }
1841  }
1842  }
1843 
1844  if ( atLeastOneDeadChannel ) {
1845  h_MatchedSimPhoBadCh_[0]->Fill( mcEta_ ) ;
1846  h_MatchedSimPhoBadCh_[1]->Fill( mcPhi_ );
1847  h_MatchedSimPhoBadCh_[2]->Fill( (*mcPho).fourMomentum().et());
1848 
1849  }
1850 
1851 
1852  h_scEta_[type]->Fill( matchingPho.superCluster()->eta() );
1853  h_scPhi_[type]->Fill( matchingPho.superCluster()->phi() );
1854  h_scEtaWidth_[type]->Fill( matchingPho.superCluster()->etaWidth() );
1855  h_scPhiWidth_[type]->Fill( matchingPho.superCluster()->phiWidth() );
1856  h_scE_[type][0]->Fill( matchingPho.superCluster()->energy() );
1857  h_scEt_[type][0]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
1858  if ( phoIsInEndcap ) h_psE_->Fill( matchingPho.superCluster()->preshowerEnergy() ) ;
1859  //
1860  h_r9_[type][0]->Fill( r9 );
1861  h2_r9VsEta_[0] -> Fill (mcEta_, r9);
1862  h2_r9VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r9);
1863  //
1864  h_r1_[type][0]->Fill( r1 );
1865  h2_r1VsEta_[0] -> Fill (mcEta_, r1);
1866  h2_r1VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r1);
1867  //
1868  h_r2_[type][0]->Fill( r2 );
1869  h2_r2VsEta_[0] -> Fill (mcEta_, r2);
1870  h2_r2VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r2);
1871  //
1872  h_sigmaIetaIeta_[type][0]->Fill( sigmaIetaIeta );
1873  h2_sigmaIetaIetaVsEta_[0] -> Fill (mcEta_, sigmaIetaIeta );
1874  h2_sigmaIetaIetaVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), sigmaIetaIeta);
1875  //
1876  h_hOverE_[type][0]->Fill( hOverE );
1877  h2_hOverEVsEta_[0] -> Fill (mcEta_, hOverE );
1878  h2_hOverEVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hOverE);
1879  p_hOverEVsEta_[0] -> Fill (mcEta_, hOverE );
1880  p_hOverEVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hOverE);
1881  //
1882  h_ecalRecHitSumEtConeDR04_[type][0]->Fill( ecalIso );
1883  h2_ecalRecHitSumEtConeDR04VsEta_[0] -> Fill (mcEta_, ecalIso );
1884  h2_ecalRecHitSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
1885  p_ecalRecHitSumEtConeDR04VsEta_[0] -> Fill (mcEta_, ecalIso );
1886  p_ecalRecHitSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
1887  //
1888  h_hcalTowerSumEtConeDR04_[type][0]->Fill( hcalIso );
1889  h2_hcalTowerSumEtConeDR04VsEta_[0] -> Fill (mcEta_, hcalIso );
1890  h2_hcalTowerSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
1891  p_hcalTowerSumEtConeDR04VsEta_[0] -> Fill (mcEta_, hcalIso );
1892  p_hcalTowerSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
1893  //
1894  h_isoTrkSolidConeDR04_[type][0]->Fill( trkIso );
1895  h2_isoTrkSolidConeDR04VsEta_[0] -> Fill (mcEta_, trkIso );
1896  h2_isoTrkSolidConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), trkIso);
1897  //
1898  h_nTrkSolidConeDR04_[type][0]->Fill( nIsoTrk );
1899  h2_nTrkSolidConeDR04VsEta_[0] -> Fill (mcEta_, nIsoTrk );
1900  h2_nTrkSolidConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), nIsoTrk);
1901  //
1902  h_phoEta_[type]->Fill( matchingPho.eta() );
1903  h_phoPhi_[type]->Fill( matchingPho.phi() );
1904  h_phoDEta_[0]->Fill ( matchingPho.eta() - (*mcPho).fourMomentum().eta() );
1905  h_phoDPhi_[0]->Fill ( matchingPho.phi() - mcPhi_ );
1906  h_phoE_[type][0]->Fill( photonE );
1907  h_phoEt_[type][0]->Fill( photonEt);
1908  //
1909  h_phoERes_[0][0]->Fill( photonE / (*mcPho).fourMomentum().e() );
1910  h2_eResVsEta_[0]->Fill (mcEta_, photonE/(*mcPho).fourMomentum().e() ) ;
1911  p_eResVsEta_[0]->Fill (mcEta_, photonE/(*mcPho).fourMomentum().e() ) ;
1912 
1913  if ( ! isRunCentrally_ ) h2_eResVsEt_[0][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
1914  p_eResVsEt_[0][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
1915 
1916  h2_eResVsR9_[0]->Fill (r9, photonE/(*mcPho).fourMomentum().e() ) ;
1917  h2_sceResVsR9_[0]->Fill (r9, matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e() ) ;
1918  p_eResVsR9_[0]->Fill (r9, photonE/(*mcPho).fourMomentum().e() ) ;
1919  p_sceResVsR9_[0]->Fill (r9, matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e() ) ;
1920  //
1921  if ( (*mcPho).isAConversion() == 0 ) {
1922  h2_eResVsEta_[1]->Fill (mcEta_, photonE/ (*mcPho).fourMomentum().e() ) ;
1923 
1924 
1925 
1926  h2_r9VsEta_[1] -> Fill (mcEta_, r9);
1927  h2_r9VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r9);
1928  //
1929  h2_r1VsEta_[1] -> Fill (mcEta_, r1);
1930  h2_r1VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r1);
1931  //
1932  h2_r2VsEta_[1] -> Fill (mcEta_, r2);
1933  h2_r2VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r2);
1934  //
1935  h2_sigmaIetaIetaVsEta_[1] -> Fill (mcEta_, sigmaIetaIeta );
1936  h2_sigmaIetaIetaVsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), sigmaIetaIeta);
1937  //
1938  h2_hOverEVsEta_[1] -> Fill (mcEta_, hOverE );
1939  h2_hOverEVsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hOverE);
1940  //
1941  h2_ecalRecHitSumEtConeDR04VsEta_[1] -> Fill (mcEta_, ecalIso );
1942  p_ecalRecHitSumEtConeDR04VsEta_[1] -> Fill (mcEta_, ecalIso );
1943  //
1944  h2_hcalTowerSumEtConeDR04VsEta_[1] -> Fill (mcEta_, hcalIso );
1945  p_hcalTowerSumEtConeDR04VsEta_[1] -> Fill (mcEta_, hcalIso );
1946  //
1947  h2_isoTrkSolidConeDR04VsEta_[1] -> Fill (mcEta_, trkIso );
1948  h2_isoTrkSolidConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), trkIso);
1949  //
1950  h2_nTrkSolidConeDR04VsEta_[1] -> Fill (mcEta_, nIsoTrk );
1951  h2_nTrkSolidConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), nIsoTrk);
1952 
1953  }
1954 
1955 
1956 
1957 
1958  if ( photonE/(*mcPho).fourMomentum().e() < 0.3 && photonE/(*mcPho).fourMomentum().e() > 0.1 ) {
1959  // std::cout << " Eta sim " << mcEta_ << " sc eta " << matchingPho.superCluster()->eta() << " pho eta " << matchingPho.eta() << std::endl;
1960 
1961  }
1962 
1963 
1964  if ( r9 > 0.93 ) {
1965  h_phoERes_[1][0]->Fill( photonE / (*mcPho).fourMomentum().e() );
1966  if ( ! isRunCentrally_ ) h2_eResVsEt_[0][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
1967  p_eResVsEt_[0][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
1968  p_eResVsEta_[1]->Fill (mcEta_,photonE/ (*mcPho).fourMomentum().e() ) ;
1969 
1970  } else if ( r9 <= 0.93 ) {
1971  h_phoERes_[2][0]->Fill(photonE / (*mcPho).fourMomentum().e() );
1972  if ( ! isRunCentrally_ ) h2_eResVsEt_[0][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
1973  p_eResVsEt_[0][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
1974  p_eResVsEta_[2]->Fill (mcEta_,photonE/ (*mcPho).fourMomentum().e() ) ;
1975  }
1976 
1977 
1978 
1979  if ( phoIsInBarrel ) {
1980  h_scE_[type][1]->Fill( matchingPho.superCluster()->energy() );
1981  h_scEt_[type][1]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
1982  h_r9_[type][1]->Fill( r9 );
1983  h_r1_[type][1]->Fill( r1 );
1984  h_r2_[type][1]->Fill( r2 );
1985  h_sigmaIetaIeta_[type][1]->Fill( sigmaIetaIeta );
1986  h_hOverE_[type][1]->Fill( hOverE );
1987  h_ecalRecHitSumEtConeDR04_[type][1]->Fill( ecalIso );
1988  h2_ecalRecHitSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
1989  p_ecalRecHitSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
1990  h_hcalTowerSumEtConeDR04_[type][1]->Fill( hcalIso );
1991  h2_hcalTowerSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
1992  p_hcalTowerSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
1993  h_isoTrkSolidConeDR04_[type][1]->Fill( trkIso );
1994  h_nTrkSolidConeDR04_[type][1]->Fill( nIsoTrk );
1995 
1996 
1997  h_phoE_[type][1]->Fill( photonE );
1998  h_phoEt_[type][1]->Fill( photonEt );
1999  h_nConv_[type][1]->Fill(float( matchingPho.conversions().size()));
2000 
2001 
2002  h_phoERes_[0][1]->Fill( photonE / (*mcPho).fourMomentum().e() );
2003  h2_eResVsR9_[1]->Fill (r9, photonE/(*mcPho).fourMomentum().e() ) ;
2004  h2_sceResVsR9_[1]->Fill (r9, matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e() ) ;
2005  p_eResVsR9_[1]->Fill (r9, photonE/(*mcPho).fourMomentum().e() ) ;
2006  p_sceResVsR9_[1]->Fill (r9, matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e() ) ;
2007 
2008  if ( ! isRunCentrally_ ) h2_eResVsEt_[1][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2009  p_eResVsEt_[1][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2010 
2011 
2012  if ( r9 > 0.93 ) {
2013  h_phoERes_[1][1]->Fill( photonE / (*mcPho).fourMomentum().e() );
2014  if ( ! isRunCentrally_ ) h2_eResVsEt_[1][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2015  p_eResVsEt_[1][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2016  }
2017  if ( r9 <= 0.93 ) {
2018  h_phoERes_[2][1]->Fill( photonE / (*mcPho).fourMomentum().e() );
2019  if ( ! isRunCentrally_ ) h2_eResVsEt_[1][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2020  p_eResVsEt_[1][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2021  }
2022  }
2023  if ( phoIsInEndcap ) {
2024  h_scE_[type][2]->Fill( matchingPho.superCluster()->energy() );
2025  h_scEt_[type][2]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
2026  h_r9_[type][2]->Fill( r9 );
2027  h_r1_[type][2]->Fill( r1 );
2028  h_r2_[type][2]->Fill( r2 );
2029  h_sigmaIetaIeta_[type][2]->Fill( sigmaIetaIeta );
2030  h_hOverE_[type][2]->Fill( hOverE );
2031  h_ecalRecHitSumEtConeDR04_[type][2]->Fill( ecalIso );
2032  h2_ecalRecHitSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
2033  p_ecalRecHitSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
2034  h_hcalTowerSumEtConeDR04_[type][2]->Fill( hcalIso );
2035  h2_hcalTowerSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
2036  p_hcalTowerSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
2037  h_isoTrkSolidConeDR04_[type][2]->Fill( trkIso );
2038  h_nTrkSolidConeDR04_[type][2]->Fill( nIsoTrk );
2039  h_phoE_[type][2]->Fill( photonE );
2040  h_phoEt_[type][2]->Fill( photonEt );
2041  h_nConv_[type][2]->Fill(float( matchingPho.conversions().size()));
2042  h_phoERes_[0][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
2043  h2_eResVsR9_[2]->Fill (r9, photonE/(*mcPho).fourMomentum().e() ) ;
2044  h2_sceResVsR9_[2]->Fill (r9, matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e() ) ;
2045  p_eResVsR9_[2]->Fill (r9, photonE/(*mcPho).fourMomentum().e() ) ;
2046  p_sceResVsR9_[2]->Fill (r9, matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e() ) ;
2047 
2048  if ( ! isRunCentrally_ ) h2_eResVsEt_[2][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2049  p_eResVsEt_[2][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2050 
2051  if ( r9 > 0.93 ) {
2052 
2053  h_phoERes_[1][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
2054  if ( ! isRunCentrally_ ) h2_eResVsEt_[2][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2055  p_eResVsEt_[2][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2056  }
2057  if ( r9 <= 0.93 ) {
2058  h_phoERes_[2][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
2059  if ( ! isRunCentrally_ ) h2_eResVsEt_[2][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2060  p_eResVsEt_[2][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2061  }
2062  }
2063 
2064 
2065 
2066 
2067  if ( ! (visibleConversion && visibleConversionsWithTwoSimTracks ) ) continue;
2068  h_r9_[1][0]->Fill( r9 );
2069  if ( phoIsInBarrel ) h_r9_[1][1]->Fill( r9 );
2070  if ( phoIsInEndcap ) h_r9_[1][2]->Fill( r9 );
2071 
2072  if ( ! isRunCentrally_ ) {
2073  h_simConvVtxRvsZ_[0] ->Fill ( fabs (mcConvZ_), mcConvR_ ) ;
2074  if ( fabs(mcEta_) <=1.) {
2075  h_simConvVtxRvsZ_[1] ->Fill ( fabs (mcConvZ_), mcConvR_ ) ;
2076  h_simConvVtxYvsX_ ->Fill ( mcConvX_, mcConvY_ ) ;
2077  }
2078  else
2079  h_simConvVtxRvsZ_[2] ->Fill ( fabs (mcConvZ_), mcConvR_ ) ;
2080  }
2081 
2082 
2083  if ( ! fastSim_) {
2084  h_nConv_[type][0]->Fill(float( matchingPho.conversions().size()));
2087 
2088  for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
2089  reco::ConversionRef aConv=conversions[iConv];
2090  double like = aConv->MVAout();
2091  if ( like < likelihoodCut_ ) continue;
2092 
2093  if ( ! isRunCentrally_ ) h2_EoverEtrueVsEta_[1]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2094  p_EoverEtrueVsEta_[1]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2095 
2096 
2097  //std::vector<reco::TrackRef> tracks = aConv->tracks();
2098  const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
2099  if (tracks.size() < 1 ) continue;
2100 
2101 
2102  h_mvaOut_[0]-> Fill(like);
2103 
2104  if ( tracks.size()==2 ) {
2105  if ( sqrt( aConv->tracksPin()[0].Perp2()) < convTrackMinPtCut_ || sqrt( aConv->tracksPin()[1].Perp2()) < convTrackMinPtCut_) continue;
2106  } else {
2107  if ( sqrt( aConv->tracksPin()[0].Perp2()) < convTrackMinPtCut_ ) continue;
2108  }
2109 
2110 
2111  if ( dCotCutOn_ ) {
2112  if ( (fabs(mcEta_) > 1.1 && fabs (mcEta_) < 1.4 ) &&
2113  fabs( aConv->pairCotThetaSeparation() ) > dCotHardCutValue_ ) continue;
2114  if ( fabs( aConv->pairCotThetaSeparation() ) > dCotCutValue_ ) continue;
2115  }
2116 
2117  //std::cout << " PhotonValidator converison algo name " << aConv->algoName() << " " << aConv->algo() << std::endl;
2118 
2119  nRecConv_++;
2120 
2121  std::map<const reco::Track*,TrackingParticleRef> myAss;
2122  std::map<const reco::Track*,TrackingParticleRef>::const_iterator itAss;
2123  std::map<reco::TrackRef,TrackingParticleRef>::const_iterator itAssMin;
2124  std::map<reco::TrackRef,TrackingParticleRef>::const_iterator itAssMax;
2125  //
2126 
2127  int nAssT2=0;
2128  for (unsigned int i=0; i<tracks.size(); i++) {
2129  // reco::TrackRef track = tracks[i].castTo<reco::TrackRef>();
2130 
2131  type =0;
2132  if ( ! isRunCentrally_ ) nHitsVsEta_[type] ->Fill (mcEta_, float(tracks[i]->numberOfValidHits())-0.0001 );
2133  if ( ! isRunCentrally_ ) nHitsVsR_[type] ->Fill (mcConvR_, float(tracks[i]->numberOfValidHits())-0.0001 );
2134  p_nHitsVsEta_[type] ->Fill (mcEta_, float(tracks[i]->numberOfValidHits()) );
2135  p_nHitsVsR_[type] ->Fill (mcConvR_, float(tracks[i]->numberOfValidHits()) );
2136  h_tkChi2_[type] ->Fill (tracks[i]->normalizedChi2() );
2137 
2138 
2139  RefToBase<reco::Track> tfrb = tracks[i];
2141  tc.push_back(tfrb);
2142  // reco::RecoToSimCollection q = theTrackAssociator_->associateRecoToSim(tc,theConvTP_,&e);
2143  reco::SimToRecoCollection q = theTrackAssociator_->associateSimToReco(tc,theConvTP_,&e);
2144  std::vector<std::pair<RefToBase<reco::Track>, double> > trackV;
2145  int tpI = 0;
2146 
2147  if (q.find(theConvTP_[0])!=q.end()){
2148  trackV = (std::vector<std::pair<RefToBase<reco::Track>, double> >) q[theConvTP_[0]];
2149  } else if (q.find(theConvTP_[1])!=q.end()){
2150  trackV = (std::vector<std::pair<RefToBase<reco::Track>, double> >) q[theConvTP_[1]];
2151  tpI = 1;
2152  }
2153 
2154  if ( !trackV.size() ) continue;
2155  edm::RefToBase<reco::Track> tr = trackV.front().first;
2156  myAss.insert( std::make_pair (tr.get(),theConvTP_[tpI] ) );
2157  nAssT2++;
2158 
2159  }
2160 
2161 
2162 
2163 
2164 
2165  /*
2167  TrackingParticleRef myTP;
2168  for (size_t j = 0; j < RtoSCollPtrs.size(); j++) {
2169  reco::RecoToSimCollection q = *(RtoSCollPtrs[j]);
2170 
2171  RefToBase<reco::Track> myTk( track );
2172 
2173  if( q.find(myTk ) != q.end() ) {
2174  std::vector<std::pair<TrackingParticleRef, double> > tp = q[myTk];
2175  for (unsigned int itp=0; itp<tp.size(); itp++) {
2176  myTP=tp[itp].first;
2177  // std::cout << " associated with TP " << myTP->pdgId() << " pt " << sqrt(myTP->momentum().perp2()) << std::endl;
2178  myAss.insert( std::make_pair ( track , myTP) );
2179  nAssT2++;
2180  }
2181  }
2182  }
2183  }
2184  */
2185 
2186 
2187  type=0;
2188 
2189  // float totP = sqrt(aConv->pairMomentum().Mag2());
2190  float refP =-99999.;
2191  float refPt =-99999.;
2192  if ( aConv->conversionVertex().isValid() ) {
2193  refP=sqrt(aConv->refittedPairMomentum().Mag2());
2194  refPt=sqrt(aConv->refittedPairMomentum().perp2());
2195  }
2196  float invM = aConv->pairInvariantMass();
2197 
2198  h_invMass_[type][0] ->Fill( invM);
2199  if ( phoIsInBarrel ) h_invMass_[type][1] ->Fill(invM);
2200  if ( phoIsInEndcap ) h_invMass_[type][2] ->Fill(invM);
2201 
2202 
2204  if ( tracks.size() ==1 ) {
2205  h_SimConvOneTracks_[0]->Fill( mcEta_ ) ;
2206  h_SimConvOneTracks_[1]->Fill( mcPhi_ );
2207  h_SimConvOneTracks_[2]->Fill( mcConvR_ );
2208  h_SimConvOneTracks_[3]->Fill( mcConvZ_ );
2209  h_SimConvOneTracks_[4]->Fill( (*mcPho).fourMomentum().et());
2210 
2211 
2212  } else if ( tracks.size() ==2 ) {
2213 
2214  h_SimConvTwoTracks_[0]->Fill( mcEta_ ) ;
2215  h_SimConvTwoTracks_[1]->Fill( mcPhi_ );
2216  h_SimConvTwoTracks_[2]->Fill( mcConvR_ );
2217  h_SimConvTwoTracks_[3]->Fill( mcConvZ_ );
2218  h_SimConvTwoTracks_[4]->Fill( (*mcPho).fourMomentum().et());
2219 
2220  h_convEta_[1]->Fill( aConv->caloCluster()[0]->eta() );
2221 
2222  float trkProvenance=3;
2223  if ( tracks[0]->algoName() == "outInEcalSeededConv" && tracks[1]->algoName() == "outInEcalSeededConv" ) trkProvenance=0;
2224  if ( tracks[0]->algoName() == "inOutEcalSeededConv" && tracks[1]->algoName() == "inOutEcalSeededConv" ) trkProvenance=1;
2225  if ( ( tracks[0]->algoName() == "outInEcalSeededConv" && tracks[1]->algoName() == "inOutEcalSeededConv") ||
2226  ( tracks[1]->algoName() == "outInEcalSeededConv" && tracks[0]->algoName() == "inOutEcalSeededConv") ) trkProvenance=2;
2227  if ( trkProvenance==3 ) {
2228  // std::cout << " PhotonValidator provenance of tracks is " << tracks[0]->algoName() << " and " << tracks[1]->algoName() << std::endl;
2229  }
2230  h_trkProv_[0]->Fill( trkProvenance );
2231 
2232 
2233 
2235  if ( nAssT2 ==2 ) {
2236 
2237 
2238 
2239 
2240  h_r9_[2][0]->Fill( r9 );
2241  if ( phoIsInBarrel ) h_r9_[2][1]->Fill( r9 );
2242  if ( phoIsInEndcap ) h_r9_[2][2]->Fill( r9 );
2243 
2244  h_convEta_[2]->Fill( aConv->caloCluster()[0]->eta() );
2245 
2246  nRecConvAss_++;
2247 
2248 
2249  h_SimConvTwoMTracks_[0]->Fill( mcEta_ ) ;
2250  h_SimConvTwoMTracks_[1]->Fill( mcPhi_ );
2251  h_SimConvTwoMTracks_[2]->Fill( mcConvR_ );
2252  h_SimConvTwoMTracks_[3]->Fill( mcConvZ_ );
2253  h_SimConvTwoMTracks_[4]->Fill( (*mcPho).fourMomentum().et());
2254 
2255  if ( aConv->conversionVertex().isValid() ) {
2256  if ( trkProvenance==3 ) std::cout << " PhotonValidator provenance of tracks is mixed and vertex is valid " << std::endl;
2257  float chi2Prob = ChiSquaredProbability( aConv->conversionVertex().chi2(), aConv->conversionVertex().ndof() );
2258  if ( chi2Prob > 0) {
2259  h_SimConvTwoMTracksAndVtxPGT0_[0]->Fill( mcEta_ ) ;
2260  h_SimConvTwoMTracksAndVtxPGT0_[1]->Fill( mcPhi_ );
2261  h_SimConvTwoMTracksAndVtxPGT0_[2]->Fill( mcConvR_ );
2262  h_SimConvTwoMTracksAndVtxPGT0_[3]->Fill( mcConvZ_ );
2263  h_SimConvTwoMTracksAndVtxPGT0_[4]->Fill( (*mcPho).fourMomentum().et());
2264  }
2265  if ( chi2Prob > 0.0005) {
2266  h_SimConvTwoMTracksAndVtxPGT0005_[0]->Fill( mcEta_ ) ;
2267  h_SimConvTwoMTracksAndVtxPGT0005_[1]->Fill( mcPhi_ );
2268  h_SimConvTwoMTracksAndVtxPGT0005_[2]->Fill( mcConvR_ );
2269  h_SimConvTwoMTracksAndVtxPGT0005_[3]->Fill( mcConvZ_ );
2270  h_SimConvTwoMTracksAndVtxPGT0005_[4]->Fill( (*mcPho).fourMomentum().et());
2271 
2272  }
2273 
2274  if ( chi2Prob > 0.0005 ) {
2275  h_convEta_[0]->Fill( aConv->caloCluster()[0]->eta() );
2276  h_convPhi_[0]->Fill( aConv->caloCluster()[0]->phi() );
2277  h_convERes_[0][0]->Fill( aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
2278  if ( ! isRunCentrally_ ) h_r9VsNofTracks_[0][0]->Fill( r9, aConv->nTracks() ) ;
2279 
2280  if ( phoIsInBarrel ) {
2281  h_convERes_[0][1]->Fill(aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
2282  if ( ! isRunCentrally_ ) h_r9VsNofTracks_[0][1]->Fill( r9, aConv->nTracks() ) ;
2283  h_mvaOut_[1]-> Fill(like);
2284  }
2285  if ( phoIsInEndcap ) {
2286  h_convERes_[0][2]->Fill(aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
2287  if ( ! isRunCentrally_ ) h_r9VsNofTracks_[0][2]->Fill( r9, aConv->nTracks() ) ;
2288  h_mvaOut_[2]-> Fill(like);
2289  }
2290 
2291  }
2292 
2293 
2294 
2295 
2296  }
2297 
2299  type =1;
2300 
2301  h_trkProv_[1]->Fill( trkProvenance );
2302  h_invMass_[type][0] ->Fill( invM);
2303 
2304 
2305 
2306  float eoverp= -99999.;
2307 
2308  if ( aConv->conversionVertex().isValid() ) {
2309  eoverp= aConv->EoverPrefittedTracks();
2310  h_convPtRes_[type][0]->Fill( refPt / (*mcPho).fourMomentum().et() );
2311  h_EoverPTracks_[type][0] ->Fill( eoverp ) ;
2312  h_PoverETracks_[type][0] ->Fill( 1./eoverp ) ;
2313  if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[0] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2314  if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[0] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e() ) ;
2315  if ( ! isRunCentrally_ ) h2_EoverPVsEta_[0]->Fill (mcEta_, eoverp);
2316  if ( ! isRunCentrally_ ) h2_EoverPVsR_[0]->Fill (mcConvR_, eoverp);
2317  p_EoverPVsEta_[0]->Fill (mcEta_, eoverp);
2318  p_EoverPVsR_[0]->Fill (mcConvR_, eoverp);
2319  p_eResVsR_ ->Fill ( mcConvR_, photonE / (*mcPho).fourMomentum().e() );
2320  if ( ! isRunCentrally_ ) h2_PoverPtrueVsEta_[0]->Fill (mcEta_,refP/ (*mcPho).fourMomentum().e() ) ;
2321  p_PoverPtrueVsEta_[0]->Fill (mcEta_,refP/ (*mcPho).fourMomentum().e() ) ;
2322 
2323 
2324  }
2325 
2326 
2327  if ( ! isRunCentrally_ ) h2_EoverEtrueVsEta_[0]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2328  if ( ! isRunCentrally_ ) h2_EoverEtrueVsR_[0]->Fill (mcConvR_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2329  p_EoverEtrueVsEta_[0]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2330  p_EoverEtrueVsR_[0]->Fill (mcConvR_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2331 
2332 
2333  if ( ! isRunCentrally_ ) h2_etaVsRsim_[0]->Fill (mcEta_,mcConvR_);
2334 
2335  /*
2336  reco::TrackRef track1 = tracks[0].castTo<reco::TrackRef>();
2337  reco::TrackRef track2 = tracks[1].castTo<reco::TrackRef>();
2338  reco::TransientTrack tt1 = (*theTTB).build( &track1);
2339  reco::TransientTrack tt2 = (*theTTB).build( &track2);
2340  TwoTrackMinimumDistance md;
2341  md.calculate ( tt1.initialFreeState(), tt2.initialFreeState() );
2342  if (md.status() ) {
2343  //cout << " Min Dist " << md.distance() << std::endl;
2344  h_distMinAppTracks_[1][0]->Fill ( md.distance() );
2345  } else {
2346  nInvalidPCA_++;
2347 
2348  }
2349  */
2350 
2351  // here original tracks and their inner momentum is considered
2352  float dPhiTracksAtVtx = aConv->dPhiTracksAtVtx();
2353  h_DPhiTracksAtVtx_[type][0]->Fill( dPhiTracksAtVtx);
2354  if ( ! isRunCentrally_ ) h2_DPhiTracksAtVtxVsEta_->Fill( mcEta_, dPhiTracksAtVtx);
2355  if ( ! isRunCentrally_ ) h2_DPhiTracksAtVtxVsR_->Fill( mcConvR_, dPhiTracksAtVtx);
2356  p_DPhiTracksAtVtxVsEta_->Fill( mcEta_, dPhiTracksAtVtx);
2357  p_DPhiTracksAtVtxVsR_->Fill( mcConvR_, dPhiTracksAtVtx);
2358 
2359  h_DCotTracks_[type][0] ->Fill ( aConv->pairCotThetaSeparation() );
2360  if ( ! isRunCentrally_ ) h2_DCotTracksVsEta_->Fill( mcEta_, aConv->pairCotThetaSeparation() );
2361  if ( ! isRunCentrally_ ) h2_DCotTracksVsR_->Fill( mcConvR_, aConv->pairCotThetaSeparation() );
2362  p_DCotTracksVsEta_->Fill( mcEta_, aConv->pairCotThetaSeparation() );
2363  p_DCotTracksVsR_->Fill( mcConvR_, aConv->pairCotThetaSeparation() );
2364 
2365 
2366  if ( phoIsInBarrel ) {
2367  h_invMass_[type][1] ->Fill(invM);
2368  if ( aConv->conversionVertex().isValid() ) {
2369  h_convPtRes_[type][1]->Fill( refPt / (*mcPho).fourMomentum().et() );
2370  h_EoverPTracks_[type][1] ->Fill( eoverp ) ;
2371  if ( mcConvR_ < 15 ) h_EoverPTracks_[0][0] ->Fill( eoverp ) ;
2372  if ( mcConvR_ > 15 && mcConvR_< 58 ) h_EoverPTracks_[0][1] ->Fill( eoverp ) ;
2373  if ( mcConvR_ > 58 ) h_EoverPTracks_[0][2] ->Fill( eoverp ) ;
2374  h_PoverETracks_[type][1] ->Fill( 1./eoverp ) ;
2375  if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[1] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2376  if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[1] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e() ) ;
2377  }
2378  h_DPhiTracksAtVtx_[type][1]->Fill( dPhiTracksAtVtx);
2379  h_DCotTracks_[type][1] ->Fill ( aConv->pairCotThetaSeparation() );
2380 
2381 
2382  }
2383 
2384 
2385  if ( phoIsInEndcap ) {
2386  h_invMass_[type][2] ->Fill(invM);
2387  if ( aConv->conversionVertex().isValid() ) {
2388  h_convPtRes_[type][2]->Fill( refPt / (*mcPho).fourMomentum().et() );
2389  h_EoverPTracks_[type][2] ->Fill( eoverp ) ;
2390  h_PoverETracks_[type][2] ->Fill( 1./eoverp ) ;
2391  if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[2] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2392  if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[2] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e() ) ;
2393  }
2394  h_DPhiTracksAtVtx_[type][2]->Fill( dPhiTracksAtVtx);
2395  h_DCotTracks_[type][2] ->Fill ( aConv->pairCotThetaSeparation() );
2396 
2397  }
2398 
2399 
2400  if ( aConv->conversionVertex().isValid() ) {
2401 
2402  h_convVtxdX_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
2403  h_convVtxdY_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
2404  h_convVtxdZ_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
2405  h_convVtxdR_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
2406 
2407  if ( fabs( mcConvEta_ ) <= 1.2 ) {
2408  h_convVtxdX_barrel_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
2409  h_convVtxdY_barrel_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
2410  h_convVtxdZ_barrel_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
2411  h_convVtxdR_barrel_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
2412  } else {
2413  h_convVtxdX_endcap_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
2414  h_convVtxdY_endcap_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
2415  h_convVtxdZ_endcap_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
2416  h_convVtxdR_endcap_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
2417  }
2418 
2419 
2420  h_convVtxdPhi_ ->Fill ( aConv->conversionVertex().position().phi() - mcConvPhi_);
2421  h_convVtxdEta_ ->Fill ( aConv->conversionVertex().position().eta() - mcConvEta_);
2422  if ( ! isRunCentrally_ ) h2_convVtxdRVsR_ ->Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
2423  if ( ! isRunCentrally_ ) h2_convVtxdRVsEta_ ->Fill (mcEta_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
2424  p_convVtxdRVsR_ ->Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
2425  p_convVtxdRVsEta_ ->Fill (mcEta_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
2426  float signX= aConv->refittedPairMomentum().x()/fabs(aConv->refittedPairMomentum().x());
2427  float signY= aConv->refittedPairMomentum().y()/fabs(aConv->refittedPairMomentum().y());
2428  float signZ= aConv->refittedPairMomentum().z()/fabs(aConv->refittedPairMomentum().z());
2429  p_convVtxdXVsX_ ->Fill (mcConvX_, (aConv->conversionVertex().position().x() - mcConvX_)*signX );
2430  p_convVtxdYVsY_ ->Fill (mcConvY_, (aConv->conversionVertex().position().y() - mcConvY_)*signY );
2431  p_convVtxdZVsZ_ ->Fill (mcConvZ_, (aConv->conversionVertex().position().z() - mcConvZ_)*signZ );
2432 
2433 
2434  if ( ! isRunCentrally_ ) h2_convVtxRrecVsTrue_ -> Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) );
2435 
2436 
2437 
2438  //float zPV = aConv->zOfPrimaryVertexFromTracks();
2439  float thetaConv=aConv->refittedPairMomentum().Theta();
2440  float thetaSC=matchingPho.superCluster()->position().theta();
2441  float rSC=sqrt(matchingPho.superCluster()->position().x()*matchingPho.superCluster()->position().x() +
2442  matchingPho.superCluster()->position().y()*matchingPho.superCluster()->position().y() );
2443  float zSC=matchingPho.superCluster()->position().z();
2444  float zPV = sqrt(rSC*rSC+zSC*zSC)*sin( thetaConv - thetaSC)/sin(thetaConv);
2445 
2446  h_zPVFromTracks_[0]->Fill ( zPV );
2447  h_dzPVFromTracks_[0]->Fill ( zPV- (*mcPho).primaryVertex().z() );
2448 
2449 
2450  if ( phoIsInBarrel ) {
2451  h_zPVFromTracks_[1]->Fill ( zPV );
2452  h_dzPVFromTracks_[1]->Fill ( zPV - (*mcPho).primaryVertex().z() );
2453  } else if ( phoIsInEndcap) {
2454  h_zPVFromTracks_[2]->Fill ( zPV );
2455  h_dzPVFromTracks_[2]->Fill ( zPV - (*mcPho).primaryVertex().z() );
2456  } else if ( phoIsInEndcapP) {
2457  h_zPVFromTracks_[3]->Fill ( zPV );
2458  h_dzPVFromTracks_[3]->Fill ( zPV - (*mcPho).primaryVertex().z() );
2459  } else if ( phoIsInEndcapM) {
2460  h_zPVFromTracks_[4]->Fill ( zPV );
2461  h_dzPVFromTracks_[4]->Fill ( zPV - (*mcPho).primaryVertex().z() );
2462  }
2463 
2464  p_dzPVVsR_ ->Fill(mcConvR_, zPV - (*mcPho).primaryVertex().z() );
2465  p_dzPVVsEta_ ->Fill(mcConvEta_, zPV - (*mcPho).primaryVertex().z() );
2466  if ( ! isRunCentrally_ ) h2_dzPVVsR_ ->Fill(mcConvR_, zPV - (*mcPho).primaryVertex().z() );
2467 
2468  }
2469 
2470  float dPhiTracksAtEcal=-99;
2471  float dEtaTracksAtEcal=-99;
2472  if (aConv->bcMatchingWithTracks()[0].isNonnull() && aConv->bcMatchingWithTracks()[1].isNonnull() ) {
2473  nRecConvAssWithEcal_++;
2474  float recoPhi1 = aConv->ecalImpactPosition()[0].phi();
2475  float recoPhi2 = aConv->ecalImpactPosition()[1].phi();
2476  float recoEta1 = aConv->ecalImpactPosition()[0].eta();
2477  float recoEta2 = aConv->ecalImpactPosition()[1].eta();
2478  float bcPhi1 = aConv->bcMatchingWithTracks()[0]->phi();
2479  float bcPhi2 = aConv->bcMatchingWithTracks()[1]->phi();
2480  // unused float bcEta1 = aConv->bcMatchingWithTracks()[0]->eta();
2481  // unused float bcEta2 = aConv->bcMatchingWithTracks()[1]->eta();
2482  recoPhi1 = phiNormalization(recoPhi1);
2483  recoPhi2 = phiNormalization(recoPhi2);
2484  bcPhi1 = phiNormalization(bcPhi1);
2485  bcPhi2 = phiNormalization(bcPhi2);
2486  dPhiTracksAtEcal = recoPhi1 -recoPhi2;
2487  dPhiTracksAtEcal = phiNormalization( dPhiTracksAtEcal );
2488  dEtaTracksAtEcal = recoEta1 -recoEta2;
2489 
2490 
2491  h_DPhiTracksAtEcal_[type][0]->Fill( fabs(dPhiTracksAtEcal));
2492  if ( ! isRunCentrally_ ) h2_DPhiTracksAtEcalVsR_ ->Fill (mcConvR_, fabs(dPhiTracksAtEcal));
2493  if ( ! isRunCentrally_ ) h2_DPhiTracksAtEcalVsEta_ ->Fill (mcEta_, fabs(dPhiTracksAtEcal));
2494  p_DPhiTracksAtEcalVsR_ ->Fill (mcConvR_, fabs(dPhiTracksAtEcal));
2495  p_DPhiTracksAtEcalVsEta_ ->Fill (mcEta_, fabs(dPhiTracksAtEcal));
2496 
2497  h_DEtaTracksAtEcal_[type][0]->Fill( dEtaTracksAtEcal);
2498 
2499  if ( phoIsInBarrel ) {
2500  h_DPhiTracksAtEcal_[type][1]->Fill( fabs(dPhiTracksAtEcal));
2501  h_DEtaTracksAtEcal_[type][1]->Fill( dEtaTracksAtEcal);
2502  }
2503  if ( phoIsInEndcap ) {
2504  h_DPhiTracksAtEcal_[type][2]->Fill( fabs(dPhiTracksAtEcal));
2505  h_DEtaTracksAtEcal_[type][2]->Fill( dEtaTracksAtEcal);
2506  }
2507 
2508  }
2509 
2510 
2511 
2512 
2514  for (unsigned int i=0; i<tracks.size(); i++) {
2515  RefToBase<reco::Track> tfrb(tracks[i] );
2516  itAss= myAss.find( tfrb.get() );
2517  if ( itAss == myAss.end() ) continue;
2518 
2519  float trkProvenance=3;
2520  if ( tracks[0]->algoName() == "outInEcalSeededConv" && tracks[1]->algoName() == "outInEcalSeededConv" ) trkProvenance=0;
2521  if ( tracks[0]->algoName() == "inOutEcalSeededConv" && tracks[1]->algoName() == "inOutEcalSeededConv" ) trkProvenance=1;
2522  if ( ( tracks[0]->algoName() == "outInEcalSeededConv" && tracks[1]->algoName() == "inOutEcalSeededConv") ||
2523  ( tracks[1]->algoName() == "outInEcalSeededConv" && tracks[0]->algoName() == "inOutEcalSeededConv") ) trkProvenance=2;
2524 
2525 
2526  if ( ! isRunCentrally_ ) nHitsVsEta_[type] ->Fill (mcEta_, float(tracks[i]->numberOfValidHits()) );
2527  if ( ! isRunCentrally_ ) nHitsVsR_[type] ->Fill (mcConvR_, float(tracks[i]->numberOfValidHits()) );
2528  p_nHitsVsEta_[type] ->Fill (mcEta_, float(tracks[i]->numberOfValidHits()) -0.0001);
2529  p_nHitsVsR_[type] ->Fill (mcConvR_, float(tracks[i]->numberOfValidHits()) -0.0001);
2530  h_tkChi2_[type] ->Fill (tracks[i]->normalizedChi2() );
2531  h_tkChi2Large_[type] ->Fill (tracks[i]->normalizedChi2() );
2532  if ( ! isRunCentrally_ ) h2_Chi2VsEta_[0] ->Fill( mcEta_, tracks[i]->normalizedChi2() );
2533  if ( ! isRunCentrally_ ) h2_Chi2VsR_[0] ->Fill( mcConvR_, tracks[i]->normalizedChi2() );
2534  p_Chi2VsEta_[0] ->Fill( mcEta_, tracks[i]->normalizedChi2() );
2535  p_Chi2VsR_[0] ->Fill( mcConvR_, tracks[i]->normalizedChi2() );
2536 
2537 
2538  float simPt = sqrt( ((*itAss).second)->momentum().perp2() );
2539  // float recPt = sqrt( aConv->tracks()[i]->innerMomentum().Perp2() ) ;
2540  float refPt=-9999.;
2541  float px=0, py=0;
2542 
2543  if ( aConv->conversionVertex().isValid() ) {
2544  reco::Track refTrack= aConv->conversionVertex().refittedTracks()[i];
2545  px= refTrack.momentum().x() ;
2546  py= refTrack.momentum().y() ;
2547  refPt=sqrt (px*px + py*py );
2548 
2549  float ptres= refPt - simPt ;
2550  // float pterror = aConv->tracks()[i]->ptError();
2551  float pterror = aConv->conversionVertex().refittedTracks()[i].ptError();
2552  if ( ! isRunCentrally_ ) {
2553  h2_PtRecVsPtSim_[0]->Fill ( simPt, refPt);
2554  if ( trkProvenance ==3 ) h2_PtRecVsPtSimMixProv_->Fill ( simPt, refPt);
2555  }
2556 
2557  h_TkPtPull_[0] ->Fill(ptres/pterror);
2558  if ( ! isRunCentrally_ ) h2_TkPtPull_[0] ->Fill(mcEta_, ptres/pterror);
2559 
2560  h_TkD0_[0]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
2561 
2562 
2563  if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[0]->Fill ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2()) );
2564 
2565  if ( phoIsInBarrel ) {
2566  h_TkD0_[1]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
2567  h_TkPtPull_[1] ->Fill(ptres/pterror);
2568  if ( ! isRunCentrally_ ) h2_PtRecVsPtSim_[1]->Fill ( simPt, refPt);
2569  if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[1]->Fill ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2()) );
2570 
2571  }
2572  if ( phoIsInEndcap ) {
2573  h_TkD0_[2]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
2574  h_TkPtPull_[2] ->Fill(ptres/pterror);
2575  if ( ! isRunCentrally_ ) h2_PtRecVsPtSim_[2]->Fill ( simPt, refPt);
2576  if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[2]->Fill ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2()) );
2577  }
2578 
2579  }
2580 
2581  } // end loop over track
2582  } // end analysis of two associated tracks
2583  } // end analysis of two tracks
2584 
2585  } // loop over conversions
2586  } // if !fastSim
2587  } // End loop over generated particles
2588  } // End loop over simulated Photons
2589 
2590 
2591 
2592 
2593  h_nSimPho_[0]->Fill(float(nSimPho_[0]));
2594  h_nSimPho_[1]->Fill(float(nSimPho_[1]));
2595  h_nSimConv_[0]->Fill(float(nSimConv_[0]));
2596  h_nSimConv_[1]->Fill(float(nSimConv_[1]));
2597 
2598 
2599  if ( !fastSim_) {
2601  for( reco::PhotonCollection::const_iterator iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
2602  reco::Photon aPho = reco::Photon(*iPho);
2603  // float et= aPho.superCluster()->energy()/cosh( aPho.superCluster()->eta()) ;
2605  for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
2606  reco::ConversionRef aConv=conversions[iConv];
2607  double like = aConv->MVAout();
2608  if ( like < likelihoodCut_ ) continue;
2609  //std::vector<reco::TrackRef> tracks = aConv->tracks();
2610  const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
2611  if (tracks.size() < 2 ) continue;
2612 
2613  RefToBase<reco::Track> tk1 = aConv->tracks().front();
2614  RefToBase<reco::Track> tk2 = aConv->tracks().back();
2616  tc1.push_back(tk1);
2617  tc2.push_back(tk2);
2618 
2619  bool phoIsInBarrel=false;
2620  bool phoIsInEndcap=false;
2621  if ( fabs(aConv->caloCluster()[0]->eta() ) < 1.479 ) {
2622  phoIsInBarrel=true;
2623  } else {
2624  phoIsInEndcap=true;
2625  }
2626 
2627 
2628  if ( dCotCutOn_ ) {
2629  if ( ( fabs(mcEta_) > 1.1 && fabs (mcEta_) < 1.4 ) &&
2630  fabs( aConv->pairCotThetaSeparation() ) > dCotHardCutValue_ ) continue;
2631  if ( fabs( aConv->pairCotThetaSeparation() ) > dCotCutValue_ ) continue;
2632  }
2633 
2634 
2635  h_RecoConvTwoTracks_[0]->Fill( aPho.eta() ) ;
2636  h_RecoConvTwoTracks_[1]->Fill( aPho.phi() );
2637  if ( aConv->conversionVertex().isValid() ) h_RecoConvTwoTracks_[2]->Fill( aConv->conversionVertex().position().perp2() );
2638  h_RecoConvTwoTracks_[3]->Fill( aConv->conversionVertex().position().z() );
2639  h_RecoConvTwoTracks_[4]->Fill( aPho.et() ) ;
2640 
2641 
2642 
2643  int nAssT2=0;
2644  for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
2645  // mcConvPt_= (*mcPho).fourMomentum().et();
2646  float mcPhi= (*mcPho).fourMomentum().phi();
2647  //simPV_Z = (*mcPho).primaryVertex().z();
2648  mcPhi_= phiNormalization(mcPhi);
2649  mcEta_= (*mcPho).fourMomentum().pseudoRapidity();
2650  mcEta_ = etaTransformation(mcEta_, (*mcPho).primaryVertex().z() );
2651  //mcConvR_= (*mcPho).vertex().perp();
2652  //mcConvX_= (*mcPho).vertex().x();
2653  //mcConvY_= (*mcPho).vertex().y();
2654  //mcConvZ_= (*mcPho).vertex().z();
2655  //mcConvEta_= (*mcPho).vertex().eta();
2656  //mcConvPhi_= (*mcPho).vertex().phi();
2657  if ( fabs(mcEta_) > END_HI ) continue;
2658  // if (mcConvPt_<minPhoPtForPurity) continue;
2659  //if (fabs(mcEta_)>maxPhoEtaForPurity) continue;
2660  //if (fabs(mcConvZ_)>maxPhoZForPurity) continue;
2661  //if (mcConvR_>maxPhoRForEffic) continue;
2662 
2663  if ( (*mcPho).isAConversion() != 1 ) continue;
2664  if (!( ( fabs(mcEta_) <= BARL && mcConvR_ <85 ) ||
2665  ( fabs(mcEta_) > BARL && fabs(mcEta_) <=END_HI && fabs( (*mcPho).vertex().z() ) < 210 ) ) )
2666  continue;
2667 
2668 
2669  theConvTP_.clear();
2670  for(size_t i = 0; i < trackingParticles.size(); ++i){
2671  TrackingParticleRef tp (ElectronTPHandle,i);
2672  if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.0001 &&
2673  fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.0001 &&
2674  fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.0001) {
2675  theConvTP_.push_back( tp );
2676  }
2677  }
2678 
2679  //std::cout << " ciao 5.3 " << std::endl;
2680  if ( theConvTP_.size() < 2 ) continue;
2681 
2682  reco::RecoToSimCollection p1 = theTrackAssociator_->associateRecoToSim(tc1,theConvTP_,&e);
2683  reco::RecoToSimCollection p2 = theTrackAssociator_->associateRecoToSim(tc2,theConvTP_,&e);
2684  std::vector<std::pair<RefToBase<reco::Track>, double> > trackV1, trackV2;
2685  try {
2686  std::vector<std::pair<TrackingParticleRef, double> > tp1 = p1[tk1];
2687  std::vector<std::pair<TrackingParticleRef, double> > tp2 = p2[tk2];
2688 
2689  if (tp1.size()&&tp2.size()) {
2690  TrackingParticleRef tpr1 = tp1.front().first;
2691  TrackingParticleRef tpr2 = tp2.front().first;
2692 
2693  if (abs(tpr1->pdgId())==11&&abs(tpr2->pdgId())==11) {
2694  if ( (tpr1->parentVertex()->sourceTracks_end()-tpr1->parentVertex()->sourceTracks_begin()==1) &&
2695  (tpr2->parentVertex()->sourceTracks_end()-tpr2->parentVertex()->sourceTracks_begin()==1)) {
2696  if (tpr1->parentVertex().key()==tpr2->parentVertex().key() && ((*tpr1->parentVertex()->sourceTracks_begin())->pdgId()==22)) {
2697  // std::cout << " ciao 5.6 " << std::endl;
2698  // mcConvR_ = sqrt(tpr1->parentVertex()->position().Perp2());
2699  //mcConvZ_ = tpr1->parentVertex()->position().z();
2700  //mcConvX_ = tpr1->parentVertex()->position().x();
2701  //mcConvY_ = tpr1->parentVertex()->position().y();
2702  //mcConvEta_ = tpr1->parentVertex()->position().eta();
2703  //mcConvPhi_ = tpr1->parentVertex()->position().phi();
2704  //mcConvPt_ = sqrt((*tpr1->parentVertex()->sourceTracks_begin())->momentum().Perp2());
2705  //std::cout << " Reco to Sim mcconvpt " << mcConvPt_ << std::endl;
2706  //cout << "associated track1 to " << tpr1->pdgId() << " with p=" << tpr1->p4() << " with pT=" << tpr1->pt() << endl;
2707  //cout << "associated track2 to " << tpr2->pdgId() << " with p=" << tpr2->p4() << " with pT=" << tpr2->pt() << endl;
2708  nAssT2 = 2;
2709  break;
2710  }
2711  }
2712  }
2713  }
2714 
2715  } catch (Exception event) {
2716  //cout << "do not continue: " << event.what() << endl;
2717  //continue;
2718  }
2719 
2720  } // end loop over simulated photons
2721 
2722 
2723 
2724  /*
2725  TrackingParticleRef myTP;
2726  for (size_t j = 0; j < RtoSCollPtrs.size(); j++) {
2727  reco::RecoToSimCollection q = *(RtoSCollPtrs[j]);
2728 
2729  RefToBase<reco::Track> myTk( track );
2730 
2731  if( q.find(myTk ) != q.end() ) {
2732  std::vector<std::pair<TrackingParticleRef, double> > tp = q[myTk];
2733  for (unsigned int itp=0; itp<tp.size(); itp++) {
2734  myTP=tp[itp].first;
2735  // std::cout << " associated with TP " << myTP->pdgId() << " pt " << sqrt(myTP->momentum().perp2()) << std::endl;
2736  myAss.insert( std::make_pair ( track , myTP) );
2737  nAssT2++;
2738  }
2739  }
2740  }
2741  */
2742 
2743  if ( nAssT2 == 2) {
2744 
2745 
2746  h_RecoConvTwoMTracks_[0]->Fill( aPho.eta() ) ;
2747  h_RecoConvTwoMTracks_[1]->Fill( aPho.phi() );
2748  if ( aConv->conversionVertex().isValid() ) h_RecoConvTwoMTracks_[2]->Fill( aConv->conversionVertex().position().perp2() );
2749  h_RecoConvTwoMTracks_[3]->Fill( aConv->conversionVertex().position().z() );
2750  h_RecoConvTwoMTracks_[4]->Fill( aPho.et() ) ;
2751 
2752  }
2753 
2754 
2756  if ( aConv->conversionVertex().isValid() ) {
2757  float chi2Prob = ChiSquaredProbability( aConv->conversionVertex().chi2(), aConv->conversionVertex().ndof() );
2758 
2759  double convR= sqrt(aConv->conversionVertex().position().perp2());
2760  double scalar = aConv->conversionVertex().position().x()*aConv->pairMomentum().x() +
2761  aConv->conversionVertex().position().y()*aConv->pairMomentum().y();
2762  if ( scalar < 0 ) convR= -sqrt(aConv->conversionVertex().position().perp2());
2763 
2764  if ( ! isRunCentrally_ ) h2_etaVsRreco_[0]->Fill (aConv->caloCluster()[0]->eta(),sqrt(aConv->conversionVertex().position().perp2()) );
2765  h_convVtxRvsZ_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ), sqrt(aConv->conversionVertex().position().perp2()) ) ;
2766  if ( fabs(aConv->caloCluster()[0]->eta() ) <= 1.) {
2767 
2768  h_convVtxYvsX_ ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x() ) ;
2769  h_convVtxRvsZ_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ), convR ) ;
2770 
2771  if ( ! isRunCentrally_ ) {
2772  h_convVtxYvsX_zoom_[0] ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x() ) ;
2773  h_convVtxYvsX_zoom_[1] ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x() ) ;
2774  h_convVtxRvsZ_zoom_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ), convR ) ;
2775  h_convVtxRvsZ_zoom_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ), convR ) ;
2776  }
2777 
2778  }
2779  if ( fabs(aConv->caloCluster()[0]->eta() ) > 1.) h_convVtxRvsZ_[2] ->Fill ( fabs (aConv->conversionVertex().position().z() ), convR ) ;
2780 
2781 
2782 
2783 
2784  h_vtxChi2Prob_[0]->Fill( chi2Prob );
2785  h_vtxChi2_[0]->Fill( aConv->conversionVertex().normalizedChi2() );
2786  if ( phoIsInBarrel ) {
2787  h_vtxChi2Prob_[1]->Fill( chi2Prob );
2788  h_vtxChi2_[1]->Fill( aConv->conversionVertex().normalizedChi2() );
2789  }
2790  if ( phoIsInEndcap ) {
2791  h_vtxChi2Prob_[2]->Fill( chi2Prob );
2792  h_vtxChi2_[2]->Fill( aConv->conversionVertex().normalizedChi2() );
2793  }
2794 
2795  } // end conversion vertex valid
2796  } // end loop over reco conversions
2797  } // end loop on all reco photons
2798  } // if !fastSim
2799 
2800 
2801 
2803  float nPho=0;
2804  for (reco::GenJetCollection::const_iterator genJetIter = genJetCollection.begin();
2805  genJetIter != genJetCollection.end(); ++genJetIter) {
2806 
2807  if ( genJetIter->pt() < minPhoEtCut_ ) continue;
2808  if ( fabs(genJetIter->eta()) > 2.5 ) continue;
2809 
2810  float mcJetPhi= genJetIter->phi();
2811  mcJetPhi_= phiNormalization(mcJetPhi);
2812  mcJetEta_= genJetIter->eta();
2813  float mcJetPt = genJetIter->pt() ;
2814 
2815  h_SimJet_[0]->Fill ( mcJetEta_);
2816  h_SimJet_[1]->Fill ( mcJetPhi_);
2817  h_SimJet_[2]->Fill ( mcJetPt );
2818 
2819  std::vector<reco::Photon> thePhotons;
2820  bool matched=false;
2821 
2822  reco::Photon matchingPho;
2823  for( reco::PhotonCollection::const_iterator iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
2824  reco::Photon aPho = reco::Photon(*iPho);
2825  float phiPho=aPho.phi();
2826  float etaPho=aPho.eta();
2827  float deltaPhi = phiPho-mcJetPhi_;
2828  float deltaEta = etaPho-mcJetEta_;
2829  if ( deltaPhi > pi ) deltaPhi -= twopi;
2830  if ( deltaPhi < -pi) deltaPhi += twopi;
2831  deltaPhi=pow(deltaPhi,2);
2832  deltaEta=pow(deltaEta,2);
2833  float delta = sqrt( deltaPhi+deltaEta);
2834  if ( delta<0.3 ) {
2835  matchingPho = * iPho;
2836  matched = true;
2837  }
2838  } // end loop over reco photons
2839 
2840  if (! matched ) continue;
2841  nPho++;
2842 
2843  h_MatchedSimJet_[0]->Fill( mcJetEta_ ) ;
2844  h_MatchedSimJet_[1]->Fill( mcJetPhi_ );
2845  h_MatchedSimJet_[2]->Fill( mcJetPt );
2846 
2847 
2848  bool phoIsInBarrel=false;
2849  bool phoIsInEndcap=false;
2850  if ( fabs(matchingPho.superCluster()->position().eta() ) < 1.479 ) {
2851  phoIsInBarrel=true;
2852  } else {
2853  phoIsInEndcap=true;
2854  }
2855  edm::Handle<EcalRecHitCollection> ecalRecHitHandle;
2856  if ( phoIsInBarrel ) {
2857  // Get handle to rec hits ecal barrel
2858  e.getByLabel(barrelEcalHits_, ecalRecHitHandle);
2859  if (!ecalRecHitHandle.isValid()) {
2860  edm::LogError("PhotonProducer") << "Error! Can't get the product "<<barrelEcalHits_.label();
2861  return;
2862  }
2863 
2864  } else if ( phoIsInEndcap ) {
2865 
2866  // Get handle to rec hits ecal encap
2867  e.getByLabel(endcapEcalHits_, ecalRecHitHandle);
2868  if (!ecalRecHitHandle.isValid()) {
2869  edm::LogError("PhotonProducer") << "Error! Can't get the product "<<endcapEcalHits_.label();
2870  return;
2871  }
2872 
2873  }
2874 
2875 
2876 
2877  const EcalRecHitCollection ecalRecHitCollection = *(ecalRecHitHandle.product());
2878  float photonE = matchingPho.energy();
2879  float photonEt= matchingPho.et();
2880  float r9 = matchingPho.r9();
2881  float r1 = matchingPho.r1x5();
2882  float r2 = matchingPho.r2x5();
2883  float sigmaIetaIeta = matchingPho.sigmaIetaIeta();
2884  float hOverE = matchingPho.hadronicOverEm();
2885  float ecalIso = matchingPho.ecalRecHitSumEtConeDR04();
2886  float hcalIso = matchingPho.hcalTowerSumEtConeDR04();
2887  float trkIso = matchingPho.trkSumPtSolidConeDR04();
2888  float nIsoTrk = matchingPho.nTrkSolidConeDR04();
2889  std::vector< std::pair<DetId, float> >::const_iterator rhIt;
2890 
2891  bool atLeastOneDeadChannel=false;
2892  for(reco::CaloCluster_iterator bcIt = matchingPho.superCluster()->clustersBegin();bcIt != matchingPho.superCluster()->clustersEnd(); ++bcIt) {
2893  for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
2894 
2895  for(EcalRecHitCollection::const_iterator it = ecalRecHitCollection.begin(); it != ecalRecHitCollection.end(); ++it) {
2896  if (rhIt->first == (*it).id() ) {
2897  if ( (*it).recoFlag() == 9 ) {
2898  atLeastOneDeadChannel=true;
2899  break;
2900  }
2901  }
2902  }
2903  }
2904  }
2905 
2906  if ( atLeastOneDeadChannel ) {
2907  h_MatchedSimJetBadCh_[0]->Fill( mcJetEta_ ) ;
2908  h_MatchedSimJetBadCh_[1]->Fill( mcJetPhi_ );
2909  h_MatchedSimJetBadCh_[2]->Fill( mcJetPt );
2910 
2911  }
2912 
2913  h_scBkgEta_->Fill( matchingPho.superCluster()->eta() );
2914  h_scBkgPhi_->Fill( matchingPho.superCluster()->phi() );
2915  h_scBkgE_[0]->Fill( matchingPho.superCluster()->energy() );
2916  h_scBkgEt_[0]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
2917  //
2918  h_phoBkgEta_->Fill( matchingPho.eta() );
2919  h_phoBkgPhi_->Fill( matchingPho.phi() );
2920  h_phoBkgE_[0]->Fill( photonE );
2921  h_phoBkgEt_[0]->Fill( photonEt);
2922  h_phoBkgDEta_->Fill ( matchingPho.eta() - mcJetEta_ );
2923  h_phoBkgDPhi_->Fill ( matchingPho.phi() - mcJetPhi_ );
2924 
2925 
2926  h_r9Bkg_[0]->Fill( r9 );
2927  h_r1Bkg_[0]->Fill( r1 );
2928  h_r2Bkg_[0]->Fill( r2 );
2929  h_sigmaIetaIetaBkg_[0]->Fill( sigmaIetaIeta );
2930  h_hOverEBkg_[0]->Fill( hOverE );
2931  h_ecalRecHitSumEtConeDR04Bkg_[0]->Fill( ecalIso );
2932  h_hcalTowerSumEtConeDR04Bkg_[0]->Fill( hcalIso );
2933  h_isoTrkSolidConeDR04Bkg_[0]->Fill( trkIso );
2934  h_nTrkSolidConeDR04Bkg_[0]->Fill( nIsoTrk );
2935 
2936 
2937  h2_r9VsEtaBkg_ -> Fill (mcJetEta_, r9);
2938  h2_r9VsEtBkg_ -> Fill (mcJetPt, r9);
2939 
2940  h2_r1VsEtaBkg_ -> Fill (mcJetEta_, r1);
2941  h2_r1VsEtBkg_ -> Fill (mcJetPt, r1);
2942  p_r1VsEtaBkg_ -> Fill (mcJetEta_, r1);
2943  p_r1VsEtBkg_ -> Fill (mcJetPt, r1);
2944 
2945  h2_r2VsEtaBkg_ -> Fill (mcJetEta_, r2);
2946  h2_r2VsEtBkg_ -> Fill (mcJetPt, r2);
2947  p_r2VsEtaBkg_ -> Fill (mcJetEta_, r2);
2948  p_r2VsEtBkg_ -> Fill (mcJetPt, r2);
2949 
2950 
2951  h2_sigmaIetaIetaVsEtaBkg_ -> Fill (mcJetEta_, sigmaIetaIeta );
2952  p_sigmaIetaIetaVsEtaBkg_ -> Fill (mcJetEta_, sigmaIetaIeta );
2953  h2_sigmaIetaIetaVsEtBkg_[0] -> Fill (mcJetPt, sigmaIetaIeta);
2954  p_sigmaIetaIetaVsEtBkg_[0] -> Fill (mcJetPt, sigmaIetaIeta);
2955 
2956 
2957  h2_hOverEVsEtaBkg_ -> Fill (mcJetEta_, hOverE );
2958  h2_hOverEVsEtBkg_ -> Fill (mcJetPt, hOverE);
2959  p_hOverEVsEtaBkg_ -> Fill (mcJetEta_, hOverE );
2960  p_hOverEVsEtBkg_ -> Fill (mcJetPt, hOverE);
2961 
2962 
2963  h2_ecalRecHitSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, ecalIso );
2964  p_ecalRecHitSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, ecalIso );
2965  h2_ecalRecHitSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, ecalIso);
2966  p_ecalRecHitSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, ecalIso);
2967 
2968 
2969  h2_hcalTowerSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, hcalIso );
2970  p_hcalTowerSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, hcalIso );
2971  h2_hcalTowerSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, hcalIso);
2972  p_hcalTowerSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, hcalIso);
2973 
2974  h2_isoTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, trkIso );
2975  p_isoTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, trkIso );
2976  h2_isoTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, trkIso);
2977  p_isoTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, trkIso);
2978 
2979 
2980  h2_nTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, nIsoTrk );
2981  p_nTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, nIsoTrk );
2982  h2_nTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, nIsoTrk);
2983  p_nTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, nIsoTrk);
2984 
2985 
2986 
2987 
2988  if ( phoIsInBarrel ) {
2989 
2990  h_r9Bkg_[1]->Fill( r9 );
2991  h_r1Bkg_[1]->Fill( r1 );
2992  h_r2Bkg_[1]->Fill( r2 );
2993 
2994 
2995  h_sigmaIetaIetaBkg_[1]->Fill( sigmaIetaIeta );
2996  h_hOverEBkg_[1]->Fill( hOverE );
2997  h_ecalRecHitSumEtConeDR04Bkg_[1]->Fill( ecalIso );
2998  h_hcalTowerSumEtConeDR04Bkg_[1]->Fill( hcalIso );
2999  h_isoTrkSolidConeDR04Bkg_[1]->Fill( trkIso );
3000  h_nTrkSolidConeDR04Bkg_[1]->Fill( nIsoTrk );
3001 
3002  h2_sigmaIetaIetaVsEtBkg_[1] -> Fill (mcJetPt, sigmaIetaIeta);
3003  p_sigmaIetaIetaVsEtBkg_[1] -> Fill (mcJetPt, sigmaIetaIeta);
3004 
3005  h2_ecalRecHitSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, ecalIso);
3006  p_ecalRecHitSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, ecalIso);
3007 
3008  h2_hcalTowerSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, hcalIso);
3009  p_hcalTowerSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, hcalIso);
3010 
3011  h2_isoTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, trkIso);
3012  p_isoTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, trkIso);
3013 
3014  h2_nTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, nIsoTrk);
3015  p_nTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, nIsoTrk);
3016 
3017 
3018  } else if ( phoIsInEndcap ) {
3019 
3020  h_r9Bkg_[2]->Fill( r9 );
3021  h_r1Bkg_[2]->Fill( r1 );
3022  h_r2Bkg_[2]->Fill( r2 );
3023 
3024  h_sigmaIetaIetaBkg_[2]->Fill( sigmaIetaIeta );
3025  h_hOverEBkg_[2]->Fill( hOverE );
3026  h_ecalRecHitSumEtConeDR04Bkg_[2]->Fill( ecalIso );
3027  h_hcalTowerSumEtConeDR04Bkg_[2]->Fill( hcalIso );
3028  h_isoTrkSolidConeDR04Bkg_[2]->Fill( trkIso );
3029  h_nTrkSolidConeDR04Bkg_[2]->Fill( nIsoTrk );
3030 
3031  h2_sigmaIetaIetaVsEtBkg_[2] -> Fill (mcJetPt, sigmaIetaIeta);
3032  p_sigmaIetaIetaVsEtBkg_[2] -> Fill (mcJetPt, sigmaIetaIeta);
3033 
3034  h2_ecalRecHitSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, ecalIso);
3035  p_ecalRecHitSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, ecalIso);
3036 
3037  h2_hcalTowerSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, hcalIso);
3038  p_hcalTowerSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, hcalIso);
3039 
3040  h2_isoTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, trkIso);
3041  p_isoTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, trkIso);
3042 
3043  h2_nTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, nIsoTrk);
3044  p_nTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, nIsoTrk);
3045 
3046 
3047  }
3048 
3049  if ( !fastSim_) {
3052  for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
3053  reco::ConversionRef aConv=conversions[iConv];
3054  //std::vector<reco::TrackRef> tracks = aConv->tracks();
3055  const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
3056  double like = aConv->MVAout();
3057  if ( like < likelihoodCut_ ) continue;
3058  if ( tracks.size() < 2 ) continue;
3059  h_convEtaBkg_->Fill( aConv->caloCluster()[0]->eta() );
3060  h_convPhiBkg_->Fill( aConv->caloCluster()[0]->phi() );
3061  h_mvaOutBkg_[0]-> Fill(like);
3062  float eoverp= aConv->EoverP();
3063  h_EoverPTracksBkg_[0] ->Fill( eoverp ) ;
3064  h_PoverETracksBkg_[0] ->Fill( 1./eoverp ) ;
3065  h_DCotTracksBkg_[0] ->Fill ( aConv->pairCotThetaSeparation() );
3066  float dPhiTracksAtVtx = aConv->dPhiTracksAtVtx();
3067  h_DPhiTracksAtVtxBkg_[0]->Fill( dPhiTracksAtVtx);
3068 
3069  if ( phoIsInBarrel ) {
3070  h_mvaOutBkg_[1]-> Fill(like);
3071  h_EoverPTracksBkg_[1] ->Fill( eoverp ) ;
3072  h_PoverETracksBkg_[1] ->Fill( 1./eoverp ) ;
3073  h_DCotTracksBkg_[1] ->Fill ( aConv->pairCotThetaSeparation() );
3074  h_DPhiTracksAtVtxBkg_[1]->Fill( dPhiTracksAtVtx);
3075  } else if ( phoIsInEndcap ) {
3076  h_mvaOutBkg_[2]-> Fill(like);
3077  h_EoverPTracksBkg_[2] ->Fill( eoverp ) ;
3078  h_PoverETracksBkg_[2] ->Fill( 1./eoverp ) ;
3079  h_DCotTracksBkg_[2] ->Fill ( aConv->pairCotThetaSeparation() );
3080  h_DPhiTracksAtVtxBkg_[2]->Fill( dPhiTracksAtVtx);
3081  }
3082 
3083  if ( aConv->conversionVertex().isValid() ) {
3084 
3085  double convR= sqrt(aConv->conversionVertex().position().perp2());
3086  double scalar = aConv->conversionVertex().position().x()*aConv->pairMomentum().x() +
3087  aConv->conversionVertex().position().y()*aConv->pairMomentum().y();
3088  if ( scalar < 0 ) convR= -sqrt(aConv->conversionVertex().position().perp2());
3089 
3090  if ( ! isRunCentrally_ ) {
3091  h_convVtxRvsZBkg_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ), sqrt(aConv->conversionVertex().position().perp2()) ) ;
3092  if ( fabs(aConv->caloCluster()[0]->eta() ) <= 1.) {
3093  h_convVtxYvsXBkg_ ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x() ) ;
3094  h_convVtxRvsZBkg_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ), convR ) ;
3095  }
3096  }
3097 
3098 
3099  } // end vertex valid
3100 
3101 
3102  } // end loop over conversions
3103  } // if !fastSim
3104  } // end loop over sim jets
3105 
3106  h_nPho_->Fill(float(nPho));
3107 
3108 }
3109 
3110 
3111 
3112 
3113 
3115 
3116 
3117  std::string outputFileName = parameters_.getParameter<std::string>("OutputFileName");
3118  if ( ! isRunCentrally_ ) {
3119  dbe_->save(outputFileName);
3120  }
3121 
3122  edm::LogInfo("PhotonValidator") << "Analyzed " << nEvt_ << "\n";
3123  // std::cout << "::endJob Analyzed " << nEvt_ << " events " << " with total " << nPho_ << " Photons " << "\n";
3124  // std::cout << "PhotonValidator::endJob Analyzed " << nEvt_ << " events " << "\n";
3125 
3126  return ;
3127 }
3128 
3130 {
3131  //---Definitions
3132  const float PI = 3.1415927;
3133  const float TWOPI = 2.0*PI;
3134 
3135 
3136  if(phi > PI) {phi = phi - TWOPI;}
3137  if(phi < -PI) {phi = phi + TWOPI;}
3138 
3139  // cout << " Float_t PHInormalization out " << PHI << endl;
3140  return phi;
3141 
3142 }
3143 
3144 
3145 float PhotonValidator::etaTransformation( float EtaParticle , float Zvertex) {
3146 
3147  //---Definitions
3148  const float PI = 3.1415927;
3149 
3150  //---Definitions for ECAL
3151  const float R_ECAL = 136.5;
3152  const float Z_Endcap = 328.0;
3153  const float etaBarrelEndcap = 1.479;
3154 
3155  //---ETA correction
3156 
3157  float Theta = 0.0 ;
3158  float ZEcal = R_ECAL*sinh(EtaParticle)+Zvertex;
3159 
3160  if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
3161  if(Theta<0.0) Theta = Theta+PI ;
3162  float ETA = - log(tan(0.5*Theta));
3163 
3164  if( fabs(ETA) > etaBarrelEndcap )
3165  {
3166  float Zend = Z_Endcap ;
3167  if(EtaParticle<0.0 ) Zend = -Zend ;
3168  float Zlen = Zend - Zvertex ;
3169  float RR = Zlen/sinh(EtaParticle);
3170  Theta = atan(RR/Zend);
3171  if(Theta<0.0) Theta = Theta+PI ;
3172  ETA = - log(tan(0.5*Theta));
3173  }
3174  //---Return the result
3175  return ETA;
3176  //---end
3177 }
3178 
3179 
dbl * delta
Definition: mlp_gen.cc:36
type
Definition: HCALResponse.h:22
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
float hcalTowerSumEtConeDR04() const
Hcal isolation sum.
Definition: Photon.h:246
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
virtual void analyze(const edm::Event &, const edm::EventSetup &)
TPRegexp parents
Definition: eve_filter.cc:24
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:150
virtual ~PhotonValidator()
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
Definition: Photon.h:57
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:514
#define PI
virtual double et() const
transverse energy
const_iterator end() const
last iterator over the map (read only)
tuple d0
Definition: debug_cff.py:3
double deltaPhi(float phi1, float phi2)
Definition: VectorUtil.h:30
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:1898
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
float trkSumPtSolidConeDR04() const
Definition: Photon.h:252
std::vector< GenJet > GenJetCollection
collection of GenJet objects
const_iterator find(const key_type &k) const
find element with specified reference key
std::vector< T >::const_iterator const_iterator
#define abs(x)
Definition: mlp_lapack.h:159
#define TWOPI
EgammaCoreTools.
float ecalRecHitSumEtConeDR04() const
Definition: Photon.h:244
virtual void beginRun(edm::Run const &r, edm::EventSetup const &theEventSetup)
double charge(const std::vector< uint8_t > &Ampls)
virtual double eta() const
momentum pseudorapidity
return((rh^lh)&mask)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:249
virtual double energy() const
energy
virtual void beginJob()
#define ETA
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
reco::ConversionRefVector conversions() const
vector of references to Conversion&#39;s
Definition: Photon.h:61
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
float phiNormalization(float &a)
T sqrt(T t)
Definition: SSEVec.h:28
float sigmaIetaIeta() const
Definition: Photon.h:168
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
float ChiSquaredProbability(double chiSquared, double nrDOF)
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:828
virtual void endJob()
float hadronicOverEm() const
the total hadronic over electromagnetic fraction
Definition: Photon.h:155
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:76
double p2[4]
Definition: TauolaWrapper.h:90
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
float r1x5() const
Definition: Photon.h:169
DQMStore * dbe_
bool etMin(const PFCandidate &cand, double cut)
const_iterator end() const
Log< T >::type log(const T &t)
Definition: Log.h:22
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:55
key_type key() const
Accessor for product key.
Definition: Ref.h:265
T const * product() const
Definition: ESHandle.h:62
int nTrkSolidConeDR04() const
Definition: Photon.h:256
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
static const float etaBarrelEndcap
T const * product() const
Definition: Handle.h:74
float etaTransformation(float a, float b)
static const float Z_Endcap
float r2x5() const
Definition: Photon.h:170
edm::EventID id() const
Definition: EventBase.h:56
double p1[4]
Definition: TauolaWrapper.h:89
float r9() const
Definition: Photon.h:171
void push_back(const RefToBase< T > &)
static const float R_ECAL
size_type size() const
Size of the RefVector.
Definition: RefVector.h:84
tuple cout
Definition: gather_cfg.py:41
std::vector< TrackingParticle > TrackingParticleCollection
double pi
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:642
virtual double phi() const
momentum azimuthal angle
value_type const * get() const
Definition: RefToBase.h:212
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232
const_iterator begin() const
Definition: Run.h:32
virtual void endRun(edm::Run &r, edm::EventSetup const &es)
PhotonValidator(const edm::ParameterSet &)
Definition: DDAxes.h:10