CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/Validation/RecoEgamma/plugins/PhotonValidator.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 //
00003 #include "FWCore/ServiceRegistry/interface/Service.h"
00004 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00005 //
00006 #include "Validation/RecoEgamma/plugins/PhotonValidator.h"
00007 
00008 //
00009 #include "FWCore/Framework/interface/MakerMacros.h"
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 #include "FWCore/Utilities/interface/Exception.h"
00012 //
00013 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00014 #include "SimDataFormats/Track/interface/SimTrack.h"
00015 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00016 #include "SimDataFormats/Vertex/interface/SimVertex.h"
00017 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
00018 //
00019 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h"
00020 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
00021 #include "SimDataFormats/TrackingAnalysis/interface/TrackingVertexContainer.h"
00022 //
00023 #include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h"
00024 #include "SimTracker/Records/interface/TrackAssociatorRecord.h"
00025 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00026 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00027 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00028 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00029 //
00030 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00031 #include "TrackingTools/PatternTools/interface/TwoTrackMinimumDistance.h"
00032 #include "TrackingTools/TransientTrack/interface/TrackTransientTrack.h"
00033 //
00034 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
00035 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
00036 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00037 #include "CommonTools/Statistics/interface/ChiSquaredProbability.h"
00038 
00039 //
00040 #include "DataFormats/Common/interface/Handle.h"
00041 #include "DataFormats/TrackReco/interface/Track.h"
00042 #include "DataFormats/TrackReco/interface/TrackExtra.h"
00043 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00044 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
00045 #include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
00046 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00047 #include "DataFormats/TrackCandidate/interface/TrackCandidateCollection.h"
00048 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
00049 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00050 #include "DataFormats/VertexReco/interface/Vertex.h"
00051 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00052 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00053 #include "DataFormats/CaloRecHit/interface/CaloCluster.h"
00054 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
00055 #include "DataFormats/DetId/interface/DetId.h"
00056 #include "DataFormats/JetReco/interface/GenJetCollection.h"
00057 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00058 #include "DataFormats/VertexReco/interface/Vertex.h"
00059 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00060 
00061 //
00062 #include "RecoEgamma/EgammaMCTools/interface/PhotonMCTruthFinder.h"
00063 #include "RecoEgamma/EgammaMCTools/interface/PhotonMCTruth.h"
00064 #include "RecoEgamma/EgammaMCTools/interface/ElectronMCTruth.h"
00065 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h"
00066 #include "RecoCaloTools/MetaCollections/interface/CaloRecHitMetaCollections.h"
00067 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00068 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00069 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
00070 //
00071 //#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00072 //
00073 #include "TFile.h"
00074 #include "TH1.h"
00075 #include "TH2.h"
00076 #include "TTree.h"
00077 #include "TVector3.h"
00078 #include "TProfile.h"
00079 //
00090 using namespace std;
00091 
00092 
00093 PhotonValidator::PhotonValidator( const edm::ParameterSet& pset )
00094   {
00095 
00096     fName_     = pset.getUntrackedParameter<std::string>("Name");
00097     verbosity_ = pset.getUntrackedParameter<int>("Verbosity");
00098     parameters_ = pset;
00099     fastSim_ =   pset.getParameter<bool>("fastSim");
00100     isRunCentrally_=   pset.getParameter<bool>("isRunCentrally");
00101 
00102 
00103     photonCollectionProducer_ = pset.getParameter<std::string>("phoProducer");
00104     photonCollection_ = pset.getParameter<std::string>("photonCollection");
00105 
00106 
00107     label_tp_   = pset.getParameter<edm::InputTag>("label_tp");
00108 
00109     barrelEcalHits_   = pset.getParameter<edm::InputTag>("barrelEcalHits");
00110     endcapEcalHits_   = pset.getParameter<edm::InputTag>("endcapEcalHits");
00111 
00112     conversionOITrackProducer_ = pset.getParameter<std::string>("conversionOITrackProducer");
00113     conversionIOTrackProducer_ = pset.getParameter<std::string>("conversionIOTrackProducer");
00114 
00115 
00116     minPhoEtCut_ = pset.getParameter<double>("minPhoEtCut");
00117     convTrackMinPtCut_ = pset.getParameter<double>("convTrackMinPtCut");
00118     likelihoodCut_ = pset.getParameter<double>("likelihoodCut");
00119 
00120     trkIsolExtRadius_ = pset.getParameter<double>("trkIsolExtR");
00121     trkIsolInnRadius_ = pset.getParameter<double>("trkIsolInnR");
00122     trkPtLow_     = pset.getParameter<double>("minTrackPtCut");
00123     lip_       = pset.getParameter<double>("lipCut");
00124     ecalIsolRadius_ = pset.getParameter<double>("ecalIsolR");
00125     bcEtLow_     = pset.getParameter<double>("minBcEtCut");
00126     hcalIsolExtRadius_ = pset.getParameter<double>("hcalIsolExtR");
00127     hcalIsolInnRadius_ = pset.getParameter<double>("hcalIsolInnR");
00128     hcalHitEtLow_     = pset.getParameter<double>("minHcalHitEtCut");
00129 
00130     numOfTracksInCone_ = pset.getParameter<int>("maxNumOfTracksInCone");
00131     trkPtSumCut_  = pset.getParameter<double>("trkPtSumCut");
00132     ecalEtSumCut_ = pset.getParameter<double>("ecalEtSumCut");
00133     hcalEtSumCut_ = pset.getParameter<double>("hcalEtSumCut");
00134     dCotCutOn_ = pset.getParameter<bool>("dCotCutOn");
00135     dCotCutValue_ = pset.getParameter<double>("dCotCutValue");
00136     dCotHardCutValue_ = pset.getParameter<double>("dCotHardCutValue");
00137 
00138   }
00139 
00140 
00141 
00142 
00143 
00144 PhotonValidator::~PhotonValidator() {}
00145 
00146 
00147 
00148 
00149 void  PhotonValidator::beginJob() {
00150 
00151   nEvt_=0;
00152   nEntry_=0;
00153   nRecConv_=0;
00154   nRecConvAss_=0;
00155   nRecConvAssWithEcal_=0;
00156 
00157   nInvalidPCA_=0;
00158 
00159   dbe_ = 0;
00160   dbe_ = edm::Service<DQMStore>().operator->();
00161 
00162 
00163 
00164 
00165   double resMin = parameters_.getParameter<double>("resMin");
00166   double resMax = parameters_.getParameter<double>("resMax");
00167   int resBin = parameters_.getParameter<int>("resBin");
00168 
00169   double eMin = parameters_.getParameter<double>("eMin");
00170   double eMax = parameters_.getParameter<double>("eMax");
00171   int eBin = parameters_.getParameter<int>("eBin");
00172 
00173   double etMin = parameters_.getParameter<double>("etMin");
00174   double etMax = parameters_.getParameter<double>("etMax");
00175   int etBin = parameters_.getParameter<int>("etBin");
00176 
00177   double etScale = parameters_.getParameter<double>("etScale");
00178 
00179   double etaMin = parameters_.getParameter<double>("etaMin");
00180   double etaMax = parameters_.getParameter<double>("etaMax");
00181   int etaBin = parameters_.getParameter<int>("etaBin");
00182   int etaBin2 = parameters_.getParameter<int>("etaBin2");
00183 
00184   double dEtaMin = parameters_.getParameter<double>("dEtaMin");
00185   double dEtaMax = parameters_.getParameter<double>("dEtaMax");
00186   int dEtaBin = parameters_.getParameter<int>("dEtaBin");
00187 
00188   double phiMin = parameters_.getParameter<double>("phiMin");
00189   double phiMax = parameters_.getParameter<double>("phiMax");
00190   int    phiBin = parameters_.getParameter<int>("phiBin");
00191 
00192   double dPhiMin = parameters_.getParameter<double>("dPhiMin");
00193   double dPhiMax = parameters_.getParameter<double>("dPhiMax");
00194   int    dPhiBin = parameters_.getParameter<int>("dPhiBin");
00195 
00196   double rMin = parameters_.getParameter<double>("rMin");
00197   double rMax = parameters_.getParameter<double>("rMax");
00198   int    rBin = parameters_.getParameter<int>("rBin");
00199 
00200   double zMin = parameters_.getParameter<double>("zMin");
00201   double zMax = parameters_.getParameter<double>("zMax");
00202   int    zBin = parameters_.getParameter<int>("zBin");
00203 
00204 
00205 
00206   double r9Min = parameters_.getParameter<double>("r9Min");
00207   double r9Max = parameters_.getParameter<double>("r9Max");
00208   int r9Bin = parameters_.getParameter<int>("r9Bin");
00209 
00210   double dPhiTracksMin = parameters_.getParameter<double>("dPhiTracksMin");
00211   double dPhiTracksMax = parameters_.getParameter<double>("dPhiTracksMax");
00212   int dPhiTracksBin = parameters_.getParameter<int>("dPhiTracksBin");
00213 
00214   double dEtaTracksMin = parameters_.getParameter<double>("dEtaTracksMin");
00215   double dEtaTracksMax = parameters_.getParameter<double>("dEtaTracksMax");
00216   int    dEtaTracksBin = parameters_.getParameter<int>("dEtaTracksBin");
00217 
00218   double dCotTracksMin = parameters_.getParameter<double>("dCotTracksMin");
00219   double dCotTracksMax = parameters_.getParameter<double>("dCotTracksMax");
00220   int    dCotTracksBin = parameters_.getParameter<int>("dCotTracksBin");
00221 
00222 
00223   double povereMin = parameters_.getParameter<double>("povereMin");
00224   double povereMax = parameters_.getParameter<double>("povereMax");
00225   int povereBin = parameters_.getParameter<int>("povereBin");
00226 
00227   double eoverpMin = parameters_.getParameter<double>("eoverpMin");
00228   double eoverpMax = parameters_.getParameter<double>("eoverpMax");
00229   int    eoverpBin = parameters_.getParameter<int>("eoverpBin");
00230 
00231   double chi2Min = parameters_.getParameter<double>("chi2Min");
00232   double chi2Max = parameters_.getParameter<double>("chi2Max");
00233 
00234   int    ggMassBin = parameters_.getParameter<int>("ggMassBin");
00235   double ggMassMin = parameters_.getParameter<double>("ggMassMin");
00236   double ggMassMax = parameters_.getParameter<double>("ggMassMax");
00237 
00238 
00239   double rMinForXray = parameters_.getParameter<double>("rMinForXray");
00240   double rMaxForXray = parameters_.getParameter<double>("rMaxForXray");
00241   int    rBinForXray = parameters_.getParameter<int>("rBinForXray");
00242   double zMinForXray = parameters_.getParameter<double>("zMinForXray");
00243   double zMaxForXray = parameters_.getParameter<double>("zMaxForXray");
00244   int    zBinForXray = parameters_.getParameter<int>("zBinForXray");
00245   int    zBin2ForXray = parameters_.getParameter<int>("zBin2ForXray");
00246 
00247 
00248 
00249   if (dbe_) {
00251     // SC from reco photons
00252 
00253     dbe_->setCurrentFolder("EgammaV/PhotonValidator/SimulationInfo");
00254     //
00255     // simulation information about all MC photons found
00256     std::string histname = "nOfSimPhotons";
00257     h_nSimPho_[0] = dbe_->book1D(histname,"# of Sim photons per event ",20,-0.5,19.5);
00258     histname = "SimPhoMotherEt";
00259     h_SimPhoMotherEt_[0] = dbe_->book1D(histname,"Sim photon Mother tranverse energy spectrum",etBin,etMin,etMax);
00260     h_SimPhoMotherEta_[0] = dbe_->book1D("SimPhoMotherEta"," Sim Photon Mother Eta ",etaBin,etaMin, etaMax) ;
00261     histname = "SimPhoMotherEtMatched";
00262     h_SimPhoMotherEt_[1] = dbe_->book1D(histname,"Sim photon  matched by a reco Photon: Mother tranverse energy spectrum",etBin,etMin,etMax);
00263     h_SimPhoMotherEta_[1] = dbe_->book1D("SimPhoMotherEtaMatched"," Sim Photon matched by a reco Photon:  Mother Eta ",etaBin,etaMin, etaMax) ;
00264     //
00265     histname = "h_SimPhoEta";
00266     h_SimPho_[0] =  dbe_->book1D(histname," All photons simulated #eta",etaBin,etaMin, etaMax);
00267     histname = "h_SimPhoPhi";
00268     h_SimPho_[1] =  dbe_->book1D(histname," All photons simulated #phi",phiBin,phiMin, phiMax);
00269     histname = "h_SimPhoEt";
00270     h_SimPho_[2] =  dbe_->book1D(histname," All photons simulated Et",etBin,etMin, etMax);
00271     // Numerators
00272     histname = "nOfSimPhotonsMatched";
00273     h_nSimPho_[1] = dbe_->book1D(histname,"# of Sim photons matched by a reco Photon per event ",20,-0.5,19.5);
00274     histname = "h_MatchedSimPhoEta";
00275     h_MatchedSimPho_[0] =  dbe_->book1D(histname," Matching photons simulated #eta",etaBin,etaMin, etaMax);
00276     histname = "h_MatchedSimPhoPhi";
00277     h_MatchedSimPho_[1] =  dbe_->book1D(histname," Matching photons simulated #phi",phiBin,phiMin, phiMax);
00278     histname = "h_MatchedSimPhoEt";
00279     h_MatchedSimPho_[2] =  dbe_->book1D(histname," Matching photons simulated Et",etBin,etMin, etMax);
00280     //
00281     histname = "h_MatchedSimPhoBadChEta";
00282     h_MatchedSimPhoBadCh_[0] =  dbe_->book1D(histname," Matching photons simulated #eta",etaBin,etaMin, etaMax);
00283     histname = "h_MatchedSimPhoBadChPhi";
00284     h_MatchedSimPhoBadCh_[1] =  dbe_->book1D(histname," Matching photons simulated #phi",phiBin,phiMin, phiMax);
00285     histname = "h_MatchedSimPhoBadChEt";
00286     h_MatchedSimPhoBadCh_[2] =  dbe_->book1D(histname," Matching photons simulated Et",etBin,etMin, etMax);
00287 
00288 
00290     histname = "nOfSimConversions";
00291     h_nSimConv_[0] = dbe_->book1D(histname,"# of Sim conversions per event ",20,-0.5,19.5);
00293     histname = "h_AllSimConvEta";
00294     h_AllSimConv_[0] =  dbe_->book1D(histname," All conversions: simulated #eta",etaBin2,etaMin,etaMax);
00295     histname = "h_AllSimConvPhi";
00296     h_AllSimConv_[1] =  dbe_->book1D(histname," All conversions: simulated #phi",phiBin,phiMin,phiMax);
00297     histname = "h_AllSimConvR";
00298     h_AllSimConv_[2] =  dbe_->book1D(histname," All conversions: simulated R",rBin,rMin,rMax);
00299     histname = "h_AllSimConvZ";
00300     h_AllSimConv_[3] =  dbe_->book1D(histname," All conversions: simulated Z",zBin,zMin,zMax);
00301     histname = "h_AllSimConvEt";
00302     h_AllSimConv_[4] =  dbe_->book1D(histname," All conversions: simulated Et",etBin,etMin,etMax);
00303     //
00304     histname = "nOfVisSimConversions";
00305     h_nSimConv_[1] = dbe_->book1D(histname,"# of Sim conversions per event ",20,-0.5,19.5);
00306     histname = "h_VisSimConvEta";
00307     h_VisSimConv_[0] =  dbe_->book1D(histname," All vis conversions: simulated #eta",etaBin2,etaMin, etaMax);
00308     histname = "h_VisSimConvPhi";
00309     h_VisSimConv_[1] =  dbe_->book1D(histname," All vis conversions: simulated #phi",phiBin,phiMin, phiMax);
00310     histname = "h_VisSimConvR";
00311     h_VisSimConv_[2] =  dbe_->book1D(histname," All vis conversions: simulated R",rBin,rMin,rMax);
00312     histname = "h_VisSimConvZ";
00313     h_VisSimConv_[3] =  dbe_->book1D(histname," All vis conversions: simulated Z",zBin,zMin, zMax);
00314     histname = "h_VisSimConvEt";
00315     h_VisSimConv_[4] =  dbe_->book1D(histname," All vis conversions: simulated Et",etBin,etMin, etMax);
00317     histname = "h_SimConvOneTracksEta";
00318     h_SimConvOneTracks_[0] =  dbe_->book1D(histname," All vis conversions with 1 reco  tracks: simulated #eta",etaBin2,etaMin, etaMax);
00319     histname = "h_SimConvOneTracksPhi";
00320     h_SimConvOneTracks_[1] =  dbe_->book1D(histname," All vis conversions with 1 reco  tracks: simulated #phi",phiBin,phiMin, phiMax);
00321     histname = "h_SimConvOneTracksR";
00322     h_SimConvOneTracks_[2] =  dbe_->book1D(histname," All vis conversions with 1 reco  tracks: simulated R",rBin,rMin, rMax);
00323     histname = "h_SimConvOneTracksZ";
00324     h_SimConvOneTracks_[3] =  dbe_->book1D(histname," All vis conversions with 1 reco  tracks: simulated Z",zBin,zMin, zMax);
00325     histname = "h_SimConvOneTracksEt";
00326     h_SimConvOneTracks_[4] =  dbe_->book1D(histname," All vis conversions with 1 reco  tracks: simulated Et",etBin,etMin, etMax);
00327     //
00328     histname = "h_SimConvTwoMTracksEta";
00329     h_SimConvTwoMTracks_[0] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated #eta",etaBin2,etaMin, etaMax);
00330     histname = "h_SimConvTwoMTracksPhi";
00331     h_SimConvTwoMTracks_[1] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated #phi",phiBin,phiMin, phiMax);
00332     histname = "h_SimConvTwoMTracksR";
00333     h_SimConvTwoMTracks_[2] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated R",rBin,rMin, rMax);
00334     histname = "h_SimConvTwoMTracksZ";
00335     h_SimConvTwoMTracks_[3] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated Z",zBin,zMin, zMax);
00336     histname = "h_SimConvTwoMTracksEt";
00337     h_SimConvTwoMTracks_[4] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated Et",etBin,etMin, etMax);
00338     //
00339     histname = "h_SimConvTwoTracksEta";
00340     h_SimConvTwoTracks_[0] =  dbe_->book1D(histname," All vis conversions with 2 reco  tracks: simulated #eta",etaBin2,etaMin, etaMax);
00341     histname = "h_SimConvTwoTracksPhi";
00342     h_SimConvTwoTracks_[1] =  dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated #phi",phiBin,phiMin, phiMax);
00343     histname = "h_SimConvTwoTracksR";
00344     h_SimConvTwoTracks_[2] =  dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated R",rBin,rMin, rMax);
00345     histname = "h_SimConvTwoTracksZ";
00346     h_SimConvTwoTracks_[3] =  dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated Z",zBin,zMin, zMax);
00347     histname = "h_SimConvTwoTracksEt";
00348     h_SimConvTwoTracks_[4] =  dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated Et",etBin,etMin, etMax);
00349     //
00350     histname = "h_SimConvOneMTracksEta";
00351     h_SimConvOneMTracks_[0] =  dbe_->book1D(histname," All vis conversions with 1 reco-matching tracks: simulated #eta",etaBin2,etaMin, etaMax);
00352     histname = "h_SimConvOneMTracksPhi";
00353     h_SimConvOneMTracks_[1] =  dbe_->book1D(histname," All vis conversions with 1 reco-matching tracks: simulated #phi",phiBin,phiMin, phiMax);
00354     histname = "h_SimConvOneMTracksR";
00355     h_SimConvOneMTracks_[2] =  dbe_->book1D(histname," All vis conversions with 1 reco-matching tracks: simulated R",rBin,rMin, rMax);
00356     histname = "h_SimConvOneMTracksZ";
00357     h_SimConvOneMTracks_[3] =  dbe_->book1D(histname," All vis conversions with 1 reco-matching tracks: simulated Z",zBin,zMin, zMax);
00358     histname = "h_SimConvOneMTracksEt";
00359     h_SimConvOneMTracks_[4] =  dbe_->book1D(histname," All vis conversions with 1 reco-matching tracks: simulated Et",etBin,etMin, etMax);
00360     //
00361     histname = "h_SimConvTwoMTracksEtaAndVtxPGT0";
00362     h_SimConvTwoMTracksAndVtxPGT0_[0] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated #eta",etaBin2,etaMin, etaMax);
00363     histname = "h_SimConvTwoMTracksPhiAndVtxPGT0";
00364     h_SimConvTwoMTracksAndVtxPGT0_[1] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated #phi",phiBin,phiMin, phiMax);
00365     histname = "h_SimConvTwoMTracksRAndVtxPGT0";
00366     h_SimConvTwoMTracksAndVtxPGT0_[2] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated R",rBin,rMin, rMax);
00367     histname = "h_SimConvTwoMTracksZAndVtxPGT0";
00368     h_SimConvTwoMTracksAndVtxPGT0_[3] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated Z",zBin,zMin, zMax);
00369     histname = "h_SimConvTwoMTracksEtAndVtxPGT0";
00370     h_SimConvTwoMTracksAndVtxPGT0_[4] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated Et",etBin,etMin, etMax);
00371     //
00372     histname = "h_SimConvTwoMTracksEtaAndVtxPGT0005";
00373     h_SimConvTwoMTracksAndVtxPGT0005_[0] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated #eta",etaBin2,etaMin, etaMax);
00374     histname = "h_SimConvTwoMTracksPhiAndVtxPGT0005";
00375     h_SimConvTwoMTracksAndVtxPGT0005_[1] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated #phi",phiBin,phiMin, phiMax);
00376     histname = "h_SimConvTwoMTracksRAndVtxPGT0005";
00377     h_SimConvTwoMTracksAndVtxPGT0005_[2] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated R",rBin,rMin, rMax);
00378     histname = "h_SimConvTwoMTracksZAndVtxPGT0005";
00379     h_SimConvTwoMTracksAndVtxPGT0005_[3] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated Z",zBin,zMin, zMax);
00380     histname = "h_SimConvTwoMTracksEtAndVtxPGT0005";
00381     h_SimConvTwoMTracksAndVtxPGT0005_[4] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated Et",etBin,etMin, etMax);
00382 
00383 
00384     h_SimConvEtaPix_[0] = dbe_->book1D("simConvEtaPix"," sim converted Photon Eta: Pix ",etaBin,etaMin, etaMax) ;
00385     h_simTkPt_ = dbe_->book1D("simTkPt","Sim conversion tracks pt ",etBin*3,0.,etMax);
00386     h_simTkEta_ = dbe_->book1D("simTkEta","Sim conversion tracks eta ",etaBin,etaMin,etaMax);
00387 
00388     if ( ! isRunCentrally_ ) {
00389       h_simConvVtxRvsZ_[0] =   dbe_->book2D("simConvVtxRvsZAll"," Photon Sim conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
00390       h_simConvVtxRvsZ_[1] =   dbe_->book2D("simConvVtxRvsZBarrel"," Photon Sim conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
00391       h_simConvVtxRvsZ_[2] =   dbe_->book2D("simConvVtxRvsZEndcap"," Photon Sim conversion vtx position",zBin2ForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
00392       h_simConvVtxYvsX_ =   dbe_->book2D("simConvVtxYvsXTrkBarrel"," Photon Sim conversion vtx position, (x,y) eta<1 ",100, -80., 80., 100, -80., 80.);
00393     }
00394 
00396     histname = "h_SimJetEta";
00397     h_SimJet_[0] =  dbe_->book1D(histname," Jet bkg simulated #eta",etaBin,etaMin, etaMax);
00398     histname = "h_SimJetPhi";
00399     h_SimJet_[1] =  dbe_->book1D(histname," Jet bkg simulated #phi",phiBin,phiMin, phiMax);
00400     histname = "h_SimJetEt";
00401     h_SimJet_[2] =  dbe_->book1D(histname," Jet bkg simulated Et",etBin,etMin, etMax);
00402     //
00403     histname = "h_MatchedSimJetEta";
00404     h_MatchedSimJet_[0] =  dbe_->book1D(histname," Matching jet simulated #eta",etaBin,etaMin, etaMax);
00405     histname = "h_MatchedSimJetPhi";
00406     h_MatchedSimJet_[1] =  dbe_->book1D(histname," Matching jet simulated #phi",phiBin,phiMin, phiMax);
00407     histname = "h_MatchedSimJetEt";
00408     h_MatchedSimJet_[2] =  dbe_->book1D(histname," Matching jet simulated Et",etBin,etMin, etMax);
00409     //
00410     histname = "h_MatchedSimJetBadChEta";
00411     h_MatchedSimJetBadCh_[0] =  dbe_->book1D(histname," Matching jet simulated #eta",etaBin,etaMin, etaMax);
00412     histname = "h_MatchedSimJetBadChPhi";
00413     h_MatchedSimJetBadCh_[1] =  dbe_->book1D(histname," Matching jet simulated #phi",phiBin,phiMin, phiMax);
00414     histname = "h_MatchedSimJetBadChEt";
00415     h_MatchedSimJetBadCh_[2] =  dbe_->book1D(histname," Matching jet simulated Et",etBin,etMin, etMax);
00416 
00417 
00418     dbe_->setCurrentFolder("EgammaV/PhotonValidator/Background");
00419 
00420     histname = "nOfPhotons";
00421     h_nPho_ = dbe_->book1D(histname,"# of Reco photons per event ",20,-0.5,19.5);
00422 
00423     h_scBkgEta_ = dbe_->book1D("scBkgEta"," SC Bkg Eta ",etaBin,etaMin, etaMax) ;
00424     h_scBkgPhi_ = dbe_->book1D("scBkgPhi"," SC Bkg  Phi ",phiBin,phiMin,phiMax) ;
00425     //
00426     h_phoBkgEta_ = dbe_->book1D("phoBkgEta"," Photon Bkg Eta ",etaBin,etaMin, etaMax) ;
00427     h_phoBkgPhi_ = dbe_->book1D("phoBkgPhi"," Photon Bkg Phi ",phiBin,phiMin,phiMax) ;
00428     //
00429     h_phoBkgDEta_ = dbe_->book1D("phoBkgDEta"," Photon Eta(rec)-Eta(true) ",dEtaBin,dEtaMin, dEtaMax) ;
00430     h_phoBkgDPhi_ = dbe_->book1D("phoBkgDPhi"," Photon  Phi(rec)-Phi(true) ",dPhiBin,dPhiMin,dPhiMax) ;
00431     //
00432     histname = "phoBkgE";
00433     h_phoBkgE_[0]=dbe_->book1D(histname+"All"," Photon Bkg Energy: All ecal ", eBin,eMin, eMax);
00434     h_phoBkgE_[1]=dbe_->book1D(histname+"Barrel"," Photon Bkg Energy: barrel ",eBin,eMin, eMax);
00435     h_phoBkgE_[2]=dbe_->book1D(histname+"Endcap"," Photon Bkg Energy: Endcap ",eBin,eMin, eMax);
00436     //
00437     histname = "phoBkgEt";
00438     h_phoBkgEt_[0] = dbe_->book1D(histname+"All"," Photon Bkg Transverse Energy: All ecal ", etBin,etMin, etMax);
00439     h_phoBkgEt_[1] = dbe_->book1D(histname+"Barrel"," Photon Bkg Transverse Energy: Barrel ",etBin,etMin, etMax);
00440     h_phoBkgEt_[2] = dbe_->book1D(histname+"Endcap"," Photon BkgTransverse Energy: Endcap ",etBin,etMin, etMax);
00441 
00442     //
00443     histname = "scBkgE";
00444     h_scBkgE_[0] = dbe_->book1D(histname+"All","    SC bkg Energy: All Ecal  ",eBin,eMin, eMax);
00445     h_scBkgE_[1] = dbe_->book1D(histname+"Barrel"," SC bkg Energy: Barrel ",eBin,eMin, eMax);
00446     h_scBkgE_[2] = dbe_->book1D(histname+"Endcap"," SC bkg Energy: Endcap ",eBin,eMin, eMax);
00447     histname = "scBkgEt";
00448     h_scBkgEt_[0] = dbe_->book1D(histname+"All","    SC bkg Et: All Ecal  ",eBin,eMin, eMax);
00449     h_scBkgEt_[1] = dbe_->book1D(histname+"Barrel"," SC bkg Et: Barrel ",eBin,eMin, eMax);
00450     h_scBkgEt_[2] = dbe_->book1D(histname+"Endcap"," SC bkg Et: Endcap ",eBin,eMin, eMax);
00451     //
00452     histname = "r9Bkg";
00453     h_r9Bkg_[0] = dbe_->book1D(histname+"All",   " r9 bkg: All Ecal",r9Bin,r9Min, r9Max) ;
00454     h_r9Bkg_[1] = dbe_->book1D(histname+"Barrel"," r9 bkg: Barrel ",r9Bin,r9Min, r9Max) ;
00455     h_r9Bkg_[2] = dbe_->book1D(histname+"Endcap"," r9 bkg: Endcap ",r9Bin,r9Min, r9Max) ;
00456     //
00457     histname="R9VsEtaBkg";
00458     h2_r9VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg r9 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00459     //
00460     histname="R9VsEtBkg";
00461     h2_r9VsEtBkg_ = dbe_->book2D(histname+"All"," Bkg photons r9 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00462     //
00463     histname = "r1Bkg";
00464     h_r1Bkg_[0] = dbe_->book1D(histname+"All",   " Bkg photon e1x5/e5x5: All Ecal",r9Bin,r9Min, r9Max) ;
00465     h_r1Bkg_[1] = dbe_->book1D(histname+"Barrel"," Bkg photon e1x5/e5x5: Barrel ",r9Bin,r9Min, r9Max) ;
00466     h_r1Bkg_[2] = dbe_->book1D(histname+"Endcap"," Bkg photon e1x5/e5x5: Endcap ",r9Bin,r9Min, r9Max) ;
00467     //
00468     histname="R1VsEtaBkg";
00469     h2_r1VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons e1x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00470     histname="pR1VsEtaBkg";
00471     p_r1VsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons e1x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00472     //
00473     histname="R1VsEtBkg";
00474     h2_r1VsEtBkg_ = dbe_->book2D(histname+"All"," Bkg photons e1x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00475     histname="pR1VsEtBkg";
00476     p_r1VsEtBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00477     //
00478     histname = "r2Bkg";
00479     h_r2Bkg_[0] = dbe_->book1D(histname+"All",   " Bkg photon e2x5/e5x5: All Ecal",r9Bin,r9Min, r9Max) ;
00480     h_r2Bkg_[1] = dbe_->book1D(histname+"Barrel"," Bkg photon e2x5/e5x5: Barrel ",r9Bin,r9Min, r9Max) ;
00481     h_r2Bkg_[2] = dbe_->book1D(histname+"Endcap"," Bkg photon e2x5/e5x5: Endcap ",r9Bin,r9Min, r9Max) ;
00482     //
00483     histname="R2VsEtaBkg";
00484     h2_r2VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons e2x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00485     histname="pR2VsEtaBkg";
00486     p_r2VsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons e2x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00487     //
00488     histname="R2VsEtBkg";
00489     h2_r2VsEtBkg_ = dbe_->book2D(histname+"All"," Bkg photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00490     histname="pR2VsEtBkg";
00491     p_r2VsEtBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00492 
00493 
00494     histname = "sigmaIetaIetaBkg";
00495     h_sigmaIetaIetaBkg_[0] = dbe_->book1D(histname+"All",   "Bkg sigmaIetaIeta: All Ecal",100,0., 0.1) ;
00496     h_sigmaIetaIetaBkg_[1] = dbe_->book1D(histname+"Barrel","Bkg sigmaIetaIeta: Barrel ", 100,0., 0.05) ;
00497     h_sigmaIetaIetaBkg_[2] = dbe_->book1D(histname+"Endcap","Bkg sigmaIetaIeta: Endcap ", 100,0., 0.1) ;
00498     //
00499     histname="sigmaIetaIetaVsEtaBkg";
00500     h2_sigmaIetaIetaVsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons sigmaIetaIeta vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
00501     histname="pSigmaIetaIetaVsEtaBkg";
00502     p_sigmaIetaIetaVsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons sigmaIetaIeta vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
00503     //
00504     histname="sigmaIetaIetaVsEtBkg";
00505     h2_sigmaIetaIetaVsEtBkg_[0] = dbe_->book2D(histname+"All"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00506     h2_sigmaIetaIetaVsEtBkg_[1] = dbe_->book2D(histname+"Barrel"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00507     h2_sigmaIetaIetaVsEtBkg_[2] = dbe_->book2D(histname+"Endcap"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00508     //
00509     histname="pSigmaIetaIetaVsEtBkg";
00510     p_sigmaIetaIetaVsEtBkg_[0] = dbe_->bookProfile(histname+"All"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00511     p_sigmaIetaIetaVsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00512     p_sigmaIetaIetaVsEtBkg_[2] = dbe_->bookProfile(histname+"Endcap"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00513     //
00514     histname = "hOverEBkg";
00515     h_hOverEBkg_[0] = dbe_->book1D(histname+"All",   "H/E bkg: All Ecal",100,0., 1.) ;
00516     h_hOverEBkg_[1] = dbe_->book1D(histname+"Barrel","H/E bkg: Barrel ", 100,0., 1.) ;
00517     h_hOverEBkg_[2] = dbe_->book1D(histname+"Endcap","H/E bkg: Endcap ", 100,0., 1.) ;
00518     //
00519     histname="hOverEVsEtaBkg";
00520     h2_hOverEVsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg H/E vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
00521     histname="pHOverEVsEtaBkg";
00522     p_hOverEVsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg H/E vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
00523     //
00524     histname="hOverEVsEtBkg";
00525     h2_hOverEVsEtBkg_ = dbe_->book2D(histname+"All"," Bkg photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00526     histname="pHOverEVsEtBkg";
00527     p_hOverEVsEtBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00528     //
00529     histname = "ecalRecHitSumEtConeDR04Bkg";
00530     h_ecalRecHitSumEtConeDR04Bkg_[0] = dbe_->book1D(histname+"All",   "bkg ecalRecHitSumEtDR04: All Ecal",etBin,etMin,50.);
00531     h_ecalRecHitSumEtConeDR04Bkg_[1] = dbe_->book1D(histname+"Barrel","bkg ecalRecHitSumEtDR04: Barrel ", etBin,etMin,50.);
00532     h_ecalRecHitSumEtConeDR04Bkg_[2] = dbe_->book1D(histname+"Endcap","bkg ecalRecHitSumEtDR04: Endcap ", etBin,etMin,50.);
00533     //
00534     histname="ecalRecHitSumEtConeDR04VsEtaBkg";
00535     h2_ecalRecHitSumEtConeDR04VsEtaBkg_ = dbe_->book2D(histname+"All"," bkg ecalRecHitSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale);
00536     histname="pEcalRecHitSumEtConeDR04VsEtaBkg";
00537     p_ecalRecHitSumEtConeDR04VsEtaBkg_ = dbe_->bookProfile(histname+"All","bkg photons ecalRecHitSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale, "");
00538     //
00539     histname="ecalRecHitSumEtConeDR04VsEtBkg";
00540     h2_ecalRecHitSumEtConeDR04VsEtBkg_[0] = dbe_->book2D(histname+"All"," Bkg ecalRecHitSumEtDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
00541     h2_ecalRecHitSumEtConeDR04VsEtBkg_[1] = dbe_->book2D(histname+"Barrel"," Bkg ecalRecHitSumEtDR04 vs Et: Barrel ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
00542     h2_ecalRecHitSumEtConeDR04VsEtBkg_[2] = dbe_->book2D(histname+"Endcap"," Bkg ecalRecHitSumEtDR04 vs Et: Endcap ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
00543     histname="pEcalRecHitSumEtConeDR04VsEtBkg";
00544     p_ecalRecHitSumEtConeDR04VsEtBkg_[0] = dbe_->bookProfile(histname+"All","Bkg ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00545     p_ecalRecHitSumEtConeDR04VsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel","Bkg ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00546     p_ecalRecHitSumEtConeDR04VsEtBkg_[2] = dbe_->bookProfile(histname+"Endcap","Bkg ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00547     //
00548     histname = "hcalTowerSumEtConeDR04Bkg";
00549     h_hcalTowerSumEtConeDR04Bkg_[0] = dbe_->book1D(histname+"All",   "bkg hcalTowerSumEtDR04: All Ecal",etBin,etMin,20.);
00550     h_hcalTowerSumEtConeDR04Bkg_[1] = dbe_->book1D(histname+"Barrel","bkg hcalTowerSumEtDR04: Barrel ", etBin,etMin,20.);
00551     h_hcalTowerSumEtConeDR04Bkg_[2] = dbe_->book1D(histname+"Endcap","bkg hcalTowerSumEtDR04: Endcap ", etBin,etMin,20.);
00552     //
00553     histname="hcalTowerSumEtConeDR04VsEtaBkg";
00554     h2_hcalTowerSumEtConeDR04VsEtaBkg_ = dbe_->book2D(histname+"All"," bkg hcalTowerSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale);
00555     histname="pHcalTowerSumEtConeDR04VsEtaBkg";
00556     p_hcalTowerSumEtConeDR04VsEtaBkg_ = dbe_->bookProfile(histname+"All","bkg photons hcalTowerSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale, "");
00557     //
00558     histname="hcalTowerSumEtConeDR04VsEtBkg";
00559     h2_hcalTowerSumEtConeDR04VsEtBkg_[0] = dbe_->book2D(histname+"All"," Bkg hcalTowerSumEtDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
00560     h2_hcalTowerSumEtConeDR04VsEtBkg_[1] = dbe_->book2D(histname+"Barrel"," Bkg hcalTowerSumEtDR04 vs Et: Barrel ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
00561     h2_hcalTowerSumEtConeDR04VsEtBkg_[2] = dbe_->book2D(histname+"Endcap"," Bkg hcalTowerSumEtDR04 vs Et: Endcap ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
00562     histname="pHcalTowerSumEtConeDR04VsEtBkg";
00563     p_hcalTowerSumEtConeDR04VsEtBkg_[0] = dbe_->bookProfile(histname+"All","Bkg hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00564     p_hcalTowerSumEtConeDR04VsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel","Bkg hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00565     p_hcalTowerSumEtConeDR04VsEtBkg_[2] = dbe_->bookProfile(histname+"Endcap","Bkg hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00566     //
00567     histname = "isoTrkSolidConeDR04Bkg";
00568     h_isoTrkSolidConeDR04Bkg_[0] = dbe_->book1D(histname+"All",   "isoTrkSolidConeDR04 Bkg: All Ecal",etBin,etMin,etMax*0.1);
00569     h_isoTrkSolidConeDR04Bkg_[1] = dbe_->book1D(histname+"Barrel","isoTrkSolidConeDR04 Bkg: Barrel ", etBin,etMin,etMax*0.1);
00570     h_isoTrkSolidConeDR04Bkg_[2] = dbe_->book1D(histname+"Endcap","isoTrkSolidConeDR04 Bkg: Endcap ", etBin,etMin,etMax*0.1);
00571     //
00572     histname="isoTrkSolidConeDR04VsEtaBkg";
00573     h2_isoTrkSolidConeDR04VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons isoTrkSolidConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1);
00574     histname="pIsoTrkSolidConeDR04VsEtaBkg";
00575     p_isoTrkSolidConeDR04VsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons isoTrkSolidConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1);
00576     //
00577     histname="isoTrkSolidConeDR04VsEtBkg";
00578     h2_isoTrkSolidConeDR04VsEtBkg_[0] = dbe_->book2D(histname+"All"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
00579     h2_isoTrkSolidConeDR04VsEtBkg_[1] = dbe_->book2D(histname+"Barrel"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
00580     h2_isoTrkSolidConeDR04VsEtBkg_[2] = dbe_->book2D(histname+"Endcap"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
00581     histname="pIsoTrkSolidConeDR04VsEtBkg";
00582     p_isoTrkSolidConeDR04VsEtBkg_[0] = dbe_->bookProfile(histname+"All"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
00583     p_isoTrkSolidConeDR04VsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
00584     p_isoTrkSolidConeDR04VsEtBkg_[2] = dbe_->bookProfile(histname+"Endcap"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
00585     //
00586     histname = "nTrkSolidConeDR04Bkg";
00587     h_nTrkSolidConeDR04Bkg_[0] = dbe_->book1D(histname+"All",   "Bkg nTrkSolidConeDR04: All Ecal",20,0., 20) ;
00588     h_nTrkSolidConeDR04Bkg_[1] = dbe_->book1D(histname+"Barrel","Bkg nTrkSolidConeDR04: Barrel ", 20,0., 20) ;
00589     h_nTrkSolidConeDR04Bkg_[2] = dbe_->book1D(histname+"Endcap","Bkg nTrkSolidConeDR04: Endcap ", 20,0., 20) ;
00590     //
00591     histname="nTrkSolidConeDR04VsEtaBkg";
00592     h2_nTrkSolidConeDR04VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons nTrkSolidConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, 20,0., 20) ;
00593     histname="p_nTrkSolidConeDR04VsEtaBkg";
00594     p_nTrkSolidConeDR04VsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons nTrkSolidConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, 20,0., 20) ;
00595     //
00596     histname="nTrkSolidConeDR04VsEtBkg";
00597     h2_nTrkSolidConeDR04VsEtBkg_[0] = dbe_->book2D(histname+"All","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
00598     h2_nTrkSolidConeDR04VsEtBkg_[1] = dbe_->book2D(histname+"Barrel","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
00599     h2_nTrkSolidConeDR04VsEtBkg_[2] = dbe_->book2D(histname+"Endcap","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
00600     //
00601     histname="pnTrkSolidConeDR04VsEtBkg";
00602     p_nTrkSolidConeDR04VsEtBkg_[0] = dbe_->bookProfile(histname+"All","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
00603     p_nTrkSolidConeDR04VsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
00604     p_nTrkSolidConeDR04VsEtBkg_[2] = dbe_->bookProfile(histname+"Endcap","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
00605     //
00606     h_convEtaBkg_ = dbe_->book1D("convEtaBkg"," converted Photon Bkg Eta 2 tracks",etaBin,etaMin, etaMax) ;
00607     h_convPhiBkg_ = dbe_->book1D("convPhiBkg"," converted Photon Bkg Phi ",phiBin,phiMin,phiMax) ;
00608     //
00609     histname="mvaOutBkg";
00610     h_mvaOutBkg_[0] = dbe_->book1D(histname+"All"," mvaOut  conversions bkg : All Ecal",100, 0., 1.);
00611     h_mvaOutBkg_[1] = dbe_->book1D(histname+"Barrel"," mvaOut conversions bkg: Barrel Ecal",100, 0., 1.);
00612     h_mvaOutBkg_[2] = dbe_->book1D(histname+"Endcap"," mvaOut  conversions bkg: Endcap Ecal",100, 0., 1.);
00613 
00614     histname="PoverEtracksBkg";
00615     h_PoverETracksBkg_[0] = dbe_->book1D(histname+"All"," bkg photons conversion p/E: all Ecal ",povereBin, povereMin, povereMax);
00616     h_PoverETracksBkg_[1] = dbe_->book1D(histname+"Barrel","bkg photons conversion p/E: Barrel Ecal",povereBin, povereMin, povereMax);
00617     h_PoverETracksBkg_[2] = dbe_->book1D(histname+"Endcap"," bkg photons conversion p/E: Endcap Ecal ",povereBin, povereMin, povereMax);
00618 
00619     histname="EoverPtracksBkg";
00620     h_EoverPTracksBkg_[0] = dbe_->book1D(histname+"All"," bkg photons conversion E/p: all Ecal ",eoverpBin, eoverpMin, eoverpMax);
00621     h_EoverPTracksBkg_[1] = dbe_->book1D(histname+"Barrel","bkg photons conversion E/p: Barrel Ecal",eoverpBin, eoverpMin, eoverpMax);
00622     h_EoverPTracksBkg_[2] = dbe_->book1D(histname+"Endcap"," bkg photons conversion E/p: Endcap Ecal ",eoverpBin, eoverpMin, eoverpMax);
00623 
00624     histname="hDCotTracksBkg";
00625     h_DCotTracksBkg_[0]= dbe_->book1D(histname+"All"," bkg Photons:Tracks from conversions #delta cotg(#Theta) Tracks: all Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
00626     h_DCotTracksBkg_[1]= dbe_->book1D(histname+"Barrel"," bkg Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Barrel Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
00627     h_DCotTracksBkg_[2]= dbe_->book1D(histname+"Endcap"," bkg Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Endcap Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
00628 
00629     histname="hDPhiTracksAtVtxBkg";
00630     h_DPhiTracksAtVtxBkg_[0] =dbe_->book1D(histname+"All", " Bkg Photons:Tracks from conversions: #delta#phi Tracks at vertex: all Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
00631     h_DPhiTracksAtVtxBkg_[1] =dbe_->book1D(histname+"Barrel", " Bkg Photons:Tracks from conversions: #delta#phi Tracks at vertex: Barrel Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
00632     h_DPhiTracksAtVtxBkg_[2] =dbe_->book1D(histname+"Endcap", " Bkg Photons:Tracks from conversions: #delta#phi Tracks at vertex: Endcap Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
00633 
00634     if ( ! isRunCentrally_ ) {
00635       h_convVtxRvsZBkg_[0] =   dbe_->book2D("convVtxRvsZAllBkg"," Bkg Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
00636       h_convVtxRvsZBkg_[1] =   dbe_->book2D("convVtxRvsZBarrelBkg"," Bkg Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
00637       h_convVtxYvsXBkg_ =   dbe_->book2D("convVtxYvsXTrkBarrelBkg"," Bkg Photon Reco conversion vtx position, (x,y) eta<1 ",100, -80., 80., 100, -80., 80.);
00638     }
00639 
00640     //
00641     dbe_->setCurrentFolder("EgammaV/PhotonValidator/Photons");
00642 
00643     h_phoEta_[0] = dbe_->book1D("phoEta"," Photon Eta ",etaBin,etaMin, etaMax) ;
00644     h_phoPhi_[0] = dbe_->book1D("phoPhi"," Photon  Phi ",phiBin,phiMin,phiMax) ;
00645 
00646     h_phoDEta_[0] = dbe_->book1D("phoDEta"," Photon Eta(rec)-Eta(true) ",dEtaBin,dEtaMin, dEtaMax) ;
00647     h_phoDPhi_[0] = dbe_->book1D("phoDPhi"," Photon  Phi(rec)-Phi(true) ",dPhiBin,dPhiMin,dPhiMax) ;
00648 
00649     h_scEta_[0] =   dbe_->book1D("scEta"," SC Eta ",etaBin,etaMin, etaMax);
00650     h_scPhi_[0] =   dbe_->book1D("scPhi"," SC Phi ",phiBin,phiMin,phiMax);
00651 
00652     h_scEtaWidth_[0] =   dbe_->book1D("scEtaWidth"," SC Eta Width ",100,0., 0.1);
00653     h_scPhiWidth_[0] =   dbe_->book1D("scPhiWidth"," SC Phi Width ",100,0., 1.);
00654 
00655 
00656     histname = "scE";
00657     h_scE_[0][0] = dbe_->book1D(histname+"All"," SC Energy: All Ecal  ",eBin,eMin, eMax);
00658     h_scE_[0][1] = dbe_->book1D(histname+"Barrel"," SC Energy: Barrel ",eBin,eMin, eMax);
00659     h_scE_[0][2] = dbe_->book1D(histname+"Endcap"," SC Energy: Endcap ",eBin,eMin, eMax);
00660 
00661     histname = "psE";
00662     h_psE_ = dbe_->book1D(histname+"Endcap"," ES Energy  ",eBin,eMin, 50.);
00663 
00664 
00665     histname = "scEt";
00666     h_scEt_[0][0] = dbe_->book1D(histname+"All"," SC Et: All Ecal ",etBin,etMin, etMax) ;
00667     h_scEt_[0][1] = dbe_->book1D(histname+"Barrel"," SC Et: Barrel",etBin,etMin, etMax) ;
00668     h_scEt_[0][2] = dbe_->book1D(histname+"Endcap"," SC Et: Endcap",etBin,etMin, etMax) ;
00669 
00670     histname = "r9";
00671     h_r9_[0][0] = dbe_->book1D(histname+"All",   " r9: All Ecal",r9Bin,r9Min, r9Max) ;
00672     h_r9_[0][1] = dbe_->book1D(histname+"Barrel"," r9: Barrel ",r9Bin,r9Min, r9Max) ;
00673     h_r9_[0][2] = dbe_->book1D(histname+"Endcap"," r9: Endcap ",r9Bin,r9Min, r9Max) ;
00674     //
00675     histname = "r9ConvFromMC";
00676     h_r9_[1][0] = dbe_->book1D(histname+"All",   " r9: All Ecal",r9Bin,r9Min, r9Max) ;
00677     h_r9_[1][1] = dbe_->book1D(histname+"Barrel"," r9: Barrel ",r9Bin,r9Min, r9Max) ;
00678     h_r9_[1][2] = dbe_->book1D(histname+"Endcap"," r9: Endcap ",r9Bin,r9Min, r9Max) ;
00679     //
00680     histname = "r9ConvFromReco";
00681     h_r9_[2][0] = dbe_->book1D(histname+"All",   " r9: All Ecal",r9Bin,r9Min, r9Max) ;
00682     h_r9_[2][1] = dbe_->book1D(histname+"Barrel"," r9: Barrel ",r9Bin,r9Min, r9Max) ;
00683     h_r9_[2][2] = dbe_->book1D(histname+"Endcap"," r9: Endcap ",r9Bin,r9Min, r9Max) ;
00685     histname = "EtR9Less093";
00686     h_EtR9Less093_[0][0] = dbe_->book1D(histname+"All",   " r9 < 0.94 or 0.95 : All Ecal",etBin,etMin, etMax);
00687     h_EtR9Less093_[0][1] = dbe_->book1D(histname+"Barrel"," r9 < 0.94 : Barrel ",etBin,etMin, etMax);
00688     h_EtR9Less093_[0][2] = dbe_->book1D(histname+"Endcap"," r9 < 0.95 : Endcap ",etBin,etMin, etMax);
00689     histname = "EtR9Less093Conv";
00690     h_EtR9Less093_[1][0] = dbe_->book1D(histname+"All",   " r9 < 0.94, 0.95 and good conv : All Ecal",etBin,etMin, etMax);
00691     h_EtR9Less093_[1][1] = dbe_->book1D(histname+"Barrel"," r9 < 0.94 and good conv : Barrel ",etBin,etMin, etMax);
00692     h_EtR9Less093_[1][2] = dbe_->book1D(histname+"Endcap"," r9 < 0.95 and good conv : Endcap ",etBin,etMin, etMax);
00693 
00694 
00696     histname="R9VsEta";
00697     h2_r9VsEta_[0] = dbe_->book2D(histname+"All"," All photons r9 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00698     h2_r9VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons r9 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00699     //
00700     histname="R9VsEt";
00701     h2_r9VsEt_[0] = dbe_->book2D(histname+"All"," All photons r9 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00702     h2_r9VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons r9 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00703     //
00704     histname = "r1";
00705     h_r1_[0][0] = dbe_->book1D(histname+"All",   " e1x5/e5x5: All Ecal",r9Bin,r9Min, r9Max) ;
00706     h_r1_[0][1] = dbe_->book1D(histname+"Barrel"," e1x5/e5x5: Barrel ",r9Bin,r9Min, r9Max) ;
00707     h_r1_[0][2] = dbe_->book1D(histname+"Endcap"," e1x5/e5x5: Endcap ",r9Bin,r9Min, r9Max) ;
00708     //
00709     histname="R1VsEta";
00710     h2_r1VsEta_[0] = dbe_->book2D(histname+"All"," All photons e1x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00711     h2_r1VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons e1x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00712     //
00713     histname="R1VsEt";
00714     h2_r1VsEt_[0] = dbe_->book2D(histname+"All"," All photons e1x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00715     h2_r1VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons e1x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00716     //
00717     histname = "r2";
00718     h_r2_[0][0] = dbe_->book1D(histname+"All",   " e2x5/e5x5: All Ecal",r9Bin,r9Min, r9Max) ;
00719     h_r2_[0][1] = dbe_->book1D(histname+"Barrel"," e2x5/e5x5: Barrel ",r9Bin,r9Min, r9Max) ;
00720     h_r2_[0][2] = dbe_->book1D(histname+"Endcap"," e2x5/e5x5: Endcap ",r9Bin,r9Min, r9Max) ;
00721     //
00722     histname="R2VsEta";
00723     h2_r2VsEta_[0] = dbe_->book2D(histname+"All"," All photons e2x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00724     h2_r2VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons e2x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00725     //
00726     histname="R2VsEt";
00727     h2_r2VsEt_[0] = dbe_->book2D(histname+"All"," All photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00728     h2_r2VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00729     //
00730     histname = "sigmaIetaIeta";
00731     h_sigmaIetaIeta_[0][0] = dbe_->book1D(histname+"All",   "sigmaIetaIeta: All Ecal",100,0., 0.1) ;
00732     h_sigmaIetaIeta_[0][1] = dbe_->book1D(histname+"Barrel","sigmaIetaIeta: Barrel ", 100,0., 0.05) ;
00733     h_sigmaIetaIeta_[0][2] = dbe_->book1D(histname+"Endcap","sigmaIetaIeta: Endcap ", 100,0., 0.1) ;
00734     //
00735     histname="sigmaIetaIetaVsEta";
00736     h2_sigmaIetaIetaVsEta_[0] = dbe_->book2D(histname+"All"," All photons sigmaIetaIeta vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
00737     h2_sigmaIetaIetaVsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons sigmaIetaIeta vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,0.1);
00738     //
00739     histname="sigmaIetaIetaVsEt";
00740     h2_sigmaIetaIetaVsEt_[0] = dbe_->book2D(histname+"All"," All photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00741     h2_sigmaIetaIetaVsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00742     //
00743     histname = "hOverE";
00744     h_hOverE_[0][0] = dbe_->book1D(histname+"All",   "H/E: All Ecal",100,0., 0.1) ;
00745     h_hOverE_[0][1] = dbe_->book1D(histname+"Barrel","H/E: Barrel ", 100,0., 0.1) ;
00746     h_hOverE_[0][2] = dbe_->book1D(histname+"Endcap","H/E: Endcap ", 100,0., 0.1) ;
00747     //
00748     histname="hOverEVsEta";
00749     h2_hOverEVsEta_[0] = dbe_->book2D(histname+"All"," All photons H/E vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
00750     h2_hOverEVsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons H/E vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,0.1);
00751     //
00752     histname="hOverEVsEt";
00753     h2_hOverEVsEt_[0] = dbe_->book2D(histname+"All"," All photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00754     h2_hOverEVsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00755     //
00756     histname="pHoverEVsEta";
00757     p_hOverEVsEta_[0] = dbe_->bookProfile(histname+"All"," All photons H/E vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
00758     p_hOverEVsEta_[1] = dbe_->bookProfile(histname+"Unconv"," All photons H/E vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,0.1);
00759     //
00760     histname="pHoverEVsEt";
00761     p_hOverEVsEt_[0] = dbe_->bookProfile(histname+"All"," All photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00762     p_hOverEVsEt_[1] = dbe_->bookProfile(histname+"Unconv"," All photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00763 
00764     //
00765     histname = "ecalRecHitSumEtConeDR04";
00766     h_ecalRecHitSumEtConeDR04_[0][0] = dbe_->book1D(histname+"All",   "ecalRecHitSumEtDR04: All Ecal",etBin,etMin,20.);
00767     h_ecalRecHitSumEtConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","ecalRecHitSumEtDR04: Barrel ", etBin,etMin,20.);
00768     h_ecalRecHitSumEtConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","ecalRecHitSumEtDR04: Endcap ", etBin,etMin,20.);
00769     //
00770     histname="ecalRecHitSumEtConeDR04VsEta";
00771     h2_ecalRecHitSumEtConeDR04VsEta_[0] = dbe_->book2D(histname+"All"," All photons ecalRecHitSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale);
00772     h2_ecalRecHitSumEtConeDR04VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons ecalRecHitSumEtDR04 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,etBin,etMin,etMax*etScale);
00773     histname="pEcalRecHitSumEtConeDR04VsEta";
00774     p_ecalRecHitSumEtConeDR04VsEta_[0] = dbe_->bookProfile(histname+"All","All photons ecalRecHitSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale, "");
00775     p_ecalRecHitSumEtConeDR04VsEta_[1] = dbe_->bookProfile(histname+"Unconv","All photons ecalRecHitSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale, "");
00776     //
00777     histname="ecalRecHitSumEtConeDR04VsEt";
00778     h2_ecalRecHitSumEtConeDR04VsEt_[0] = dbe_->book2D(histname+"All"," All photons ecalRecHitSumEtDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
00779     h2_ecalRecHitSumEtConeDR04VsEt_[1] = dbe_->book2D(histname+"Barrel"," All photons ecalRecHitSumEtDR04 vs Et: Barrel ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
00780     h2_ecalRecHitSumEtConeDR04VsEt_[2] = dbe_->book2D(histname+"Endcap"," All photons ecalRecHitSumEtDR04 vs Et: Endcap ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
00781     histname="pEcalRecHitSumEtConeDR04VsEt";
00782     p_ecalRecHitSumEtConeDR04VsEt_[0] = dbe_->bookProfile(histname+"All","All photons ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00783     p_ecalRecHitSumEtConeDR04VsEt_[1] = dbe_->bookProfile(histname+"Barrel","All photons ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00784     p_ecalRecHitSumEtConeDR04VsEt_[2] = dbe_->bookProfile(histname+"Endcap","All photons ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00785     //
00786     histname = "hcalTowerSumEtConeDR04";
00787     h_hcalTowerSumEtConeDR04_[0][0] = dbe_->book1D(histname+"All",   "hcalTowerSumEtConeDR04: All Ecal",etBin,etMin,20.);
00788     h_hcalTowerSumEtConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","hcalTowerSumEtConeDR04: Barrel ", etBin,etMin,20.);
00789     h_hcalTowerSumEtConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","hcalTowerSumEtConeDR04: Endcap ", etBin,etMin,20.);
00790 
00791     //
00792     histname="hcalTowerSumEtConeDR04VsEta";
00793     h2_hcalTowerSumEtConeDR04VsEta_[0] = dbe_->book2D(histname+"All"," All photons hcalTowerSumEtConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1);
00794     h2_hcalTowerSumEtConeDR04VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons hcalTowerSumEtConeDR04 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,etBin,etMin,etMax*0.1);
00795     histname="pHcalTowerSumEtConeDR04VsEta";
00796     p_hcalTowerSumEtConeDR04VsEta_[0] = dbe_->bookProfile(histname+"All","All photons hcalTowerSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1, "");
00797     p_hcalTowerSumEtConeDR04VsEta_[1] = dbe_->bookProfile(histname+"Unconv","All photons hcalTowerSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1, "");
00798     //
00799     histname="hcalTowerSumEtConeDR04VsEt";
00800     h2_hcalTowerSumEtConeDR04VsEt_[0] = dbe_->book2D(histname+"All"," All photons hcalTowerSumEtConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
00801     h2_hcalTowerSumEtConeDR04VsEt_[1] = dbe_->book2D(histname+"Barrel"," All photons hcalTowerSumEtConeDR04 vs Et: Barrel ",etBin,etMin, etMax,etBin,etMin,etMax*0.1);
00802     h2_hcalTowerSumEtConeDR04VsEt_[2] = dbe_->book2D(histname+"Endcap"," All photons hcalTowerSumEtConeDR04 vs Et: Endcap ",etBin,etMin, etMax,etBin,etMin,etMax*0.1);
00803     histname="pHcalTowerSumEtConeDR04VsEt";
00804     p_hcalTowerSumEtConeDR04VsEt_[0] = dbe_->bookProfile(histname+"All","All photons hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00805     p_hcalTowerSumEtConeDR04VsEt_[1] = dbe_->bookProfile(histname+"Barrel","All photons hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00806     p_hcalTowerSumEtConeDR04VsEt_[2] = dbe_->bookProfile(histname+"Endcap","All photons hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00807 
00808     //
00809     histname = "isoTrkSolidConeDR04";
00810     h_isoTrkSolidConeDR04_[0][0] = dbe_->book1D(histname+"All",   "isoTrkSolidConeDR04: All Ecal",etBin,etMin,etMax*0.1);
00811     h_isoTrkSolidConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","isoTrkSolidConeDR04: Barrel ", etBin,etMin,etMax*0.1);
00812     h_isoTrkSolidConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","isoTrkSolidConeDR04: Endcap ", etBin,etMin,etMax*0.1);
00813     //
00814     histname="isoTrkSolidConeDR04VsEta";
00815     h2_isoTrkSolidConeDR04VsEta_[0] = dbe_->book2D(histname+"All"," All photons isoTrkSolidConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1);
00816     h2_isoTrkSolidConeDR04VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons isoTrkSolidConeDR04 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,etBin,etMin,etMax*0.1);
00817     //
00818     histname="isoTrkSolidConeDR04VsEt";
00819     h2_isoTrkSolidConeDR04VsEt_[0] = dbe_->book2D(histname+"All"," All photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
00820     h2_isoTrkSolidConeDR04VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
00821     //
00822     histname = "nTrkSolidConeDR04";
00823     h_nTrkSolidConeDR04_[0][0] = dbe_->book1D(histname+"All",   "nTrkSolidConeDR04: All Ecal",20,0., 20) ;
00824     h_nTrkSolidConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","nTrkSolidConeDR04: Barrel ", 20,0., 20) ;
00825     h_nTrkSolidConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","nTrkSolidConeDR04: Endcap ", 20,0., 20) ;
00826     //
00827     histname="nTrkSolidConeDR04VsEta";
00828     h2_nTrkSolidConeDR04VsEta_[0] = dbe_->book2D(histname+"All"," All photons nTrkSolidConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, 20,0., 20) ;
00829     h2_nTrkSolidConeDR04VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons nTrkSolidConeDR04 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,20,0., 20) ;
00830     //
00831     histname="nTrkSolidConeDR04VsEt";
00832     h2_nTrkSolidConeDR04VsEt_[0] = dbe_->book2D(histname+"All"," All photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
00833     h2_nTrkSolidConeDR04VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax,20,0., 20) ;
00834     //
00835     histname = "phoE";
00836     h_phoE_[0][0]=dbe_->book1D(histname+"All"," Photon Energy: All ecal ", eBin,eMin, eMax);
00837     h_phoE_[0][1]=dbe_->book1D(histname+"Barrel"," Photon Energy: barrel ",eBin,eMin, eMax);
00838     h_phoE_[0][2]=dbe_->book1D(histname+"Endcap"," Photon Energy: Endcap ",eBin,eMin, eMax);
00839 
00840     histname = "phoEt";
00841     h_phoEt_[0][0] = dbe_->book1D(histname+"All"," Photon Transverse Energy: All ecal ", etBin,etMin, etMax);
00842     h_phoEt_[0][1] = dbe_->book1D(histname+"Barrel"," Photon Transverse Energy: Barrel ",etBin,etMin, etMax);
00843     h_phoEt_[0][2] = dbe_->book1D(histname+"Endcap"," Photon Transverse Energy: Endcap ",etBin,etMin, etMax);
00844 
00845     histname = "eRes";
00846     h_phoERes_[0][0] = dbe_->book1D(histname+"All"," Photon rec/true Energy: All ecal ", resBin,resMin, resMax);
00847     h_phoERes_[0][1] = dbe_->book1D(histname+"Barrel"," Photon rec/true Energy: Barrel ",resBin,resMin, resMax);
00848     h_phoERes_[0][2] = dbe_->book1D(histname+"Endcap"," Photon rec/true Energy: Endcap ",resBin,resMin, resMax);
00849 
00850     h_phoERes_[1][0] = dbe_->book1D(histname+"unconvAll"," Photon rec/true Energy if r9>0.94, 0.95: All ecal ", resBin,resMin, resMax);
00851     h_phoERes_[1][1] = dbe_->book1D(histname+"unconvBarrel"," Photon rec/true Energy if r9>0.94: Barrel ",resBin,resMin, resMax);
00852     h_phoERes_[1][2] = dbe_->book1D(histname+"unconvEndcap"," Photon rec/true Energyif r9>0.95: Endcap ",resBin,resMin, resMax);
00853 
00854     h_phoERes_[2][0] = dbe_->book1D(histname+"convAll"," Photon rec/true Energy if r9<0.0.94, 0.95: All ecal ", resBin,resMin, resMax);
00855     h_phoERes_[2][1] = dbe_->book1D(histname+"convBarrel"," Photon rec/true Energyif r9<0.94: Barrel ",resBin,resMin, resMax);
00856     h_phoERes_[2][2] = dbe_->book1D(histname+"convEndcap"," Photon rec/true Energyif r9<0.95: Endcap ",resBin,resMin, resMax);
00857 
00858 
00859     histname="eResVsEta";
00860     h2_eResVsEta_[0] = dbe_->book2D(histname+"All"," All photons E/Etrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 2.5);
00861     h2_eResVsEta_[1] = dbe_->book2D(histname+"Unconv"," Unconv photons E/Etrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 2.5);
00862 
00863     histname="pEResVsEta";
00864     p_eResVsEta_[0] = dbe_->bookProfile(histname+"All","All photons  E/Etrue vs #eta: all Ecal ",etaBin2,etaMin,etaMax,resBin,resMin, resMax,"");
00865     p_eResVsEta_[1] = dbe_->bookProfile(histname+"Unconv","Unconv photons  E/Etrue vs #eta: all Ecal",etaBin2,etaMin,etaMax,resBin,resMin, resMax,"");
00866     p_eResVsEta_[2] = dbe_->bookProfile(histname+"Conv","Conv photons  E/Etrue vs #eta: all Ecal",etaBin2,etaMin,etaMax,resBin,resMin, resMax,"");
00867 
00868     if ( ! isRunCentrally_ ) {
00869       histname="eResVsEt";
00870       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);
00871       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);
00872       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);
00873       h2_eResVsEt_[1][0] = dbe_->book2D(histname+"Barrel"," All photons E/Etrue vs true Et: Barrel ",etBin,etMin, etMax,100, 0.9, 1.1);
00874       h2_eResVsEt_[1][1] = dbe_->book2D(histname+"unconvBarrel"," All photons E/Etrue vs true Et: Barrel ",etBin,etMin, etMax,100, 0.9, 1.1);
00875       h2_eResVsEt_[1][2] = dbe_->book2D(histname+"convBarrel"," All photons E/Etrue vs true Et: Barrel ",etBin,etMin, etMax,100, 0.9, 1.1);
00876       h2_eResVsEt_[2][0] = dbe_->book2D(histname+"Endcap"," All photons E/Etrue vs true Et: Endcap ",etBin,etMin, etMax,100, 0.9, 1.1);
00877       h2_eResVsEt_[2][1] = dbe_->book2D(histname+"unconvEndcap"," All photons E/Etrue vs true Et: Endcap ",etBin,etMin, etMax,100, 0.9, 1.1);
00878       h2_eResVsEt_[2][2] = dbe_->book2D(histname+"convEndcap"," All photons E/Etrue vs true Et: Endcap ",etBin,etMin, etMax,100, 0.9, 1.1);
00879     }
00880 
00881     histname="pEResVsEt";
00882     p_eResVsEt_[0][0] = dbe_->bookProfile(histname+"All","All photons  E/Etrue vs Et: all Ecal ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00883     p_eResVsEt_[0][1] = dbe_->bookProfile(histname+"unconv","All photons  E/Etrue vs Et: all Ecal ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00884     p_eResVsEt_[0][2] = dbe_->bookProfile(histname+"conv","All photons  E/Etrue vs Et: all Ecal ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00885     p_eResVsEt_[1][0] = dbe_->bookProfile(histname+"Barrel","All photons  E/Etrue vs Et: Barrel ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00886     p_eResVsEt_[1][1] = dbe_->bookProfile(histname+"unconvBarrel","All photons  E/Etrue vs Et: Barrel ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00887     p_eResVsEt_[1][2] = dbe_->bookProfile(histname+"convBarrel","All photons  E/Etrue vs Et: Barrel ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00888     p_eResVsEt_[2][0] = dbe_->bookProfile(histname+"Endcap","All photons  E/Etrue vs Et: Endcap ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00889     p_eResVsEt_[2][1] = dbe_->bookProfile(histname+"unconvEndcap","All photons  E/Etrue vs Et: Endcap ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00890     p_eResVsEt_[2][2] = dbe_->bookProfile(histname+"convEndcap","All photons  E/Etrue vs Et: Endcap ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00891 
00892 
00893     histname="eResVsR9";
00894     h2_eResVsR9_[0] = dbe_->book2D(histname+"All"," All photons E/Etrue vs R9: all Ecal ",r9Bin*2,r9Min, r9Max,100, 0., 2.5);
00895     h2_eResVsR9_[1] = dbe_->book2D(histname+"Barrel"," All photons E/Etrue vs R9: Barrel ",  r9Bin*2,r9Min, r9Max,100, 0.,2.5);
00896     h2_eResVsR9_[2] = dbe_->book2D(histname+"Endcap"," All photons E/Etrue vs R9: Endcap ",  r9Bin*2,r9Min, r9Max,100, 0., 2.5);
00897     histname="pEResVsR9";
00898     p_eResVsR9_[0] = dbe_->bookProfile(histname+"All"," All photons  E/Etrue vs R9: all Ecal ",r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
00899     p_eResVsR9_[1] = dbe_->bookProfile(histname+"Barrel"," All photons  E/Etrue vs R9: Barrel ",  r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
00900     p_eResVsR9_[2] = dbe_->bookProfile(histname+"Endcap"," All photons  E/Etrue vs R9: Endcap ",  r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
00901     histname="sceResVsR9";
00902     h2_sceResVsR9_[0] = dbe_->book2D(histname+"All"," All photons scE/Etrue vs R9: all Ecal ",r9Bin*2,r9Min, r9Max,100, 0., 2.5);
00903     h2_sceResVsR9_[1] = dbe_->book2D(histname+"Barrel"," All photons scE/Etrue vs R9: Barrel ",  r9Bin*2,r9Min, r9Max,100, 0.,2.5);
00904     h2_sceResVsR9_[2] = dbe_->book2D(histname+"Endcap"," All photons scE/Etrue vs R9: Endcap ",  r9Bin*2,r9Min, r9Max,100, 0., 2.5);
00905     histname="scpEResVsR9";
00906     p_sceResVsR9_[0] = dbe_->bookProfile(histname+"All"," All photons  scE/Etrue vs R9: all Ecal ",r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
00907     p_sceResVsR9_[1] = dbe_->bookProfile(histname+"Barrel"," All photons  scE/Etrue vs R9: Barrel ",  r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
00908     p_sceResVsR9_[2] = dbe_->bookProfile(histname+"Endcap"," All photons  scE/Etrue vs R9: Endcap ",  r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
00909 
00910 
00911 
00912     // Photon pair invariant mass
00913     histname = "gamgamMass";
00914     h_gamgamMass_[0][0] = dbe_->book1D(histname+"All","2 photons invariant mass: All ecal ", ggMassBin, ggMassMin, ggMassMax);
00915     h_gamgamMass_[0][1] = dbe_->book1D(histname+"Barrel","2 photons invariant mass:  Barrel ",ggMassBin, ggMassMin, ggMassMax);
00916     h_gamgamMass_[0][2] = dbe_->book1D(histname+"Endcap","2 photons invariant mass:  Endcap ",ggMassBin, ggMassMin, ggMassMax);
00917     //
00918     histname = "gamgamMassNoConv";
00919     h_gamgamMass_[1][0] = dbe_->book1D(histname+"All","2 photons with no conversion invariant mass: All ecal ",ggMassBin, ggMassMin, ggMassMax);
00920     h_gamgamMass_[1][1] = dbe_->book1D(histname+"Barrel","2 photons with no conversion  invariant mass:  Barrel ",ggMassBin, ggMassMin, ggMassMax);
00921     h_gamgamMass_[1][2] = dbe_->book1D(histname+"Endcap","2 photons with no conversion  invariant mass:  Endcap ",ggMassBin, ggMassMin, ggMassMax);
00922     //
00923     histname = "gamgamMassConv";
00924     h_gamgamMass_[2][0] = dbe_->book1D(histname+"All","2 photons with conversion invariant mass: All ecal ", ggMassBin, ggMassMin, ggMassMax);
00925     h_gamgamMass_[2][1] = dbe_->book1D(histname+"Barrel","2 photons with  conversion  invariant mass:  Barrel ",ggMassBin, ggMassMin, ggMassMax);
00926     h_gamgamMass_[2][2] = dbe_->book1D(histname+"Endcap","2 photons with  conversion  invariant mass:  Endcap ",ggMassBin, ggMassMin, ggMassMax);
00927 
00928 
00929     dbe_->setCurrentFolder("EgammaV/PhotonValidator/ConversionInfo");
00930 
00931     histname="nOfflineVtx";
00932     h_nRecoVtx_ = dbe_->book1D(histname,"# of Offline Vertices",30, -0.5, 29.5);
00933 
00934     histname="nConv";
00935     h_nConv_[0][0] = dbe_->book1D(histname+"All","Number Of Conversions per isolated candidates per events: All Ecal  ",10,-0.5, 9.5);
00936     h_nConv_[0][1] = dbe_->book1D(histname+"Barrel","Number Of Conversions per isolated candidates per events: Ecal Barrel  ",10,-0.5, 9.5);
00937     h_nConv_[0][2] = dbe_->book1D(histname+"Endcap","Number Of Conversions per isolated candidates per events: Ecal Endcap ",10,-0.5, 9.5);
00938 
00939     h_convEta_[0] = dbe_->book1D("convEta1"," converted Photon Eta >1 track",etaBin,etaMin, etaMax) ;
00940     h_convEta_[1] = dbe_->book1D("convEta2"," converted Photon Eta =2 tracks ",etaBin,etaMin, etaMax) ;
00941     h_convEta_[2] = dbe_->book1D("convEta2ass"," converted Photon Eta =2 tracks, both ass ",etaBin,etaMin, etaMax) ;
00942     h_convPhi_[0] = dbe_->book1D("convPhi"," converted Photon  Phi ",phiBin,phiMin,phiMax) ;
00943 
00944 
00945     histname = "convERes";
00946     h_convERes_[0][0] = dbe_->book1D(histname+"All"," Conversion rec/true Energy: All ecal ", resBin,resMin, resMax);
00947     h_convERes_[0][1] = dbe_->book1D(histname+"Barrel"," Conversion rec/true Energy: Barrel ",resBin,resMin, resMax);
00948     h_convERes_[0][2] = dbe_->book1D(histname+"Endcap"," Conversion rec/true Energy: Endcap ",resBin,resMin, resMax);
00949 
00950     histname="p_EResVsR";
00951     p_eResVsR_ = dbe_->bookProfile(histname+"All"," photons conversion E/Etrue vs R: all Ecal ",rBin,rMin,rMax, 100, 0.,1.5,"");
00952 
00953 
00954     histname = "convPtRes";
00955     h_convPtRes_[1][0] = dbe_->book1D(histname+"All"," Conversion Pt rec/true  from tracks : All ecal ", resBin,0.,1.5);
00956     h_convPtRes_[1][1] = dbe_->book1D(histname+"Barrel"," Conversion Pt rec/true  from tracks: Barrel ",resBin,0., 1.5);
00957     h_convPtRes_[1][2] = dbe_->book1D(histname+"Endcap"," Conversion Pt rec/true  from tracks: Endcap ",resBin,0., 1.5);
00958 
00959 
00960     if ( ! isRunCentrally_ ) {
00961       histname="r9VsTracks";
00962       h_r9VsNofTracks_[0][0] = dbe_->book2D(histname+"All"," photons r9 vs nTracks from conversions: All Ecal",r9Bin,r9Min, r9Max, 3, -0.5, 2.5) ;
00963       h_r9VsNofTracks_[0][1] = dbe_->book2D(histname+"Barrel"," photons r9 vs nTracks from conversions: Barrel Ecal",r9Bin,r9Min, r9Max, 3, -0.5, 2.5) ;
00964       h_r9VsNofTracks_[0][2] = dbe_->book2D(histname+"Endcap"," photons r9 vs nTracks from conversions: Endcap Ecal",r9Bin,r9Min, r9Max, 3, -0.5, 2.5) ;
00965     }
00966 
00967     histname="mvaOut";
00968     h_mvaOut_[0] = dbe_->book1D(histname+"All"," mvaOut for all conversions : All Ecal",100, 0., 1.);
00969     h_mvaOut_[1] = dbe_->book1D(histname+"Barrel"," mvaOut for all conversions : Barrel Ecal",100, 0., 1.);
00970     h_mvaOut_[2] = dbe_->book1D(histname+"Endcap"," mvaOut for all conversions : Endcap Ecal",100, 0., 1.);
00971 
00972 
00973 
00974     histname="EoverPtracks";
00975     h_EoverPTracks_[0][0] = dbe_->book1D(histname+"BarrelPix"," photons conversion E/p: barrel pix",eoverpBin, eoverpMin,eoverpMax);
00976     h_EoverPTracks_[0][1] = dbe_->book1D(histname+"BarrelTib"," photons conversion E/p: barrel tib",eoverpBin, eoverpMin,eoverpMax);
00977     h_EoverPTracks_[0][2] = dbe_->book1D(histname+"BarrelTob"," photons conversion E/p: barrel tob ",eoverpBin, eoverpMin,eoverpMax);
00978 
00979     h_EoverPTracks_[1][0] = dbe_->book1D(histname+"All"," photons conversion E/p: all Ecal ",100, 0., 5.);
00980     h_EoverPTracks_[1][1] = dbe_->book1D(histname+"Barrel"," photons conversion E/p: Barrel Ecal",100, 0., 5.);
00981     h_EoverPTracks_[1][2] = dbe_->book1D(histname+"Endcap"," photons conversion E/p: Endcap Ecal ",100, 0., 5.);
00982 
00983     histname="PoverEtracks";
00984     h_PoverETracks_[1][0] = dbe_->book1D(histname+"All"," photons conversion p/E: all Ecal ",povereBin, povereMin, povereMax);
00985     h_PoverETracks_[1][1] = dbe_->book1D(histname+"Barrel"," photons conversion p/E: Barrel Ecal",povereBin, povereMin, povereMax);
00986     h_PoverETracks_[1][2] = dbe_->book1D(histname+"Endcap"," photons conversion p/E: Endcap Ecal ",povereBin, povereMin, povereMax);
00987 
00988     histname="pEoverEtrueVsEta";
00989     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,"");
00990 
00991     histname="pEoverEtrueVsR";
00992     p_EoverEtrueVsR_[0] = dbe_->bookProfile(histname+"All"," photons conversion E/Etrue vs R: all Ecal ",rBin,rMin,rMax, 100, 0., 2.5, "");
00993 
00994     histname="pEoverEtrueVsEta";
00995     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,"");
00996 
00997     histname="pPoverPtrueVsEta";
00998     p_PoverPtrueVsEta_[0] = dbe_->bookProfile(histname+"All"," photons conversion P/Ptrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 5.,"");
00999 
01000     histname="pEoverPVsEta";
01001     p_EoverPVsEta_[0] = dbe_->bookProfile(histname+"All"," photons conversion E/P vs #eta: all Ecal ",etaBin2,etaMin, etaMax, 100, 0., 5.,"");
01002 
01003 
01004     if ( ! isRunCentrally_ ) {
01005       histname="EoverEtrueVsEoverP";
01006       h2_EoverEtrueVsEoverP_[0] = dbe_->book2D(histname+"All"," photons conversion E/Etrue vs E/P: all Ecal ",100, 0., 5., 100, 0.5, 1.5);
01007       h2_EoverEtrueVsEoverP_[1] = dbe_->book2D(histname+"Barrel"," photons conversion  E/Etrue vs E/: Barrel Ecal",100, 0., 5.,100, 0.5, 1.5);
01008       h2_EoverEtrueVsEoverP_[2] = dbe_->book2D(histname+"Endcap"," photons conversion  E/Etrue vs E/: Endcap Ecal ",100, 0., 5., 100, 0.5, 1.5);
01009       histname="PoverPtrueVsEoverP";
01010       h2_PoverPtrueVsEoverP_[0] = dbe_->book2D(histname+"All"," photons conversion P/Ptrue vs E/P: all Ecal ",100, 0., 5., 100, 0., 2.5);
01011       h2_PoverPtrueVsEoverP_[1] = dbe_->book2D(histname+"Barrel"," photons conversion  P/Ptrue vs E/: Barrel Ecal",100, 0., 5.,100, 0., 2.5);
01012       h2_PoverPtrueVsEoverP_[2] = dbe_->book2D(histname+"Endcap"," photons conversion  P/Ptrue vs E/: Endcap Ecal ",100, 0., 5., 100, 0., 2.5);
01013 
01014       histname="EoverEtrueVsEta";
01015       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);
01016 
01017 
01018       histname="EoverEtrueVsEta";
01019       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);
01020 
01021       histname="EoverEtrueVsR";
01022       h2_EoverEtrueVsR_[0] = dbe_->book2D(histname+"All"," photons conversion E/Etrue vs R: all Ecal ",rBin,rMin, rMax,100, 0., 2.5);
01023 
01024       histname="PoverPtrueVsEta";
01025       h2_PoverPtrueVsEta_[0] = dbe_->book2D(histname+"All"," photons conversion P/Ptrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 5.);
01026 
01027       histname="EoverPVsEta";
01028       h2_EoverPVsEta_[0] = dbe_->book2D(histname+"All"," photons conversion E/P vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 5.);
01029 
01030       histname="EoverPVsR";
01031       h2_EoverPVsR_[0] = dbe_->book2D(histname+"All"," photons conversion E/P vs R: all Ecal ",rBin,rMin, rMax,100, 0., 5.);
01032 
01033       histname="etaVsRsim";
01034       h2_etaVsRsim_[0] = dbe_->book2D(histname+"All"," eta(sim) vs R (sim) for associated conversions: all Ecal ",etaBin, etaMin, etaMax,rBin,rMin, rMax);
01035       histname="etaVsRreco";
01036       h2_etaVsRreco_[0] = dbe_->book2D(histname+"All"," eta(reco) vs R (reco) for associated conversions: all Ecal ",etaBin, etaMin, etaMax,rBin,rMin, rMax);
01037 
01038     }
01039 
01040     histname="pEoverPVsR";
01041     p_EoverPVsR_[0] = dbe_->bookProfile(histname+"All"," photons conversion E/P vs R: all Ecal ",rBin,rMin,rMax, 100, 0., 5.,"");
01042 
01043 
01044     histname="hInvMass";
01045     h_invMass_[0][0]= dbe_->book1D(histname+"All_AllTracks"," Photons:Tracks from conversion: Pair invariant mass: all Ecal ",100, 0., 1.5);
01046     h_invMass_[0][1]= dbe_->book1D(histname+"Barrel_AllTracks"," Photons:Tracks from conversion: Pair invariant mass: Barrel Ecal ",100, 0., 1.5);
01047     h_invMass_[0][2]= dbe_->book1D(histname+"Endcap_AllTracks"," Photons:Tracks from conversion: Pair invariant mass: Endcap Ecal ",100, 0., 1.5);
01048     histname="hInvMass";
01049     h_invMass_[1][0]= dbe_->book1D(histname+"All_AssTracks"," Photons:Tracks from conversion: Pair invariant mass: all Ecal ",100, 0., 1.5);
01050     h_invMass_[1][1]= dbe_->book1D(histname+"Barrel_AssTracks"," Photons:Tracks from conversion: Pair invariant mass: Barrel Ecal ",100, 0., 1.5);
01051     h_invMass_[1][2]= dbe_->book1D(histname+"Endcap_AssTracks"," Photons:Tracks from conversion: Pair invariant mass: Endcap Ecal ",100, 0., 1.5);
01052 
01053 
01054     histname="hDPhiTracksAtVtx";
01055     h_DPhiTracksAtVtx_[1][0] =dbe_->book1D(histname+"All", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: all Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
01056     h_DPhiTracksAtVtx_[1][1] =dbe_->book1D(histname+"Barrel", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Barrel Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
01057     h_DPhiTracksAtVtx_[1][2] =dbe_->book1D(histname+"Endcap", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Endcap Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
01058 
01059 
01060     if ( ! isRunCentrally_ ) {
01061       histname="hDPhiTracksAtVtxVsEta";
01062       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);
01063 
01064       histname="hDPhiTracksAtVtxVsR";
01065       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);
01066 
01067       histname="hDCotTracksVsEta";
01068       h2_DCotTracksVsEta_ = dbe_->book2D(histname+"All","  Photons:Tracks from conversions:  #delta cotg(#Theta) Tracks vs #eta",etaBin2,etaMin, etaMax,100, -0.2, 0.2);
01069 
01070       histname="hDCotTracksVsR";
01071       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);
01072 
01073       histname="h2_DPhiTracksAtEcalVsR";
01074       h2_DPhiTracksAtEcalVsR_= dbe_->book2D(histname+"All"," Photons:Tracks from conversions:  #delta#phi at Ecal vs R : all Ecal ",rBin,rMin, rMax, dPhiTracksBin,0.,dPhiTracksMax);
01075 
01076       histname="h2_DPhiTracksAtEcalVsEta";
01077       h2_DPhiTracksAtEcalVsEta_= dbe_->book2D(histname+"All"," Photons:Tracks from conversions:  #delta#phi at Ecal vs #eta : all Ecal ",etaBin2,etaMin, etaMax, dPhiTracksBin,0.,dPhiTracksMax);
01078 
01079 
01080     }
01081 
01082     histname="pDPhiTracksAtVtxVsEta";
01083     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,"");
01084 
01085     histname="pDPhiTracksAtVtxVsR";
01086     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,"");
01087 
01088 
01089     histname="hDCotTracks";
01090     h_DCotTracks_[1][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: all Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
01091     h_DCotTracks_[1][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Barrel Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
01092     h_DCotTracks_[1][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Endcap Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
01093 
01094 
01095     histname="pDCotTracksVsEta";
01096     p_DCotTracksVsEta_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions:  #delta cotg(#Theta) Tracks vs #eta ",etaBin2,etaMin, etaMax, 100, -0.2, 0.2,"");
01097 
01098     histname="pDCotTracksVsR";
01099     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,"");
01100 
01101 
01102     histname="hDistMinAppTracks";
01103     h_distMinAppTracks_[1][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions Min Approach Dist Tracks: all Ecal ",dEtaTracksBin,-0.1,0.6);
01104     h_distMinAppTracks_[1][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions Min Approach Dist Tracks: Barrel Ecal ",dEtaTracksBin,-0.1,0.6);
01105     h_distMinAppTracks_[1][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions Min Approach Dist Tracks: Endcap Ecal ",dEtaTracksBin,-0.1,0.6);
01106 
01107     histname="hDPhiTracksAtEcal";
01108     h_DPhiTracksAtEcal_[1][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions:  #delta#phi at Ecal : all Ecal ",dPhiTracksBin,0.,dPhiTracksMax);
01109     h_DPhiTracksAtEcal_[1][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions:  #delta#phi at Ecal : Barrel Ecal ",dPhiTracksBin,0.,dPhiTracksMax);
01110     h_DPhiTracksAtEcal_[1][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions:  #delta#phi at Ecal : Endcap Ecal ",dPhiTracksBin,0.,dPhiTracksMax);
01111 
01112     histname="pDPhiTracksAtEcalVsR";
01113     p_DPhiTracksAtEcalVsR_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions:  #delta#phi at Ecal  vs R ",rBin,rMin, rMax, dPhiTracksBin,0.,dPhiTracksMax,"");
01114 
01115     histname="pDPhiTracksAtEcalVsEta";
01116     p_DPhiTracksAtEcalVsEta_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions:  #delta#phi at Ecal  vs #eta ",etaBin2,etaMin, etaMax,dPhiTracksBin,0.,dPhiTracksMax,"");
01117 
01118 
01119     histname="hDEtaTracksAtEcal";
01120     h_DEtaTracksAtEcal_[1][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions:  #delta#eta at Ecal : all Ecal ",dEtaTracksBin,dEtaTracksMin,dEtaTracksMax);
01121     h_DEtaTracksAtEcal_[1][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions:  #delta#eta at Ecal : Barrel Ecal ",dEtaTracksBin,dEtaTracksMin,dEtaTracksMax);
01122     h_DEtaTracksAtEcal_[1][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions:  #delta#eta at Ecal : Endcap Ecal ",dEtaTracksBin,dEtaTracksMin,dEtaTracksMax);
01123 
01124 
01125     h_convVtxRvsZ_[0] =   dbe_->book2D("convVtxRvsZAll"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
01126     h_convVtxRvsZ_[1] =   dbe_->book2D("convVtxRvsZBarrel"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
01127     h_convVtxRvsZ_[2] =   dbe_->book2D("convVtxRvsZEndcap"," Photon Reco conversion vtx position",zBin2ForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
01128     h_convVtxYvsX_ =   dbe_->book2D("convVtxYvsXTrkBarrel"," Photon Reco conversion vtx position, (x,y) eta<1 ",100, -80., 80., 100, -80., 80.);
01130     if ( ! isRunCentrally_ ) {
01131       h_convVtxRvsZ_zoom_[0] =  dbe_->book2D("convVtxRvsZBarrelZoom1"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, -10., 40.);
01132       h_convVtxRvsZ_zoom_[1] =  dbe_->book2D("convVtxRvsZBarrelZoom2"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, -10., 20.);
01133       h_convVtxYvsX_zoom_[0] =   dbe_->book2D("convVtxYvsXTrkBarrelZoom1"," Photon Reco conversion vtx position, (x,y) eta<1 ",100, -40., 40., 100, -40., 40.);
01134       h_convVtxYvsX_zoom_[1] =   dbe_->book2D("convVtxYvsXTrkBarrelZoom2"," Photon Reco conversion vtx position, (x,y) eta<1 ",100, -20., 20., 100, -20., 20.);
01135     }
01136 
01137     h_convVtxdX_ =   dbe_->book1D("convVtxdX"," Photon Reco conversion vtx dX",100, -20.,20.);
01138     h_convVtxdY_ =   dbe_->book1D("convVtxdY"," Photon Reco conversion vtx dY",100, -20.,20.);
01139     h_convVtxdZ_ =   dbe_->book1D("convVtxdZ"," Photon Reco conversion vtx dZ",100, -20.,20.);
01140     h_convVtxdR_ =   dbe_->book1D("convVtxdR"," Photon Reco conversion vtx dR",100, -20.,20.);
01141 
01142     h_convVtxdX_barrel_ =   dbe_->book1D("convVtxdX_barrel"," Photon Reco conversion vtx dX, |eta|<=1.2",100, -20.,20.);
01143     h_convVtxdY_barrel_ =   dbe_->book1D("convVtxdY_barrel"," Photon Reco conversion vtx dY, |eta|<=1.2 ",100, -20.,20.);
01144     h_convVtxdZ_barrel_ =   dbe_->book1D("convVtxdZ_barrel"," Photon Reco conversion vtx dZ, |eta|<=1.2,",100, -20.,20.);
01145     h_convVtxdR_barrel_ =   dbe_->book1D("convVtxdR_barrel"," Photon Reco conversion vtx dR, |eta|<=1.2",100, -20.,20.);
01146     h_convVtxdX_endcap_ =   dbe_->book1D("convVtxdX_endcap"," Photon Reco conversion vtx dX,  |eta|>1.2",100, -20.,20.);
01147     h_convVtxdY_endcap_ =   dbe_->book1D("convVtxdY_endcap"," Photon Reco conversion vtx dY,  |eta|>1.2",100, -20.,20.);
01148     h_convVtxdZ_endcap_ =   dbe_->book1D("convVtxdZ_endcap"," Photon Reco conversion vtx dZ,  |eta|>1.2",100, -20.,20.);
01149     h_convVtxdR_endcap_ =   dbe_->book1D("convVtxdR_endcap"," Photon Reco conversion vtx dR,  |eta|>1.2 ",100, -20.,20.);
01150 
01151 
01152     h_convVtxdPhi_ =   dbe_->book1D("convVtxdPhi"," Photon Reco conversion vtx dPhi",100, -0.005,0.005);
01153     h_convVtxdEta_ =   dbe_->book1D("convVtxdEta"," Photon Reco conversion vtx dEta",100, -0.5,0.5);
01154 
01155     if ( ! isRunCentrally_ ) {
01156       h2_convVtxdRVsR_ =  dbe_->book2D("h2ConvVtxdRVsR","Photon Reco conversion vtx dR vsR" ,rBin,rMin, rMax,100, -20.,20.);
01157       h2_convVtxdRVsEta_ =  dbe_->book2D("h2ConvVtxdRVsEta","Photon Reco conversion vtx dR vs Eta" ,etaBin2,etaMin, etaMax,100, -20.,20.);
01158     }
01159 
01160     p_convVtxdRVsR_ =  dbe_->bookProfile("pConvVtxdRVsR","Photon Reco conversion vtx dR vsR" ,rBin,rMin, rMax ,100, -20.,20., "");
01161     p_convVtxdRVsEta_ =  dbe_->bookProfile("pConvVtxdRVsEta","Photon Reco conversion vtx dR vs Eta" ,etaBin2,etaMin, etaMax, 100, -20.,20., "");
01162     p_convVtxdXVsX_ =  dbe_->bookProfile("pConvVtxdXVsX","Conversion vtx dX vs X" ,120,-60, 60 ,100, -20.,20., "");
01163     p_convVtxdYVsY_ =  dbe_->bookProfile("pConvVtxdYVsY","Conversion vtx dY vs Y" ,120,-60, 60 ,100, -20.,20., "");
01164     p_convVtxdZVsZ_ =  dbe_->bookProfile("pConvVtxdZVsZ","Conversion vtx dZ vs Z" ,zBin,zMin,zMax ,100, -20.,20., "");
01165 
01166 
01167     if ( ! isRunCentrally_ ) {
01168       h2_convVtxRrecVsTrue_ =  dbe_->book2D("h2ConvVtxRrecVsTrue","Photon Reco conversion vtx R rec vs true" ,rBin,rMin, rMax,rBin,rMin, rMax);
01169     }
01170 
01171     histname="vtxChi2";
01172     h_vtxChi2_[0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 100, chi2Min, chi2Max);
01173     h_vtxChi2_[1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 100, chi2Min, chi2Max);
01174     h_vtxChi2_[2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 100, chi2Min, chi2Max);
01175     histname="vtxChi2Prob";
01176     h_vtxChi2Prob_[0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 100, 0., 1.);
01177     h_vtxChi2Prob_[1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 100, 0., 1.);
01178     h_vtxChi2Prob_[2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 100, 0., 1.);
01179 
01180     histname="zPVFromTracks";
01181     h_zPVFromTracks_[0] =  dbe_->book1D(histname+"All"," Photons: PV z from conversion tracks",   100, -30., 30.);
01182     h_zPVFromTracks_[1] =  dbe_->book1D(histname+"Barrel"," Photons: PV z from conversion tracks",100, -30., 30.);
01183     h_zPVFromTracks_[2] =  dbe_->book1D(histname+"Endcap"," Photons: PV z from conversion tracks",100, -30., 30.);
01184     h_zPVFromTracks_[3] =  dbe_->book1D(histname+"EndcapP"," Photons: PV z from conversion tracks",100, -30., 30.);
01185     h_zPVFromTracks_[4] =  dbe_->book1D(histname+"EndcapM"," Photons: PV z from conversion tracks",100, -30., 30.);
01186     histname="dzPVFromTracks";
01187     h_dzPVFromTracks_[0] =  dbe_->book1D(histname+"All"," Photons: PV Z_rec - Z_true from conversion tracks",   100, -10., 10.);
01188     h_dzPVFromTracks_[1] =  dbe_->book1D(histname+"Barrel"," Photons: PV Z_rec - Z_true from conversion tracks",100, -10., 10.);
01189     h_dzPVFromTracks_[2] =  dbe_->book1D(histname+"Endcap"," Photons: PV Z_rec - Z_true from conversion tracks",100, -10., 10.);
01190     h_dzPVFromTracks_[3] =  dbe_->book1D(histname+"EndcapP"," Photons: PV Z_rec - Z_true from conversion tracks",100, -10., 10.);
01191     h_dzPVFromTracks_[4] =  dbe_->book1D(histname+"EndcapM"," Photons: PV Z_rec - Z_true from conversion tracks",100, -10., 10.);
01192     p_dzPVVsR_ =  dbe_->bookProfile("pdzPVVsR","Photon Reco conversions: dz(PV) vs R" ,rBin,rMin, rMax, 100, -3.,3.,"");
01193     p_dzPVVsEta_ =  dbe_->bookProfile("pdzPVVsEta","Photon Reco conversions: dz(PV) vs Eta" ,etaBin,etaMin, etaMax, 100, -3.,3.,"");
01194 
01195     if ( ! isRunCentrally_ ) {
01196       h2_dzPVVsR_ =  dbe_->book2D("h2dzPVVsR","Photon Reco conversions: dz(PV) vs R" ,rBin,rMin, rMax,100, -3.,3.);
01197     }
01198 
01200     if ( ! isRunCentrally_ ) {
01201       histname="nHitsVsEta";
01202       nHitsVsEta_[0] =  dbe_->book2D(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs #eta all tracks",etaBin,etaMin, etaMax,25,0., 25.);
01203 
01204       histname="nHitsVsEta";
01205       nHitsVsEta_[1] =  dbe_->book2D(histname+"AssTracks","Photons:Tracks from conversions: # of hits vs #eta associated tracks",etaBin,etaMin, etaMax,25,0., 25.);
01206 
01207       histname="nHitsVsR";
01208       nHitsVsR_[0] =  dbe_->book2D(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs radius all tracks" ,rBin,rMin, rMax,25,0.,25);
01209 
01210       histname="nHitsVsR";
01211       nHitsVsR_[1] =  dbe_->book2D(histname+"AssTracks","Photons:Tracks from conversions: # of hits vs radius associated tracks" ,rBin,rMin, rMax,25,0.,25);
01212 
01213       histname="h2Chi2VsEta";
01214       h2_Chi2VsEta_[0]=dbe_->book2D(histname+"All"," Reco Track  #chi^{2} vs #eta: All ",etaBin2,etaMin, etaMax,100, chi2Min, chi2Max);
01215 
01216 
01217       histname="h2Chi2VsR";
01218       h2_Chi2VsR_[0]=dbe_->book2D(histname+"All"," Reco Track  #chi^{2} vs R: All ",rBin,rMin, rMax,100,chi2Min, chi2Max);
01219     }
01220 
01221     histname="h_nHitsVsEta";
01222     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,"");
01223 
01224     histname="h_nHitsVsEta";
01225     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,"");
01226 
01227 
01228     histname="h_nHitsVsR";
01229     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,"");
01230     histname="tkChi2";
01231     h_tkChi2_[0] = dbe_->book1D(histname+"AllTracks","Photons:Tracks from conversions: #chi^{2} of all tracks", 100, chi2Min, chi2Max);
01232     histname="tkChi2Large";
01233     h_tkChi2Large_[0] = dbe_->book1D(histname+"AllTracks","Photons:Tracks from conversions: #chi^{2} of all tracks", 1000, 0., 5000.0);
01234 
01235     histname="h_nHitsVsR";
01236     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,"");
01237 
01238     histname="tkChi2";
01239     h_tkChi2_[1] = dbe_->book1D(histname+"AssTracks","Photons:Tracks from conversions: #chi^{2} of associated  tracks", 100, chi2Min, chi2Max);
01240     histname="tkChi2Large";
01241     h_tkChi2Large_[1] = dbe_->book1D(histname+"AssTracks","Photons:Tracks from conversions: #chi^{2} of associated  tracks", 1000, 0., 5000.0);
01242 
01243     histname="pChi2VsEta";
01244     p_Chi2VsEta_[0]=dbe_->bookProfile(histname+"All"," Reco Track #chi^{2} vs #eta : All ",etaBin2,etaMin, etaMax, 100, chi2Min, chi2Max,"");
01245 
01246     histname="pChi2VsR";
01247     p_Chi2VsR_[0]=dbe_->bookProfile(histname+"All"," Reco Track #chi^{2} vas R : All ",rBin,rMin,rMax, 100,chi2Min, chi2Max,"");
01248 
01249 
01250     histname="hTkD0";
01251     h_TkD0_[0]=dbe_->book1D(histname+"All"," Reco Track D0*q: All ",100,-0.1,0.6);
01252     h_TkD0_[1]=dbe_->book1D(histname+"Barrel"," Reco Track D0*q: Barrel ",100,-0.1,0.6);
01253     h_TkD0_[2]=dbe_->book1D(histname+"Endcap"," Reco Track D0*q: Endcap ",100,-0.1,0.6);
01254 
01255 
01256     histname="hTkPtPull";
01257     h_TkPtPull_[0]=dbe_->book1D(histname+"All"," Reco Track Pt pull: All ",100, -10., 10.);
01258     histname="hTkPtPull";
01259     h_TkPtPull_[1]=dbe_->book1D(histname+"Barrel"," Reco Track Pt pull: Barrel ",100, -10., 10.);
01260     histname="hTkPtPull";
01261     h_TkPtPull_[2]=dbe_->book1D(histname+"Endcap"," Reco Track Pt pull: Endcap ",100, -10., 10.);
01262 
01263     histname="pTkPtPullEta";
01264     p_TkPtPull_[0]=dbe_->bookProfile(histname+"All"," Reco Track Pt pull: All ",etaBin2,etaMin, etaMax, 100, -10., 10., " ");
01265 
01266     if ( ! isRunCentrally_ ) {
01267       histname="h2TkPtPullEta";
01268       h2_TkPtPull_[0]=dbe_->book2D(histname+"All"," Reco Track Pt pull: All ",etaBin2,etaMin, etaMax,100, -10., 10.);
01269 
01270       histname="PtRecVsPtSim";
01271       h2_PtRecVsPtSim_[0]=dbe_->book2D(histname+"All", "Pt Rec vs Pt sim: All ", etBin,etMin,etMax,etBin,etMin, etMax);
01272       h2_PtRecVsPtSim_[1]=dbe_->book2D(histname+"Barrel", "Pt Rec vs Pt sim: Barrel ", etBin,etMin,etMax,etBin,etMin, etMax);
01273       h2_PtRecVsPtSim_[2]=dbe_->book2D(histname+"Endcap", "Pt Rec vs Pt sim: Endcap ", etBin,etMin,etMax,etBin,etMin, etMax);
01274       histname="PtRecVsPtSimMixProv";
01275       h2_PtRecVsPtSimMixProv_ =dbe_->book2D(histname+"All", "Pt Rec vs Pt sim All for mix with general tracks ", etBin,etMin,etMax,etBin,etMin, etMax);
01276     }
01277 
01278 
01279     histname="eBcOverTkPout";
01280     hBCEnergyOverTrackPout_[0] = dbe_->book1D(histname+"All","Matrching BC E/P_out: all Ecal ",100, 0., 5.);
01281     hBCEnergyOverTrackPout_[1] = dbe_->book1D(histname+"Barrel","Matrching BC E/P_out: Barrel ",100, 0., 5.);
01282     hBCEnergyOverTrackPout_[2] = dbe_->book1D(histname+"Endcap","Matrching BC E/P_out: Endcap ",100, 0., 5.);
01283 
01284 
01286     h_OIinnermostHitR_ = dbe_->book1D("OIinnermostHitR"," R innermost hit for OI tracks ",50, 0., 25);
01287     h_IOinnermostHitR_ = dbe_->book1D("IOinnermostHitR"," R innermost hit for IO tracks ",50, 0., 25);
01288 
01290     h_trkProv_[0] = dbe_->book1D("allTrkProv"," Track pair provenance ",4, 0., 4.);
01291     h_trkProv_[1] = dbe_->book1D("assTrkProv"," Track pair provenance ",4, 0., 4.);
01292 
01293     // histos for fake rate
01294     histname = "h_RecoConvTwoTracksEta";
01295     h_RecoConvTwoTracks_[0] =  dbe_->book1D(histname," All reco conversions with 2 reco  tracks: simulated #eta",etaBin2,etaMin, etaMax);
01296     histname = "h_RecoConvTwoTracksPhi";
01297     h_RecoConvTwoTracks_[1] =  dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated #phi",phiBin,phiMin, phiMax);
01298     histname = "h_RecoConvTwoTracksR";
01299     h_RecoConvTwoTracks_[2] =  dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated R",rBin,rMin, rMax);
01300     histname = "h_RecoConvTwoTracksZ";
01301     h_RecoConvTwoTracks_[3] =  dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated Z",zBin,zMin, zMax);
01302     histname = "h_RecoConvTwoTracksEt";
01303     h_RecoConvTwoTracks_[4] =  dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated Et",etBin,etMin, etMax);
01304     //
01305     histname = "h_RecoConvTwoMTracksEta";
01306     h_RecoConvTwoMTracks_[0] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated #eta",etaBin2,etaMin, etaMax);
01307     histname = "h_RecoConvTwoMTracksPhi";
01308     h_RecoConvTwoMTracks_[1] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated #phi",phiBin,phiMin, phiMax);
01309     histname = "h_RecoConvTwoMTracksR";
01310     h_RecoConvTwoMTracks_[2] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated R",rBin,rMin, rMax);
01311     histname = "h_RecoConvTwoMTracksZ";
01312     h_RecoConvTwoMTracks_[3] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated Z",zBin,zMin, zMax);
01313     histname = "h_RecoConvTwoMTracksEt";
01314     h_RecoConvTwoMTracks_[4] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated Et",etBin,etMin, etMax);
01315 
01316 
01317 
01318 
01319   } // if DQM
01320 
01321 
01322 
01323 }
01324 
01325 
01326 
01327  void  PhotonValidator::beginRun (edm::Run const & r, edm::EventSetup const & theEventSetup) {
01328 
01329    //get magnetic field
01330   edm::LogInfo("ConvertedPhotonProducer") << " get magnetic field" << "\n";
01331   theEventSetup.get<IdealMagneticFieldRecord>().get(theMF_);
01332 
01333 
01334   edm::ESHandle<TrackAssociatorBase> theHitsAssociator;
01335   theEventSetup.get<TrackAssociatorRecord>().get("trackAssociatorByHitsForPhotonValidation",theHitsAssociator);
01336   theTrackAssociator_ = (TrackAssociatorBase *) theHitsAssociator.product();
01337 
01338   thePhotonMCTruthFinder_ = new PhotonMCTruthFinder();
01339 
01340 }
01341 
01342 void  PhotonValidator::endRun (edm::Run& r, edm::EventSetup const & theEventSetup) {
01343 
01344   delete thePhotonMCTruthFinder_;
01345 
01346 }
01347 
01348 
01349 
01350 void PhotonValidator::analyze( const edm::Event& e, const edm::EventSetup& esup ) {
01351 
01352 
01353   using namespace edm;
01354   //  const float etaPhiDistance=0.01;
01355   // Fiducial region
01356   // const float TRK_BARL =0.9;
01357   const float BARL = 1.4442; // DAQ TDR p.290
01358   //  const float END_LO = 1.566; // unused
01359   const float END_HI = 2.5;
01360   // Electron mass
01361   //const Float_t mElec= 0.000511;
01362 
01363 
01364   nEvt_++;
01365   LogInfo("PhotonValidator") << "PhotonValidator Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n";
01366   //  std::cout << "PhotonValidator Analyzing event number: "  << e.id() << " Global Counter " << nEvt_ <<"\n";
01367 
01368 
01369   // get the geometry from the event setup:
01370   esup.get<CaloGeometryRecord>().get(theCaloGeom_);
01371 
01372   edm::Handle<reco::VertexCollection> vtxH;
01373   e.getByLabel("offlinePrimaryVertices", vtxH);
01374   h_nRecoVtx_ ->Fill (float(vtxH->size()));
01375 
01376   // Transform Track into TransientTrack (needed by the Vertex fitter)
01377   edm::ESHandle<TransientTrackBuilder> theTTB;
01378   esup.get<TransientTrackRecord>().get("TransientTrackBuilder",theTTB);
01379 
01380 
01382   Handle<reco::PhotonCollection> photonHandle;
01383   e.getByLabel(photonCollectionProducer_, photonCollection_ , photonHandle);
01384   const reco::PhotonCollection photonCollection = *(photonHandle.product());
01385   if (!photonHandle.isValid()) {
01386     edm::LogError("PhotonProducer") << "Error! Can't get the Photon collection "<< std::endl;
01387     return;
01388   }
01389 
01390   Handle< edm::View<reco::Track> > outInTrkHandle;
01391   Handle< edm::View<reco::Track> > inOutTrkHandle;
01392   if ( !fastSim_) {
01394     e.getByLabel(conversionOITrackProducer_,  outInTrkHandle);
01395     //std::cout << "ConvPhoAnalyzerWithOfficialAssociation  outInTrack collection size " << (*outInTrkHandle).size() << "\n";
01396 
01398     e.getByLabel(conversionIOTrackProducer_, inOutTrkHandle);
01399     //std::cout  << " ConvPhoAnalyzerWithOfficialAssociation inOutTrack collection size " << (*inOutTrkHandle).size() << "\n";
01400 
01401     // Loop over Out In Tracks
01402     int iTrk=0;
01403     int nHits=0;
01404     for( View<reco::Track>::const_iterator    iTk =  (*outInTrkHandle).begin(); iTk !=  (*outInTrkHandle).end(); iTk++) {
01405       //    std::cout  << " Barrel  Out In Track charge " << iTk->charge() << " Num of RecHits " << iTk->recHitsSize() << " inner momentum " << sqrt( iTk->innerMomentum().Mag2() ) << "\n";
01406       // std::cout  << " Barrel Out In Track Extra inner momentum  " << sqrt(iTk->extra()->innerMomentum().Mag2()) <<  " inner position R " <<  sqrt( iTk->innerPosition().Perp2() ) << "\n";
01407       h_OIinnermostHitR_ ->Fill ( sqrt( iTk->innerPosition().Perp2() ) );
01408       for (  trackingRecHit_iterator itHits=iTk->extra()->recHitsBegin();  itHits!=iTk->extra()->recHitsEnd(); ++itHits ) {
01409         if ( (*itHits)->isValid() ) {
01410           nHits++;
01411           //    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";
01412         }
01413 
01414 
01415       }
01416 
01417       iTrk++;
01418 
01419 
01420     }
01421 
01422     // Loop over In Out Tracks Barrel
01423     iTrk=0;
01424     for( View<reco::Track>::const_iterator    iTk =  (*inOutTrkHandle).begin(); iTk !=  (*inOutTrkHandle).end(); iTk++) {
01425       //std::cout  << " Barrel In Out Track charge " << iTk->charge() << " Num of RecHits " << iTk->recHitsSize() << " inner momentum " << sqrt( iTk->innerMomentum().Mag2())  << "\n";
01426       // std::cout   << " Barrel In Out  Track Extra inner momentum  " << sqrt(iTk->extra()->innerMomentum().Mag2()) << "\n";
01427       h_IOinnermostHitR_ ->Fill ( sqrt( iTk->innerPosition().Perp2() ) );
01428       nHits=0;
01429       for (  trackingRecHit_iterator itHits=iTk->extra()->recHitsBegin();  itHits!=iTk->extra()->recHitsEnd(); ++itHits ) {
01430         if ( (*itHits)->isValid() ) {
01431           nHits++;
01432           //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";
01433 
01434         }
01435       }
01436 
01437 
01438 
01439       iTrk++;
01440     }
01441 
01442   }  // if !fastSim
01443 
01444 
01446   //get simtrack info
01447   std::vector<SimTrack> theSimTracks;
01448   std::vector<SimVertex> theSimVertices;
01449   edm::Handle<SimTrackContainer> SimTk;
01450   edm::Handle<SimVertexContainer> SimVtx;
01451 
01452   if ( ! fastSim_) {
01453     e.getByLabel("g4SimHits",SimTk);
01454     e.getByLabel("g4SimHits",SimVtx);
01455   } else {
01456     e.getByLabel("famosSimHits",SimTk);
01457     e.getByLabel("famosSimHits",SimVtx);
01458 
01459   }
01460 
01461 
01462 
01463   theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
01464   theSimVertices.insert(theSimVertices.end(),SimVtx->begin(),SimVtx->end());
01465   std::vector<PhotonMCTruth> mcPhotons=thePhotonMCTruthFinder_->find (theSimTracks,  theSimVertices);
01466 
01467   edm::Handle<edm::HepMCProduct> hepMC;
01468   e.getByLabel("generator",hepMC);
01469   const HepMC::GenEvent *myGenEvent = hepMC->GetEvent();
01470 
01471 
01472   // get generated jets
01473   Handle<reco::GenJetCollection> GenJetsHandle ;
01474   e.getByLabel("iterativeCone5GenJets","",GenJetsHandle);
01475   reco::GenJetCollection genJetCollection = *(GenJetsHandle.product());
01476 
01477 
01478 
01479   // Get electron tracking truth
01480   bool useTP= parameters_.getParameter<bool>("useTP");
01481   TrackingParticleCollection trackingParticles;
01482   edm::Handle<TrackingParticleCollection> ElectronTPHandle;
01483   if ( useTP) {
01484     if ( ! fastSim_) {
01485     e.getByLabel(label_tp_,ElectronTPHandle);
01486     //  e.getByLabel("mergedtruth","MergedTrackTruth",ElectronTPHandle);
01487     trackingParticles = *(ElectronTPHandle.product());
01488     }
01489   }
01490 
01492   std::vector<reco::PhotonCollection::const_iterator> StoRMatchedConvertedPhotons;
01493   reco::SimToRecoCollection OISimToReco;
01494   reco::SimToRecoCollection IOSimToReco;
01495   // Reco to Sim
01496   reco::RecoToSimCollection OIRecoToSim;
01497   reco::RecoToSimCollection IORecoToSim;
01498 
01499   if ( useTP) {
01500     if ( ! fastSim_) {
01501     // Sim to Reco
01502     OISimToReco = theTrackAssociator_->associateSimToReco(outInTrkHandle, ElectronTPHandle, &e);
01503     IOSimToReco = theTrackAssociator_->associateSimToReco(inOutTrkHandle, ElectronTPHandle, &e);
01504     // Reco to Sim
01505     OIRecoToSim = theTrackAssociator_->associateRecoToSim(outInTrkHandle, ElectronTPHandle, &e);
01506     IORecoToSim = theTrackAssociator_->associateRecoToSim(inOutTrkHandle, ElectronTPHandle, &e);
01507     }
01508   }
01509   //
01510   vector<reco::SimToRecoCollection*> StoRCollPtrs;
01511   StoRCollPtrs.push_back(&OISimToReco);
01512   StoRCollPtrs.push_back(&IOSimToReco);
01513   vector<reco::RecoToSimCollection*> RtoSCollPtrs;
01514   RtoSCollPtrs.push_back(&OIRecoToSim);
01515   RtoSCollPtrs.push_back(&IORecoToSim);
01516   //
01517   for (int i=0; i<2; i++)
01518     nSimPho_[i]=0;
01519   for (int i=0; i<2; i++)
01520     nSimConv_[i]=0;
01521 
01522 
01523   std::vector<reco::Photon> myPhotons;
01524   for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
01525     if ( fabs(iPho->eta()) > 2.5 ) continue;
01526     myPhotons.push_back(*iPho);
01527   }
01528 
01529   std::sort(myPhotons.begin(), myPhotons.end(), sortPhotons());
01530   if ( myPhotons.size() >=2 ) {
01531     if ( myPhotons[0].et() > 40 && myPhotons[1].et() > 25 ) {
01532 
01533       math::XYZTLorentzVector p12 = myPhotons[0].p4()+myPhotons[1].p4();
01534       float gamgamMass2 = p12.Dot(p12);
01535       if (  gamgamMass2 > 0 ) {
01536 
01537         // total
01538         h_gamgamMass_[0][0] -> Fill(sqrt( gamgamMass2 ));
01539         if (  myPhotons[0].isEB() &&     myPhotons[1].isEB() )
01540           h_gamgamMass_[0][1] -> Fill(sqrt( gamgamMass2 ));
01541         if ( (  myPhotons[0].isEE() &&   myPhotons[1].isEE() )  ||
01542              (  myPhotons[0].isEE() &&   myPhotons[1].isEB() ) ||
01543              (  myPhotons[0].isEB() &&   myPhotons[1].isEE() ) )
01544           h_gamgamMass_[0][2] -> Fill(sqrt( gamgamMass2 ));
01545 
01546 
01547         // Golden photons
01548         if (  myPhotons[0].r9() > 0.93 &&  myPhotons[1].r9() > 0.93 ) {
01549           h_gamgamMass_[1][0] -> Fill(sqrt( gamgamMass2 ));
01550           if (  myPhotons[0].isEB() &&   myPhotons[1].isEB() )
01551             h_gamgamMass_[1][1] -> Fill(sqrt( gamgamMass2 ));
01552           if ( (  myPhotons[0].isEE() &&         myPhotons[1].isEE() )  ||
01553                (  myPhotons[0].isEE() &&         myPhotons[1].isEB() ) ||
01554                (  myPhotons[0].isEB() &&         myPhotons[1].isEE() ) )
01555             h_gamgamMass_[1][2] -> Fill(sqrt( gamgamMass2 ));
01556         }
01557 
01558 
01559         // both photons converted
01560         if ( myPhotons[0].conversions().size() > 0 && myPhotons[1].conversions().size() >0 ) {
01561           if ( myPhotons[0].conversions()[0]->nTracks() ==2 &&  myPhotons[1].conversions()[0]->nTracks() ==2  ) {
01562             float chi2Prob1 = ChiSquaredProbability( myPhotons[0].conversions()[0]->conversionVertex().chi2(),  myPhotons[0].conversions()[0]->conversionVertex().ndof() );
01563             float chi2Prob2 = ChiSquaredProbability( myPhotons[1].conversions()[0]->conversionVertex().chi2(),  myPhotons[1].conversions()[0]->conversionVertex().ndof() );
01564             if ( chi2Prob1 > 0.0005 &&  chi2Prob2 > 0.0005 ) {
01565               h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
01566               if (  myPhotons[0].isEB() &&       myPhotons[1].isEB() ) {
01567                 h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
01568               }
01569               if ( (  myPhotons[0].isEE() &&     myPhotons[1].isEE() )  ||
01570                    (  myPhotons[0].isEE() &&     myPhotons[1].isEB() ) ||
01571                    (  myPhotons[0].isEB() &&     myPhotons[1].isEE() ) )
01572                 h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 )); {
01573               }
01574             }
01575           }
01576 
01577 
01578         } else if ( myPhotons[0].conversions().size() > 0 && myPhotons[1].conversions().size() ==0 && myPhotons[1].r9() > 0.93  )  {    // one photon converted
01579           if ( myPhotons[0].conversions()[0]->nTracks() ==2 ) {
01580             float chi2Prob1 = ChiSquaredProbability( myPhotons[0].conversions()[0]->conversionVertex().chi2(),  myPhotons[0].conversions()[0]->conversionVertex().ndof() );
01581             if ( chi2Prob1 > 0.0005 ) {
01582               h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
01583               if (  myPhotons[0].isEB() &&  myPhotons[1].isEB() ) {
01584                 h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
01585               }
01586               if (  myPhotons[0].isEE() ||  myPhotons[1].isEE() ) {
01587                 h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 ));
01588               }
01589             }
01590           }
01591 
01592 
01593         } else if ( myPhotons[1].conversions().size() > 0 && myPhotons[0].conversions().size() ==0 &&  myPhotons[0].r9() > 0.93 )  {    // one photon converted
01594           if ( myPhotons[1].conversions()[0]->nTracks() ==2 ) {
01595             float chi2Prob1 = ChiSquaredProbability( myPhotons[1].conversions()[0]->conversionVertex().chi2(),  myPhotons[1].conversions()[0]->conversionVertex().ndof() );
01596             if ( chi2Prob1 > 0.0005 ) {
01597               h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
01598               if (  myPhotons[0].isEB() && myPhotons[1].isEB() ) {
01599                 h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
01600               }
01601               if (  myPhotons[0].isEE() ||  myPhotons[1].isEE() ) {
01602                 h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 ));
01603               }
01604             }
01605           }
01606         }
01607 
01608 
01609       }
01610     }
01611   }
01612 
01613 
01614   //  cout << " PhotonValidator mcPhotons.size() " << mcPhotons.size() << endl;
01615   for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
01616     if ( (*mcPho).fourMomentum().et() < minPhoEtCut_ ) continue;
01617 
01618     for ( HepMC::GenEvent::particle_const_iterator mcIter=myGenEvent->particles_begin(); mcIter != myGenEvent->particles_end(); mcIter++ ) {
01619       if ( (*mcIter)->pdg_id() != 22 ) continue;
01620       bool isTheSame= false;
01621       HepMC::GenParticle* mother = 0;
01622       if ( (*mcIter)->production_vertex() )  {
01623         if ( (*mcIter)->production_vertex()->particles_begin(HepMC::parents) !=
01624              (*mcIter)->production_vertex()->particles_end(HepMC::parents))
01625           mother = *((*mcIter)->production_vertex()->particles_begin(HepMC::parents));
01626       }
01627 
01628 
01629 
01630 
01631       float mcPhi= (*mcPho).fourMomentum().phi();
01632       mcPhi_= phiNormalization(mcPhi);
01633       mcEta_= (*mcPho).fourMomentum().pseudoRapidity();
01634       mcEta_ = etaTransformation(mcEta_, (*mcPho).primaryVertex().z() );
01635       mcConvR_= (*mcPho).vertex().perp();
01636       mcConvX_= (*mcPho).vertex().x();
01637       mcConvY_= (*mcPho).vertex().y();
01638       mcConvZ_= (*mcPho).vertex().z();
01639       mcConvEta_= (*mcPho).vertex().eta();
01640       mcConvPhi_= (*mcPho).vertex().phi();
01641 
01642       if ( fabs(mcEta_) > END_HI ) continue;
01643 
01644 
01645 
01646       if (  mother ==0
01647             ||  (mother != 0  && mother->pdg_id() == 22)
01648             ||  (mother != 0  && mother->pdg_id() == 25)
01649             ||  (mother != 0  && mother->pdg_id() == 35) )
01650         {
01651           //std::cout << " ZERO mother or Higgs or primary photon  " << std::endl;
01652           //if (mother !=0) std::cout <<  mother->pdg_id() << std::endl;
01653           double dPt =  fabs((*mcIter)->momentum().perp() - (*mcPho).fourMomentum().et());
01654           float phiMother=(*mcIter)->momentum().phi();
01655           double dPhi = phiNormalization(phiMother) - mcPhi_ ;
01656           double dEta = fabs( (*mcIter)->momentum().eta() - (*mcPho).fourMomentum().pseudoRapidity() );
01657 
01658           //std::cout << " HEP photon pt " << (*mcIter)->momentum().perp() << " eta " << (*mcIter)->momentum().eta() << " phi " << (*mcIter)->momentum().phi() << std::endl;
01659           //std::cout << "   (*mcPho).motherType() selection  " <<   (*mcPho).motherType() << " pt " <<  (*mcPho).fourMomentum().et()  << " eta " << (*mcPho).fourMomentum().pseudoRapidity() << " phi " << mcPhi_ << std::endl;
01660           //std::cout << " dPt " << dPt << " dEta " << dEta << " dPhi " << dPhi << std::endl;
01661           if ( dEta <=0.0001 && dPhi <=0.0001 && dPt <=0.0001)
01662             isTheSame = true;
01663 
01664         }
01665       if ( ! isTheSame ) continue;
01666       //      std::cout << " HEP photon pt " << (*mcIter)->momentum().perp() << " eta " << (*mcIter)->momentum().eta() << " phi " << (*mcIter)->momentum().phi() << std::endl;
01667       //std::cout << "   (*mcPho).motherType() after  " <<   (*mcPho).motherType() << " pt " <<  (*mcPho).fourMomentum().et()  << " eta " << (*mcPho).fourMomentum().pseudoRapidity() << " phi " << mcPhi_ << std::endl;
01668 
01669 
01670 
01671       // if ( ! (  fabs(mcEta_) <= BARL || ( fabs(mcEta_) >= END_LO && fabs(mcEta_) <=END_HI ) ) )
01672       //        continue;  // all ecal fiducial region
01673 
01674 
01675       nSimPho_[0]++;
01676       h_SimPhoMotherEt_[0]->Fill(  (*mcPho).motherMomentum().et()  );
01677       h_SimPhoMotherEta_[0]->Fill(  (*mcPho).motherMomentum().pseudoRapidity());
01678 
01679       h_SimPho_[0]->Fill ( mcEta_);
01680       h_SimPho_[1]->Fill ( mcPhi_);
01681       h_SimPho_[2]->Fill ( (*mcPho).fourMomentum().et()   );
01682 
01683 
01684 
01685 
01687 
01688       bool goodSimConversion=false;
01689       bool visibleConversion=false;
01690       bool visibleConversionsWithTwoSimTracks=false;
01691       if (  (*mcPho).isAConversion() == 1 ) {
01692         nSimConv_[0]++;
01693         h_AllSimConv_[0]->Fill( mcEta_ ) ;
01694         h_AllSimConv_[1]->Fill( mcPhi_ );
01695         h_AllSimConv_[2]->Fill( mcConvR_ );
01696         h_AllSimConv_[3]->Fill( mcConvZ_ );
01697         h_AllSimConv_[4]->Fill(  (*mcPho).fourMomentum().et());
01698 
01699         if ( mcConvR_ <15) h_SimConvEtaPix_[0]->Fill( mcEta_ ) ;
01700 
01701         if ( ( fabs(mcEta_) <= BARL && mcConvR_ <85 )  ||
01702              ( fabs(mcEta_) > BARL && fabs(mcEta_) <=END_HI && fabs( (*mcPho).vertex().z() ) < 210 )  ) visibleConversion=true;
01703 
01704 
01705 
01706         theConvTP_.clear();
01707         //std::cout << " PhotonValidator TrackingParticles   TrackingParticleCollection size "<<  trackingParticles.size() <<  "\n";
01708         for(size_t i = 0; i < trackingParticles.size(); ++i){
01709           TrackingParticleRef tp (ElectronTPHandle,i);
01710           //std::cout << "  Electron pt " << tp -> pt() << " charge " << tp -> charge() << " pdgId " << tp->pdgId() << " Hits for this track: " << tp -> trackPSimHit().size() << std::endl;
01711           //std::cout << " track vertex position x " <<  tp->vertex().x() << " y " << tp->vertex().y() << " z " << tp->vertex().z() << std::endl;
01712           //std::cout << " track vertex position x " <<  tp->vx() << " y " << tp->vy() << " z " << tp->vz() << std::endl;
01713           //std::cout << " conversion vertex position x " <<  (*mcPho).vertex().x() << " y " << (*mcPho).vertex().y() << " z " << (*mcPho).vertex().z() << std::endl;
01714           if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.001   &&
01715                fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.001   &&
01716                fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.001) {
01717 
01718             //std::cout << " From conversion Electron pt " << tp -> pt() << " charge " << tp -> charge() << " pdgId " << tp->pdgId() << " Hits for this track: " << tp -> trackPSimHit().size() << std::endl;
01719             //  std::cout << " track vertex position x " <<  tp->vertex().x() << " y " << tp->vertex().y() << " z " << tp->vertex().z() << std::endl;
01720             //std::cout << " conversion vertex position x " <<  (*mcPho).vertex().x() << " y " << (*mcPho).vertex().y() << " z " << (*mcPho).vertex().z() << "  R " <<  (*mcPho).vertex().perp() << std::endl;
01721             theConvTP_.push_back( tp );
01722           }
01723         }
01724         //      std::cout << " PhotonValidator  theConvTP_ size " <<   theConvTP_.size() << std::endl;
01725 
01726         if ( theConvTP_.size() == 2 )   visibleConversionsWithTwoSimTracks=true;
01727         goodSimConversion=false;
01728 
01729         if (   visibleConversion && visibleConversionsWithTwoSimTracks )  goodSimConversion=true;
01730         if ( goodSimConversion ) {
01731           nSimConv_[1]++;
01732           h_VisSimConv_[0]->Fill( mcEta_ ) ;
01733           h_VisSimConv_[1]->Fill( mcPhi_ );
01734           h_VisSimConv_[2]->Fill( mcConvR_ );
01735           h_VisSimConv_[3]->Fill( mcConvZ_ );
01736           h_VisSimConv_[4]->Fill(  (*mcPho).fourMomentum().et());
01737 
01738 
01739           if ( useTP ) {
01740             for ( edm::RefVector<TrackingParticleCollection>::iterator iTrk=theConvTP_.begin(); iTrk!=theConvTP_.end(); ++iTrk) {
01741               h_simTkPt_ -> Fill ( (*iTrk)->pt() );
01742               h_simTkEta_ -> Fill ( (*iTrk)->eta() );
01743             }
01744           }
01745         }
01746       }  
01747 
01748 
01749 
01750       float minDelta=10000.;
01751       std::vector<reco::Photon> thePhotons;
01752       int index=0;
01753       int iMatch=-1;
01754       bool matched=false;
01755 
01756       //std::cout << " Reco photon size " <<  photonCollection.size() << std::endl;
01757       for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
01758         reco::Photon aPho = reco::Photon(*iPho);
01759         thePhotons.push_back(aPho);
01760         float phiPho=aPho.phi();
01761         float etaPho=aPho.eta();
01762         float deltaPhi = phiPho-mcPhi_;
01763         float deltaEta = etaPho-mcEta_;
01764         if ( deltaPhi > pi )  deltaPhi -= twopi;
01765         if ( deltaPhi < -pi) deltaPhi += twopi;
01766         deltaPhi=pow(deltaPhi,2);
01767         deltaEta=pow(deltaEta,2);
01768         float delta = sqrt( deltaPhi+deltaEta);
01769         if ( delta<0.1 && delta < minDelta ) {
01770           minDelta=delta;
01771           iMatch=index;
01772 
01773         }
01774         index++;
01775       }  // end loop over reco photons
01776       if ( iMatch>-1 ) matched=true;
01777 
01778 
01779       if ( matched ) {
01780         nSimPho_[1]++;
01781 
01782         h_SimPhoMotherEt_[1]->Fill(  (*mcPho).motherMomentum().et()  );
01783         h_SimPhoMotherEta_[1]->Fill(  (*mcPho).motherMomentum().pseudoRapidity());
01784 
01785         h_MatchedSimPho_[0]->Fill( mcEta_ ) ;
01786         h_MatchedSimPho_[1]->Fill( mcPhi_ );
01787         h_MatchedSimPho_[2]->Fill(  (*mcPho).fourMomentum().et());
01788 
01789       }
01790 
01791 
01792 
01793 
01794       if ( ! matched) continue;
01795 
01796       bool  phoIsInBarrel=false;
01797       bool  phoIsInEndcap=false;
01798       bool  phoIsInEndcapP=false;
01799       bool  phoIsInEndcapM=false;
01800 
01801       reco::Photon matchingPho = thePhotons[iMatch];
01802 
01803       if ( fabs(matchingPho.superCluster()->position().eta() ) < 1.479 ) {
01804         phoIsInBarrel=true;
01805       } else {
01806         phoIsInEndcap=true;
01807         if ( matchingPho.superCluster()->position().eta() > 0) phoIsInEndcapP=true;
01808         if ( matchingPho.superCluster()->position().eta() < 0) phoIsInEndcapM=true;
01809 
01810       }
01811       edm::Handle<EcalRecHitCollection>   ecalRecHitHandle;
01812       if ( phoIsInBarrel ) {
01813         // Get handle to rec hits ecal barrel
01814         e.getByLabel(barrelEcalHits_, ecalRecHitHandle);
01815         if (!ecalRecHitHandle.isValid()) {
01816           edm::LogError("PhotonProducer") << "Error! Can't get the product "<<barrelEcalHits_.label();
01817           return;
01818         }
01819 
01820       } else if ( phoIsInEndcap ) {
01821 
01822         // Get handle to rec hits ecal encap
01823         e.getByLabel(endcapEcalHits_, ecalRecHitHandle);
01824         if (!ecalRecHitHandle.isValid()) {
01825           edm::LogError("PhotonProducer") << "Error! Can't get the product "<<endcapEcalHits_.label();
01826           return;
01827         }
01828 
01829       }
01830 
01831 
01832 
01833       int type=0;
01834       const EcalRecHitCollection ecalRecHitCollection = *(ecalRecHitHandle.product());
01835       float photonE = matchingPho.energy();
01836       float photonEt= matchingPho.energy()/cosh( matchingPho.eta()) ;
01837       float r9 = matchingPho.r9();
01838       float r1 = matchingPho.r1x5();
01839       float r2 = matchingPho.r2x5();
01840       float sigmaIetaIeta =  matchingPho.sigmaIetaIeta();
01841       float hOverE = matchingPho.hadronicOverEm();
01842       float ecalIso = matchingPho.ecalRecHitSumEtConeDR04();
01843       float hcalIso = matchingPho.hcalTowerSumEtConeDR04();
01844       float trkIso =  matchingPho.trkSumPtSolidConeDR04();
01845       float nIsoTrk   =  matchingPho.nTrkSolidConeDR04();
01846       std::vector< std::pair<DetId, float> >::const_iterator rhIt;
01847 
01848       bool atLeastOneDeadChannel=false;
01849       for(reco::CaloCluster_iterator bcIt = matchingPho.superCluster()->clustersBegin();bcIt != matchingPho.superCluster()->clustersEnd(); ++bcIt) {
01850         for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
01851 
01852           for(EcalRecHitCollection::const_iterator it =  ecalRecHitCollection.begin(); it !=  ecalRecHitCollection.end(); ++it) {
01853             if  (rhIt->first ==  (*it).id() ) {
01854               if (  (*it).recoFlag() == 9 ) {
01855                 atLeastOneDeadChannel=true;
01856                 break;
01857               }
01858             }
01859           }
01860         }
01861       }
01862 
01863       if (   atLeastOneDeadChannel ) {
01864         h_MatchedSimPhoBadCh_[0]->Fill( mcEta_ ) ;
01865         h_MatchedSimPhoBadCh_[1]->Fill( mcPhi_ );
01866         h_MatchedSimPhoBadCh_[2]->Fill(  (*mcPho).fourMomentum().et());
01867 
01868       }
01869 
01870 
01871       h_scEta_[type]->Fill( matchingPho.superCluster()->eta() );
01872       h_scPhi_[type]->Fill( matchingPho.superCluster()->phi() );
01873       h_scEtaWidth_[type]->Fill( matchingPho.superCluster()->etaWidth() );
01874       h_scPhiWidth_[type]->Fill( matchingPho.superCluster()->phiWidth() );
01875       h_scE_[type][0]->Fill( matchingPho.superCluster()->energy() );
01876       h_scEt_[type][0]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
01877       if ( phoIsInEndcap ) h_psE_->Fill( matchingPho.superCluster()->preshowerEnergy() ) ;
01878       //
01879       h_r9_[type][0]->Fill( r9 );
01880       h2_r9VsEta_[0] -> Fill (mcEta_, r9);
01881       h2_r9VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r9);
01882       //
01883       h_r1_[type][0]->Fill( r1 );
01884       h2_r1VsEta_[0] -> Fill (mcEta_, r1);
01885       h2_r1VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r1);
01886       //
01887       h_r2_[type][0]->Fill( r2 );
01888       h2_r2VsEta_[0] -> Fill (mcEta_, r2);
01889       h2_r2VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r2);
01890       //
01891       h_sigmaIetaIeta_[type][0]->Fill( sigmaIetaIeta );
01892       h2_sigmaIetaIetaVsEta_[0] -> Fill (mcEta_, sigmaIetaIeta );
01893       h2_sigmaIetaIetaVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), sigmaIetaIeta);
01894       //
01895       h_hOverE_[type][0]->Fill( hOverE );
01896       h2_hOverEVsEta_[0] -> Fill (mcEta_, hOverE );
01897       h2_hOverEVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hOverE);
01898       p_hOverEVsEta_[0] -> Fill (mcEta_, hOverE );
01899       p_hOverEVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hOverE);
01900       //
01901       h_ecalRecHitSumEtConeDR04_[type][0]->Fill( ecalIso );
01902       h2_ecalRecHitSumEtConeDR04VsEta_[0] -> Fill (mcEta_, ecalIso );
01903       h2_ecalRecHitSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
01904       p_ecalRecHitSumEtConeDR04VsEta_[0] -> Fill (mcEta_, ecalIso );
01905       p_ecalRecHitSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
01906       //
01907       h_hcalTowerSumEtConeDR04_[type][0]->Fill( hcalIso );
01908       h2_hcalTowerSumEtConeDR04VsEta_[0] -> Fill (mcEta_, hcalIso );
01909       h2_hcalTowerSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
01910       p_hcalTowerSumEtConeDR04VsEta_[0] -> Fill (mcEta_, hcalIso );
01911       p_hcalTowerSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
01912       //
01913       h_isoTrkSolidConeDR04_[type][0]->Fill( trkIso );
01914       h2_isoTrkSolidConeDR04VsEta_[0] -> Fill (mcEta_, trkIso );
01915       h2_isoTrkSolidConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), trkIso);
01916       //
01917       h_nTrkSolidConeDR04_[type][0]->Fill( nIsoTrk );
01918       h2_nTrkSolidConeDR04VsEta_[0] -> Fill (mcEta_, nIsoTrk );
01919       h2_nTrkSolidConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), nIsoTrk);
01920       //
01921       h_phoEta_[type]->Fill( matchingPho.eta() );
01922       h_phoPhi_[type]->Fill( matchingPho.phi() );
01923       h_phoDEta_[0]->Fill (  matchingPho.eta() - (*mcPho).fourMomentum().eta() );
01924       h_phoDPhi_[0]->Fill (  matchingPho.phi() - mcPhi_ );
01925       h_phoE_[type][0]->Fill( photonE );
01926       h_phoEt_[type][0]->Fill( photonEt);
01927       //
01928       h_phoERes_[0][0]->Fill( photonE / (*mcPho).fourMomentum().e() );
01929       h2_eResVsEta_[0]->Fill (mcEta_, photonE/(*mcPho).fourMomentum().e()  ) ;
01930       p_eResVsEta_[0]->Fill (mcEta_, photonE/(*mcPho).fourMomentum().e()  ) ;
01931 
01932       if ( ! isRunCentrally_ ) h2_eResVsEt_[0][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
01933       p_eResVsEt_[0][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
01934 
01935       h2_eResVsR9_[0]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
01936       h2_sceResVsR9_[0]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
01937       p_eResVsR9_[0]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
01938       p_sceResVsR9_[0]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
01939       //
01940       if (  (*mcPho).isAConversion() == 0 ) {
01941         h2_eResVsEta_[1]->Fill (mcEta_, photonE/ (*mcPho).fourMomentum().e()  ) ;
01942 
01943 
01944 
01945         h2_r9VsEta_[1] -> Fill (mcEta_, r9);
01946         h2_r9VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r9);
01947         //
01948         h2_r1VsEta_[1] -> Fill (mcEta_, r1);
01949         h2_r1VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r1);
01950         //
01951         h2_r2VsEta_[1] -> Fill (mcEta_, r2);
01952         h2_r2VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r2);
01953         //
01954         h2_sigmaIetaIetaVsEta_[1] -> Fill (mcEta_, sigmaIetaIeta );
01955         h2_sigmaIetaIetaVsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), sigmaIetaIeta);
01956         //
01957         h2_hOverEVsEta_[1] -> Fill (mcEta_, hOverE );
01958         h2_hOverEVsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hOverE);
01959         //
01960         h2_ecalRecHitSumEtConeDR04VsEta_[1] -> Fill (mcEta_, ecalIso );
01961         p_ecalRecHitSumEtConeDR04VsEta_[1] -> Fill (mcEta_, ecalIso );
01962         //
01963         h2_hcalTowerSumEtConeDR04VsEta_[1] -> Fill (mcEta_, hcalIso );
01964         p_hcalTowerSumEtConeDR04VsEta_[1] -> Fill (mcEta_, hcalIso );
01965         //
01966         h2_isoTrkSolidConeDR04VsEta_[1] -> Fill (mcEta_, trkIso );
01967         h2_isoTrkSolidConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), trkIso);
01968         //
01969         h2_nTrkSolidConeDR04VsEta_[1] -> Fill (mcEta_, nIsoTrk );
01970         h2_nTrkSolidConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), nIsoTrk);
01971 
01972       }
01973 
01974 
01975 
01976 
01977       if ( photonE/(*mcPho).fourMomentum().e()  < 0.3 &&   photonE/(*mcPho).fourMomentum().e() > 0.1 ) {
01978         //      std::cout << " Eta sim " << mcEta_ << " sc eta " << matchingPho.superCluster()->eta() << " pho eta " << matchingPho.eta() << std::endl;
01979 
01980       }
01981 
01982 
01983       if ( (r9>0.94 && phoIsInBarrel) ||   (r9>0.95 && phoIsInEndcap)  )  {
01984         h_phoERes_[1][0]->Fill( photonE / (*mcPho).fourMomentum().e() );
01985         if ( ! isRunCentrally_ ) h2_eResVsEt_[0][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
01986         p_eResVsEt_[0][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
01987         p_eResVsEta_[1]->Fill (mcEta_,photonE/ (*mcPho).fourMomentum().e()  ) ;
01988 
01989       } else if ( ( r9 <= 0.94&& phoIsInBarrel) ||  ( r9 <= 0.95&& phoIsInEndcap)  ) {
01990         h_phoERes_[2][0]->Fill(photonE / (*mcPho).fourMomentum().e() );
01991         if ( ! isRunCentrally_ ) h2_eResVsEt_[0][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
01992         p_eResVsEt_[0][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
01993         p_eResVsEta_[2]->Fill (mcEta_,photonE/ (*mcPho).fourMomentum().e()  ) ;
01994         h_EtR9Less093_[0][0] ->Fill ( photonEt );
01995       }
01996 
01997 
01998 
01999       if ( phoIsInBarrel ) {
02000         h_scE_[type][1]->Fill( matchingPho.superCluster()->energy() );
02001         h_scEt_[type][1]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
02002         h_r9_[type][1]->Fill( r9 );
02003         h_r1_[type][1]->Fill( r1 );
02004         h_r2_[type][1]->Fill( r2 );
02005         h_sigmaIetaIeta_[type][1]->Fill( sigmaIetaIeta );
02006         h_hOverE_[type][1]->Fill( hOverE );
02007         h_ecalRecHitSumEtConeDR04_[type][1]->Fill( ecalIso );
02008         h2_ecalRecHitSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
02009         p_ecalRecHitSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
02010         h_hcalTowerSumEtConeDR04_[type][1]->Fill( hcalIso );
02011         h2_hcalTowerSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
02012         p_hcalTowerSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
02013         h_isoTrkSolidConeDR04_[type][1]->Fill( trkIso );
02014         h_nTrkSolidConeDR04_[type][1]->Fill( nIsoTrk );
02015 
02016 
02017         h_phoE_[type][1]->Fill( photonE );
02018         h_phoEt_[type][1]->Fill( photonEt );
02019         h_nConv_[type][1]->Fill(float( matchingPho.conversions().size()));
02020 
02021 
02022         h_phoERes_[0][1]->Fill( photonE / (*mcPho).fourMomentum().e() );
02023         h2_eResVsR9_[1]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
02024         h2_sceResVsR9_[1]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
02025         p_eResVsR9_[1]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
02026         p_sceResVsR9_[1]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
02027 
02028         if ( ! isRunCentrally_ ) h2_eResVsEt_[1][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02029         p_eResVsEt_[1][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02030 
02031 
02032         if ( r9 > 0.94 ) {
02033           h_phoERes_[1][1]->Fill(  photonE  / (*mcPho).fourMomentum().e() );
02034           if ( ! isRunCentrally_ ) h2_eResVsEt_[1][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02035           p_eResVsEt_[1][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02036         }
02037         if ( r9 <= 0.94 )  {
02038           h_phoERes_[2][1]->Fill( photonE / (*mcPho).fourMomentum().e() );
02039           if ( ! isRunCentrally_ ) h2_eResVsEt_[1][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02040           p_eResVsEt_[1][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02041           h_EtR9Less093_[0][1] ->Fill ( photonEt );
02042         }
02043       }
02044       if ( phoIsInEndcap ) {
02045         h_scE_[type][2]->Fill( matchingPho.superCluster()->energy() );
02046         h_scEt_[type][2]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
02047         h_r9_[type][2]->Fill( r9 );
02048         h_r1_[type][2]->Fill( r1 );
02049         h_r2_[type][2]->Fill( r2 );
02050         h_sigmaIetaIeta_[type][2]->Fill( sigmaIetaIeta );
02051         h_hOverE_[type][2]->Fill( hOverE );
02052         h_ecalRecHitSumEtConeDR04_[type][2]->Fill( ecalIso );
02053         h2_ecalRecHitSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
02054         p_ecalRecHitSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
02055         h_hcalTowerSumEtConeDR04_[type][2]->Fill( hcalIso );
02056         h2_hcalTowerSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
02057         p_hcalTowerSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
02058         h_isoTrkSolidConeDR04_[type][2]->Fill( trkIso );
02059         h_nTrkSolidConeDR04_[type][2]->Fill( nIsoTrk );
02060         h_phoE_[type][2]->Fill( photonE );
02061         h_phoEt_[type][2]->Fill( photonEt );
02062         h_nConv_[type][2]->Fill(float( matchingPho.conversions().size()));
02063         h_phoERes_[0][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
02064         h2_eResVsR9_[2]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
02065         h2_sceResVsR9_[2]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
02066         p_eResVsR9_[2]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
02067         p_sceResVsR9_[2]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
02068 
02069         if ( ! isRunCentrally_ ) h2_eResVsEt_[2][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02070         p_eResVsEt_[2][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02071 
02072         if ( r9 > 0.95 ) {
02073 
02074           h_phoERes_[1][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
02075           if ( ! isRunCentrally_ ) h2_eResVsEt_[2][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02076           p_eResVsEt_[2][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02077         }
02078         if ( r9 <= 0.95 ) {
02079           h_phoERes_[2][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
02080           if ( ! isRunCentrally_ ) h2_eResVsEt_[2][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02081           p_eResVsEt_[2][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02082           h_EtR9Less093_[0][2] ->Fill ( photonEt );
02083         }
02084       }
02085 
02086 
02087 
02088 
02089       if ( ! (visibleConversion &&  visibleConversionsWithTwoSimTracks ) ) continue;
02090       h_r9_[1][0]->Fill( r9 );
02091       if ( phoIsInBarrel ) h_r9_[1][1]->Fill( r9 );
02092       if ( phoIsInEndcap ) h_r9_[1][2]->Fill( r9 );
02093 
02094       if ( ! isRunCentrally_ ) {
02095         h_simConvVtxRvsZ_[0] ->Fill ( fabs (mcConvZ_), mcConvR_  ) ;
02096         if ( fabs(mcEta_) <=1.) {
02097           h_simConvVtxRvsZ_[1] ->Fill ( fabs (mcConvZ_), mcConvR_  ) ;
02098           h_simConvVtxYvsX_ ->Fill ( mcConvX_, mcConvY_  ) ;
02099         }
02100         else
02101           h_simConvVtxRvsZ_[2] ->Fill ( fabs (mcConvZ_), mcConvR_  ) ;
02102       }
02103 
02104 
02105       if ( ! fastSim_) {
02106         h_nConv_[type][0]->Fill(float( matchingPho.conversions().size()));
02108         reco::ConversionRefVector conversions = matchingPho.conversions();
02109 
02110         for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
02111           reco::ConversionRef aConv=conversions[iConv];
02112           double like = aConv->MVAout();
02113           if ( like < likelihoodCut_ ) continue;
02114 
02115           if ( ! isRunCentrally_ ) h2_EoverEtrueVsEta_[1]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02116           p_EoverEtrueVsEta_[1]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02117 
02118 
02119           //std::vector<reco::TrackRef> tracks = aConv->tracks();
02120           const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
02121           if (tracks.size() < 1 ) continue;
02122 
02123 
02124           h_mvaOut_[0]-> Fill(like);
02125 
02126           if ( tracks.size()==2 ) {
02127             if ( sqrt( aConv->tracksPin()[0].Perp2()) < convTrackMinPtCut_ || sqrt( aConv->tracksPin()[1].Perp2()) < convTrackMinPtCut_) continue;
02128           } else {
02129             if ( sqrt( aConv->tracksPin()[0].Perp2()) < convTrackMinPtCut_ ) continue;
02130           }
02131 
02132 
02133           if ( dCotCutOn_ ) {
02134             if (  (fabs(mcEta_) > 1.1 && fabs (mcEta_)  < 1.4  )  &&
02135                   fabs( aConv->pairCotThetaSeparation() ) > dCotHardCutValue_ ) continue;
02136             if ( fabs( aConv->pairCotThetaSeparation() ) > dCotCutValue_ ) continue;
02137           }
02138 
02139           //std::cout << " PhotonValidator converison algo name " << aConv->algoName() << " " << aConv->algo() << std::endl;
02140 
02141           nRecConv_++;
02142 
02143           std::map<const reco::Track*,TrackingParticleRef> myAss;
02144           std::map<const reco::Track*,TrackingParticleRef>::const_iterator itAss;
02145           std::map<reco::TrackRef,TrackingParticleRef>::const_iterator itAssMin;
02146           std::map<reco::TrackRef,TrackingParticleRef>::const_iterator itAssMax;
02147           //
02148 
02149           int nAssT2=0;
02150           for (unsigned int i=0; i<tracks.size(); i++) {
02151             //      reco::TrackRef track = tracks[i].castTo<reco::TrackRef>();
02152 
02153             type =0;
02154             if ( ! isRunCentrally_ ) nHitsVsEta_[type] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits())-0.0001 );
02155             if ( ! isRunCentrally_ ) nHitsVsR_[type] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits())-0.0001 );
02156             p_nHitsVsEta_[type] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits()) );
02157             p_nHitsVsR_[type] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits()) );
02158             h_tkChi2_[type] ->Fill (tracks[i]->normalizedChi2() );
02159 
02160 
02161             RefToBase<reco::Track> tfrb = tracks[i];
02162             RefToBaseVector<reco::Track> tc;
02163             tc.push_back(tfrb);
02164             // reco::RecoToSimCollection q = theTrackAssociator_->associateRecoToSim(tc,theConvTP_,&e);
02165             reco::SimToRecoCollection q = theTrackAssociator_->associateSimToReco(tc,theConvTP_,&e);
02166             std::vector<std::pair<RefToBase<reco::Track>, double> >  trackV;
02167             int tpI = 0;
02168 
02169             if (q.find(theConvTP_[0])!=q.end()){
02170               trackV = (std::vector<std::pair<RefToBase<reco::Track>, double> >) q[theConvTP_[0]];
02171             } else if (q.find(theConvTP_[1])!=q.end()){
02172               trackV = (std::vector<std::pair<RefToBase<reco::Track>, double> >) q[theConvTP_[1]];
02173               tpI = 1;
02174             }
02175 
02176             if ( !trackV.size() ) continue;
02177             edm::RefToBase<reco::Track> tr = trackV.front().first;
02178             myAss.insert( std::make_pair (tr.get(),theConvTP_[tpI] ) );
02179             nAssT2++;
02180 
02181           }
02182 
02183 
02184 
02185 
02186 
02187             /*
02189             TrackingParticleRef myTP;
02190             for (size_t j = 0; j < RtoSCollPtrs.size(); j++) {
02191               reco::RecoToSimCollection q = *(RtoSCollPtrs[j]);
02192 
02193               RefToBase<reco::Track> myTk( track );
02194 
02195               if( q.find(myTk ) != q.end() ) {
02196                 std::vector<std::pair<TrackingParticleRef, double> > tp = q[myTk];
02197                 for (unsigned int itp=0; itp<tp.size(); itp++) {
02198                   myTP=tp[itp].first;
02199                   //      std::cout << " associated with TP " << myTP->pdgId() << " pt " << sqrt(myTP->momentum().perp2()) << std::endl;
02200                   myAss.insert( std::make_pair ( track  , myTP) );
02201                   nAssT2++;
02202                 }
02203               }
02204             }
02205           }
02206           */
02207 
02208 
02209           type=0;
02210 
02211           //      float totP = sqrt(aConv->pairMomentum().Mag2());
02212           float refP =-99999.;
02213           float refPt =-99999.;
02214           if ( aConv->conversionVertex().isValid() ) {
02215                refP=sqrt(aConv->refittedPairMomentum().Mag2());
02216                refPt=sqrt(aConv->refittedPairMomentum().perp2());
02217           }
02218           float invM = aConv->pairInvariantMass();
02219 
02220           h_invMass_[type][0] ->Fill( invM);
02221           if ( phoIsInBarrel ) h_invMass_[type][1] ->Fill(invM);
02222           if ( phoIsInEndcap ) h_invMass_[type][2] ->Fill(invM);
02223 
02224 
02226           if ( tracks.size() ==1  ) {
02227             h_SimConvOneTracks_[0]->Fill( mcEta_ ) ;
02228             h_SimConvOneTracks_[1]->Fill( mcPhi_ );
02229             h_SimConvOneTracks_[2]->Fill( mcConvR_ );
02230             h_SimConvOneTracks_[3]->Fill( mcConvZ_ );
02231             h_SimConvOneTracks_[4]->Fill(  (*mcPho).fourMomentum().et());
02232 
02233 
02234           } else if ( tracks.size() ==2 ) {
02235 
02236             h_SimConvTwoTracks_[0]->Fill( mcEta_ ) ;
02237             h_SimConvTwoTracks_[1]->Fill( mcPhi_ );
02238             h_SimConvTwoTracks_[2]->Fill( mcConvR_ );
02239             h_SimConvTwoTracks_[3]->Fill( mcConvZ_ );
02240             h_SimConvTwoTracks_[4]->Fill(  (*mcPho).fourMomentum().et());
02241 
02242             h_convEta_[1]->Fill( aConv->caloCluster()[0]->eta() );
02243 
02244             float trkProvenance=3;
02245             if ( tracks[0]->algoName() == "outInEcalSeededConv"  &&  tracks[1]->algoName() == "outInEcalSeededConv" ) trkProvenance=0;
02246             if ( tracks[0]->algoName() == "inOutEcalSeededConv"  &&  tracks[1]->algoName() == "inOutEcalSeededConv" ) trkProvenance=1;
02247             if ( ( tracks[0]->algoName() == "outInEcalSeededConv"  &&  tracks[1]->algoName() == "inOutEcalSeededConv") ||
02248                  ( tracks[1]->algoName() == "outInEcalSeededConv"  &&  tracks[0]->algoName() == "inOutEcalSeededConv") ) trkProvenance=2;
02249             if ( trkProvenance==3 ) {
02250               // std::cout << " PhotonValidator provenance of tracks is " << tracks[0]->algoName() << " and " << tracks[1]->algoName() << std::endl;
02251             }
02252             h_trkProv_[0]->Fill( trkProvenance );
02253 
02254 
02255 
02257             if ( nAssT2 ==2 ) {
02258 
02259 
02260 
02261 
02262               h_r9_[2][0]->Fill( r9 );
02263               if ( phoIsInBarrel ) h_r9_[2][1]->Fill( r9 );
02264               if ( phoIsInEndcap ) h_r9_[2][2]->Fill( r9 );
02265 
02266               h_convEta_[2]->Fill( aConv->caloCluster()[0]->eta() );
02267 
02268               nRecConvAss_++;
02269 
02270 
02271               h_SimConvTwoMTracks_[0]->Fill( mcEta_ ) ;
02272               h_SimConvTwoMTracks_[1]->Fill( mcPhi_ );
02273               h_SimConvTwoMTracks_[2]->Fill( mcConvR_ );
02274               h_SimConvTwoMTracks_[3]->Fill( mcConvZ_ );
02275               h_SimConvTwoMTracks_[4]->Fill(  (*mcPho).fourMomentum().et());
02276 
02277               if ( aConv->conversionVertex().isValid() ) {
02278                 if ( trkProvenance==3 ) std::cout << " PhotonValidator provenance of tracks is mixed and vertex is valid " << std::endl;
02279                 float chi2Prob = ChiSquaredProbability( aConv->conversionVertex().chi2(),  aConv->conversionVertex().ndof() );
02280                 if (   chi2Prob > 0) {
02281                   h_SimConvTwoMTracksAndVtxPGT0_[0]->Fill( mcEta_ ) ;
02282                   h_SimConvTwoMTracksAndVtxPGT0_[1]->Fill( mcPhi_ );
02283                   h_SimConvTwoMTracksAndVtxPGT0_[2]->Fill( mcConvR_ );
02284                   h_SimConvTwoMTracksAndVtxPGT0_[3]->Fill( mcConvZ_ );
02285                   h_SimConvTwoMTracksAndVtxPGT0_[4]->Fill(  (*mcPho).fourMomentum().et());
02286                 }
02287                 if (   chi2Prob > 0.0005) {
02288                   h_SimConvTwoMTracksAndVtxPGT0005_[0]->Fill( mcEta_ ) ;
02289                   h_SimConvTwoMTracksAndVtxPGT0005_[1]->Fill( mcPhi_ );
02290                   h_SimConvTwoMTracksAndVtxPGT0005_[2]->Fill( mcConvR_ );
02291                   h_SimConvTwoMTracksAndVtxPGT0005_[3]->Fill( mcConvZ_ );
02292                   h_SimConvTwoMTracksAndVtxPGT0005_[4]->Fill(  (*mcPho).fourMomentum().et());
02293 
02294 
02295                 }
02296 
02297                 if (  chi2Prob > 0.0005 ) {
02298                   h_convEta_[0]->Fill( aConv->caloCluster()[0]->eta() );
02299                   h_convPhi_[0]->Fill( aConv->caloCluster()[0]->phi() );
02300                   h_convERes_[0][0]->Fill( aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
02301                   if ( ! isRunCentrally_ ) h_r9VsNofTracks_[0][0]->Fill( r9, aConv->nTracks() ) ;
02302 
02303 
02304                   h_EtR9Less093_[1][0] ->Fill ( photonEt );
02305                   if ( phoIsInBarrel ) h_EtR9Less093_[1][1] ->Fill ( photonEt );
02306                   if ( phoIsInEndcap ) h_EtR9Less093_[1][2] ->Fill ( photonEt );
02307 
02308 
02309 
02310                   if ( phoIsInBarrel )  {
02311                     h_convERes_[0][1]->Fill(aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
02312                     if ( ! isRunCentrally_ ) h_r9VsNofTracks_[0][1]->Fill( r9, aConv->nTracks() ) ;
02313                     h_mvaOut_[1]-> Fill(like);
02314                   }
02315                   if ( phoIsInEndcap ) {
02316                     h_convERes_[0][2]->Fill(aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
02317                     if ( ! isRunCentrally_ ) h_r9VsNofTracks_[0][2]->Fill( r9, aConv->nTracks() ) ;
02318                     h_mvaOut_[2]-> Fill(like);
02319                   }
02320 
02321                 }
02322 
02323 
02324 
02325 
02326               }
02327 
02329               type =1;
02330 
02331               h_trkProv_[1]->Fill( trkProvenance );
02332               h_invMass_[type][0] ->Fill( invM);
02333 
02334 
02335 
02336               float eoverp= -99999.;
02337 
02338               if ( aConv->conversionVertex().isValid() ) {
02339                 eoverp= aConv->EoverPrefittedTracks();
02340                 h_convPtRes_[type][0]->Fill( refPt / (*mcPho).fourMomentum().et() );
02341                 h_EoverPTracks_[type][0] ->Fill( eoverp ) ;
02342                 h_PoverETracks_[type][0] ->Fill( 1./eoverp ) ;
02343                 if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[0] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02344                 if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[0] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e()  ) ;
02345                 if ( ! isRunCentrally_ ) h2_EoverPVsEta_[0]->Fill (mcEta_, eoverp);
02346                 if ( ! isRunCentrally_ ) h2_EoverPVsR_[0]->Fill (mcConvR_, eoverp);
02347                 p_EoverPVsEta_[0]->Fill (mcEta_, eoverp);
02348                 p_EoverPVsR_[0]->Fill (mcConvR_, eoverp);
02349                 p_eResVsR_ ->Fill ( mcConvR_, photonE / (*mcPho).fourMomentum().e() );
02350                  if ( ! isRunCentrally_ ) h2_PoverPtrueVsEta_[0]->Fill (mcEta_,refP/ (*mcPho).fourMomentum().e()  ) ;
02351                 p_PoverPtrueVsEta_[0]->Fill (mcEta_,refP/ (*mcPho).fourMomentum().e()  ) ;
02352 
02353 
02354               }
02355 
02356 
02357               if ( ! isRunCentrally_ )  h2_EoverEtrueVsEta_[0]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02358               if ( ! isRunCentrally_ )  h2_EoverEtrueVsR_[0]->Fill (mcConvR_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02359               p_EoverEtrueVsEta_[0]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02360               p_EoverEtrueVsR_[0]->Fill (mcConvR_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02361 
02362 
02363               if ( ! isRunCentrally_ ) h2_etaVsRsim_[0]->Fill (mcEta_,mcConvR_);
02364 
02365               /*
02366               reco::TrackRef track1 = tracks[0].castTo<reco::TrackRef>();
02367               reco::TrackRef track2 = tracks[1].castTo<reco::TrackRef>();
02368               reco::TransientTrack tt1 = (*theTTB).build( &track1);
02369               reco::TransientTrack tt2 = (*theTTB).build( &track2);
02370               TwoTrackMinimumDistance md;
02371               md.calculate  (  tt1.initialFreeState(),  tt2.initialFreeState() );
02372               if (md.status() )  {
02373                 //cout << " Min Dist " << md.distance() << std::endl;
02374                 h_distMinAppTracks_[1][0]->Fill ( md.distance() );
02375               }  else {
02376                 nInvalidPCA_++;
02377 
02378               }
02379               */
02380 
02381               //  here original tracks and their inner momentum is considered
02382               float  dPhiTracksAtVtx =  aConv->dPhiTracksAtVtx();
02383               h_DPhiTracksAtVtx_[type][0]->Fill( dPhiTracksAtVtx);
02384               if ( ! isRunCentrally_ ) h2_DPhiTracksAtVtxVsEta_->Fill( mcEta_, dPhiTracksAtVtx);
02385               if ( ! isRunCentrally_ ) h2_DPhiTracksAtVtxVsR_->Fill( mcConvR_, dPhiTracksAtVtx);
02386               p_DPhiTracksAtVtxVsEta_->Fill( mcEta_, dPhiTracksAtVtx);
02387               p_DPhiTracksAtVtxVsR_->Fill( mcConvR_, dPhiTracksAtVtx);
02388 
02389               h_DCotTracks_[type][0] ->Fill ( aConv->pairCotThetaSeparation() );
02390               if ( ! isRunCentrally_ ) h2_DCotTracksVsEta_->Fill( mcEta_, aConv->pairCotThetaSeparation() );
02391               if ( ! isRunCentrally_ ) h2_DCotTracksVsR_->Fill( mcConvR_, aConv->pairCotThetaSeparation() );
02392               p_DCotTracksVsEta_->Fill( mcEta_, aConv->pairCotThetaSeparation() );
02393               p_DCotTracksVsR_->Fill( mcConvR_, aConv->pairCotThetaSeparation() );
02394 
02395 
02396               if ( phoIsInBarrel ) {
02397                 h_invMass_[type][1] ->Fill(invM);
02398                 if ( aConv->conversionVertex().isValid() ) {
02399                   h_convPtRes_[type][1]->Fill( refPt / (*mcPho).fourMomentum().et() );
02400                   h_EoverPTracks_[type][1] ->Fill( eoverp ) ;
02401                   if (  mcConvR_ < 15 )                 h_EoverPTracks_[0][0] ->Fill( eoverp ) ;
02402                   if (  mcConvR_ > 15 && mcConvR_< 58 ) h_EoverPTracks_[0][1] ->Fill( eoverp ) ;
02403                   if (  mcConvR_ > 58 )                 h_EoverPTracks_[0][2] ->Fill( eoverp ) ;
02404                   h_PoverETracks_[type][1] ->Fill( 1./eoverp ) ;
02405                   if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[1] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02406                   if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[1] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e()  ) ;
02407                 }
02408                 h_DPhiTracksAtVtx_[type][1]->Fill( dPhiTracksAtVtx);
02409                 h_DCotTracks_[type][1] ->Fill ( aConv->pairCotThetaSeparation() );
02410 
02411 
02412               }
02413 
02414 
02415               if ( phoIsInEndcap ) {
02416                 h_invMass_[type][2] ->Fill(invM);
02417                 if ( aConv->conversionVertex().isValid() ) {
02418                   h_convPtRes_[type][2]->Fill( refPt / (*mcPho).fourMomentum().et() );
02419                   h_EoverPTracks_[type][2] ->Fill( eoverp ) ;
02420                   h_PoverETracks_[type][2] ->Fill( 1./eoverp ) ;
02421                   if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[2] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02422                   if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[2] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e()  ) ;
02423                 }
02424                 h_DPhiTracksAtVtx_[type][2]->Fill( dPhiTracksAtVtx);
02425                 h_DCotTracks_[type][2] ->Fill ( aConv->pairCotThetaSeparation() );
02426 
02427               }
02428 
02429 
02430               if ( aConv->conversionVertex().isValid() ) {
02431 
02432                 h_convVtxdX_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
02433                 h_convVtxdY_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
02434                 h_convVtxdZ_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
02435                 h_convVtxdR_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
02436 
02437                 if ( fabs( mcConvEta_ ) <= 1.2 ) {
02438                   h_convVtxdX_barrel_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
02439                   h_convVtxdY_barrel_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
02440                   h_convVtxdZ_barrel_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
02441                   h_convVtxdR_barrel_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
02442                 } else {
02443                   h_convVtxdX_endcap_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
02444                   h_convVtxdY_endcap_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
02445                   h_convVtxdZ_endcap_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
02446                   h_convVtxdR_endcap_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
02447                 }
02448 
02449 
02450                 h_convVtxdPhi_ ->Fill ( aConv->conversionVertex().position().phi() - mcConvPhi_);
02451                 h_convVtxdEta_ ->Fill ( aConv->conversionVertex().position().eta() - mcConvEta_);
02452                 if ( ! isRunCentrally_ ) h2_convVtxdRVsR_ ->Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
02453                 if ( ! isRunCentrally_ ) h2_convVtxdRVsEta_ ->Fill (mcEta_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
02454                 p_convVtxdRVsR_ ->Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
02455                 p_convVtxdRVsEta_ ->Fill (mcEta_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
02456                 float signX= aConv->refittedPairMomentum().x()/fabs(aConv->refittedPairMomentum().x());
02457                 float signY= aConv->refittedPairMomentum().y()/fabs(aConv->refittedPairMomentum().y());
02458                 float signZ= aConv->refittedPairMomentum().z()/fabs(aConv->refittedPairMomentum().z());
02459                 p_convVtxdXVsX_ ->Fill (mcConvX_, (aConv->conversionVertex().position().x() - mcConvX_)*signX );
02460                 p_convVtxdYVsY_ ->Fill (mcConvY_, (aConv->conversionVertex().position().y() - mcConvY_)*signY );
02461                 p_convVtxdZVsZ_ ->Fill (mcConvZ_, (aConv->conversionVertex().position().z() - mcConvZ_)*signZ );
02462 
02463 
02464                 if ( ! isRunCentrally_ ) h2_convVtxRrecVsTrue_ -> Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) );
02465 
02466 
02467 
02468                 //float zPV = aConv->zOfPrimaryVertexFromTracks();
02469                 float thetaConv=aConv->refittedPairMomentum().Theta();
02470                 float thetaSC=matchingPho.superCluster()->position().theta();
02471                 float rSC=sqrt(matchingPho.superCluster()->position().x()*matchingPho.superCluster()->position().x() +
02472                                matchingPho.superCluster()->position().y()*matchingPho.superCluster()->position().y() );
02473                 float zSC=matchingPho.superCluster()->position().z();
02474                 float zPV = sqrt(rSC*rSC+zSC*zSC)*sin( thetaConv - thetaSC)/sin(thetaConv);
02475 
02476                 h_zPVFromTracks_[0]->Fill (  zPV );
02477                 h_dzPVFromTracks_[0]->Fill ( zPV- (*mcPho).primaryVertex().z() );
02478 
02479 
02480                 if ( phoIsInBarrel ) {
02481                   h_zPVFromTracks_[1]->Fill ( zPV );
02482                   h_dzPVFromTracks_[1]->Fill ( zPV - (*mcPho).primaryVertex().z() );
02483                 } else if ( phoIsInEndcap) {
02484                   h_zPVFromTracks_[2]->Fill ( zPV );
02485                   h_dzPVFromTracks_[2]->Fill ( zPV - (*mcPho).primaryVertex().z() );
02486                 } else if ( phoIsInEndcapP) {
02487                   h_zPVFromTracks_[3]->Fill ( zPV );
02488                   h_dzPVFromTracks_[3]->Fill ( zPV - (*mcPho).primaryVertex().z() );
02489                 }  else if ( phoIsInEndcapM) {
02490                   h_zPVFromTracks_[4]->Fill ( zPV );
02491                   h_dzPVFromTracks_[4]->Fill ( zPV - (*mcPho).primaryVertex().z() );
02492                 }
02493 
02494                 p_dzPVVsR_ ->Fill(mcConvR_, zPV - (*mcPho).primaryVertex().z() );
02495                 p_dzPVVsEta_ ->Fill(mcConvEta_, zPV - (*mcPho).primaryVertex().z() );
02496                 if ( ! isRunCentrally_ ) h2_dzPVVsR_ ->Fill(mcConvR_, zPV - (*mcPho).primaryVertex().z() );
02497 
02498               }
02499 
02500               float  dPhiTracksAtEcal=-99;
02501               float  dEtaTracksAtEcal=-99;
02502               if (aConv->bcMatchingWithTracks()[0].isNonnull() && aConv->bcMatchingWithTracks()[1].isNonnull() ) {
02503                 nRecConvAssWithEcal_++;
02504                 float recoPhi1 = aConv->ecalImpactPosition()[0].phi();
02505                 float recoPhi2 = aConv->ecalImpactPosition()[1].phi();
02506                 float recoEta1 = aConv->ecalImpactPosition()[0].eta();
02507                 float recoEta2 = aConv->ecalImpactPosition()[1].eta();
02508                 float bcPhi1 = aConv->bcMatchingWithTracks()[0]->phi();
02509                 float bcPhi2 = aConv->bcMatchingWithTracks()[1]->phi();
02510                 // unused       float bcEta1 = aConv->bcMatchingWithTracks()[0]->eta();
02511                 // unused   float bcEta2 = aConv->bcMatchingWithTracks()[1]->eta();
02512                 recoPhi1 = phiNormalization(recoPhi1);
02513                 recoPhi2 = phiNormalization(recoPhi2);
02514                 bcPhi1 = phiNormalization(bcPhi1);
02515                 bcPhi2 = phiNormalization(bcPhi2);
02516                 dPhiTracksAtEcal = recoPhi1 -recoPhi2;
02517                 dPhiTracksAtEcal = phiNormalization( dPhiTracksAtEcal );
02518                 dEtaTracksAtEcal = recoEta1 -recoEta2;
02519 
02520 
02521                 h_DPhiTracksAtEcal_[type][0]->Fill( fabs(dPhiTracksAtEcal));
02522                 if ( ! isRunCentrally_ ) h2_DPhiTracksAtEcalVsR_ ->Fill (mcConvR_, fabs(dPhiTracksAtEcal));
02523                 if ( ! isRunCentrally_ ) h2_DPhiTracksAtEcalVsEta_ ->Fill (mcEta_, fabs(dPhiTracksAtEcal));
02524                 p_DPhiTracksAtEcalVsR_ ->Fill (mcConvR_, fabs(dPhiTracksAtEcal));
02525                 p_DPhiTracksAtEcalVsEta_ ->Fill (mcEta_, fabs(dPhiTracksAtEcal));
02526 
02527                 h_DEtaTracksAtEcal_[type][0]->Fill( dEtaTracksAtEcal);
02528 
02529                 if ( phoIsInBarrel ) {
02530                   h_DPhiTracksAtEcal_[type][1]->Fill( fabs(dPhiTracksAtEcal));
02531                   h_DEtaTracksAtEcal_[type][1]->Fill( dEtaTracksAtEcal);
02532                 }
02533                 if ( phoIsInEndcap ) {
02534                   h_DPhiTracksAtEcal_[type][2]->Fill( fabs(dPhiTracksAtEcal));
02535                   h_DEtaTracksAtEcal_[type][2]->Fill( dEtaTracksAtEcal);
02536                 }
02537 
02538               }
02539 
02540 
02541 
02542 
02544               for (unsigned int i=0; i<tracks.size(); i++) {
02545                 RefToBase<reco::Track> tfrb(tracks[i] );
02546                 itAss= myAss.find( tfrb.get() );
02547                 if ( itAss == myAss.end()  ) continue;
02548 
02549                 float trkProvenance=3;
02550                 if ( tracks[0]->algoName() == "outInEcalSeededConv"  &&  tracks[1]->algoName() == "outInEcalSeededConv" ) trkProvenance=0;
02551                 if ( tracks[0]->algoName() == "inOutEcalSeededConv"  &&  tracks[1]->algoName() == "inOutEcalSeededConv" ) trkProvenance=1;
02552                 if ( ( tracks[0]->algoName() == "outInEcalSeededConv"  &&  tracks[1]->algoName() == "inOutEcalSeededConv") ||
02553                      ( tracks[1]->algoName() == "outInEcalSeededConv"  &&  tracks[0]->algoName() == "inOutEcalSeededConv") ) trkProvenance=2;
02554 
02555 
02556                 if ( ! isRunCentrally_ ) nHitsVsEta_[type] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits()) );
02557                  if ( ! isRunCentrally_ ) nHitsVsR_[type] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits()) );
02558                 p_nHitsVsEta_[type] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits()) -0.0001);
02559                 p_nHitsVsR_[type] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits()) -0.0001);
02560                 h_tkChi2_[type] ->Fill (tracks[i]->normalizedChi2() );
02561                 h_tkChi2Large_[type] ->Fill (tracks[i]->normalizedChi2() );
02562                 if ( ! isRunCentrally_ ) h2_Chi2VsEta_[0] ->Fill(  mcEta_, tracks[i]->normalizedChi2() );
02563                  if ( ! isRunCentrally_ ) h2_Chi2VsR_[0] ->Fill(  mcConvR_, tracks[i]->normalizedChi2() );
02564                 p_Chi2VsEta_[0] ->Fill(  mcEta_, tracks[i]->normalizedChi2() );
02565                 p_Chi2VsR_[0] ->Fill(  mcConvR_, tracks[i]->normalizedChi2() );
02566 
02567 
02568                 float simPt = sqrt( ((*itAss).second)->momentum().perp2() );
02569                 //              float recPt =   sqrt( aConv->tracks()[i]->innerMomentum().Perp2() ) ;
02570                 float refPt=-9999.;
02571                 float px=0, py=0;
02572 
02573                 if ( aConv->conversionVertex().isValid() ) {
02574                   reco::Track refTrack= aConv->conversionVertex().refittedTracks()[i];
02575                   px= refTrack.momentum().x() ;
02576                   py= refTrack.momentum().y() ;
02577                   refPt=sqrt (px*px + py*py );
02578 
02579                   float ptres= refPt - simPt ;
02580                   // float pterror = aConv->tracks()[i]->ptError();
02581                   float pterror =  aConv->conversionVertex().refittedTracks()[i].ptError();
02582                   if ( ! isRunCentrally_ ) {
02583                     h2_PtRecVsPtSim_[0]->Fill ( simPt, refPt);
02584                     if ( trkProvenance ==3 ) h2_PtRecVsPtSimMixProv_->Fill ( simPt, refPt);
02585                   }
02586 
02587                   h_TkPtPull_[0] ->Fill(ptres/pterror);
02588                    if ( ! isRunCentrally_ ) h2_TkPtPull_[0] ->Fill(mcEta_, ptres/pterror);
02589 
02590                   h_TkD0_[0]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
02591 
02592 
02593                   if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[0]->Fill  ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2())  );
02594 
02595                   if ( phoIsInBarrel ) {
02596                     h_TkD0_[1]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
02597                     h_TkPtPull_[1] ->Fill(ptres/pterror);
02598                      if ( ! isRunCentrally_ ) h2_PtRecVsPtSim_[1]->Fill ( simPt, refPt);
02599                     if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[1]->Fill  ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2())  );
02600 
02601                   }
02602                   if ( phoIsInEndcap ) {
02603                     h_TkD0_[2]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
02604                     h_TkPtPull_[2] ->Fill(ptres/pterror);
02605                      if ( ! isRunCentrally_ ) h2_PtRecVsPtSim_[2]->Fill ( simPt, refPt);
02606                     if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[2]->Fill  ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2())  );
02607                   }
02608 
02609                 }
02610 
02611               } // end loop over track
02612             } // end analysis of two associated tracks
02613           } // end analysis of two  tracks
02614 
02615         } // loop over conversions
02616       }  // if !fastSim
02617     }  // End loop over generated particles
02618   } // End loop over simulated Photons
02619 
02620 
02621 
02622 
02623   h_nSimPho_[0]->Fill(float(nSimPho_[0]));
02624   h_nSimPho_[1]->Fill(float(nSimPho_[1]));
02625   h_nSimConv_[0]->Fill(float(nSimConv_[0]));
02626   h_nSimConv_[1]->Fill(float(nSimConv_[1]));
02627 
02628 
02629   if ( !fastSim_) {
02631     for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
02632       reco::Photon aPho = reco::Photon(*iPho);
02633       //    float et= aPho.superCluster()->energy()/cosh( aPho.superCluster()->eta()) ;
02634       reco::ConversionRefVector conversions = aPho.conversions();
02635       for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
02636         reco::ConversionRef aConv=conversions[iConv];
02637         double like = aConv->MVAout();
02638         if ( like < likelihoodCut_ ) continue;
02639         //std::vector<reco::TrackRef> tracks = aConv->tracks();
02640         const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
02641         if (tracks.size() < 2 ) continue;
02642 
02643         RefToBase<reco::Track> tk1 = aConv->tracks().front();
02644         RefToBase<reco::Track> tk2 = aConv->tracks().back();
02645         RefToBaseVector<reco::Track> tc1, tc2;
02646         tc1.push_back(tk1);
02647         tc2.push_back(tk2);
02648 
02649         bool  phoIsInBarrel=false;
02650         bool  phoIsInEndcap=false;
02651         if ( fabs(aConv->caloCluster()[0]->eta() ) < 1.479 ) {
02652           phoIsInBarrel=true;
02653         } else {
02654           phoIsInEndcap=true;
02655         }
02656 
02657 
02658         if ( dCotCutOn_ ) {
02659           if ( ( fabs(mcEta_) > 1.1 && fabs (mcEta_)  < 1.4  )  &&
02660                fabs( aConv->pairCotThetaSeparation() ) > dCotHardCutValue_ )  continue;
02661           if ( fabs( aConv->pairCotThetaSeparation() ) > dCotCutValue_ ) continue;
02662         }
02663 
02664 
02665         h_RecoConvTwoTracks_[0]->Fill( aPho.eta() ) ;
02666         h_RecoConvTwoTracks_[1]->Fill( aPho.phi() );
02667         if (  aConv->conversionVertex().isValid() ) h_RecoConvTwoTracks_[2]->Fill(  aConv->conversionVertex().position().perp2() );
02668         h_RecoConvTwoTracks_[3]->Fill( aConv->conversionVertex().position().z() );
02669         h_RecoConvTwoTracks_[4]->Fill( aPho.et() ) ;
02670 
02671 
02672 
02673         int  nAssT2=0;
02674         for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
02675           // mcConvPt_= (*mcPho).fourMomentum().et();
02676           float mcPhi= (*mcPho).fourMomentum().phi();
02677           //simPV_Z = (*mcPho).primaryVertex().z();
02678           mcPhi_= phiNormalization(mcPhi);
02679           mcEta_= (*mcPho).fourMomentum().pseudoRapidity();
02680           mcEta_ = etaTransformation(mcEta_, (*mcPho).primaryVertex().z() );
02681           //mcConvR_= (*mcPho).vertex().perp();
02682           //mcConvX_= (*mcPho).vertex().x();
02683           //mcConvY_= (*mcPho).vertex().y();
02684           //mcConvZ_= (*mcPho).vertex().z();
02685           //mcConvEta_= (*mcPho).vertex().eta();
02686           //mcConvPhi_= (*mcPho).vertex().phi();
02687           if ( fabs(mcEta_) > END_HI ) continue;
02688           //        if (mcConvPt_<minPhoPtForPurity) continue;
02689           //if (fabs(mcEta_)>maxPhoEtaForPurity) continue;
02690           //if (fabs(mcConvZ_)>maxPhoZForPurity) continue;
02691           //if (mcConvR_>maxPhoRForEffic) continue;
02692 
02693           if (  (*mcPho).isAConversion() != 1 ) continue;
02694           if (!( ( fabs(mcEta_) <= BARL && mcConvR_ <85 )  ||
02695                  ( fabs(mcEta_) > BARL && fabs(mcEta_) <=END_HI && fabs( (*mcPho).vertex().z() ) < 210 )  ) )
02696             continue;
02697 
02698 
02699           theConvTP_.clear();
02700           for(size_t i = 0; i <  trackingParticles.size(); ++i){
02701             TrackingParticleRef tp (ElectronTPHandle,i);
02702             if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.0001   &&
02703                  fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.0001   &&
02704                  fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.0001) {
02705               theConvTP_.push_back( tp );
02706             }
02707           }
02708 
02709           //std::cout << " ciao 5.3 " << std::endl;
02710           if ( theConvTP_.size() < 2 )   continue;
02711 
02712           reco::RecoToSimCollection p1 =  theTrackAssociator_->associateRecoToSim(tc1,theConvTP_,&e);
02713           reco::RecoToSimCollection p2 =  theTrackAssociator_->associateRecoToSim(tc2,theConvTP_,&e);
02714           std::vector<std::pair<RefToBase<reco::Track>, double> > trackV1, trackV2;
02715           try {
02716           std::vector<std::pair<TrackingParticleRef, double> > tp1 = p1[tk1];
02717           std::vector<std::pair<TrackingParticleRef, double> > tp2 = p2[tk2];
02718 
02719           if (tp1.size()&&tp2.size()) {
02720             TrackingParticleRef tpr1 = tp1.front().first;
02721             TrackingParticleRef tpr2 = tp2.front().first;
02722 
02723             if (abs(tpr1->pdgId())==11&&abs(tpr2->pdgId())==11) {
02724               if ( (tpr1->parentVertex()->sourceTracks_end()-tpr1->parentVertex()->sourceTracks_begin()==1) &&
02725                    (tpr2->parentVertex()->sourceTracks_end()-tpr2->parentVertex()->sourceTracks_begin()==1)) {
02726                 if (tpr1->parentVertex().key()==tpr2->parentVertex().key() && ((*tpr1->parentVertex()->sourceTracks_begin())->pdgId()==22)) {
02727                   //              std::cout << " ciao 5.6 " << std::endl;
02728                   //            mcConvR_ = sqrt(tpr1->parentVertex()->position().Perp2());
02729                   //mcConvZ_ = tpr1->parentVertex()->position().z();
02730                   //mcConvX_ = tpr1->parentVertex()->position().x();
02731                   //mcConvY_ = tpr1->parentVertex()->position().y();
02732                   //mcConvEta_ = tpr1->parentVertex()->position().eta();
02733                   //mcConvPhi_ = tpr1->parentVertex()->position().phi();
02734                   //mcConvPt_ = sqrt((*tpr1->parentVertex()->sourceTracks_begin())->momentum().Perp2());
02735                   //std::cout << " Reco to Sim mcconvpt " << mcConvPt_ << std::endl;
02736                   //cout << "associated track1 to " << tpr1->pdgId() << " with p=" << tpr1->p4() << " with pT=" << tpr1->pt() << endl;
02737                   //cout << "associated track2 to " << tpr2->pdgId() << " with p=" << tpr2->p4() << " with pT=" << tpr2->pt() << endl;
02738                   nAssT2 = 2;
02739                   break;
02740                 }
02741               }
02742             }
02743           }
02744 
02745           } catch (Exception event) {
02746             //cout << "do not continue: " << event.what()  << endl;
02747             //continue;
02748           }
02749 
02750         } // end loop over simulated photons
02751 
02752 
02753 
02754           /*
02755           TrackingParticleRef myTP;
02756           for (size_t j = 0; j < RtoSCollPtrs.size(); j++) {
02757             reco::RecoToSimCollection q = *(RtoSCollPtrs[j]);
02758 
02759             RefToBase<reco::Track> myTk( track );
02760 
02761             if( q.find(myTk ) != q.end() ) {
02762               std::vector<std::pair<TrackingParticleRef, double> > tp = q[myTk];
02763               for (unsigned int itp=0; itp<tp.size(); itp++) {
02764                 myTP=tp[itp].first;
02765                 //            std::cout << " associated with TP " << myTP->pdgId() << " pt " << sqrt(myTP->momentum().perp2()) << std::endl;
02766                 myAss.insert( std::make_pair ( track  , myTP) );
02767                 nAssT2++;
02768               }
02769             }
02770           }
02771           */
02772 
02773           if ( nAssT2 == 2) {
02774 
02775 
02776             h_RecoConvTwoMTracks_[0]->Fill( aPho.eta() ) ;
02777             h_RecoConvTwoMTracks_[1]->Fill( aPho.phi() );
02778             if (  aConv->conversionVertex().isValid() ) h_RecoConvTwoMTracks_[2]->Fill(  aConv->conversionVertex().position().perp2() );
02779             h_RecoConvTwoMTracks_[3]->Fill( aConv->conversionVertex().position().z() );
02780             h_RecoConvTwoMTracks_[4]->Fill( aPho.et() ) ;
02781 
02782           }
02783 
02784 
02786         if ( aConv->conversionVertex().isValid() ) {
02787           float chi2Prob = ChiSquaredProbability( aConv->conversionVertex().chi2(),  aConv->conversionVertex().ndof() );
02788 
02789           double convR= sqrt(aConv->conversionVertex().position().perp2());
02790           double scalar = aConv->conversionVertex().position().x()*aConv->pairMomentum().x() +
02791             aConv->conversionVertex().position().y()*aConv->pairMomentum().y();
02792           if ( scalar < 0 ) convR= -sqrt(aConv->conversionVertex().position().perp2());
02793 
02794           if ( ! isRunCentrally_ ) h2_etaVsRreco_[0]->Fill (aConv->caloCluster()[0]->eta(),sqrt(aConv->conversionVertex().position().perp2()) );
02795           h_convVtxRvsZ_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  sqrt(aConv->conversionVertex().position().perp2())  ) ;
02796           if ( fabs(aConv->caloCluster()[0]->eta() ) <= 1.) {
02797 
02798             h_convVtxYvsX_ ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x()  ) ;
02799             h_convVtxRvsZ_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR  ) ;
02800 
02801             if ( ! isRunCentrally_ ) {
02802               h_convVtxYvsX_zoom_[0] ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x()  ) ;
02803               h_convVtxYvsX_zoom_[1] ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x()  ) ;
02804               h_convVtxRvsZ_zoom_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR  ) ;
02805               h_convVtxRvsZ_zoom_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR ) ;
02806             }
02807 
02808           }
02809           if ( fabs(aConv->caloCluster()[0]->eta() ) > 1.)      h_convVtxRvsZ_[2] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR  ) ;
02810 
02811 
02812 
02813 
02814           h_vtxChi2Prob_[0]->Fill( chi2Prob );
02815           h_vtxChi2_[0]->Fill(  aConv->conversionVertex().normalizedChi2() );
02816           if ( phoIsInBarrel ) {
02817             h_vtxChi2Prob_[1]->Fill( chi2Prob );
02818             h_vtxChi2_[1]->Fill( aConv->conversionVertex().normalizedChi2() );
02819           }
02820           if ( phoIsInEndcap ) {
02821             h_vtxChi2Prob_[2]->Fill(  chi2Prob );
02822             h_vtxChi2_[2]->Fill( aConv->conversionVertex().normalizedChi2() );
02823           }
02824 
02825         } // end conversion vertex valid
02826       } // end loop over reco conversions
02827     } // end loop on all reco photons
02828   } // if !fastSim
02829 
02830 
02831 
02833   float nPho=0;
02834   for (reco::GenJetCollection::const_iterator genJetIter = genJetCollection.begin();
02835        genJetIter != genJetCollection.end();     ++genJetIter) {
02836 
02837     if ( genJetIter->pt() < minPhoEtCut_ ) continue;
02838     if ( fabs(genJetIter->eta())  > 2.5 ) continue;
02839 
02840     float mcJetPhi= genJetIter->phi();
02841     mcJetPhi_= phiNormalization(mcJetPhi);
02842     mcJetEta_= genJetIter->eta();
02843     float mcJetPt = genJetIter->pt() ;
02844 
02845     h_SimJet_[0]->Fill ( mcJetEta_);
02846     h_SimJet_[1]->Fill ( mcJetPhi_);
02847     h_SimJet_[2]->Fill ( mcJetPt );
02848 
02849     std::vector<reco::Photon> thePhotons;
02850     bool matched=false;
02851 
02852     reco::Photon matchingPho;
02853     for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
02854       reco::Photon aPho = reco::Photon(*iPho);
02855       float phiPho=aPho.phi();
02856       float etaPho=aPho.eta();
02857       float deltaPhi = phiPho-mcJetPhi_;
02858       float deltaEta = etaPho-mcJetEta_;
02859       if ( deltaPhi > pi )  deltaPhi -= twopi;
02860       if ( deltaPhi < -pi) deltaPhi += twopi;
02861       deltaPhi=pow(deltaPhi,2);
02862       deltaEta=pow(deltaEta,2);
02863       float delta = sqrt( deltaPhi+deltaEta);
02864       if ( delta<0.3 ) {
02865         matchingPho = * iPho;
02866         matched = true;
02867       }
02868     }  // end loop over reco photons
02869 
02870     if (!  matched ) continue;
02871     nPho++;
02872 
02873     h_MatchedSimJet_[0]->Fill( mcJetEta_ ) ;
02874     h_MatchedSimJet_[1]->Fill( mcJetPhi_ );
02875     h_MatchedSimJet_[2]->Fill( mcJetPt );
02876 
02877 
02878     bool  phoIsInBarrel=false;
02879     bool  phoIsInEndcap=false;
02880     if ( fabs(matchingPho.superCluster()->position().eta() ) < 1.479 ) {
02881       phoIsInBarrel=true;
02882     } else {
02883       phoIsInEndcap=true;
02884     }
02885     edm::Handle<EcalRecHitCollection>   ecalRecHitHandle;
02886     if ( phoIsInBarrel ) {
02887       // Get handle to rec hits ecal barrel
02888       e.getByLabel(barrelEcalHits_, ecalRecHitHandle);
02889       if (!ecalRecHitHandle.isValid()) {
02890         edm::LogError("PhotonProducer") << "Error! Can't get the product "<<barrelEcalHits_.label();
02891         return;
02892       }
02893 
02894     } else if ( phoIsInEndcap ) {
02895 
02896       // Get handle to rec hits ecal encap
02897       e.getByLabel(endcapEcalHits_, ecalRecHitHandle);
02898       if (!ecalRecHitHandle.isValid()) {
02899         edm::LogError("PhotonProducer") << "Error! Can't get the product "<<endcapEcalHits_.label();
02900         return;
02901       }
02902 
02903     }
02904 
02905 
02906 
02907     const EcalRecHitCollection ecalRecHitCollection = *(ecalRecHitHandle.product());
02908     float photonE = matchingPho.energy();
02909     float photonEt= matchingPho.et();
02910     float r9 = matchingPho.r9();
02911     float r1 = matchingPho.r1x5();
02912     float r2 = matchingPho.r2x5();
02913     float sigmaIetaIeta =  matchingPho.sigmaIetaIeta();
02914     float hOverE = matchingPho.hadronicOverEm();
02915     float ecalIso = matchingPho.ecalRecHitSumEtConeDR04();
02916     float hcalIso = matchingPho.hcalTowerSumEtConeDR04();
02917     float trkIso =  matchingPho.trkSumPtSolidConeDR04();
02918     float nIsoTrk   =  matchingPho.nTrkSolidConeDR04();
02919     std::vector< std::pair<DetId, float> >::const_iterator rhIt;
02920 
02921     bool atLeastOneDeadChannel=false;
02922       for(reco::CaloCluster_iterator bcIt = matchingPho.superCluster()->clustersBegin();bcIt != matchingPho.superCluster()->clustersEnd(); ++bcIt) {
02923         for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
02924 
02925           for(EcalRecHitCollection::const_iterator it =  ecalRecHitCollection.begin(); it !=  ecalRecHitCollection.end(); ++it) {
02926             if  (rhIt->first ==  (*it).id() ) {
02927               if (  (*it).recoFlag() == 9 ) {
02928                 atLeastOneDeadChannel=true;
02929                 break;
02930               }
02931             }
02932           }
02933         }
02934       }
02935 
02936       if (   atLeastOneDeadChannel ) {
02937         h_MatchedSimJetBadCh_[0]->Fill( mcJetEta_ ) ;
02938         h_MatchedSimJetBadCh_[1]->Fill( mcJetPhi_ );
02939         h_MatchedSimJetBadCh_[2]->Fill( mcJetPt );
02940 
02941       }
02942 
02943       h_scBkgEta_->Fill( matchingPho.superCluster()->eta() );
02944       h_scBkgPhi_->Fill( matchingPho.superCluster()->phi() );
02945       h_scBkgE_[0]->Fill( matchingPho.superCluster()->energy() );
02946       h_scBkgEt_[0]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
02947       //
02948       h_phoBkgEta_->Fill( matchingPho.eta() );
02949       h_phoBkgPhi_->Fill( matchingPho.phi() );
02950       h_phoBkgE_[0]->Fill( photonE );
02951       h_phoBkgEt_[0]->Fill( photonEt);
02952       h_phoBkgDEta_->Fill (  matchingPho.eta() - mcJetEta_ );
02953       h_phoBkgDPhi_->Fill (  matchingPho.phi() - mcJetPhi_ );
02954 
02955 
02956       h_r9Bkg_[0]->Fill( r9 );
02957       h_r1Bkg_[0]->Fill( r1 );
02958       h_r2Bkg_[0]->Fill( r2 );
02959       h_sigmaIetaIetaBkg_[0]->Fill( sigmaIetaIeta );
02960       h_hOverEBkg_[0]->Fill( hOverE );
02961       h_ecalRecHitSumEtConeDR04Bkg_[0]->Fill( ecalIso );
02962       h_hcalTowerSumEtConeDR04Bkg_[0]->Fill( hcalIso );
02963       h_isoTrkSolidConeDR04Bkg_[0]->Fill( trkIso );
02964       h_nTrkSolidConeDR04Bkg_[0]->Fill( nIsoTrk );
02965 
02966 
02967       h2_r9VsEtaBkg_ -> Fill (mcJetEta_, r9);
02968       h2_r9VsEtBkg_ -> Fill (mcJetPt, r9);
02969 
02970       h2_r1VsEtaBkg_ -> Fill (mcJetEta_, r1);
02971       h2_r1VsEtBkg_ -> Fill (mcJetPt, r1);
02972       p_r1VsEtaBkg_ -> Fill (mcJetEta_, r1);
02973       p_r1VsEtBkg_ -> Fill (mcJetPt, r1);
02974 
02975       h2_r2VsEtaBkg_ -> Fill (mcJetEta_, r2);
02976       h2_r2VsEtBkg_ -> Fill (mcJetPt, r2);
02977       p_r2VsEtaBkg_ -> Fill (mcJetEta_, r2);
02978       p_r2VsEtBkg_ -> Fill (mcJetPt, r2);
02979 
02980 
02981       h2_sigmaIetaIetaVsEtaBkg_ -> Fill (mcJetEta_, sigmaIetaIeta );
02982       p_sigmaIetaIetaVsEtaBkg_ -> Fill (mcJetEta_, sigmaIetaIeta );
02983       h2_sigmaIetaIetaVsEtBkg_[0] -> Fill (mcJetPt, sigmaIetaIeta);
02984       p_sigmaIetaIetaVsEtBkg_[0] -> Fill (mcJetPt, sigmaIetaIeta);
02985 
02986 
02987       h2_hOverEVsEtaBkg_ -> Fill (mcJetEta_, hOverE );
02988       h2_hOverEVsEtBkg_ -> Fill (mcJetPt, hOverE);
02989       p_hOverEVsEtaBkg_ -> Fill (mcJetEta_, hOverE );
02990       p_hOverEVsEtBkg_ -> Fill (mcJetPt, hOverE);
02991 
02992 
02993       h2_ecalRecHitSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, ecalIso );
02994       p_ecalRecHitSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, ecalIso );
02995       h2_ecalRecHitSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, ecalIso);
02996       p_ecalRecHitSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, ecalIso);
02997 
02998 
02999       h2_hcalTowerSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, hcalIso );
03000       p_hcalTowerSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, hcalIso );
03001       h2_hcalTowerSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, hcalIso);
03002       p_hcalTowerSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, hcalIso);
03003 
03004       h2_isoTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, trkIso );
03005       p_isoTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, trkIso );
03006       h2_isoTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, trkIso);
03007       p_isoTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, trkIso);
03008 
03009 
03010       h2_nTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, nIsoTrk );
03011       p_nTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, nIsoTrk );
03012       h2_nTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, nIsoTrk);
03013       p_nTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, nIsoTrk);
03014 
03015 
03016 
03017 
03018       if ( phoIsInBarrel ) {
03019 
03020         h_r9Bkg_[1]->Fill( r9 );
03021         h_r1Bkg_[1]->Fill( r1 );
03022         h_r2Bkg_[1]->Fill( r2 );
03023 
03024 
03025         h_sigmaIetaIetaBkg_[1]->Fill( sigmaIetaIeta );
03026         h_hOverEBkg_[1]->Fill( hOverE );
03027         h_ecalRecHitSumEtConeDR04Bkg_[1]->Fill( ecalIso );
03028         h_hcalTowerSumEtConeDR04Bkg_[1]->Fill( hcalIso );
03029         h_isoTrkSolidConeDR04Bkg_[1]->Fill( trkIso );
03030         h_nTrkSolidConeDR04Bkg_[1]->Fill( nIsoTrk );
03031 
03032         h2_sigmaIetaIetaVsEtBkg_[1] -> Fill (mcJetPt, sigmaIetaIeta);
03033         p_sigmaIetaIetaVsEtBkg_[1] -> Fill (mcJetPt, sigmaIetaIeta);
03034 
03035         h2_ecalRecHitSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, ecalIso);
03036         p_ecalRecHitSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, ecalIso);
03037 
03038         h2_hcalTowerSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, hcalIso);
03039         p_hcalTowerSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, hcalIso);
03040 
03041         h2_isoTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, trkIso);
03042         p_isoTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, trkIso);
03043 
03044         h2_nTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, nIsoTrk);
03045         p_nTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, nIsoTrk);
03046 
03047 
03048       } else if ( phoIsInEndcap )  {
03049 
03050         h_r9Bkg_[2]->Fill( r9 );
03051         h_r1Bkg_[2]->Fill( r1 );
03052         h_r2Bkg_[2]->Fill( r2 );
03053 
03054         h_sigmaIetaIetaBkg_[2]->Fill( sigmaIetaIeta );
03055         h_hOverEBkg_[2]->Fill( hOverE );
03056         h_ecalRecHitSumEtConeDR04Bkg_[2]->Fill( ecalIso );
03057         h_hcalTowerSumEtConeDR04Bkg_[2]->Fill( hcalIso );
03058         h_isoTrkSolidConeDR04Bkg_[2]->Fill( trkIso );
03059         h_nTrkSolidConeDR04Bkg_[2]->Fill( nIsoTrk );
03060 
03061         h2_sigmaIetaIetaVsEtBkg_[2] -> Fill (mcJetPt, sigmaIetaIeta);
03062         p_sigmaIetaIetaVsEtBkg_[2] -> Fill (mcJetPt, sigmaIetaIeta);
03063 
03064         h2_ecalRecHitSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, ecalIso);
03065         p_ecalRecHitSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, ecalIso);
03066 
03067         h2_hcalTowerSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, hcalIso);
03068         p_hcalTowerSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, hcalIso);
03069 
03070         h2_isoTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, trkIso);
03071         p_isoTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, trkIso);
03072 
03073         h2_nTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, nIsoTrk);
03074         p_nTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, nIsoTrk);
03075 
03076 
03077       }
03078 
03079       if ( !fastSim_) {
03081         reco::ConversionRefVector conversions = matchingPho.conversions();
03082         for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
03083           reco::ConversionRef aConv=conversions[iConv];
03084           //std::vector<reco::TrackRef> tracks = aConv->tracks();
03085           const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
03086           double like = aConv->MVAout();
03087           if ( like < likelihoodCut_ ) continue;
03088           if ( tracks.size() < 2 ) continue;
03089           h_convEtaBkg_->Fill( aConv->caloCluster()[0]->eta() );
03090           h_convPhiBkg_->Fill( aConv->caloCluster()[0]->phi() );
03091           h_mvaOutBkg_[0]-> Fill(like);
03092           float eoverp= aConv->EoverP();
03093           h_EoverPTracksBkg_[0] ->Fill( eoverp ) ;
03094           h_PoverETracksBkg_[0] ->Fill( 1./eoverp ) ;
03095           h_DCotTracksBkg_[0] ->Fill ( aConv->pairCotThetaSeparation() );
03096           float  dPhiTracksAtVtx =  aConv->dPhiTracksAtVtx();
03097           h_DPhiTracksAtVtxBkg_[0]->Fill( dPhiTracksAtVtx);
03098 
03099           if ( phoIsInBarrel ) {
03100             h_mvaOutBkg_[1]-> Fill(like);
03101             h_EoverPTracksBkg_[1] ->Fill( eoverp ) ;
03102             h_PoverETracksBkg_[1] ->Fill( 1./eoverp ) ;
03103             h_DCotTracksBkg_[1] ->Fill ( aConv->pairCotThetaSeparation() );
03104             h_DPhiTracksAtVtxBkg_[1]->Fill( dPhiTracksAtVtx);
03105           }     else if ( phoIsInEndcap )  {
03106             h_mvaOutBkg_[2]-> Fill(like);
03107             h_EoverPTracksBkg_[2] ->Fill( eoverp ) ;
03108             h_PoverETracksBkg_[2] ->Fill( 1./eoverp ) ;
03109             h_DCotTracksBkg_[2] ->Fill ( aConv->pairCotThetaSeparation() );
03110             h_DPhiTracksAtVtxBkg_[2]->Fill( dPhiTracksAtVtx);
03111           }
03112 
03113           if ( aConv->conversionVertex().isValid() ) {
03114 
03115             double convR= sqrt(aConv->conversionVertex().position().perp2());
03116             double scalar = aConv->conversionVertex().position().x()*aConv->pairMomentum().x() +
03117               aConv->conversionVertex().position().y()*aConv->pairMomentum().y();
03118             if ( scalar < 0 ) convR= -sqrt(aConv->conversionVertex().position().perp2());
03119 
03120             if ( ! isRunCentrally_ ) {
03121               h_convVtxRvsZBkg_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  sqrt(aConv->conversionVertex().position().perp2())  ) ;
03122               if ( fabs(aConv->caloCluster()[0]->eta() ) <= 1.) {
03123                 h_convVtxYvsXBkg_ ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x()  ) ;
03124                 h_convVtxRvsZBkg_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR  ) ;
03125               }
03126             }
03127 
03128 
03129           } // end vertex valid
03130 
03131 
03132         } // end loop over conversions
03133       } // if !fastSim
03134   } // end loop over sim jets
03135 
03136   h_nPho_->Fill(float(nPho));
03137 
03138 }
03139 
03140 
03141 
03142 
03143 
03144 void PhotonValidator::endJob() {
03145 
03146 
03147   std::string outputFileName = parameters_.getParameter<std::string>("OutputFileName");
03148   if ( ! isRunCentrally_ ) {
03149     dbe_->save(outputFileName);
03150   }
03151 
03152   edm::LogInfo("PhotonValidator") << "Analyzed " << nEvt_  << "\n";
03153   // std::cout  << "::endJob Analyzed " << nEvt_ << " events " << " with total " << nPho_ << " Photons " << "\n";
03154   //  std::cout  << "PhotonValidator::endJob Analyzed " << nEvt_ << " events " << "\n";
03155 
03156   return ;
03157 }
03158 
03159 float PhotonValidator::phiNormalization(float & phi)
03160 {
03161   //---Definitions
03162   const float PI    = 3.1415927;
03163   const float TWOPI = 2.0*PI;
03164 
03165 
03166   if(phi >  PI) {phi = phi - TWOPI;}
03167   if(phi < -PI) {phi = phi + TWOPI;}
03168 
03169   //  cout << " Float_t PHInormalization out " << PHI << endl;
03170   return phi;
03171 
03172 }
03173 
03174 
03175 float PhotonValidator::etaTransformation(  float EtaParticle , float Zvertex)  {
03176 
03177   //---Definitions
03178   const float PI    = 3.1415927;
03179 
03180   //---Definitions for ECAL
03181   const float R_ECAL           = 136.5;
03182   const float Z_Endcap         = 328.0;
03183   const float etaBarrelEndcap  = 1.479;
03184 
03185   //---ETA correction
03186 
03187   float Theta = 0.0  ;
03188   float ZEcal = R_ECAL*sinh(EtaParticle)+Zvertex;
03189 
03190   if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
03191   if(Theta<0.0) Theta = Theta+PI ;
03192   float ETA = - log(tan(0.5*Theta));
03193 
03194   if( fabs(ETA) > etaBarrelEndcap )
03195     {
03196       float Zend = Z_Endcap ;
03197       if(EtaParticle<0.0 )  Zend = -Zend ;
03198       float Zlen = Zend - Zvertex ;
03199       float RR = Zlen/sinh(EtaParticle);
03200       Theta = atan(RR/Zend);
03201       if(Theta<0.0) Theta = Theta+PI ;
03202       ETA = - log(tan(0.5*Theta));
03203     }
03204   //---Return the result
03205   return ETA;
03206   //---end
03207 }
03208 
03209