CMS 3D CMS Logo

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