CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/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.getParameter<std::string>("analyzerName");
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/"+fName_+"/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/"+fName_+"/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     if ( ! isRunCentrally_ ) h2_r9VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg r9 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00463     //
00464     histname="R9VsEtBkg";
00465     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) h2_sigmaIetaIetaVsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons sigmaIetaIeta vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
00505     histname="pSigmaIetaIetaVsEtaBkg";
00506     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) h2_sigmaIetaIetaVsEtBkg_[0] = dbe_->book2D(histname+"All"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00510     if ( ! isRunCentrally_ ) h2_sigmaIetaIetaVsEtBkg_[1] = dbe_->book2D(histname+"Barrel"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00511     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) p_sigmaIetaIetaVsEtBkg_[0] = dbe_->bookProfile(histname+"All"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00515     if ( ! isRunCentrally_ ) p_sigmaIetaIetaVsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00516     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) p_hOverEVsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg H/E vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
00525     histname="pHOverEVsEtBkg";
00526     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) p_ecalRecHitSumEtConeDR04VsEtBkg_[0] = dbe_->bookProfile(histname+"All","Bkg ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00560     if ( ! isRunCentrally_ ) p_ecalRecHitSumEtConeDR04VsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel","Bkg ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00561     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) p_hcalTowerSumEtConeDR04VsEtBkg_[0] = dbe_->bookProfile(histname+"All","Bkg hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00573     if ( ! isRunCentrally_ ) p_hcalTowerSumEtConeDR04VsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel","Bkg hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00574     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) h2_isoTrkSolidConeDR04VsEtBkg_[0] = dbe_->book2D(histname+"All"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
00588     if ( ! isRunCentrally_ ) h2_isoTrkSolidConeDR04VsEtBkg_[1] = dbe_->book2D(histname+"Barrel"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
00589     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) p_isoTrkSolidConeDR04VsEtBkg_[0] = dbe_->bookProfile(histname+"All"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
00592     if ( ! isRunCentrally_ ) p_isoTrkSolidConeDR04VsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
00593     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) h2_nTrkSolidConeDR04VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons nTrkSolidConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, 20,0., 20) ;
00602     histname="p_nTrkSolidConeDR04VsEtaBkg";
00603     if ( ! isRunCentrally_ ) p_nTrkSolidConeDR04VsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons nTrkSolidConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, 20,0., 20) ;
00604     //
00605     histname="nTrkSolidConeDR04VsEtBkg";
00606     if ( ! isRunCentrally_ ) h2_nTrkSolidConeDR04VsEtBkg_[0] = dbe_->book2D(histname+"All","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
00607     if ( ! isRunCentrally_ ) h2_nTrkSolidConeDR04VsEtBkg_[1] = dbe_->book2D(histname+"Barrel","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
00608     if ( ! isRunCentrally_ ) 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     if ( ! isRunCentrally_ ) p_nTrkSolidConeDR04VsEtBkg_[0] = dbe_->bookProfile(histname+"All","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
00612     if ( ! isRunCentrally_ ) p_nTrkSolidConeDR04VsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
00613     if ( ! isRunCentrally_ ) 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/"+fName_+"/Photons");
00651 
00652     histname="nOfflineVtx";
00653     h_nRecoVtx_ = dbe_->book1D(histname,"# of Offline Vertices",80, -0.5, 79.5);
00654 
00655     h_phoEta_[0] = dbe_->book1D("phoEta"," Photon Eta ",etaBin,etaMin, etaMax) ;
00656     h_phoPhi_[0] = dbe_->book1D("phoPhi"," Photon  Phi ",phiBin,phiMin,phiMax) ;
00657 
00658     h_phoDEta_[0] = dbe_->book1D("phoDEta"," Photon Eta(rec)-Eta(true) ",dEtaBin,dEtaMin, dEtaMax) ;
00659     h_phoDPhi_[0] = dbe_->book1D("phoDPhi"," Photon  Phi(rec)-Phi(true) ",dPhiBin,dPhiMin,dPhiMax) ;
00660 
00661     h_scEta_[0] =   dbe_->book1D("scEta"," SC Eta ",etaBin,etaMin, etaMax);
00662     h_scPhi_[0] =   dbe_->book1D("scPhi"," SC Phi ",phiBin,phiMin,phiMax);
00663 
00664     if ( ! isRunCentrally_ ) {
00665       h_scEtaWidth_[0] =   dbe_->book1D("scEtaWidth"," SC Eta Width ",100,0., 0.1);
00666       h_scPhiWidth_[0] =   dbe_->book1D("scPhiWidth"," SC Phi Width ",100,0., 1.);
00667     }
00668 
00669     histname = "scE";
00670     h_scE_[0][0] = dbe_->book1D(histname+"All"," SC Energy: All Ecal  ",eBin,eMin, eMax);
00671     h_scE_[0][1] = dbe_->book1D(histname+"Barrel"," SC Energy: Barrel ",eBin,eMin, eMax);
00672     h_scE_[0][2] = dbe_->book1D(histname+"Endcap"," SC Energy: Endcap ",eBin,eMin, eMax);
00673 
00674     histname = "psE";
00675     h_psE_ = dbe_->book1D(histname+"Endcap"," ES Energy  ",eBin,eMin, 50.);
00676 
00677 
00678     histname = "scEt";
00679     h_scEt_[0][0] = dbe_->book1D(histname+"All"," SC Et: All Ecal ",etBin,etMin, etMax) ;
00680     h_scEt_[0][1] = dbe_->book1D(histname+"Barrel"," SC Et: Barrel",etBin,etMin, etMax) ;
00681     h_scEt_[0][2] = dbe_->book1D(histname+"Endcap"," SC Et: Endcap",etBin,etMin, etMax) ;
00682 
00683     histname = "r9";
00684     h_r9_[0][0] = dbe_->book1D(histname+"All",   " r9: All Ecal",r9Bin,r9Min, r9Max) ;
00685     h_r9_[0][1] = dbe_->book1D(histname+"Barrel"," r9: Barrel ",r9Bin,r9Min, r9Max) ;
00686     h_r9_[0][2] = dbe_->book1D(histname+"Endcap"," r9: Endcap ",r9Bin,r9Min, r9Max) ;
00687     //
00688 
00689     if ( ! isRunCentrally_ ) {
00690       histname = "r9ConvFromMC";
00691       h_r9_[1][0] = dbe_->book1D(histname+"All",   " r9: All Ecal",r9Bin,r9Min, r9Max) ;
00692       h_r9_[1][1] = dbe_->book1D(histname+"Barrel"," r9: Barrel ",r9Bin,r9Min, r9Max) ;
00693       h_r9_[1][2] = dbe_->book1D(histname+"Endcap"," r9: Endcap ",r9Bin,r9Min, r9Max) ;
00694       //
00695       histname = "r9ConvFromReco";
00696       h_r9_[2][0] = dbe_->book1D(histname+"All",   " r9: All Ecal",r9Bin,r9Min, r9Max) ;
00697       h_r9_[2][1] = dbe_->book1D(histname+"Barrel"," r9: Barrel ",r9Bin,r9Min, r9Max) ;
00698       h_r9_[2][2] = dbe_->book1D(histname+"Endcap"," r9: Endcap ",r9Bin,r9Min, r9Max) ;
00700       histname = "EtR9Less093";
00701       h_EtR9Less093_[0][0] = dbe_->book1D(histname+"All",   " r9 < 0.94 or 0.95 : All Ecal",etBin,etMin, etMax);
00702       h_EtR9Less093_[0][1] = dbe_->book1D(histname+"Barrel"," r9 < 0.94 : Barrel ",etBin,etMin, etMax);
00703       h_EtR9Less093_[0][2] = dbe_->book1D(histname+"Endcap"," r9 < 0.95 : Endcap ",etBin,etMin, etMax);
00704       histname = "EtR9Less093Conv";
00705       h_EtR9Less093_[1][0] = dbe_->book1D(histname+"All",   " r9 < 0.94, 0.95 and good conv : All Ecal",etBin,etMin, etMax);
00706       h_EtR9Less093_[1][1] = dbe_->book1D(histname+"Barrel"," r9 < 0.94 and good conv : Barrel ",etBin,etMin, etMax);
00707       h_EtR9Less093_[1][2] = dbe_->book1D(histname+"Endcap"," r9 < 0.95 and good conv : Endcap ",etBin,etMin, etMax);
00708     }
00709 
00711     histname="R9VsEta";
00712     if ( ! isRunCentrally_ ) h2_r9VsEta_[0] = dbe_->book2D(histname+"All"," All photons r9 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00713     if ( ! isRunCentrally_ ) h2_r9VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons r9 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00714     //
00715     histname="R9VsEt";
00716     if ( ! isRunCentrally_ ) h2_r9VsEt_[0] = dbe_->book2D(histname+"All"," All photons r9 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00717     if ( ! isRunCentrally_ ) h2_r9VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons r9 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00718     //
00719     histname = "r1";
00720     h_r1_[0][0] = dbe_->book1D(histname+"All",   " e1x5/e5x5: All Ecal",r9Bin,r9Min, r9Max) ;
00721     h_r1_[0][1] = dbe_->book1D(histname+"Barrel"," e1x5/e5x5: Barrel ",r9Bin,r9Min, r9Max) ;
00722     h_r1_[0][2] = dbe_->book1D(histname+"Endcap"," e1x5/e5x5: Endcap ",r9Bin,r9Min, r9Max) ;
00723     //
00724     histname="R1VsEta";
00725     if ( ! isRunCentrally_ ) h2_r1VsEta_[0] = dbe_->book2D(histname+"All"," All photons e1x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00726     if ( ! isRunCentrally_ ) h2_r1VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons e1x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00727     //
00728     histname="R1VsEt";
00729     if ( ! isRunCentrally_ ) h2_r1VsEt_[0] = dbe_->book2D(histname+"All"," All photons e1x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00730     if ( ! isRunCentrally_ ) h2_r1VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons e1x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00731     //
00732     histname = "r2";
00733     h_r2_[0][0] = dbe_->book1D(histname+"All",   " e2x5/e5x5: All Ecal",r9Bin,r9Min, r9Max) ;
00734     h_r2_[0][1] = dbe_->book1D(histname+"Barrel"," e2x5/e5x5: Barrel ",r9Bin,r9Min, r9Max) ;
00735     h_r2_[0][2] = dbe_->book1D(histname+"Endcap"," e2x5/e5x5: Endcap ",r9Bin,r9Min, r9Max) ;
00736     //
00737     histname="R2VsEta";
00738     if ( ! isRunCentrally_ ) h2_r2VsEta_[0] = dbe_->book2D(histname+"All"," All photons e2x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00739     if ( ! isRunCentrally_ ) h2_r2VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons e2x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
00740     //
00741     histname="R2VsEt";
00742     if ( ! isRunCentrally_ ) h2_r2VsEt_[0] = dbe_->book2D(histname+"All"," All photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00743     if ( ! isRunCentrally_ ) h2_r2VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
00744     //
00745     histname = "sigmaIetaIeta";
00746     h_sigmaIetaIeta_[0][0] = dbe_->book1D(histname+"All",   "sigmaIetaIeta: All Ecal",100,0., 0.1) ;
00747     h_sigmaIetaIeta_[0][1] = dbe_->book1D(histname+"Barrel","sigmaIetaIeta: Barrel ", 100,0., 0.05) ;
00748     h_sigmaIetaIeta_[0][2] = dbe_->book1D(histname+"Endcap","sigmaIetaIeta: Endcap ", 100,0., 0.1) ;
00749     //
00750     histname="sigmaIetaIetaVsEta";
00751     if ( ! isRunCentrally_ ) h2_sigmaIetaIetaVsEta_[0] = dbe_->book2D(histname+"All"," All photons sigmaIetaIeta vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
00752     if ( ! isRunCentrally_ ) h2_sigmaIetaIetaVsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons sigmaIetaIeta vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,0.1);
00753     //
00754     histname="sigmaIetaIetaVsEt";
00755     if ( ! isRunCentrally_ ) h2_sigmaIetaIetaVsEt_[0] = dbe_->book2D(histname+"All"," All photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00756     if ( ! isRunCentrally_ ) h2_sigmaIetaIetaVsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00757     //
00758     histname = "hOverE";
00759     h_hOverE_[0][0] = dbe_->book1D(histname+"All",   "H/E: All Ecal",100,0., 0.1) ;
00760     h_hOverE_[0][1] = dbe_->book1D(histname+"Barrel","H/E: Barrel ", 100,0., 0.1) ;
00761     h_hOverE_[0][2] = dbe_->book1D(histname+"Endcap","H/E: Endcap ", 100,0., 0.1) ;
00762     //
00763     histname = "newhOverE";
00764     h_newhOverE_[0][0] = dbe_->book1D(histname+"All",   "new H/E: All Ecal",100,0., 0.1) ;
00765     h_newhOverE_[0][1] = dbe_->book1D(histname+"Barrel","new H/E: Barrel ", 100,0., 0.1) ;
00766     h_newhOverE_[0][2] = dbe_->book1D(histname+"Endcap","new H/E: Endcap ", 100,0., 0.1) ;
00767 
00768     //
00769     if ( ! isRunCentrally_ ) { 
00770       histname="hOverEVsEta";
00771       h2_hOverEVsEta_[0] = dbe_->book2D(histname+"All"," All photons H/E vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
00772       h2_hOverEVsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons H/E vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,0.1);
00773       //
00774       histname="hOverEVsEt";
00775       h2_hOverEVsEt_[0] = dbe_->book2D(histname+"All"," All photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00776       h2_hOverEVsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00777       //
00778     }
00779     histname="pHoverEVsEta";
00780     p_hOverEVsEta_[0] = dbe_->bookProfile(histname+"All"," All photons H/E vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
00781     p_hOverEVsEta_[1] = dbe_->bookProfile(histname+"Unconv"," All photons H/E vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,0.1);
00782     //
00783     histname="pHoverEVsEt";
00784     p_hOverEVsEt_[0] = dbe_->bookProfile(histname+"All"," All photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00785     p_hOverEVsEt_[1] = dbe_->bookProfile(histname+"Unconv"," All photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00786     //
00787     histname="pnewHoverEVsEta";
00788     p_newhOverEVsEta_[0] = dbe_->bookProfile(histname+"All"," All photons new H/E vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
00789     p_newhOverEVsEta_[1] = dbe_->bookProfile(histname+"Unconv"," All photons new H/E vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,0.1);
00790     //
00791     histname="pnewHoverEVsEt";
00792     p_newhOverEVsEt_[0] = dbe_->bookProfile(histname+"All"," All photons new H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00793     p_newhOverEVsEt_[1] = dbe_->bookProfile(histname+"Unconv"," All photons new H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
00794     //
00795     histname = "ecalRecHitSumEtConeDR04";
00796     h_ecalRecHitSumEtConeDR04_[0][0] = dbe_->book1D(histname+"All",   "ecalRecHitSumEtDR04: All Ecal",etBin,etMin,20.);
00797     h_ecalRecHitSumEtConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","ecalRecHitSumEtDR04: Barrel ", etBin,etMin,20.);
00798     h_ecalRecHitSumEtConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","ecalRecHitSumEtDR04: Endcap ", etBin,etMin,20.);
00799     //
00800 
00801     if ( ! isRunCentrally_ ) { 
00802       histname="ecalRecHitSumEtConeDR04VsEta";
00803       h2_ecalRecHitSumEtConeDR04VsEta_[0] = dbe_->book2D(histname+"All"," All photons ecalRecHitSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale);
00804       h2_ecalRecHitSumEtConeDR04VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons ecalRecHitSumEtDR04 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,etBin,etMin,etMax*etScale);
00805     }
00806     histname="pEcalRecHitSumEtConeDR04VsEta";
00807     p_ecalRecHitSumEtConeDR04VsEta_[0] = dbe_->bookProfile(histname+"All","All photons ecalRecHitSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale, "");
00808     p_ecalRecHitSumEtConeDR04VsEta_[1] = dbe_->bookProfile(histname+"Unconv","All photons ecalRecHitSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale, "");
00809     //
00810     if ( ! isRunCentrally_ ) { 
00811       histname="ecalRecHitSumEtConeDR04VsEt";
00812       h2_ecalRecHitSumEtConeDR04VsEt_[0] = dbe_->book2D(histname+"All"," All photons ecalRecHitSumEtDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
00813       h2_ecalRecHitSumEtConeDR04VsEt_[1] = dbe_->book2D(histname+"Barrel"," All photons ecalRecHitSumEtDR04 vs Et: Barrel ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
00814       h2_ecalRecHitSumEtConeDR04VsEt_[2] = dbe_->book2D(histname+"Endcap"," All photons ecalRecHitSumEtDR04 vs Et: Endcap ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
00815     }
00816     histname="pEcalRecHitSumEtConeDR04VsEt";
00817     if ( ! isRunCentrally_ ) p_ecalRecHitSumEtConeDR04VsEt_[0] = dbe_->bookProfile(histname+"All","All photons ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00818     p_ecalRecHitSumEtConeDR04VsEt_[1] = dbe_->bookProfile(histname+"Barrel","All photons ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00819     p_ecalRecHitSumEtConeDR04VsEt_[2] = dbe_->bookProfile(histname+"Endcap","All photons ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00820     //
00821     histname = "hcalTowerSumEtConeDR04";
00822     h_hcalTowerSumEtConeDR04_[0][0] = dbe_->book1D(histname+"All",   "hcalTowerSumEtConeDR04: All Ecal",etBin,etMin,20.);
00823     h_hcalTowerSumEtConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","hcalTowerSumEtConeDR04: Barrel ", etBin,etMin,20.);
00824     h_hcalTowerSumEtConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","hcalTowerSumEtConeDR04: Endcap ", etBin,etMin,20.);
00825     //
00826     histname = "hcalTowerBcSumEtConeDR04";
00827     if ( ! isRunCentrally_ ) h_hcalTowerBcSumEtConeDR04_[0][0] = dbe_->book1D(histname+"All",   "hcalTowerBcSumEtConeDR04: All Ecal",etBin,etMin,20.);
00828     h_hcalTowerBcSumEtConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","hcalTowerBcSumEtConeDR04: Barrel ", etBin,etMin,20.);
00829     h_hcalTowerBcSumEtConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","hcalTowerBcSumEtConeDR04: Endcap ", etBin,etMin,20.);
00830 
00831     //
00832     if ( ! isRunCentrally_ ) { 
00833       histname="hcalTowerSumEtConeDR04VsEta";
00834       h2_hcalTowerSumEtConeDR04VsEta_[0] = dbe_->book2D(histname+"All"," All photons hcalTowerSumEtConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1);
00835       h2_hcalTowerSumEtConeDR04VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons hcalTowerSumEtConeDR04 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,etBin,etMin,etMax*0.1);
00836     }
00837     histname="pHcalTowerSumEtConeDR04VsEta";
00838     p_hcalTowerSumEtConeDR04VsEta_[0] = dbe_->bookProfile(histname+"All","All photons hcalTowerSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1, "");
00839     p_hcalTowerSumEtConeDR04VsEta_[1] = dbe_->bookProfile(histname+"Unconv","All photons hcalTowerSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1, "");
00840     histname="pHcalTowerBcSumEtConeDR04VsEta";
00841     p_hcalTowerBcSumEtConeDR04VsEta_[0] = dbe_->bookProfile(histname+"All","All photons hcalTowerBcSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1, "");
00842     p_hcalTowerBcSumEtConeDR04VsEta_[1] = dbe_->bookProfile(histname+"Unconv","All photons hcalTowerBcSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1, "");
00843     //
00844     if ( ! isRunCentrally_ ) { 
00845       histname="hcalTowerSumEtConeDR04VsEt";
00846       h2_hcalTowerSumEtConeDR04VsEt_[0] = dbe_->book2D(histname+"All"," All photons hcalTowerSumEtConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
00847       h2_hcalTowerSumEtConeDR04VsEt_[1] = dbe_->book2D(histname+"Barrel"," All photons hcalTowerSumEtConeDR04 vs Et: Barrel ",etBin,etMin, etMax,etBin,etMin,etMax*0.1);
00848       h2_hcalTowerSumEtConeDR04VsEt_[2] = dbe_->book2D(histname+"Endcap"," All photons hcalTowerSumEtConeDR04 vs Et: Endcap ",etBin,etMin, etMax,etBin,etMin,etMax*0.1);
00849     }
00850     histname="pHcalTowerSumEtConeDR04VsEt";
00851     if ( ! isRunCentrally_ ) p_hcalTowerSumEtConeDR04VsEt_[0] = dbe_->bookProfile(histname+"All","All photons hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00852     p_hcalTowerSumEtConeDR04VsEt_[1] = dbe_->bookProfile(histname+"Barrel","All photons hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00853     p_hcalTowerSumEtConeDR04VsEt_[2] = dbe_->bookProfile(histname+"Endcap","All photons hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00854     //
00855     histname="pHcalTowerBcSumEtConeDR04VsEt";
00856     if ( ! isRunCentrally_ ) p_hcalTowerBcSumEtConeDR04VsEt_[0] = dbe_->bookProfile(histname+"All","All photons hcalTowerBcSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00857     p_hcalTowerBcSumEtConeDR04VsEt_[1] = dbe_->bookProfile(histname+"Barrel","All photons hcalTowerBcSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00858     p_hcalTowerBcSumEtConeDR04VsEt_[2] = dbe_->bookProfile(histname+"Endcap","All photons hcalTowerBcSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
00859 
00860     //
00861     histname = "isoTrkSolidConeDR04";
00862     h_isoTrkSolidConeDR04_[0][0] = dbe_->book1D(histname+"All",   "isoTrkSolidConeDR04: All Ecal",etBin,etMin,etMax*0.1);
00863     h_isoTrkSolidConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","isoTrkSolidConeDR04: Barrel ", etBin,etMin,etMax*0.1);
00864     h_isoTrkSolidConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","isoTrkSolidConeDR04: Endcap ", etBin,etMin,etMax*0.1);
00865     //
00866 
00867     histname="isoTrkSolidConeDR04VsEta";
00868     if ( ! isRunCentrally_ ) h2_isoTrkSolidConeDR04VsEta_[0] = dbe_->book2D(histname+"All"," All photons isoTrkSolidConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1);
00869     if ( ! isRunCentrally_ ) h2_isoTrkSolidConeDR04VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons isoTrkSolidConeDR04 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,etBin,etMin,etMax*0.1);
00870 
00871     //
00872     histname="isoTrkSolidConeDR04VsEt";
00873     if ( ! isRunCentrally_ ) h2_isoTrkSolidConeDR04VsEt_[0] = dbe_->book2D(histname+"All"," All photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
00874     if ( ! isRunCentrally_ ) h2_isoTrkSolidConeDR04VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
00875     //
00876     histname = "nTrkSolidConeDR04";
00877     h_nTrkSolidConeDR04_[0][0] = dbe_->book1D(histname+"All",   "nTrkSolidConeDR04: All Ecal",20,0., 20) ;
00878     h_nTrkSolidConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","nTrkSolidConeDR04: Barrel ", 20,0., 20) ;
00879     h_nTrkSolidConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","nTrkSolidConeDR04: Endcap ", 20,0., 20) ;
00880     //
00881     histname="nTrkSolidConeDR04VsEta";
00882     if ( ! isRunCentrally_ ) h2_nTrkSolidConeDR04VsEta_[0] = dbe_->book2D(histname+"All"," All photons nTrkSolidConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, 20,0., 20) ;
00883     if ( ! isRunCentrally_ ) h2_nTrkSolidConeDR04VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons nTrkSolidConeDR04 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,20,0., 20) ;
00884     //
00885     histname="nTrkSolidConeDR04VsEt";
00886     if ( ! isRunCentrally_ ) h2_nTrkSolidConeDR04VsEt_[0] = dbe_->book2D(histname+"All"," All photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
00887     if ( ! isRunCentrally_ ) h2_nTrkSolidConeDR04VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax,20,0., 20) ;
00888     //
00889     histname = "phoE";
00890     h_phoE_[0][0]=dbe_->book1D(histname+"All"," Photon Energy: All ecal ", eBin,eMin, eMax);
00891     h_phoE_[0][1]=dbe_->book1D(histname+"Barrel"," Photon Energy: barrel ",eBin,eMin, eMax);
00892     h_phoE_[0][2]=dbe_->book1D(histname+"Endcap"," Photon Energy: Endcap ",eBin,eMin, eMax);
00893 
00894     histname = "phoEt";
00895     h_phoEt_[0][0] = dbe_->book1D(histname+"All"," Photon Transverse Energy: All ecal ", etBin,etMin, etMax);
00896     h_phoEt_[0][1] = dbe_->book1D(histname+"Barrel"," Photon Transverse Energy: Barrel ",etBin,etMin, etMax);
00897     h_phoEt_[0][2] = dbe_->book1D(histname+"Endcap"," Photon Transverse Energy: Endcap ",etBin,etMin, etMax);
00898 
00899     histname = "eRes";
00900     h_phoERes_[0][0] = dbe_->book1D(histname+"All"," Photon rec/true Energy: All ecal ", resBin,resMin, resMax);
00901     h_phoERes_[0][1] = dbe_->book1D(histname+"Barrel"," Photon rec/true Energy: Barrel ",resBin,resMin, resMax);
00902     h_phoERes_[0][2] = dbe_->book1D(histname+"Endcap"," Photon rec/true Energy: Endcap ",resBin,resMin, resMax);
00903 
00904     h_phoERes_[1][0] = dbe_->book1D(histname+"unconvAll"," Photon rec/true Energy if r9>0.94, 0.95: All ecal ", resBin,resMin, resMax);
00905     h_phoERes_[1][1] = dbe_->book1D(histname+"unconvBarrel"," Photon rec/true Energy if r9>0.94: Barrel ",resBin,resMin, resMax);
00906     h_phoERes_[1][2] = dbe_->book1D(histname+"unconvEndcap"," Photon rec/true Energyif r9>0.95: Endcap ",resBin,resMin, resMax);
00907 
00908     h_phoERes_[2][0] = dbe_->book1D(histname+"convAll"," Photon rec/true Energy if r9<0.0.94, 0.95: All ecal ", resBin,resMin, resMax);
00909     h_phoERes_[2][1] = dbe_->book1D(histname+"convBarrel"," Photon rec/true Energyif r9<0.94: Barrel ",resBin,resMin, resMax);
00910     h_phoERes_[2][2] = dbe_->book1D(histname+"convEndcap"," Photon rec/true Energyif r9<0.95: Endcap ",resBin,resMin, resMax);
00911 
00912 
00913     histname="eResVsEta";
00914     if ( ! isRunCentrally_ ) h2_eResVsEta_[0] = dbe_->book2D(histname+"All"," All photons E/Etrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 2.5);
00915     if ( ! isRunCentrally_ ) h2_eResVsEta_[1] = dbe_->book2D(histname+"Unconv"," Unconv photons E/Etrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 2.5);
00916 
00917     histname="pEResVsEta";
00918     p_eResVsEta_[0] = dbe_->bookProfile(histname+"All","All photons  E/Etrue vs #eta: all Ecal ",etaBin2,etaMin,etaMax,resBin,resMin, resMax,"");
00919     p_eResVsEta_[1] = dbe_->bookProfile(histname+"Unconv","Unconv photons  E/Etrue vs #eta: all Ecal",etaBin2,etaMin,etaMax,resBin,resMin, resMax,"");
00920     p_eResVsEta_[2] = dbe_->bookProfile(histname+"Conv","Conv photons  E/Etrue vs #eta: all Ecal",etaBin2,etaMin,etaMax,resBin,resMin, resMax,"");
00921 
00922     if ( ! isRunCentrally_ ) {
00923       histname="eResVsEt";
00924       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);
00925       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);
00926       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);
00927       h2_eResVsEt_[1][0] = dbe_->book2D(histname+"Barrel"," All photons E/Etrue vs true Et: Barrel ",etBin,etMin, etMax,100, 0.9, 1.1);
00928       h2_eResVsEt_[1][1] = dbe_->book2D(histname+"unconvBarrel"," All photons E/Etrue vs true Et: Barrel ",etBin,etMin, etMax,100, 0.9, 1.1);
00929       h2_eResVsEt_[1][2] = dbe_->book2D(histname+"convBarrel"," All photons E/Etrue vs true Et: Barrel ",etBin,etMin, etMax,100, 0.9, 1.1);
00930       h2_eResVsEt_[2][0] = dbe_->book2D(histname+"Endcap"," All photons E/Etrue vs true Et: Endcap ",etBin,etMin, etMax,100, 0.9, 1.1);
00931       h2_eResVsEt_[2][1] = dbe_->book2D(histname+"unconvEndcap"," All photons E/Etrue vs true Et: Endcap ",etBin,etMin, etMax,100, 0.9, 1.1);
00932       h2_eResVsEt_[2][2] = dbe_->book2D(histname+"convEndcap"," All photons E/Etrue vs true Et: Endcap ",etBin,etMin, etMax,100, 0.9, 1.1);
00933     }
00934 
00935     histname="pEResVsEt";
00936     p_eResVsEt_[0][0] = dbe_->bookProfile(histname+"All","All photons  E/Etrue vs Et: all Ecal ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00937     p_eResVsEt_[0][1] = dbe_->bookProfile(histname+"unconv","All photons  E/Etrue vs Et: all Ecal ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00938     p_eResVsEt_[0][2] = dbe_->bookProfile(histname+"conv","All photons  E/Etrue vs Et: all Ecal ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00939     p_eResVsEt_[1][0] = dbe_->bookProfile(histname+"Barrel","All photons  E/Etrue vs Et: Barrel ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00940     p_eResVsEt_[1][1] = dbe_->bookProfile(histname+"unconvBarrel","All photons  E/Etrue vs Et: Barrel ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00941     p_eResVsEt_[1][2] = dbe_->bookProfile(histname+"convBarrel","All photons  E/Etrue vs Et: Barrel ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00942     p_eResVsEt_[2][0] = dbe_->bookProfile(histname+"Endcap","All photons  E/Etrue vs Et: Endcap ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00943     p_eResVsEt_[2][1] = dbe_->bookProfile(histname+"unconvEndcap","All photons  E/Etrue vs Et: Endcap ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00944     p_eResVsEt_[2][2] = dbe_->bookProfile(histname+"convEndcap","All photons  E/Etrue vs Et: Endcap ",etBin,etMin,etMax,resBin,resMin, resMax,"");
00945 
00946 
00947     histname="eResVsR9";
00948     if ( ! isRunCentrally_ ) h2_eResVsR9_[0] = dbe_->book2D(histname+"All"," All photons E/Etrue vs R9: all Ecal ",r9Bin*2,r9Min, r9Max,100, 0., 2.5);
00949     if ( ! isRunCentrally_ ) h2_eResVsR9_[1] = dbe_->book2D(histname+"Barrel"," All photons E/Etrue vs R9: Barrel ",  r9Bin*2,r9Min, r9Max,100, 0.,2.5);
00950     if ( ! isRunCentrally_ ) h2_eResVsR9_[2] = dbe_->book2D(histname+"Endcap"," All photons E/Etrue vs R9: Endcap ",  r9Bin*2,r9Min, r9Max,100, 0., 2.5);
00951     histname="pEResVsR9";
00952     if ( ! isRunCentrally_ ) p_eResVsR9_[0] = dbe_->bookProfile(histname+"All"," All photons  E/Etrue vs R9: all Ecal ",r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
00953     p_eResVsR9_[1] = dbe_->bookProfile(histname+"Barrel"," All photons  E/Etrue vs R9: Barrel ",  r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
00954     p_eResVsR9_[2] = dbe_->bookProfile(histname+"Endcap"," All photons  E/Etrue vs R9: Endcap ",  r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
00955     histname="sceResVsR9";
00956     if ( ! isRunCentrally_ ) h2_sceResVsR9_[0] = dbe_->book2D(histname+"All"," All photons scE/Etrue vs R9: all Ecal ",r9Bin*2,r9Min, r9Max,100, 0., 2.5);
00957     if ( ! isRunCentrally_ ) h2_sceResVsR9_[1] = dbe_->book2D(histname+"Barrel"," All photons scE/Etrue vs R9: Barrel ",  r9Bin*2,r9Min, r9Max,100, 0.,2.5);
00958     if ( ! isRunCentrally_ ) h2_sceResVsR9_[2] = dbe_->book2D(histname+"Endcap"," All photons scE/Etrue vs R9: Endcap ",  r9Bin*2,r9Min, r9Max,100, 0., 2.5);
00959     histname="scpEResVsR9";
00960     if ( ! isRunCentrally_ ) p_sceResVsR9_[0] = dbe_->bookProfile(histname+"All"," All photons  scE/Etrue vs R9: all Ecal ",r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
00961     p_sceResVsR9_[1] = dbe_->bookProfile(histname+"Barrel"," All photons  scE/Etrue vs R9: Barrel ",  r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
00962     p_sceResVsR9_[2] = dbe_->bookProfile(histname+"Endcap"," All photons  scE/Etrue vs R9: Endcap ",  r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
00963 
00964     // Photon E reslution when using energy values from regressions
00965     histname = "eResRegr1";
00966     h_phoEResRegr1_[0][0] = dbe_->book1D(histname+"All"," Photon rec/true Energy from Regression1 : All ecal ", resBin,resMin, resMax);
00967     h_phoEResRegr1_[0][1] = dbe_->book1D(histname+"Barrel"," Photon rec/true Energy from Regression1: Barrel ",resBin,resMin, resMax);
00968     h_phoEResRegr1_[0][2] = dbe_->book1D(histname+"Endcap"," Photon rec/true Energy from Regression1: Endcap ",resBin,resMin, resMax);
00969 
00970     h_phoEResRegr1_[1][0] = dbe_->book1D(histname+"unconvAll"," Photon rec/true Energy from Regression1 if r9>0.94, 0.95: All ecal ", resBin,resMin, resMax);
00971     h_phoEResRegr1_[1][1] = dbe_->book1D(histname+"unconvBarrel"," Photon rec/true Energy from Regression1 if r9>0.94: Barrel ",resBin,resMin, resMax);
00972     h_phoEResRegr1_[1][2] = dbe_->book1D(histname+"unconvEndcap"," Photon rec/true Energy from Regression1 if r9>0.95: Endcap ",resBin,resMin, resMax);
00973 
00974     h_phoEResRegr1_[2][0] = dbe_->book1D(histname+"convAll"," Photon rec/true Energy  from Regression1if r9<0.0.94, 0.95: All ecal ", resBin,resMin, resMax);
00975     h_phoEResRegr1_[2][1] = dbe_->book1D(histname+"convBarrel"," Photon rec/true Energy from Regression1 if r9<0.94: Barrel ",resBin,resMin, resMax);
00976     h_phoEResRegr1_[2][2] = dbe_->book1D(histname+"convEndcap"," Photon rec/true Energy from Regression1 if r9<0.95: Endcap ",resBin,resMin, resMax);
00977 
00978     histname = "eResRegr2";
00979     h_phoEResRegr2_[0][0] = dbe_->book1D(histname+"All"," Photon rec/true Energy from Regression2 : All ecal ", resBin,resMin, resMax);
00980     h_phoEResRegr2_[0][1] = dbe_->book1D(histname+"Barrel"," Photon rec/true Energy from Regression2: Barrel ",resBin,resMin, resMax);
00981     h_phoEResRegr2_[0][2] = dbe_->book1D(histname+"Endcap"," Photon rec/true Energy from Regression2: Endcap ",resBin,resMin, resMax);
00982 
00983     h_phoEResRegr2_[1][0] = dbe_->book1D(histname+"unconvAll"," Photon rec/true Energy from Regression2 if r9>0.94, 0.95: All ecal ", resBin,resMin, resMax);
00984     h_phoEResRegr2_[1][1] = dbe_->book1D(histname+"unconvBarrel"," Photon rec/true Energy from Regression2 if r9>0.94: Barrel ",resBin,resMin, resMax);
00985     h_phoEResRegr2_[1][2] = dbe_->book1D(histname+"unconvEndcap"," Photon rec/true Energy from Regression2 if r9>0.95: Endcap ",resBin,resMin, resMax);
00986 
00987     h_phoEResRegr2_[2][0] = dbe_->book1D(histname+"convAll"," Photon rec/true Energy  from Regression2 if r9<0.0.94, 0.95: All ecal ", resBin,resMin, resMax);
00988     h_phoEResRegr2_[2][1] = dbe_->book1D(histname+"convBarrel"," Photon rec/true Energy from Regression2 if r9<0.94: Barrel ",resBin,resMin, resMax);
00989     h_phoEResRegr2_[2][2] = dbe_->book1D(histname+"convEndcap"," Photon rec/true Energy from Regression2 if r9<0.95: Endcap ",resBin,resMin, resMax);
00990 
00991     //  Infos from Particle Flow - isolation and ID
00992     histname = "chargedHadIso";
00993     h_chHadIso_[0]=  dbe_->book1D(histname+"All",   "PF chargedHadIso:  All Ecal",etBin,etMin,20.);
00994     h_chHadIso_[1]=  dbe_->book1D(histname+"Barrel",   "PF chargedHadIso:  Barrel",etBin,etMin,20.);
00995     h_chHadIso_[2]=  dbe_->book1D(histname+"Endcap",   "PF chargedHadIso:  Endcap",etBin,etMin,20.);
00996     histname = "neutralHadIso";
00997     h_nHadIso_[0]=  dbe_->book1D(histname+"All",   "PF neutralHadIso:  All Ecal",etBin,etMin,20.);
00998     h_nHadIso_[1]=  dbe_->book1D(histname+"Barrel",   "PF neutralHadIso:  Barrel",etBin,etMin,20.);
00999     h_nHadIso_[2]=  dbe_->book1D(histname+"Endcap",   "PF neutralHadIso:  Endcap",etBin,etMin,20.);
01000     histname = "photonIso";
01001     h_phoIso_[0]=  dbe_->book1D(histname+"All",   "PF photonIso:  All Ecal",etBin,etMin,20.);
01002     h_phoIso_[1]=  dbe_->book1D(histname+"Barrel",   "PF photonIso:  Barrel",etBin,etMin,20.);
01003     h_phoIso_[2]=  dbe_->book1D(histname+"Endcap",   "PF photonIso:  Endcap",etBin,etMin,20.);
01004     histname = "nCluOutMustache";
01005     h_nCluOutsideMustache_[0]= dbe_->book1D(histname+"All",   "PF number of clusters outside Mustache:  All Ecal",50,0.,50.);      
01006     h_nCluOutsideMustache_[1]= dbe_->book1D(histname+"Barrel",   "PF number of clusters outside Mustache:  Barrel",50,0.,50.);      
01007     h_nCluOutsideMustache_[2]= dbe_->book1D(histname+"Endcap",   "PF number of clusters outside Mustache:  Endcap",50,0.,50.);      
01008     histname = "etOutMustache";
01009     h_etOutsideMustache_[0]= dbe_->book1D(histname+"All",   "PF et outside Mustache:  All Ecal",etBin,etMin,20.);
01010     h_etOutsideMustache_[1]= dbe_->book1D(histname+"Barrel",   "PF et outside Mustache:  Barrel",etBin,etMin,20.);
01011     h_etOutsideMustache_[2]= dbe_->book1D(histname+"Endcap",   "PF et outside Mustache:  Endcap",etBin,etMin,20.);
01012     histname = "pfMVA";
01013     h_pfMva_[0]= dbe_->book1D(histname+"All",   "PF MVA output:  All Ecal",50,-1.,2.);
01014     h_pfMva_[1]= dbe_->book1D(histname+"Barrel",   "PF MVA output:  Barrel",50,-1.,2.);
01015     h_pfMva_[2]= dbe_->book1D(histname+"Endcap",   "PF MVA output:  Endcap",50,-1,2.);
01016 
01017 
01018     //    if ( ! isRunCentrally_ ) { 
01019       // Photon pair invariant mass
01020       histname = "gamgamMass";
01021       h_gamgamMass_[0][0] = dbe_->book1D(histname+"All","2 photons invariant mass: All ecal ", ggMassBin, ggMassMin, ggMassMax);
01022       h_gamgamMass_[0][1] = dbe_->book1D(histname+"Barrel","2 photons invariant mass:  Barrel ",ggMassBin, ggMassMin, ggMassMax);
01023       h_gamgamMass_[0][2] = dbe_->book1D(histname+"Endcap","2 photons invariant mass:  Endcap ",ggMassBin, ggMassMin, ggMassMax);
01024       //
01025       histname = "gamgamMassNoConv";
01026       h_gamgamMass_[1][0] = dbe_->book1D(histname+"All","2 photons with no conversion invariant mass: All ecal ",ggMassBin, ggMassMin, ggMassMax);
01027       h_gamgamMass_[1][1] = dbe_->book1D(histname+"Barrel","2 photons with no conversion  invariant mass:  Barrel ",ggMassBin, ggMassMin, ggMassMax);
01028       h_gamgamMass_[1][2] = dbe_->book1D(histname+"Endcap","2 photons with no conversion  invariant mass:  Endcap ",ggMassBin, ggMassMin, ggMassMax);
01029       //
01030       histname = "gamgamMassConv";
01031       h_gamgamMass_[2][0] = dbe_->book1D(histname+"All","2 photons with conversion invariant mass: All ecal ", ggMassBin, ggMassMin, ggMassMax);
01032       h_gamgamMass_[2][1] = dbe_->book1D(histname+"Barrel","2 photons with  conversion  invariant mass:  Barrel ",ggMassBin, ggMassMin, ggMassMax);
01033       h_gamgamMass_[2][2] = dbe_->book1D(histname+"Endcap","2 photons with  conversion  invariant mass:  Endcap ",ggMassBin, ggMassMin, ggMassMax);
01034       // with energy regression1 
01035       histname = "gamgamMassRegr1";
01036       h_gamgamMassRegr1_[0][0] = dbe_->book1D(histname+"All","2 photons invariant mass Regr1 : All ecal ", ggMassBin, ggMassMin, ggMassMax);
01037       h_gamgamMassRegr1_[0][1] = dbe_->book1D(histname+"Barrel","2 photons invariant mass Regr1 :  Barrel ",ggMassBin, ggMassMin, ggMassMax);
01038       h_gamgamMassRegr1_[0][2] = dbe_->book1D(histname+"Endcap","2 photons invariant mass Regr1 :  Endcap ",ggMassBin, ggMassMin, ggMassMax);
01039       //
01040       histname = "gamgamMassRegr1NoConv";
01041       h_gamgamMassRegr1_[1][0] = dbe_->book1D(histname+"All","2 photons with no conversion invariant mass Regr1: All ecal ",ggMassBin, ggMassMin, ggMassMax);
01042       h_gamgamMassRegr1_[1][1] = dbe_->book1D(histname+"Barrel","2 photons with no conversion  invariant mass Regr1:  Barrel ",ggMassBin, ggMassMin, ggMassMax);
01043       h_gamgamMassRegr1_[1][2] = dbe_->book1D(histname+"Endcap","2 photons with no conversion  invariant mass Regr1:  Endcap ",ggMassBin, ggMassMin, ggMassMax);
01044       //
01045       histname = "gamgamMassRegr1Conv";
01046       h_gamgamMassRegr1_[2][0] = dbe_->book1D(histname+"All","2 photons with conversion invariant mass Regr1: All ecal ", ggMassBin, ggMassMin, ggMassMax);
01047       h_gamgamMassRegr1_[2][1] = dbe_->book1D(histname+"Barrel","2 photons with  conversion  invariant mass Regr1:  Barrel ",ggMassBin, ggMassMin, ggMassMax);
01048       h_gamgamMassRegr1_[2][2] = dbe_->book1D(histname+"Endcap","2 photons with  conversion  invariant mass Regr1:  Endcap ",ggMassBin, ggMassMin, ggMassMax);
01049       // with energy regression2
01050       histname = "gamgamMassRegr2";
01051       h_gamgamMassRegr2_[0][0] = dbe_->book1D(histname+"All","2 photons invariant mass Regr2 : All ecal ", ggMassBin, ggMassMin, ggMassMax);
01052       h_gamgamMassRegr2_[0][1] = dbe_->book1D(histname+"Barrel","2 photons invariant mass Regr2 :  Barrel ",ggMassBin, ggMassMin, ggMassMax);
01053       h_gamgamMassRegr2_[0][2] = dbe_->book1D(histname+"Endcap","2 photons invariant mass Regr2 :  Endcap ",ggMassBin, ggMassMin, ggMassMax);
01054       //
01055       histname = "gamgamMassRegr2NoConv";
01056       h_gamgamMassRegr2_[1][0] = dbe_->book1D(histname+"All","2 photons with no conversion invariant mass Regr2: All ecal ",ggMassBin, ggMassMin, ggMassMax);
01057       h_gamgamMassRegr2_[1][1] = dbe_->book1D(histname+"Barrel","2 photons with no conversion  invariant mass Regr2:  Barrel ",ggMassBin, ggMassMin, ggMassMax);
01058       h_gamgamMassRegr2_[1][2] = dbe_->book1D(histname+"Endcap","2 photons with no conversion  invariant mass Regr2:  Endcap ",ggMassBin, ggMassMin, ggMassMax);
01059       //
01060       histname = "gamgamMassRegr2Conv";
01061       h_gamgamMassRegr2_[2][0] = dbe_->book1D(histname+"All","2 photons with conversion invariant mass Regr2: All ecal ", ggMassBin, ggMassMin, ggMassMax);
01062       h_gamgamMassRegr2_[2][1] = dbe_->book1D(histname+"Barrel","2 photons with  conversion  invariant mass Regr2:  Barrel ",ggMassBin, ggMassMin, ggMassMax);
01063       h_gamgamMassRegr2_[2][2] = dbe_->book1D(histname+"Endcap","2 photons with  conversion  invariant mass Regr2:  Endcap ",ggMassBin, ggMassMin, ggMassMax);
01064  
01065 
01066       //}
01067 
01068     dbe_->setCurrentFolder("EgammaV/"+fName_+"/ConversionInfo");
01069 
01070   
01071     histname="nConv";
01072     h_nConv_[0][0] = dbe_->book1D(histname+"All","Number Of Conversions per isolated candidates per events: All Ecal  ",10,-0.5, 9.5);
01073     h_nConv_[0][1] = dbe_->book1D(histname+"Barrel","Number Of Conversions per isolated candidates per events: Ecal Barrel  ",10,-0.5, 9.5);
01074     h_nConv_[0][2] = dbe_->book1D(histname+"Endcap","Number Of Conversions per isolated candidates per events: Ecal Endcap ",10,-0.5, 9.5);
01075 
01076     h_convEta_[0] = dbe_->book1D("convEta1"," converted Photon Eta >1 track",etaBin,etaMin, etaMax) ;
01077     h_convEta_[1] = dbe_->book1D("convEta2"," converted Photon Eta =2 tracks ",etaBin,etaMin, etaMax) ;
01078     h_convEta_[2] = dbe_->book1D("convEta2ass"," converted Photon Eta =2 tracks, both ass ",etaBin,etaMin, etaMax) ;
01079     h_convPhi_[0] = dbe_->book1D("convPhi"," converted Photon  Phi ",phiBin,phiMin,phiMax) ;
01080 
01081 
01082     histname = "convERes";
01083     h_convERes_[0][0] = dbe_->book1D(histname+"All"," Conversion rec/true Energy: All ecal ", resBin,resMin, resMax);
01084     h_convERes_[0][1] = dbe_->book1D(histname+"Barrel"," Conversion rec/true Energy: Barrel ",resBin,resMin, resMax);
01085     h_convERes_[0][2] = dbe_->book1D(histname+"Endcap"," Conversion rec/true Energy: Endcap ",resBin,resMin, resMax);
01086 
01087     histname="p_EResVsR";
01088     p_eResVsR_ = dbe_->bookProfile(histname+"All"," photons conversion E/Etrue vs R: all Ecal ",rBin,rMin,rMax, 100, 0.,1.5,"");
01089 
01090 
01091     histname = "convPtRes";
01092     h_convPtRes_[1][0] = dbe_->book1D(histname+"All"," Conversion Pt rec/true  from tracks : All ecal ", resBin,0.,1.5);
01093     h_convPtRes_[1][1] = dbe_->book1D(histname+"Barrel"," Conversion Pt rec/true  from tracks: Barrel ",resBin,0., 1.5);
01094     h_convPtRes_[1][2] = dbe_->book1D(histname+"Endcap"," Conversion Pt rec/true  from tracks: Endcap ",resBin,0., 1.5);
01095 
01096 
01097     if ( ! isRunCentrally_ ) {
01098       histname="r9VsTracks";
01099       h_r9VsNofTracks_[0][0] = dbe_->book2D(histname+"All"," photons r9 vs nTracks from conversions: All Ecal",r9Bin,r9Min, r9Max, 3, -0.5, 2.5) ;
01100       h_r9VsNofTracks_[0][1] = dbe_->book2D(histname+"Barrel"," photons r9 vs nTracks from conversions: Barrel Ecal",r9Bin,r9Min, r9Max, 3, -0.5, 2.5) ;
01101       h_r9VsNofTracks_[0][2] = dbe_->book2D(histname+"Endcap"," photons r9 vs nTracks from conversions: Endcap Ecal",r9Bin,r9Min, r9Max, 3, -0.5, 2.5) ;
01102     }
01103 
01104     histname="mvaOut";
01105     h_mvaOut_[0] = dbe_->book1D(histname+"All"," mvaOut for all conversions : All Ecal",100, 0., 1.);
01106     h_mvaOut_[1] = dbe_->book1D(histname+"Barrel"," mvaOut for all conversions : Barrel Ecal",100, 0., 1.);
01107     h_mvaOut_[2] = dbe_->book1D(histname+"Endcap"," mvaOut for all conversions : Endcap Ecal",100, 0., 1.);
01108 
01109 
01110 
01111     histname="EoverPtracks";
01112     h_EoverPTracks_[0][0] = dbe_->book1D(histname+"BarrelPix"," photons conversion E/p: barrel pix",eoverpBin, eoverpMin,eoverpMax);
01113     h_EoverPTracks_[0][1] = dbe_->book1D(histname+"BarrelTib"," photons conversion E/p: barrel tib",eoverpBin, eoverpMin,eoverpMax);
01114     h_EoverPTracks_[0][2] = dbe_->book1D(histname+"BarrelTob"," photons conversion E/p: barrel tob ",eoverpBin, eoverpMin,eoverpMax);
01115 
01116     h_EoverPTracks_[1][0] = dbe_->book1D(histname+"All"," photons conversion E/p: all Ecal ",100, 0., 5.);
01117     h_EoverPTracks_[1][1] = dbe_->book1D(histname+"Barrel"," photons conversion E/p: Barrel Ecal",100, 0., 5.);
01118     h_EoverPTracks_[1][2] = dbe_->book1D(histname+"Endcap"," photons conversion E/p: Endcap Ecal ",100, 0., 5.);
01119 
01120     histname="PoverEtracks";
01121     h_PoverETracks_[1][0] = dbe_->book1D(histname+"All"," photons conversion p/E: all Ecal ",povereBin, povereMin, povereMax);
01122     h_PoverETracks_[1][1] = dbe_->book1D(histname+"Barrel"," photons conversion p/E: Barrel Ecal",povereBin, povereMin, povereMax);
01123     h_PoverETracks_[1][2] = dbe_->book1D(histname+"Endcap"," photons conversion p/E: Endcap Ecal ",povereBin, povereMin, povereMax);
01124 
01125     histname="pEoverEtrueVsEta";
01126     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,"");
01127 
01128     histname="pEoverEtrueVsR";
01129     p_EoverEtrueVsR_[0] = dbe_->bookProfile(histname+"All"," photons conversion E/Etrue vs R: all Ecal ",rBin,rMin,rMax, 100, 0., 2.5, "");
01130 
01131     histname="pEoverEtrueVsEta";
01132     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,"");
01133 
01134     histname="pPoverPtrueVsEta";
01135     p_PoverPtrueVsEta_[0] = dbe_->bookProfile(histname+"All"," photons conversion P/Ptrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 5.,"");
01136 
01137     histname="pEoverPVsEta";
01138     p_EoverPVsEta_[0] = dbe_->bookProfile(histname+"All"," photons conversion E/P vs #eta: all Ecal ",etaBin2,etaMin, etaMax, 100, 0., 5.,"");
01139 
01140 
01141     if ( ! isRunCentrally_ ) {
01142       histname="EoverEtrueVsEoverP";
01143       h2_EoverEtrueVsEoverP_[0] = dbe_->book2D(histname+"All"," photons conversion E/Etrue vs E/P: all Ecal ",100, 0., 5., 100, 0.5, 1.5);
01144       h2_EoverEtrueVsEoverP_[1] = dbe_->book2D(histname+"Barrel"," photons conversion  E/Etrue vs E/: Barrel Ecal",100, 0., 5.,100, 0.5, 1.5);
01145       h2_EoverEtrueVsEoverP_[2] = dbe_->book2D(histname+"Endcap"," photons conversion  E/Etrue vs E/: Endcap Ecal ",100, 0., 5., 100, 0.5, 1.5);
01146       histname="PoverPtrueVsEoverP";
01147       h2_PoverPtrueVsEoverP_[0] = dbe_->book2D(histname+"All"," photons conversion P/Ptrue vs E/P: all Ecal ",100, 0., 5., 100, 0., 2.5);
01148       h2_PoverPtrueVsEoverP_[1] = dbe_->book2D(histname+"Barrel"," photons conversion  P/Ptrue vs E/: Barrel Ecal",100, 0., 5.,100, 0., 2.5);
01149       h2_PoverPtrueVsEoverP_[2] = dbe_->book2D(histname+"Endcap"," photons conversion  P/Ptrue vs E/: Endcap Ecal ",100, 0., 5., 100, 0., 2.5);
01150 
01151       histname="EoverEtrueVsEta";
01152       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);
01153 
01154 
01155       histname="EoverEtrueVsEta";
01156       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);
01157 
01158       histname="EoverEtrueVsR";
01159       h2_EoverEtrueVsR_[0] = dbe_->book2D(histname+"All"," photons conversion E/Etrue vs R: all Ecal ",rBin,rMin, rMax,100, 0., 2.5);
01160 
01161       histname="PoverPtrueVsEta";
01162       h2_PoverPtrueVsEta_[0] = dbe_->book2D(histname+"All"," photons conversion P/Ptrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 5.);
01163 
01164       histname="EoverPVsEta";
01165       h2_EoverPVsEta_[0] = dbe_->book2D(histname+"All"," photons conversion E/P vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 5.);
01166 
01167       histname="EoverPVsR";
01168       h2_EoverPVsR_[0] = dbe_->book2D(histname+"All"," photons conversion E/P vs R: all Ecal ",rBin,rMin, rMax,100, 0., 5.);
01169 
01170       histname="etaVsRsim";
01171       h2_etaVsRsim_[0] = dbe_->book2D(histname+"All"," eta(sim) vs R (sim) for associated conversions: all Ecal ",etaBin, etaMin, etaMax,rBin,rMin, rMax);
01172       histname="etaVsRreco";
01173       h2_etaVsRreco_[0] = dbe_->book2D(histname+"All"," eta(reco) vs R (reco) for associated conversions: all Ecal ",etaBin, etaMin, etaMax,rBin,rMin, rMax);
01174 
01175     }
01176 
01177     histname="pEoverPVsR";
01178     p_EoverPVsR_[0] = dbe_->bookProfile(histname+"All"," photons conversion E/P vs R: all Ecal ",rBin,rMin,rMax, 100, 0., 5.,"");
01179 
01180 
01181     histname="hInvMass";
01182     h_invMass_[0][0]= dbe_->book1D(histname+"All_AllTracks"," Photons:Tracks from conversion: Pair invariant mass: all Ecal ",100, 0., 1.5);
01183     h_invMass_[0][1]= dbe_->book1D(histname+"Barrel_AllTracks"," Photons:Tracks from conversion: Pair invariant mass: Barrel Ecal ",100, 0., 1.5);
01184     h_invMass_[0][2]= dbe_->book1D(histname+"Endcap_AllTracks"," Photons:Tracks from conversion: Pair invariant mass: Endcap Ecal ",100, 0., 1.5);
01185     histname="hInvMass";
01186     h_invMass_[1][0]= dbe_->book1D(histname+"All_AssTracks"," Photons:Tracks from conversion: Pair invariant mass: all Ecal ",100, 0., 1.5);
01187     h_invMass_[1][1]= dbe_->book1D(histname+"Barrel_AssTracks"," Photons:Tracks from conversion: Pair invariant mass: Barrel Ecal ",100, 0., 1.5);
01188     h_invMass_[1][2]= dbe_->book1D(histname+"Endcap_AssTracks"," Photons:Tracks from conversion: Pair invariant mass: Endcap Ecal ",100, 0., 1.5);
01189 
01190 
01191     histname="hDPhiTracksAtVtx";
01192     h_DPhiTracksAtVtx_[1][0] =dbe_->book1D(histname+"All", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: all Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
01193     h_DPhiTracksAtVtx_[1][1] =dbe_->book1D(histname+"Barrel", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Barrel Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
01194     h_DPhiTracksAtVtx_[1][2] =dbe_->book1D(histname+"Endcap", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Endcap Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
01195 
01196 
01197     if ( ! isRunCentrally_ ) {
01198       histname="hDPhiTracksAtVtxVsEta";
01199       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);
01200 
01201       histname="hDPhiTracksAtVtxVsR";
01202       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);
01203 
01204       histname="hDCotTracksVsEta";
01205       h2_DCotTracksVsEta_ = dbe_->book2D(histname+"All","  Photons:Tracks from conversions:  #delta cotg(#Theta) Tracks vs #eta",etaBin2,etaMin, etaMax,100, -0.2, 0.2);
01206 
01207       histname="hDCotTracksVsR";
01208       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);
01209 
01210       histname="h2_DPhiTracksAtEcalVsR";
01211       if ( fName_ != "pfPhotonValidator" &&  fName_ != "oldpfPhotonValidator" ) h2_DPhiTracksAtEcalVsR_= dbe_->book2D(histname+"All"," Photons:Tracks from conversions:  #delta#phi at Ecal vs R : all Ecal ",rBin,rMin, rMax, dPhiTracksBin,0.,dPhiTracksMax);
01212 
01213       histname="h2_DPhiTracksAtEcalVsEta";
01214       if ( fName_ != "pfPhotonValidator" &&  fName_ != "oldpfPhotonValidator" ) h2_DPhiTracksAtEcalVsEta_= dbe_->book2D(histname+"All"," Photons:Tracks from conversions:  #delta#phi at Ecal vs #eta : all Ecal ",etaBin2,etaMin, etaMax, dPhiTracksBin,0.,dPhiTracksMax);
01215 
01216 
01217     }
01218 
01219     histname="pDPhiTracksAtVtxVsEta";
01220     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,"");
01221 
01222     histname="pDPhiTracksAtVtxVsR";
01223     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,"");
01224 
01225 
01226     histname="hDCotTracks";
01227     h_DCotTracks_[1][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: all Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
01228     h_DCotTracks_[1][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Barrel Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
01229     h_DCotTracks_[1][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Endcap Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
01230 
01231 
01232     histname="pDCotTracksVsEta";
01233     p_DCotTracksVsEta_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions:  #delta cotg(#Theta) Tracks vs #eta ",etaBin2,etaMin, etaMax, 100, -0.2, 0.2,"");
01234 
01235     histname="pDCotTracksVsR";
01236     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,"");
01237 
01238 
01239     histname="hDistMinAppTracks";
01240     h_distMinAppTracks_[1][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions Min Approach Dist Tracks: all Ecal ",dEtaTracksBin,-0.1,0.6);
01241     h_distMinAppTracks_[1][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions Min Approach Dist Tracks: Barrel Ecal ",dEtaTracksBin,-0.1,0.6);
01242     h_distMinAppTracks_[1][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions Min Approach Dist Tracks: Endcap Ecal ",dEtaTracksBin,-0.1,0.6);
01243 
01244     if ( fName_ != "pfPhotonValidator" &&  fName_ != "oldpfPhotonValidator" ) {
01245       histname="hDPhiTracksAtEcal";
01246       h_DPhiTracksAtEcal_[1][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions:  #delta#phi at Ecal : all Ecal ",dPhiTracksBin,0.,dPhiTracksMax);
01247       h_DPhiTracksAtEcal_[1][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions:  #delta#phi at Ecal : Barrel Ecal ",dPhiTracksBin,0.,dPhiTracksMax);
01248       h_DPhiTracksAtEcal_[1][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions:  #delta#phi at Ecal : Endcap Ecal ",dPhiTracksBin,0.,dPhiTracksMax);
01249       
01250       histname="pDPhiTracksAtEcalVsR";
01251       p_DPhiTracksAtEcalVsR_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions:  #delta#phi at Ecal  vs R ",rBin,rMin, rMax, dPhiTracksBin,0.,dPhiTracksMax,"");
01252 
01253       histname="pDPhiTracksAtEcalVsEta";
01254       p_DPhiTracksAtEcalVsEta_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions:  #delta#phi at Ecal  vs #eta ",etaBin2,etaMin, etaMax,dPhiTracksBin,0.,dPhiTracksMax,"");
01255 
01256 
01257       histname="hDEtaTracksAtEcal";
01258       h_DEtaTracksAtEcal_[1][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions:  #delta#eta at Ecal : all Ecal ",dEtaTracksBin,dEtaTracksMin,dEtaTracksMax);
01259       h_DEtaTracksAtEcal_[1][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions:  #delta#eta at Ecal : Barrel Ecal ",dEtaTracksBin,dEtaTracksMin,dEtaTracksMax);
01260       h_DEtaTracksAtEcal_[1][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions:  #delta#eta at Ecal : Endcap Ecal ",dEtaTracksBin,dEtaTracksMin,dEtaTracksMax);
01261       
01262     }
01263 
01264 
01265     h_convVtxRvsZ_[0] =   dbe_->book2D("convVtxRvsZAll"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
01266     h_convVtxRvsZ_[1] =   dbe_->book2D("convVtxRvsZBarrel"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
01267     h_convVtxRvsZ_[2] =   dbe_->book2D("convVtxRvsZEndcap"," Photon Reco conversion vtx position",zBin2ForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
01268     h_convVtxYvsX_ =   dbe_->book2D("convVtxYvsXTrkBarrel"," Photon Reco conversion vtx position, (x,y) eta<1 ",100, -80., 80., 100, -80., 80.);
01270     if ( ! isRunCentrally_ ) {
01271       h_convVtxRvsZ_zoom_[0] =  dbe_->book2D("convVtxRvsZBarrelZoom1"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, -10., 40.);
01272       h_convVtxRvsZ_zoom_[1] =  dbe_->book2D("convVtxRvsZBarrelZoom2"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, -10., 20.);
01273       h_convVtxYvsX_zoom_[0] =   dbe_->book2D("convVtxYvsXTrkBarrelZoom1"," Photon Reco conversion vtx position, (x,y) eta<1 ",100, -40., 40., 100, -40., 40.);
01274       h_convVtxYvsX_zoom_[1] =   dbe_->book2D("convVtxYvsXTrkBarrelZoom2"," Photon Reco conversion vtx position, (x,y) eta<1 ",100, -20., 20., 100, -20., 20.);
01275     }
01276 
01277     h_convVtxdX_ =   dbe_->book1D("convVtxdX"," Photon Reco conversion vtx dX",100, -20.,20.);
01278     h_convVtxdY_ =   dbe_->book1D("convVtxdY"," Photon Reco conversion vtx dY",100, -20.,20.);
01279     h_convVtxdZ_ =   dbe_->book1D("convVtxdZ"," Photon Reco conversion vtx dZ",100, -20.,20.);
01280     h_convVtxdR_ =   dbe_->book1D("convVtxdR"," Photon Reco conversion vtx dR",100, -20.,20.);
01281 
01282     h_convVtxdX_barrel_ =   dbe_->book1D("convVtxdX_barrel"," Photon Reco conversion vtx dX, |eta|<=1.2",100, -20.,20.);
01283     h_convVtxdY_barrel_ =   dbe_->book1D("convVtxdY_barrel"," Photon Reco conversion vtx dY, |eta|<=1.2 ",100, -20.,20.);
01284     h_convVtxdZ_barrel_ =   dbe_->book1D("convVtxdZ_barrel"," Photon Reco conversion vtx dZ, |eta|<=1.2,",100, -20.,20.);
01285     h_convVtxdR_barrel_ =   dbe_->book1D("convVtxdR_barrel"," Photon Reco conversion vtx dR, |eta|<=1.2",100, -20.,20.);
01286     h_convVtxdX_endcap_ =   dbe_->book1D("convVtxdX_endcap"," Photon Reco conversion vtx dX,  |eta|>1.2",100, -20.,20.);
01287     h_convVtxdY_endcap_ =   dbe_->book1D("convVtxdY_endcap"," Photon Reco conversion vtx dY,  |eta|>1.2",100, -20.,20.);
01288     h_convVtxdZ_endcap_ =   dbe_->book1D("convVtxdZ_endcap"," Photon Reco conversion vtx dZ,  |eta|>1.2",100, -20.,20.);
01289     h_convVtxdR_endcap_ =   dbe_->book1D("convVtxdR_endcap"," Photon Reco conversion vtx dR,  |eta|>1.2 ",100, -20.,20.);
01290 
01291 
01292     h_convVtxdPhi_ =   dbe_->book1D("convVtxdPhi"," Photon Reco conversion vtx dPhi",100, -0.005,0.005);
01293     h_convVtxdEta_ =   dbe_->book1D("convVtxdEta"," Photon Reco conversion vtx dEta",100, -0.5,0.5);
01294 
01295     if ( ! isRunCentrally_ ) {
01296       h2_convVtxdRVsR_ =  dbe_->book2D("h2ConvVtxdRVsR","Photon Reco conversion vtx dR vsR" ,rBin,rMin, rMax,100, -20.,20.);
01297       h2_convVtxdRVsEta_ =  dbe_->book2D("h2ConvVtxdRVsEta","Photon Reco conversion vtx dR vs Eta" ,etaBin2,etaMin, etaMax,100, -20.,20.);
01298     }
01299 
01300     p_convVtxdRVsR_ =  dbe_->bookProfile("pConvVtxdRVsR","Photon Reco conversion vtx dR vsR" ,rBin,rMin, rMax ,100, -20.,20., "");
01301     p_convVtxdRVsEta_ =  dbe_->bookProfile("pConvVtxdRVsEta","Photon Reco conversion vtx dR vs Eta" ,etaBin2,etaMin, etaMax, 100, -20.,20., "");
01302     p_convVtxdXVsX_ =  dbe_->bookProfile("pConvVtxdXVsX","Conversion vtx dX vs X" ,120,-60, 60 ,100, -20.,20., "");
01303     p_convVtxdYVsY_ =  dbe_->bookProfile("pConvVtxdYVsY","Conversion vtx dY vs Y" ,120,-60, 60 ,100, -20.,20., "");
01304     p_convVtxdZVsZ_ =  dbe_->bookProfile("pConvVtxdZVsZ","Conversion vtx dZ vs Z" ,zBin,zMin,zMax ,100, -20.,20., "");
01305 
01306 
01307     if ( ! isRunCentrally_ ) {
01308       h2_convVtxRrecVsTrue_ =  dbe_->book2D("h2ConvVtxRrecVsTrue","Photon Reco conversion vtx R rec vs true" ,rBin,rMin, rMax,rBin,rMin, rMax);
01309     }
01310 
01311     histname="vtxChi2";
01312     h_vtxChi2_[0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 100, chi2Min, chi2Max);
01313     h_vtxChi2_[1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 100, chi2Min, chi2Max);
01314     h_vtxChi2_[2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 100, chi2Min, chi2Max);
01315     histname="vtxChi2Prob";
01316     h_vtxChi2Prob_[0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 100, 0., 1.);
01317     h_vtxChi2Prob_[1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 100, 0., 1.);
01318     h_vtxChi2Prob_[2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 100, 0., 1.);
01319 
01320     histname="zPVFromTracks";
01321     h_zPVFromTracks_[0] =  dbe_->book1D(histname+"All"," Photons: PV z from conversion tracks",   100, -30., 30.);
01322     h_zPVFromTracks_[1] =  dbe_->book1D(histname+"Barrel"," Photons: PV z from conversion tracks",100, -30., 30.);
01323     h_zPVFromTracks_[2] =  dbe_->book1D(histname+"Endcap"," Photons: PV z from conversion tracks",100, -30., 30.);
01324     h_zPVFromTracks_[3] =  dbe_->book1D(histname+"EndcapP"," Photons: PV z from conversion tracks",100, -30., 30.);
01325     h_zPVFromTracks_[4] =  dbe_->book1D(histname+"EndcapM"," Photons: PV z from conversion tracks",100, -30., 30.);
01326     histname="dzPVFromTracks";
01327     h_dzPVFromTracks_[0] =  dbe_->book1D(histname+"All"," Photons: PV Z_rec - Z_true from conversion tracks",   100, -10., 10.);
01328     h_dzPVFromTracks_[1] =  dbe_->book1D(histname+"Barrel"," Photons: PV Z_rec - Z_true from conversion tracks",100, -10., 10.);
01329     h_dzPVFromTracks_[2] =  dbe_->book1D(histname+"Endcap"," Photons: PV Z_rec - Z_true from conversion tracks",100, -10., 10.);
01330     h_dzPVFromTracks_[3] =  dbe_->book1D(histname+"EndcapP"," Photons: PV Z_rec - Z_true from conversion tracks",100, -10., 10.);
01331     h_dzPVFromTracks_[4] =  dbe_->book1D(histname+"EndcapM"," Photons: PV Z_rec - Z_true from conversion tracks",100, -10., 10.);
01332     p_dzPVVsR_ =  dbe_->bookProfile("pdzPVVsR","Photon Reco conversions: dz(PV) vs R" ,rBin,rMin, rMax, 100, -3.,3.,"");
01333     p_dzPVVsEta_ =  dbe_->bookProfile("pdzPVVsEta","Photon Reco conversions: dz(PV) vs Eta" ,etaBin,etaMin, etaMax, 100, -3.,3.,"");
01334 
01335     if ( ! isRunCentrally_ ) {
01336       h2_dzPVVsR_ =  dbe_->book2D("h2dzPVVsR","Photon Reco conversions: dz(PV) vs R" ,rBin,rMin, rMax,100, -3.,3.);
01337     }
01338 
01340     if ( ! isRunCentrally_ ) {
01341       histname="nHitsVsEta";
01342       nHitsVsEta_[0] =  dbe_->book2D(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs #eta all tracks",etaBin,etaMin, etaMax,25,0., 25.);
01343 
01344       histname="nHitsVsEta";
01345       nHitsVsEta_[1] =  dbe_->book2D(histname+"AssTracks","Photons:Tracks from conversions: # of hits vs #eta associated tracks",etaBin,etaMin, etaMax,25,0., 25.);
01346 
01347       histname="nHitsVsR";
01348       nHitsVsR_[0] =  dbe_->book2D(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs radius all tracks" ,rBin,rMin, rMax,25,0.,25);
01349 
01350       histname="nHitsVsR";
01351       nHitsVsR_[1] =  dbe_->book2D(histname+"AssTracks","Photons:Tracks from conversions: # of hits vs radius associated tracks" ,rBin,rMin, rMax,25,0.,25);
01352 
01353       histname="h2Chi2VsEta";
01354       h2_Chi2VsEta_[0]=dbe_->book2D(histname+"All"," Reco Track  #chi^{2} vs #eta: All ",etaBin2,etaMin, etaMax,100, chi2Min, chi2Max);
01355 
01356 
01357       histname="h2Chi2VsR";
01358       h2_Chi2VsR_[0]=dbe_->book2D(histname+"All"," Reco Track  #chi^{2} vs R: All ",rBin,rMin, rMax,100,chi2Min, chi2Max);
01359     }
01360 
01361     histname="h_nHitsVsEta";
01362     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,"");
01363 
01364     histname="h_nHitsVsEta";
01365     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,"");
01366 
01367 
01368     histname="h_nHitsVsR";
01369     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,"");
01370     histname="tkChi2";
01371     h_tkChi2_[0] = dbe_->book1D(histname+"AllTracks","Photons:Tracks from conversions: #chi^{2} of all tracks", 100, chi2Min, chi2Max);
01372     histname="tkChi2Large";
01373     h_tkChi2Large_[0] = dbe_->book1D(histname+"AllTracks","Photons:Tracks from conversions: #chi^{2} of all tracks", 1000, 0., 5000.0);
01374 
01375     histname="h_nHitsVsR";
01376     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,"");
01377 
01378     histname="tkChi2";
01379     h_tkChi2_[1] = dbe_->book1D(histname+"AssTracks","Photons:Tracks from conversions: #chi^{2} of associated  tracks", 100, chi2Min, chi2Max);
01380     histname="tkChi2Large";
01381     h_tkChi2Large_[1] = dbe_->book1D(histname+"AssTracks","Photons:Tracks from conversions: #chi^{2} of associated  tracks", 1000, 0., 5000.0);
01382 
01383     histname="pChi2VsEta";
01384     p_Chi2VsEta_[0]=dbe_->bookProfile(histname+"All"," Reco Track #chi^{2} vs #eta : All ",etaBin2,etaMin, etaMax, 100, chi2Min, chi2Max,"");
01385 
01386     histname="pChi2VsR";
01387     p_Chi2VsR_[0]=dbe_->bookProfile(histname+"All"," Reco Track #chi^{2} vas R : All ",rBin,rMin,rMax, 100,chi2Min, chi2Max,"");
01388 
01389 
01390     histname="hTkD0";
01391     h_TkD0_[0]=dbe_->book1D(histname+"All"," Reco Track D0*q: All ",100,-0.1,0.6);
01392     h_TkD0_[1]=dbe_->book1D(histname+"Barrel"," Reco Track D0*q: Barrel ",100,-0.1,0.6);
01393     h_TkD0_[2]=dbe_->book1D(histname+"Endcap"," Reco Track D0*q: Endcap ",100,-0.1,0.6);
01394 
01395 
01396     histname="hTkPtPull";
01397     h_TkPtPull_[0]=dbe_->book1D(histname+"All"," Reco Track Pt pull: All ",100, -10., 10.);
01398     histname="hTkPtPull";
01399     h_TkPtPull_[1]=dbe_->book1D(histname+"Barrel"," Reco Track Pt pull: Barrel ",100, -10., 10.);
01400     histname="hTkPtPull";
01401     h_TkPtPull_[2]=dbe_->book1D(histname+"Endcap"," Reco Track Pt pull: Endcap ",100, -10., 10.);
01402 
01403     histname="pTkPtPullEta";
01404     p_TkPtPull_[0]=dbe_->bookProfile(histname+"All"," Reco Track Pt pull: All ",etaBin2,etaMin, etaMax, 100, -10., 10., " ");
01405 
01406     if ( ! isRunCentrally_ ) {
01407       histname="h2TkPtPullEta";
01408       h2_TkPtPull_[0]=dbe_->book2D(histname+"All"," Reco Track Pt pull: All ",etaBin2,etaMin, etaMax,100, -10., 10.);
01409 
01410       histname="PtRecVsPtSim";
01411       h2_PtRecVsPtSim_[0]=dbe_->book2D(histname+"All", "Pt Rec vs Pt sim: All ", etBin,etMin,etMax,etBin,etMin, etMax);
01412       h2_PtRecVsPtSim_[1]=dbe_->book2D(histname+"Barrel", "Pt Rec vs Pt sim: Barrel ", etBin,etMin,etMax,etBin,etMin, etMax);
01413       h2_PtRecVsPtSim_[2]=dbe_->book2D(histname+"Endcap", "Pt Rec vs Pt sim: Endcap ", etBin,etMin,etMax,etBin,etMin, etMax);
01414       histname="PtRecVsPtSimMixProv";
01415       h2_PtRecVsPtSimMixProv_ =dbe_->book2D(histname+"All", "Pt Rec vs Pt sim All for mix with general tracks ", etBin,etMin,etMax,etBin,etMin, etMax);
01416     }
01417 
01418     if ( fName_ != "pfPhotonValidator" &&  fName_ != "oldpfPhotonValidator" ) {
01419       histname="eBcOverTkPout";
01420       hBCEnergyOverTrackPout_[0] = dbe_->book1D(histname+"All","Matrching BC E/P_out: all Ecal ",100, 0., 5.);
01421       hBCEnergyOverTrackPout_[1] = dbe_->book1D(histname+"Barrel","Matrching BC E/P_out: Barrel ",100, 0., 5.);
01422       hBCEnergyOverTrackPout_[2] = dbe_->book1D(histname+"Endcap","Matrching BC E/P_out: Endcap ",100, 0., 5.);
01423     }
01424 
01426     h_OIinnermostHitR_ = dbe_->book1D("OIinnermostHitR"," R innermost hit for OI tracks ",50, 0., 25);
01427     h_IOinnermostHitR_ = dbe_->book1D("IOinnermostHitR"," R innermost hit for IO tracks ",50, 0., 25);
01428 
01430     h_trkProv_[0] = dbe_->book1D("allTrkProv"," Track pair provenance ",4, 0., 4.);
01431     h_trkProv_[1] = dbe_->book1D("assTrkProv"," Track pair provenance ",4, 0., 4.);
01432 
01433     // histos for fake rate
01434     histname = "h_RecoConvTwoTracksEta";
01435     h_RecoConvTwoTracks_[0] =  dbe_->book1D(histname," All reco conversions with 2 reco  tracks: simulated #eta",etaBin2,etaMin, etaMax);
01436     histname = "h_RecoConvTwoTracksPhi";
01437     h_RecoConvTwoTracks_[1] =  dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated #phi",phiBin,phiMin, phiMax);
01438     histname = "h_RecoConvTwoTracksR";
01439     h_RecoConvTwoTracks_[2] =  dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated R",rBin,rMin, rMax);
01440     histname = "h_RecoConvTwoTracksZ";
01441     h_RecoConvTwoTracks_[3] =  dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated Z",zBin,zMin, zMax);
01442     histname = "h_RecoConvTwoTracksEt";
01443     h_RecoConvTwoTracks_[4] =  dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated Et",etBin,etMin, etMax);
01444     //
01445     histname = "h_RecoConvTwoMTracksEta";
01446     h_RecoConvTwoMTracks_[0] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated #eta",etaBin2,etaMin, etaMax);
01447     histname = "h_RecoConvTwoMTracksPhi";
01448     h_RecoConvTwoMTracks_[1] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated #phi",phiBin,phiMin, phiMax);
01449     histname = "h_RecoConvTwoMTracksR";
01450     h_RecoConvTwoMTracks_[2] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated R",rBin,rMin, rMax);
01451     histname = "h_RecoConvTwoMTracksZ";
01452     h_RecoConvTwoMTracks_[3] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated Z",zBin,zMin, zMax);
01453     histname = "h_RecoConvTwoMTracksEt";
01454     h_RecoConvTwoMTracks_[4] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated Et",etBin,etMin, etMax);
01455 
01456 
01457 
01458 
01459   } // if DQM
01460 
01461 
01462 
01463 }
01464 
01465 
01466 
01467  void  PhotonValidator::beginRun (edm::Run const & r, edm::EventSetup const & theEventSetup) {
01468 
01469    //get magnetic field
01470   edm::LogInfo("ConvertedPhotonProducer") << " get magnetic field" << "\n";
01471   theEventSetup.get<IdealMagneticFieldRecord>().get(theMF_);
01472 
01473 
01474   edm::ESHandle<TrackAssociatorBase> theHitsAssociator;
01475   theEventSetup.get<TrackAssociatorRecord>().get("trackAssociatorByHitsForPhotonValidation",theHitsAssociator);
01476   theTrackAssociator_ = (TrackAssociatorBase *) theHitsAssociator.product();
01477 
01478   thePhotonMCTruthFinder_ = new PhotonMCTruthFinder();
01479 
01480 }
01481 
01482 void  PhotonValidator::endRun (edm::Run& r, edm::EventSetup const & theEventSetup) {
01483 
01484   delete thePhotonMCTruthFinder_;
01485 
01486 }
01487 
01488 
01489 
01490 void PhotonValidator::analyze( const edm::Event& e, const edm::EventSetup& esup ) {
01491 
01492 
01493   using namespace edm;
01494   //  const float etaPhiDistance=0.01;
01495   // Fiducial region
01496   // const float TRK_BARL =0.9;
01497   const float BARL = 1.4442; // DAQ TDR p.290
01498   //  const float END_LO = 1.566; // unused
01499   const float END_HI = 2.5;
01500   // Electron mass
01501   //const Float_t mElec= 0.000511;
01502 
01503 
01504   nEvt_++;
01505   LogInfo("PhotonValidator") << "PhotonValidator Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n";
01506   //  std::cout << "PhotonValidator Analyzing event number: "  << e.id() << " Global Counter " << nEvt_ <<"\n";
01507 
01508 
01509   // get the geometry from the event setup:
01510   esup.get<CaloGeometryRecord>().get(theCaloGeom_);
01511 
01512   edm::Handle<reco::VertexCollection> vtxH;
01513   e.getByLabel("offlinePrimaryVertices", vtxH);
01514   h_nRecoVtx_ ->Fill (float(vtxH->size()));
01515 
01516   // Transform Track into TransientTrack (needed by the Vertex fitter)
01517   edm::ESHandle<TransientTrackBuilder> theTTB;
01518   esup.get<TransientTrackRecord>().get("TransientTrackBuilder",theTTB);
01519 
01520 
01522   Handle<reco::PhotonCollection> photonHandle;
01523   e.getByLabel(photonCollectionProducer_, photonCollection_ , photonHandle);
01524   const reco::PhotonCollection photonCollection = *(photonHandle.product());
01525   if (!photonHandle.isValid()) {
01526     edm::LogError("PhotonProducer") << "Error! Can't get the Photon collection "<< std::endl;
01527     return;
01528   }
01529 
01530   Handle< edm::View<reco::Track> > outInTrkHandle;
01531   Handle< edm::View<reco::Track> > inOutTrkHandle;
01532   if ( !fastSim_) {
01534     e.getByLabel(conversionOITrackProducer_,  outInTrkHandle);
01535     //std::cout << "ConvPhoAnalyzerWithOfficialAssociation  outInTrack collection size " << (*outInTrkHandle).size() << "\n";
01536 
01538     e.getByLabel(conversionIOTrackProducer_, inOutTrkHandle);
01539     //std::cout  << " ConvPhoAnalyzerWithOfficialAssociation inOutTrack collection size " << (*inOutTrkHandle).size() << "\n";
01540 
01541     // Loop over Out In Tracks
01542     int iTrk=0;
01543     int nHits=0;
01544     for( View<reco::Track>::const_iterator    iTk =  (*outInTrkHandle).begin(); iTk !=  (*outInTrkHandle).end(); iTk++) {
01545       //    std::cout  << " Barrel  Out In Track charge " << iTk->charge() << " Num of RecHits " << iTk->recHitsSize() << " inner momentum " << sqrt( iTk->innerMomentum().Mag2() ) << "\n";
01546       // std::cout  << " Barrel Out In Track Extra inner momentum  " << sqrt(iTk->extra()->innerMomentum().Mag2()) <<  " inner position R " <<  sqrt( iTk->innerPosition().Perp2() ) << "\n";
01547       h_OIinnermostHitR_ ->Fill ( sqrt( iTk->innerPosition().Perp2() ) );
01548       for (  trackingRecHit_iterator itHits=iTk->extra()->recHitsBegin();  itHits!=iTk->extra()->recHitsEnd(); ++itHits ) {
01549         if ( (*itHits)->isValid() ) {
01550           nHits++;
01551           //    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";
01552         }
01553 
01554 
01555       }
01556 
01557       iTrk++;
01558 
01559 
01560     }
01561 
01562     // Loop over In Out Tracks Barrel
01563     iTrk=0;
01564     for( View<reco::Track>::const_iterator    iTk =  (*inOutTrkHandle).begin(); iTk !=  (*inOutTrkHandle).end(); iTk++) {
01565       //std::cout  << " Barrel In Out Track charge " << iTk->charge() << " Num of RecHits " << iTk->recHitsSize() << " inner momentum " << sqrt( iTk->innerMomentum().Mag2())  << "\n";
01566       // std::cout   << " Barrel In Out  Track Extra inner momentum  " << sqrt(iTk->extra()->innerMomentum().Mag2()) << "\n";
01567       h_IOinnermostHitR_ ->Fill ( sqrt( iTk->innerPosition().Perp2() ) );
01568       nHits=0;
01569       for (  trackingRecHit_iterator itHits=iTk->extra()->recHitsBegin();  itHits!=iTk->extra()->recHitsEnd(); ++itHits ) {
01570         if ( (*itHits)->isValid() ) {
01571           nHits++;
01572           //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";
01573 
01574         }
01575       }
01576 
01577 
01578 
01579       iTrk++;
01580     }
01581 
01582   }  // if !fastSim
01583 
01584 
01586   //get simtrack info
01587   std::vector<SimTrack> theSimTracks;
01588   std::vector<SimVertex> theSimVertices;
01589   edm::Handle<SimTrackContainer> SimTk;
01590   edm::Handle<SimVertexContainer> SimVtx;
01591 
01592   if ( ! fastSim_) {
01593     e.getByLabel("g4SimHits",SimTk);
01594     e.getByLabel("g4SimHits",SimVtx);
01595   } else {
01596     e.getByLabel("famosSimHits",SimTk);
01597     e.getByLabel("famosSimHits",SimVtx);
01598 
01599   }
01600 
01601 
01602 
01603   theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
01604   theSimVertices.insert(theSimVertices.end(),SimVtx->begin(),SimVtx->end());
01605   std::vector<PhotonMCTruth> mcPhotons=thePhotonMCTruthFinder_->find (theSimTracks,  theSimVertices);
01606 
01607   edm::Handle<edm::HepMCProduct> hepMC;
01608   e.getByLabel("generator",hepMC);
01609   const HepMC::GenEvent *myGenEvent = hepMC->GetEvent();
01610 
01611 
01612   // get generated jets
01613   Handle<reco::GenJetCollection> GenJetsHandle ;
01614   e.getByLabel("iterativeCone5GenJets","",GenJetsHandle);
01615   reco::GenJetCollection genJetCollection = *(GenJetsHandle.product());
01616 
01617 
01618 
01619   // Get electron tracking truth
01620   bool useTP= parameters_.getParameter<bool>("useTP");
01621   TrackingParticleCollection trackingParticles;
01622   edm::Handle<TrackingParticleCollection> ElectronTPHandle;
01623   if ( useTP) {
01624     if ( ! fastSim_) {
01625     e.getByLabel(label_tp_,ElectronTPHandle);
01626     //  e.getByLabel("mergedtruth","MergedTrackTruth",ElectronTPHandle);
01627     trackingParticles = *(ElectronTPHandle.product());
01628     }
01629   }
01630 
01632   std::vector<reco::PhotonCollection::const_iterator> StoRMatchedConvertedPhotons;
01633   reco::SimToRecoCollection OISimToReco;
01634   reco::SimToRecoCollection IOSimToReco;
01635   // Reco to Sim
01636   reco::RecoToSimCollection OIRecoToSim;
01637   reco::RecoToSimCollection IORecoToSim;
01638 
01639   if ( useTP) {
01640     if ( ! fastSim_) {
01641     // Sim to Reco
01642       OISimToReco = theTrackAssociator_->associateSimToReco(outInTrkHandle, ElectronTPHandle, &e, &esup);
01643       IOSimToReco = theTrackAssociator_->associateSimToReco(inOutTrkHandle, ElectronTPHandle, &e, &esup);
01644     // Reco to Sim
01645       OIRecoToSim = theTrackAssociator_->associateRecoToSim(outInTrkHandle, ElectronTPHandle, &e, &esup);
01646       IORecoToSim = theTrackAssociator_->associateRecoToSim(inOutTrkHandle, ElectronTPHandle, &e, &esup);
01647     }
01648   }
01649   //
01650   vector<reco::SimToRecoCollection*> StoRCollPtrs;
01651   StoRCollPtrs.push_back(&OISimToReco);
01652   StoRCollPtrs.push_back(&IOSimToReco);
01653   vector<reco::RecoToSimCollection*> RtoSCollPtrs;
01654   RtoSCollPtrs.push_back(&OIRecoToSim);
01655   RtoSCollPtrs.push_back(&IORecoToSim);
01656   //
01657   for (int i=0; i<2; i++)
01658     nSimPho_[i]=0;
01659   for (int i=0; i<2; i++)
01660     nSimConv_[i]=0;
01661 
01662 
01663   std::vector<reco::Photon> myPhotons;
01664   for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
01665     if ( fabs(iPho->eta()) > 2.5 ) continue;
01666     myPhotons.push_back(*iPho);
01667   }
01668 
01669   std::sort(myPhotons.begin(), myPhotons.end(), sortPhotons());
01670   // if ( ! isRunCentrally_ ) { 
01671     if ( myPhotons.size() >=2 ) {
01672       if ( myPhotons[0].et() > 40 && myPhotons[1].et() > 25 ) {
01673         
01674         math::XYZTLorentzVector p12 = myPhotons[0].p4()+myPhotons[1].p4();
01675         math::XYZTLorentzVector p12_regr1 = myPhotons[0].p4(reco::Photon::regression1)+myPhotons[1].p4(reco::Photon::regression1);
01676         math::XYZTLorentzVector p12_regr2 = myPhotons[0].p4(reco::Photon::regression2)+myPhotons[1].p4(reco::Photon::regression2);
01677         float gamgamMass2 = p12.Dot(p12);
01678         float gamgamMass2_regr1 = p12_regr1.Dot(p12_regr1);
01679         float gamgamMass2_regr2 = p12_regr2.Dot(p12_regr2);
01680 
01682         if (  gamgamMass2 > 0 ) {
01683           // total
01684           h_gamgamMass_[0][0] -> Fill(sqrt( gamgamMass2 ));
01685           if (  myPhotons[0].isEB() &&   myPhotons[1].isEB() )
01686             h_gamgamMass_[0][1] -> Fill(sqrt( gamgamMass2 ));
01687           if ( (  myPhotons[0].isEE() &&         myPhotons[1].isEE() )  ||
01688                (  myPhotons[0].isEE() &&         myPhotons[1].isEB() ) ||
01689                (  myPhotons[0].isEB() &&         myPhotons[1].isEE() ) )
01690             h_gamgamMass_[0][2] -> Fill(sqrt( gamgamMass2 ));
01691           // Golden photons
01692           if (  myPhotons[0].r9() > 0.94 &&  myPhotons[1].r9() > 0.94 ) {
01693             h_gamgamMass_[1][0] -> Fill(sqrt( gamgamMass2 ));
01694             if (  myPhotons[0].isEB() &&         myPhotons[1].isEB() )
01695               h_gamgamMass_[1][1] -> Fill(sqrt( gamgamMass2 ));
01696             if ( (  myPhotons[0].isEE() &&       myPhotons[1].isEE() )  ||
01697                  (  myPhotons[0].isEE() &&       myPhotons[1].isEB() ) ||
01698                  (  myPhotons[0].isEB() &&       myPhotons[1].isEE() ) )
01699               h_gamgamMass_[1][2] -> Fill(sqrt( gamgamMass2 ));
01700           }
01701           // both photons converted
01702           if ( myPhotons[0].conversions().size() > 0 && myPhotons[1].conversions().size() >0 ) {
01703             if ( myPhotons[0].conversions()[0]->nTracks() ==2 &&  myPhotons[1].conversions()[0]->nTracks() ==2  ) {
01704               float chi2Prob1 = ChiSquaredProbability( myPhotons[0].conversions()[0]->conversionVertex().chi2(),  myPhotons[0].conversions()[0]->conversionVertex().ndof() );
01705               float chi2Prob2 = ChiSquaredProbability( myPhotons[1].conversions()[0]->conversionVertex().chi2(),  myPhotons[1].conversions()[0]->conversionVertex().ndof() );
01706               if ( chi2Prob1 > 0.0005 &&  chi2Prob2 > 0.0005 ) {
01707                 h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
01708                 if (  myPhotons[0].isEB() &&     myPhotons[1].isEB() ) {
01709                   h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
01710                 }
01711                 if ( (  myPhotons[0].isEE() &&   myPhotons[1].isEE() )  ||
01712                      (  myPhotons[0].isEE() &&   myPhotons[1].isEB() ) ||
01713                      (  myPhotons[0].isEB() &&   myPhotons[1].isEE() ) )
01714                   h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 )); {
01715                 }
01716               }
01717             }
01718           } else if ( myPhotons[0].conversions().size() > 0 && myPhotons[1].conversions().size() ==0 && myPhotons[1].r9() > 0.93  )  {  // one photon converted
01719             if ( myPhotons[0].conversions()[0]->nTracks() ==2 ) {
01720               float chi2Prob1 = ChiSquaredProbability( myPhotons[0].conversions()[0]->conversionVertex().chi2(),  myPhotons[0].conversions()[0]->conversionVertex().ndof() );
01721               if ( chi2Prob1 > 0.0005 ) {
01722                 h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
01723                 if (  myPhotons[0].isEB() &&  myPhotons[1].isEB() ) {
01724                   h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
01725                 }
01726                 if (  myPhotons[0].isEE() ||  myPhotons[1].isEE() ) {
01727                   h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 ));
01728                 }
01729               }
01730             }
01731           } else if ( myPhotons[1].conversions().size() > 0 && myPhotons[0].conversions().size() ==0 &&  myPhotons[0].r9() > 0.93 )  {  // one photon converted
01732             if ( myPhotons[1].conversions()[0]->nTracks() ==2 ) {
01733               float chi2Prob1 = ChiSquaredProbability( myPhotons[1].conversions()[0]->conversionVertex().chi2(),  myPhotons[1].conversions()[0]->conversionVertex().ndof() );
01734               if ( chi2Prob1 > 0.0005 ) {
01735                 h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
01736                 if (  myPhotons[0].isEB() && myPhotons[1].isEB() ) {
01737                   h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
01738                 }
01739                 if (  myPhotons[0].isEE() ||  myPhotons[1].isEE() ) {
01740                   h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 ));
01741                 }
01742               }
01743             }
01744           }
01745         } // gamgamMass2 > 0
01746 
01748         if (  gamgamMass2_regr1 > 0 ) {
01749           // total
01750           h_gamgamMassRegr1_[0][0] -> Fill(sqrt( gamgamMass2_regr1 ));
01751           if (  myPhotons[0].isEB() &&   myPhotons[1].isEB() )
01752             h_gamgamMassRegr1_[0][1] -> Fill(sqrt( gamgamMass2_regr1 ));
01753           if ( (  myPhotons[0].isEE() &&         myPhotons[1].isEE() )  ||
01754                (  myPhotons[0].isEE() &&         myPhotons[1].isEB() ) ||
01755                (  myPhotons[0].isEB() &&         myPhotons[1].isEE() ) )
01756             h_gamgamMassRegr1_[0][2] -> Fill(sqrt( gamgamMass2_regr1 ));
01757           // Golden photons
01758           if (  myPhotons[0].r9() > 0.94 &&  myPhotons[1].r9() > 0.94 ) {
01759             h_gamgamMassRegr1_[1][0] -> Fill(sqrt( gamgamMass2_regr1 ));
01760             if (  myPhotons[0].isEB() &&         myPhotons[1].isEB() )
01761               h_gamgamMassRegr1_[1][1] -> Fill(sqrt( gamgamMass2_regr1 ));
01762             if ( (  myPhotons[0].isEE() &&       myPhotons[1].isEE() )  ||
01763                  (  myPhotons[0].isEE() &&       myPhotons[1].isEB() ) ||
01764                  (  myPhotons[0].isEB() &&       myPhotons[1].isEE() ) )
01765               h_gamgamMassRegr1_[1][2] -> Fill(sqrt( gamgamMass2_regr1 ));
01766           }
01767           
01768           
01769           // both photons converted
01770           if ( myPhotons[0].conversions().size() > 0 && myPhotons[1].conversions().size() >0 ) {
01771             if ( myPhotons[0].conversions()[0]->nTracks() ==2 &&  myPhotons[1].conversions()[0]->nTracks() ==2  ) {
01772               float chi2Prob1 = ChiSquaredProbability( myPhotons[0].conversions()[0]->conversionVertex().chi2(),  myPhotons[0].conversions()[0]->conversionVertex().ndof() );
01773               float chi2Prob2 = ChiSquaredProbability( myPhotons[1].conversions()[0]->conversionVertex().chi2(),  myPhotons[1].conversions()[0]->conversionVertex().ndof() );
01774               if ( chi2Prob1 > 0.0005 &&  chi2Prob2 > 0.0005 ) {
01775                 h_gamgamMassRegr1_[2][0] -> Fill(sqrt( gamgamMass2_regr1 ));
01776                 if (  myPhotons[0].isEB() &&     myPhotons[1].isEB() ) {
01777                   h_gamgamMassRegr1_[2][1] -> Fill(sqrt( gamgamMass2_regr1 ));
01778                 }
01779                 if ( (  myPhotons[0].isEE() &&   myPhotons[1].isEE() )  ||
01780                      (  myPhotons[0].isEE() &&   myPhotons[1].isEB() ) ||
01781                      (  myPhotons[0].isEB() &&   myPhotons[1].isEE() ) )
01782                   h_gamgamMassRegr1_[2][2] -> Fill(sqrt( gamgamMass2_regr1 )); {
01783                 }
01784               }
01785             }
01786           } else if ( myPhotons[0].conversions().size() > 0 && myPhotons[1].conversions().size() ==0 && myPhotons[1].r9() > 0.93  )  {  // one photon converted
01787             if ( myPhotons[0].conversions()[0]->nTracks() ==2 ) {
01788               float chi2Prob1 = ChiSquaredProbability( myPhotons[0].conversions()[0]->conversionVertex().chi2(),  myPhotons[0].conversions()[0]->conversionVertex().ndof() );
01789               if ( chi2Prob1 > 0.0005 ) {
01790                 h_gamgamMassRegr1_[2][0] -> Fill(sqrt( gamgamMass2_regr1 ));
01791                 if (  myPhotons[0].isEB() &&  myPhotons[1].isEB() ) {
01792                   h_gamgamMassRegr1_[2][1] -> Fill(sqrt( gamgamMass2_regr1 ));
01793                 }
01794                 if (  myPhotons[0].isEE() ||  myPhotons[1].isEE() ) {
01795                   h_gamgamMassRegr1_[2][2] -> Fill(sqrt( gamgamMass2_regr1 ));
01796                 }
01797               }
01798             }
01799           } else if ( myPhotons[1].conversions().size() > 0 && myPhotons[0].conversions().size() ==0 &&  myPhotons[0].r9() > 0.93 )  {  // one photon converted
01800             if ( myPhotons[1].conversions()[0]->nTracks() ==2 ) {
01801               float chi2Prob1 = ChiSquaredProbability( myPhotons[1].conversions()[0]->conversionVertex().chi2(),  myPhotons[1].conversions()[0]->conversionVertex().ndof() );
01802               if ( chi2Prob1 > 0.0005 ) {
01803                 h_gamgamMassRegr1_[2][0] -> Fill(sqrt( gamgamMass2_regr1 ));
01804                 if (  myPhotons[0].isEB() && myPhotons[1].isEB() ) {
01805                   h_gamgamMassRegr1_[2][1] -> Fill(sqrt( gamgamMass2_regr1 ));
01806                 }
01807                 if (  myPhotons[0].isEE() ||  myPhotons[1].isEE() ) {
01808                   h_gamgamMassRegr1_[2][2] -> Fill(sqrt( gamgamMass2_regr1 ));
01809                 }
01810               }
01811             }
01812           }
01813         } // gamgamMass2_regr1 > 0
01814 
01815 
01817         if (  gamgamMass2_regr2 > 0 ) {
01818           // total
01819           h_gamgamMassRegr2_[0][0] -> Fill(sqrt( gamgamMass2_regr2 ));
01820           if (  myPhotons[0].isEB() &&   myPhotons[1].isEB() )
01821             h_gamgamMassRegr2_[0][1] -> Fill(sqrt( gamgamMass2_regr2 ));
01822           if ( (  myPhotons[0].isEE() &&         myPhotons[1].isEE() )  ||
01823                (  myPhotons[0].isEE() &&         myPhotons[1].isEB() ) ||
01824                (  myPhotons[0].isEB() &&         myPhotons[1].isEE() ) )
01825             h_gamgamMassRegr2_[0][2] -> Fill(sqrt( gamgamMass2_regr2 ));
01826           // Golden photons
01827           if (  myPhotons[0].r9() > 0.94 &&  myPhotons[1].r9() > 0.94 ) {
01828             h_gamgamMassRegr2_[1][0] -> Fill(sqrt( gamgamMass2_regr2 ));
01829             if (  myPhotons[0].isEB() &&         myPhotons[1].isEB() )
01830               h_gamgamMassRegr2_[1][1] -> Fill(sqrt( gamgamMass2_regr2 ));
01831             if ( (  myPhotons[0].isEE() &&       myPhotons[1].isEE() )  ||
01832                  (  myPhotons[0].isEE() &&       myPhotons[1].isEB() ) ||
01833                  (  myPhotons[0].isEB() &&       myPhotons[1].isEE() ) )
01834               h_gamgamMassRegr2_[1][2] -> Fill(sqrt( gamgamMass2_regr2 ));
01835           }
01836           
01837           
01838           // both photons converted
01839           if ( myPhotons[0].conversions().size() > 0 && myPhotons[1].conversions().size() >0 ) {
01840             if ( myPhotons[0].conversions()[0]->nTracks() ==2 &&  myPhotons[1].conversions()[0]->nTracks() ==2  ) {
01841               float chi2Prob1 = ChiSquaredProbability( myPhotons[0].conversions()[0]->conversionVertex().chi2(),  myPhotons[0].conversions()[0]->conversionVertex().ndof() );
01842               float chi2Prob2 = ChiSquaredProbability( myPhotons[1].conversions()[0]->conversionVertex().chi2(),  myPhotons[1].conversions()[0]->conversionVertex().ndof() );
01843               if ( chi2Prob1 > 0.0005 &&  chi2Prob2 > 0.0005 ) {
01844                 h_gamgamMassRegr2_[2][0] -> Fill(sqrt( gamgamMass2_regr2 ));
01845                 if (  myPhotons[0].isEB() &&     myPhotons[1].isEB() ) {
01846                   h_gamgamMassRegr2_[2][1] -> Fill(sqrt( gamgamMass2_regr2 ));
01847                 }
01848                 if ( (  myPhotons[0].isEE() &&   myPhotons[1].isEE() )  ||
01849                      (  myPhotons[0].isEE() &&   myPhotons[1].isEB() ) ||
01850                      (  myPhotons[0].isEB() &&   myPhotons[1].isEE() ) )
01851                   h_gamgamMassRegr2_[2][2] -> Fill(sqrt( gamgamMass2_regr2 )); {
01852                 }
01853               }
01854             }
01855           } else if ( myPhotons[0].conversions().size() > 0 && myPhotons[1].conversions().size() ==0 && myPhotons[1].r9() > 0.93  )  {  // one photon converted
01856             if ( myPhotons[0].conversions()[0]->nTracks() ==2 ) {
01857               float chi2Prob1 = ChiSquaredProbability( myPhotons[0].conversions()[0]->conversionVertex().chi2(),  myPhotons[0].conversions()[0]->conversionVertex().ndof() );
01858               if ( chi2Prob1 > 0.0005 ) {
01859                 h_gamgamMassRegr2_[2][0] -> Fill(sqrt( gamgamMass2_regr2 ));
01860                 if (  myPhotons[0].isEB() &&  myPhotons[1].isEB() ) {
01861                   h_gamgamMassRegr2_[2][1] -> Fill(sqrt( gamgamMass2_regr2 ));
01862                 }
01863                 if (  myPhotons[0].isEE() ||  myPhotons[1].isEE() ) {
01864                   h_gamgamMassRegr2_[2][2] -> Fill(sqrt( gamgamMass2_regr2 ));
01865                 }
01866               }
01867             }
01868           } else if ( myPhotons[1].conversions().size() > 0 && myPhotons[0].conversions().size() ==0 &&  myPhotons[0].r9() > 0.93 )  {  // one photon converted
01869             if ( myPhotons[1].conversions()[0]->nTracks() ==2 ) {
01870               float chi2Prob1 = ChiSquaredProbability( myPhotons[1].conversions()[0]->conversionVertex().chi2(),  myPhotons[1].conversions()[0]->conversionVertex().ndof() );
01871               if ( chi2Prob1 > 0.0005 ) {
01872                 h_gamgamMassRegr2_[2][0] -> Fill(sqrt( gamgamMass2_regr2 ));
01873                 if (  myPhotons[0].isEB() && myPhotons[1].isEB() ) {
01874                   h_gamgamMassRegr2_[2][1] -> Fill(sqrt( gamgamMass2_regr2 ));
01875                 }
01876                 if (  myPhotons[0].isEE() ||  myPhotons[1].isEE() ) {
01877                   h_gamgamMassRegr2_[2][2] -> Fill(sqrt( gamgamMass2_regr2 ));
01878                 }
01879               }
01880             }
01881           }
01882         } // gamgamMass2_regr2 > 0
01883 
01884 
01885 
01886 
01887 
01888 
01889 
01890 
01891 
01892 
01893 
01894 
01895       }
01896     }
01897     // }
01898 
01899 
01900   //  cout << " PhotonValidator mcPhotons.size() " << mcPhotons.size() << endl;
01901   for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
01902     if ( (*mcPho).fourMomentum().et() < minPhoEtCut_ ) continue;
01903 
01904     for ( HepMC::GenEvent::particle_const_iterator mcIter=myGenEvent->particles_begin(); mcIter != myGenEvent->particles_end(); mcIter++ ) {
01905       if ( (*mcIter)->pdg_id() != 22 ) continue;
01906       bool isTheSame= false;
01907       HepMC::GenParticle* mother = 0;
01908       if ( (*mcIter)->production_vertex() )  {
01909         if ( (*mcIter)->production_vertex()->particles_begin(HepMC::parents) !=
01910              (*mcIter)->production_vertex()->particles_end(HepMC::parents))
01911           mother = *((*mcIter)->production_vertex()->particles_begin(HepMC::parents));
01912       }
01913 
01914 
01915 
01916 
01917       float mcPhi= (*mcPho).fourMomentum().phi();
01918       mcPhi_= phiNormalization(mcPhi);
01919       mcEta_= (*mcPho).fourMomentum().pseudoRapidity();
01920       mcEta_ = etaTransformation(mcEta_, (*mcPho).primaryVertex().z() );
01921       mcConvR_= (*mcPho).vertex().perp();
01922       mcConvX_= (*mcPho).vertex().x();
01923       mcConvY_= (*mcPho).vertex().y();
01924       mcConvZ_= (*mcPho).vertex().z();
01925       mcConvEta_= (*mcPho).vertex().eta();
01926       mcConvPhi_= (*mcPho).vertex().phi();
01927 
01928       if ( fabs(mcEta_) > END_HI ) continue;
01929 
01930 
01931 
01932       if (  mother ==0
01933             ||  (mother != 0  && mother->pdg_id() == 22)
01934             ||  (mother != 0  && mother->pdg_id() == 25)
01935             ||  (mother != 0  && mother->pdg_id() == 35) )
01936         {
01937           //std::cout << " ZERO mother or Higgs or primary photon  " << std::endl;
01938           //if (mother !=0) std::cout <<  mother->pdg_id() << std::endl;
01939           double dPt =  fabs((*mcIter)->momentum().perp() - (*mcPho).fourMomentum().et());
01940           float phiMother=(*mcIter)->momentum().phi();
01941           double dPhi = phiNormalization(phiMother) - mcPhi_ ;
01942           double dEta = fabs( (*mcIter)->momentum().eta() - (*mcPho).fourMomentum().pseudoRapidity() );
01943 
01944           //std::cout << " HEP photon pt " << (*mcIter)->momentum().perp() << " eta " << (*mcIter)->momentum().eta() << " phi " << (*mcIter)->momentum().phi() << std::endl;
01945           //std::cout << "   (*mcPho).motherType() selection  " <<   (*mcPho).motherType() << " pt " <<  (*mcPho).fourMomentum().et()  << " eta " << (*mcPho).fourMomentum().pseudoRapidity() << " phi " << mcPhi_ << std::endl;
01946           //std::cout << " dPt " << dPt << " dEta " << dEta << " dPhi " << dPhi << std::endl;
01947           if ( dEta <=0.0001 && dPhi <=0.0001 && dPt <=0.0001)
01948             isTheSame = true;
01949 
01950         }
01951       if ( ! isTheSame ) continue;
01952       //      std::cout << " HEP photon pt " << (*mcIter)->momentum().perp() << " eta " << (*mcIter)->momentum().eta() << " phi " << (*mcIter)->momentum().phi() << std::endl;
01953       //std::cout << "   (*mcPho).motherType() after  " <<   (*mcPho).motherType() << " pt " <<  (*mcPho).fourMomentum().et()  << " eta " << (*mcPho).fourMomentum().pseudoRapidity() << " phi " << mcPhi_ << std::endl;
01954 
01955 
01956 
01957       // if ( ! (  fabs(mcEta_) <= BARL || ( fabs(mcEta_) >= END_LO && fabs(mcEta_) <=END_HI ) ) )
01958       //        continue;  // all ecal fiducial region
01959 
01960       nSimPho_[0]++;
01961       if ( ! isRunCentrally_ ) {
01962         h_SimPhoMotherEt_[0]->Fill(  (*mcPho).motherMomentum().et()  );
01963         h_SimPhoMotherEta_[0]->Fill(  (*mcPho).motherMomentum().pseudoRapidity());
01964       }
01965 
01966       h_SimPho_[0]->Fill ( mcEta_);
01967       h_SimPho_[1]->Fill ( mcPhi_);
01968       h_SimPho_[2]->Fill ( (*mcPho).fourMomentum().et()   );
01969 
01970 
01971 
01972 
01974 
01975       bool goodSimConversion=false;
01976       bool visibleConversion=false;
01977       bool visibleConversionsWithTwoSimTracks=false;
01978       if (  (*mcPho).isAConversion() == 1 ) {
01979         nSimConv_[0]++;
01980         h_AllSimConv_[0]->Fill( mcEta_ ) ;
01981         h_AllSimConv_[1]->Fill( mcPhi_ );
01982         h_AllSimConv_[2]->Fill( mcConvR_ );
01983         h_AllSimConv_[3]->Fill( mcConvZ_ );
01984         h_AllSimConv_[4]->Fill(  (*mcPho).fourMomentum().et());
01985 
01986         if ( ! isRunCentrally_ ) {
01987           if ( mcConvR_ <15) h_SimConvEtaPix_[0]->Fill( mcEta_ ) ;
01988         }
01989 
01990         if ( ( fabs(mcEta_) <= BARL && mcConvR_ <85 )  ||
01991              ( fabs(mcEta_) > BARL && fabs(mcEta_) <=END_HI && fabs( (*mcPho).vertex().z() ) < 210 )  ) visibleConversion=true;
01992 
01993 
01994 
01995         theConvTP_.clear();
01996         //std::cout << " PhotonValidator TrackingParticles   TrackingParticleCollection size "<<  trackingParticles.size() <<  "\n";
01997         for(size_t i = 0; i < trackingParticles.size(); ++i){
01998           TrackingParticleRef tp (ElectronTPHandle,i);
01999           //std::cout << "  Electron pt " << tp -> pt() << " charge " << tp -> charge() << " pdgId " << tp->pdgId() << " Hits for this track: " << tp -> trackPSimHit().size() << std::endl;
02000           //std::cout << " track vertex position x " <<  tp->vertex().x() << " y " << tp->vertex().y() << " z " << tp->vertex().z() << std::endl;
02001           //std::cout << " track vertex position x " <<  tp->vx() << " y " << tp->vy() << " z " << tp->vz() << std::endl;
02002           //std::cout << " conversion vertex position x " <<  (*mcPho).vertex().x() << " y " << (*mcPho).vertex().y() << " z " << (*mcPho).vertex().z() << std::endl;
02003           if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.001   &&
02004                fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.001   &&
02005                fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.001) {
02006 
02007             //std::cout << " From conversion Electron pt " << tp -> pt() << " charge " << tp -> charge() << " pdgId " << tp->pdgId() << " Hits for this track: " << tp -> trackPSimHit().size() << std::endl;
02008             //  std::cout << " track vertex position x " <<  tp->vertex().x() << " y " << tp->vertex().y() << " z " << tp->vertex().z() << std::endl;
02009             //std::cout << " conversion vertex position x " <<  (*mcPho).vertex().x() << " y " << (*mcPho).vertex().y() << " z " << (*mcPho).vertex().z() << "  R " <<  (*mcPho).vertex().perp() << std::endl;
02010             theConvTP_.push_back( tp );
02011           }
02012         }
02013         //      std::cout << " PhotonValidator  theConvTP_ size " <<   theConvTP_.size() << std::endl;
02014 
02015         if ( theConvTP_.size() == 2 )   visibleConversionsWithTwoSimTracks=true;
02016         goodSimConversion=false;
02017 
02018         if (   visibleConversion && visibleConversionsWithTwoSimTracks )  goodSimConversion=true;
02019         if ( goodSimConversion ) {
02020           nSimConv_[1]++;
02021           h_VisSimConv_[0]->Fill( mcEta_ ) ;
02022           h_VisSimConv_[1]->Fill( mcPhi_ );
02023           h_VisSimConv_[2]->Fill( mcConvR_ );
02024           h_VisSimConv_[3]->Fill( mcConvZ_ );
02025           h_VisSimConv_[4]->Fill(  (*mcPho).fourMomentum().et());
02026 
02027 
02028           if ( useTP ) {
02029             if ( ! isRunCentrally_ ) {
02030               for ( edm::RefVector<TrackingParticleCollection>::iterator iTrk=theConvTP_.begin(); iTrk!=theConvTP_.end(); ++iTrk) {
02031                 h_simTkPt_ -> Fill ( (*iTrk)->pt() );
02032                 h_simTkEta_ -> Fill ( (*iTrk)->eta() );
02033               }
02034             }
02035 
02036           }
02037         }
02038       }  
02039 
02040 
02041 
02042       float minDelta=10000.;
02043       std::vector<reco::Photon> thePhotons;
02044       int index=0;
02045       int iMatch=-1;
02046       bool matched=false;
02047 
02048       //std::cout << " Reco photon size " <<  photonCollection.size() << std::endl;
02049       for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
02050         reco::Photon aPho = reco::Photon(*iPho);
02051         thePhotons.push_back(aPho);
02052         float phiPho=aPho.phi();
02053         float etaPho=aPho.eta();
02054         float deltaPhi = phiPho-mcPhi_;
02055         float deltaEta = etaPho-mcEta_;
02056         if ( deltaPhi > pi )  deltaPhi -= twopi;
02057         if ( deltaPhi < -pi) deltaPhi += twopi;
02058         deltaPhi=pow(deltaPhi,2);
02059         deltaEta=pow(deltaEta,2);
02060         float delta = sqrt( deltaPhi+deltaEta);
02061         if ( delta<0.1 && delta < minDelta ) {
02062           minDelta=delta;
02063           iMatch=index;
02064 
02065         }
02066         index++;
02067       }  // end loop over reco photons
02068       if ( iMatch>-1 ) matched=true;
02069       //std::cout << " Debug 1 " << std::endl;
02070 
02071       if ( matched ) {
02072         nSimPho_[1]++;
02073         if ( ! isRunCentrally_ ) {
02074           h_SimPhoMotherEt_[1]->Fill(  (*mcPho).motherMomentum().et()  );
02075           h_SimPhoMotherEta_[1]->Fill(  (*mcPho).motherMomentum().pseudoRapidity());
02076         }
02077         h_MatchedSimPho_[0]->Fill( mcEta_ ) ;
02078         h_MatchedSimPho_[1]->Fill( mcPhi_ );
02079         h_MatchedSimPho_[2]->Fill(  (*mcPho).fourMomentum().et());
02080 
02081       }
02082 
02083 
02084 
02085 
02086       if ( ! matched) continue;
02087 
02088       bool  phoIsInBarrel=false;
02089       bool  phoIsInEndcap=false;
02090       bool  phoIsInEndcapP=false;
02091       bool  phoIsInEndcapM=false;
02092 
02093       reco::Photon matchingPho = thePhotons[iMatch];
02094 
02095       if ( fabs(matchingPho.superCluster()->position().eta() ) < 1.479 ) {
02096         phoIsInBarrel=true;
02097       } else {
02098         phoIsInEndcap=true;
02099         if ( matchingPho.superCluster()->position().eta() > 0) phoIsInEndcapP=true;
02100         if ( matchingPho.superCluster()->position().eta() < 0) phoIsInEndcapM=true;
02101 
02102       }
02103       //std::cout << " Debug 1.1 " << std::endl;
02104 
02105       edm::Handle<EcalRecHitCollection>   ecalRecHitHandle;
02106       if ( phoIsInBarrel ) {
02107         // Get handle to rec hits ecal barrel
02108         e.getByLabel(barrelEcalHits_, ecalRecHitHandle);
02109         if (!ecalRecHitHandle.isValid()) {
02110           edm::LogError("PhotonProducer") << "Error! Can't get the product "<<barrelEcalHits_.label();
02111           return;
02112         }
02113 
02114       } else if ( phoIsInEndcap ) {
02115 
02116         // Get handle to rec hits ecal encap
02117         e.getByLabel(endcapEcalHits_, ecalRecHitHandle);
02118         if (!ecalRecHitHandle.isValid()) {
02119           edm::LogError("PhotonProducer") << "Error! Can't get the product "<<endcapEcalHits_.label();
02120           return;
02121         }
02122 
02123       }
02124 
02125       int type=0;
02126       const EcalRecHitCollection ecalRecHitCollection = *(ecalRecHitHandle.product());
02127       float photonE = matchingPho.energy();
02128       float photonEt= matchingPho.energy()/cosh( matchingPho.eta()) ;
02129       float photonERegr1 = matchingPho.getCorrectedEnergy(reco::Photon::regression1);
02130       float photonERegr2 = matchingPho.getCorrectedEnergy(reco::Photon::regression2);
02131       float r9 = matchingPho.r9();
02132       float r1 = matchingPho.r1x5();
02133       float r2 = matchingPho.r2x5();
02134       float sigmaIetaIeta =  matchingPho.sigmaIetaIeta();
02135       float hOverE = matchingPho.hadronicOverEm();
02136       float newhOverE = matchingPho.hadTowOverEm();
02137       float ecalIso = matchingPho.ecalRecHitSumEtConeDR04();
02138       float hcalIso = matchingPho.hcalTowerSumEtConeDR04();
02139       float newhcalIso = matchingPho.hcalTowerSumEtBcConeDR04();
02140       float trkIso =  matchingPho.trkSumPtSolidConeDR04();
02141       float nIsoTrk   =  matchingPho.nTrkSolidConeDR04();
02142       // PF related quantities
02143       float chargedHadIso =  matchingPho.chargedHadronIso();
02144       float neutralHadIso =  matchingPho.neutralHadronIso();
02145       float photonIso     =  matchingPho.photonIso();
02146       float etOutsideMustache = matchingPho.etOutsideMustache();
02147       int   nClusterOutsideMustache = matchingPho.nClusterOutsideMustache();
02148       float pfMVA = matchingPho.pfMVA();
02149 
02151 
02152       //std::cout << " Debug 1.2 " << std::endl;
02153       std::vector< std::pair<DetId, float> >::const_iterator rhIt;
02154       bool atLeastOneDeadChannel=false;
02155       for(reco::CaloCluster_iterator bcIt = matchingPho.superCluster()->clustersBegin();bcIt != matchingPho.superCluster()->clustersEnd(); ++bcIt) {
02156         for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
02157 
02158           for(EcalRecHitCollection::const_iterator it =  ecalRecHitCollection.begin(); it !=  ecalRecHitCollection.end(); ++it) {
02159             if  (rhIt->first ==  (*it).id() ) {
02160               if (  (*it).recoFlag() == 9 ) {
02161                 atLeastOneDeadChannel=true;
02162                 break;
02163               }
02164             }
02165           }
02166         }
02167       }
02168 
02169       //std::cout << " Debug 1.3 " << std::endl;
02170       if (   atLeastOneDeadChannel ) {
02171         h_MatchedSimPhoBadCh_[0]->Fill( mcEta_ ) ;
02172         h_MatchedSimPhoBadCh_[1]->Fill( mcPhi_ );
02173         h_MatchedSimPhoBadCh_[2]->Fill(  (*mcPho).fourMomentum().et());
02174 
02175       }
02176 
02177 
02178       h_scEta_[type]->Fill( matchingPho.superCluster()->eta() );
02179       h_scPhi_[type]->Fill( matchingPho.superCluster()->phi() );
02180       if ( ! isRunCentrally_ ) {
02181         h_scEtaWidth_[type]->Fill( matchingPho.superCluster()->etaWidth() );
02182         h_scPhiWidth_[type]->Fill( matchingPho.superCluster()->phiWidth() );
02183       }
02184       h_scE_[type][0]->Fill( matchingPho.superCluster()->energy() );
02185       h_scEt_[type][0]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
02186       if ( phoIsInEndcap ) h_psE_->Fill( matchingPho.superCluster()->preshowerEnergy() ) ;
02187       //
02188       h_r9_[type][0]->Fill( r9 );
02189       //
02190       h_r1_[type][0]->Fill( r1 );
02191       //
02192       h_r2_[type][0]->Fill( r2 );
02193       //
02194       h_sigmaIetaIeta_[type][0]->Fill( sigmaIetaIeta );
02195       //
02196       h_hOverE_[type][0]->Fill( hOverE );
02197       if ( ! isRunCentrally_ ) { 
02198         h2_r9VsEta_[0] -> Fill (mcEta_, r9);
02199         h2_r9VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r9);
02200         h2_r1VsEta_[0] -> Fill (mcEta_, r1);
02201         h2_r1VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r1);
02202         h2_r2VsEta_[0] -> Fill (mcEta_, r2);
02203         h2_r2VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r2);
02204         h2_sigmaIetaIetaVsEta_[0] -> Fill (mcEta_, sigmaIetaIeta );
02205         h2_sigmaIetaIetaVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), sigmaIetaIeta);
02206         h2_hOverEVsEta_[0] -> Fill (mcEta_, hOverE );
02207         h2_hOverEVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hOverE);
02208       }
02209       p_hOverEVsEta_[0] -> Fill (mcEta_, hOverE );
02210       p_hOverEVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hOverE);
02211       //
02212       h_newhOverE_[type][0]->Fill( newhOverE );
02213       p_newhOverEVsEta_[0] -> Fill (mcEta_, newhOverE );
02214       p_newhOverEVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), newhOverE);
02215 
02216       //
02217       h_ecalRecHitSumEtConeDR04_[type][0]->Fill( ecalIso );
02218       //std::cout << " Debug 1.4 " << std::endl;
02219       if ( ! isRunCentrally_ ) { 
02220         h2_ecalRecHitSumEtConeDR04VsEta_[0] -> Fill (mcEta_, ecalIso );
02221         h2_ecalRecHitSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
02222         h2_hcalTowerSumEtConeDR04VsEta_[0] -> Fill (mcEta_, hcalIso );
02223         h2_hcalTowerSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
02224  
02225       }
02226       p_ecalRecHitSumEtConeDR04VsEta_[0] -> Fill (mcEta_, ecalIso );
02227       if ( ! isRunCentrally_ ) p_ecalRecHitSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
02228       //
02229       h_hcalTowerSumEtConeDR04_[type][0]->Fill( hcalIso );
02230       p_hcalTowerSumEtConeDR04VsEta_[0] -> Fill (mcEta_, hcalIso );
02231       if ( ! isRunCentrally_ ) p_hcalTowerSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
02232       //
02233       if ( ! isRunCentrally_ ) h_hcalTowerBcSumEtConeDR04_[type][0]->Fill( newhcalIso );
02234       p_hcalTowerBcSumEtConeDR04VsEta_[0] -> Fill (mcEta_, newhcalIso );
02235       if ( ! isRunCentrally_ ) p_hcalTowerBcSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), newhcalIso);
02236       //
02237       h_isoTrkSolidConeDR04_[type][0]->Fill( trkIso );
02238       h_nTrkSolidConeDR04_[type][0]->Fill( nIsoTrk );
02239 
02240       if ( ! isRunCentrally_ ) {
02241         h2_isoTrkSolidConeDR04VsEta_[0] -> Fill (mcEta_, trkIso );
02242         h2_isoTrkSolidConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), trkIso);
02243         h2_nTrkSolidConeDR04VsEta_[0] -> Fill (mcEta_, nIsoTrk );
02244         h2_nTrkSolidConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), nIsoTrk);
02245       }
02246 
02247       h_chHadIso_[0]-> Fill (chargedHadIso);
02248       h_nHadIso_[0]-> Fill (neutralHadIso);
02249       h_phoIso_[0]-> Fill (photonIso);
02250       h_nCluOutsideMustache_[0]->Fill(float(nClusterOutsideMustache));
02251       h_etOutsideMustache_[0]->Fill(etOutsideMustache);
02252       h_pfMva_[0]->Fill(pfMVA);    
02253       //
02254       h_phoEta_[type]->Fill( matchingPho.eta() );
02255       h_phoPhi_[type]->Fill( matchingPho.phi() );
02256       h_phoDEta_[0]->Fill (  matchingPho.eta() - (*mcPho).fourMomentum().eta() );
02257       h_phoDPhi_[0]->Fill (  matchingPho.phi() - mcPhi_ );
02258       h_phoE_[type][0]->Fill( photonE );
02259       h_phoEt_[type][0]->Fill( photonEt);
02260       //
02261       h_phoERes_[0][0]->Fill( photonE / (*mcPho).fourMomentum().e() );
02262       h_phoEResRegr1_[0][0]->Fill( photonERegr1 / (*mcPho).fourMomentum().e() );
02263       h_phoEResRegr2_[0][0]->Fill( photonERegr2 / (*mcPho).fourMomentum().e() );
02264 
02265       p_eResVsEta_[0]->Fill (mcEta_, photonE/(*mcPho).fourMomentum().e()  ) ;
02266       p_eResVsEt_[0][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02267 
02268       if ( ! isRunCentrally_ ) h2_eResVsEta_[0]->Fill (mcEta_, photonE/(*mcPho).fourMomentum().e()  ) ;
02269       if ( ! isRunCentrally_ ) h2_eResVsEt_[0][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02270       if ( ! isRunCentrally_ ) h2_eResVsR9_[0]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
02271       if ( ! isRunCentrally_ ) h2_sceResVsR9_[0]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
02272       if ( ! isRunCentrally_ ) p_eResVsR9_[0]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
02273       if ( ! isRunCentrally_ ) p_sceResVsR9_[0]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
02274       //
02275       //std::cout << " Debug 1.6 " << std::endl;
02276       if (  (*mcPho).isAConversion() == 0 ) {
02277         if ( ! isRunCentrally_ ) { 
02278           h2_eResVsEta_[1]->Fill (mcEta_, photonE/ (*mcPho).fourMomentum().e()  ) ;
02279           h2_r9VsEta_[1] -> Fill (mcEta_, r9);
02280           h2_r9VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r9);
02281           //
02282           h2_r1VsEta_[1] -> Fill (mcEta_, r1);
02283           h2_r1VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r1);
02284           //
02285           h2_r2VsEta_[1] -> Fill (mcEta_, r2);
02286           h2_r2VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r2);
02287           //
02288           h2_sigmaIetaIetaVsEta_[1] -> Fill (mcEta_, sigmaIetaIeta );
02289           h2_sigmaIetaIetaVsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), sigmaIetaIeta);
02290           //
02291           h2_hOverEVsEta_[1] -> Fill (mcEta_, hOverE );
02292           h2_hOverEVsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hOverE);
02293         }
02294 
02295         //std::cout << " Debug 1.7 " << std::endl;
02296 
02297         //
02298         if ( ! isRunCentrally_ ) {
02299           h2_ecalRecHitSumEtConeDR04VsEta_[1] -> Fill (mcEta_, ecalIso );
02300           h2_hcalTowerSumEtConeDR04VsEta_[1] -> Fill (mcEta_, hcalIso );
02301           h2_isoTrkSolidConeDR04VsEta_[1] -> Fill (mcEta_, trkIso );
02302           h2_isoTrkSolidConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), trkIso);
02303           h2_nTrkSolidConeDR04VsEta_[1] -> Fill (mcEta_, nIsoTrk );
02304           h2_nTrkSolidConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), nIsoTrk);
02305 
02306         }
02307         p_ecalRecHitSumEtConeDR04VsEta_[1] -> Fill (mcEta_, ecalIso );
02308         if ( ! isRunCentrally_ ) p_hcalTowerSumEtConeDR04VsEta_[1] -> Fill (mcEta_, hcalIso );
02309         //
02310         //std::cout << " Debug 1.8 " << std::endl;
02311       }
02312 
02313 
02314 
02315 
02316       if ( photonE/(*mcPho).fourMomentum().e()  < 0.3 &&   photonE/(*mcPho).fourMomentum().e() > 0.1 ) {
02317         //      std::cout << " Eta sim " << mcEta_ << " sc eta " << matchingPho.superCluster()->eta() << " pho eta " << matchingPho.eta() << std::endl;
02318 
02319       }
02320 
02321 
02322       if ( (r9>0.94 && phoIsInBarrel) ||   (r9>0.95 && phoIsInEndcap)  )  {
02323         h_phoERes_[1][0]->Fill( photonE / (*mcPho).fourMomentum().e() );
02324         h_phoEResRegr1_[1][0]->Fill( photonERegr1 / (*mcPho).fourMomentum().e() );
02325         h_phoEResRegr2_[1][0]->Fill( photonERegr2 / (*mcPho).fourMomentum().e() );
02326         if ( ! isRunCentrally_ ) h2_eResVsEt_[0][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02327         p_eResVsEt_[0][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02328         p_eResVsEta_[1]->Fill (mcEta_,photonE/ (*mcPho).fourMomentum().e()  ) ;
02329 
02330       } else if ( ( r9 <= 0.94&& phoIsInBarrel) ||  ( r9 <= 0.95&& phoIsInEndcap)  ) {
02331         h_phoERes_[2][0]->Fill(photonE / (*mcPho).fourMomentum().e() );
02332         h_phoEResRegr1_[2][0]->Fill( photonERegr1 / (*mcPho).fourMomentum().e() );
02333         h_phoEResRegr2_[2][0]->Fill( photonERegr2 / (*mcPho).fourMomentum().e() );
02334         p_eResVsEt_[0][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02335         p_eResVsEta_[2]->Fill (mcEta_,photonE/ (*mcPho).fourMomentum().e()  ) ;
02336         if ( ! isRunCentrally_ ) {
02337           h2_eResVsEt_[0][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02338           h_EtR9Less093_[0][0] ->Fill ( photonEt );
02339         }
02340         
02341       }
02342 
02343       //std::cout << " Debug 1.9 " << std::endl;
02344 
02345       if ( phoIsInBarrel ) {
02346         h_scE_[type][1]->Fill( matchingPho.superCluster()->energy() );
02347         h_scEt_[type][1]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
02348         h_r9_[type][1]->Fill( r9 );
02349         h_r1_[type][1]->Fill( r1 );
02350         h_r2_[type][1]->Fill( r2 );
02351         h_sigmaIetaIeta_[type][1]->Fill( sigmaIetaIeta );
02352         h_hOverE_[type][1]->Fill( hOverE );
02353         h_newhOverE_[type][1]->Fill( newhOverE );
02354         h_ecalRecHitSumEtConeDR04_[type][1]->Fill( ecalIso );
02355         p_ecalRecHitSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
02356         h_hcalTowerSumEtConeDR04_[type][1]->Fill( hcalIso );
02357         p_hcalTowerSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
02358         h_hcalTowerBcSumEtConeDR04_[type][1]->Fill( newhcalIso );
02359         p_hcalTowerBcSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), newhcalIso);
02360         h_isoTrkSolidConeDR04_[type][1]->Fill( trkIso );
02361         h_nTrkSolidConeDR04_[type][1]->Fill( nIsoTrk );
02362         h_chHadIso_[1]-> Fill (chargedHadIso);
02363         h_nHadIso_[1]-> Fill (neutralHadIso);
02364         h_phoIso_[1]-> Fill (photonIso);
02365         h_nCluOutsideMustache_[1]->Fill(float(nClusterOutsideMustache));
02366         h_etOutsideMustache_[1]->Fill(etOutsideMustache);
02367         h_pfMva_[1]->Fill(pfMVA);    
02368         h_phoE_[type][1]->Fill( photonE );
02369         h_phoEt_[type][1]->Fill( photonEt );
02370         h_nConv_[type][1]->Fill(float( matchingPho.conversions().size()));
02371         h_phoERes_[0][1]->Fill( photonE / (*mcPho).fourMomentum().e() );
02372         h_phoEResRegr1_[0][1]->Fill( photonERegr1 / (*mcPho).fourMomentum().e() );
02373         h_phoEResRegr2_[0][1]->Fill( photonERegr2 / (*mcPho).fourMomentum().e() );
02374         p_eResVsR9_[1]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
02375         p_sceResVsR9_[1]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
02376         if ( ! isRunCentrally_ ) {
02377           h2_eResVsR9_[1]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
02378           h2_sceResVsR9_[1]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
02379           h2_ecalRecHitSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
02380           h2_hcalTowerSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
02381           h2_eResVsEt_[1][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02382         }
02383         p_eResVsEt_[1][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02384 
02385         //std::cout << " Debug 1.10 " << std::endl;
02386         if ( r9 > 0.94 ) {
02387           h_phoERes_[1][1]->Fill(  photonE  / (*mcPho).fourMomentum().e() );
02388           h_phoEResRegr1_[1][1]->Fill( photonERegr1 / (*mcPho).fourMomentum().e() );
02389           h_phoEResRegr2_[1][1]->Fill( photonERegr2 / (*mcPho).fourMomentum().e() );
02390           if ( ! isRunCentrally_ ) h2_eResVsEt_[1][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02391           p_eResVsEt_[1][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02392         }
02393         if ( r9 <= 0.94 )  {
02394           h_phoERes_[2][1]->Fill( photonE / (*mcPho).fourMomentum().e() );
02395           h_phoEResRegr1_[2][1]->Fill( photonERegr1 / (*mcPho).fourMomentum().e() );
02396           h_phoEResRegr2_[2][1]->Fill( photonERegr2 / (*mcPho).fourMomentum().e() );
02397           p_eResVsEt_[1][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02398           if ( ! isRunCentrally_ ) {
02399             h2_eResVsEt_[1][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02400             h_EtR9Less093_[0][1] ->Fill ( photonEt );
02401           }
02402         }
02403         //std::cout << " Debug 1.11 " << std::endl;
02404       }
02405       if ( phoIsInEndcap ) {
02406         //std::cout << " Looking for troubles 1 " << std::endl;
02407         h_scE_[type][2]->Fill( matchingPho.superCluster()->energy() );
02408         h_scEt_[type][2]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
02409         h_r9_[type][2]->Fill( r9 );
02410         h_r1_[type][2]->Fill( r1 );
02411         h_r2_[type][2]->Fill( r2 );
02412         //std::cout << " Looking for troubles 2 " << std::endl;
02413         h_sigmaIetaIeta_[type][2]->Fill( sigmaIetaIeta );
02414         h_hOverE_[type][2]->Fill( hOverE );
02415         h_newhOverE_[type][2]->Fill( newhOverE );
02416         h_ecalRecHitSumEtConeDR04_[type][2]->Fill( ecalIso );
02417         p_ecalRecHitSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
02418         h_hcalTowerSumEtConeDR04_[type][2]->Fill( hcalIso );
02419         p_hcalTowerSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
02420         //std::cout << " Looking for troubles 3 " << std::endl;
02421         h_hcalTowerBcSumEtConeDR04_[type][2]->Fill( newhcalIso );
02422         p_hcalTowerBcSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), newhcalIso);
02423         h_isoTrkSolidConeDR04_[type][2]->Fill( trkIso );
02424         h_nTrkSolidConeDR04_[type][2]->Fill( nIsoTrk );
02425         //std::cout << " Looking for troubles 4 " << std::endl;
02426         h_chHadIso_[2]-> Fill (chargedHadIso);
02427         h_nHadIso_[2]-> Fill (neutralHadIso);
02428         h_phoIso_[2]-> Fill (photonIso);
02429         h_nCluOutsideMustache_[2]->Fill(float(nClusterOutsideMustache));
02430         h_etOutsideMustache_[2]->Fill(etOutsideMustache);
02431         //std::cout << " Looking for troubles 5 " << std::endl;
02432         h_pfMva_[2]->Fill(pfMVA);    
02433         h_phoE_[type][2]->Fill( photonE );
02434         h_phoEt_[type][2]->Fill( photonEt );
02435         h_nConv_[type][2]->Fill(float( matchingPho.conversions().size()));
02436         h_phoERes_[0][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
02437         //std::cout << " Looking for troubles 6 " << std::endl;
02438         h_phoEResRegr1_[0][2]->Fill( photonERegr1 / (*mcPho).fourMomentum().e() );
02439         h_phoEResRegr2_[0][2]->Fill( photonERegr2 / (*mcPho).fourMomentum().e() );
02440         //std::cout << " Looking for troubles 7 " << std::endl;
02441         p_eResVsR9_[2]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
02442         p_sceResVsR9_[2]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
02443         if ( ! isRunCentrally_ ) {
02444           h2_eResVsR9_[2]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
02445           h2_sceResVsR9_[2]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
02446           h2_ecalRecHitSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
02447           h2_hcalTowerSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
02448           h2_eResVsEt_[2][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02449         }
02450         //std::cout << " Debug 1.12 " << std::endl;
02451 
02452         p_eResVsEt_[2][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02453 
02454         if ( r9 > 0.95 ) {
02455 
02456           h_phoERes_[1][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
02457           h_phoEResRegr1_[1][2]->Fill( photonERegr1 / (*mcPho).fourMomentum().e() );
02458           h_phoEResRegr2_[1][2]->Fill( photonERegr2 / (*mcPho).fourMomentum().e() );
02459           if ( ! isRunCentrally_ ) h2_eResVsEt_[2][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02460           p_eResVsEt_[2][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02461         }
02462         if ( r9 <= 0.95 ) {
02463           h_phoERes_[2][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
02464           h_phoEResRegr1_[2][2]->Fill( photonERegr1 / (*mcPho).fourMomentum().e() );
02465           h_phoEResRegr2_[2][2]->Fill( photonERegr2 / (*mcPho).fourMomentum().e() );
02466           p_eResVsEt_[2][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02467           if ( ! isRunCentrally_ ) {
02468             h2_eResVsEt_[2][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02469             h_EtR9Less093_[0][2] ->Fill ( photonEt );
02470           }
02471         }
02472         //      std::cout << " Debug 1.13 " << std::endl;
02473       }
02474 
02475 
02476 
02477 
02478       if ( ! (visibleConversion &&  visibleConversionsWithTwoSimTracks ) ) continue;
02479 
02480       //      std::cout << " Debug 1.14 " << std::endl;
02481 
02482       if ( ! isRunCentrally_ ) {
02483         h_r9_[1][0]->Fill( r9 );
02484         if ( phoIsInBarrel ) h_r9_[1][1]->Fill( r9 );
02485         if ( phoIsInEndcap ) h_r9_[1][2]->Fill( r9 );
02486 
02487         h_simConvVtxRvsZ_[0] ->Fill ( fabs (mcConvZ_), mcConvR_  ) ;
02488         if ( fabs(mcEta_) <=1.) {
02489           h_simConvVtxRvsZ_[1] ->Fill ( fabs (mcConvZ_), mcConvR_  ) ;
02490           h_simConvVtxYvsX_ ->Fill ( mcConvX_, mcConvY_  ) ;
02491         }
02492         else
02493           h_simConvVtxRvsZ_[2] ->Fill ( fabs (mcConvZ_), mcConvR_  ) ;
02494       }
02495 
02496 
02497       if ( ! fastSim_) {
02498         h_nConv_[type][0]->Fill(float( matchingPho.conversions().size()));
02499         //std::cout << " Conversion size " <<  matchingPho.conversions().size() << std::endl;
02501         reco::ConversionRefVector conversions = matchingPho.conversions();
02502 
02503         for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
02504           reco::ConversionRef aConv=conversions[iConv];
02505           double like = aConv->MVAout();
02506           if ( like < likelihoodCut_ ) continue;
02507 
02508           if ( ! isRunCentrally_ ) h2_EoverEtrueVsEta_[1]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02509           p_EoverEtrueVsEta_[1]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02510 
02511 
02512           //std::vector<reco::TrackRef> tracks = aConv->tracks();
02513           const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
02514           if (tracks.size() < 1 ) continue;
02515 
02516 
02517           h_mvaOut_[0]-> Fill(like);
02518 
02519           if ( tracks.size()==2 ) {
02520             if ( sqrt( aConv->tracksPin()[0].Perp2()) < convTrackMinPtCut_ || sqrt( aConv->tracksPin()[1].Perp2()) < convTrackMinPtCut_) continue;
02521           } else {
02522             if ( sqrt( aConv->tracksPin()[0].Perp2()) < convTrackMinPtCut_ ) continue;
02523           }
02524 
02525 
02526           if ( dCotCutOn_ ) {
02527             if (  (fabs(mcEta_) > 1.1 && fabs (mcEta_)  < 1.4  )  &&
02528                   fabs( aConv->pairCotThetaSeparation() ) > dCotHardCutValue_ ) continue;
02529             if ( fabs( aConv->pairCotThetaSeparation() ) > dCotCutValue_ ) continue;
02530           }
02531 
02532           //std::cout << " PhotonValidator converison algo name " << aConv->algoName() << " " << aConv->algo() << std::endl;
02533 
02534           nRecConv_++;
02535 
02536           std::map<const reco::Track*,TrackingParticleRef> myAss;
02537           std::map<const reco::Track*,TrackingParticleRef>::const_iterator itAss;
02538           std::map<reco::TrackRef,TrackingParticleRef>::const_iterator itAssMin;
02539           std::map<reco::TrackRef,TrackingParticleRef>::const_iterator itAssMax;
02540           //
02541 
02542           int nAssT2=0;
02543           for (unsigned int i=0; i<tracks.size(); i++) {
02544             //      reco::TrackRef track = tracks[i].castTo<reco::TrackRef>();
02545 
02546             type =0;
02547             if ( ! isRunCentrally_ ) nHitsVsEta_[type] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits())-0.0001 );
02548             if ( ! isRunCentrally_ ) nHitsVsR_[type] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits())-0.0001 );
02549             p_nHitsVsEta_[type] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits()) );
02550             p_nHitsVsR_[type] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits()) );
02551             h_tkChi2_[type] ->Fill (tracks[i]->normalizedChi2() );
02552 
02553             //std::cout << " Debug 1.15 " << std::endl;
02554 
02555             RefToBase<reco::Track> tfrb = tracks[i];
02556             RefToBaseVector<reco::Track> tc;
02557             tc.push_back(tfrb);
02558             // reco::RecoToSimCollection q = theTrackAssociator_->associateRecoToSim(tc,theConvTP_,&e,&esup);
02559             reco::SimToRecoCollection q = theTrackAssociator_->associateSimToReco(tc,theConvTP_,&e,&esup);
02560             std::vector<std::pair<RefToBase<reco::Track>, double> >  trackV;
02561             int tpI = 0;
02562 
02563             if (q.find(theConvTP_[0])!=q.end()){
02564               trackV = (std::vector<std::pair<RefToBase<reco::Track>, double> >) q[theConvTP_[0]];
02565             } else if (q.find(theConvTP_[1])!=q.end()){
02566               trackV = (std::vector<std::pair<RefToBase<reco::Track>, double> >) q[theConvTP_[1]];
02567               tpI = 1;
02568             }
02569 
02570             if ( !trackV.size() ) continue;
02571             edm::RefToBase<reco::Track> tr = trackV.front().first;
02572             myAss.insert( std::make_pair (tr.get(),theConvTP_[tpI] ) );
02573             nAssT2++;
02574 
02575           }
02576 
02577 
02578           //std::cout << " Debug 1.16 " << std::endl;
02579 
02580 
02581             /*
02583             TrackingParticleRef myTP;
02584             for (size_t j = 0; j < RtoSCollPtrs.size(); j++) {
02585               reco::RecoToSimCollection q = *(RtoSCollPtrs[j]);
02586 
02587               RefToBase<reco::Track> myTk( track );
02588 
02589               if( q.find(myTk ) != q.end() ) {
02590                 std::vector<std::pair<TrackingParticleRef, double> > tp = q[myTk];
02591                 for (unsigned int itp=0; itp<tp.size(); itp++) {
02592                   myTP=tp[itp].first;
02593                   //      std::cout << " associated with TP " << myTP->pdgId() << " pt " << sqrt(myTP->momentum().perp2()) << std::endl;
02594                   myAss.insert( std::make_pair ( track  , myTP) );
02595                   nAssT2++;
02596                 }
02597               }
02598             }
02599           }
02600           */
02601 
02602 
02603           type=0;
02604 
02605           //      float totP = sqrt(aConv->pairMomentum().Mag2());
02606           float refP =-99999.;
02607           float refPt =-99999.;
02608           if ( aConv->conversionVertex().isValid() ) {
02609                refP=sqrt(aConv->refittedPairMomentum().Mag2());
02610                refPt=sqrt(aConv->refittedPairMomentum().perp2());
02611           }
02612           float invM = aConv->pairInvariantMass();
02613 
02614           h_invMass_[type][0] ->Fill( invM);
02615           if ( phoIsInBarrel ) h_invMass_[type][1] ->Fill(invM);
02616           if ( phoIsInEndcap ) h_invMass_[type][2] ->Fill(invM);
02617 
02618           //std::cout << " Debug 1.17 " << std::endl;
02619 
02621           if ( tracks.size() ==1  ) {
02622             h_SimConvOneTracks_[0]->Fill( mcEta_ ) ;
02623             h_SimConvOneTracks_[1]->Fill( mcPhi_ );
02624             h_SimConvOneTracks_[2]->Fill( mcConvR_ );
02625             h_SimConvOneTracks_[3]->Fill( mcConvZ_ );
02626             h_SimConvOneTracks_[4]->Fill(  (*mcPho).fourMomentum().et());
02627 
02628 
02629           } else if ( tracks.size() ==2 ) {
02630 
02631             h_SimConvTwoTracks_[0]->Fill( mcEta_ ) ;
02632             h_SimConvTwoTracks_[1]->Fill( mcPhi_ );
02633             h_SimConvTwoTracks_[2]->Fill( mcConvR_ );
02634             h_SimConvTwoTracks_[3]->Fill( mcConvZ_ );
02635             h_SimConvTwoTracks_[4]->Fill(  (*mcPho).fourMomentum().et());
02636 
02637             //std::cout << " Debug 1.17.1 " << std::endl;
02638             if (aConv->caloCluster().size() !=0) h_convEta_[1]->Fill( aConv->caloCluster()[0]->eta() );
02639             //std::cout << " Debug 1.17.2 " << std::endl;
02640 
02641             float trkProvenance=3;
02642             if ( tracks[0]->algoName() == "outInEcalSeededConv"  &&  tracks[1]->algoName() == "outInEcalSeededConv" ) trkProvenance=0;
02643             if ( tracks[0]->algoName() == "inOutEcalSeededConv"  &&  tracks[1]->algoName() == "inOutEcalSeededConv" ) trkProvenance=1;
02644             if ( ( tracks[0]->algoName() == "outInEcalSeededConv"  &&  tracks[1]->algoName() == "inOutEcalSeededConv") ||
02645                  ( tracks[1]->algoName() == "outInEcalSeededConv"  &&  tracks[0]->algoName() == "inOutEcalSeededConv") ) trkProvenance=2;
02646             if ( trkProvenance==3 ) {
02647               // std::cout << " PhotonValidator provenance of tracks is " << tracks[0]->algoName() << " and " << tracks[1]->algoName() << std::endl;
02648             }
02649             h_trkProv_[0]->Fill( trkProvenance );
02650 
02651 
02652 
02654             if ( nAssT2 ==2 ) {
02655 
02656 
02657 
02658               if ( ! isRunCentrally_ ) {
02659                 h_r9_[2][0]->Fill( r9 );
02660                 if ( phoIsInBarrel ) h_r9_[2][1]->Fill( r9 );
02661                 if ( phoIsInEndcap ) h_r9_[2][2]->Fill( r9 );
02662               }
02663 
02664               if (aConv->caloCluster().size() !=0)  h_convEta_[2]->Fill( aConv->caloCluster()[0]->eta() );
02665               nRecConvAss_++;
02666 
02667 
02668               h_SimConvTwoMTracks_[0]->Fill( mcEta_ ) ;
02669               h_SimConvTwoMTracks_[1]->Fill( mcPhi_ );
02670               h_SimConvTwoMTracks_[2]->Fill( mcConvR_ );
02671               h_SimConvTwoMTracks_[3]->Fill( mcConvZ_ );
02672               h_SimConvTwoMTracks_[4]->Fill(  (*mcPho).fourMomentum().et());
02673 
02674               if ( aConv->conversionVertex().isValid() ) {
02675                 //if ( trkProvenance==3 ) std::cout << " PhotonValidator provenance of tracks is mixed and vertex is valid " << std::endl;
02676                 float chi2Prob = ChiSquaredProbability( aConv->conversionVertex().chi2(),  aConv->conversionVertex().ndof() );
02677                 if (   chi2Prob > 0) {
02678                   h_SimConvTwoMTracksAndVtxPGT0_[0]->Fill( mcEta_ ) ;
02679                   h_SimConvTwoMTracksAndVtxPGT0_[1]->Fill( mcPhi_ );
02680                   h_SimConvTwoMTracksAndVtxPGT0_[2]->Fill( mcConvR_ );
02681                   h_SimConvTwoMTracksAndVtxPGT0_[3]->Fill( mcConvZ_ );
02682                   h_SimConvTwoMTracksAndVtxPGT0_[4]->Fill(  (*mcPho).fourMomentum().et());
02683                 }
02684                 if (   chi2Prob > 0.0005) {
02685                   h_SimConvTwoMTracksAndVtxPGT0005_[0]->Fill( mcEta_ ) ;
02686                   h_SimConvTwoMTracksAndVtxPGT0005_[1]->Fill( mcPhi_ );
02687                   h_SimConvTwoMTracksAndVtxPGT0005_[2]->Fill( mcConvR_ );
02688                   h_SimConvTwoMTracksAndVtxPGT0005_[3]->Fill( mcConvZ_ );
02689                   h_SimConvTwoMTracksAndVtxPGT0005_[4]->Fill(  (*mcPho).fourMomentum().et());
02690 
02691 
02692                 }
02693 
02694                 //std::cout << " Debug 1.18 " << std::endl;
02695                 if (  chi2Prob > 0.0005 ) {
02696                   if (aConv->caloCluster().size() !=0) {
02697                     h_convEta_[0]->Fill( aConv->caloCluster()[0]->eta() );
02698                     h_convPhi_[0]->Fill( aConv->caloCluster()[0]->phi() );
02699                     h_convERes_[0][0]->Fill( aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
02700                   }
02701                   if ( ! isRunCentrally_ ) {
02702                     h_r9VsNofTracks_[0][0]->Fill( r9, aConv->nTracks() ) ;
02703                     h_EtR9Less093_[1][0] ->Fill ( photonEt );
02704                     if ( phoIsInBarrel ) h_EtR9Less093_[1][1] ->Fill ( photonEt );
02705                     if ( phoIsInEndcap ) h_EtR9Less093_[1][2] ->Fill ( photonEt );
02706                   }
02707                   //std::cout << " Debug 1.19 " << std::endl;
02708                   if ( phoIsInBarrel )  {
02709                     if (aConv->caloCluster().size() !=0) h_convERes_[0][1]->Fill(aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
02710                     if ( ! isRunCentrally_ ) h_r9VsNofTracks_[0][1]->Fill( r9, aConv->nTracks() ) ;
02711                     h_mvaOut_[1]-> Fill(like);
02712                   }
02713                   if ( phoIsInEndcap ) {
02714                     if (aConv->caloCluster().size() !=0)  h_convERes_[0][2]->Fill(aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
02715                     if ( ! isRunCentrally_ ) h_r9VsNofTracks_[0][2]->Fill( r9, aConv->nTracks() ) ;
02716                     h_mvaOut_[2]-> Fill(like);
02717                   }
02718                   //std::cout << " Debug 1.20 " << std::endl;
02719 
02720                 }
02721 
02722 
02723 
02724 
02725               }
02726 
02727               //              std::cout << " Debug 2 " << std::endl;
02728 
02730               type =1;
02731 
02732               h_trkProv_[1]->Fill( trkProvenance );
02733               h_invMass_[type][0] ->Fill( invM);
02734 
02735 
02736 
02737               float eoverp= -99999.;
02738 
02739               if ( aConv->conversionVertex().isValid() ) {
02740                 eoverp= aConv->EoverPrefittedTracks();
02741                 h_convPtRes_[type][0]->Fill( refPt / (*mcPho).fourMomentum().et() );
02742                 h_EoverPTracks_[type][0] ->Fill( eoverp ) ;
02743                 h_PoverETracks_[type][0] ->Fill( 1./eoverp ) ;
02744                 if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[0] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02745                 if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[0] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e()  ) ;
02746                 if ( ! isRunCentrally_ ) h2_EoverPVsEta_[0]->Fill (mcEta_, eoverp);
02747                 if ( ! isRunCentrally_ ) h2_EoverPVsR_[0]->Fill (mcConvR_, eoverp);
02748                 p_EoverPVsEta_[0]->Fill (mcEta_, eoverp);
02749                 p_EoverPVsR_[0]->Fill (mcConvR_, eoverp);
02750                 p_eResVsR_ ->Fill ( mcConvR_, photonE / (*mcPho).fourMomentum().e() );
02751                  if ( ! isRunCentrally_ ) h2_PoverPtrueVsEta_[0]->Fill (mcEta_,refP/ (*mcPho).fourMomentum().e()  ) ;
02752                 p_PoverPtrueVsEta_[0]->Fill (mcEta_,refP/ (*mcPho).fourMomentum().e()  ) ;
02753 
02754 
02755               }
02756 
02757               //std::cout << " Debug 3 " << std::endl;
02758               if ( ! isRunCentrally_ )  h2_EoverEtrueVsEta_[0]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02759               if ( ! isRunCentrally_ )  h2_EoverEtrueVsR_[0]->Fill (mcConvR_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02760               p_EoverEtrueVsEta_[0]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02761               p_EoverEtrueVsR_[0]->Fill (mcConvR_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02762 
02763 
02764               if ( ! isRunCentrally_ ) h2_etaVsRsim_[0]->Fill (mcEta_,mcConvR_);
02765 
02766               /*
02767               reco::TrackRef track1 = tracks[0].castTo<reco::TrackRef>();
02768               reco::TrackRef track2 = tracks[1].castTo<reco::TrackRef>();
02769               reco::TransientTrack tt1 = (*theTTB).build( &track1);
02770               reco::TransientTrack tt2 = (*theTTB).build( &track2);
02771               TwoTrackMinimumDistance md;
02772               md.calculate  (  tt1.initialFreeState(),  tt2.initialFreeState() );
02773               if (md.status() )  {
02774                 //cout << " Min Dist " << md.distance() << std::endl;
02775                 h_distMinAppTracks_[1][0]->Fill ( md.distance() );
02776               }  else {
02777                 nInvalidPCA_++;
02778 
02779               }
02780               */
02781 
02782               //  here original tracks and their inner momentum is considered
02783               float  dPhiTracksAtVtx =  aConv->dPhiTracksAtVtx();
02784               h_DPhiTracksAtVtx_[type][0]->Fill( dPhiTracksAtVtx);
02785               if ( ! isRunCentrally_ ) h2_DPhiTracksAtVtxVsEta_->Fill( mcEta_, dPhiTracksAtVtx);
02786               if ( ! isRunCentrally_ ) h2_DPhiTracksAtVtxVsR_->Fill( mcConvR_, dPhiTracksAtVtx);
02787               p_DPhiTracksAtVtxVsEta_->Fill( mcEta_, dPhiTracksAtVtx);
02788               p_DPhiTracksAtVtxVsR_->Fill( mcConvR_, dPhiTracksAtVtx);
02789 
02790               h_DCotTracks_[type][0] ->Fill ( aConv->pairCotThetaSeparation() );
02791               if ( ! isRunCentrally_ ) h2_DCotTracksVsEta_->Fill( mcEta_, aConv->pairCotThetaSeparation() );
02792               if ( ! isRunCentrally_ ) h2_DCotTracksVsR_->Fill( mcConvR_, aConv->pairCotThetaSeparation() );
02793               p_DCotTracksVsEta_->Fill( mcEta_, aConv->pairCotThetaSeparation() );
02794               p_DCotTracksVsR_->Fill( mcConvR_, aConv->pairCotThetaSeparation() );
02795 
02796               //std::cout << " Debug 4 " << std::endl;
02797 
02798               if ( phoIsInBarrel ) {
02799                 h_invMass_[type][1] ->Fill(invM);
02800                 if ( aConv->conversionVertex().isValid() ) {
02801                   h_convPtRes_[type][1]->Fill( refPt / (*mcPho).fourMomentum().et() );
02802                   h_EoverPTracks_[type][1] ->Fill( eoverp ) ;
02803                   if (  mcConvR_ < 15 )                 h_EoverPTracks_[0][0] ->Fill( eoverp ) ;
02804                   if (  mcConvR_ > 15 && mcConvR_< 58 ) h_EoverPTracks_[0][1] ->Fill( eoverp ) ;
02805                   if (  mcConvR_ > 58 )                 h_EoverPTracks_[0][2] ->Fill( eoverp ) ;
02806                   h_PoverETracks_[type][1] ->Fill( 1./eoverp ) ;
02807                   if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[1] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02808                   if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[1] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e()  ) ;
02809                 }
02810                 h_DPhiTracksAtVtx_[type][1]->Fill( dPhiTracksAtVtx);
02811                 h_DCotTracks_[type][1] ->Fill ( aConv->pairCotThetaSeparation() );
02812 
02813 
02814               }
02815 
02816               //std::cout << " Debug 5 " << std::endl;
02817 
02818               if ( phoIsInEndcap ) {
02819                 h_invMass_[type][2] ->Fill(invM);
02820                 if ( aConv->conversionVertex().isValid() ) {
02821                   h_convPtRes_[type][2]->Fill( refPt / (*mcPho).fourMomentum().et() );
02822                   h_EoverPTracks_[type][2] ->Fill( eoverp ) ;
02823                   h_PoverETracks_[type][2] ->Fill( 1./eoverp ) ;
02824                   if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[2] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02825                   if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[2] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e()  ) ;
02826                 }
02827                 h_DPhiTracksAtVtx_[type][2]->Fill( dPhiTracksAtVtx);
02828                 h_DCotTracks_[type][2] ->Fill ( aConv->pairCotThetaSeparation() );
02829 
02830               }
02831 
02832               //std::cout << " Debug 6 " << std::endl;
02833               if ( aConv->conversionVertex().isValid() ) {
02834 
02835                 h_convVtxdX_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
02836                 h_convVtxdY_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
02837                 h_convVtxdZ_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
02838                 h_convVtxdR_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
02839 
02840                 if ( fabs( mcConvEta_ ) <= 1.2 ) {
02841                   h_convVtxdX_barrel_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
02842                   h_convVtxdY_barrel_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
02843                   h_convVtxdZ_barrel_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
02844                   h_convVtxdR_barrel_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
02845                 } else {
02846                   h_convVtxdX_endcap_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
02847                   h_convVtxdY_endcap_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
02848                   h_convVtxdZ_endcap_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
02849                   h_convVtxdR_endcap_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
02850                 }
02851 
02852                 //std::cout << " Debug 7 " << std::endl;
02853                 h_convVtxdPhi_ ->Fill ( aConv->conversionVertex().position().phi() - mcConvPhi_);
02854                 h_convVtxdEta_ ->Fill ( aConv->conversionVertex().position().eta() - mcConvEta_);
02855                 if ( ! isRunCentrally_ ) h2_convVtxdRVsR_ ->Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
02856                 if ( ! isRunCentrally_ ) h2_convVtxdRVsEta_ ->Fill (mcEta_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
02857                 p_convVtxdRVsR_ ->Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
02858                 p_convVtxdRVsEta_ ->Fill (mcEta_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
02859                 float signX= aConv->refittedPairMomentum().x()/fabs(aConv->refittedPairMomentum().x());
02860                 float signY= aConv->refittedPairMomentum().y()/fabs(aConv->refittedPairMomentum().y());
02861                 float signZ= aConv->refittedPairMomentum().z()/fabs(aConv->refittedPairMomentum().z());
02862                 p_convVtxdXVsX_ ->Fill (mcConvX_, (aConv->conversionVertex().position().x() - mcConvX_)*signX );
02863                 p_convVtxdYVsY_ ->Fill (mcConvY_, (aConv->conversionVertex().position().y() - mcConvY_)*signY );
02864                 p_convVtxdZVsZ_ ->Fill (mcConvZ_, (aConv->conversionVertex().position().z() - mcConvZ_)*signZ );
02865 
02866 
02867                 if ( ! isRunCentrally_ ) h2_convVtxRrecVsTrue_ -> Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) );
02868 
02869 
02870 
02871                 //float zPV = aConv->zOfPrimaryVertexFromTracks();
02872                 float thetaConv=aConv->refittedPairMomentum().Theta();
02873                 float thetaSC=matchingPho.superCluster()->position().theta();
02874                 float rSC=sqrt(matchingPho.superCluster()->position().x()*matchingPho.superCluster()->position().x() +
02875                                matchingPho.superCluster()->position().y()*matchingPho.superCluster()->position().y() );
02876                 float zSC=matchingPho.superCluster()->position().z();
02877                 float zPV = sqrt(rSC*rSC+zSC*zSC)*sin( thetaConv - thetaSC)/sin(thetaConv);
02878 
02879                 h_zPVFromTracks_[0]->Fill (  zPV );
02880                 h_dzPVFromTracks_[0]->Fill ( zPV- (*mcPho).primaryVertex().z() );
02881 
02882                 //std::cout << " Debug 8 " << std::endl;
02883 
02884                 if ( phoIsInBarrel ) {
02885                   h_zPVFromTracks_[1]->Fill ( zPV );
02886                   h_dzPVFromTracks_[1]->Fill ( zPV - (*mcPho).primaryVertex().z() );
02887                 } else if ( phoIsInEndcap) {
02888                   h_zPVFromTracks_[2]->Fill ( zPV );
02889                   h_dzPVFromTracks_[2]->Fill ( zPV - (*mcPho).primaryVertex().z() );
02890                 } else if ( phoIsInEndcapP) {
02891                   h_zPVFromTracks_[3]->Fill ( zPV );
02892                   h_dzPVFromTracks_[3]->Fill ( zPV - (*mcPho).primaryVertex().z() );
02893                 }  else if ( phoIsInEndcapM) {
02894                   h_zPVFromTracks_[4]->Fill ( zPV );
02895                   h_dzPVFromTracks_[4]->Fill ( zPV - (*mcPho).primaryVertex().z() );
02896                 }
02897 
02898                 //              std::cout << " Debug 8.1 " << std::endl;
02899                 p_dzPVVsR_ ->Fill(mcConvR_, zPV - (*mcPho).primaryVertex().z() );
02900                 p_dzPVVsEta_ ->Fill(mcConvEta_, zPV - (*mcPho).primaryVertex().z() );
02901                 if ( ! isRunCentrally_ ) h2_dzPVVsR_ ->Fill(mcConvR_, zPV - (*mcPho).primaryVertex().z() );
02902                 //              std::cout << " Debug 8.2 " << std::endl;
02903 
02904               }
02905 
02906               float  dPhiTracksAtEcal=-99;
02907               float  dEtaTracksAtEcal=-99;
02908               if ( fName_ != "pfPhotonValidator" &&  fName_ != "oldpfPhotonValidator" ) {
02909                 if (aConv->bcMatchingWithTracks()[0].isNonnull() && aConv->bcMatchingWithTracks()[1].isNonnull() ) {
02910                   //              std::cout << " Debug 8.3 " << std::endl;
02911                   nRecConvAssWithEcal_++;
02912                   float recoPhi1 = aConv->ecalImpactPosition()[0].phi();
02913                   float recoPhi2 = aConv->ecalImpactPosition()[1].phi();
02914                   float recoEta1 = aConv->ecalImpactPosition()[0].eta();
02915                   float recoEta2 = aConv->ecalImpactPosition()[1].eta();
02916                   float bcPhi1 = aConv->bcMatchingWithTracks()[0]->phi();
02917                   float bcPhi2 = aConv->bcMatchingWithTracks()[1]->phi();
02918                   // unused     float bcEta1 = aConv->bcMatchingWithTracks()[0]->eta();
02919                   // unused   float bcEta2 = aConv->bcMatchingWithTracks()[1]->eta();
02920                   recoPhi1 = phiNormalization(recoPhi1);
02921                   recoPhi2 = phiNormalization(recoPhi2);
02922                   bcPhi1 = phiNormalization(bcPhi1);
02923                   bcPhi2 = phiNormalization(bcPhi2);
02924                   dPhiTracksAtEcal = recoPhi1 -recoPhi2;
02925                   dPhiTracksAtEcal = phiNormalization( dPhiTracksAtEcal );
02926                   dEtaTracksAtEcal = recoEta1 -recoEta2;
02927                   //              std::cout << " Debug 8.4 " << std::endl;
02928                   
02929                   h_DPhiTracksAtEcal_[type][0]->Fill( fabs(dPhiTracksAtEcal));
02930                   if ( ! isRunCentrally_ ) h2_DPhiTracksAtEcalVsR_ ->Fill (mcConvR_, fabs(dPhiTracksAtEcal));
02931                   if ( ! isRunCentrally_ ) h2_DPhiTracksAtEcalVsEta_ ->Fill (mcEta_, fabs(dPhiTracksAtEcal));
02932                   p_DPhiTracksAtEcalVsR_ ->Fill (mcConvR_, fabs(dPhiTracksAtEcal));
02933                   p_DPhiTracksAtEcalVsEta_ ->Fill (mcEta_, fabs(dPhiTracksAtEcal));
02934                   
02935                   h_DEtaTracksAtEcal_[type][0]->Fill( dEtaTracksAtEcal);
02936                   
02937                   //              std::cout << " Debug 8.5 " << std::endl;
02938                   if ( phoIsInBarrel ) {
02939                     h_DPhiTracksAtEcal_[type][1]->Fill( fabs(dPhiTracksAtEcal));
02940                     h_DEtaTracksAtEcal_[type][1]->Fill( dEtaTracksAtEcal);
02941                   }
02942                   //              std::cout << " Debug 8.6 " << std::endl;
02943                   if ( phoIsInEndcap ) {
02944                     h_DPhiTracksAtEcal_[type][2]->Fill( fabs(dPhiTracksAtEcal));
02945                     h_DEtaTracksAtEcal_[type][2]->Fill( dEtaTracksAtEcal);
02946                   }
02947                   //              std::cout << " Debug 8.7 " << std::endl;
02948                   
02949                 }
02950               }
02951 
02952 
02953               //std::cout << " Debug 9 " << std::endl;
02954 
02956               for (unsigned int i=0; i<tracks.size(); i++) {
02957                 RefToBase<reco::Track> tfrb(tracks[i] );
02958                 itAss= myAss.find( tfrb.get() );
02959                 if ( itAss == myAss.end()  ) continue;
02960 
02961                 float trkProvenance=3;
02962                 if ( tracks[0]->algoName() == "outInEcalSeededConv"  &&  tracks[1]->algoName() == "outInEcalSeededConv" ) trkProvenance=0;
02963                 if ( tracks[0]->algoName() == "inOutEcalSeededConv"  &&  tracks[1]->algoName() == "inOutEcalSeededConv" ) trkProvenance=1;
02964                 if ( ( tracks[0]->algoName() == "outInEcalSeededConv"  &&  tracks[1]->algoName() == "inOutEcalSeededConv") ||
02965                      ( tracks[1]->algoName() == "outInEcalSeededConv"  &&  tracks[0]->algoName() == "inOutEcalSeededConv") ) trkProvenance=2;
02966 
02967                 //              std::cout << " Debug 9.1 " << std::endl;
02968 
02969                 if ( ! isRunCentrally_ ) nHitsVsEta_[type] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits()) );
02970                  if ( ! isRunCentrally_ ) nHitsVsR_[type] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits()) );
02971                 p_nHitsVsEta_[type] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits()) -0.0001);
02972                 p_nHitsVsR_[type] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits()) -0.0001);
02973                 h_tkChi2_[type] ->Fill (tracks[i]->normalizedChi2() );
02974                 h_tkChi2Large_[type] ->Fill (tracks[i]->normalizedChi2() );
02975                 if ( ! isRunCentrally_ ) h2_Chi2VsEta_[0] ->Fill(  mcEta_, tracks[i]->normalizedChi2() );
02976                  if ( ! isRunCentrally_ ) h2_Chi2VsR_[0] ->Fill(  mcConvR_, tracks[i]->normalizedChi2() );
02977                 p_Chi2VsEta_[0] ->Fill(  mcEta_, tracks[i]->normalizedChi2() );
02978                 p_Chi2VsR_[0] ->Fill(  mcConvR_, tracks[i]->normalizedChi2() );
02979 
02980 
02981                 float simPt = sqrt( ((*itAss).second)->momentum().perp2() );
02982                 //              float recPt =   sqrt( aConv->tracks()[i]->innerMomentum().Perp2() ) ;
02983                 float refPt=-9999.;
02984                 float px=0, py=0;
02985 
02986                 if ( aConv->conversionVertex().isValid() ) {
02987                   reco::Track refTrack= aConv->conversionVertex().refittedTracks()[i];
02988                   px= refTrack.momentum().x() ;
02989                   py= refTrack.momentum().y() ;
02990                   refPt=sqrt (px*px + py*py );
02991 
02992                   float ptres= refPt - simPt ;
02993                   // float pterror = aConv->tracks()[i]->ptError();
02994                   float pterror =  aConv->conversionVertex().refittedTracks()[i].ptError();
02995                   if ( ! isRunCentrally_ ) {
02996                     h2_PtRecVsPtSim_[0]->Fill ( simPt, refPt);
02997                     if ( trkProvenance ==3 ) h2_PtRecVsPtSimMixProv_->Fill ( simPt, refPt);
02998                   }
02999 
03000                   h_TkPtPull_[0] ->Fill(ptres/pterror);
03001                    if ( ! isRunCentrally_ ) h2_TkPtPull_[0] ->Fill(mcEta_, ptres/pterror);
03002 
03003                   h_TkD0_[0]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
03004 
03005 
03006                   if ( fName_ != "pfPhotonValidator" &&  fName_ != "oldpfPhotonValidator" ) 
03007                     if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[0]->Fill  ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2())  );
03008 
03009                   if ( phoIsInBarrel ) {
03010                     h_TkD0_[1]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
03011                     h_TkPtPull_[1] ->Fill(ptres/pterror);
03012                     if ( ! isRunCentrally_ ) h2_PtRecVsPtSim_[1]->Fill ( simPt, refPt);
03013                     if ( fName_ != "pfPhotonValidator"  &&  fName_ != "oldpfPhotonValidator")
03014                       if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[1]->Fill  ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2())  );
03015 
03016                   }
03017                   if ( phoIsInEndcap ) {
03018                     h_TkD0_[2]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
03019                     h_TkPtPull_[2] ->Fill(ptres/pterror);
03020                     if ( ! isRunCentrally_ ) h2_PtRecVsPtSim_[2]->Fill ( simPt, refPt);
03021                     if ( fName_ != "pfPhotonValidator" &&  fName_ != "oldpfPhotonValidator")
03022                       if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[2]->Fill  ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2())  );
03023                   }
03024 
03025                 }
03026 
03027               } // end loop over track
03028             } // end analysis of two associated tracks
03029           } // end analysis of two  tracks
03030 
03031         } // loop over conversions
03032       }  // if !fastSim
03033     }  // End loop over generated particles
03034   } // End loop over simulated Photons
03035 
03036 
03037 
03038   if ( ! isRunCentrally_ ) {
03039     h_nSimPho_[0]->Fill(float(nSimPho_[0]));
03040     h_nSimPho_[1]->Fill(float(nSimPho_[1]));
03041     h_nSimConv_[0]->Fill(float(nSimConv_[0]));
03042     h_nSimConv_[1]->Fill(float(nSimConv_[1]));
03043   }
03044 
03045   if ( !fastSim_) {
03047     for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
03048       reco::Photon aPho = reco::Photon(*iPho);
03049       //    float et= aPho.superCluster()->energy()/cosh( aPho.superCluster()->eta()) ;
03050       reco::ConversionRefVector conversions = aPho.conversions();
03051       for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
03052         reco::ConversionRef aConv=conversions[iConv];
03053         double like = aConv->MVAout();
03054         if ( like < likelihoodCut_ ) continue;
03055         //std::vector<reco::TrackRef> tracks = aConv->tracks();
03056         const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
03057         if (tracks.size() < 2 ) continue;
03058 
03059         RefToBase<reco::Track> tk1 = aConv->tracks().front();
03060         RefToBase<reco::Track> tk2 = aConv->tracks().back();
03061         RefToBaseVector<reco::Track> tc1, tc2;
03062         tc1.push_back(tk1);
03063         tc2.push_back(tk2);
03064 
03065         bool  phoIsInBarrel=false;
03066         bool  phoIsInEndcap=false;
03067         if ( fabs(aPho.superCluster()->position().eta())  < 1.479 ) {
03068           phoIsInBarrel=true;
03069         } else {
03070           phoIsInEndcap=true;
03071         }
03072         //std::cout << " Debug 10 " << std::endl;
03073 
03074         if ( dCotCutOn_ ) {
03075           if ( ( fabs(mcEta_) > 1.1 && fabs (mcEta_)  < 1.4  )  &&
03076                fabs( aConv->pairCotThetaSeparation() ) > dCotHardCutValue_ )  continue;
03077           if ( fabs( aConv->pairCotThetaSeparation() ) > dCotCutValue_ ) continue;
03078         }
03079 
03080 
03081         h_RecoConvTwoTracks_[0]->Fill( aPho.eta() ) ;
03082         h_RecoConvTwoTracks_[1]->Fill( aPho.phi() );
03083         if (  aConv->conversionVertex().isValid() ) h_RecoConvTwoTracks_[2]->Fill(  aConv->conversionVertex().position().perp2() );
03084         h_RecoConvTwoTracks_[3]->Fill( aConv->conversionVertex().position().z() );
03085         h_RecoConvTwoTracks_[4]->Fill( aPho.et() ) ;
03086 
03087 
03088 
03089         int  nAssT2=0;
03090         for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
03091           // mcConvPt_= (*mcPho).fourMomentum().et();
03092           float mcPhi= (*mcPho).fourMomentum().phi();
03093           //simPV_Z = (*mcPho).primaryVertex().z();
03094           mcPhi_= phiNormalization(mcPhi);
03095           mcEta_= (*mcPho).fourMomentum().pseudoRapidity();
03096           mcEta_ = etaTransformation(mcEta_, (*mcPho).primaryVertex().z() );
03097           //mcConvR_= (*mcPho).vertex().perp();
03098           //mcConvX_= (*mcPho).vertex().x();
03099           //mcConvY_= (*mcPho).vertex().y();
03100           //mcConvZ_= (*mcPho).vertex().z();
03101           //mcConvEta_= (*mcPho).vertex().eta();
03102           //mcConvPhi_= (*mcPho).vertex().phi();
03103           if ( fabs(mcEta_) > END_HI ) continue;
03104           //        if (mcConvPt_<minPhoPtForPurity) continue;
03105           //if (fabs(mcEta_)>maxPhoEtaForPurity) continue;
03106           //if (fabs(mcConvZ_)>maxPhoZForPurity) continue;
03107           //if (mcConvR_>maxPhoRForEffic) continue;
03108 
03109           if (  (*mcPho).isAConversion() != 1 ) continue;
03110           if (!( ( fabs(mcEta_) <= BARL && mcConvR_ <85 )  ||
03111                  ( fabs(mcEta_) > BARL && fabs(mcEta_) <=END_HI && fabs( (*mcPho).vertex().z() ) < 210 )  ) )
03112             continue;
03113 
03114           //std::cout << " Debug 11 " << std::endl;
03115           theConvTP_.clear();
03116           for(size_t i = 0; i <  trackingParticles.size(); ++i){
03117             TrackingParticleRef tp (ElectronTPHandle,i);
03118             if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.0001   &&
03119                  fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.0001   &&
03120                  fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.0001) {
03121               theConvTP_.push_back( tp );
03122             }
03123           }
03124 
03125 
03126           if ( theConvTP_.size() < 2 )   continue;
03127 
03128           reco::RecoToSimCollection p1 =  theTrackAssociator_->associateRecoToSim(tc1,theConvTP_,&e,&esup);
03129           reco::RecoToSimCollection p2 =  theTrackAssociator_->associateRecoToSim(tc2,theConvTP_,&e,&esup);
03130           std::vector<std::pair<RefToBase<reco::Track>, double> > trackV1, trackV2;
03131           try {
03132           std::vector<std::pair<TrackingParticleRef, double> > tp1 = p1[tk1];
03133           std::vector<std::pair<TrackingParticleRef, double> > tp2 = p2[tk2];
03134 
03135           if (tp1.size()&&tp2.size()) {
03136             TrackingParticleRef tpr1 = tp1.front().first;
03137             TrackingParticleRef tpr2 = tp2.front().first;
03138 
03139             if (abs(tpr1->pdgId())==11&&abs(tpr2->pdgId())==11) {
03140               if ( (tpr1->parentVertex()->sourceTracks_end()-tpr1->parentVertex()->sourceTracks_begin()==1) &&
03141                    (tpr2->parentVertex()->sourceTracks_end()-tpr2->parentVertex()->sourceTracks_begin()==1)) {
03142                 if (tpr1->parentVertex().key()==tpr2->parentVertex().key() && ((*tpr1->parentVertex()->sourceTracks_begin())->pdgId()==22)) {
03143                   //              std::cout << " ciao 5.6 " << std::endl;
03144                   //            mcConvR_ = sqrt(tpr1->parentVertex()->position().Perp2());
03145                   //mcConvZ_ = tpr1->parentVertex()->position().z();
03146                   //mcConvX_ = tpr1->parentVertex()->position().x();
03147                   //mcConvY_ = tpr1->parentVertex()->position().y();
03148                   //mcConvEta_ = tpr1->parentVertex()->position().eta();
03149                   //mcConvPhi_ = tpr1->parentVertex()->position().phi();
03150                   //mcConvPt_ = sqrt((*tpr1->parentVertex()->sourceTracks_begin())->momentum().Perp2());
03151                   //std::cout << " Reco to Sim mcconvpt " << mcConvPt_ << std::endl;
03152                   //cout << "associated track1 to " << tpr1->pdgId() << " with p=" << tpr1->p4() << " with pT=" << tpr1->pt() << endl;
03153                   //cout << "associated track2 to " << tpr2->pdgId() << " with p=" << tpr2->p4() << " with pT=" << tpr2->pt() << endl;
03154                   nAssT2 = 2;
03155                   break;
03156                 }
03157               }
03158             }
03159           }
03160 
03161           } catch (Exception event) {
03162             //cout << "do not continue: " << event.what()  << endl;
03163             //continue;
03164           }
03165 
03166         } // end loop over simulated photons
03167 
03168 
03169 
03170           /*
03171           TrackingParticleRef myTP;
03172           for (size_t j = 0; j < RtoSCollPtrs.size(); j++) {
03173             reco::RecoToSimCollection q = *(RtoSCollPtrs[j]);
03174 
03175             RefToBase<reco::Track> myTk( track );
03176 
03177             if( q.find(myTk ) != q.end() ) {
03178               std::vector<std::pair<TrackingParticleRef, double> > tp = q[myTk];
03179               for (unsigned int itp=0; itp<tp.size(); itp++) {
03180                 myTP=tp[itp].first;
03181                 //            std::cout << " associated with TP " << myTP->pdgId() << " pt " << sqrt(myTP->momentum().perp2()) << std::endl;
03182                 myAss.insert( std::make_pair ( track  , myTP) );
03183                 nAssT2++;
03184               }
03185             }
03186           }
03187           */
03188 
03189           if ( nAssT2 == 2) {
03190 
03191 
03192             h_RecoConvTwoMTracks_[0]->Fill( aPho.eta() ) ;
03193             h_RecoConvTwoMTracks_[1]->Fill( aPho.phi() );
03194             if (  aConv->conversionVertex().isValid() ) h_RecoConvTwoMTracks_[2]->Fill(  aConv->conversionVertex().position().perp2() );
03195             h_RecoConvTwoMTracks_[3]->Fill( aConv->conversionVertex().position().z() );
03196             h_RecoConvTwoMTracks_[4]->Fill( aPho.et() ) ;
03197 
03198           }
03199 
03200 
03202         if ( aConv->conversionVertex().isValid() ) {
03203           // std::cout << " Debug 11.1 " << std::endl;
03204 
03205           float chi2Prob = ChiSquaredProbability( aConv->conversionVertex().chi2(),  aConv->conversionVertex().ndof() );
03206           double convR= sqrt(aConv->conversionVertex().position().perp2());
03207           double scalar = aConv->conversionVertex().position().x()*aConv->pairMomentum().x() +
03208             aConv->conversionVertex().position().y()*aConv->pairMomentum().y();
03209 
03210           //std::cout << " Debug 11.2 " << std::endl;
03211 
03212           if ( scalar < 0 ) convR= -sqrt(aConv->conversionVertex().position().perp2());
03213           h_convVtxRvsZ_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  sqrt(aConv->conversionVertex().position().perp2())  ) ;
03214 
03215           if (aConv->caloCluster().size() !=0) {
03216             if ( ! isRunCentrally_ ) h2_etaVsRreco_[0]->Fill (aConv->caloCluster()[0]->eta(),sqrt(aConv->conversionVertex().position().perp2()) );
03217             if ( fabs(aConv->caloCluster()[0]->eta() ) <= 1.) {
03218               
03219               h_convVtxYvsX_ ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x()  ) ;
03220               h_convVtxRvsZ_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR  ) ;
03221               
03222               if ( ! isRunCentrally_ ) {
03223                 h_convVtxYvsX_zoom_[0] ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x()  ) ;
03224                 h_convVtxYvsX_zoom_[1] ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x()  ) ;
03225                 h_convVtxRvsZ_zoom_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR  ) ;
03226                 h_convVtxRvsZ_zoom_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR ) ;
03227               }
03228 
03229             }
03230             if ( fabs(aConv->caloCluster()[0]->eta() ) > 1.)      h_convVtxRvsZ_[2] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR  ) ;
03231           }
03232 
03233           //std::cout << " Debug 12 " << std::endl;
03234 
03235           h_vtxChi2Prob_[0]->Fill( chi2Prob );
03236           h_vtxChi2_[0]->Fill(  aConv->conversionVertex().normalizedChi2() );
03237           if ( phoIsInBarrel ) {
03238             h_vtxChi2Prob_[1]->Fill( chi2Prob );
03239             h_vtxChi2_[1]->Fill( aConv->conversionVertex().normalizedChi2() );
03240           }
03241           if ( phoIsInEndcap ) {
03242             h_vtxChi2Prob_[2]->Fill(  chi2Prob );
03243             h_vtxChi2_[2]->Fill( aConv->conversionVertex().normalizedChi2() );
03244           }
03245 
03246           //std::cout << " Debug 13 " << std::endl;
03247 
03248 
03249         } // end conversion vertex valid
03250       } // end loop over reco conversions
03251     } // end loop on all reco photons
03252   } // if !fastSim
03253 
03254 
03255 
03257   float nPho=0;
03258   for (reco::GenJetCollection::const_iterator genJetIter = genJetCollection.begin();
03259        genJetIter != genJetCollection.end();     ++genJetIter) {
03260 
03261     if ( genJetIter->pt() < minPhoEtCut_ ) continue;
03262     if ( fabs(genJetIter->eta())  > 2.5 ) continue;
03263 
03264     float mcJetPhi= genJetIter->phi();
03265     mcJetPhi_= phiNormalization(mcJetPhi);
03266     mcJetEta_= genJetIter->eta();
03267     float mcJetPt = genJetIter->pt() ;
03268 
03269     //std::cout << " Debug 14 " << std::endl;
03270 
03271     h_SimJet_[0]->Fill ( mcJetEta_);
03272     h_SimJet_[1]->Fill ( mcJetPhi_);
03273     h_SimJet_[2]->Fill ( mcJetPt );
03274 
03275     std::vector<reco::Photon> thePhotons;
03276     bool matched=false;
03277 
03278     reco::Photon matchingPho;
03279     for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
03280       reco::Photon aPho = reco::Photon(*iPho);
03281       float phiPho=aPho.phi();
03282       float etaPho=aPho.eta();
03283       float deltaPhi = phiPho-mcJetPhi_;
03284       float deltaEta = etaPho-mcJetEta_;
03285       if ( deltaPhi > pi )  deltaPhi -= twopi;
03286       if ( deltaPhi < -pi) deltaPhi += twopi;
03287       deltaPhi=pow(deltaPhi,2);
03288       deltaEta=pow(deltaEta,2);
03289       float delta = sqrt( deltaPhi+deltaEta);
03290       if ( delta<0.3 ) {
03291         matchingPho = * iPho;
03292         matched = true;
03293       }
03294     }  // end loop over reco photons
03295 
03296     //std::cout << " Debug 15 " << std::endl;
03297 
03298     if (!  matched ) continue;
03299     nPho++;
03300 
03301     h_MatchedSimJet_[0]->Fill( mcJetEta_ ) ;
03302     h_MatchedSimJet_[1]->Fill( mcJetPhi_ );
03303     h_MatchedSimJet_[2]->Fill( mcJetPt );
03304 
03305 
03306     bool  phoIsInBarrel=false;
03307     bool  phoIsInEndcap=false;
03308     if ( fabs(matchingPho.superCluster()->position().eta() ) < 1.479 ) {
03309       phoIsInBarrel=true;
03310     } else {
03311       phoIsInEndcap=true;
03312     }
03313     edm::Handle<EcalRecHitCollection>   ecalRecHitHandle;
03314     if ( phoIsInBarrel ) {
03315       // Get handle to rec hits ecal barrel
03316       e.getByLabel(barrelEcalHits_, ecalRecHitHandle);
03317       if (!ecalRecHitHandle.isValid()) {
03318         edm::LogError("PhotonProducer") << "Error! Can't get the product "<<barrelEcalHits_.label();
03319         return;
03320       }
03321 
03322     } else if ( phoIsInEndcap ) {
03323 
03324       // Get handle to rec hits ecal encap
03325       e.getByLabel(endcapEcalHits_, ecalRecHitHandle);
03326       if (!ecalRecHitHandle.isValid()) {
03327         edm::LogError("PhotonProducer") << "Error! Can't get the product "<<endcapEcalHits_.label();
03328         return;
03329       }
03330 
03331     }
03332 
03333     //std::cout << " Debug 16 " << std::endl;
03334 
03335     const EcalRecHitCollection ecalRecHitCollection = *(ecalRecHitHandle.product());
03336     float photonE = matchingPho.energy();
03337     float photonEt= matchingPho.et();
03338     float r9 = matchingPho.r9();
03339     float r1 = matchingPho.r1x5();
03340     float r2 = matchingPho.r2x5();
03341     float sigmaIetaIeta =  matchingPho.sigmaIetaIeta();
03342     float hOverE = matchingPho.hadronicOverEm();
03343     float ecalIso = matchingPho.ecalRecHitSumEtConeDR04();
03344     float hcalIso = matchingPho.hcalTowerSumEtConeDR04();
03345     float trkIso =  matchingPho.trkSumPtSolidConeDR04();
03346     float nIsoTrk   =  matchingPho.nTrkSolidConeDR04();
03347     std::vector< std::pair<DetId, float> >::const_iterator rhIt;
03348 
03349     bool atLeastOneDeadChannel=false;
03350       for(reco::CaloCluster_iterator bcIt = matchingPho.superCluster()->clustersBegin();bcIt != matchingPho.superCluster()->clustersEnd(); ++bcIt) {
03351         for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
03352 
03353           for(EcalRecHitCollection::const_iterator it =  ecalRecHitCollection.begin(); it !=  ecalRecHitCollection.end(); ++it) {
03354             if  (rhIt->first ==  (*it).id() ) {
03355               if (  (*it).recoFlag() == 9 ) {
03356                 atLeastOneDeadChannel=true;
03357                 break;
03358               }
03359             }
03360           }
03361         }
03362       }
03363 
03364       if (   atLeastOneDeadChannel ) {
03365         h_MatchedSimJetBadCh_[0]->Fill( mcJetEta_ ) ;
03366         h_MatchedSimJetBadCh_[1]->Fill( mcJetPhi_ );
03367         h_MatchedSimJetBadCh_[2]->Fill( mcJetPt );
03368 
03369       }
03370 
03371       h_scBkgEta_->Fill( matchingPho.superCluster()->eta() );
03372       h_scBkgPhi_->Fill( matchingPho.superCluster()->phi() );
03373       h_scBkgE_[0]->Fill( matchingPho.superCluster()->energy() );
03374       h_scBkgEt_[0]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
03375       //
03376       h_phoBkgEta_->Fill( matchingPho.eta() );
03377       h_phoBkgPhi_->Fill( matchingPho.phi() );
03378       h_phoBkgE_[0]->Fill( photonE );
03379       h_phoBkgEt_[0]->Fill( photonEt);
03380       h_phoBkgDEta_->Fill (  matchingPho.eta() - mcJetEta_ );
03381       h_phoBkgDPhi_->Fill (  matchingPho.phi() - mcJetPhi_ );
03382 
03383       //std::cout << " Debug 17 " << std::endl;
03384 
03385       h_r9Bkg_[0]->Fill( r9 );
03386       h_r1Bkg_[0]->Fill( r1 );
03387       h_r2Bkg_[0]->Fill( r2 );
03388       h_sigmaIetaIetaBkg_[0]->Fill( sigmaIetaIeta );
03389       h_hOverEBkg_[0]->Fill( hOverE );
03390       h_ecalRecHitSumEtConeDR04Bkg_[0]->Fill( ecalIso );
03391       h_hcalTowerSumEtConeDR04Bkg_[0]->Fill( hcalIso );
03392       h_isoTrkSolidConeDR04Bkg_[0]->Fill( trkIso );
03393       h_nTrkSolidConeDR04Bkg_[0]->Fill( nIsoTrk );
03394 
03395       if ( ! isRunCentrally_ ) {
03396 
03397         h2_r9VsEtaBkg_ -> Fill (mcJetEta_, r9);
03398         h2_r9VsEtBkg_ -> Fill (mcJetPt, r9);
03399         h2_r1VsEtaBkg_ -> Fill (mcJetEta_, r1);
03400         h2_r1VsEtBkg_ -> Fill (mcJetPt, r1);
03401         h2_r2VsEtaBkg_ -> Fill (mcJetEta_, r2);
03402         h2_r2VsEtBkg_ -> Fill (mcJetPt, r2);
03403         h2_sigmaIetaIetaVsEtaBkg_ -> Fill (mcJetEta_, sigmaIetaIeta );
03404         h2_sigmaIetaIetaVsEtBkg_[0] -> Fill (mcJetPt, sigmaIetaIeta);
03405         h2_hOverEVsEtaBkg_ -> Fill (mcJetEta_, hOverE );
03406         h2_hOverEVsEtBkg_ -> Fill (mcJetPt, hOverE);
03407 
03408         p_r1VsEtaBkg_ -> Fill (mcJetEta_, r1);
03409         p_r1VsEtBkg_ -> Fill (mcJetPt, r1);
03410         p_r2VsEtaBkg_ -> Fill (mcJetEta_, r2);
03411         p_r2VsEtBkg_ -> Fill (mcJetPt, r2);
03412         p_sigmaIetaIetaVsEtaBkg_ -> Fill (mcJetEta_, sigmaIetaIeta );
03413         p_sigmaIetaIetaVsEtBkg_[0] -> Fill (mcJetPt, sigmaIetaIeta);
03414         p_hOverEVsEtaBkg_ -> Fill (mcJetEta_, hOverE );
03415         p_hOverEVsEtBkg_ -> Fill (mcJetPt, hOverE);
03416 
03417       }
03418 
03419 
03420       if ( ! isRunCentrally_ ) {
03421         h2_ecalRecHitSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, ecalIso );
03422         h2_ecalRecHitSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, ecalIso);
03423         h2_hcalTowerSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, hcalIso );
03424         h2_hcalTowerSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, hcalIso);
03425         p_ecalRecHitSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, ecalIso );
03426         p_ecalRecHitSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, ecalIso);
03427         p_hcalTowerSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, hcalIso );
03428         p_hcalTowerSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, hcalIso);
03429         p_isoTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, trkIso );
03430         p_isoTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, trkIso);
03431         p_nTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, nIsoTrk );
03432         p_nTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, nIsoTrk);
03433         h2_isoTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, trkIso );
03434         h2_isoTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, trkIso);
03435         h2_nTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, nIsoTrk );
03436         h2_nTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, nIsoTrk);
03437 
03438       }
03439 
03440 
03441       if ( phoIsInBarrel ) {
03442 
03443         h_r9Bkg_[1]->Fill( r9 );
03444         h_r1Bkg_[1]->Fill( r1 );
03445         h_r2Bkg_[1]->Fill( r2 );
03446 
03447 
03448         h_sigmaIetaIetaBkg_[1]->Fill( sigmaIetaIeta );
03449         h_hOverEBkg_[1]->Fill( hOverE );
03450         h_ecalRecHitSumEtConeDR04Bkg_[1]->Fill( ecalIso );
03451         h_hcalTowerSumEtConeDR04Bkg_[1]->Fill( hcalIso );
03452         h_isoTrkSolidConeDR04Bkg_[1]->Fill( trkIso );
03453         h_nTrkSolidConeDR04Bkg_[1]->Fill( nIsoTrk );
03454 
03455         if ( ! isRunCentrally_ ) {
03456           h2_sigmaIetaIetaVsEtBkg_[1] -> Fill (mcJetPt, sigmaIetaIeta);
03457           h2_isoTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, trkIso);
03458           h2_nTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, nIsoTrk);
03459           h2_ecalRecHitSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, ecalIso);
03460           h2_hcalTowerSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, hcalIso);
03461           p_sigmaIetaIetaVsEtBkg_[1] -> Fill (mcJetPt, sigmaIetaIeta);
03462           p_ecalRecHitSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, ecalIso);
03463           p_hcalTowerSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, hcalIso);
03464           p_isoTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, trkIso);
03465           p_nTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, nIsoTrk);
03466         }
03467         //std::cout << " Debug 20 " << std::endl;
03468 
03469       } else if ( phoIsInEndcap )  {
03470 
03471         h_r9Bkg_[2]->Fill( r9 );
03472         h_r1Bkg_[2]->Fill( r1 );
03473         h_r2Bkg_[2]->Fill( r2 );
03474 
03475         h_sigmaIetaIetaBkg_[2]->Fill( sigmaIetaIeta );
03476         h_hOverEBkg_[2]->Fill( hOverE );
03477         h_ecalRecHitSumEtConeDR04Bkg_[2]->Fill( ecalIso );
03478         h_hcalTowerSumEtConeDR04Bkg_[2]->Fill( hcalIso );
03479         h_isoTrkSolidConeDR04Bkg_[2]->Fill( trkIso );
03480         h_nTrkSolidConeDR04Bkg_[2]->Fill( nIsoTrk );
03481 
03482         if ( ! isRunCentrally_ ) {
03483           h2_sigmaIetaIetaVsEtBkg_[2] -> Fill (mcJetPt, sigmaIetaIeta);
03484           h2_isoTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, trkIso);
03485           h2_nTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, nIsoTrk);
03486           h2_ecalRecHitSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, ecalIso);
03487           h2_hcalTowerSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, hcalIso);
03488           p_sigmaIetaIetaVsEtBkg_[2] -> Fill (mcJetPt, sigmaIetaIeta);
03489           p_ecalRecHitSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, ecalIso);
03490           p_hcalTowerSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, hcalIso);
03491           p_isoTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, trkIso);
03492           p_nTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, nIsoTrk);
03493         }
03494         //std::cout << " Debug 21 " << std::endl;
03495 
03496       }
03497 
03498       if ( !fastSim_) {
03500         reco::ConversionRefVector conversions = matchingPho.conversions();
03501         for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
03502           reco::ConversionRef aConv=conversions[iConv];
03503           //std::vector<reco::TrackRef> tracks = aConv->tracks();
03504           const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
03505           double like = aConv->MVAout();
03506           if ( like < likelihoodCut_ ) continue;
03507           if ( tracks.size() < 2 ) continue;
03508           if (aConv->caloCluster().size() !=0) {
03509             h_convEtaBkg_->Fill( aConv->caloCluster()[0]->eta() );
03510             h_convPhiBkg_->Fill( aConv->caloCluster()[0]->phi() );
03511           }
03512           h_mvaOutBkg_[0]-> Fill(like);
03513           float eoverp= aConv->EoverP();
03514           h_EoverPTracksBkg_[0] ->Fill( eoverp ) ;
03515           h_PoverETracksBkg_[0] ->Fill( 1./eoverp ) ;
03516           h_DCotTracksBkg_[0] ->Fill ( aConv->pairCotThetaSeparation() );
03517           float  dPhiTracksAtVtx =  aConv->dPhiTracksAtVtx();
03518           h_DPhiTracksAtVtxBkg_[0]->Fill( dPhiTracksAtVtx);
03519 
03520           if ( phoIsInBarrel ) {
03521             h_mvaOutBkg_[1]-> Fill(like);
03522             h_EoverPTracksBkg_[1] ->Fill( eoverp ) ;
03523             h_PoverETracksBkg_[1] ->Fill( 1./eoverp ) ;
03524             h_DCotTracksBkg_[1] ->Fill ( aConv->pairCotThetaSeparation() );
03525             h_DPhiTracksAtVtxBkg_[1]->Fill( dPhiTracksAtVtx);
03526           }     else if ( phoIsInEndcap )  {
03527             h_mvaOutBkg_[2]-> Fill(like);
03528             h_EoverPTracksBkg_[2] ->Fill( eoverp ) ;
03529             h_PoverETracksBkg_[2] ->Fill( 1./eoverp ) ;
03530             h_DCotTracksBkg_[2] ->Fill ( aConv->pairCotThetaSeparation() );
03531             h_DPhiTracksAtVtxBkg_[2]->Fill( dPhiTracksAtVtx);
03532           }
03533 
03534           if ( aConv->conversionVertex().isValid() ) {
03535 
03536             double convR= sqrt(aConv->conversionVertex().position().perp2());
03537             double scalar = aConv->conversionVertex().position().x()*aConv->pairMomentum().x() +
03538               aConv->conversionVertex().position().y()*aConv->pairMomentum().y();
03539             if ( scalar < 0 ) convR= -sqrt(aConv->conversionVertex().position().perp2());
03540 
03541             if ( ! isRunCentrally_ ) {
03542               h_convVtxRvsZBkg_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  sqrt(aConv->conversionVertex().position().perp2())  ) ;
03543               if ( aConv->caloCluster().size() !=0 && fabs(aConv->caloCluster()[0]->eta() )  <= 1. ) {
03544                 h_convVtxYvsXBkg_ ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x()  ) ;
03545                 h_convVtxRvsZBkg_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR  ) ;
03546               }
03547             }
03548 
03549 
03550           } // end vertex valid
03551 
03552 
03553         } // end loop over conversions
03554       } // if !fastSim
03555   } // end loop over sim jets
03556 
03557   h_nPho_->Fill(float(nPho));
03558 
03559 }
03560 
03561 
03562 
03563 
03564 
03565 void PhotonValidator::endJob() {
03566 
03567 
03568   std::string outputFileName = parameters_.getParameter<std::string>("OutputFileName");
03569   if ( ! isRunCentrally_ ) {
03570     dbe_->save(outputFileName);
03571   }
03572 
03573   edm::LogInfo("PhotonValidator") << "Analyzed " << nEvt_  << "\n";
03574   // std::cout  << "::endJob Analyzed " << nEvt_ << " events " << " with total " << nPho_ << " Photons " << "\n";
03575   //  std::cout  << "PhotonValidator::endJob Analyzed " << nEvt_ << " events " << "\n";
03576 
03577   return ;
03578 }
03579 
03580 float PhotonValidator::phiNormalization(float & phi)
03581 {
03582   //---Definitions
03583   const float PI    = 3.1415927;
03584   const float TWOPI = 2.0*PI;
03585 
03586 
03587   if(phi >  PI) {phi = phi - TWOPI;}
03588   if(phi < -PI) {phi = phi + TWOPI;}
03589 
03590   //  cout << " Float_t PHInormalization out " << PHI << endl;
03591   return phi;
03592 
03593 }
03594 
03595 
03596 float PhotonValidator::etaTransformation(  float EtaParticle , float Zvertex)  {
03597 
03598   //---Definitions
03599   const float PI    = 3.1415927;
03600 
03601   //---Definitions for ECAL
03602   const float R_ECAL           = 136.5;
03603   const float Z_Endcap         = 328.0;
03604   const float etaBarrelEndcap  = 1.479;
03605 
03606   //---ETA correction
03607 
03608   float Theta = 0.0  ;
03609   float ZEcal = R_ECAL*sinh(EtaParticle)+Zvertex;
03610 
03611   if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
03612   if(Theta<0.0) Theta = Theta+PI ;
03613   float ETA = - log(tan(0.5*Theta));
03614 
03615   if( fabs(ETA) > etaBarrelEndcap )
03616     {
03617       float Zend = Z_Endcap ;
03618       if(EtaParticle<0.0 )  Zend = -Zend ;
03619       float Zlen = Zend - Zvertex ;
03620       float RR = Zlen/sinh(EtaParticle);
03621       Theta = atan(RR/Zend);
03622       if(Theta<0.0) Theta = Theta+PI ;
03623       ETA = - log(tan(0.5*Theta));
03624     }
03625   //---Return the result
03626   return ETA;
03627   //---end
03628 }
03629 
03630