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