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  h_zPVFromTracks_[1] = dbe_->book1D("zPVFromTracks"," Photons: PV z from conversion tracks",100, -25., 25.);
1165  h_dzPVFromTracks_[1] = dbe_->book1D("dzPVFromTracks"," Photons: PV Z_rec - Z_true from conversion tracks",100, -5., 5.);
1166  p_dzPVVsR_ = dbe_->bookProfile("pdzPVVsR","Photon Reco conversions: dz(PV) vs R" ,rBin,rMin, rMax, 100, -3.,3.,"");
1167 
1168  if ( ! isRunCentrally_ ) {
1169  h2_dzPVVsR_ = dbe_->book2D("h2dzPVVsR","Photon Reco conversions: dz(PV) vs R" ,rBin,rMin, rMax,100, -3.,3.);
1170  }
1171 
1173  if ( ! isRunCentrally_ ) {
1174  histname="nHitsVsEta";
1175  nHitsVsEta_[0] = dbe_->book2D(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs #eta all tracks",etaBin,etaMin, etaMax,25,0., 25.);
1176 
1177  histname="nHitsVsEta";
1178  nHitsVsEta_[1] = dbe_->book2D(histname+"AssTracks","Photons:Tracks from conversions: # of hits vs #eta associated tracks",etaBin,etaMin, etaMax,25,0., 25.);
1179 
1180  histname="nHitsVsR";
1181  nHitsVsR_[0] = dbe_->book2D(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs radius all tracks" ,rBin,rMin, rMax,25,0.,25);
1182 
1183  histname="nHitsVsR";
1184  nHitsVsR_[1] = dbe_->book2D(histname+"AssTracks","Photons:Tracks from conversions: # of hits vs radius associated tracks" ,rBin,rMin, rMax,25,0.,25);
1185 
1186  histname="h2Chi2VsEta";
1187  h2_Chi2VsEta_[0]=dbe_->book2D(histname+"All"," Reco Track #chi^{2} vs #eta: All ",etaBin2,etaMin, etaMax,100, chi2Min, chi2Max);
1188 
1189 
1190  histname="h2Chi2VsR";
1191  h2_Chi2VsR_[0]=dbe_->book2D(histname+"All"," Reco Track #chi^{2} vs R: All ",rBin,rMin, rMax,100,chi2Min, chi2Max);
1192  }
1193 
1194  histname="h_nHitsVsEta";
1195  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,"");
1196 
1197  histname="h_nHitsVsEta";
1198  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,"");
1199 
1200 
1201  histname="h_nHitsVsR";
1202  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,"");
1203  histname="tkChi2";
1204  h_tkChi2_[0] = dbe_->book1D(histname+"AllTracks","Photons:Tracks from conversions: #chi^{2} of all tracks", 100, chi2Min, chi2Max);
1205  histname="tkChi2Large";
1206  h_tkChi2Large_[0] = dbe_->book1D(histname+"AllTracks","Photons:Tracks from conversions: #chi^{2} of all tracks", 1000, 0., 5000.0);
1207 
1208  histname="h_nHitsVsR";
1209  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,"");
1210 
1211  histname="tkChi2";
1212  h_tkChi2_[1] = dbe_->book1D(histname+"AssTracks","Photons:Tracks from conversions: #chi^{2} of associated tracks", 100, chi2Min, chi2Max);
1213  histname="tkChi2Large";
1214  h_tkChi2Large_[1] = dbe_->book1D(histname+"AssTracks","Photons:Tracks from conversions: #chi^{2} of associated tracks", 1000, 0., 5000.0);
1215 
1216  histname="pChi2VsEta";
1217  p_Chi2VsEta_[0]=dbe_->bookProfile(histname+"All"," Reco Track #chi^{2} vs #eta : All ",etaBin2,etaMin, etaMax, 100, chi2Min, chi2Max,"");
1218 
1219  histname="pChi2VsR";
1220  p_Chi2VsR_[0]=dbe_->bookProfile(histname+"All"," Reco Track #chi^{2} vas R : All ",rBin,rMin,rMax, 100,chi2Min, chi2Max,"");
1221 
1222 
1223  histname="hTkD0";
1224  h_TkD0_[0]=dbe_->book1D(histname+"All"," Reco Track D0*q: All ",100,-0.1,0.6);
1225  h_TkD0_[1]=dbe_->book1D(histname+"Barrel"," Reco Track D0*q: Barrel ",100,-0.1,0.6);
1226  h_TkD0_[2]=dbe_->book1D(histname+"Endcap"," Reco Track D0*q: Endcap ",100,-0.1,0.6);
1227 
1228 
1229  histname="hTkPtPull";
1230  h_TkPtPull_[0]=dbe_->book1D(histname+"All"," Reco Track Pt pull: All ",100, -10., 10.);
1231  histname="hTkPtPull";
1232  h_TkPtPull_[1]=dbe_->book1D(histname+"Barrel"," Reco Track Pt pull: Barrel ",100, -10., 10.);
1233  histname="hTkPtPull";
1234  h_TkPtPull_[2]=dbe_->book1D(histname+"Endcap"," Reco Track Pt pull: Endcap ",100, -10., 10.);
1235 
1236  histname="pTkPtPullEta";
1237  p_TkPtPull_[0]=dbe_->bookProfile(histname+"All"," Reco Track Pt pull: All ",etaBin2,etaMin, etaMax, 100, -10., 10., " ");
1238 
1239  if ( ! isRunCentrally_ ) {
1240  histname="h2TkPtPullEta";
1241  h2_TkPtPull_[0]=dbe_->book2D(histname+"All"," Reco Track Pt pull: All ",etaBin2,etaMin, etaMax,100, -10., 10.);
1242 
1243  histname="PtRecVsPtSim";
1244  h2_PtRecVsPtSim_[0]=dbe_->book2D(histname+"All", "Pt Rec vs Pt sim: All ", etBin,etMin,etMax,etBin,etMin, etMax);
1245  h2_PtRecVsPtSim_[1]=dbe_->book2D(histname+"Barrel", "Pt Rec vs Pt sim: Barrel ", etBin,etMin,etMax,etBin,etMin, etMax);
1246  h2_PtRecVsPtSim_[2]=dbe_->book2D(histname+"Endcap", "Pt Rec vs Pt sim: Endcap ", etBin,etMin,etMax,etBin,etMin, etMax);
1247  histname="PtRecVsPtSimMixProv";
1248  h2_PtRecVsPtSimMixProv_ =dbe_->book2D(histname+"All", "Pt Rec vs Pt sim All for mix with general tracks ", etBin,etMin,etMax,etBin,etMin, etMax);
1249  }
1250 
1251 
1252  histname="eBcOverTkPout";
1253  hBCEnergyOverTrackPout_[0] = dbe_->book1D(histname+"All","Matrching BC E/P_out: all Ecal ",100, 0., 5.);
1254  hBCEnergyOverTrackPout_[1] = dbe_->book1D(histname+"Barrel","Matrching BC E/P_out: Barrel ",100, 0., 5.);
1255  hBCEnergyOverTrackPout_[2] = dbe_->book1D(histname+"Endcap","Matrching BC E/P_out: Endcap ",100, 0., 5.);
1256 
1257 
1259  h_OIinnermostHitR_ = dbe_->book1D("OIinnermostHitR"," R innermost hit for OI tracks ",50, 0., 25);
1260  h_IOinnermostHitR_ = dbe_->book1D("IOinnermostHitR"," R innermost hit for IO tracks ",50, 0., 25);
1261 
1263  h_trkProv_[0] = dbe_->book1D("allTrkProv"," Track pair provenance ",4, 0., 4.);
1264  h_trkProv_[1] = dbe_->book1D("assTrkProv"," Track pair provenance ",4, 0., 4.);
1265 
1266  // histos for fake rate
1267  histname = "h_RecoConvTwoTracksEta";
1268  h_RecoConvTwoTracks_[0] = dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated #eta",etaBin2,etaMin, etaMax);
1269  histname = "h_RecoConvTwoTracksPhi";
1270  h_RecoConvTwoTracks_[1] = dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated #phi",phiBin,phiMin, phiMax);
1271  histname = "h_RecoConvTwoTracksR";
1272  h_RecoConvTwoTracks_[2] = dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated R",rBin,rMin, rMax);
1273  histname = "h_RecoConvTwoTracksZ";
1274  h_RecoConvTwoTracks_[3] = dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated Z",zBin,zMin, zMax);
1275  histname = "h_RecoConvTwoTracksEt";
1276  h_RecoConvTwoTracks_[4] = dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated Et",etBin,etMin, etMax);
1277  //
1278  histname = "h_RecoConvTwoMTracksEta";
1279  h_RecoConvTwoMTracks_[0] = dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated #eta",etaBin2,etaMin, etaMax);
1280  histname = "h_RecoConvTwoMTracksPhi";
1281  h_RecoConvTwoMTracks_[1] = dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated #phi",phiBin,phiMin, phiMax);
1282  histname = "h_RecoConvTwoMTracksR";
1283  h_RecoConvTwoMTracks_[2] = dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated R",rBin,rMin, rMax);
1284  histname = "h_RecoConvTwoMTracksZ";
1285  h_RecoConvTwoMTracks_[3] = dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated Z",zBin,zMin, zMax);
1286  histname = "h_RecoConvTwoMTracksEt";
1287  h_RecoConvTwoMTracks_[4] = dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated Et",etBin,etMin, etMax);
1288 
1289 
1290 
1291 
1292  } // if DQM
1293 
1294 
1295 
1296 }
1297 
1298 
1299 
1300  void PhotonValidator::beginRun (edm::Run const & r, edm::EventSetup const & theEventSetup) {
1301 
1302  //get magnetic field
1303  edm::LogInfo("ConvertedPhotonProducer") << " get magnetic field" << "\n";
1304  theEventSetup.get<IdealMagneticFieldRecord>().get(theMF_);
1305 
1306 
1307  edm::ESHandle<TrackAssociatorBase> theHitsAssociator;
1308  theEventSetup.get<TrackAssociatorRecord>().get("TrackAssociatorByHits",theHitsAssociator);
1309  theTrackAssociator_ = (TrackAssociatorBase *) theHitsAssociator.product();
1310 
1311  thePhotonMCTruthFinder_ = new PhotonMCTruthFinder();
1312 
1313 }
1314 
1315 void PhotonValidator::endRun (edm::Run& r, edm::EventSetup const & theEventSetup) {
1316 
1317  delete thePhotonMCTruthFinder_;
1318 
1319 }
1320 
1321 
1322 
1324 
1325 
1326  using namespace edm;
1327  // const float etaPhiDistance=0.01;
1328  // Fiducial region
1329  // const float TRK_BARL =0.9;
1330  const float BARL = 1.4442; // DAQ TDR p.290
1331  // const float END_LO = 1.566; // unused
1332  const float END_HI = 2.5;
1333  // Electron mass
1334  //const Float_t mElec= 0.000511;
1335 
1336 
1337  nEvt_++;
1338  LogInfo("PhotonValidator") << "PhotonValidator Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n";
1339  // std::cout << "PhotonValidator Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n";
1340 
1341 
1342  // get the geometry from the event setup:
1343  esup.get<CaloGeometryRecord>().get(theCaloGeom_);
1344 
1345 
1346  // Transform Track into TransientTrack (needed by the Vertex fitter)
1348  esup.get<TransientTrackRecord>().get("TransientTrackBuilder",theTTB);
1349 
1350 
1352  Handle<reco::PhotonCollection> photonHandle;
1353  e.getByLabel(photonCollectionProducer_, photonCollection_ , photonHandle);
1354  const reco::PhotonCollection photonCollection = *(photonHandle.product());
1355  if (!photonHandle.isValid()) {
1356  edm::LogError("PhotonProducer") << "Error! Can't get the Photon collection "<< std::endl;
1357  return;
1358  }
1359 
1360  Handle< edm::View<reco::Track> > outInTrkHandle;
1361  Handle< edm::View<reco::Track> > inOutTrkHandle;
1362  if ( !fastSim_) {
1364  e.getByLabel(conversionOITrackProducer_, outInTrkHandle);
1365  //std::cout << "ConvPhoAnalyzerWithOfficialAssociation outInTrack collection size " << (*outInTrkHandle).size() << "\n";
1366 
1368  e.getByLabel(conversionIOTrackProducer_, inOutTrkHandle);
1369  //std::cout << " ConvPhoAnalyzerWithOfficialAssociation inOutTrack collection size " << (*inOutTrkHandle).size() << "\n";
1370 
1371  // Loop over Out In Tracks
1372  int iTrk=0;
1373  int nHits=0;
1374  for( View<reco::Track>::const_iterator iTk = (*outInTrkHandle).begin(); iTk != (*outInTrkHandle).end(); iTk++) {
1375  // std::cout << " Barrel Out In Track charge " << iTk->charge() << " Num of RecHits " << iTk->recHitsSize() << " inner momentum " << sqrt( iTk->innerMomentum().Mag2() ) << "\n";
1376  // std::cout << " Barrel Out In Track Extra inner momentum " << sqrt(iTk->extra()->innerMomentum().Mag2()) << " inner position R " << sqrt( iTk->innerPosition().Perp2() ) << "\n";
1377  h_OIinnermostHitR_ ->Fill ( sqrt( iTk->innerPosition().Perp2() ) );
1378  for ( trackingRecHit_iterator itHits=iTk->extra()->recHitsBegin(); itHits!=iTk->extra()->recHitsEnd(); ++itHits ) {
1379  if ( (*itHits)->isValid() ) {
1380  nHits++;
1381  // 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";
1382  }
1383 
1384 
1385  }
1386 
1387  iTrk++;
1388 
1389 
1390  }
1391 
1392  // Loop over In Out Tracks Barrel
1393  iTrk=0;
1394  for( View<reco::Track>::const_iterator iTk = (*inOutTrkHandle).begin(); iTk != (*inOutTrkHandle).end(); iTk++) {
1395  //std::cout << " Barrel In Out Track charge " << iTk->charge() << " Num of RecHits " << iTk->recHitsSize() << " inner momentum " << sqrt( iTk->innerMomentum().Mag2()) << "\n";
1396  // std::cout << " Barrel In Out Track Extra inner momentum " << sqrt(iTk->extra()->innerMomentum().Mag2()) << "\n";
1397  h_IOinnermostHitR_ ->Fill ( sqrt( iTk->innerPosition().Perp2() ) );
1398  nHits=0;
1399  for ( trackingRecHit_iterator itHits=iTk->extra()->recHitsBegin(); itHits!=iTk->extra()->recHitsEnd(); ++itHits ) {
1400  if ( (*itHits)->isValid() ) {
1401  nHits++;
1402  //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";
1403 
1404  }
1405  }
1406 
1407 
1408 
1409  iTrk++;
1410  }
1411 
1412  } // if !fastSim
1413 
1414 
1416  //get simtrack info
1417  std::vector<SimTrack> theSimTracks;
1418  std::vector<SimVertex> theSimVertices;
1421 
1422  if ( ! fastSim_) {
1423  e.getByLabel("g4SimHits",SimTk);
1424  e.getByLabel("g4SimHits",SimVtx);
1425  } else {
1426  e.getByLabel("famosSimHits",SimTk);
1427  e.getByLabel("famosSimHits",SimVtx);
1428 
1429  }
1430 
1431 
1432 
1433  theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
1434  theSimVertices.insert(theSimVertices.end(),SimVtx->begin(),SimVtx->end());
1435  std::vector<PhotonMCTruth> mcPhotons=thePhotonMCTruthFinder_->find (theSimTracks, theSimVertices);
1436 
1438  e.getByLabel("generator",hepMC);
1439  const HepMC::GenEvent *myGenEvent = hepMC->GetEvent();
1440 
1441 
1442  // get generated jets
1443  Handle<reco::GenJetCollection> GenJetsHandle ;
1444  e.getByLabel("iterativeCone5GenJets","",GenJetsHandle);
1445  reco::GenJetCollection genJetCollection = *(GenJetsHandle.product());
1446 
1447 
1448 
1449  // Get electron tracking truth
1450  bool useTP= parameters_.getParameter<bool>("useTP");
1452  edm::Handle<TrackingParticleCollection> ElectronTPHandle;
1453  if ( useTP) {
1454  if ( ! fastSim_) {
1455  e.getByLabel(label_tp_,ElectronTPHandle);
1456  // e.getByLabel("mergedtruth","MergedTrackTruth",ElectronTPHandle);
1457  trackingParticles = *(ElectronTPHandle.product());
1458  }
1459  }
1460 
1462  std::vector<reco::PhotonCollection::const_iterator> StoRMatchedConvertedPhotons;
1463  reco::SimToRecoCollection OISimToReco;
1464  reco::SimToRecoCollection IOSimToReco;
1465  // Reco to Sim
1466  reco::RecoToSimCollection OIRecoToSim;
1467  reco::RecoToSimCollection IORecoToSim;
1468 
1469  if ( useTP) {
1470  if ( ! fastSim_) {
1471  // Sim to Reco
1472  OISimToReco = theTrackAssociator_->associateSimToReco(outInTrkHandle, ElectronTPHandle, &e);
1473  IOSimToReco = theTrackAssociator_->associateSimToReco(inOutTrkHandle, ElectronTPHandle, &e);
1474  // Reco to Sim
1475  OIRecoToSim = theTrackAssociator_->associateRecoToSim(outInTrkHandle, ElectronTPHandle, &e);
1476  IORecoToSim = theTrackAssociator_->associateRecoToSim(inOutTrkHandle, ElectronTPHandle, &e);
1477  }
1478  }
1479  //
1480  vector<reco::SimToRecoCollection*> StoRCollPtrs;
1481  StoRCollPtrs.push_back(&OISimToReco);
1482  StoRCollPtrs.push_back(&IOSimToReco);
1483  vector<reco::RecoToSimCollection*> RtoSCollPtrs;
1484  RtoSCollPtrs.push_back(&OIRecoToSim);
1485  RtoSCollPtrs.push_back(&IORecoToSim);
1486  //
1487  for (int i=0; i<2; i++)
1488  nSimPho_[i]=0;
1489  for (int i=0; i<2; i++)
1490  nSimConv_[i]=0;
1491 
1492 
1493  std::vector<reco::Photon> myPhotons;
1494  for( reco::PhotonCollection::const_iterator iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
1495  if ( fabs(iPho->eta()) > 2.5 ) continue;
1496  myPhotons.push_back(*iPho);
1497  }
1498 
1499  std::sort(myPhotons.begin(), myPhotons.end(), sortPhotons());
1500  if ( myPhotons.size() >=2 ) {
1501  if ( myPhotons[0].et() > 40 && myPhotons[1].et() > 25 ) {
1502 
1503  math::XYZTLorentzVector p12 = myPhotons[0].p4()+myPhotons[1].p4();
1504  float gamgamMass2 = p12.Dot(p12);
1505  if ( gamgamMass2 > 0 ) {
1506 
1507  // total
1508  h_gamgamMass_[0][0] -> Fill(sqrt( gamgamMass2 ));
1509  if ( myPhotons[0].isEB() && myPhotons[1].isEB() )
1510  h_gamgamMass_[0][1] -> Fill(sqrt( gamgamMass2 ));
1511  if ( ( myPhotons[0].isEE() && myPhotons[1].isEE() ) ||
1512  ( myPhotons[0].isEE() && myPhotons[1].isEB() ) ||
1513  ( myPhotons[0].isEB() && myPhotons[1].isEE() ) )
1514  h_gamgamMass_[0][2] -> Fill(sqrt( gamgamMass2 ));
1515 
1516 
1517  // Golden photons
1518  if ( myPhotons[0].r9() > 0.93 && myPhotons[1].r9() > 0.93 ) {
1519  h_gamgamMass_[1][0] -> Fill(sqrt( gamgamMass2 ));
1520  if ( myPhotons[0].isEB() && myPhotons[1].isEB() )
1521  h_gamgamMass_[1][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_[1][2] -> Fill(sqrt( gamgamMass2 ));
1526  }
1527 
1528 
1529  // both photons converted
1530  if ( myPhotons[0].conversions().size() > 0 && myPhotons[1].conversions().size() >0 ) {
1531  if ( myPhotons[0].conversions()[0]->nTracks() ==2 && myPhotons[1].conversions()[0]->nTracks() ==2 ) {
1532  float chi2Prob1 = ChiSquaredProbability( myPhotons[0].conversions()[0]->conversionVertex().chi2(), myPhotons[0].conversions()[0]->conversionVertex().ndof() );
1533  float chi2Prob2 = ChiSquaredProbability( myPhotons[1].conversions()[0]->conversionVertex().chi2(), myPhotons[1].conversions()[0]->conversionVertex().ndof() );
1534  if ( chi2Prob1 > 0.0005 && chi2Prob2 > 0.0005 ) {
1535  h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
1536  if ( myPhotons[0].isEB() && myPhotons[1].isEB() ) {
1537  h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
1538  }
1539  if ( ( myPhotons[0].isEE() && myPhotons[1].isEE() ) ||
1540  ( myPhotons[0].isEE() && myPhotons[1].isEB() ) ||
1541  ( myPhotons[0].isEB() && myPhotons[1].isEE() ) )
1542  h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 )); {
1543  }
1544  }
1545  }
1546 
1547 
1548  } else if ( myPhotons[0].conversions().size() > 0 && myPhotons[1].conversions().size() ==0 && myPhotons[1].r9() > 0.93 ) { // one photon converted
1549  if ( myPhotons[0].conversions()[0]->nTracks() ==2 ) {
1550  float chi2Prob1 = ChiSquaredProbability( myPhotons[0].conversions()[0]->conversionVertex().chi2(), myPhotons[0].conversions()[0]->conversionVertex().ndof() );
1551  if ( chi2Prob1 > 0.0005 ) {
1552  h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
1553  if ( myPhotons[0].isEB() && myPhotons[1].isEB() ) {
1554  h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
1555  }
1556  if ( myPhotons[0].isEE() || myPhotons[1].isEE() ) {
1557  h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 ));
1558  }
1559  }
1560  }
1561 
1562 
1563  } else if ( myPhotons[1].conversions().size() > 0 && myPhotons[0].conversions().size() ==0 && myPhotons[0].r9() > 0.93 ) { // one photon converted
1564  if ( myPhotons[1].conversions()[0]->nTracks() ==2 ) {
1565  float chi2Prob1 = ChiSquaredProbability( myPhotons[1].conversions()[0]->conversionVertex().chi2(), myPhotons[1].conversions()[0]->conversionVertex().ndof() );
1566  if ( chi2Prob1 > 0.0005 ) {
1567  h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
1568  if ( myPhotons[0].isEB() && myPhotons[1].isEB() ) {
1569  h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
1570  }
1571  if ( myPhotons[0].isEE() || myPhotons[1].isEE() ) {
1572  h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 ));
1573  }
1574  }
1575  }
1576  }
1577 
1578 
1579  }
1580  }
1581  }
1582 
1583 
1584  // cout << " PhotonValidator mcPhotons.size() " << mcPhotons.size() << endl;
1585  for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
1586  if ( (*mcPho).fourMomentum().et() < minPhoEtCut_ ) continue;
1587 
1588  for ( HepMC::GenEvent::particle_const_iterator mcIter=myGenEvent->particles_begin(); mcIter != myGenEvent->particles_end(); mcIter++ ) {
1589  if ( (*mcIter)->pdg_id() != 22 ) continue;
1590  bool isTheSame= false;
1591  HepMC::GenParticle* mother = 0;
1592  if ( (*mcIter)->production_vertex() ) {
1593  if ( (*mcIter)->production_vertex()->particles_begin(HepMC::parents) !=
1594  (*mcIter)->production_vertex()->particles_end(HepMC::parents))
1595  mother = *((*mcIter)->production_vertex()->particles_begin(HepMC::parents));
1596  }
1597 
1598 
1599 
1600 
1601  float mcPhi= (*mcPho).fourMomentum().phi();
1602  mcPhi_= phiNormalization(mcPhi);
1603  mcEta_= (*mcPho).fourMomentum().pseudoRapidity();
1604  mcEta_ = etaTransformation(mcEta_, (*mcPho).primaryVertex().z() );
1605  mcConvR_= (*mcPho).vertex().perp();
1606  mcConvX_= (*mcPho).vertex().x();
1607  mcConvY_= (*mcPho).vertex().y();
1608  mcConvZ_= (*mcPho).vertex().z();
1609  mcConvEta_= (*mcPho).vertex().eta();
1610  mcConvPhi_= (*mcPho).vertex().phi();
1611 
1612  if ( fabs(mcEta_) > END_HI ) continue;
1613 
1614 
1615 
1616  if ( mother ==0
1617  || (mother != 0 && mother->pdg_id() == 22)
1618  || (mother != 0 && mother->pdg_id() == 25)
1619  || (mother != 0 && mother->pdg_id() == 35) )
1620  {
1621  //std::cout << " ZERO mother or Higgs or primary photon " << std::endl;
1622  //if (mother !=0) std::cout << mother->pdg_id() << std::endl;
1623  double dPt = fabs((*mcIter)->momentum().perp() - (*mcPho).fourMomentum().et());
1624  float phiMother=(*mcIter)->momentum().phi();
1625  double dPhi = phiNormalization(phiMother) - mcPhi_ ;
1626  double dEta = fabs( (*mcIter)->momentum().eta() - (*mcPho).fourMomentum().pseudoRapidity() );
1627 
1628  //std::cout << " HEP photon pt " << (*mcIter)->momentum().perp() << " eta " << (*mcIter)->momentum().eta() << " phi " << (*mcIter)->momentum().phi() << std::endl;
1629  //std::cout << " (*mcPho).motherType() selection " << (*mcPho).motherType() << " pt " << (*mcPho).fourMomentum().et() << " eta " << (*mcPho).fourMomentum().pseudoRapidity() << " phi " << mcPhi_ << std::endl;
1630  //std::cout << " dPt " << dPt << " dEta " << dEta << " dPhi " << dPhi << std::endl;
1631  if ( dEta <=0.0001 && dPhi <=0.0001 && dPt <=0.0001)
1632  isTheSame = true;
1633 
1634  }
1635  if ( ! isTheSame ) continue;
1636  // std::cout << " HEP photon pt " << (*mcIter)->momentum().perp() << " eta " << (*mcIter)->momentum().eta() << " phi " << (*mcIter)->momentum().phi() << std::endl;
1637  //std::cout << " (*mcPho).motherType() after " << (*mcPho).motherType() << " pt " << (*mcPho).fourMomentum().et() << " eta " << (*mcPho).fourMomentum().pseudoRapidity() << " phi " << mcPhi_ << std::endl;
1638 
1639 
1640 
1641  // if ( ! ( fabs(mcEta_) <= BARL || ( fabs(mcEta_) >= END_LO && fabs(mcEta_) <=END_HI ) ) )
1642  // continue; // all ecal fiducial region
1643 
1644 
1645  nSimPho_[0]++;
1646  h_SimPhoMotherEt_[0]->Fill( (*mcPho).motherMomentum().et() );
1647  h_SimPhoMotherEta_[0]->Fill( (*mcPho).motherMomentum().pseudoRapidity());
1648 
1649  h_SimPho_[0]->Fill ( mcEta_);
1650  h_SimPho_[1]->Fill ( mcPhi_);
1651  h_SimPho_[2]->Fill ( (*mcPho).fourMomentum().et() );
1652 
1653 
1654 
1655 
1657 
1658  bool goodSimConversion=false;
1659  bool visibleConversion=false;
1660  bool visibleConversionsWithTwoSimTracks=false;
1661  if ( (*mcPho).isAConversion() == 1 ) {
1662  nSimConv_[0]++;
1663  h_AllSimConv_[0]->Fill( mcEta_ ) ;
1664  h_AllSimConv_[1]->Fill( mcPhi_ );
1665  h_AllSimConv_[2]->Fill( mcConvR_ );
1666  h_AllSimConv_[3]->Fill( mcConvZ_ );
1667  h_AllSimConv_[4]->Fill( (*mcPho).fourMomentum().et());
1668 
1669  if ( mcConvR_ <15) h_SimConvEtaPix_[0]->Fill( mcEta_ ) ;
1670 
1671  if ( ( fabs(mcEta_) <= BARL && mcConvR_ <85 ) ||
1672  ( fabs(mcEta_) > BARL && fabs(mcEta_) <=END_HI && fabs( (*mcPho).vertex().z() ) < 210 ) ) visibleConversion=true;
1673 
1674 
1675 
1676  theConvTP_.clear();
1677  //std::cout << " PhotonValidator TrackingParticles TrackingParticleCollection size "<< trackingParticles.size() << "\n";
1678  for(size_t i = 0; i < trackingParticles.size(); ++i){
1679  TrackingParticleRef tp (ElectronTPHandle,i);
1680  //std::cout << " Electron pt " << tp -> pt() << " charge " << tp -> charge() << " pdgId " << tp->pdgId() << " Hits for this track: " << tp -> trackPSimHit().size() << std::endl;
1681  //std::cout << " track vertex position x " << tp->vertex().x() << " y " << tp->vertex().y() << " z " << tp->vertex().z() << std::endl;
1682  //std::cout << " track vertex position x " << tp->vx() << " y " << tp->vy() << " z " << tp->vz() << std::endl;
1683  //std::cout << " conversion vertex position x " << (*mcPho).vertex().x() << " y " << (*mcPho).vertex().y() << " z " << (*mcPho).vertex().z() << std::endl;
1684  if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.001 &&
1685  fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.001 &&
1686  fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.001) {
1687 
1688  //std::cout << " From conversion Electron pt " << tp -> pt() << " charge " << tp -> charge() << " pdgId " << tp->pdgId() << " Hits for this track: " << tp -> trackPSimHit().size() << std::endl;
1689  // std::cout << " track vertex position x " << tp->vertex().x() << " y " << tp->vertex().y() << " z " << tp->vertex().z() << std::endl;
1690  //std::cout << " conversion vertex position x " << (*mcPho).vertex().x() << " y " << (*mcPho).vertex().y() << " z " << (*mcPho).vertex().z() << " R " << (*mcPho).vertex().perp() << std::endl;
1691  theConvTP_.push_back( tp );
1692  }
1693  }
1694  // std::cout << " PhotonValidator theConvTP_ size " << theConvTP_.size() << std::endl;
1695 
1696  if ( theConvTP_.size() == 2 ) visibleConversionsWithTwoSimTracks=true;
1697  goodSimConversion=false;
1698 
1699  if ( visibleConversion && visibleConversionsWithTwoSimTracks ) goodSimConversion=true;
1700  if ( goodSimConversion ) {
1701  nSimConv_[1]++;
1702  h_VisSimConv_[0]->Fill( mcEta_ ) ;
1703  h_VisSimConv_[1]->Fill( mcPhi_ );
1704  h_VisSimConv_[2]->Fill( mcConvR_ );
1705  h_VisSimConv_[3]->Fill( mcConvZ_ );
1706  h_VisSimConv_[4]->Fill( (*mcPho).fourMomentum().et());
1707 
1708 
1709  if ( useTP ) {
1710  for ( vector<TrackingParticleRef>::iterator iTrk=theConvTP_.begin(); iTrk!=theConvTP_.end(); ++iTrk) {
1711  h_simTkPt_ -> Fill ( (*iTrk)->pt() );
1712  h_simTkEta_ -> Fill ( (*iTrk)->eta() );
1713  }
1714  }
1715  }
1716  }
1717 
1718 
1719 
1720  float minDelta=10000.;
1721  std::vector<reco::Photon> thePhotons;
1722  int index=0;
1723  int iMatch=-1;
1724  bool matched=false;
1725 
1726  //std::cout << " Reco photon size " << photonCollection.size() << std::endl;
1727  for( reco::PhotonCollection::const_iterator iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
1728  reco::Photon aPho = reco::Photon(*iPho);
1729  thePhotons.push_back(aPho);
1730  float phiPho=aPho.phi();
1731  float etaPho=aPho.eta();
1732  float deltaPhi = phiPho-mcPhi_;
1733  float deltaEta = etaPho-mcEta_;
1734  if ( deltaPhi > pi ) deltaPhi -= twopi;
1735  if ( deltaPhi < -pi) deltaPhi += twopi;
1736  deltaPhi=pow(deltaPhi,2);
1737  deltaEta=pow(deltaEta,2);
1738  float delta = sqrt( deltaPhi+deltaEta);
1739  if ( delta<0.1 && delta < minDelta ) {
1740  minDelta=delta;
1741  iMatch=index;
1742 
1743  }
1744  index++;
1745  } // end loop over reco photons
1746  if ( iMatch>-1 ) matched=true;
1747 
1748 
1749  if ( matched ) {
1750  nSimPho_[1]++;
1751 
1752  h_SimPhoMotherEt_[1]->Fill( (*mcPho).motherMomentum().et() );
1753  h_SimPhoMotherEta_[1]->Fill( (*mcPho).motherMomentum().pseudoRapidity());
1754 
1755  h_MatchedSimPho_[0]->Fill( mcEta_ ) ;
1756  h_MatchedSimPho_[1]->Fill( mcPhi_ );
1757  h_MatchedSimPho_[2]->Fill( (*mcPho).fourMomentum().et());
1758 
1759  }
1760 
1761 
1762 
1763 
1764  if ( ! matched) continue;
1765 
1766  bool phoIsInBarrel=false;
1767  bool phoIsInEndcap=false;
1768 
1769  reco::Photon matchingPho = thePhotons[iMatch];
1770 
1771  if ( fabs(matchingPho.superCluster()->position().eta() ) < 1.479 ) {
1772  phoIsInBarrel=true;
1773  } else {
1774  phoIsInEndcap=true;
1775  }
1776  edm::Handle<EcalRecHitCollection> ecalRecHitHandle;
1777  if ( phoIsInBarrel ) {
1778  // Get handle to rec hits ecal barrel
1779  e.getByLabel(barrelEcalHits_, ecalRecHitHandle);
1780  if (!ecalRecHitHandle.isValid()) {
1781  edm::LogError("PhotonProducer") << "Error! Can't get the product "<<barrelEcalHits_.label();
1782  return;
1783  }
1784 
1785  } else if ( phoIsInEndcap ) {
1786 
1787  // Get handle to rec hits ecal encap
1788  e.getByLabel(endcapEcalHits_, ecalRecHitHandle);
1789  if (!ecalRecHitHandle.isValid()) {
1790  edm::LogError("PhotonProducer") << "Error! Can't get the product "<<endcapEcalHits_.label();
1791  return;
1792  }
1793 
1794  }
1795 
1796 
1797 
1798  int type=0;
1799  const EcalRecHitCollection ecalRecHitCollection = *(ecalRecHitHandle.product());
1800  float photonE = matchingPho.energy();
1801  float photonEt= matchingPho.energy()/cosh( matchingPho.eta()) ;
1802  float r9 = matchingPho.r9();
1803  float r1 = matchingPho.r1x5();
1804  float r2 = matchingPho.r2x5();
1805  float sigmaIetaIeta = matchingPho.sigmaIetaIeta();
1806  float hOverE = matchingPho.hadronicOverEm();
1807  float ecalIso = matchingPho.ecalRecHitSumEtConeDR04();
1808  float hcalIso = matchingPho.hcalTowerSumEtConeDR04();
1809  float trkIso = matchingPho.trkSumPtSolidConeDR04();
1810  float nIsoTrk = matchingPho.nTrkSolidConeDR04();
1811  std::vector< std::pair<DetId, float> >::const_iterator rhIt;
1812 
1813  bool atLeastOneDeadChannel=false;
1814  for(reco::CaloCluster_iterator bcIt = matchingPho.superCluster()->clustersBegin();bcIt != matchingPho.superCluster()->clustersEnd(); ++bcIt) {
1815  for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
1816 
1817  for(EcalRecHitCollection::const_iterator it = ecalRecHitCollection.begin(); it != ecalRecHitCollection.end(); ++it) {
1818  if (rhIt->first == (*it).id() ) {
1819  if ( (*it).recoFlag() == 9 ) {
1820  atLeastOneDeadChannel=true;
1821  break;
1822  }
1823  }
1824  }
1825  }
1826  }
1827 
1828  if ( atLeastOneDeadChannel ) {
1829  h_MatchedSimPhoBadCh_[0]->Fill( mcEta_ ) ;
1830  h_MatchedSimPhoBadCh_[1]->Fill( mcPhi_ );
1831  h_MatchedSimPhoBadCh_[2]->Fill( (*mcPho).fourMomentum().et());
1832 
1833  }
1834 
1835 
1836  h_scEta_[type]->Fill( matchingPho.superCluster()->eta() );
1837  h_scPhi_[type]->Fill( matchingPho.superCluster()->phi() );
1838  h_scEtaWidth_[type]->Fill( matchingPho.superCluster()->etaWidth() );
1839  h_scPhiWidth_[type]->Fill( matchingPho.superCluster()->phiWidth() );
1840  h_scE_[type][0]->Fill( matchingPho.superCluster()->energy() );
1841  h_scEt_[type][0]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
1842  if ( phoIsInEndcap ) h_psE_->Fill( matchingPho.superCluster()->preshowerEnergy() ) ;
1843  //
1844  h_r9_[type][0]->Fill( r9 );
1845  h2_r9VsEta_[0] -> Fill (mcEta_, r9);
1846  h2_r9VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r9);
1847  //
1848  h_r1_[type][0]->Fill( r1 );
1849  h2_r1VsEta_[0] -> Fill (mcEta_, r1);
1850  h2_r1VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r1);
1851  //
1852  h_r2_[type][0]->Fill( r2 );
1853  h2_r2VsEta_[0] -> Fill (mcEta_, r2);
1854  h2_r2VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r2);
1855  //
1856  h_sigmaIetaIeta_[type][0]->Fill( sigmaIetaIeta );
1857  h2_sigmaIetaIetaVsEta_[0] -> Fill (mcEta_, sigmaIetaIeta );
1858  h2_sigmaIetaIetaVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), sigmaIetaIeta);
1859  //
1860  h_hOverE_[type][0]->Fill( hOverE );
1861  h2_hOverEVsEta_[0] -> Fill (mcEta_, hOverE );
1862  h2_hOverEVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hOverE);
1863  p_hOverEVsEta_[0] -> Fill (mcEta_, hOverE );
1864  p_hOverEVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hOverE);
1865  //
1866  h_ecalRecHitSumEtConeDR04_[type][0]->Fill( ecalIso );
1867  h2_ecalRecHitSumEtConeDR04VsEta_[0] -> Fill (mcEta_, ecalIso );
1868  h2_ecalRecHitSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
1869  p_ecalRecHitSumEtConeDR04VsEta_[0] -> Fill (mcEta_, ecalIso );
1870  p_ecalRecHitSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
1871  //
1872  h_hcalTowerSumEtConeDR04_[type][0]->Fill( hcalIso );
1873  h2_hcalTowerSumEtConeDR04VsEta_[0] -> Fill (mcEta_, hcalIso );
1874  h2_hcalTowerSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
1875  p_hcalTowerSumEtConeDR04VsEta_[0] -> Fill (mcEta_, hcalIso );
1876  p_hcalTowerSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
1877  //
1878  h_isoTrkSolidConeDR04_[type][0]->Fill( trkIso );
1879  h2_isoTrkSolidConeDR04VsEta_[0] -> Fill (mcEta_, trkIso );
1880  h2_isoTrkSolidConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), trkIso);
1881  //
1882  h_nTrkSolidConeDR04_[type][0]->Fill( nIsoTrk );
1883  h2_nTrkSolidConeDR04VsEta_[0] -> Fill (mcEta_, nIsoTrk );
1884  h2_nTrkSolidConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), nIsoTrk);
1885  //
1886  h_phoEta_[type]->Fill( matchingPho.eta() );
1887  h_phoPhi_[type]->Fill( matchingPho.phi() );
1888  h_phoDEta_[0]->Fill ( matchingPho.eta() - (*mcPho).fourMomentum().eta() );
1889  h_phoDPhi_[0]->Fill ( matchingPho.phi() - mcPhi_ );
1890  h_phoE_[type][0]->Fill( photonE );
1891  h_phoEt_[type][0]->Fill( photonEt);
1892  //
1893  h_phoERes_[0][0]->Fill( photonE / (*mcPho).fourMomentum().e() );
1894  h2_eResVsEta_[0]->Fill (mcEta_, photonE/(*mcPho).fourMomentum().e() ) ;
1895  p_eResVsEta_[0]->Fill (mcEta_, photonE/(*mcPho).fourMomentum().e() ) ;
1896 
1897  if ( ! isRunCentrally_ ) h2_eResVsEt_[0][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
1898  p_eResVsEt_[0][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
1899 
1900  h2_eResVsR9_[0]->Fill (r9, photonE/(*mcPho).fourMomentum().e() ) ;
1901  h2_sceResVsR9_[0]->Fill (r9, matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e() ) ;
1902  p_eResVsR9_[0]->Fill (r9, photonE/(*mcPho).fourMomentum().e() ) ;
1903  p_sceResVsR9_[0]->Fill (r9, matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e() ) ;
1904  //
1905  if ( (*mcPho).isAConversion() == 0 ) {
1906  h2_eResVsEta_[1]->Fill (mcEta_, photonE/ (*mcPho).fourMomentum().e() ) ;
1907 
1908 
1909 
1910  h2_r9VsEta_[1] -> Fill (mcEta_, r9);
1911  h2_r9VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r9);
1912  //
1913  h2_r1VsEta_[1] -> Fill (mcEta_, r1);
1914  h2_r1VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r1);
1915  //
1916  h2_r2VsEta_[1] -> Fill (mcEta_, r2);
1917  h2_r2VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r2);
1918  //
1919  h2_sigmaIetaIetaVsEta_[1] -> Fill (mcEta_, sigmaIetaIeta );
1920  h2_sigmaIetaIetaVsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), sigmaIetaIeta);
1921  //
1922  h2_hOverEVsEta_[1] -> Fill (mcEta_, hOverE );
1923  h2_hOverEVsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hOverE);
1924  //
1925  h2_ecalRecHitSumEtConeDR04VsEta_[1] -> Fill (mcEta_, ecalIso );
1926  p_ecalRecHitSumEtConeDR04VsEta_[1] -> Fill (mcEta_, ecalIso );
1927  //
1928  h2_hcalTowerSumEtConeDR04VsEta_[1] -> Fill (mcEta_, hcalIso );
1929  p_hcalTowerSumEtConeDR04VsEta_[1] -> Fill (mcEta_, hcalIso );
1930  //
1931  h2_isoTrkSolidConeDR04VsEta_[1] -> Fill (mcEta_, trkIso );
1932  h2_isoTrkSolidConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), trkIso);
1933  //
1934  h2_nTrkSolidConeDR04VsEta_[1] -> Fill (mcEta_, nIsoTrk );
1935  h2_nTrkSolidConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), nIsoTrk);
1936 
1937  }
1938 
1939 
1940 
1941 
1942  if ( photonE/(*mcPho).fourMomentum().e() < 0.3 && photonE/(*mcPho).fourMomentum().e() > 0.1 ) {
1943  // std::cout << " Eta sim " << mcEta_ << " sc eta " << matchingPho.superCluster()->eta() << " pho eta " << matchingPho.eta() << std::endl;
1944 
1945  }
1946 
1947 
1948  if ( r9 > 0.93 ) {
1949  h_phoERes_[1][0]->Fill( photonE / (*mcPho).fourMomentum().e() );
1950  if ( ! isRunCentrally_ ) h2_eResVsEt_[0][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
1951  p_eResVsEt_[0][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
1952  p_eResVsEta_[1]->Fill (mcEta_,photonE/ (*mcPho).fourMomentum().e() ) ;
1953 
1954  } else if ( r9 <= 0.93 ) {
1955  h_phoERes_[2][0]->Fill(photonE / (*mcPho).fourMomentum().e() );
1956  if ( ! isRunCentrally_ ) h2_eResVsEt_[0][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
1957  p_eResVsEt_[0][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
1958  p_eResVsEta_[2]->Fill (mcEta_,photonE/ (*mcPho).fourMomentum().e() ) ;
1959  }
1960 
1961 
1962 
1963  if ( phoIsInBarrel ) {
1964  h_scE_[type][1]->Fill( matchingPho.superCluster()->energy() );
1965  h_scEt_[type][1]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
1966  h_r9_[type][1]->Fill( r9 );
1967  h_r1_[type][1]->Fill( r1 );
1968  h_r2_[type][1]->Fill( r2 );
1969  h_sigmaIetaIeta_[type][1]->Fill( sigmaIetaIeta );
1970  h_hOverE_[type][1]->Fill( hOverE );
1971  h_ecalRecHitSumEtConeDR04_[type][1]->Fill( ecalIso );
1972  h2_ecalRecHitSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
1973  p_ecalRecHitSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
1974  h_hcalTowerSumEtConeDR04_[type][1]->Fill( hcalIso );
1975  h2_hcalTowerSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
1976  p_hcalTowerSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
1977  h_isoTrkSolidConeDR04_[type][1]->Fill( trkIso );
1978  h_nTrkSolidConeDR04_[type][1]->Fill( nIsoTrk );
1979 
1980 
1981  h_phoE_[type][1]->Fill( photonE );
1982  h_phoEt_[type][1]->Fill( photonEt );
1983  h_nConv_[type][1]->Fill(float( matchingPho.conversions().size()));
1984 
1985 
1986  h_phoERes_[0][1]->Fill( photonE / (*mcPho).fourMomentum().e() );
1987  h2_eResVsR9_[1]->Fill (r9, photonE/(*mcPho).fourMomentum().e() ) ;
1988  h2_sceResVsR9_[1]->Fill (r9, matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e() ) ;
1989  p_eResVsR9_[1]->Fill (r9, photonE/(*mcPho).fourMomentum().e() ) ;
1990  p_sceResVsR9_[1]->Fill (r9, matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e() ) ;
1991 
1992  if ( ! isRunCentrally_ ) h2_eResVsEt_[1][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
1993  p_eResVsEt_[1][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
1994 
1995 
1996  if ( r9 > 0.93 ) {
1997  h_phoERes_[1][1]->Fill( photonE / (*mcPho).fourMomentum().e() );
1998  if ( ! isRunCentrally_ ) h2_eResVsEt_[1][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
1999  p_eResVsEt_[1][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2000  }
2001  if ( r9 <= 0.93 ) {
2002  h_phoERes_[2][1]->Fill( photonE / (*mcPho).fourMomentum().e() );
2003  if ( ! isRunCentrally_ ) h2_eResVsEt_[1][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2004  p_eResVsEt_[1][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2005  }
2006  }
2007  if ( phoIsInEndcap ) {
2008  h_scE_[type][2]->Fill( matchingPho.superCluster()->energy() );
2009  h_scEt_[type][2]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
2010  h_r9_[type][2]->Fill( r9 );
2011  h_r1_[type][2]->Fill( r1 );
2012  h_r2_[type][2]->Fill( r2 );
2013  h_sigmaIetaIeta_[type][2]->Fill( sigmaIetaIeta );
2014  h_hOverE_[type][2]->Fill( hOverE );
2015  h_ecalRecHitSumEtConeDR04_[type][2]->Fill( ecalIso );
2016  h2_ecalRecHitSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
2017  p_ecalRecHitSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
2018  h_hcalTowerSumEtConeDR04_[type][2]->Fill( hcalIso );
2019  h2_hcalTowerSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
2020  p_hcalTowerSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
2021  h_isoTrkSolidConeDR04_[type][2]->Fill( trkIso );
2022  h_nTrkSolidConeDR04_[type][2]->Fill( nIsoTrk );
2023  h_phoE_[type][2]->Fill( photonE );
2024  h_phoEt_[type][2]->Fill( photonEt );
2025  h_nConv_[type][2]->Fill(float( matchingPho.conversions().size()));
2026  h_phoERes_[0][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
2027  h2_eResVsR9_[2]->Fill (r9, photonE/(*mcPho).fourMomentum().e() ) ;
2028  h2_sceResVsR9_[2]->Fill (r9, matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e() ) ;
2029  p_eResVsR9_[2]->Fill (r9, photonE/(*mcPho).fourMomentum().e() ) ;
2030  p_sceResVsR9_[2]->Fill (r9, matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e() ) ;
2031 
2032  if ( ! isRunCentrally_ ) h2_eResVsEt_[2][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2033  p_eResVsEt_[2][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2034 
2035  if ( r9 > 0.93 ) {
2036 
2037  h_phoERes_[1][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
2038  if ( ! isRunCentrally_ ) h2_eResVsEt_[2][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2039  p_eResVsEt_[2][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2040  }
2041  if ( r9 <= 0.93 ) {
2042  h_phoERes_[2][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
2043  if ( ! isRunCentrally_ ) h2_eResVsEt_[2][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2044  p_eResVsEt_[2][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e() ) ;
2045  }
2046  }
2047 
2048 
2049 
2050 
2051  if ( ! (visibleConversion && visibleConversionsWithTwoSimTracks ) ) continue;
2052  h_r9_[1][0]->Fill( r9 );
2053  if ( phoIsInBarrel ) h_r9_[1][1]->Fill( r9 );
2054  if ( phoIsInEndcap ) h_r9_[1][2]->Fill( r9 );
2055 
2056  if ( ! isRunCentrally_ ) {
2057  h_simConvVtxRvsZ_[0] ->Fill ( fabs (mcConvZ_), mcConvR_ ) ;
2058  if ( fabs(mcEta_) <=1.) {
2059  h_simConvVtxRvsZ_[1] ->Fill ( fabs (mcConvZ_), mcConvR_ ) ;
2060  h_simConvVtxYvsX_ ->Fill ( mcConvX_, mcConvY_ ) ;
2061  }
2062  else
2063  h_simConvVtxRvsZ_[2] ->Fill ( fabs (mcConvZ_), mcConvR_ ) ;
2064  }
2065 
2066 
2067  if ( ! fastSim_) {
2068  h_nConv_[type][0]->Fill(float( matchingPho.conversions().size()));
2071  for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
2072  reco::ConversionRef aConv=conversions[iConv];
2073  double like = aConv->MVAout();
2074  if ( like < likelihoodCut_ ) continue;
2075 
2076  if ( ! isRunCentrally_ ) h2_EoverEtrueVsEta_[1]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2077  p_EoverEtrueVsEta_[1]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2078 
2079 
2080  //std::vector<reco::TrackRef> tracks = aConv->tracks();
2081  const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
2082  if (tracks.size() < 1 ) continue;
2083 
2084 
2085  h_mvaOut_[0]-> Fill(like);
2086 
2087  if ( tracks.size()==2 ) {
2088  if ( sqrt( aConv->tracksPin()[0].Perp2()) < convTrackMinPtCut_ || sqrt( aConv->tracksPin()[1].Perp2()) < convTrackMinPtCut_) continue;
2089  } else {
2090  if ( sqrt( aConv->tracksPin()[0].Perp2()) < convTrackMinPtCut_ ) continue;
2091  }
2092 
2093 
2094  if ( dCotCutOn_ ) {
2095  if ( (fabs(mcEta_) > 1.1 && fabs (mcEta_) < 1.4 ) &&
2096  fabs( aConv->pairCotThetaSeparation() ) > dCotHardCutValue_ ) continue;
2097  if ( fabs( aConv->pairCotThetaSeparation() ) > dCotCutValue_ ) continue;
2098  }
2099 
2100  //std::cout << " PhotonValidator converison algo name " << aConv->algoName() << " " << aConv->algo() << std::endl;
2101 
2102  nRecConv_++;
2103 
2104 
2105  std::map<reco::TrackRef,TrackingParticleRef> myAss;
2106  std::map<reco::TrackRef,TrackingParticleRef>::const_iterator itAss;
2107  std::map<reco::TrackRef,TrackingParticleRef>::const_iterator itAssMin;
2108  std::map<reco::TrackRef,TrackingParticleRef>::const_iterator itAssMax;
2109  //
2110 
2111  int nAssT2=0;
2112  // unused int nAssT1=0;
2113  for (unsigned int i=0; i<tracks.size(); i++) {
2114  reco::TrackRef track = tracks[i].castTo<reco::TrackRef>();
2115 
2116  type =0;
2117  if ( ! isRunCentrally_ ) nHitsVsEta_[type] ->Fill (mcEta_, float(tracks[i]->numberOfValidHits())-0.0001 );
2118  if ( ! isRunCentrally_ ) nHitsVsR_[type] ->Fill (mcConvR_, float(tracks[i]->numberOfValidHits())-0.0001 );
2119  p_nHitsVsEta_[type] ->Fill (mcEta_, float(tracks[i]->numberOfValidHits()) );
2120  p_nHitsVsR_[type] ->Fill (mcConvR_, float(tracks[i]->numberOfValidHits()) );
2121  h_tkChi2_[type] ->Fill (tracks[i]->normalizedChi2() );
2122 
2124  TrackingParticleRef myTP;
2125  for (size_t j = 0; j < RtoSCollPtrs.size(); j++) {
2126  reco::RecoToSimCollection q = *(RtoSCollPtrs[j]);
2127 
2128  RefToBase<reco::Track> myTk( track );
2129 
2130  if( q.find(myTk ) != q.end() ) {
2131  std::vector<std::pair<TrackingParticleRef, double> > tp = q[myTk];
2132  for (unsigned int itp=0; itp<tp.size(); itp++) {
2133  myTP=tp[itp].first;
2134  // std::cout << " associated with TP " << myTP->pdgId() << " pt " << sqrt(myTP->momentum().perp2()) << std::endl;
2135  myAss.insert( std::make_pair ( track , myTP) );
2136  nAssT2++;
2137  }
2138  }
2139  }
2140  }
2141 
2142 
2143 
2144  type=0;
2145 
2146  // float totP = sqrt(aConv->pairMomentum().Mag2());
2147  float refP =-99999.;
2148  float refPt =-99999.;
2149  if ( aConv->conversionVertex().isValid() ) {
2150  refP=sqrt(aConv->refittedPairMomentum().Mag2());
2151  refPt=sqrt(aConv->refittedPairMomentum().perp2());
2152  }
2153  float invM = aConv->pairInvariantMass();
2154 
2155  h_invMass_[type][0] ->Fill( invM);
2156  if ( phoIsInBarrel ) h_invMass_[type][1] ->Fill(invM);
2157  if ( phoIsInEndcap ) h_invMass_[type][2] ->Fill(invM);
2158 
2159 
2161  if ( tracks.size() ==1 ) {
2162  h_SimConvOneTracks_[0]->Fill( mcEta_ ) ;
2163  h_SimConvOneTracks_[1]->Fill( mcPhi_ );
2164  h_SimConvOneTracks_[2]->Fill( mcConvR_ );
2165  h_SimConvOneTracks_[3]->Fill( mcConvZ_ );
2166  h_SimConvOneTracks_[4]->Fill( (*mcPho).fourMomentum().et());
2167 
2168 
2169  } else if ( tracks.size() ==2 ) {
2170 
2171  h_SimConvTwoTracks_[0]->Fill( mcEta_ ) ;
2172  h_SimConvTwoTracks_[1]->Fill( mcPhi_ );
2173  h_SimConvTwoTracks_[2]->Fill( mcConvR_ );
2174  h_SimConvTwoTracks_[3]->Fill( mcConvZ_ );
2175  h_SimConvTwoTracks_[4]->Fill( (*mcPho).fourMomentum().et());
2176 
2177  h_convEta_[1]->Fill( aConv->caloCluster()[0]->eta() );
2178 
2179  float trkProvenance=3;
2180  if ( tracks[0]->algoName() == "outInEcalSeededConv" && tracks[1]->algoName() == "outInEcalSeededConv" ) trkProvenance=0;
2181  if ( tracks[0]->algoName() == "inOutEcalSeededConv" && tracks[1]->algoName() == "inOutEcalSeededConv" ) trkProvenance=1;
2182  if ( ( tracks[0]->algoName() == "outInEcalSeededConv" && tracks[1]->algoName() == "inOutEcalSeededConv") ||
2183  ( tracks[1]->algoName() == "outInEcalSeededConv" && tracks[0]->algoName() == "inOutEcalSeededConv") ) trkProvenance=2;
2184  if ( trkProvenance==3 ) {
2185  // std::cout << " PhotonValidator provenance of tracks is " << tracks[0]->algoName() << " and " << tracks[1]->algoName() << std::endl;
2186  }
2187  h_trkProv_[0]->Fill( trkProvenance );
2188 
2189 
2190 
2192  if ( nAssT2 ==2 ) {
2193 
2194 
2195 
2196 
2197  h_r9_[2][0]->Fill( r9 );
2198  if ( phoIsInBarrel ) h_r9_[2][1]->Fill( r9 );
2199  if ( phoIsInEndcap ) h_r9_[2][2]->Fill( r9 );
2200 
2201  h_convEta_[2]->Fill( aConv->caloCluster()[0]->eta() );
2202 
2203  nRecConvAss_++;
2204 
2205 
2206  h_SimConvTwoMTracks_[0]->Fill( mcEta_ ) ;
2207  h_SimConvTwoMTracks_[1]->Fill( mcPhi_ );
2208  h_SimConvTwoMTracks_[2]->Fill( mcConvR_ );
2209  h_SimConvTwoMTracks_[3]->Fill( mcConvZ_ );
2210  h_SimConvTwoMTracks_[4]->Fill( (*mcPho).fourMomentum().et());
2211 
2212  if ( aConv->conversionVertex().isValid() ) {
2213  if ( trkProvenance==3 ) std::cout << " PhotonValidator provenance of tracks is mixed and vertex is valid " << std::endl;
2214  float chi2Prob = ChiSquaredProbability( aConv->conversionVertex().chi2(), aConv->conversionVertex().ndof() );
2215  if ( chi2Prob > 0) {
2216  h_SimConvTwoMTracksAndVtxPGT0_[0]->Fill( mcEta_ ) ;
2217  h_SimConvTwoMTracksAndVtxPGT0_[1]->Fill( mcPhi_ );
2218  h_SimConvTwoMTracksAndVtxPGT0_[2]->Fill( mcConvR_ );
2219  h_SimConvTwoMTracksAndVtxPGT0_[3]->Fill( mcConvZ_ );
2220  h_SimConvTwoMTracksAndVtxPGT0_[4]->Fill( (*mcPho).fourMomentum().et());
2221  }
2222  if ( chi2Prob > 0.0005) {
2223  h_SimConvTwoMTracksAndVtxPGT0005_[0]->Fill( mcEta_ ) ;
2224  h_SimConvTwoMTracksAndVtxPGT0005_[1]->Fill( mcPhi_ );
2225  h_SimConvTwoMTracksAndVtxPGT0005_[2]->Fill( mcConvR_ );
2226  h_SimConvTwoMTracksAndVtxPGT0005_[3]->Fill( mcConvZ_ );
2227  h_SimConvTwoMTracksAndVtxPGT0005_[4]->Fill( (*mcPho).fourMomentum().et());
2228 
2229  }
2230 
2231  if ( chi2Prob > 0.0005 ) {
2232  h_convEta_[0]->Fill( aConv->caloCluster()[0]->eta() );
2233  h_convPhi_[0]->Fill( aConv->caloCluster()[0]->phi() );
2234  h_convERes_[0][0]->Fill( aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
2235  if ( ! isRunCentrally_ ) h_r9VsNofTracks_[0][0]->Fill( r9, aConv->nTracks() ) ;
2236 
2237  if ( phoIsInBarrel ) {
2238  h_convERes_[0][1]->Fill(aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
2239  if ( ! isRunCentrally_ ) h_r9VsNofTracks_[0][1]->Fill( r9, aConv->nTracks() ) ;
2240  h_mvaOut_[1]-> Fill(like);
2241  }
2242  if ( phoIsInEndcap ) {
2243  h_convERes_[0][2]->Fill(aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
2244  if ( ! isRunCentrally_ ) h_r9VsNofTracks_[0][2]->Fill( r9, aConv->nTracks() ) ;
2245  h_mvaOut_[2]-> Fill(like);
2246  }
2247 
2248  }
2249 
2250 
2251 
2252 
2253  }
2254 
2256  type =1;
2257 
2258  h_trkProv_[1]->Fill( trkProvenance );
2259  h_invMass_[type][0] ->Fill( invM);
2260 
2261 
2262 
2263  float eoverp= -99999.;
2264 
2265  if ( aConv->conversionVertex().isValid() ) {
2266  eoverp= aConv->EoverPrefittedTracks();
2267  h_convPtRes_[type][0]->Fill( refPt / (*mcPho).fourMomentum().et() );
2268  h_EoverPTracks_[type][0] ->Fill( eoverp ) ;
2269  h_PoverETracks_[type][0] ->Fill( 1./eoverp ) ;
2270  if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[0] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2271  if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[0] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e() ) ;
2272  if ( ! isRunCentrally_ ) h2_EoverPVsEta_[0]->Fill (mcEta_, eoverp);
2273  if ( ! isRunCentrally_ ) h2_EoverPVsR_[0]->Fill (mcConvR_, eoverp);
2274  p_EoverPVsEta_[0]->Fill (mcEta_, eoverp);
2275  p_EoverPVsR_[0]->Fill (mcConvR_, eoverp);
2276  p_eResVsR_ ->Fill ( mcConvR_, photonE / (*mcPho).fourMomentum().e() );
2277  if ( ! isRunCentrally_ ) h2_PoverPtrueVsEta_[0]->Fill (mcEta_,refP/ (*mcPho).fourMomentum().e() ) ;
2278  p_PoverPtrueVsEta_[0]->Fill (mcEta_,refP/ (*mcPho).fourMomentum().e() ) ;
2279 
2280 
2281  }
2282 
2283 
2284  if ( ! isRunCentrally_ ) h2_EoverEtrueVsEta_[0]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2285  if ( ! isRunCentrally_ ) h2_EoverEtrueVsR_[0]->Fill (mcConvR_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2286  p_EoverEtrueVsEta_[0]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2287  p_EoverEtrueVsR_[0]->Fill (mcConvR_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2288 
2289 
2290  if ( ! isRunCentrally_ ) h2_etaVsRsim_[0]->Fill (mcEta_,mcConvR_);
2291 
2292 
2293  reco::TrackRef track1 = tracks[0].castTo<reco::TrackRef>();
2294  reco::TrackRef track2 = tracks[1].castTo<reco::TrackRef>();
2295  reco::TransientTrack tt1 = (*theTTB).build( &track1);
2296  reco::TransientTrack tt2 = (*theTTB).build( &track2);
2298  md.calculate ( tt1.initialFreeState(), tt2.initialFreeState() );
2299  if (md.status() ) {
2300  //cout << " Min Dist " << md.distance() << std::endl;
2301  h_distMinAppTracks_[1][0]->Fill ( md.distance() );
2302  } else {
2303  nInvalidPCA_++;
2304 
2305  }
2306 
2307 
2308  // here original tracks and their inner momentum is considered
2309  float dPhiTracksAtVtx = aConv->dPhiTracksAtVtx();
2310  h_DPhiTracksAtVtx_[type][0]->Fill( dPhiTracksAtVtx);
2311  if ( ! isRunCentrally_ ) h2_DPhiTracksAtVtxVsEta_->Fill( mcEta_, dPhiTracksAtVtx);
2312  if ( ! isRunCentrally_ ) h2_DPhiTracksAtVtxVsR_->Fill( mcConvR_, dPhiTracksAtVtx);
2313  p_DPhiTracksAtVtxVsEta_->Fill( mcEta_, dPhiTracksAtVtx);
2314  p_DPhiTracksAtVtxVsR_->Fill( mcConvR_, dPhiTracksAtVtx);
2315 
2316  h_DCotTracks_[type][0] ->Fill ( aConv->pairCotThetaSeparation() );
2317  if ( ! isRunCentrally_ ) h2_DCotTracksVsEta_->Fill( mcEta_, aConv->pairCotThetaSeparation() );
2318  if ( ! isRunCentrally_ ) h2_DCotTracksVsR_->Fill( mcConvR_, aConv->pairCotThetaSeparation() );
2319  p_DCotTracksVsEta_->Fill( mcEta_, aConv->pairCotThetaSeparation() );
2320  p_DCotTracksVsR_->Fill( mcConvR_, aConv->pairCotThetaSeparation() );
2321 
2322 
2323  if ( phoIsInBarrel ) {
2324  h_invMass_[type][1] ->Fill(invM);
2325  if ( aConv->conversionVertex().isValid() ) {
2326  h_convPtRes_[type][1]->Fill( refPt / (*mcPho).fourMomentum().et() );
2327  h_EoverPTracks_[type][1] ->Fill( eoverp ) ;
2328  if ( mcConvR_ < 15 ) h_EoverPTracks_[0][0] ->Fill( eoverp ) ;
2329  if ( mcConvR_ > 15 && mcConvR_< 58 ) h_EoverPTracks_[0][1] ->Fill( eoverp ) ;
2330  if ( mcConvR_ > 58 ) h_EoverPTracks_[0][2] ->Fill( eoverp ) ;
2331  h_PoverETracks_[type][1] ->Fill( 1./eoverp ) ;
2332  if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[1] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2333  if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[1] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e() ) ;
2334  }
2335  h_DPhiTracksAtVtx_[type][1]->Fill( dPhiTracksAtVtx);
2336  h_DCotTracks_[type][1] ->Fill ( aConv->pairCotThetaSeparation() );
2337 
2338 
2339  }
2340 
2341 
2342  if ( phoIsInEndcap ) {
2343  h_invMass_[type][2] ->Fill(invM);
2344  if ( aConv->conversionVertex().isValid() ) {
2345  h_convPtRes_[type][2]->Fill( refPt / (*mcPho).fourMomentum().et() );
2346  h_EoverPTracks_[type][2] ->Fill( eoverp ) ;
2347  h_PoverETracks_[type][2] ->Fill( 1./eoverp ) ;
2348  if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[2] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e() ) ;
2349  if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[2] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e() ) ;
2350  }
2351  h_DPhiTracksAtVtx_[type][2]->Fill( dPhiTracksAtVtx);
2352  h_DCotTracks_[type][2] ->Fill ( aConv->pairCotThetaSeparation() );
2353 
2354  }
2355 
2356 
2357  if ( aConv->conversionVertex().isValid() ) {
2358 
2359  h_convVtxdX_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
2360  h_convVtxdY_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
2361  h_convVtxdZ_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
2362  h_convVtxdR_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
2363 
2364  if ( fabs( mcConvEta_ ) <= 1.2 ) {
2365  h_convVtxdX_barrel_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
2366  h_convVtxdY_barrel_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
2367  h_convVtxdZ_barrel_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
2368  h_convVtxdR_barrel_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
2369  } else {
2370  h_convVtxdX_endcap_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
2371  h_convVtxdY_endcap_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
2372  h_convVtxdZ_endcap_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
2373  h_convVtxdR_endcap_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
2374  }
2375 
2376 
2377  h_convVtxdPhi_ ->Fill ( aConv->conversionVertex().position().phi() - mcConvPhi_);
2378  h_convVtxdEta_ ->Fill ( aConv->conversionVertex().position().eta() - mcConvEta_);
2379  if ( ! isRunCentrally_ ) h2_convVtxdRVsR_ ->Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
2380  if ( ! isRunCentrally_ ) h2_convVtxdRVsEta_ ->Fill (mcEta_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
2381  p_convVtxdRVsR_ ->Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
2382  p_convVtxdRVsEta_ ->Fill (mcEta_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
2383  float signX= aConv->refittedPairMomentum().x()/fabs(aConv->refittedPairMomentum().x());
2384  float signY= aConv->refittedPairMomentum().y()/fabs(aConv->refittedPairMomentum().y());
2385  float signZ= aConv->refittedPairMomentum().z()/fabs(aConv->refittedPairMomentum().z());
2386  p_convVtxdXVsX_ ->Fill (mcConvX_, (aConv->conversionVertex().position().x() - mcConvX_)*signX );
2387  p_convVtxdYVsY_ ->Fill (mcConvY_, (aConv->conversionVertex().position().y() - mcConvY_)*signY );
2388  p_convVtxdZVsZ_ ->Fill (mcConvZ_, (aConv->conversionVertex().position().z() - mcConvZ_)*signZ );
2389 
2390 
2391  if ( ! isRunCentrally_ ) h2_convVtxRrecVsTrue_ -> Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) );
2392 
2393 
2394 
2395  } // end conversion vertex valid
2396 
2397 
2398 
2399  h_zPVFromTracks_[type]->Fill ( aConv->zOfPrimaryVertexFromTracks() );
2400  h_dzPVFromTracks_[type]->Fill ( aConv->zOfPrimaryVertexFromTracks() - (*mcPho).primaryVertex().z() );
2401  p_dzPVVsR_ ->Fill(mcConvR_, aConv->zOfPrimaryVertexFromTracks() - (*mcPho).primaryVertex().z() );
2402  if ( ! isRunCentrally_ ) h2_dzPVVsR_ ->Fill(mcConvR_, aConv->zOfPrimaryVertexFromTracks() - (*mcPho).primaryVertex().z() );
2403 
2404 
2405  float dPhiTracksAtEcal=-99;
2406  float dEtaTracksAtEcal=-99;
2407  if (aConv->bcMatchingWithTracks()[0].isNonnull() && aConv->bcMatchingWithTracks()[1].isNonnull() ) {
2408  nRecConvAssWithEcal_++;
2409  float recoPhi1 = aConv->ecalImpactPosition()[0].phi();
2410  float recoPhi2 = aConv->ecalImpactPosition()[1].phi();
2411  float recoEta1 = aConv->ecalImpactPosition()[0].eta();
2412  float recoEta2 = aConv->ecalImpactPosition()[1].eta();
2413  float bcPhi1 = aConv->bcMatchingWithTracks()[0]->phi();
2414  float bcPhi2 = aConv->bcMatchingWithTracks()[1]->phi();
2415  // unused float bcEta1 = aConv->bcMatchingWithTracks()[0]->eta();
2416  // unused float bcEta2 = aConv->bcMatchingWithTracks()[1]->eta();
2417  recoPhi1 = phiNormalization(recoPhi1);
2418  recoPhi2 = phiNormalization(recoPhi2);
2419  bcPhi1 = phiNormalization(bcPhi1);
2420  bcPhi2 = phiNormalization(bcPhi2);
2421  dPhiTracksAtEcal = recoPhi1 -recoPhi2;
2422  dPhiTracksAtEcal = phiNormalization( dPhiTracksAtEcal );
2423  dEtaTracksAtEcal = recoEta1 -recoEta2;
2424 
2425 
2426  h_DPhiTracksAtEcal_[type][0]->Fill( fabs(dPhiTracksAtEcal));
2427  if ( ! isRunCentrally_ ) h2_DPhiTracksAtEcalVsR_ ->Fill (mcConvR_, fabs(dPhiTracksAtEcal));
2428  if ( ! isRunCentrally_ ) h2_DPhiTracksAtEcalVsEta_ ->Fill (mcEta_, fabs(dPhiTracksAtEcal));
2429  p_DPhiTracksAtEcalVsR_ ->Fill (mcConvR_, fabs(dPhiTracksAtEcal));
2430  p_DPhiTracksAtEcalVsEta_ ->Fill (mcEta_, fabs(dPhiTracksAtEcal));
2431 
2432  h_DEtaTracksAtEcal_[type][0]->Fill( dEtaTracksAtEcal);
2433 
2434  if ( phoIsInBarrel ) {
2435  h_DPhiTracksAtEcal_[type][1]->Fill( fabs(dPhiTracksAtEcal));
2436  h_DEtaTracksAtEcal_[type][1]->Fill( dEtaTracksAtEcal);
2437  }
2438  if ( phoIsInEndcap ) {
2439  h_DPhiTracksAtEcal_[type][2]->Fill( fabs(dPhiTracksAtEcal));
2440  h_DEtaTracksAtEcal_[type][2]->Fill( dEtaTracksAtEcal);
2441  }
2442 
2443  }
2444 
2445 
2446 
2447 
2449  for (unsigned int i=0; i<tracks.size(); i++) {
2450  reco::TrackRef track = tracks[i].castTo<reco::TrackRef>();
2451  itAss= myAss.find( track );
2452  if ( itAss == myAss.end() ) continue;
2453 
2454  float trkProvenance=3;
2455  if ( tracks[0]->algoName() == "outInEcalSeededConv" && tracks[1]->algoName() == "outInEcalSeededConv" ) trkProvenance=0;
2456  if ( tracks[0]->algoName() == "inOutEcalSeededConv" && tracks[1]->algoName() == "inOutEcalSeededConv" ) trkProvenance=1;
2457  if ( ( tracks[0]->algoName() == "outInEcalSeededConv" && tracks[1]->algoName() == "inOutEcalSeededConv") ||
2458  ( tracks[1]->algoName() == "outInEcalSeededConv" && tracks[0]->algoName() == "inOutEcalSeededConv") ) trkProvenance=2;
2459 
2460 
2461  if ( ! isRunCentrally_ ) nHitsVsEta_[type] ->Fill (mcEta_, float(tracks[i]->numberOfValidHits()) );
2462  if ( ! isRunCentrally_ ) nHitsVsR_[type] ->Fill (mcConvR_, float(tracks[i]->numberOfValidHits()) );
2463  p_nHitsVsEta_[type] ->Fill (mcEta_, float(tracks[i]->numberOfValidHits()) -0.0001);
2464  p_nHitsVsR_[type] ->Fill (mcConvR_, float(tracks[i]->numberOfValidHits()) -0.0001);
2465  h_tkChi2_[type] ->Fill (tracks[i]->normalizedChi2() );
2466  h_tkChi2Large_[type] ->Fill (tracks[i]->normalizedChi2() );
2467  if ( ! isRunCentrally_ ) h2_Chi2VsEta_[0] ->Fill( mcEta_, tracks[i]->normalizedChi2() );
2468  if ( ! isRunCentrally_ ) h2_Chi2VsR_[0] ->Fill( mcConvR_, tracks[i]->normalizedChi2() );
2469  p_Chi2VsEta_[0] ->Fill( mcEta_, tracks[i]->normalizedChi2() );
2470  p_Chi2VsR_[0] ->Fill( mcConvR_, tracks[i]->normalizedChi2() );
2471 
2472 
2473  float simPt = sqrt( ((*itAss).second)->momentum().perp2() );
2474  // float recPt = sqrt( aConv->tracks()[i]->innerMomentum().Perp2() ) ;
2475  float refPt=-9999.;
2476  float px=0, py=0;
2477 
2478  if ( aConv->conversionVertex().isValid() ) {
2479  reco::Track refTrack= aConv->conversionVertex().refittedTracks()[i];
2480  px= refTrack.momentum().x() ;
2481  py= refTrack.momentum().y() ;
2482  refPt=sqrt (px*px + py*py );
2483 
2484  float ptres= refPt - simPt ;
2485  // float pterror = aConv->tracks()[i]->ptError();
2486  float pterror = aConv->conversionVertex().refittedTracks()[i].ptError();
2487  if ( ! isRunCentrally_ ) {
2488  h2_PtRecVsPtSim_[0]->Fill ( simPt, refPt);
2489  if ( trkProvenance ==3 ) h2_PtRecVsPtSimMixProv_->Fill ( simPt, refPt);
2490  }
2491 
2492  h_TkPtPull_[0] ->Fill(ptres/pterror);
2493  if ( ! isRunCentrally_ ) h2_TkPtPull_[0] ->Fill(mcEta_, ptres/pterror);
2494 
2495  h_TkD0_[0]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
2496 
2497 
2498  if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[0]->Fill ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2()) );
2499 
2500  if ( phoIsInBarrel ) {
2501  h_TkD0_[1]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
2502  h_TkPtPull_[1] ->Fill(ptres/pterror);
2503  if ( ! isRunCentrally_ ) h2_PtRecVsPtSim_[1]->Fill ( simPt, refPt);
2504  if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[1]->Fill ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2()) );
2505 
2506  }
2507  if ( phoIsInEndcap ) {
2508  h_TkD0_[2]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
2509  h_TkPtPull_[2] ->Fill(ptres/pterror);
2510  if ( ! isRunCentrally_ ) h2_PtRecVsPtSim_[2]->Fill ( simPt, refPt);
2511  if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[2]->Fill ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2()) );
2512  }
2513 
2514  }
2515 
2516  } // end loop over track
2517  } // end analysis of two associated tracks
2518  } // end analysis of two tracks
2519 
2520  } // loop over conversions
2521  } // if !fastSim
2522  } // End loop over generated particles
2523  } // End loop over simulated Photons
2524 
2525 
2526 
2527 
2528  h_nSimPho_[0]->Fill(float(nSimPho_[0]));
2529  h_nSimPho_[1]->Fill(float(nSimPho_[1]));
2530  h_nSimConv_[0]->Fill(float(nSimConv_[0]));
2531  h_nSimConv_[1]->Fill(float(nSimConv_[1]));
2532 
2533 
2534  if ( !fastSim_) {
2536  for( reco::PhotonCollection::const_iterator iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
2537  reco::Photon aPho = reco::Photon(*iPho);
2538  // float et= aPho.superCluster()->energy()/cosh( aPho.superCluster()->eta()) ;
2540  for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
2541  reco::ConversionRef aConv=conversions[iConv];
2542  double like = aConv->MVAout();
2543  if ( like < likelihoodCut_ ) continue;
2544  //std::vector<reco::TrackRef> tracks = aConv->tracks();
2545  const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
2546  if (tracks.size() < 2 ) continue;
2547 
2548  bool phoIsInBarrel=false;
2549  bool phoIsInEndcap=false;
2550  if ( fabs(aConv->caloCluster()[0]->eta() ) < 1.479 ) {
2551  phoIsInBarrel=true;
2552  } else {
2553  phoIsInEndcap=true;
2554  }
2555 
2556 
2557  if ( dCotCutOn_ ) {
2558  if ( ( fabs(mcEta_) > 1.1 && fabs (mcEta_) < 1.4 ) &&
2559  fabs( aConv->pairCotThetaSeparation() ) > dCotHardCutValue_ ) continue;
2560  if ( fabs( aConv->pairCotThetaSeparation() ) > dCotCutValue_ ) continue;
2561  }
2562 
2563 
2564  h_RecoConvTwoTracks_[0]->Fill( aPho.eta() ) ;
2565  h_RecoConvTwoTracks_[1]->Fill( aPho.phi() );
2566  if ( aConv->conversionVertex().isValid() ) h_RecoConvTwoTracks_[2]->Fill( aConv->conversionVertex().position().perp2() );
2567  h_RecoConvTwoTracks_[3]->Fill( aConv->conversionVertex().position().z() );
2568  h_RecoConvTwoTracks_[4]->Fill( aPho.et() ) ;
2569 
2570 
2571 
2572  int nAssT2=0;
2573 
2574  std::map<reco::TrackRef,TrackingParticleRef> myAss;
2575  for (unsigned int i=0; i<tracks.size(); i++) {
2576  reco::TrackRef track = tracks[i].castTo<reco::TrackRef>();
2577 
2578  TrackingParticleRef myTP;
2579  for (size_t j = 0; j < RtoSCollPtrs.size(); j++) {
2580  reco::RecoToSimCollection q = *(RtoSCollPtrs[j]);
2581 
2582  RefToBase<reco::Track> myTk( track );
2583 
2584  if( q.find(myTk ) != q.end() ) {
2585  std::vector<std::pair<TrackingParticleRef, double> > tp = q[myTk];
2586  for (unsigned int itp=0; itp<tp.size(); itp++) {
2587  myTP=tp[itp].first;
2588  // std::cout << " associated with TP " << myTP->pdgId() << " pt " << sqrt(myTP->momentum().perp2()) << std::endl;
2589  myAss.insert( std::make_pair ( track , myTP) );
2590  nAssT2++;
2591  }
2592  }
2593  }
2594 
2595  if ( nAssT2 == 2) {
2596 
2597 
2598  h_RecoConvTwoMTracks_[0]->Fill( aPho.eta() ) ;
2599  h_RecoConvTwoMTracks_[1]->Fill( aPho.phi() );
2600  if ( aConv->conversionVertex().isValid() ) h_RecoConvTwoMTracks_[2]->Fill( aConv->conversionVertex().position().perp2() );
2601  h_RecoConvTwoMTracks_[3]->Fill( aConv->conversionVertex().position().z() );
2602  h_RecoConvTwoMTracks_[4]->Fill( aPho.et() ) ;
2603 
2604  }
2605  }
2606 
2608  if ( aConv->conversionVertex().isValid() ) {
2609  float chi2Prob = ChiSquaredProbability( aConv->conversionVertex().chi2(), aConv->conversionVertex().ndof() );
2610 
2611  double convR= sqrt(aConv->conversionVertex().position().perp2());
2612  double scalar = aConv->conversionVertex().position().x()*aConv->pairMomentum().x() +
2613  aConv->conversionVertex().position().y()*aConv->pairMomentum().y();
2614  if ( scalar < 0 ) convR= -sqrt(aConv->conversionVertex().position().perp2());
2615 
2616  if ( ! isRunCentrally_ ) h2_etaVsRreco_[0]->Fill (aConv->caloCluster()[0]->eta(),sqrt(aConv->conversionVertex().position().perp2()) );
2617  h_convVtxRvsZ_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ), sqrt(aConv->conversionVertex().position().perp2()) ) ;
2618  if ( fabs(aConv->caloCluster()[0]->eta() ) <= 1.) {
2619 
2620  h_convVtxYvsX_ ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x() ) ;
2621  h_convVtxRvsZ_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ), convR ) ;
2622 
2623  if ( ! isRunCentrally_ ) {
2624  h_convVtxYvsX_zoom_[0] ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x() ) ;
2625  h_convVtxYvsX_zoom_[1] ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x() ) ;
2626  h_convVtxRvsZ_zoom_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ), convR ) ;
2627  h_convVtxRvsZ_zoom_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ), convR ) ;
2628  }
2629 
2630  }
2631  if ( fabs(aConv->caloCluster()[0]->eta() ) > 1.) h_convVtxRvsZ_[2] ->Fill ( fabs (aConv->conversionVertex().position().z() ), convR ) ;
2632 
2633 
2634 
2635 
2636  h_vtxChi2Prob_[0]->Fill( chi2Prob );
2637  h_vtxChi2_[0]->Fill( aConv->conversionVertex().normalizedChi2() );
2638  if ( phoIsInBarrel ) {
2639  h_vtxChi2Prob_[1]->Fill( chi2Prob );
2640  h_vtxChi2_[1]->Fill( aConv->conversionVertex().normalizedChi2() );
2641  }
2642  if ( phoIsInEndcap ) {
2643  h_vtxChi2Prob_[2]->Fill( chi2Prob );
2644  h_vtxChi2_[2]->Fill( aConv->conversionVertex().normalizedChi2() );
2645  }
2646 
2647  } // end conversion vertex valid
2648  } // end loop over reco conversions
2649  } // end loop on all reco photons
2650  } // if !fastSim
2651 
2652 
2653 
2655  float nPho=0;
2656  for (reco::GenJetCollection::const_iterator genJetIter = genJetCollection.begin();
2657  genJetIter != genJetCollection.end(); ++genJetIter) {
2658 
2659  if ( genJetIter->pt() < minPhoEtCut_ ) continue;
2660  if ( fabs(genJetIter->eta()) > 2.5 ) continue;
2661 
2662  float mcJetPhi= genJetIter->phi();
2663  mcJetPhi_= phiNormalization(mcJetPhi);
2664  mcJetEta_= genJetIter->eta();
2665  float mcJetPt = genJetIter->pt() ;
2666 
2667  h_SimJet_[0]->Fill ( mcJetEta_);
2668  h_SimJet_[1]->Fill ( mcJetPhi_);
2669  h_SimJet_[2]->Fill ( mcJetPt );
2670 
2671  std::vector<reco::Photon> thePhotons;
2672  bool matched=false;
2673 
2674  reco::Photon matchingPho;
2675  for( reco::PhotonCollection::const_iterator iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
2676  reco::Photon aPho = reco::Photon(*iPho);
2677  float phiPho=aPho.phi();
2678  float etaPho=aPho.eta();
2679  float deltaPhi = phiPho-mcJetPhi_;
2680  float deltaEta = etaPho-mcJetEta_;
2681  if ( deltaPhi > pi ) deltaPhi -= twopi;
2682  if ( deltaPhi < -pi) deltaPhi += twopi;
2683  deltaPhi=pow(deltaPhi,2);
2684  deltaEta=pow(deltaEta,2);
2685  float delta = sqrt( deltaPhi+deltaEta);
2686  if ( delta<0.3 ) {
2687  matchingPho = * iPho;
2688  matched = true;
2689  }
2690  } // end loop over reco photons
2691 
2692  if (! matched ) continue;
2693  nPho++;
2694 
2695  h_MatchedSimJet_[0]->Fill( mcJetEta_ ) ;
2696  h_MatchedSimJet_[1]->Fill( mcJetPhi_ );
2697  h_MatchedSimJet_[2]->Fill( mcJetPt );
2698 
2699 
2700  bool phoIsInBarrel=false;
2701  bool phoIsInEndcap=false;
2702  if ( fabs(matchingPho.superCluster()->position().eta() ) < 1.479 ) {
2703  phoIsInBarrel=true;
2704  } else {
2705  phoIsInEndcap=true;
2706  }
2707  edm::Handle<EcalRecHitCollection> ecalRecHitHandle;
2708  if ( phoIsInBarrel ) {
2709  // Get handle to rec hits ecal barrel
2710  e.getByLabel(barrelEcalHits_, ecalRecHitHandle);
2711  if (!ecalRecHitHandle.isValid()) {
2712  edm::LogError("PhotonProducer") << "Error! Can't get the product "<<barrelEcalHits_.label();
2713  return;
2714  }
2715 
2716  } else if ( phoIsInEndcap ) {
2717 
2718  // Get handle to rec hits ecal encap
2719  e.getByLabel(endcapEcalHits_, ecalRecHitHandle);
2720  if (!ecalRecHitHandle.isValid()) {
2721  edm::LogError("PhotonProducer") << "Error! Can't get the product "<<endcapEcalHits_.label();
2722  return;
2723  }
2724 
2725  }
2726 
2727 
2728 
2729  const EcalRecHitCollection ecalRecHitCollection = *(ecalRecHitHandle.product());
2730  float photonE = matchingPho.energy();
2731  float photonEt= matchingPho.et();
2732  float r9 = matchingPho.r9();
2733  float r1 = matchingPho.r1x5();
2734  float r2 = matchingPho.r2x5();
2735  float sigmaIetaIeta = matchingPho.sigmaIetaIeta();
2736  float hOverE = matchingPho.hadronicOverEm();
2737  float ecalIso = matchingPho.ecalRecHitSumEtConeDR04();
2738  float hcalIso = matchingPho.hcalTowerSumEtConeDR04();
2739  float trkIso = matchingPho.trkSumPtSolidConeDR04();
2740  float nIsoTrk = matchingPho.nTrkSolidConeDR04();
2741  std::vector< std::pair<DetId, float> >::const_iterator rhIt;
2742 
2743  bool atLeastOneDeadChannel=false;
2744  for(reco::CaloCluster_iterator bcIt = matchingPho.superCluster()->clustersBegin();bcIt != matchingPho.superCluster()->clustersEnd(); ++bcIt) {
2745  for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
2746 
2747  for(EcalRecHitCollection::const_iterator it = ecalRecHitCollection.begin(); it != ecalRecHitCollection.end(); ++it) {
2748  if (rhIt->first == (*it).id() ) {
2749  if ( (*it).recoFlag() == 9 ) {
2750  atLeastOneDeadChannel=true;
2751  break;
2752  }
2753  }
2754  }
2755  }
2756  }
2757 
2758  if ( atLeastOneDeadChannel ) {
2759  h_MatchedSimJetBadCh_[0]->Fill( mcJetEta_ ) ;
2760  h_MatchedSimJetBadCh_[1]->Fill( mcJetPhi_ );
2761  h_MatchedSimJetBadCh_[2]->Fill( mcJetPt );
2762 
2763  }
2764 
2765  h_scBkgEta_->Fill( matchingPho.superCluster()->eta() );
2766  h_scBkgPhi_->Fill( matchingPho.superCluster()->phi() );
2767  h_scBkgE_[0]->Fill( matchingPho.superCluster()->energy() );
2768  h_scBkgEt_[0]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
2769  //
2770  h_phoBkgEta_->Fill( matchingPho.eta() );
2771  h_phoBkgPhi_->Fill( matchingPho.phi() );
2772  h_phoBkgE_[0]->Fill( photonE );
2773  h_phoBkgEt_[0]->Fill( photonEt);
2774  h_phoBkgDEta_->Fill ( matchingPho.eta() - mcJetEta_ );
2775  h_phoBkgDPhi_->Fill ( matchingPho.phi() - mcJetPhi_ );
2776 
2777 
2778  h_r9Bkg_[0]->Fill( r9 );
2779  h_r1Bkg_[0]->Fill( r1 );
2780  h_r2Bkg_[0]->Fill( r2 );
2781  h_sigmaIetaIetaBkg_[0]->Fill( sigmaIetaIeta );
2782  h_hOverEBkg_[0]->Fill( hOverE );
2783  h_ecalRecHitSumEtConeDR04Bkg_[0]->Fill( ecalIso );
2784  h_hcalTowerSumEtConeDR04Bkg_[0]->Fill( hcalIso );
2785  h_isoTrkSolidConeDR04Bkg_[0]->Fill( trkIso );
2786  h_nTrkSolidConeDR04Bkg_[0]->Fill( nIsoTrk );
2787 
2788 
2789  h2_r9VsEtaBkg_ -> Fill (mcJetEta_, r9);
2790  h2_r9VsEtBkg_ -> Fill (mcJetPt, r9);
2791 
2792  h2_r1VsEtaBkg_ -> Fill (mcJetEta_, r1);
2793  h2_r1VsEtBkg_ -> Fill (mcJetPt, r1);
2794  p_r1VsEtaBkg_ -> Fill (mcJetEta_, r1);
2795  p_r1VsEtBkg_ -> Fill (mcJetPt, r1);
2796 
2797  h2_r2VsEtaBkg_ -> Fill (mcJetEta_, r2);
2798  h2_r2VsEtBkg_ -> Fill (mcJetPt, r2);
2799  p_r2VsEtaBkg_ -> Fill (mcJetEta_, r2);
2800  p_r2VsEtBkg_ -> Fill (mcJetPt, r2);
2801 
2802 
2803  h2_sigmaIetaIetaVsEtaBkg_ -> Fill (mcJetEta_, sigmaIetaIeta );
2804  p_sigmaIetaIetaVsEtaBkg_ -> Fill (mcJetEta_, sigmaIetaIeta );
2805  h2_sigmaIetaIetaVsEtBkg_[0] -> Fill (mcJetPt, sigmaIetaIeta);
2806  p_sigmaIetaIetaVsEtBkg_[0] -> Fill (mcJetPt, sigmaIetaIeta);
2807 
2808 
2809  h2_hOverEVsEtaBkg_ -> Fill (mcJetEta_, hOverE );
2810  h2_hOverEVsEtBkg_ -> Fill (mcJetPt, hOverE);
2811  p_hOverEVsEtaBkg_ -> Fill (mcJetEta_, hOverE );
2812  p_hOverEVsEtBkg_ -> Fill (mcJetPt, hOverE);
2813 
2814 
2815  h2_ecalRecHitSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, ecalIso );
2816  p_ecalRecHitSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, ecalIso );
2817  h2_ecalRecHitSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, ecalIso);
2818  p_ecalRecHitSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, ecalIso);
2819 
2820 
2821  h2_hcalTowerSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, hcalIso );
2822  p_hcalTowerSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, hcalIso );
2823  h2_hcalTowerSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, hcalIso);
2824  p_hcalTowerSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, hcalIso);
2825 
2826  h2_isoTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, trkIso );
2827  p_isoTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, trkIso );
2828  h2_isoTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, trkIso);
2829  p_isoTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, trkIso);
2830 
2831 
2832  h2_nTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, nIsoTrk );
2833  p_nTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, nIsoTrk );
2834  h2_nTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, nIsoTrk);
2835  p_nTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, nIsoTrk);
2836 
2837 
2838 
2839 
2840  if ( phoIsInBarrel ) {
2841 
2842  h_r9Bkg_[1]->Fill( r9 );
2843  h_r1Bkg_[1]->Fill( r1 );
2844  h_r2Bkg_[1]->Fill( r2 );
2845 
2846 
2847  h_sigmaIetaIetaBkg_[1]->Fill( sigmaIetaIeta );
2848  h_hOverEBkg_[1]->Fill( hOverE );
2849  h_ecalRecHitSumEtConeDR04Bkg_[1]->Fill( ecalIso );
2850  h_hcalTowerSumEtConeDR04Bkg_[1]->Fill( hcalIso );
2851  h_isoTrkSolidConeDR04Bkg_[1]->Fill( trkIso );
2852  h_nTrkSolidConeDR04Bkg_[1]->Fill( nIsoTrk );
2853 
2854  h2_sigmaIetaIetaVsEtBkg_[1] -> Fill (mcJetPt, sigmaIetaIeta);
2855  p_sigmaIetaIetaVsEtBkg_[1] -> Fill (mcJetPt, sigmaIetaIeta);
2856 
2857  h2_ecalRecHitSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, ecalIso);
2858  p_ecalRecHitSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, ecalIso);
2859 
2860  h2_hcalTowerSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, hcalIso);
2861  p_hcalTowerSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, hcalIso);
2862 
2863  h2_isoTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, trkIso);
2864  p_isoTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, trkIso);
2865 
2866  h2_nTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, nIsoTrk);
2867  p_nTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, nIsoTrk);
2868 
2869 
2870  } else if ( phoIsInEndcap ) {
2871 
2872  h_r9Bkg_[2]->Fill( r9 );
2873  h_r1Bkg_[2]->Fill( r1 );
2874  h_r2Bkg_[2]->Fill( r2 );
2875 
2876  h_sigmaIetaIetaBkg_[2]->Fill( sigmaIetaIeta );
2877  h_hOverEBkg_[2]->Fill( hOverE );
2878  h_ecalRecHitSumEtConeDR04Bkg_[2]->Fill( ecalIso );
2879  h_hcalTowerSumEtConeDR04Bkg_[2]->Fill( hcalIso );
2880  h_isoTrkSolidConeDR04Bkg_[2]->Fill( trkIso );
2881  h_nTrkSolidConeDR04Bkg_[2]->Fill( nIsoTrk );
2882 
2883  h2_sigmaIetaIetaVsEtBkg_[2] -> Fill (mcJetPt, sigmaIetaIeta);
2884  p_sigmaIetaIetaVsEtBkg_[2] -> Fill (mcJetPt, sigmaIetaIeta);
2885 
2886  h2_ecalRecHitSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, ecalIso);
2887  p_ecalRecHitSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, ecalIso);
2888 
2889  h2_hcalTowerSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, hcalIso);
2890  p_hcalTowerSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, hcalIso);
2891 
2892  h2_isoTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, trkIso);
2893  p_isoTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, trkIso);
2894 
2895  h2_nTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, nIsoTrk);
2896  p_nTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, nIsoTrk);
2897 
2898 
2899  }
2900 
2901  if ( !fastSim_) {
2904  for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
2905  reco::ConversionRef aConv=conversions[iConv];
2906  //std::vector<reco::TrackRef> tracks = aConv->tracks();
2907  const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
2908  double like = aConv->MVAout();
2909  if ( like < likelihoodCut_ ) continue;
2910  if ( tracks.size() < 2 ) continue;
2911  h_convEtaBkg_->Fill( aConv->caloCluster()[0]->eta() );
2912  h_convPhiBkg_->Fill( aConv->caloCluster()[0]->phi() );
2913  h_mvaOutBkg_[0]-> Fill(like);
2914  float eoverp= aConv->EoverP();
2915  h_EoverPTracksBkg_[0] ->Fill( eoverp ) ;
2916  h_PoverETracksBkg_[0] ->Fill( 1./eoverp ) ;
2917  h_DCotTracksBkg_[0] ->Fill ( aConv->pairCotThetaSeparation() );
2918  float dPhiTracksAtVtx = aConv->dPhiTracksAtVtx();
2919  h_DPhiTracksAtVtxBkg_[0]->Fill( dPhiTracksAtVtx);
2920 
2921  if ( phoIsInBarrel ) {
2922  h_mvaOutBkg_[1]-> Fill(like);
2923  h_EoverPTracksBkg_[1] ->Fill( eoverp ) ;
2924  h_PoverETracksBkg_[1] ->Fill( 1./eoverp ) ;
2925  h_DCotTracksBkg_[1] ->Fill ( aConv->pairCotThetaSeparation() );
2926  h_DPhiTracksAtVtxBkg_[1]->Fill( dPhiTracksAtVtx);
2927  } else if ( phoIsInEndcap ) {
2928  h_mvaOutBkg_[2]-> Fill(like);
2929  h_EoverPTracksBkg_[2] ->Fill( eoverp ) ;
2930  h_PoverETracksBkg_[2] ->Fill( 1./eoverp ) ;
2931  h_DCotTracksBkg_[2] ->Fill ( aConv->pairCotThetaSeparation() );
2932  h_DPhiTracksAtVtxBkg_[2]->Fill( dPhiTracksAtVtx);
2933  }
2934 
2935  if ( aConv->conversionVertex().isValid() ) {
2936 
2937  double convR= sqrt(aConv->conversionVertex().position().perp2());
2938  double scalar = aConv->conversionVertex().position().x()*aConv->pairMomentum().x() +
2939  aConv->conversionVertex().position().y()*aConv->pairMomentum().y();
2940  if ( scalar < 0 ) convR= -sqrt(aConv->conversionVertex().position().perp2());
2941 
2942  if ( ! isRunCentrally_ ) {
2943  h_convVtxRvsZBkg_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ), sqrt(aConv->conversionVertex().position().perp2()) ) ;
2944  if ( fabs(aConv->caloCluster()[0]->eta() ) <= 1.) {
2945  h_convVtxYvsXBkg_ ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x() ) ;
2946  h_convVtxRvsZBkg_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ), convR ) ;
2947  }
2948  }
2949 
2950 
2951  } // end vertex valid
2952 
2953 
2954  } // end loop over conversions
2955  } // if !fastSim
2956  } // end loop over sim jets
2957 
2958  h_nPho_->Fill(float(nPho));
2959 
2960 }
2961 
2962 
2963 
2964 
2965 
2967 
2968 
2969  std::string outputFileName = parameters_.getParameter<std::string>("OutputFileName");
2970  if ( ! isRunCentrally_ ) {
2971  dbe_->save(outputFileName);
2972  }
2973 
2974  edm::LogInfo("PhotonValidator") << "Analyzed " << nEvt_ << "\n";
2975  // std::cout << "::endJob Analyzed " << nEvt_ << " events " << " with total " << nPho_ << " Photons " << "\n";
2976  // std::cout << "PhotonValidator::endJob Analyzed " << nEvt_ << " events " << "\n";
2977 
2978  return ;
2979 }
2980 
2982 {
2983  //---Definitions
2984  const float PI = 3.1415927;
2985  const float TWOPI = 2.0*PI;
2986 
2987 
2988  if(phi > PI) {phi = phi - TWOPI;}
2989  if(phi < -PI) {phi = phi + TWOPI;}
2990 
2991  // cout << " Float_t PHInormalization out " << PHI << endl;
2992  return phi;
2993 
2994 }
2995 
2996 
2997 float PhotonValidator::etaTransformation( float EtaParticle , float Zvertex) {
2998 
2999  //---Definitions
3000  const float PI = 3.1415927;
3001 
3002  //---Definitions for ECAL
3003  const float R_ECAL = 136.5;
3004  const float Z_Endcap = 328.0;
3005  const float etaBarrelEndcap = 1.479;
3006 
3007  //---ETA correction
3008 
3009  float Theta = 0.0 ;
3010  float ZEcal = R_ECAL*sinh(EtaParticle)+Zvertex;
3011 
3012  if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
3013  if(Theta<0.0) Theta = Theta+PI ;
3014  float ETA = - log(tan(0.5*Theta));
3015 
3016  if( fabs(ETA) > etaBarrelEndcap )
3017  {
3018  float Zend = Z_Endcap ;
3019  if(EtaParticle<0.0 ) Zend = -Zend ;
3020  float Zlen = Zend - Zvertex ;
3021  float RR = Zlen/sinh(EtaParticle);
3022  Theta = atan(RR/Zend);
3023  if(Theta<0.0) Theta = Theta+PI ;
3024  ETA = - log(tan(0.5*Theta));
3025  }
3026  //---Return the result
3027  return ETA;
3028  //---end
3029 }
3030 
3031 
virtual float distance() const
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:245
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
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:149
virtual ~PhotonValidator()
reco::SuperClusterRef superCluster() const
Retrieve photonCore attributes.
Definition: Photon.h:54
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:519
#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:1883
float trkSumPtSolidConeDR04() const
Definition: Photon.h:251
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 TWOPI
EgammaCoreTools.
float ecalRecHitSumEtConeDR04() const
Definition: Photon.h:243
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:248
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:60
float phiNormalization(float &a)
T sqrt(T t)
Definition: SSEVec.h:28
float sigmaIetaIeta() const
Definition: Photon.h:167
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
int j
Definition: DBlmapReader.cc:9
float ChiSquaredProbability(double chiSquared, double nrDOF)
tuple pset
Definition: CrabTask.py:85
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:833
virtual void endJob()
float hadronicOverEm() const
the total hadronic over electromagnetic fraction
Definition: Photon.h:154
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
float r1x5() const
Definition: Photon.h:168
DQMStore * dbe_
const_iterator end() const
FreeTrajectoryState initialFreeState() const
virtual bool status() const
Log< T >::type log(const T &t)
Definition: Log.h:22
void insert(const key_type &k, const data_type &v)
insert an association
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
int nTrkSolidConeDR04() const
Definition: Photon.h:255
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:169
edm::EventID id() const
Definition: EventBase.h:56
float r9() const
Definition: Photon.h:170
static const float R_ECAL
size_type size() const
Size of the RefVector.
Definition: RefVector.h:85
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:647
virtual double phi() const
momentum azimuthal angle
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:237
const_iterator begin() const
Definition: Run.h:31
virtual void endRun(edm::Run &r, edm::EventSetup const &es)
PhotonValidator(const edm::ParameterSet &)
Definition: DDAxes.h:10