CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/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     h_zPVFromTracks_[1] =  dbe_->book1D("zPVFromTracks"," Photons: PV z from conversion tracks",100, -25., 25.);
01165     h_dzPVFromTracks_[1] =  dbe_->book1D("dzPVFromTracks"," Photons: PV Z_rec - Z_true from conversion tracks",100, -5., 5.);
01166     p_dzPVVsR_ =  dbe_->bookProfile("pdzPVVsR","Photon Reco conversions: dz(PV) vs R" ,rBin,rMin, rMax, 100, -3.,3.,"");
01167 
01168     if ( ! isRunCentrally_ ) {
01169       h2_dzPVVsR_ =  dbe_->book2D("h2dzPVVsR","Photon Reco conversions: dz(PV) vs R" ,rBin,rMin, rMax,100, -3.,3.);
01170     }
01171 
01173     if ( ! isRunCentrally_ ) {
01174       histname="nHitsVsEta";
01175       nHitsVsEta_[0] =  dbe_->book2D(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs #eta all tracks",etaBin,etaMin, etaMax,25,0., 25.);
01176       
01177       histname="nHitsVsEta";
01178       nHitsVsEta_[1] =  dbe_->book2D(histname+"AssTracks","Photons:Tracks from conversions: # of hits vs #eta associated tracks",etaBin,etaMin, etaMax,25,0., 25.);
01179       
01180       histname="nHitsVsR";
01181       nHitsVsR_[0] =  dbe_->book2D(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs radius all tracks" ,rBin,rMin, rMax,25,0.,25);
01182       
01183       histname="nHitsVsR";
01184       nHitsVsR_[1] =  dbe_->book2D(histname+"AssTracks","Photons:Tracks from conversions: # of hits vs radius associated tracks" ,rBin,rMin, rMax,25,0.,25);
01185       
01186       histname="h2Chi2VsEta";
01187       h2_Chi2VsEta_[0]=dbe_->book2D(histname+"All"," Reco Track  #chi^{2} vs #eta: All ",etaBin2,etaMin, etaMax,100, chi2Min, chi2Max); 
01188 
01189       
01190       histname="h2Chi2VsR";
01191       h2_Chi2VsR_[0]=dbe_->book2D(histname+"All"," Reco Track  #chi^{2} vs R: All ",rBin,rMin, rMax,100,chi2Min, chi2Max);
01192     }
01193 
01194     histname="h_nHitsVsEta";
01195     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,"");
01196 
01197     histname="h_nHitsVsEta";
01198     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,"");
01199 
01200 
01201     histname="h_nHitsVsR";
01202     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,"");
01203     histname="tkChi2";
01204     h_tkChi2_[0] = dbe_->book1D(histname+"AllTracks","Photons:Tracks from conversions: #chi^{2} of all tracks", 100, chi2Min, chi2Max);  
01205     histname="tkChi2Large";
01206     h_tkChi2Large_[0] = dbe_->book1D(histname+"AllTracks","Photons:Tracks from conversions: #chi^{2} of all tracks", 1000, 0., 5000.0); 
01207 
01208     histname="h_nHitsVsR";
01209     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,"");
01210 
01211     histname="tkChi2";
01212     h_tkChi2_[1] = dbe_->book1D(histname+"AssTracks","Photons:Tracks from conversions: #chi^{2} of associated  tracks", 100, chi2Min, chi2Max); 
01213     histname="tkChi2Large";
01214     h_tkChi2Large_[1] = dbe_->book1D(histname+"AssTracks","Photons:Tracks from conversions: #chi^{2} of associated  tracks", 1000, 0., 5000.0); 
01215 
01216     histname="pChi2VsEta";
01217     p_Chi2VsEta_[0]=dbe_->bookProfile(histname+"All"," Reco Track #chi^{2} vs #eta : All ",etaBin2,etaMin, etaMax, 100, chi2Min, chi2Max,""); 
01218 
01219     histname="pChi2VsR";
01220     p_Chi2VsR_[0]=dbe_->bookProfile(histname+"All"," Reco Track #chi^{2} vas R : All ",rBin,rMin,rMax, 100,chi2Min, chi2Max,"");
01221 
01222 
01223     histname="hTkD0";
01224     h_TkD0_[0]=dbe_->book1D(histname+"All"," Reco Track D0*q: All ",100,-0.1,0.6);
01225     h_TkD0_[1]=dbe_->book1D(histname+"Barrel"," Reco Track D0*q: Barrel ",100,-0.1,0.6);
01226     h_TkD0_[2]=dbe_->book1D(histname+"Endcap"," Reco Track D0*q: Endcap ",100,-0.1,0.6);
01227 
01228 
01229     histname="hTkPtPull";
01230     h_TkPtPull_[0]=dbe_->book1D(histname+"All"," Reco Track Pt pull: All ",100, -10., 10.);
01231     histname="hTkPtPull";
01232     h_TkPtPull_[1]=dbe_->book1D(histname+"Barrel"," Reco Track Pt pull: Barrel ",100, -10., 10.);
01233     histname="hTkPtPull";
01234     h_TkPtPull_[2]=dbe_->book1D(histname+"Endcap"," Reco Track Pt pull: Endcap ",100, -10., 10.);
01235 
01236     histname="pTkPtPullEta";
01237     p_TkPtPull_[0]=dbe_->bookProfile(histname+"All"," Reco Track Pt pull: All ",etaBin2,etaMin, etaMax, 100, -10., 10., " ");
01238 
01239     if ( ! isRunCentrally_ ) {
01240       histname="h2TkPtPullEta";
01241       h2_TkPtPull_[0]=dbe_->book2D(histname+"All"," Reco Track Pt pull: All ",etaBin2,etaMin, etaMax,100, -10., 10.);
01242 
01243       histname="PtRecVsPtSim";
01244       h2_PtRecVsPtSim_[0]=dbe_->book2D(histname+"All", "Pt Rec vs Pt sim: All ", etBin,etMin,etMax,etBin,etMin, etMax);
01245       h2_PtRecVsPtSim_[1]=dbe_->book2D(histname+"Barrel", "Pt Rec vs Pt sim: Barrel ", etBin,etMin,etMax,etBin,etMin, etMax);
01246       h2_PtRecVsPtSim_[2]=dbe_->book2D(histname+"Endcap", "Pt Rec vs Pt sim: Endcap ", etBin,etMin,etMax,etBin,etMin, etMax);
01247       histname="PtRecVsPtSimMixProv";
01248       h2_PtRecVsPtSimMixProv_ =dbe_->book2D(histname+"All", "Pt Rec vs Pt sim All for mix with general tracks ", etBin,etMin,etMax,etBin,etMin, etMax);
01249     }
01250 
01251 
01252     histname="eBcOverTkPout";
01253     hBCEnergyOverTrackPout_[0] = dbe_->book1D(histname+"All","Matrching BC E/P_out: all Ecal ",100, 0., 5.);
01254     hBCEnergyOverTrackPout_[1] = dbe_->book1D(histname+"Barrel","Matrching BC E/P_out: Barrel ",100, 0., 5.);
01255     hBCEnergyOverTrackPout_[2] = dbe_->book1D(histname+"Endcap","Matrching BC E/P_out: Endcap ",100, 0., 5.);
01256     
01257 
01259     h_OIinnermostHitR_ = dbe_->book1D("OIinnermostHitR"," R innermost hit for OI tracks ",50, 0., 25);
01260     h_IOinnermostHitR_ = dbe_->book1D("IOinnermostHitR"," R innermost hit for IO tracks ",50, 0., 25);
01261 
01263     h_trkProv_[0] = dbe_->book1D("allTrkProv"," Track pair provenance ",4, 0., 4.);
01264     h_trkProv_[1] = dbe_->book1D("assTrkProv"," Track pair provenance ",4, 0., 4.);
01265 
01266     // histos for fake rate
01267     histname = "h_RecoConvTwoTracksEta";
01268     h_RecoConvTwoTracks_[0] =  dbe_->book1D(histname," All reco conversions with 2 reco  tracks: simulated #eta",etaBin2,etaMin, etaMax);
01269     histname = "h_RecoConvTwoTracksPhi";
01270     h_RecoConvTwoTracks_[1] =  dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated #phi",phiBin,phiMin, phiMax);
01271     histname = "h_RecoConvTwoTracksR";
01272     h_RecoConvTwoTracks_[2] =  dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated R",rBin,rMin, rMax);
01273     histname = "h_RecoConvTwoTracksZ";
01274     h_RecoConvTwoTracks_[3] =  dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated Z",zBin,zMin, zMax);
01275     histname = "h_RecoConvTwoTracksEt";
01276     h_RecoConvTwoTracks_[4] =  dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated Et",etBin,etMin, etMax);
01277     //
01278     histname = "h_RecoConvTwoMTracksEta";
01279     h_RecoConvTwoMTracks_[0] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated #eta",etaBin2,etaMin, etaMax);
01280     histname = "h_RecoConvTwoMTracksPhi";
01281     h_RecoConvTwoMTracks_[1] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated #phi",phiBin,phiMin, phiMax);
01282     histname = "h_RecoConvTwoMTracksR";
01283     h_RecoConvTwoMTracks_[2] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated R",rBin,rMin, rMax);
01284     histname = "h_RecoConvTwoMTracksZ";
01285     h_RecoConvTwoMTracks_[3] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated Z",zBin,zMin, zMax);
01286     histname = "h_RecoConvTwoMTracksEt";
01287     h_RecoConvTwoMTracks_[4] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated Et",etBin,etMin, etMax);
01288 
01289 
01290 
01291 
01292   } // if DQM 
01293 
01294 
01295 
01296 }
01297 
01298 
01299 
01300  void  PhotonValidator::beginRun (edm::Run const & r, edm::EventSetup const & theEventSetup) {
01301    
01302    //get magnetic field
01303   edm::LogInfo("ConvertedPhotonProducer") << " get magnetic field" << "\n";
01304   theEventSetup.get<IdealMagneticFieldRecord>().get(theMF_);  
01305 
01306 
01307   edm::ESHandle<TrackAssociatorBase> theHitsAssociator;
01308   theEventSetup.get<TrackAssociatorRecord>().get("TrackAssociatorByHits",theHitsAssociator);
01309   theTrackAssociator_ = (TrackAssociatorBase *) theHitsAssociator.product();
01310 
01311   thePhotonMCTruthFinder_ = new PhotonMCTruthFinder();  
01312 
01313 }
01314 
01315 void  PhotonValidator::endRun (edm::Run& r, edm::EventSetup const & theEventSetup) {
01316 
01317   delete thePhotonMCTruthFinder_;
01318 
01319 }
01320 
01321 
01322 
01323 void PhotonValidator::analyze( const edm::Event& e, const edm::EventSetup& esup ) {
01324   
01325   
01326   using namespace edm;
01327   //  const float etaPhiDistance=0.01;
01328   // Fiducial region
01329   // const float TRK_BARL =0.9;
01330   const float BARL = 1.4442; // DAQ TDR p.290
01331   //  const float END_LO = 1.566; // unused
01332   const float END_HI = 2.5;
01333   // Electron mass
01334   //const Float_t mElec= 0.000511;
01335 
01336 
01337   nEvt_++;  
01338   LogInfo("PhotonValidator") << "PhotonValidator Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n";
01339   //  std::cout << "PhotonValidator Analyzing event number: "  << e.id() << " Global Counter " << nEvt_ <<"\n";
01340 
01341 
01342   // get the geometry from the event setup:
01343   esup.get<CaloGeometryRecord>().get(theCaloGeom_);
01344 
01345 
01346   // Transform Track into TransientTrack (needed by the Vertex fitter)
01347   edm::ESHandle<TransientTrackBuilder> theTTB;
01348   esup.get<TransientTrackRecord>().get("TransientTrackBuilder",theTTB);
01349 
01350 
01352   Handle<reco::PhotonCollection> photonHandle; 
01353   e.getByLabel(photonCollectionProducer_, photonCollection_ , photonHandle);
01354   const reco::PhotonCollection photonCollection = *(photonHandle.product());
01355   if (!photonHandle.isValid()) {
01356     edm::LogError("PhotonProducer") << "Error! Can't get the Photon collection "<< std::endl;
01357     return; 
01358   }
01359 
01360   Handle< edm::View<reco::Track> > outInTrkHandle;
01361   Handle< edm::View<reco::Track> > inOutTrkHandle;
01362   if ( !fastSim_) {
01364     e.getByLabel(conversionOITrackProducer_,  outInTrkHandle);
01365     //std::cout << "ConvPhoAnalyzerWithOfficialAssociation  outInTrack collection size " << (*outInTrkHandle).size() << "\n";
01366     
01368     e.getByLabel(conversionIOTrackProducer_, inOutTrkHandle);
01369     //std::cout  << " ConvPhoAnalyzerWithOfficialAssociation inOutTrack collection size " << (*inOutTrkHandle).size() << "\n";
01370 
01371     // Loop over Out In Tracks 
01372     int iTrk=0;
01373     int nHits=0;
01374     for( View<reco::Track>::const_iterator    iTk =  (*outInTrkHandle).begin(); iTk !=  (*outInTrkHandle).end(); iTk++) {
01375       //    std::cout  << " Barrel  Out In Track charge " << iTk->charge() << " Num of RecHits " << iTk->recHitsSize() << " inner momentum " << sqrt( iTk->innerMomentum().Mag2() ) << "\n";  
01376       // std::cout  << " Barrel Out In Track Extra inner momentum  " << sqrt(iTk->extra()->innerMomentum().Mag2()) <<  " inner position R " <<  sqrt( iTk->innerPosition().Perp2() ) << "\n";  
01377       h_OIinnermostHitR_ ->Fill ( sqrt( iTk->innerPosition().Perp2() ) );
01378       for (  trackingRecHit_iterator itHits=iTk->extra()->recHitsBegin();  itHits!=iTk->extra()->recHitsEnd(); ++itHits ) {
01379         if ( (*itHits)->isValid() ) {
01380           nHits++;
01381           //    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";
01382         }
01383         
01384         
01385       }
01386       
01387       iTrk++;
01388       
01389       
01390     }
01391     
01392     // Loop over In Out Tracks Barrel
01393     iTrk=0;
01394     for( View<reco::Track>::const_iterator    iTk =  (*inOutTrkHandle).begin(); iTk !=  (*inOutTrkHandle).end(); iTk++) {
01395       //std::cout  << " Barrel In Out Track charge " << iTk->charge() << " Num of RecHits " << iTk->recHitsSize() << " inner momentum " << sqrt( iTk->innerMomentum().Mag2())  << "\n";  
01396       // std::cout   << " Barrel In Out  Track Extra inner momentum  " << sqrt(iTk->extra()->innerMomentum().Mag2()) << "\n"; 
01397       h_IOinnermostHitR_ ->Fill ( sqrt( iTk->innerPosition().Perp2() ) );  
01398       nHits=0;
01399       for (  trackingRecHit_iterator itHits=iTk->extra()->recHitsBegin();  itHits!=iTk->extra()->recHitsEnd(); ++itHits ) {
01400         if ( (*itHits)->isValid() ) {
01401           nHits++;
01402           //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";
01403           
01404         }
01405       }
01406       
01407       
01408       
01409       iTrk++;
01410     }
01411 
01412   }  // if !fastSim
01413 
01414 
01416   //get simtrack info
01417   std::vector<SimTrack> theSimTracks;
01418   std::vector<SimVertex> theSimVertices;
01419   edm::Handle<SimTrackContainer> SimTk;
01420   edm::Handle<SimVertexContainer> SimVtx;
01421 
01422   if ( ! fastSim_) {  
01423     e.getByLabel("g4SimHits",SimTk);
01424     e.getByLabel("g4SimHits",SimVtx);
01425   } else {
01426     e.getByLabel("famosSimHits",SimTk);
01427     e.getByLabel("famosSimHits",SimVtx);
01428 
01429   }
01430   
01431 
01432 
01433   theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
01434   theSimVertices.insert(theSimVertices.end(),SimVtx->begin(),SimVtx->end());
01435   std::vector<PhotonMCTruth> mcPhotons=thePhotonMCTruthFinder_->find (theSimTracks,  theSimVertices);  
01436 
01437   edm::Handle<edm::HepMCProduct> hepMC;
01438   e.getByLabel("generator",hepMC);
01439   const HepMC::GenEvent *myGenEvent = hepMC->GetEvent();
01440 
01441 
01442   // get generated jets
01443   Handle<reco::GenJetCollection> GenJetsHandle ;
01444   e.getByLabel("iterativeCone5GenJets","",GenJetsHandle);
01445   reco::GenJetCollection genJetCollection = *(GenJetsHandle.product());
01446 
01447 
01448 
01449   // Get electron tracking truth
01450   bool useTP= parameters_.getParameter<bool>("useTP"); 
01451   TrackingParticleCollection trackingParticles;
01452   edm::Handle<TrackingParticleCollection> ElectronTPHandle;
01453   if ( useTP) {
01454     if ( ! fastSim_) {
01455     e.getByLabel(label_tp_,ElectronTPHandle);
01456     //  e.getByLabel("mergedtruth","MergedTrackTruth",ElectronTPHandle);
01457     trackingParticles = *(ElectronTPHandle.product());
01458     }
01459   }
01460 
01462   std::vector<reco::PhotonCollection::const_iterator> StoRMatchedConvertedPhotons;
01463   reco::SimToRecoCollection OISimToReco;
01464   reco::SimToRecoCollection IOSimToReco;
01465   // Reco to Sim
01466   reco::RecoToSimCollection OIRecoToSim;
01467   reco::RecoToSimCollection IORecoToSim;
01468 
01469   if ( useTP) {  
01470     if ( ! fastSim_) {
01471     // Sim to Reco
01472     OISimToReco = theTrackAssociator_->associateSimToReco(outInTrkHandle, ElectronTPHandle, &e);
01473     IOSimToReco = theTrackAssociator_->associateSimToReco(inOutTrkHandle, ElectronTPHandle, &e);
01474     // Reco to Sim
01475     OIRecoToSim = theTrackAssociator_->associateRecoToSim(outInTrkHandle, ElectronTPHandle, &e);
01476     IORecoToSim = theTrackAssociator_->associateRecoToSim(inOutTrkHandle, ElectronTPHandle, &e);
01477     }
01478   }
01479   //
01480   vector<reco::SimToRecoCollection*> StoRCollPtrs;
01481   StoRCollPtrs.push_back(&OISimToReco);
01482   StoRCollPtrs.push_back(&IOSimToReco);
01483   vector<reco::RecoToSimCollection*> RtoSCollPtrs;
01484   RtoSCollPtrs.push_back(&OIRecoToSim);
01485   RtoSCollPtrs.push_back(&IORecoToSim);
01486   //
01487   for (int i=0; i<2; i++)  
01488     nSimPho_[i]=0;
01489   for (int i=0; i<2; i++)  
01490     nSimConv_[i]=0;
01491 
01492 
01493   std::vector<reco::Photon> myPhotons;
01494   for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
01495     if ( fabs(iPho->eta()) > 2.5 ) continue;
01496     myPhotons.push_back(*iPho);
01497   }
01498   
01499   std::sort(myPhotons.begin(), myPhotons.end(), sortPhotons()); 
01500   if ( myPhotons.size() >=2 ) {
01501     if ( myPhotons[0].et() > 40 && myPhotons[1].et() > 25 ) {
01502             
01503       math::XYZTLorentzVector p12 = myPhotons[0].p4()+myPhotons[1].p4();
01504       float gamgamMass2 = p12.Dot(p12);
01505       if (  gamgamMass2 > 0 ) {
01506         
01507         // total 
01508         h_gamgamMass_[0][0] -> Fill(sqrt( gamgamMass2 ));
01509         if (  myPhotons[0].isEB() &&     myPhotons[1].isEB() ) 
01510           h_gamgamMass_[0][1] -> Fill(sqrt( gamgamMass2 ));     
01511         if ( (  myPhotons[0].isEE() &&   myPhotons[1].isEE() )  ||
01512              (  myPhotons[0].isEE() &&   myPhotons[1].isEB() ) ||
01513              (  myPhotons[0].isEB() &&   myPhotons[1].isEE() ) )
01514           h_gamgamMass_[0][2] -> Fill(sqrt( gamgamMass2 ));     
01515 
01516 
01517         // Golden photons 
01518         if (  myPhotons[0].r9() > 0.93 &&  myPhotons[1].r9() > 0.93 ) {
01519           h_gamgamMass_[1][0] -> Fill(sqrt( gamgamMass2 ));
01520           if (  myPhotons[0].isEB() &&   myPhotons[1].isEB() ) 
01521             h_gamgamMass_[1][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_[1][2] -> Fill(sqrt( gamgamMass2 ));   
01526         }
01527 
01528 
01529         // both photons converted
01530         if ( myPhotons[0].conversions().size() > 0 && myPhotons[1].conversions().size() >0 ) {
01531           if ( myPhotons[0].conversions()[0]->nTracks() ==2 &&  myPhotons[1].conversions()[0]->nTracks() ==2  ) {
01532             float chi2Prob1 = ChiSquaredProbability( myPhotons[0].conversions()[0]->conversionVertex().chi2(),  myPhotons[0].conversions()[0]->conversionVertex().ndof() );
01533             float chi2Prob2 = ChiSquaredProbability( myPhotons[1].conversions()[0]->conversionVertex().chi2(),  myPhotons[1].conversions()[0]->conversionVertex().ndof() );
01534             if ( chi2Prob1 > 0.0005 &&  chi2Prob2 > 0.0005 ) {
01535               h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
01536               if (  myPhotons[0].isEB() &&       myPhotons[1].isEB() ) {
01537                 h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 )); 
01538               }
01539               if ( (  myPhotons[0].isEE() &&     myPhotons[1].isEE() )  ||
01540                    (  myPhotons[0].isEE() &&     myPhotons[1].isEB() ) ||
01541                    (  myPhotons[0].isEB() &&     myPhotons[1].isEE() ) )
01542                 h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 )); {
01543               }
01544             }
01545           }
01546 
01547 
01548         } else if ( myPhotons[0].conversions().size() > 0 && myPhotons[1].conversions().size() ==0 && myPhotons[1].r9() > 0.93  )  {    // one photon converted
01549           if ( myPhotons[0].conversions()[0]->nTracks() ==2 ) {
01550             float chi2Prob1 = ChiSquaredProbability( myPhotons[0].conversions()[0]->conversionVertex().chi2(),  myPhotons[0].conversions()[0]->conversionVertex().ndof() );
01551             if ( chi2Prob1 > 0.0005 ) {
01552               h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
01553               if (  myPhotons[0].isEB() &&  myPhotons[1].isEB() ) {
01554                 h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
01555               }
01556               if (  myPhotons[0].isEE() ||  myPhotons[1].isEE() ) {
01557                 h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 ));
01558               }
01559             }
01560           }
01561 
01562 
01563         } else if ( myPhotons[1].conversions().size() > 0 && myPhotons[0].conversions().size() ==0 &&  myPhotons[0].r9() > 0.93 )  {    // one photon converted
01564           if ( myPhotons[1].conversions()[0]->nTracks() ==2 ) {
01565             float chi2Prob1 = ChiSquaredProbability( myPhotons[1].conversions()[0]->conversionVertex().chi2(),  myPhotons[1].conversions()[0]->conversionVertex().ndof() );
01566             if ( chi2Prob1 > 0.0005 ) {
01567               h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
01568               if (  myPhotons[0].isEB() && myPhotons[1].isEB() ) {
01569                 h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
01570               }
01571               if (  myPhotons[0].isEE() ||  myPhotons[1].isEE() ) {
01572                 h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 ));
01573               }
01574             }
01575           }
01576         }
01577 
01578 
01579       }
01580     }      
01581   }
01582 
01583 
01584   //  cout << " PhotonValidator mcPhotons.size() " << mcPhotons.size() << endl;
01585   for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
01586     if ( (*mcPho).fourMomentum().et() < minPhoEtCut_ ) continue;
01587     
01588     for ( HepMC::GenEvent::particle_const_iterator mcIter=myGenEvent->particles_begin(); mcIter != myGenEvent->particles_end(); mcIter++ ) {   
01589       if ( (*mcIter)->pdg_id() != 22 ) continue;
01590       bool isTheSame= false;     
01591       HepMC::GenParticle* mother = 0;
01592       if ( (*mcIter)->production_vertex() )  {
01593         if ( (*mcIter)->production_vertex()->particles_begin(HepMC::parents) !=
01594              (*mcIter)->production_vertex()->particles_end(HepMC::parents))
01595           mother = *((*mcIter)->production_vertex()->particles_begin(HepMC::parents));
01596       }
01597       
01598       
01599       
01600       
01601       float mcPhi= (*mcPho).fourMomentum().phi();
01602       mcPhi_= phiNormalization(mcPhi);
01603       mcEta_= (*mcPho).fourMomentum().pseudoRapidity();   
01604       mcEta_ = etaTransformation(mcEta_, (*mcPho).primaryVertex().z() ); 
01605       mcConvR_= (*mcPho).vertex().perp();   
01606       mcConvX_= (*mcPho).vertex().x();    
01607       mcConvY_= (*mcPho).vertex().y();    
01608       mcConvZ_= (*mcPho).vertex().z();  
01609       mcConvEta_= (*mcPho).vertex().eta();    
01610       mcConvPhi_= (*mcPho).vertex().phi();  
01611   
01612       if ( fabs(mcEta_) > END_HI ) continue;
01613       
01614       
01615       
01616       if (  mother ==0 
01617             ||  (mother != 0  && mother->pdg_id() == 22)  
01618             ||  (mother != 0  && mother->pdg_id() == 25) 
01619             ||  (mother != 0  && mother->pdg_id() == 35) ) 
01620         { 
01621           //std::cout << " ZERO mother or Higgs or primary photon  " << std::endl;
01622           //if (mother !=0) std::cout <<  mother->pdg_id() << std::endl; 
01623           double dPt =  fabs((*mcIter)->momentum().perp() - (*mcPho).fourMomentum().et());
01624           float phiMother=(*mcIter)->momentum().phi();
01625           double dPhi = phiNormalization(phiMother) - mcPhi_ ; 
01626           double dEta = fabs( (*mcIter)->momentum().eta() - (*mcPho).fourMomentum().pseudoRapidity() );
01627           
01628           //std::cout << " HEP photon pt " << (*mcIter)->momentum().perp() << " eta " << (*mcIter)->momentum().eta() << " phi " << (*mcIter)->momentum().phi() << std::endl;
01629           //std::cout << "   (*mcPho).motherType() selection  " <<   (*mcPho).motherType() << " pt " <<  (*mcPho).fourMomentum().et()  << " eta " << (*mcPho).fourMomentum().pseudoRapidity() << " phi " << mcPhi_ << std::endl;
01630           //std::cout << " dPt " << dPt << " dEta " << dEta << " dPhi " << dPhi << std::endl;
01631           if ( dEta <=0.0001 && dPhi <=0.0001 && dPt <=0.0001) 
01632             isTheSame = true;
01633 
01634         } 
01635       if ( ! isTheSame ) continue; 
01636       //      std::cout << " HEP photon pt " << (*mcIter)->momentum().perp() << " eta " << (*mcIter)->momentum().eta() << " phi " << (*mcIter)->momentum().phi() << std::endl;
01637       //std::cout << "   (*mcPho).motherType() after  " <<   (*mcPho).motherType() << " pt " <<  (*mcPho).fourMomentum().et()  << " eta " << (*mcPho).fourMomentum().pseudoRapidity() << " phi " << mcPhi_ << std::endl;
01638 
01639 
01640     
01641       // if ( ! (  fabs(mcEta_) <= BARL || ( fabs(mcEta_) >= END_LO && fabs(mcEta_) <=END_HI ) ) ) 
01642       //        continue;  // all ecal fiducial region
01643 
01644 
01645       nSimPho_[0]++;
01646       h_SimPhoMotherEt_[0]->Fill(  (*mcPho).motherMomentum().et()  );
01647       h_SimPhoMotherEta_[0]->Fill(  (*mcPho).motherMomentum().pseudoRapidity());
01648 
01649       h_SimPho_[0]->Fill ( mcEta_);
01650       h_SimPho_[1]->Fill ( mcPhi_);
01651       h_SimPho_[2]->Fill ( (*mcPho).fourMomentum().et()   );
01652 
01653 
01654     
01655 
01657     
01658       bool goodSimConversion=false;
01659       bool visibleConversion=false;
01660       bool visibleConversionsWithTwoSimTracks=false;
01661       if (  (*mcPho).isAConversion() == 1 ) {
01662         nSimConv_[0]++;
01663         h_AllSimConv_[0]->Fill( mcEta_ ) ;
01664         h_AllSimConv_[1]->Fill( mcPhi_ );
01665         h_AllSimConv_[2]->Fill( mcConvR_ );
01666         h_AllSimConv_[3]->Fill( mcConvZ_ );
01667         h_AllSimConv_[4]->Fill(  (*mcPho).fourMomentum().et());
01668       
01669         if ( mcConvR_ <15) h_SimConvEtaPix_[0]->Fill( mcEta_ ) ;
01670 
01671         if ( ( fabs(mcEta_) <= BARL && mcConvR_ <85 )  || 
01672              ( fabs(mcEta_) > BARL && fabs(mcEta_) <=END_HI && fabs( (*mcPho).vertex().z() ) < 210 )  ) visibleConversion=true;
01673       
01674 
01675 
01676         theConvTP_.clear(); 
01677         //std::cout << " PhotonValidator TrackingParticles   TrackingParticleCollection size "<<  trackingParticles.size() <<  "\n";
01678         for(size_t i = 0; i < trackingParticles.size(); ++i){
01679           TrackingParticleRef tp (ElectronTPHandle,i);
01680           //std::cout << "  Electron pt " << tp -> pt() << " charge " << tp -> charge() << " pdgId " << tp->pdgId() << " Hits for this track: " << tp -> trackPSimHit().size() << std::endl;      
01681           //std::cout << " track vertex position x " <<  tp->vertex().x() << " y " << tp->vertex().y() << " z " << tp->vertex().z() << std::endl;
01682           //std::cout << " track vertex position x " <<  tp->vx() << " y " << tp->vy() << " z " << tp->vz() << std::endl;
01683           //std::cout << " conversion vertex position x " <<  (*mcPho).vertex().x() << " y " << (*mcPho).vertex().y() << " z " << (*mcPho).vertex().z() << std::endl;
01684           if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.001   &&
01685                fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.001   &&
01686                fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.001) {
01687           
01688             //std::cout << " From conversion Electron pt " << tp -> pt() << " charge " << tp -> charge() << " pdgId " << tp->pdgId() << " Hits for this track: " << tp -> trackPSimHit().size() << std::endl;      
01689             //  std::cout << " track vertex position x " <<  tp->vertex().x() << " y " << tp->vertex().y() << " z " << tp->vertex().z() << std::endl;
01690             //std::cout << " conversion vertex position x " <<  (*mcPho).vertex().x() << " y " << (*mcPho).vertex().y() << " z " << (*mcPho).vertex().z() << "  R " <<  (*mcPho).vertex().perp() << std::endl;
01691             theConvTP_.push_back( tp ); 
01692           }
01693         }
01694         //      std::cout << " PhotonValidator  theConvTP_ size " <<   theConvTP_.size() << std::endl;  
01695 
01696         if ( theConvTP_.size() == 2 )   visibleConversionsWithTwoSimTracks=true;
01697         goodSimConversion=false;
01698 
01699         if (   visibleConversion && visibleConversionsWithTwoSimTracks )  goodSimConversion=true;
01700         if ( goodSimConversion ) {
01701           nSimConv_[1]++;       
01702           h_VisSimConv_[0]->Fill( mcEta_ ) ;
01703           h_VisSimConv_[1]->Fill( mcPhi_ );
01704           h_VisSimConv_[2]->Fill( mcConvR_ );
01705           h_VisSimConv_[3]->Fill( mcConvZ_ );
01706           h_VisSimConv_[4]->Fill(  (*mcPho).fourMomentum().et());
01707         
01708         
01709           if ( useTP ) { 
01710             for ( vector<TrackingParticleRef>::iterator iTrk=theConvTP_.begin(); iTrk!=theConvTP_.end(); ++iTrk) {
01711               h_simTkPt_ -> Fill ( (*iTrk)->pt() );
01712               h_simTkEta_ -> Fill ( (*iTrk)->eta() );
01713             }
01714           }
01715         }
01716       }  
01717 
01718 
01719     
01720       float minDelta=10000.;
01721       std::vector<reco::Photon> thePhotons;
01722       int index=0;
01723       int iMatch=-1;
01724       bool matched=false;
01725     
01726       //std::cout << " Reco photon size " <<  photonCollection.size() << std::endl;
01727       for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
01728         reco::Photon aPho = reco::Photon(*iPho);
01729         thePhotons.push_back(aPho);
01730         float phiPho=aPho.phi();
01731         float etaPho=aPho.eta();
01732         float deltaPhi = phiPho-mcPhi_;
01733         float deltaEta = etaPho-mcEta_;
01734         if ( deltaPhi > pi )  deltaPhi -= twopi;
01735         if ( deltaPhi < -pi) deltaPhi += twopi;
01736         deltaPhi=pow(deltaPhi,2);
01737         deltaEta=pow(deltaEta,2);
01738         float delta = sqrt( deltaPhi+deltaEta); 
01739         if ( delta<0.1 && delta < minDelta ) {
01740           minDelta=delta;
01741           iMatch=index;
01742          
01743         }
01744         index++;
01745       }  // end loop over reco photons
01746       if ( iMatch>-1 ) matched=true; 
01747 
01748   
01749       if ( matched ) {
01750         nSimPho_[1]++;
01751 
01752         h_SimPhoMotherEt_[1]->Fill(  (*mcPho).motherMomentum().et()  );
01753         h_SimPhoMotherEta_[1]->Fill(  (*mcPho).motherMomentum().pseudoRapidity());
01754 
01755         h_MatchedSimPho_[0]->Fill( mcEta_ ) ;
01756         h_MatchedSimPho_[1]->Fill( mcPhi_ );
01757         h_MatchedSimPho_[2]->Fill(  (*mcPho).fourMomentum().et());
01758 
01759       }
01760 
01761 
01762 
01763 
01764       if ( ! matched) continue;
01765 
01766       bool  phoIsInBarrel=false;
01767       bool  phoIsInEndcap=false;
01768 
01769       reco::Photon matchingPho = thePhotons[iMatch];
01770 
01771       if ( fabs(matchingPho.superCluster()->position().eta() ) < 1.479 ) {
01772         phoIsInBarrel=true;
01773       } else {
01774         phoIsInEndcap=true;
01775       }
01776       edm::Handle<EcalRecHitCollection>   ecalRecHitHandle;
01777       if ( phoIsInBarrel ) {
01778         // Get handle to rec hits ecal barrel 
01779         e.getByLabel(barrelEcalHits_, ecalRecHitHandle);
01780         if (!ecalRecHitHandle.isValid()) {
01781           edm::LogError("PhotonProducer") << "Error! Can't get the product "<<barrelEcalHits_.label();
01782           return;
01783         }
01784       
01785       } else if ( phoIsInEndcap ) {    
01786       
01787         // Get handle to rec hits ecal encap 
01788         e.getByLabel(endcapEcalHits_, ecalRecHitHandle);
01789         if (!ecalRecHitHandle.isValid()) {
01790           edm::LogError("PhotonProducer") << "Error! Can't get the product "<<endcapEcalHits_.label();
01791           return;
01792         }
01793       
01794       }
01795 
01796    
01797 
01798       int type=0;
01799       const EcalRecHitCollection ecalRecHitCollection = *(ecalRecHitHandle.product());
01800       float photonE = matchingPho.energy();
01801       float photonEt= matchingPho.energy()/cosh( matchingPho.eta()) ;
01802       float r9 = matchingPho.r9();
01803       float r1 = matchingPho.r1x5();
01804       float r2 = matchingPho.r2x5();
01805       float sigmaIetaIeta =  matchingPho.sigmaIetaIeta();
01806       float hOverE = matchingPho.hadronicOverEm();
01807       float ecalIso = matchingPho.ecalRecHitSumEtConeDR04();
01808       float hcalIso = matchingPho.hcalTowerSumEtConeDR04();
01809       float trkIso =  matchingPho.trkSumPtSolidConeDR04();
01810       float nIsoTrk   =  matchingPho.nTrkSolidConeDR04();
01811       std::vector< std::pair<DetId, float> >::const_iterator rhIt;
01812 
01813       bool atLeastOneDeadChannel=false;
01814       for(reco::CaloCluster_iterator bcIt = matchingPho.superCluster()->clustersBegin();bcIt != matchingPho.superCluster()->clustersEnd(); ++bcIt) {
01815         for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
01816 
01817           for(EcalRecHitCollection::const_iterator it =  ecalRecHitCollection.begin(); it !=  ecalRecHitCollection.end(); ++it) {
01818             if  (rhIt->first ==  (*it).id() ) {
01819               if (  (*it).recoFlag() == 9 ) {
01820                 atLeastOneDeadChannel=true;
01821                 break;
01822               }
01823             }
01824           }
01825         } 
01826       }
01827 
01828       if (   atLeastOneDeadChannel ) {
01829         h_MatchedSimPhoBadCh_[0]->Fill( mcEta_ ) ;
01830         h_MatchedSimPhoBadCh_[1]->Fill( mcPhi_ );
01831         h_MatchedSimPhoBadCh_[2]->Fill(  (*mcPho).fourMomentum().et());
01832       
01833       }
01834 
01835   
01836       h_scEta_[type]->Fill( matchingPho.superCluster()->eta() );
01837       h_scPhi_[type]->Fill( matchingPho.superCluster()->phi() );
01838       h_scEtaWidth_[type]->Fill( matchingPho.superCluster()->etaWidth() );
01839       h_scPhiWidth_[type]->Fill( matchingPho.superCluster()->phiWidth() );
01840       h_scE_[type][0]->Fill( matchingPho.superCluster()->energy() );
01841       h_scEt_[type][0]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
01842       if ( phoIsInEndcap ) h_psE_->Fill( matchingPho.superCluster()->preshowerEnergy() ) ;
01843       //
01844       h_r9_[type][0]->Fill( r9 );
01845       h2_r9VsEta_[0] -> Fill (mcEta_, r9);      
01846       h2_r9VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r9);      
01847       //
01848       h_r1_[type][0]->Fill( r1 );
01849       h2_r1VsEta_[0] -> Fill (mcEta_, r1);      
01850       h2_r1VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r1);      
01851       //
01852       h_r2_[type][0]->Fill( r2 );
01853       h2_r2VsEta_[0] -> Fill (mcEta_, r2);      
01854       h2_r2VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r2);      
01855       //
01856       h_sigmaIetaIeta_[type][0]->Fill( sigmaIetaIeta );
01857       h2_sigmaIetaIetaVsEta_[0] -> Fill (mcEta_, sigmaIetaIeta );      
01858       h2_sigmaIetaIetaVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), sigmaIetaIeta);      
01859       //    
01860       h_hOverE_[type][0]->Fill( hOverE );
01861       h2_hOverEVsEta_[0] -> Fill (mcEta_, hOverE );      
01862       h2_hOverEVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hOverE);      
01863       p_hOverEVsEta_[0] -> Fill (mcEta_, hOverE );      
01864       p_hOverEVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hOverE);      
01865       //
01866       h_ecalRecHitSumEtConeDR04_[type][0]->Fill( ecalIso );
01867       h2_ecalRecHitSumEtConeDR04VsEta_[0] -> Fill (mcEta_, ecalIso );      
01868       h2_ecalRecHitSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);      
01869       p_ecalRecHitSumEtConeDR04VsEta_[0] -> Fill (mcEta_, ecalIso );      
01870       p_ecalRecHitSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);      
01871       //
01872       h_hcalTowerSumEtConeDR04_[type][0]->Fill( hcalIso );
01873       h2_hcalTowerSumEtConeDR04VsEta_[0] -> Fill (mcEta_, hcalIso );      
01874       h2_hcalTowerSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);      
01875       p_hcalTowerSumEtConeDR04VsEta_[0] -> Fill (mcEta_, hcalIso );      
01876       p_hcalTowerSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);      
01877       //
01878       h_isoTrkSolidConeDR04_[type][0]->Fill( trkIso );
01879       h2_isoTrkSolidConeDR04VsEta_[0] -> Fill (mcEta_, trkIso );      
01880       h2_isoTrkSolidConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), trkIso);      
01881       //
01882       h_nTrkSolidConeDR04_[type][0]->Fill( nIsoTrk );
01883       h2_nTrkSolidConeDR04VsEta_[0] -> Fill (mcEta_, nIsoTrk );      
01884       h2_nTrkSolidConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), nIsoTrk);      
01885       //
01886       h_phoEta_[type]->Fill( matchingPho.eta() );
01887       h_phoPhi_[type]->Fill( matchingPho.phi() );
01888       h_phoDEta_[0]->Fill (  matchingPho.eta() - (*mcPho).fourMomentum().eta() );
01889       h_phoDPhi_[0]->Fill (  matchingPho.phi() - mcPhi_ );
01890       h_phoE_[type][0]->Fill( photonE );
01891       h_phoEt_[type][0]->Fill( photonEt);
01892       //
01893       h_phoERes_[0][0]->Fill( photonE / (*mcPho).fourMomentum().e() );
01894       h2_eResVsEta_[0]->Fill (mcEta_, photonE/(*mcPho).fourMomentum().e()  ) ;
01895       p_eResVsEta_[0]->Fill (mcEta_, photonE/(*mcPho).fourMomentum().e()  ) ;
01896 
01897       if ( ! isRunCentrally_ ) h2_eResVsEt_[0][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
01898       p_eResVsEt_[0][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
01899 
01900       h2_eResVsR9_[0]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
01901       h2_sceResVsR9_[0]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
01902       p_eResVsR9_[0]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
01903       p_sceResVsR9_[0]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
01904       //
01905       if (  (*mcPho).isAConversion() == 0 ) {
01906         h2_eResVsEta_[1]->Fill (mcEta_, photonE/ (*mcPho).fourMomentum().e()  ) ;
01907 
01908 
01909 
01910         h2_r9VsEta_[1] -> Fill (mcEta_, r9);
01911         h2_r9VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r9);     
01912         //
01913         h2_r1VsEta_[1] -> Fill (mcEta_, r1);      
01914         h2_r1VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r1);      
01915         //
01916         h2_r2VsEta_[1] -> Fill (mcEta_, r2);      
01917         h2_r2VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r2);      
01918         //
01919         h2_sigmaIetaIetaVsEta_[1] -> Fill (mcEta_, sigmaIetaIeta );      
01920         h2_sigmaIetaIetaVsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), sigmaIetaIeta);
01921         //
01922         h2_hOverEVsEta_[1] -> Fill (mcEta_, hOverE );      
01923         h2_hOverEVsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hOverE);
01924         //
01925         h2_ecalRecHitSumEtConeDR04VsEta_[1] -> Fill (mcEta_, ecalIso );      
01926         p_ecalRecHitSumEtConeDR04VsEta_[1] -> Fill (mcEta_, ecalIso );      
01927         //
01928         h2_hcalTowerSumEtConeDR04VsEta_[1] -> Fill (mcEta_, hcalIso );      
01929         p_hcalTowerSumEtConeDR04VsEta_[1] -> Fill (mcEta_, hcalIso );      
01930         //
01931         h2_isoTrkSolidConeDR04VsEta_[1] -> Fill (mcEta_, trkIso );      
01932         h2_isoTrkSolidConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), trkIso);      
01933         //
01934         h2_nTrkSolidConeDR04VsEta_[1] -> Fill (mcEta_, nIsoTrk );      
01935         h2_nTrkSolidConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), nIsoTrk);      
01936 
01937       }
01938 
01939 
01940     
01941  
01942       if ( photonE/(*mcPho).fourMomentum().e()  < 0.3 &&   photonE/(*mcPho).fourMomentum().e() > 0.1 ) {
01943         //      std::cout << " Eta sim " << mcEta_ << " sc eta " << matchingPho.superCluster()->eta() << " pho eta " << matchingPho.eta() << std::endl;
01944       
01945       }
01946 
01947 
01948       if ( r9 > 0.93 )  {
01949         h_phoERes_[1][0]->Fill( photonE / (*mcPho).fourMomentum().e() );
01950         if ( ! isRunCentrally_ ) h2_eResVsEt_[0][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;  
01951         p_eResVsEt_[0][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ; 
01952         p_eResVsEta_[1]->Fill (mcEta_,photonE/ (*mcPho).fourMomentum().e()  ) ;     
01953 
01954       } else if ( r9 <= 0.93 ) {  
01955         h_phoERes_[2][0]->Fill(photonE / (*mcPho).fourMomentum().e() );
01956         if ( ! isRunCentrally_ ) h2_eResVsEt_[0][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
01957         p_eResVsEt_[0][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
01958         p_eResVsEta_[2]->Fill (mcEta_,photonE/ (*mcPho).fourMomentum().e()  ) ;     
01959       }
01960         
01961     
01962           
01963       if ( phoIsInBarrel ) {
01964         h_scE_[type][1]->Fill( matchingPho.superCluster()->energy() );
01965         h_scEt_[type][1]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
01966         h_r9_[type][1]->Fill( r9 );
01967         h_r1_[type][1]->Fill( r1 );
01968         h_r2_[type][1]->Fill( r2 );
01969         h_sigmaIetaIeta_[type][1]->Fill( sigmaIetaIeta );
01970         h_hOverE_[type][1]->Fill( hOverE );
01971         h_ecalRecHitSumEtConeDR04_[type][1]->Fill( ecalIso );
01972         h2_ecalRecHitSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);      
01973         p_ecalRecHitSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);      
01974         h_hcalTowerSumEtConeDR04_[type][1]->Fill( hcalIso );
01975         h2_hcalTowerSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);      
01976         p_hcalTowerSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);      
01977         h_isoTrkSolidConeDR04_[type][1]->Fill( trkIso );
01978         h_nTrkSolidConeDR04_[type][1]->Fill( nIsoTrk );
01979 
01980       
01981         h_phoE_[type][1]->Fill( photonE );
01982         h_phoEt_[type][1]->Fill( photonEt );
01983         h_nConv_[type][1]->Fill(float( matchingPho.conversions().size()));
01984       
01985       
01986         h_phoERes_[0][1]->Fill( photonE / (*mcPho).fourMomentum().e() );
01987         h2_eResVsR9_[1]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
01988         h2_sceResVsR9_[1]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
01989         p_eResVsR9_[1]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
01990         p_sceResVsR9_[1]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
01991 
01992         if ( ! isRunCentrally_ ) h2_eResVsEt_[1][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;  
01993         p_eResVsEt_[1][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
01994 
01995       
01996         if ( r9 > 0.93 ) {  
01997           h_phoERes_[1][1]->Fill(  photonE  / (*mcPho).fourMomentum().e() );
01998           if ( ! isRunCentrally_ ) h2_eResVsEt_[1][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;  
01999           p_eResVsEt_[1][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02000         }
02001         if ( r9 <= 0.93 )  { 
02002           h_phoERes_[2][1]->Fill( photonE / (*mcPho).fourMomentum().e() );
02003           if ( ! isRunCentrally_ ) h2_eResVsEt_[1][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;  
02004           p_eResVsEt_[1][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02005         }
02006       }
02007       if ( phoIsInEndcap ) {
02008         h_scE_[type][2]->Fill( matchingPho.superCluster()->energy() );
02009         h_scEt_[type][2]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
02010         h_r9_[type][2]->Fill( r9 );
02011         h_r1_[type][2]->Fill( r1 );
02012         h_r2_[type][2]->Fill( r2 );
02013         h_sigmaIetaIeta_[type][2]->Fill( sigmaIetaIeta );
02014         h_hOverE_[type][2]->Fill( hOverE );
02015         h_ecalRecHitSumEtConeDR04_[type][2]->Fill( ecalIso );
02016         h2_ecalRecHitSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);      
02017         p_ecalRecHitSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);      
02018         h_hcalTowerSumEtConeDR04_[type][2]->Fill( hcalIso );
02019         h2_hcalTowerSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);      
02020         p_hcalTowerSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);      
02021         h_isoTrkSolidConeDR04_[type][2]->Fill( trkIso );
02022         h_nTrkSolidConeDR04_[type][2]->Fill( nIsoTrk );
02023         h_phoE_[type][2]->Fill( photonE );
02024         h_phoEt_[type][2]->Fill( photonEt );
02025         h_nConv_[type][2]->Fill(float( matchingPho.conversions().size()));
02026         h_phoERes_[0][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
02027         h2_eResVsR9_[2]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;     
02028         h2_sceResVsR9_[2]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
02029         p_eResVsR9_[2]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;     
02030         p_sceResVsR9_[2]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
02031 
02032         if ( ! isRunCentrally_ ) h2_eResVsEt_[2][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;  
02033         p_eResVsEt_[2][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02034 
02035         if ( r9 > 0.93 ) {  
02036 
02037           h_phoERes_[1][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
02038           if ( ! isRunCentrally_ ) h2_eResVsEt_[2][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;  
02039           p_eResVsEt_[2][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02040         }
02041         if ( r9 <= 0.93 ) {
02042           h_phoERes_[2][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
02043           if ( ! isRunCentrally_ ) h2_eResVsEt_[2][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
02044           p_eResVsEt_[2][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;  
02045         }
02046       }
02047       
02048 
02049 
02050         
02051       if ( ! (visibleConversion &&  visibleConversionsWithTwoSimTracks ) ) continue;
02052       h_r9_[1][0]->Fill( r9 );
02053       if ( phoIsInBarrel ) h_r9_[1][1]->Fill( r9 );
02054       if ( phoIsInEndcap ) h_r9_[1][2]->Fill( r9 );
02055 
02056       if ( ! isRunCentrally_ ) {
02057         h_simConvVtxRvsZ_[0] ->Fill ( fabs (mcConvZ_), mcConvR_  ) ;
02058         if ( fabs(mcEta_) <=1.) {
02059           h_simConvVtxRvsZ_[1] ->Fill ( fabs (mcConvZ_), mcConvR_  ) ;
02060           h_simConvVtxYvsX_ ->Fill ( mcConvX_, mcConvY_  ) ;
02061         }
02062         else 
02063           h_simConvVtxRvsZ_[2] ->Fill ( fabs (mcConvZ_), mcConvR_  ) ;
02064       }
02065 
02066 
02067       if ( ! fastSim_) {    
02068         h_nConv_[type][0]->Fill(float( matchingPho.conversions().size()));          
02070         reco::ConversionRefVector conversions = matchingPho.conversions();
02071         for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
02072           reco::ConversionRef aConv=conversions[iConv];
02073           double like = aConv->MVAout();
02074           if ( like < likelihoodCut_ ) continue;      
02075           
02076           if ( ! isRunCentrally_ ) h2_EoverEtrueVsEta_[1]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02077           p_EoverEtrueVsEta_[1]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02078           
02079           
02080           //std::vector<reco::TrackRef> tracks = aConv->tracks();
02081           const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
02082           if (tracks.size() < 1 ) continue;
02083           
02084           
02085           h_mvaOut_[0]-> Fill(like);
02086           
02087           if ( tracks.size()==2 ) {
02088             if ( sqrt( aConv->tracksPin()[0].Perp2()) < convTrackMinPtCut_ || sqrt( aConv->tracksPin()[1].Perp2()) < convTrackMinPtCut_) continue;
02089           } else {
02090             if ( sqrt( aConv->tracksPin()[0].Perp2()) < convTrackMinPtCut_ ) continue;
02091           }
02092           
02093           
02094           if ( dCotCutOn_ ) {
02095             if (  (fabs(mcEta_) > 1.1 && fabs (mcEta_)  < 1.4  )  &&
02096                   fabs( aConv->pairCotThetaSeparation() ) > dCotHardCutValue_ ) continue;
02097             if ( fabs( aConv->pairCotThetaSeparation() ) > dCotCutValue_ ) continue;
02098           }
02099           
02100           //std::cout << " PhotonValidator converison algo name " << aConv->algoName() << " " << aConv->algo() << std::endl;
02101           
02102           nRecConv_++;
02103           
02104           
02105           std::map<reco::TrackRef,TrackingParticleRef> myAss;
02106           std::map<reco::TrackRef,TrackingParticleRef>::const_iterator itAss;
02107           std::map<reco::TrackRef,TrackingParticleRef>::const_iterator itAssMin;
02108           std::map<reco::TrackRef,TrackingParticleRef>::const_iterator itAssMax;
02109           //     
02110           
02111           int nAssT2=0;
02112           // unused      int nAssT1=0;
02113           for (unsigned int i=0; i<tracks.size(); i++) {
02114             reco::TrackRef track = tracks[i].castTo<reco::TrackRef>();
02115             
02116             type =0;
02117             if ( ! isRunCentrally_ ) nHitsVsEta_[type] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits())-0.0001 );
02118             if ( ! isRunCentrally_ ) nHitsVsR_[type] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits())-0.0001 );
02119             p_nHitsVsEta_[type] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits()) );
02120             p_nHitsVsR_[type] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits()) );
02121             h_tkChi2_[type] ->Fill (tracks[i]->normalizedChi2() ); 
02122           
02124             TrackingParticleRef myTP;
02125             for (size_t j = 0; j < RtoSCollPtrs.size(); j++) {          
02126               reco::RecoToSimCollection q = *(RtoSCollPtrs[j]);
02127               
02128               RefToBase<reco::Track> myTk( track );
02129               
02130               if( q.find(myTk ) != q.end() ) {
02131                 std::vector<std::pair<TrackingParticleRef, double> > tp = q[myTk];
02132                 for (unsigned int itp=0; itp<tp.size(); itp++) {
02133                   myTP=tp[itp].first;
02134                   //      std::cout << " associated with TP " << myTP->pdgId() << " pt " << sqrt(myTP->momentum().perp2()) << std::endl;
02135                   myAss.insert( std::make_pair ( track  , myTP) );
02136                   nAssT2++;
02137                 }
02138               }
02139             }
02140           }
02141           
02142           
02143           
02144           type=0;
02145 
02146           //      float totP = sqrt(aConv->pairMomentum().Mag2());
02147           float refP =-99999.;
02148           float refPt =-99999.;
02149           if ( aConv->conversionVertex().isValid() ) {
02150                refP=sqrt(aConv->refittedPairMomentum().Mag2());
02151                refPt=sqrt(aConv->refittedPairMomentum().perp2());
02152           }
02153           float invM = aConv->pairInvariantMass();
02154 
02155           h_invMass_[type][0] ->Fill( invM);
02156           if ( phoIsInBarrel ) h_invMass_[type][1] ->Fill(invM);
02157           if ( phoIsInEndcap ) h_invMass_[type][2] ->Fill(invM);
02158 
02159                   
02161           if ( tracks.size() ==1  ) {
02162             h_SimConvOneTracks_[0]->Fill( mcEta_ ) ;
02163             h_SimConvOneTracks_[1]->Fill( mcPhi_ );
02164             h_SimConvOneTracks_[2]->Fill( mcConvR_ );
02165             h_SimConvOneTracks_[3]->Fill( mcConvZ_ );
02166             h_SimConvOneTracks_[4]->Fill(  (*mcPho).fourMomentum().et());
02167             
02168             
02169           } else if ( tracks.size() ==2 ) {
02170             
02171             h_SimConvTwoTracks_[0]->Fill( mcEta_ ) ;
02172             h_SimConvTwoTracks_[1]->Fill( mcPhi_ );
02173             h_SimConvTwoTracks_[2]->Fill( mcConvR_ );
02174             h_SimConvTwoTracks_[3]->Fill( mcConvZ_ );
02175             h_SimConvTwoTracks_[4]->Fill(  (*mcPho).fourMomentum().et());
02176             
02177             h_convEta_[1]->Fill( aConv->caloCluster()[0]->eta() );              
02178             
02179             float trkProvenance=3;
02180             if ( tracks[0]->algoName() == "outInEcalSeededConv"  &&  tracks[1]->algoName() == "outInEcalSeededConv" ) trkProvenance=0;
02181             if ( tracks[0]->algoName() == "inOutEcalSeededConv"  &&  tracks[1]->algoName() == "inOutEcalSeededConv" ) trkProvenance=1;
02182             if ( ( tracks[0]->algoName() == "outInEcalSeededConv"  &&  tracks[1]->algoName() == "inOutEcalSeededConv") || 
02183                  ( tracks[1]->algoName() == "outInEcalSeededConv"  &&  tracks[0]->algoName() == "inOutEcalSeededConv") ) trkProvenance=2;
02184             if ( trkProvenance==3 ) {
02185               // std::cout << " PhotonValidator provenance of tracks is " << tracks[0]->algoName() << " and " << tracks[1]->algoName() << std::endl;
02186             }
02187             h_trkProv_[0]->Fill( trkProvenance );
02188             
02189             
02190             
02192             if ( nAssT2 ==2 ) {
02193               
02194               
02195               
02196               
02197               h_r9_[2][0]->Fill( r9 );
02198               if ( phoIsInBarrel ) h_r9_[2][1]->Fill( r9 );
02199               if ( phoIsInEndcap ) h_r9_[2][2]->Fill( r9 );
02200               
02201               h_convEta_[2]->Fill( aConv->caloCluster()[0]->eta() );    
02202               
02203               nRecConvAss_++;
02204               
02205               
02206               h_SimConvTwoMTracks_[0]->Fill( mcEta_ ) ;
02207               h_SimConvTwoMTracks_[1]->Fill( mcPhi_ );
02208               h_SimConvTwoMTracks_[2]->Fill( mcConvR_ );
02209               h_SimConvTwoMTracks_[3]->Fill( mcConvZ_ );
02210               h_SimConvTwoMTracks_[4]->Fill(  (*mcPho).fourMomentum().et());
02211               
02212               if ( aConv->conversionVertex().isValid() ) {
02213                 if ( trkProvenance==3 ) std::cout << " PhotonValidator provenance of tracks is mixed and vertex is valid " << std::endl;
02214                 float chi2Prob = ChiSquaredProbability( aConv->conversionVertex().chi2(),  aConv->conversionVertex().ndof() );
02215                 if (   chi2Prob > 0) {
02216                   h_SimConvTwoMTracksAndVtxPGT0_[0]->Fill( mcEta_ ) ;
02217                   h_SimConvTwoMTracksAndVtxPGT0_[1]->Fill( mcPhi_ );
02218                   h_SimConvTwoMTracksAndVtxPGT0_[2]->Fill( mcConvR_ ); 
02219                   h_SimConvTwoMTracksAndVtxPGT0_[3]->Fill( mcConvZ_ );
02220                   h_SimConvTwoMTracksAndVtxPGT0_[4]->Fill(  (*mcPho).fourMomentum().et()); 
02221                 }
02222                 if (   chi2Prob > 0.0005) {
02223                   h_SimConvTwoMTracksAndVtxPGT0005_[0]->Fill( mcEta_ ) ;
02224                   h_SimConvTwoMTracksAndVtxPGT0005_[1]->Fill( mcPhi_ );
02225                   h_SimConvTwoMTracksAndVtxPGT0005_[2]->Fill( mcConvR_ ); 
02226                   h_SimConvTwoMTracksAndVtxPGT0005_[3]->Fill( mcConvZ_ );
02227                   h_SimConvTwoMTracksAndVtxPGT0005_[4]->Fill(  (*mcPho).fourMomentum().et()); 
02228                   
02229                 }
02230                 
02231                 if (  chi2Prob > 0.0005 ) {
02232                   h_convEta_[0]->Fill( aConv->caloCluster()[0]->eta() );
02233                   h_convPhi_[0]->Fill( aConv->caloCluster()[0]->phi() );
02234                   h_convERes_[0][0]->Fill( aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
02235                   if ( ! isRunCentrally_ ) h_r9VsNofTracks_[0][0]->Fill( r9, aConv->nTracks() ) ; 
02236                   
02237                   if ( phoIsInBarrel )  {
02238                     h_convERes_[0][1]->Fill(aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
02239                     if ( ! isRunCentrally_ ) h_r9VsNofTracks_[0][1]->Fill( r9, aConv->nTracks() ) ; 
02240                     h_mvaOut_[1]-> Fill(like);
02241                   }
02242                   if ( phoIsInEndcap ) {
02243                     h_convERes_[0][2]->Fill(aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
02244                     if ( ! isRunCentrally_ ) h_r9VsNofTracks_[0][2]->Fill( r9, aConv->nTracks() ) ; 
02245                     h_mvaOut_[2]-> Fill(like);
02246                   }
02247                   
02248                 }
02249                 
02250 
02251 
02252 
02253               } 
02254               
02256               type =1;
02257               
02258               h_trkProv_[1]->Fill( trkProvenance );
02259               h_invMass_[type][0] ->Fill( invM);              
02260              
02261               
02262               
02263               float eoverp= -99999.;
02264            
02265               if ( aConv->conversionVertex().isValid() ) {
02266                 eoverp= aConv->EoverPrefittedTracks();
02267                 h_convPtRes_[type][0]->Fill( refPt / (*mcPho).fourMomentum().et() );
02268                 h_EoverPTracks_[type][0] ->Fill( eoverp ) ;
02269                 h_PoverETracks_[type][0] ->Fill( 1./eoverp ) ;
02270                 if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[0] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02271                 if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[0] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e()  ) ;
02272                 if ( ! isRunCentrally_ ) h2_EoverPVsEta_[0]->Fill (mcEta_, eoverp);
02273                 if ( ! isRunCentrally_ ) h2_EoverPVsR_[0]->Fill (mcConvR_, eoverp);
02274                 p_EoverPVsEta_[0]->Fill (mcEta_, eoverp);
02275                 p_EoverPVsR_[0]->Fill (mcConvR_, eoverp);
02276                 p_eResVsR_ ->Fill ( mcConvR_, photonE / (*mcPho).fourMomentum().e() ); 
02277                  if ( ! isRunCentrally_ ) h2_PoverPtrueVsEta_[0]->Fill (mcEta_,refP/ (*mcPho).fourMomentum().e()  ) ;
02278                 p_PoverPtrueVsEta_[0]->Fill (mcEta_,refP/ (*mcPho).fourMomentum().e()  ) ;
02279 
02280 
02281               }
02282 
02283                       
02284               if ( ! isRunCentrally_ )  h2_EoverEtrueVsEta_[0]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02285               if ( ! isRunCentrally_ )  h2_EoverEtrueVsR_[0]->Fill (mcConvR_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02286               p_EoverEtrueVsEta_[0]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;          
02287               p_EoverEtrueVsR_[0]->Fill (mcConvR_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02288               
02289               
02290               if ( ! isRunCentrally_ ) h2_etaVsRsim_[0]->Fill (mcEta_,mcConvR_);         
02291               
02292               
02293               reco::TrackRef track1 = tracks[0].castTo<reco::TrackRef>();
02294               reco::TrackRef track2 = tracks[1].castTo<reco::TrackRef>();
02295               reco::TransientTrack tt1 = (*theTTB).build( &track1);
02296               reco::TransientTrack tt2 = (*theTTB).build( &track2);
02297               TwoTrackMinimumDistance md;
02298               md.calculate  (  tt1.initialFreeState(),  tt2.initialFreeState() );
02299               if (md.status() )  {
02300                 //cout << " Min Dist " << md.distance() << std::endl;
02301                 h_distMinAppTracks_[1][0]->Fill ( md.distance() );
02302               }  else {
02303                 nInvalidPCA_++;
02304                 
02305               }
02306 
02307                       
02308               //  here original tracks and their inner momentum is considered
02309               float  dPhiTracksAtVtx =  aConv->dPhiTracksAtVtx();
02310               h_DPhiTracksAtVtx_[type][0]->Fill( dPhiTracksAtVtx);
02311               if ( ! isRunCentrally_ ) h2_DPhiTracksAtVtxVsEta_->Fill( mcEta_, dPhiTracksAtVtx);
02312               if ( ! isRunCentrally_ ) h2_DPhiTracksAtVtxVsR_->Fill( mcConvR_, dPhiTracksAtVtx);
02313               p_DPhiTracksAtVtxVsEta_->Fill( mcEta_, dPhiTracksAtVtx);
02314               p_DPhiTracksAtVtxVsR_->Fill( mcConvR_, dPhiTracksAtVtx);
02315                       
02316               h_DCotTracks_[type][0] ->Fill ( aConv->pairCotThetaSeparation() );
02317               if ( ! isRunCentrally_ ) h2_DCotTracksVsEta_->Fill( mcEta_, aConv->pairCotThetaSeparation() );
02318               if ( ! isRunCentrally_ ) h2_DCotTracksVsR_->Fill( mcConvR_, aConv->pairCotThetaSeparation() );
02319               p_DCotTracksVsEta_->Fill( mcEta_, aConv->pairCotThetaSeparation() );
02320               p_DCotTracksVsR_->Fill( mcConvR_, aConv->pairCotThetaSeparation() );
02321               
02322                       
02323               if ( phoIsInBarrel ) {
02324                 h_invMass_[type][1] ->Fill(invM);
02325                 if ( aConv->conversionVertex().isValid() ) {
02326                   h_convPtRes_[type][1]->Fill( refPt / (*mcPho).fourMomentum().et() );
02327                   h_EoverPTracks_[type][1] ->Fill( eoverp ) ;
02328                   if (  mcConvR_ < 15 )                 h_EoverPTracks_[0][0] ->Fill( eoverp ) ;
02329                   if (  mcConvR_ > 15 && mcConvR_< 58 ) h_EoverPTracks_[0][1] ->Fill( eoverp ) ;
02330                   if (  mcConvR_ > 58 )                 h_EoverPTracks_[0][2] ->Fill( eoverp ) ;
02331                   h_PoverETracks_[type][1] ->Fill( 1./eoverp ) ;
02332                   if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[1] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02333                   if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[1] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e()  ) ;
02334                 }
02335                 h_DPhiTracksAtVtx_[type][1]->Fill( dPhiTracksAtVtx);
02336                 h_DCotTracks_[type][1] ->Fill ( aConv->pairCotThetaSeparation() );
02337                 
02338                 
02339               }
02340               
02341                       
02342               if ( phoIsInEndcap ) {
02343                 h_invMass_[type][2] ->Fill(invM);
02344                 if ( aConv->conversionVertex().isValid() ) {
02345                   h_convPtRes_[type][2]->Fill( refPt / (*mcPho).fourMomentum().et() );
02346                   h_EoverPTracks_[type][2] ->Fill( eoverp ) ;
02347                   h_PoverETracks_[type][2] ->Fill( 1./eoverp ) ;
02348                   if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[2] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
02349                   if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[2] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e()  ) ;
02350                 }
02351                 h_DPhiTracksAtVtx_[type][2]->Fill( dPhiTracksAtVtx);
02352                 h_DCotTracks_[type][2] ->Fill ( aConv->pairCotThetaSeparation() );
02353                  
02354               }
02355               
02356                       
02357               if ( aConv->conversionVertex().isValid() ) {
02358 
02359                 h_convVtxdX_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
02360                 h_convVtxdY_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
02361                 h_convVtxdZ_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
02362                 h_convVtxdR_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
02363                 
02364                 if ( fabs( mcConvEta_ ) <= 1.2 ) {
02365                   h_convVtxdX_barrel_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
02366                   h_convVtxdY_barrel_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
02367                   h_convVtxdZ_barrel_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
02368                   h_convVtxdR_barrel_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
02369                 } else {
02370                   h_convVtxdX_endcap_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
02371                   h_convVtxdY_endcap_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
02372                   h_convVtxdZ_endcap_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
02373                   h_convVtxdR_endcap_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
02374                 }
02375                 
02376                 
02377                 h_convVtxdPhi_ ->Fill ( aConv->conversionVertex().position().phi() - mcConvPhi_);
02378                 h_convVtxdEta_ ->Fill ( aConv->conversionVertex().position().eta() - mcConvEta_);
02379                 if ( ! isRunCentrally_ ) h2_convVtxdRVsR_ ->Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
02380                 if ( ! isRunCentrally_ ) h2_convVtxdRVsEta_ ->Fill (mcEta_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
02381                 p_convVtxdRVsR_ ->Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
02382                 p_convVtxdRVsEta_ ->Fill (mcEta_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
02383                 float signX= aConv->refittedPairMomentum().x()/fabs(aConv->refittedPairMomentum().x());
02384                 float signY= aConv->refittedPairMomentum().y()/fabs(aConv->refittedPairMomentum().y());
02385                 float signZ= aConv->refittedPairMomentum().z()/fabs(aConv->refittedPairMomentum().z());
02386                 p_convVtxdXVsX_ ->Fill (mcConvX_, (aConv->conversionVertex().position().x() - mcConvX_)*signX );
02387                 p_convVtxdYVsY_ ->Fill (mcConvY_, (aConv->conversionVertex().position().y() - mcConvY_)*signY );
02388                 p_convVtxdZVsZ_ ->Fill (mcConvZ_, (aConv->conversionVertex().position().z() - mcConvZ_)*signZ );
02389                 
02390 
02391                 if ( ! isRunCentrally_ ) h2_convVtxRrecVsTrue_ -> Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) );
02392                 
02393                 
02394                 
02395               } // end conversion vertex valid
02396               
02397               
02398               
02399               h_zPVFromTracks_[type]->Fill ( aConv->zOfPrimaryVertexFromTracks() );
02400               h_dzPVFromTracks_[type]->Fill ( aConv->zOfPrimaryVertexFromTracks() - (*mcPho).primaryVertex().z() );
02401               p_dzPVVsR_ ->Fill(mcConvR_, aConv->zOfPrimaryVertexFromTracks() - (*mcPho).primaryVertex().z() );
02402               if ( ! isRunCentrally_ ) h2_dzPVVsR_ ->Fill(mcConvR_, aConv->zOfPrimaryVertexFromTracks() - (*mcPho).primaryVertex().z() );   
02403 
02404                       
02405               float  dPhiTracksAtEcal=-99;
02406               float  dEtaTracksAtEcal=-99;
02407               if (aConv->bcMatchingWithTracks()[0].isNonnull() && aConv->bcMatchingWithTracks()[1].isNonnull() ) {
02408                 nRecConvAssWithEcal_++;
02409                 float recoPhi1 = aConv->ecalImpactPosition()[0].phi();
02410                 float recoPhi2 = aConv->ecalImpactPosition()[1].phi();
02411                 float recoEta1 = aConv->ecalImpactPosition()[0].eta();
02412                 float recoEta2 = aConv->ecalImpactPosition()[1].eta();
02413                 float bcPhi1 = aConv->bcMatchingWithTracks()[0]->phi();
02414                 float bcPhi2 = aConv->bcMatchingWithTracks()[1]->phi();
02415                 // unused       float bcEta1 = aConv->bcMatchingWithTracks()[0]->eta();
02416                 // unused   float bcEta2 = aConv->bcMatchingWithTracks()[1]->eta();
02417                 recoPhi1 = phiNormalization(recoPhi1);
02418                 recoPhi2 = phiNormalization(recoPhi2);
02419                 bcPhi1 = phiNormalization(bcPhi1);
02420                 bcPhi2 = phiNormalization(bcPhi2);
02421                 dPhiTracksAtEcal = recoPhi1 -recoPhi2;
02422                 dPhiTracksAtEcal = phiNormalization( dPhiTracksAtEcal );
02423                 dEtaTracksAtEcal = recoEta1 -recoEta2;
02424                 
02425                 
02426                 h_DPhiTracksAtEcal_[type][0]->Fill( fabs(dPhiTracksAtEcal));
02427                 if ( ! isRunCentrally_ ) h2_DPhiTracksAtEcalVsR_ ->Fill (mcConvR_, fabs(dPhiTracksAtEcal));
02428                 if ( ! isRunCentrally_ ) h2_DPhiTracksAtEcalVsEta_ ->Fill (mcEta_, fabs(dPhiTracksAtEcal));
02429                 p_DPhiTracksAtEcalVsR_ ->Fill (mcConvR_, fabs(dPhiTracksAtEcal));
02430                 p_DPhiTracksAtEcalVsEta_ ->Fill (mcEta_, fabs(dPhiTracksAtEcal));
02431                 
02432                 h_DEtaTracksAtEcal_[type][0]->Fill( dEtaTracksAtEcal);
02433                 
02434                 if ( phoIsInBarrel ) {
02435                   h_DPhiTracksAtEcal_[type][1]->Fill( fabs(dPhiTracksAtEcal));
02436                   h_DEtaTracksAtEcal_[type][1]->Fill( dEtaTracksAtEcal);
02437                 }
02438                 if ( phoIsInEndcap ) {
02439                   h_DPhiTracksAtEcal_[type][2]->Fill( fabs(dPhiTracksAtEcal));
02440                   h_DEtaTracksAtEcal_[type][2]->Fill( dEtaTracksAtEcal);
02441                 }
02442                 
02443               }
02444               
02445               
02446               
02447               
02449               for (unsigned int i=0; i<tracks.size(); i++) {
02450                 reco::TrackRef track = tracks[i].castTo<reco::TrackRef>();
02451                 itAss= myAss.find(  track );
02452                 if ( itAss == myAss.end()  ) continue;
02453                 
02454                 float trkProvenance=3;
02455                 if ( tracks[0]->algoName() == "outInEcalSeededConv"  &&  tracks[1]->algoName() == "outInEcalSeededConv" ) trkProvenance=0;
02456                 if ( tracks[0]->algoName() == "inOutEcalSeededConv"  &&  tracks[1]->algoName() == "inOutEcalSeededConv" ) trkProvenance=1;
02457                 if ( ( tracks[0]->algoName() == "outInEcalSeededConv"  &&  tracks[1]->algoName() == "inOutEcalSeededConv") || 
02458                      ( tracks[1]->algoName() == "outInEcalSeededConv"  &&  tracks[0]->algoName() == "inOutEcalSeededConv") ) trkProvenance=2;
02459 
02460                 
02461                 if ( ! isRunCentrally_ ) nHitsVsEta_[type] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits()) );
02462                  if ( ! isRunCentrally_ ) nHitsVsR_[type] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits()) );
02463                 p_nHitsVsEta_[type] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits()) -0.0001);
02464                 p_nHitsVsR_[type] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits()) -0.0001);
02465                 h_tkChi2_[type] ->Fill (tracks[i]->normalizedChi2() ); 
02466                 h_tkChi2Large_[type] ->Fill (tracks[i]->normalizedChi2() ); 
02467                 if ( ! isRunCentrally_ ) h2_Chi2VsEta_[0] ->Fill(  mcEta_, tracks[i]->normalizedChi2() ); 
02468                  if ( ! isRunCentrally_ ) h2_Chi2VsR_[0] ->Fill(  mcConvR_, tracks[i]->normalizedChi2() ); 
02469                 p_Chi2VsEta_[0] ->Fill(  mcEta_, tracks[i]->normalizedChi2() ); 
02470                 p_Chi2VsR_[0] ->Fill(  mcConvR_, tracks[i]->normalizedChi2() ); 
02471                 
02472 
02473                 float simPt = sqrt( ((*itAss).second)->momentum().perp2() );    
02474                 //              float recPt =   sqrt( aConv->tracks()[i]->innerMomentum().Perp2() ) ;
02475                 float refPt=-9999.;
02476                 float px=0, py=0;
02477               
02478                 if ( aConv->conversionVertex().isValid() ) {
02479                   reco::Track refTrack= aConv->conversionVertex().refittedTracks()[i];
02480                   px= refTrack.momentum().x() ;
02481                   py= refTrack.momentum().y() ;
02482                   refPt=sqrt (px*px + py*py );
02483                   
02484                   float ptres= refPt - simPt ;
02485                   // float pterror = aConv->tracks()[i]->ptError();
02486                   float pterror =  aConv->conversionVertex().refittedTracks()[i].ptError();
02487                   if ( ! isRunCentrally_ ) {
02488                     h2_PtRecVsPtSim_[0]->Fill ( simPt, refPt);
02489                     if ( trkProvenance ==3 ) h2_PtRecVsPtSimMixProv_->Fill ( simPt, refPt);
02490                   }
02491   
02492                   h_TkPtPull_[0] ->Fill(ptres/pterror);
02493                    if ( ! isRunCentrally_ ) h2_TkPtPull_[0] ->Fill(mcEta_, ptres/pterror);
02494                   
02495                   h_TkD0_[0]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
02496                   
02497                   
02498                   if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[0]->Fill  ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2())  );
02499                   
02500                   if ( phoIsInBarrel ) {
02501                     h_TkD0_[1]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
02502                     h_TkPtPull_[1] ->Fill(ptres/pterror);
02503                      if ( ! isRunCentrally_ ) h2_PtRecVsPtSim_[1]->Fill ( simPt, refPt);
02504                     if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[1]->Fill  ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2())  );
02505                     
02506                   }
02507                   if ( phoIsInEndcap ) { 
02508                     h_TkD0_[2]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
02509                     h_TkPtPull_[2] ->Fill(ptres/pterror);
02510                      if ( ! isRunCentrally_ ) h2_PtRecVsPtSim_[2]->Fill ( simPt, refPt);
02511                     if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[2]->Fill  ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2())  );
02512                   }
02513                   
02514                 }
02515           
02516               } // end loop over track
02517             } // end analysis of two associated tracks
02518           } // end analysis of two  tracks
02519       
02520         } // loop over conversions
02521       }  // if !fastSim
02522     }  // End loop over generated particles
02523   } // End loop over simulated Photons
02524 
02525 
02526  
02527  
02528   h_nSimPho_[0]->Fill(float(nSimPho_[0]));
02529   h_nSimPho_[1]->Fill(float(nSimPho_[1]));
02530   h_nSimConv_[0]->Fill(float(nSimConv_[0]));
02531   h_nSimConv_[1]->Fill(float(nSimConv_[1]));
02532   
02533  
02534   if ( !fastSim_) {
02536     for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
02537       reco::Photon aPho = reco::Photon(*iPho);
02538       //    float et= aPho.superCluster()->energy()/cosh( aPho.superCluster()->eta()) ;    
02539       reco::ConversionRefVector conversions = aPho.conversions();
02540       for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
02541         reco::ConversionRef aConv=conversions[iConv];
02542         double like = aConv->MVAout();   
02543         if ( like < likelihoodCut_ ) continue;      
02544         //std::vector<reco::TrackRef> tracks = aConv->tracks();
02545         const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
02546         if (tracks.size() < 2 ) continue;
02547 
02548         bool  phoIsInBarrel=false;
02549         bool  phoIsInEndcap=false;
02550         if ( fabs(aConv->caloCluster()[0]->eta() ) < 1.479 ) {
02551           phoIsInBarrel=true;
02552         } else {
02553           phoIsInEndcap=true;
02554         }
02555 
02556       
02557         if ( dCotCutOn_ ) {
02558           if ( ( fabs(mcEta_) > 1.1 && fabs (mcEta_)  < 1.4  )  &&
02559                fabs( aConv->pairCotThetaSeparation() ) > dCotHardCutValue_ )  continue;
02560           if ( fabs( aConv->pairCotThetaSeparation() ) > dCotCutValue_ ) continue;
02561         }
02562       
02563       
02564         h_RecoConvTwoTracks_[0]->Fill( aPho.eta() ) ;
02565         h_RecoConvTwoTracks_[1]->Fill( aPho.phi() );
02566         if (  aConv->conversionVertex().isValid() ) h_RecoConvTwoTracks_[2]->Fill(  aConv->conversionVertex().position().perp2() );
02567         h_RecoConvTwoTracks_[3]->Fill( aConv->conversionVertex().position().z() );
02568         h_RecoConvTwoTracks_[4]->Fill( aPho.et() ) ;
02569       
02570       
02571       
02572         int  nAssT2=0;
02573 
02574         std::map<reco::TrackRef,TrackingParticleRef> myAss;
02575         for (unsigned int i=0; i<tracks.size(); i++) {
02576           reco::TrackRef track = tracks[i].castTo<reco::TrackRef>();
02577         
02578           TrackingParticleRef myTP;
02579           for (size_t j = 0; j < RtoSCollPtrs.size(); j++) {          
02580             reco::RecoToSimCollection q = *(RtoSCollPtrs[j]);
02581           
02582             RefToBase<reco::Track> myTk( track );
02583           
02584             if( q.find(myTk ) != q.end() ) {
02585               std::vector<std::pair<TrackingParticleRef, double> > tp = q[myTk];
02586               for (unsigned int itp=0; itp<tp.size(); itp++) {
02587                 myTP=tp[itp].first;
02588                 //            std::cout << " associated with TP " << myTP->pdgId() << " pt " << sqrt(myTP->momentum().perp2()) << std::endl;
02589                 myAss.insert( std::make_pair ( track  , myTP) );
02590                 nAssT2++;
02591               }
02592             }
02593           }
02594         
02595           if ( nAssT2 == 2) {
02596           
02597           
02598             h_RecoConvTwoMTracks_[0]->Fill( aPho.eta() ) ;
02599             h_RecoConvTwoMTracks_[1]->Fill( aPho.phi() );
02600             if (  aConv->conversionVertex().isValid() ) h_RecoConvTwoMTracks_[2]->Fill(  aConv->conversionVertex().position().perp2() );
02601             h_RecoConvTwoMTracks_[3]->Fill( aConv->conversionVertex().position().z() );
02602             h_RecoConvTwoMTracks_[4]->Fill( aPho.et() ) ;
02603           
02604           }
02605         }
02606 
02608         if ( aConv->conversionVertex().isValid() ) {
02609           float chi2Prob = ChiSquaredProbability( aConv->conversionVertex().chi2(),  aConv->conversionVertex().ndof() );
02610         
02611           double convR= sqrt(aConv->conversionVertex().position().perp2());
02612           double scalar = aConv->conversionVertex().position().x()*aConv->pairMomentum().x() + 
02613             aConv->conversionVertex().position().y()*aConv->pairMomentum().y();
02614           if ( scalar < 0 ) convR= -sqrt(aConv->conversionVertex().position().perp2());
02615         
02616           if ( ! isRunCentrally_ ) h2_etaVsRreco_[0]->Fill (aConv->caloCluster()[0]->eta(),sqrt(aConv->conversionVertex().position().perp2()) );         
02617           h_convVtxRvsZ_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  sqrt(aConv->conversionVertex().position().perp2())  ) ;
02618           if ( fabs(aConv->caloCluster()[0]->eta() ) <= 1.) {
02619           
02620             h_convVtxYvsX_ ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x()  ) ;
02621             h_convVtxRvsZ_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR  ) ;
02622           
02623             if ( ! isRunCentrally_ ) {
02624               h_convVtxYvsX_zoom_[0] ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x()  ) ;
02625               h_convVtxYvsX_zoom_[1] ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x()  ) ;
02626               h_convVtxRvsZ_zoom_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR  ) ;
02627               h_convVtxRvsZ_zoom_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR ) ;
02628             }
02629           
02630           }
02631           if ( fabs(aConv->caloCluster()[0]->eta() ) > 1.)      h_convVtxRvsZ_[2] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR  ) ;
02632         
02633         
02634         
02635         
02636           h_vtxChi2Prob_[0]->Fill( chi2Prob ); 
02637           h_vtxChi2_[0]->Fill(  aConv->conversionVertex().normalizedChi2() );
02638           if ( phoIsInBarrel ) {
02639             h_vtxChi2Prob_[1]->Fill( chi2Prob );
02640             h_vtxChi2_[1]->Fill( aConv->conversionVertex().normalizedChi2() ); 
02641           }
02642           if ( phoIsInEndcap ) {   
02643             h_vtxChi2Prob_[2]->Fill(  chi2Prob );
02644             h_vtxChi2_[2]->Fill( aConv->conversionVertex().normalizedChi2() );
02645           }
02646         
02647         } // end conversion vertex valid
02648       } // end loop over reco conversions
02649     } // end loop on all reco photons
02650   } // if !fastSim
02651 
02652   
02653 
02655   float nPho=0;
02656   for (reco::GenJetCollection::const_iterator genJetIter = genJetCollection.begin();
02657        genJetIter != genJetCollection.end();     ++genJetIter) {
02658     
02659     if ( genJetIter->pt() < minPhoEtCut_ ) continue;
02660     if ( fabs(genJetIter->eta())  > 2.5 ) continue;
02661  
02662     float mcJetPhi= genJetIter->phi();
02663     mcJetPhi_= phiNormalization(mcJetPhi);
02664     mcJetEta_= genJetIter->eta();
02665     float mcJetPt = genJetIter->pt() ;
02666     
02667     h_SimJet_[0]->Fill ( mcJetEta_);
02668     h_SimJet_[1]->Fill ( mcJetPhi_);
02669     h_SimJet_[2]->Fill ( mcJetPt );
02670 
02671     std::vector<reco::Photon> thePhotons;
02672     bool matched=false;
02673     
02674     reco::Photon matchingPho;    
02675     for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
02676       reco::Photon aPho = reco::Photon(*iPho);
02677       float phiPho=aPho.phi();
02678       float etaPho=aPho.eta();
02679       float deltaPhi = phiPho-mcJetPhi_;
02680       float deltaEta = etaPho-mcJetEta_;
02681       if ( deltaPhi > pi )  deltaPhi -= twopi;
02682       if ( deltaPhi < -pi) deltaPhi += twopi;
02683       deltaPhi=pow(deltaPhi,2);
02684       deltaEta=pow(deltaEta,2);
02685       float delta = sqrt( deltaPhi+deltaEta); 
02686       if ( delta<0.3 ) {
02687         matchingPho = * iPho;
02688         matched = true;
02689       }
02690     }  // end loop over reco photons
02691 
02692     if (!  matched ) continue;
02693     nPho++;
02694 
02695     h_MatchedSimJet_[0]->Fill( mcJetEta_ ) ;
02696     h_MatchedSimJet_[1]->Fill( mcJetPhi_ );
02697     h_MatchedSimJet_[2]->Fill( mcJetPt );
02698 
02699 
02700     bool  phoIsInBarrel=false;
02701     bool  phoIsInEndcap=false;
02702     if ( fabs(matchingPho.superCluster()->position().eta() ) < 1.479 ) {
02703       phoIsInBarrel=true;
02704     } else {
02705       phoIsInEndcap=true;
02706     }
02707     edm::Handle<EcalRecHitCollection>   ecalRecHitHandle;
02708     if ( phoIsInBarrel ) {
02709       // Get handle to rec hits ecal barrel 
02710       e.getByLabel(barrelEcalHits_, ecalRecHitHandle);
02711       if (!ecalRecHitHandle.isValid()) {
02712         edm::LogError("PhotonProducer") << "Error! Can't get the product "<<barrelEcalHits_.label();
02713         return;
02714       }
02715       
02716     } else if ( phoIsInEndcap ) {    
02717       
02718       // Get handle to rec hits ecal encap 
02719       e.getByLabel(endcapEcalHits_, ecalRecHitHandle);
02720       if (!ecalRecHitHandle.isValid()) {
02721         edm::LogError("PhotonProducer") << "Error! Can't get the product "<<endcapEcalHits_.label();
02722         return;
02723       }
02724       
02725     }
02726     
02727 
02728 
02729     const EcalRecHitCollection ecalRecHitCollection = *(ecalRecHitHandle.product());
02730     float photonE = matchingPho.energy();
02731     float photonEt= matchingPho.et();
02732     float r9 = matchingPho.r9();
02733     float r1 = matchingPho.r1x5();
02734     float r2 = matchingPho.r2x5();
02735     float sigmaIetaIeta =  matchingPho.sigmaIetaIeta();
02736     float hOverE = matchingPho.hadronicOverEm();
02737     float ecalIso = matchingPho.ecalRecHitSumEtConeDR04();
02738     float hcalIso = matchingPho.hcalTowerSumEtConeDR04();
02739     float trkIso =  matchingPho.trkSumPtSolidConeDR04();
02740     float nIsoTrk   =  matchingPho.nTrkSolidConeDR04();
02741     std::vector< std::pair<DetId, float> >::const_iterator rhIt;
02742     
02743     bool atLeastOneDeadChannel=false;
02744       for(reco::CaloCluster_iterator bcIt = matchingPho.superCluster()->clustersBegin();bcIt != matchingPho.superCluster()->clustersEnd(); ++bcIt) {
02745         for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
02746           
02747           for(EcalRecHitCollection::const_iterator it =  ecalRecHitCollection.begin(); it !=  ecalRecHitCollection.end(); ++it) {
02748             if  (rhIt->first ==  (*it).id() ) {
02749               if (  (*it).recoFlag() == 9 ) {
02750                 atLeastOneDeadChannel=true;
02751                 break;
02752               }
02753             }
02754           }
02755         } 
02756       }
02757       
02758       if (   atLeastOneDeadChannel ) {
02759         h_MatchedSimJetBadCh_[0]->Fill( mcJetEta_ ) ;
02760         h_MatchedSimJetBadCh_[1]->Fill( mcJetPhi_ );
02761         h_MatchedSimJetBadCh_[2]->Fill( mcJetPt );
02762         
02763       }
02764 
02765       h_scBkgEta_->Fill( matchingPho.superCluster()->eta() );
02766       h_scBkgPhi_->Fill( matchingPho.superCluster()->phi() );
02767       h_scBkgE_[0]->Fill( matchingPho.superCluster()->energy() );
02768       h_scBkgEt_[0]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
02769       //
02770       h_phoBkgEta_->Fill( matchingPho.eta() );
02771       h_phoBkgPhi_->Fill( matchingPho.phi() );
02772       h_phoBkgE_[0]->Fill( photonE );
02773       h_phoBkgEt_[0]->Fill( photonEt);
02774       h_phoBkgDEta_->Fill (  matchingPho.eta() - mcJetEta_ );
02775       h_phoBkgDPhi_->Fill (  matchingPho.phi() - mcJetPhi_ );
02776 
02777       
02778       h_r9Bkg_[0]->Fill( r9 );
02779       h_r1Bkg_[0]->Fill( r1 );
02780       h_r2Bkg_[0]->Fill( r2 );
02781       h_sigmaIetaIetaBkg_[0]->Fill( sigmaIetaIeta );
02782       h_hOverEBkg_[0]->Fill( hOverE );
02783       h_ecalRecHitSumEtConeDR04Bkg_[0]->Fill( ecalIso );
02784       h_hcalTowerSumEtConeDR04Bkg_[0]->Fill( hcalIso );
02785       h_isoTrkSolidConeDR04Bkg_[0]->Fill( trkIso );
02786       h_nTrkSolidConeDR04Bkg_[0]->Fill( nIsoTrk );
02787       
02788 
02789       h2_r9VsEtaBkg_ -> Fill (mcJetEta_, r9);      
02790       h2_r9VsEtBkg_ -> Fill (mcJetPt, r9);      
02791 
02792       h2_r1VsEtaBkg_ -> Fill (mcJetEta_, r1);      
02793       h2_r1VsEtBkg_ -> Fill (mcJetPt, r1);      
02794       p_r1VsEtaBkg_ -> Fill (mcJetEta_, r1);      
02795       p_r1VsEtBkg_ -> Fill (mcJetPt, r1);      
02796 
02797       h2_r2VsEtaBkg_ -> Fill (mcJetEta_, r2);      
02798       h2_r2VsEtBkg_ -> Fill (mcJetPt, r2);  
02799       p_r2VsEtaBkg_ -> Fill (mcJetEta_, r2);      
02800       p_r2VsEtBkg_ -> Fill (mcJetPt, r2);  
02801 
02802 
02803       h2_sigmaIetaIetaVsEtaBkg_ -> Fill (mcJetEta_, sigmaIetaIeta );      
02804       p_sigmaIetaIetaVsEtaBkg_ -> Fill (mcJetEta_, sigmaIetaIeta );      
02805       h2_sigmaIetaIetaVsEtBkg_[0] -> Fill (mcJetPt, sigmaIetaIeta);
02806       p_sigmaIetaIetaVsEtBkg_[0] -> Fill (mcJetPt, sigmaIetaIeta);
02807 
02808 
02809       h2_hOverEVsEtaBkg_ -> Fill (mcJetEta_, hOverE );      
02810       h2_hOverEVsEtBkg_ -> Fill (mcJetPt, hOverE);
02811       p_hOverEVsEtaBkg_ -> Fill (mcJetEta_, hOverE );      
02812       p_hOverEVsEtBkg_ -> Fill (mcJetPt, hOverE);
02813 
02814 
02815       h2_ecalRecHitSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, ecalIso );      
02816       p_ecalRecHitSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, ecalIso );      
02817       h2_ecalRecHitSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, ecalIso);      
02818       p_ecalRecHitSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, ecalIso);
02819 
02820 
02821       h2_hcalTowerSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, hcalIso );      
02822       p_hcalTowerSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, hcalIso );      
02823       h2_hcalTowerSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, hcalIso);      
02824       p_hcalTowerSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, hcalIso);
02825 
02826       h2_isoTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, trkIso );      
02827       p_isoTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, trkIso );      
02828       h2_isoTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, trkIso); 
02829       p_isoTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, trkIso); 
02830 
02831 
02832       h2_nTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, nIsoTrk );      
02833       p_nTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, nIsoTrk );      
02834       h2_nTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, nIsoTrk); 
02835       p_nTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, nIsoTrk); 
02836 
02837 
02838 
02839 
02840       if ( phoIsInBarrel ) {
02841 
02842         h_r9Bkg_[1]->Fill( r9 );
02843         h_r1Bkg_[1]->Fill( r1 );
02844         h_r2Bkg_[1]->Fill( r2 );
02845 
02846 
02847         h_sigmaIetaIetaBkg_[1]->Fill( sigmaIetaIeta );
02848         h_hOverEBkg_[1]->Fill( hOverE );
02849         h_ecalRecHitSumEtConeDR04Bkg_[1]->Fill( ecalIso );
02850         h_hcalTowerSumEtConeDR04Bkg_[1]->Fill( hcalIso );
02851         h_isoTrkSolidConeDR04Bkg_[1]->Fill( trkIso );
02852         h_nTrkSolidConeDR04Bkg_[1]->Fill( nIsoTrk );
02853 
02854         h2_sigmaIetaIetaVsEtBkg_[1] -> Fill (mcJetPt, sigmaIetaIeta);
02855         p_sigmaIetaIetaVsEtBkg_[1] -> Fill (mcJetPt, sigmaIetaIeta);
02856 
02857         h2_ecalRecHitSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, ecalIso);   
02858         p_ecalRecHitSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, ecalIso);   
02859 
02860         h2_hcalTowerSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, hcalIso);      
02861         p_hcalTowerSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, hcalIso);
02862 
02863         h2_isoTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, trkIso); 
02864         p_isoTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, trkIso); 
02865 
02866         h2_nTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, nIsoTrk); 
02867         p_nTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, nIsoTrk); 
02868 
02869 
02870       } else if ( phoIsInEndcap )  {
02871         
02872         h_r9Bkg_[2]->Fill( r9 );
02873         h_r1Bkg_[2]->Fill( r1 );
02874         h_r2Bkg_[2]->Fill( r2 );
02875 
02876         h_sigmaIetaIetaBkg_[2]->Fill( sigmaIetaIeta );
02877         h_hOverEBkg_[2]->Fill( hOverE );
02878         h_ecalRecHitSumEtConeDR04Bkg_[2]->Fill( ecalIso );
02879         h_hcalTowerSumEtConeDR04Bkg_[2]->Fill( hcalIso );
02880         h_isoTrkSolidConeDR04Bkg_[2]->Fill( trkIso );
02881         h_nTrkSolidConeDR04Bkg_[2]->Fill( nIsoTrk );
02882 
02883         h2_sigmaIetaIetaVsEtBkg_[2] -> Fill (mcJetPt, sigmaIetaIeta);
02884         p_sigmaIetaIetaVsEtBkg_[2] -> Fill (mcJetPt, sigmaIetaIeta);
02885 
02886         h2_ecalRecHitSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, ecalIso);   
02887         p_ecalRecHitSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, ecalIso);   
02888 
02889         h2_hcalTowerSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, hcalIso);      
02890         p_hcalTowerSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, hcalIso);
02891 
02892         h2_isoTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, trkIso); 
02893         p_isoTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, trkIso); 
02894 
02895         h2_nTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, nIsoTrk); 
02896         p_nTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, nIsoTrk); 
02897 
02898 
02899       }
02900 
02901       if ( !fastSim_) {
02903         reco::ConversionRefVector conversions = matchingPho.conversions();
02904         for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
02905           reco::ConversionRef aConv=conversions[iConv];
02906           //std::vector<reco::TrackRef> tracks = aConv->tracks();
02907           const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
02908           double like = aConv->MVAout();
02909           if ( like < likelihoodCut_ ) continue;      
02910           if ( tracks.size() < 2 ) continue;    
02911           h_convEtaBkg_->Fill( aConv->caloCluster()[0]->eta() );
02912           h_convPhiBkg_->Fill( aConv->caloCluster()[0]->phi() );
02913           h_mvaOutBkg_[0]-> Fill(like);
02914           float eoverp= aConv->EoverP();
02915           h_EoverPTracksBkg_[0] ->Fill( eoverp ) ;
02916           h_PoverETracksBkg_[0] ->Fill( 1./eoverp ) ;
02917           h_DCotTracksBkg_[0] ->Fill ( aConv->pairCotThetaSeparation() );
02918           float  dPhiTracksAtVtx =  aConv->dPhiTracksAtVtx();
02919           h_DPhiTracksAtVtxBkg_[0]->Fill( dPhiTracksAtVtx);
02920         
02921           if ( phoIsInBarrel ) {
02922             h_mvaOutBkg_[1]-> Fill(like);
02923             h_EoverPTracksBkg_[1] ->Fill( eoverp ) ;
02924             h_PoverETracksBkg_[1] ->Fill( 1./eoverp ) ;
02925             h_DCotTracksBkg_[1] ->Fill ( aConv->pairCotThetaSeparation() );
02926             h_DPhiTracksAtVtxBkg_[1]->Fill( dPhiTracksAtVtx);
02927           }     else if ( phoIsInEndcap )  {
02928             h_mvaOutBkg_[2]-> Fill(like);
02929             h_EoverPTracksBkg_[2] ->Fill( eoverp ) ;
02930             h_PoverETracksBkg_[2] ->Fill( 1./eoverp ) ;
02931             h_DCotTracksBkg_[2] ->Fill ( aConv->pairCotThetaSeparation() );
02932             h_DPhiTracksAtVtxBkg_[2]->Fill( dPhiTracksAtVtx);
02933           }
02934         
02935           if ( aConv->conversionVertex().isValid() ) {
02936           
02937             double convR= sqrt(aConv->conversionVertex().position().perp2());
02938             double scalar = aConv->conversionVertex().position().x()*aConv->pairMomentum().x() + 
02939               aConv->conversionVertex().position().y()*aConv->pairMomentum().y();
02940             if ( scalar < 0 ) convR= -sqrt(aConv->conversionVertex().position().perp2());
02941           
02942             if ( ! isRunCentrally_ ) {
02943               h_convVtxRvsZBkg_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  sqrt(aConv->conversionVertex().position().perp2())  ) ;
02944               if ( fabs(aConv->caloCluster()[0]->eta() ) <= 1.) {
02945                 h_convVtxYvsXBkg_ ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x()  ) ;
02946                 h_convVtxRvsZBkg_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR  ) ;
02947               }
02948             }
02949 
02950 
02951           } // end vertex valid
02952         
02953         
02954         } // end loop over conversions
02955       } // if !fastSim
02956   } // end loop over sim jets
02957   
02958   h_nPho_->Fill(float(nPho));
02959 
02960 }
02961 
02962 
02963 
02964 
02965 
02966 void PhotonValidator::endJob() {
02967 
02968 
02969   std::string outputFileName = parameters_.getParameter<std::string>("OutputFileName");
02970   if ( ! isRunCentrally_ ) {
02971     dbe_->save(outputFileName);
02972   }
02973   
02974   edm::LogInfo("PhotonValidator") << "Analyzed " << nEvt_  << "\n";
02975   // std::cout  << "::endJob Analyzed " << nEvt_ << " events " << " with total " << nPho_ << " Photons " << "\n";
02976   //  std::cout  << "PhotonValidator::endJob Analyzed " << nEvt_ << " events " << "\n";
02977     
02978   return ;
02979 }
02980  
02981 float PhotonValidator::phiNormalization(float & phi)
02982 {
02983   //---Definitions
02984   const float PI    = 3.1415927;
02985   const float TWOPI = 2.0*PI;
02986 
02987 
02988   if(phi >  PI) {phi = phi - TWOPI;}
02989   if(phi < -PI) {phi = phi + TWOPI;}
02990 
02991   //  cout << " Float_t PHInormalization out " << PHI << endl;
02992   return phi;
02993 
02994 }
02995 
02996 
02997 float PhotonValidator::etaTransformation(  float EtaParticle , float Zvertex)  {
02998 
02999   //---Definitions
03000   const float PI    = 3.1415927;
03001 
03002   //---Definitions for ECAL
03003   const float R_ECAL           = 136.5;
03004   const float Z_Endcap         = 328.0;
03005   const float etaBarrelEndcap  = 1.479; 
03006    
03007   //---ETA correction
03008 
03009   float Theta = 0.0  ; 
03010   float ZEcal = R_ECAL*sinh(EtaParticle)+Zvertex;
03011 
03012   if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
03013   if(Theta<0.0) Theta = Theta+PI ;
03014   float ETA = - log(tan(0.5*Theta));
03015          
03016   if( fabs(ETA) > etaBarrelEndcap )
03017     {
03018       float Zend = Z_Endcap ;
03019       if(EtaParticle<0.0 )  Zend = -Zend ;
03020       float Zlen = Zend - Zvertex ;
03021       float RR = Zlen/sinh(EtaParticle); 
03022       Theta = atan(RR/Zend);
03023       if(Theta<0.0) Theta = Theta+PI ;
03024       ETA = - log(tan(0.5*Theta));                    
03025     } 
03026   //---Return the result
03027   return ETA;
03028   //---end
03029 }
03030 
03031