CMS 3D CMS Logo

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