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