CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/Validation/RecoEgamma/plugins/PhotonValidator.cc

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