CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes

PhotonValidator Class Reference

#include <PhotonValidator.h>

Inheritance diagram for PhotonValidator:
edm::EDAnalyzer

List of all members.

Classes

class  sortPhotons

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob ()
virtual void beginRun (edm::Run const &r, edm::EventSetup const &theEventSetup)
virtual void endJob ()
virtual void endRun (edm::Run &r, edm::EventSetup const &es)
 PhotonValidator (const edm::ParameterSet &)
virtual ~PhotonValidator ()

Private Member Functions

float etaTransformation (float a, float b)
float phiNormalization (float &a)

Private Attributes

edm::InputTag barrelEcalHits_
edm::InputTag bcBarrelCollection_
edm::InputTag bcEndcapCollection_
double bcEtLow_
std::string conversionIOTrackProducer_
std::string conversionOITrackProducer_
double convTrackMinPtCut_
DQMStoredbe_
bool dCotCutOn_
double dCotCutValue_
double dCotHardCutValue_
double ecalEtSumCut_
double ecalIsolRadius_
edm::InputTag endcapEcalHits_
bool fastSim_
std::string fName_
MonitorElementh2_Chi2VsEta_ [3]
MonitorElementh2_Chi2VsR_ [3]
MonitorElementh2_convVtxdRVsEta_
MonitorElementh2_convVtxdRVsR_
MonitorElementh2_convVtxRrecVsTrue_
MonitorElementh2_DCotTracksVsEta_
MonitorElementh2_DCotTracksVsR_
MonitorElementh2_DPhiTracksAtEcalVsEta_
MonitorElementh2_DPhiTracksAtEcalVsR_
MonitorElementh2_DPhiTracksAtVtxVsEta_
MonitorElementh2_DPhiTracksAtVtxVsR_
MonitorElementh2_dzPVVsR_
MonitorElementh2_ecalRecHitSumEtConeDR04VsEt_ [3]
MonitorElementh2_ecalRecHitSumEtConeDR04VsEta_ [3]
MonitorElementh2_ecalRecHitSumEtConeDR04VsEtaBkg_
MonitorElementh2_ecalRecHitSumEtConeDR04VsEtBkg_ [3]
MonitorElementh2_EoverEtrueVsEoverP_ [3]
MonitorElementh2_EoverEtrueVsEta_ [3]
MonitorElementh2_EoverEtrueVsR_ [3]
MonitorElementh2_EoverPVsEta_ [3]
MonitorElementh2_EoverPVsR_ [3]
MonitorElementh2_eResVsEt_ [3][3]
MonitorElementh2_eResVsEta_ [3]
MonitorElementh2_eResVsR9_ [3]
MonitorElementh2_etaVsRreco_ [3]
MonitorElementh2_etaVsRsim_ [3]
MonitorElementh2_hcalTowerSumEtConeDR04VsEt_ [3]
MonitorElementh2_hcalTowerSumEtConeDR04VsEta_ [3]
MonitorElementh2_hcalTowerSumEtConeDR04VsEtaBkg_
MonitorElementh2_hcalTowerSumEtConeDR04VsEtBkg_ [3]
MonitorElementh2_hOverEVsEt_ [3]
MonitorElementh2_hOverEVsEta_ [3]
MonitorElementh2_hOverEVsEtaBkg_
MonitorElementh2_hOverEVsEtBkg_
MonitorElementh2_isoTrkSolidConeDR04VsEt_ [3]
MonitorElementh2_isoTrkSolidConeDR04VsEta_ [3]
MonitorElementh2_isoTrkSolidConeDR04VsEtaBkg_
MonitorElementh2_isoTrkSolidConeDR04VsEtBkg_ [3]
MonitorElementh2_nTrkSolidConeDR04VsEt_ [3]
MonitorElementh2_nTrkSolidConeDR04VsEta_ [3]
MonitorElementh2_nTrkSolidConeDR04VsEtaBkg_
MonitorElementh2_nTrkSolidConeDR04VsEtBkg_ [3]
MonitorElementh2_PoverPtrueVsEoverP_ [3]
MonitorElementh2_PoverPtrueVsEta_ [3]
MonitorElementh2_PtRecVsPtSim_ [3]
MonitorElementh2_PtRecVsPtSimMixProv_
MonitorElementh2_r1VsEt_ [3]
MonitorElementh2_r1VsEta_ [3]
MonitorElementh2_r1VsEtaBkg_
MonitorElementh2_r1VsEtBkg_
MonitorElementh2_r2VsEt_ [3]
MonitorElementh2_r2VsEta_ [3]
MonitorElementh2_r2VsEtaBkg_
MonitorElementh2_r2VsEtBkg_
MonitorElementh2_r9VsEt_ [3]
MonitorElementh2_r9VsEta_ [3]
MonitorElementh2_r9VsEtaBkg_
MonitorElementh2_r9VsEtBkg_
MonitorElementh2_sceResVsR9_ [3]
MonitorElementh2_sigmaIetaIetaVsEt_ [3]
MonitorElementh2_sigmaIetaIetaVsEta_ [3]
MonitorElementh2_sigmaIetaIetaVsEtaBkg_
MonitorElementh2_sigmaIetaIetaVsEtBkg_ [3]
MonitorElementh2_TkPtPull_ [3]
MonitorElementh_AllSimConv_ [5]
MonitorElementh_convERes_ [2][3]
MonitorElementh_convEta_ [3]
MonitorElementh_convEtaBkg_
MonitorElementh_convPhi_ [2]
MonitorElementh_convPhiBkg_
MonitorElementh_convPtRes_ [2][3]
MonitorElementh_convVtxdEta_
MonitorElementh_convVtxdPhi_
MonitorElementh_convVtxdR_
MonitorElementh_convVtxdR_barrel_
MonitorElementh_convVtxdR_endcap_
MonitorElementh_convVtxdX_
MonitorElementh_convVtxdX_barrel_
MonitorElementh_convVtxdX_endcap_
MonitorElementh_convVtxdY_
MonitorElementh_convVtxdY_barrel_
MonitorElementh_convVtxdY_endcap_
MonitorElementh_convVtxdZ_
MonitorElementh_convVtxdZ_barrel_
MonitorElementh_convVtxdZ_endcap_
MonitorElementh_convVtxRvsZ_ [3]
MonitorElementh_convVtxRvsZ_zoom_ [2]
MonitorElementh_convVtxRvsZBkg_ [2]
MonitorElementh_convVtxYvsX_
MonitorElementh_convVtxYvsX_zoom_ [2]
MonitorElementh_convVtxYvsXBkg_
MonitorElementh_DCotTracks_ [2][3]
MonitorElementh_DCotTracksBkg_ [3]
MonitorElementh_DEtaTracksAtEcal_ [2][3]
MonitorElementh_distMinAppTracks_ [2][3]
MonitorElementh_DPhiTracksAtEcal_ [2][3]
MonitorElementh_DPhiTracksAtVtx_ [2][3]
MonitorElementh_DPhiTracksAtVtxBkg_ [3]
MonitorElementh_dzPVFromTracks_ [5]
MonitorElementh_ecalRecHitSumEtConeDR04_ [3][3]
MonitorElementh_ecalRecHitSumEtConeDR04Bkg_ [3]
MonitorElementh_EoverPTracks_ [2][3]
MonitorElementh_EoverPTracksBkg_ [3]
MonitorElementh_EtR9Less093_ [3][3]
MonitorElementh_gamgamMass_ [3][3]
MonitorElementh_hcalTowerSumEtConeDR04_ [3][3]
MonitorElementh_hcalTowerSumEtConeDR04Bkg_ [3]
MonitorElementh_hOverE_ [3][3]
MonitorElementh_hOverEBkg_ [3]
MonitorElementh_invMass_ [2][3]
MonitorElementh_IOinnermostHitR_
MonitorElementh_isoTrkSolidConeDR04_ [3][3]
MonitorElementh_isoTrkSolidConeDR04Bkg_ [3]
MonitorElementh_MatchedSimJet_ [3]
MonitorElementh_MatchedSimJetBadCh_ [3]
MonitorElementh_MatchedSimPho_ [3]
 Numerator for efficiencies.
MonitorElementh_MatchedSimPhoBadCh_ [3]
MonitorElementh_mvaOut_ [3]
MonitorElementh_mvaOutBkg_ [3]
MonitorElementh_nConv_ [2][3]
 info per conversion
MonitorElementh_nPho_
MonitorElementh_nRecoVtx_
MonitorElementh_nSimConv_ [2]
MonitorElementh_nSimPho_ [2]
MonitorElementh_nTrkSolidConeDR04_ [3][3]
MonitorElementh_nTrkSolidConeDR04Bkg_ [3]
MonitorElementh_OIinnermostHitR_
MonitorElementh_phoBkgDEta_
MonitorElementh_phoBkgDPhi_
MonitorElementh_phoBkgE_ [3]
MonitorElementh_phoBkgEt_ [3]
MonitorElementh_phoBkgEta_
MonitorElementh_phoBkgPhi_
MonitorElementh_phoDEta_ [2]
MonitorElementh_phoDPhi_ [2]
MonitorElementh_phoE_ [2][3]
MonitorElementh_phoERes_ [3][3]
MonitorElementh_phoEt_ [2][3]
MonitorElementh_phoEta_ [2]
MonitorElementh_phoPhi_ [2]
MonitorElementh_PoverETracks_ [2][3]
MonitorElementh_PoverETracksBkg_ [3]
MonitorElementh_psE_
MonitorElementh_r1_ [3][3]
MonitorElementh_r1Bkg_ [3]
MonitorElementh_r2_ [3][3]
MonitorElementh_r2Bkg_ [3]
MonitorElementh_r9_ [3][3]
MonitorElementh_r9Bkg_ [3]
MonitorElementh_r9VsNofTracks_ [2][3]
MonitorElementh_RecoConvTwoMTracks_ [5]
MonitorElementh_RecoConvTwoTracks_ [5]
MonitorElementh_scBkgE_ [3]
MonitorElementh_scBkgEt_ [3]
MonitorElementh_scBkgEta_
MonitorElementh_scBkgPhi_
MonitorElementh_scE_ [2][3]
MonitorElementh_scEt_ [2][3]
MonitorElementh_scEta_ [2]
MonitorElementh_scEtaPhi_ [2]
MonitorElementh_scEtaWidth_ [2]
MonitorElementh_scPhi_ [2]
MonitorElementh_scPhiWidth_ [2]
MonitorElementh_sigmaIetaIeta_ [3][3]
MonitorElementh_sigmaIetaIetaBkg_ [3]
MonitorElementh_SimConvEtaPix_ [2]
MonitorElementh_SimConvOneMTracks_ [5]
MonitorElementh_SimConvOneTracks_ [5]
MonitorElementh_SimConvTwoMTracks_ [5]
MonitorElementh_SimConvTwoMTracksAndVtxPGT0005_ [5]
MonitorElementh_SimConvTwoMTracksAndVtxPGT01_ [5]
MonitorElementh_SimConvTwoMTracksAndVtxPGT0_ [5]
MonitorElementh_SimConvTwoTracks_ [5]
MonitorElementh_simConvVtxRvsZ_ [4]
MonitorElementh_simConvVtxYvsX_
MonitorElementh_SimJet_ [3]
MonitorElementh_SimPho_ [3]
 Denominator for efficiencies.
MonitorElementh_SimPhoEtaSmallR9_
MonitorElementh_SimPhoMotherEt_ [2]
MonitorElementh_SimPhoMotherEta_ [2]
MonitorElementh_SimPhoMotherType_ [2]
MonitorElementh_simTkEta_
MonitorElementh_simTkPt_
MonitorElementh_tkChi2_ [2]
MonitorElementh_tkChi2Bkg_
MonitorElementh_tkChi2Large_ [2]
MonitorElementh_TkD0_ [3]
MonitorElementh_TkPtPull_ [3]
MonitorElementh_trkProv_ [2]
MonitorElementh_VisSimConv_ [6]
MonitorElementh_VisSimConvLarge_
MonitorElementh_vtxChi2_ [3]
MonitorElementh_vtxChi2Prob_ [3]
MonitorElementh_zPVFromTracks_ [5]
MonitorElementhBCEnergyOverTrackPout_ [3]
double hcalEtSumCut_
double hcalHitEtLow_
double hcalIsolExtRadius_
double hcalIsolInnRadius_
bool isRunCentrally_
edm::InputTag label_tp_
double likelihoodCut_
double lip_
double mcConvEta_
double mcConvPhi_
double mcConvR_
double mcConvX_
double mcConvY_
double mcConvZ_
double mcEta_
double mcJetEta_
double mcJetPhi_
double mcPhi_
 global variable for the MC photon
double minPhoEtCut_
int nEntry_
int nEvt_
MonitorElementnHitsVsEta_ [2]
MonitorElementnHitsVsEtaBkg_
MonitorElementnHitsVsR_ [2]
int nInvalidPCA_
int nMatched_
int nRecConv_
int nRecConvAss_
int nRecConvAssWithEcal_
int nSimConv_ [2]
int nSimPho_ [2]
int numOfTracksInCone_
MonitorElementp_Chi2VsEta_ [3]
MonitorElementp_Chi2VsR_ [3]
MonitorElementp_convVtxdRVsEta_
MonitorElementp_convVtxdRVsR_
MonitorElementp_convVtxdXVsX_
MonitorElementp_convVtxdYVsY_
MonitorElementp_convVtxdZVsZ_
MonitorElementp_DCotTracksVsEta_
MonitorElementp_DCotTracksVsR_
MonitorElementp_DPhiTracksAtEcalVsEta_
MonitorElementp_DPhiTracksAtEcalVsR_
MonitorElementp_DPhiTracksAtVtxVsEta_
MonitorElementp_DPhiTracksAtVtxVsR_
MonitorElementp_dzPVVsEta_
MonitorElementp_dzPVVsR_
MonitorElementp_ecalRecHitSumEtConeDR04VsEt_ [3]
MonitorElementp_ecalRecHitSumEtConeDR04VsEta_ [3]
MonitorElementp_ecalRecHitSumEtConeDR04VsEtaBkg_
MonitorElementp_ecalRecHitSumEtConeDR04VsEtBkg_ [3]
MonitorElementp_EoverEtrueVsEta_ [3]
MonitorElementp_EoverEtrueVsR_ [3]
MonitorElementp_EoverPVsEta_ [3]
MonitorElementp_EoverPVsR_ [3]
MonitorElementp_eResVsEt_ [3][3]
MonitorElementp_eResVsEta_ [3]
MonitorElementp_eResVsR9_ [3]
MonitorElementp_eResVsR_
MonitorElementp_hcalTowerSumEtConeDR04VsEt_ [3]
MonitorElementp_hcalTowerSumEtConeDR04VsEta_ [3]
MonitorElementp_hcalTowerSumEtConeDR04VsEtaBkg_
MonitorElementp_hcalTowerSumEtConeDR04VsEtBkg_ [3]
MonitorElementp_hOverEVsEt_ [3]
MonitorElementp_hOverEVsEta_ [3]
MonitorElementp_hOverEVsEtaBkg_
MonitorElementp_hOverEVsEtBkg_
MonitorElementp_isoTrkSolidConeDR04VsEt_ [3]
MonitorElementp_isoTrkSolidConeDR04VsEta_ [3]
MonitorElementp_isoTrkSolidConeDR04VsEtaBkg_
MonitorElementp_isoTrkSolidConeDR04VsEtBkg_ [3]
MonitorElementp_nHitsVsEta_ [2]
MonitorElementp_nHitsVsR_ [2]
MonitorElementp_nTrkSolidConeDR04VsEt_ [3]
MonitorElementp_nTrkSolidConeDR04VsEta_ [3]
MonitorElementp_nTrkSolidConeDR04VsEtaBkg_
MonitorElementp_nTrkSolidConeDR04VsEtBkg_ [3]
MonitorElementp_PoverPtrueVsEta_ [3]
MonitorElementp_r1VsEt_ [3]
MonitorElementp_r1VsEta_ [3]
MonitorElementp_r1VsEtaBkg_
MonitorElementp_r1VsEtBkg_
MonitorElementp_r2VsEt_ [3]
MonitorElementp_r2VsEta_ [3]
MonitorElementp_r2VsEtaBkg_
MonitorElementp_r2VsEtBkg_
MonitorElementp_r9VsEt_ [3]
MonitorElementp_r9VsEta_ [3]
MonitorElementp_sceResVsR9_ [3]
MonitorElementp_sigmaIetaIetaVsEt_ [3]
MonitorElementp_sigmaIetaIetaVsEta_ [3]
MonitorElementp_sigmaIetaIetaVsEtaBkg_
MonitorElementp_sigmaIetaIetaVsEtBkg_ [3]
MonitorElementp_TkPtPull_ [3]
edm::ParameterSet parameters_
std::string photonCollection_
std::string photonCollectionProducer_
double recMaxPt_
double recMinPt_
 Global variables for reco Photon.
double simMaxPt_
double simMinPt_
edm::ESHandle< CaloGeometrytheCaloGeom_
edm::ESHandle< CaloTopologytheCaloTopo_
edm::RefVector
< TrackingParticleCollection
theConvTP_
edm::ESHandle< MagneticFieldtheMF_
PhotonMCTruthFinderthePhotonMCTruthFinder_
TrackAssociatorBasetheTrackAssociator_
double trkIsolExtRadius_
double trkIsolInnRadius_
double trkPtLow_
double trkPtSumCut_
int verbosity_

Detailed Description

$Id: PhotonValidator

Date:
2012/02/14 19:43:43
Revision:
1.2
Author:
Nancy Marinelli, U. of Notre Dame, US

$Id: PhotonValidator

Date:
2011/05/20 13:55:42
Revision:
1.1
Author:
Nancy Marinelli, U. of Notre Dame, US

Definition at line 49 of file PhotonValidator.h.


Constructor & Destructor Documentation

PhotonValidator::PhotonValidator ( const edm::ParameterSet pset) [explicit]

Definition at line 93 of file PhotonValidator.cc.

References edm::ParameterSet::getParameter(), and edm::ParameterSet::getUntrackedParameter().

  {

    fName_     = pset.getUntrackedParameter<std::string>("Name");
    verbosity_ = pset.getUntrackedParameter<int>("Verbosity");
    parameters_ = pset;
    fastSim_ =   pset.getParameter<bool>("fastSim");
    isRunCentrally_=   pset.getParameter<bool>("isRunCentrally");

    photonCollectionProducer_ = pset.getParameter<std::string>("phoProducer");
    photonCollection_ = pset.getParameter<std::string>("photonCollection");


    label_tp_   = pset.getParameter<edm::InputTag>("label_tp");

    barrelEcalHits_   = pset.getParameter<edm::InputTag>("barrelEcalHits");
    endcapEcalHits_   = pset.getParameter<edm::InputTag>("endcapEcalHits");

    conversionOITrackProducer_ = pset.getParameter<std::string>("conversionOITrackProducer");
    conversionIOTrackProducer_ = pset.getParameter<std::string>("conversionIOTrackProducer");


    minPhoEtCut_ = pset.getParameter<double>("minPhoEtCut");
    convTrackMinPtCut_ = pset.getParameter<double>("convTrackMinPtCut");
    likelihoodCut_ = pset.getParameter<double>("likelihoodCut");

    trkIsolExtRadius_ = pset.getParameter<double>("trkIsolExtR");
    trkIsolInnRadius_ = pset.getParameter<double>("trkIsolInnR");
    trkPtLow_     = pset.getParameter<double>("minTrackPtCut");
    lip_       = pset.getParameter<double>("lipCut");
    ecalIsolRadius_ = pset.getParameter<double>("ecalIsolR");
    bcEtLow_     = pset.getParameter<double>("minBcEtCut");
    hcalIsolExtRadius_ = pset.getParameter<double>("hcalIsolExtR");
    hcalIsolInnRadius_ = pset.getParameter<double>("hcalIsolInnR");
    hcalHitEtLow_     = pset.getParameter<double>("minHcalHitEtCut");

    numOfTracksInCone_ = pset.getParameter<int>("maxNumOfTracksInCone");
    trkPtSumCut_  = pset.getParameter<double>("trkPtSumCut");
    ecalEtSumCut_ = pset.getParameter<double>("ecalEtSumCut");
    hcalEtSumCut_ = pset.getParameter<double>("hcalEtSumCut");
    dCotCutOn_ = pset.getParameter<bool>("dCotCutOn");
    dCotCutValue_ = pset.getParameter<double>("dCotCutValue");
    dCotHardCutValue_ = pset.getParameter<double>("dCotHardCutValue");

  }
PhotonValidator::~PhotonValidator ( ) [virtual]

Definition at line 143 of file PhotonValidator.cc.

{}

Member Function Documentation

void PhotonValidator::analyze ( const edm::Event e,
const edm::EventSetup esup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 1375 of file PhotonValidator.cc.

References abs, edm::SortedCollection< T, SORT >::begin(), DeDxDiscriminatorTools::charge(), ChiSquaredProbability(), conversions_cfi::conversions, reco::Photon::conversions(), gather_cfg::cout, delta, HLTFastRecoForTau_cff::deltaEta, SiPixelRawToDigiRegional_cfi::deltaPhi, dPhi(), reco::Photon::ecalRecHitSumEtConeDR04(), edm::AssociationMap< Tag >::end(), edm::SortedCollection< T, SORT >::end(), reco::LeafCandidate::energy(), reco::LeafCandidate::et(), reco::LeafCandidate::eta(), event(), HcalObjRepresent::Fill(), edm::AssociationMap< Tag >::find(), configurableAnalysis::GenParticle, edm::RefToBase< T >::get(), edm::EventSetup::get(), edm::Event::getByLabel(), reco::Photon::hadronicOverEm(), reco::Photon::hcalTowerSumEtConeDR04(), i, edm::EventBase::id(), getHLTprescales::index, edm::Ref< C, T, F >::isNonnull(), edm::HandleBase::isValid(), edm::Ref< C, T, F >::key(), reco::TrackBase::momentum(), reco::Photon::nTrkSolidConeDR04(), p1, p2, parents, benchmark_cfg::pdgId, reco::LeafCandidate::phi(), pi, funct::pow(), edm::Handle< T >::product(), edm::RefToBaseVector< T >::push_back(), lumiQueryAPI::q, diffTwoXMLs::r1, reco::Photon::r1x5(), diffTwoXMLs::r2, reco::Photon::r2x5(), reco::Photon::r9(), hitfit::scalar(), reco::Photon::sigmaIetaIeta(), funct::sin(), findQualityFiles::size, edm::RefVector< C, T, F >::size(), python::multivaluedict::sort(), mathSSE::sqrt(), reco::Photon::superCluster(), trackingParticlesFastSim_cfi::trackingParticles, testEve_cfg::tracks, and reco::Photon::trkSumPtSolidConeDR04().

                                                                            {


  using namespace edm;
  //  const float etaPhiDistance=0.01;
  // Fiducial region
  // const float TRK_BARL =0.9;
  const float BARL = 1.4442; // DAQ TDR p.290
  //  const float END_LO = 1.566; // unused
  const float END_HI = 2.5;
  // Electron mass
  //const Float_t mElec= 0.000511;


  nEvt_++;
  LogInfo("PhotonValidator") << "PhotonValidator Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n";
  //  std::cout << "PhotonValidator Analyzing event number: "  << e.id() << " Global Counter " << nEvt_ <<"\n";


  // get the geometry from the event setup:
  esup.get<CaloGeometryRecord>().get(theCaloGeom_);

  edm::Handle<reco::VertexCollection> vtxH;
  e.getByLabel("offlinePrimaryVertices", vtxH);
  h_nRecoVtx_ ->Fill (float(vtxH->size()));

  // Transform Track into TransientTrack (needed by the Vertex fitter)
  edm::ESHandle<TransientTrackBuilder> theTTB;
  esup.get<TransientTrackRecord>().get("TransientTrackBuilder",theTTB);


  Handle<reco::PhotonCollection> photonHandle;
  e.getByLabel(photonCollectionProducer_, photonCollection_ , photonHandle);
  const reco::PhotonCollection photonCollection = *(photonHandle.product());
  if (!photonHandle.isValid()) {
    edm::LogError("PhotonProducer") << "Error! Can't get the Photon collection "<< std::endl;
    return;
  }

  Handle< edm::View<reco::Track> > outInTrkHandle;
  Handle< edm::View<reco::Track> > inOutTrkHandle;
  if ( !fastSim_) {
    e.getByLabel(conversionOITrackProducer_,  outInTrkHandle);
    //std::cout << "ConvPhoAnalyzerWithOfficialAssociation  outInTrack collection size " << (*outInTrkHandle).size() << "\n";

    e.getByLabel(conversionIOTrackProducer_, inOutTrkHandle);
    //std::cout  << " ConvPhoAnalyzerWithOfficialAssociation inOutTrack collection size " << (*inOutTrkHandle).size() << "\n";

    // Loop over Out In Tracks
    int iTrk=0;
    int nHits=0;
    for( View<reco::Track>::const_iterator    iTk =  (*outInTrkHandle).begin(); iTk !=  (*outInTrkHandle).end(); iTk++) {
      //    std::cout  << " Barrel  Out In Track charge " << iTk->charge() << " Num of RecHits " << iTk->recHitsSize() << " inner momentum " << sqrt( iTk->innerMomentum().Mag2() ) << "\n";
      // std::cout  << " Barrel Out In Track Extra inner momentum  " << sqrt(iTk->extra()->innerMomentum().Mag2()) <<  " inner position R " <<  sqrt( iTk->innerPosition().Perp2() ) << "\n";
      h_OIinnermostHitR_ ->Fill ( sqrt( iTk->innerPosition().Perp2() ) );
      for (  trackingRecHit_iterator itHits=iTk->extra()->recHitsBegin();  itHits!=iTk->extra()->recHitsEnd(); ++itHits ) {
        if ( (*itHits)->isValid() ) {
          nHits++;
          //    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";
        }


      }

      iTrk++;


    }

    // Loop over In Out Tracks Barrel
    iTrk=0;
    for( View<reco::Track>::const_iterator    iTk =  (*inOutTrkHandle).begin(); iTk !=  (*inOutTrkHandle).end(); iTk++) {
      //std::cout  << " Barrel In Out Track charge " << iTk->charge() << " Num of RecHits " << iTk->recHitsSize() << " inner momentum " << sqrt( iTk->innerMomentum().Mag2())  << "\n";
      // std::cout   << " Barrel In Out  Track Extra inner momentum  " << sqrt(iTk->extra()->innerMomentum().Mag2()) << "\n";
      h_IOinnermostHitR_ ->Fill ( sqrt( iTk->innerPosition().Perp2() ) );
      nHits=0;
      for (  trackingRecHit_iterator itHits=iTk->extra()->recHitsBegin();  itHits!=iTk->extra()->recHitsEnd(); ++itHits ) {
        if ( (*itHits)->isValid() ) {
          nHits++;
          //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";

        }
      }



      iTrk++;
    }

  }  // if !fastSim


  //get simtrack info
  std::vector<SimTrack> theSimTracks;
  std::vector<SimVertex> theSimVertices;
  edm::Handle<SimTrackContainer> SimTk;
  edm::Handle<SimVertexContainer> SimVtx;

  if ( ! fastSim_) {
    e.getByLabel("g4SimHits",SimTk);
    e.getByLabel("g4SimHits",SimVtx);
  } else {
    e.getByLabel("famosSimHits",SimTk);
    e.getByLabel("famosSimHits",SimVtx);

  }



  theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
  theSimVertices.insert(theSimVertices.end(),SimVtx->begin(),SimVtx->end());
  std::vector<PhotonMCTruth> mcPhotons=thePhotonMCTruthFinder_->find (theSimTracks,  theSimVertices);

  edm::Handle<edm::HepMCProduct> hepMC;
  e.getByLabel("generator",hepMC);
  const HepMC::GenEvent *myGenEvent = hepMC->GetEvent();


  // get generated jets
  Handle<reco::GenJetCollection> GenJetsHandle ;
  e.getByLabel("iterativeCone5GenJets","",GenJetsHandle);
  reco::GenJetCollection genJetCollection = *(GenJetsHandle.product());



  // Get electron tracking truth
  bool useTP= parameters_.getParameter<bool>("useTP");
  TrackingParticleCollection trackingParticles;
  edm::Handle<TrackingParticleCollection> ElectronTPHandle;
  if ( useTP) {
    if ( ! fastSim_) {
    e.getByLabel(label_tp_,ElectronTPHandle);
    //  e.getByLabel("mergedtruth","MergedTrackTruth",ElectronTPHandle);
    trackingParticles = *(ElectronTPHandle.product());
    }
  }

  std::vector<reco::PhotonCollection::const_iterator> StoRMatchedConvertedPhotons;
  reco::SimToRecoCollection OISimToReco;
  reco::SimToRecoCollection IOSimToReco;
  // Reco to Sim
  reco::RecoToSimCollection OIRecoToSim;
  reco::RecoToSimCollection IORecoToSim;

  if ( useTP) {
    if ( ! fastSim_) {
    // Sim to Reco
    OISimToReco = theTrackAssociator_->associateSimToReco(outInTrkHandle, ElectronTPHandle, &e);
    IOSimToReco = theTrackAssociator_->associateSimToReco(inOutTrkHandle, ElectronTPHandle, &e);
    // Reco to Sim
    OIRecoToSim = theTrackAssociator_->associateRecoToSim(outInTrkHandle, ElectronTPHandle, &e);
    IORecoToSim = theTrackAssociator_->associateRecoToSim(inOutTrkHandle, ElectronTPHandle, &e);
    }
  }
  //
  vector<reco::SimToRecoCollection*> StoRCollPtrs;
  StoRCollPtrs.push_back(&OISimToReco);
  StoRCollPtrs.push_back(&IOSimToReco);
  vector<reco::RecoToSimCollection*> RtoSCollPtrs;
  RtoSCollPtrs.push_back(&OIRecoToSim);
  RtoSCollPtrs.push_back(&IORecoToSim);
  //
  for (int i=0; i<2; i++)
    nSimPho_[i]=0;
  for (int i=0; i<2; i++)
    nSimConv_[i]=0;


  std::vector<reco::Photon> myPhotons;
  for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
    if ( fabs(iPho->eta()) > 2.5 ) continue;
    myPhotons.push_back(*iPho);
  }

  std::sort(myPhotons.begin(), myPhotons.end(), sortPhotons());
  if ( ! isRunCentrally_ ) { 
    if ( myPhotons.size() >=2 ) {
      if ( myPhotons[0].et() > 40 && myPhotons[1].et() > 25 ) {
        
        math::XYZTLorentzVector p12 = myPhotons[0].p4()+myPhotons[1].p4();
        float gamgamMass2 = p12.Dot(p12);
        if (  gamgamMass2 > 0 ) {
          
          // total
          h_gamgamMass_[0][0] -> Fill(sqrt( gamgamMass2 ));
          if (  myPhotons[0].isEB() &&   myPhotons[1].isEB() )
            h_gamgamMass_[0][1] -> Fill(sqrt( gamgamMass2 ));
          if ( (  myPhotons[0].isEE() &&         myPhotons[1].isEE() )  ||
               (  myPhotons[0].isEE() &&         myPhotons[1].isEB() ) ||
               (  myPhotons[0].isEB() &&         myPhotons[1].isEE() ) )
            h_gamgamMass_[0][2] -> Fill(sqrt( gamgamMass2 ));
          
          
          // Golden photons
          if (  myPhotons[0].r9() > 0.93 &&  myPhotons[1].r9() > 0.93 ) {
            h_gamgamMass_[1][0] -> Fill(sqrt( gamgamMass2 ));
            if (  myPhotons[0].isEB() &&         myPhotons[1].isEB() )
              h_gamgamMass_[1][1] -> Fill(sqrt( gamgamMass2 ));
            if ( (  myPhotons[0].isEE() &&       myPhotons[1].isEE() )  ||
                 (  myPhotons[0].isEE() &&       myPhotons[1].isEB() ) ||
                 (  myPhotons[0].isEB() &&       myPhotons[1].isEE() ) )
              h_gamgamMass_[1][2] -> Fill(sqrt( gamgamMass2 ));
          }
          
          
          // both photons converted
          if ( myPhotons[0].conversions().size() > 0 && myPhotons[1].conversions().size() >0 ) {
            if ( myPhotons[0].conversions()[0]->nTracks() ==2 &&  myPhotons[1].conversions()[0]->nTracks() ==2  ) {
              float chi2Prob1 = ChiSquaredProbability( myPhotons[0].conversions()[0]->conversionVertex().chi2(),  myPhotons[0].conversions()[0]->conversionVertex().ndof() );
              float chi2Prob2 = ChiSquaredProbability( myPhotons[1].conversions()[0]->conversionVertex().chi2(),  myPhotons[1].conversions()[0]->conversionVertex().ndof() );
              if ( chi2Prob1 > 0.0005 &&  chi2Prob2 > 0.0005 ) {
                h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
                if (  myPhotons[0].isEB() &&     myPhotons[1].isEB() ) {
                  h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
                }
                if ( (  myPhotons[0].isEE() &&   myPhotons[1].isEE() )  ||
                     (  myPhotons[0].isEE() &&   myPhotons[1].isEB() ) ||
                     (  myPhotons[0].isEB() &&   myPhotons[1].isEE() ) )
                  h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 )); {
                }
              }
            }
            
            
          } else if ( myPhotons[0].conversions().size() > 0 && myPhotons[1].conversions().size() ==0 && myPhotons[1].r9() > 0.93  )  {  // one photon converted
            if ( myPhotons[0].conversions()[0]->nTracks() ==2 ) {
              float chi2Prob1 = ChiSquaredProbability( myPhotons[0].conversions()[0]->conversionVertex().chi2(),  myPhotons[0].conversions()[0]->conversionVertex().ndof() );
              if ( chi2Prob1 > 0.0005 ) {
                h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
                if (  myPhotons[0].isEB() &&  myPhotons[1].isEB() ) {
                  h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
                }
                if (  myPhotons[0].isEE() ||  myPhotons[1].isEE() ) {
                  h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 ));
                }
              }
            }
            
            
          } else if ( myPhotons[1].conversions().size() > 0 && myPhotons[0].conversions().size() ==0 &&  myPhotons[0].r9() > 0.93 )  {  // one photon converted
            if ( myPhotons[1].conversions()[0]->nTracks() ==2 ) {
              float chi2Prob1 = ChiSquaredProbability( myPhotons[1].conversions()[0]->conversionVertex().chi2(),  myPhotons[1].conversions()[0]->conversionVertex().ndof() );
              if ( chi2Prob1 > 0.0005 ) {
                h_gamgamMass_[2][0] -> Fill(sqrt( gamgamMass2 ));
                if (  myPhotons[0].isEB() && myPhotons[1].isEB() ) {
                  h_gamgamMass_[2][1] -> Fill(sqrt( gamgamMass2 ));
                }
                if (  myPhotons[0].isEE() ||  myPhotons[1].isEE() ) {
                  h_gamgamMass_[2][2] -> Fill(sqrt( gamgamMass2 ));
                }
              }
            }
          }
          
          
        }
      }
    }
  }


  //  cout << " PhotonValidator mcPhotons.size() " << mcPhotons.size() << endl;
  for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
    if ( (*mcPho).fourMomentum().et() < minPhoEtCut_ ) continue;

    for ( HepMC::GenEvent::particle_const_iterator mcIter=myGenEvent->particles_begin(); mcIter != myGenEvent->particles_end(); mcIter++ ) {
      if ( (*mcIter)->pdg_id() != 22 ) continue;
      bool isTheSame= false;
      HepMC::GenParticle* mother = 0;
      if ( (*mcIter)->production_vertex() )  {
        if ( (*mcIter)->production_vertex()->particles_begin(HepMC::parents) !=
             (*mcIter)->production_vertex()->particles_end(HepMC::parents))
          mother = *((*mcIter)->production_vertex()->particles_begin(HepMC::parents));
      }




      float mcPhi= (*mcPho).fourMomentum().phi();
      mcPhi_= phiNormalization(mcPhi);
      mcEta_= (*mcPho).fourMomentum().pseudoRapidity();
      mcEta_ = etaTransformation(mcEta_, (*mcPho).primaryVertex().z() );
      mcConvR_= (*mcPho).vertex().perp();
      mcConvX_= (*mcPho).vertex().x();
      mcConvY_= (*mcPho).vertex().y();
      mcConvZ_= (*mcPho).vertex().z();
      mcConvEta_= (*mcPho).vertex().eta();
      mcConvPhi_= (*mcPho).vertex().phi();

      if ( fabs(mcEta_) > END_HI ) continue;



      if (  mother ==0
            ||  (mother != 0  && mother->pdg_id() == 22)
            ||  (mother != 0  && mother->pdg_id() == 25)
            ||  (mother != 0  && mother->pdg_id() == 35) )
        {
          //std::cout << " ZERO mother or Higgs or primary photon  " << std::endl;
          //if (mother !=0) std::cout <<  mother->pdg_id() << std::endl;
          double dPt =  fabs((*mcIter)->momentum().perp() - (*mcPho).fourMomentum().et());
          float phiMother=(*mcIter)->momentum().phi();
          double dPhi = phiNormalization(phiMother) - mcPhi_ ;
          double dEta = fabs( (*mcIter)->momentum().eta() - (*mcPho).fourMomentum().pseudoRapidity() );

          //std::cout << " HEP photon pt " << (*mcIter)->momentum().perp() << " eta " << (*mcIter)->momentum().eta() << " phi " << (*mcIter)->momentum().phi() << std::endl;
          //std::cout << "   (*mcPho).motherType() selection  " <<   (*mcPho).motherType() << " pt " <<  (*mcPho).fourMomentum().et()  << " eta " << (*mcPho).fourMomentum().pseudoRapidity() << " phi " << mcPhi_ << std::endl;
          //std::cout << " dPt " << dPt << " dEta " << dEta << " dPhi " << dPhi << std::endl;
          if ( dEta <=0.0001 && dPhi <=0.0001 && dPt <=0.0001)
            isTheSame = true;

        }
      if ( ! isTheSame ) continue;
      //      std::cout << " HEP photon pt " << (*mcIter)->momentum().perp() << " eta " << (*mcIter)->momentum().eta() << " phi " << (*mcIter)->momentum().phi() << std::endl;
      //std::cout << "   (*mcPho).motherType() after  " <<   (*mcPho).motherType() << " pt " <<  (*mcPho).fourMomentum().et()  << " eta " << (*mcPho).fourMomentum().pseudoRapidity() << " phi " << mcPhi_ << std::endl;



      // if ( ! (  fabs(mcEta_) <= BARL || ( fabs(mcEta_) >= END_LO && fabs(mcEta_) <=END_HI ) ) )
      //        continue;  // all ecal fiducial region

      nSimPho_[0]++;
      if ( ! isRunCentrally_ ) {
        h_SimPhoMotherEt_[0]->Fill(  (*mcPho).motherMomentum().et()  );
        h_SimPhoMotherEta_[0]->Fill(  (*mcPho).motherMomentum().pseudoRapidity());
      }

      h_SimPho_[0]->Fill ( mcEta_);
      h_SimPho_[1]->Fill ( mcPhi_);
      h_SimPho_[2]->Fill ( (*mcPho).fourMomentum().et()   );





      bool goodSimConversion=false;
      bool visibleConversion=false;
      bool visibleConversionsWithTwoSimTracks=false;
      if (  (*mcPho).isAConversion() == 1 ) {
        nSimConv_[0]++;
        h_AllSimConv_[0]->Fill( mcEta_ ) ;
        h_AllSimConv_[1]->Fill( mcPhi_ );
        h_AllSimConv_[2]->Fill( mcConvR_ );
        h_AllSimConv_[3]->Fill( mcConvZ_ );
        h_AllSimConv_[4]->Fill(  (*mcPho).fourMomentum().et());

        if ( ! isRunCentrally_ ) {
          if ( mcConvR_ <15) h_SimConvEtaPix_[0]->Fill( mcEta_ ) ;
        }

        if ( ( fabs(mcEta_) <= BARL && mcConvR_ <85 )  ||
             ( fabs(mcEta_) > BARL && fabs(mcEta_) <=END_HI && fabs( (*mcPho).vertex().z() ) < 210 )  ) visibleConversion=true;



        theConvTP_.clear();
        //std::cout << " PhotonValidator TrackingParticles   TrackingParticleCollection size "<<  trackingParticles.size() <<  "\n";
        for(size_t i = 0; i < trackingParticles.size(); ++i){
          TrackingParticleRef tp (ElectronTPHandle,i);
          //std::cout << "  Electron pt " << tp -> pt() << " charge " << tp -> charge() << " pdgId " << tp->pdgId() << " Hits for this track: " << tp -> trackPSimHit().size() << std::endl;
          //std::cout << " track vertex position x " <<  tp->vertex().x() << " y " << tp->vertex().y() << " z " << tp->vertex().z() << std::endl;
          //std::cout << " track vertex position x " <<  tp->vx() << " y " << tp->vy() << " z " << tp->vz() << std::endl;
          //std::cout << " conversion vertex position x " <<  (*mcPho).vertex().x() << " y " << (*mcPho).vertex().y() << " z " << (*mcPho).vertex().z() << std::endl;
          if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.001   &&
               fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.001   &&
               fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.001) {

            //std::cout << " From conversion Electron pt " << tp -> pt() << " charge " << tp -> charge() << " pdgId " << tp->pdgId() << " Hits for this track: " << tp -> trackPSimHit().size() << std::endl;
            //  std::cout << " track vertex position x " <<  tp->vertex().x() << " y " << tp->vertex().y() << " z " << tp->vertex().z() << std::endl;
            //std::cout << " conversion vertex position x " <<  (*mcPho).vertex().x() << " y " << (*mcPho).vertex().y() << " z " << (*mcPho).vertex().z() << "  R " <<  (*mcPho).vertex().perp() << std::endl;
            theConvTP_.push_back( tp );
          }
        }
        //      std::cout << " PhotonValidator  theConvTP_ size " <<   theConvTP_.size() << std::endl;

        if ( theConvTP_.size() == 2 )   visibleConversionsWithTwoSimTracks=true;
        goodSimConversion=false;

        if (   visibleConversion && visibleConversionsWithTwoSimTracks )  goodSimConversion=true;
        if ( goodSimConversion ) {
          nSimConv_[1]++;
          h_VisSimConv_[0]->Fill( mcEta_ ) ;
          h_VisSimConv_[1]->Fill( mcPhi_ );
          h_VisSimConv_[2]->Fill( mcConvR_ );
          h_VisSimConv_[3]->Fill( mcConvZ_ );
          h_VisSimConv_[4]->Fill(  (*mcPho).fourMomentum().et());


          if ( useTP ) {
            if ( ! isRunCentrally_ ) {
              for ( edm::RefVector<TrackingParticleCollection>::iterator iTrk=theConvTP_.begin(); iTrk!=theConvTP_.end(); ++iTrk) {
                h_simTkPt_ -> Fill ( (*iTrk)->pt() );
                h_simTkEta_ -> Fill ( (*iTrk)->eta() );
              }
            }

          }
        }
      }  



      float minDelta=10000.;
      std::vector<reco::Photon> thePhotons;
      int index=0;
      int iMatch=-1;
      bool matched=false;

      //std::cout << " Reco photon size " <<  photonCollection.size() << std::endl;
      for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
        reco::Photon aPho = reco::Photon(*iPho);
        thePhotons.push_back(aPho);
        float phiPho=aPho.phi();
        float etaPho=aPho.eta();
        float deltaPhi = phiPho-mcPhi_;
        float deltaEta = etaPho-mcEta_;
        if ( deltaPhi > pi )  deltaPhi -= twopi;
        if ( deltaPhi < -pi) deltaPhi += twopi;
        deltaPhi=pow(deltaPhi,2);
        deltaEta=pow(deltaEta,2);
        float delta = sqrt( deltaPhi+deltaEta);
        if ( delta<0.1 && delta < minDelta ) {
          minDelta=delta;
          iMatch=index;

        }
        index++;
      }  // end loop over reco photons
      if ( iMatch>-1 ) matched=true;


      if ( matched ) {
        nSimPho_[1]++;
        if ( ! isRunCentrally_ ) {
          h_SimPhoMotherEt_[1]->Fill(  (*mcPho).motherMomentum().et()  );
          h_SimPhoMotherEta_[1]->Fill(  (*mcPho).motherMomentum().pseudoRapidity());
        }
        h_MatchedSimPho_[0]->Fill( mcEta_ ) ;
        h_MatchedSimPho_[1]->Fill( mcPhi_ );
        h_MatchedSimPho_[2]->Fill(  (*mcPho).fourMomentum().et());

      }




      if ( ! matched) continue;

      bool  phoIsInBarrel=false;
      bool  phoIsInEndcap=false;
      bool  phoIsInEndcapP=false;
      bool  phoIsInEndcapM=false;

      reco::Photon matchingPho = thePhotons[iMatch];

      if ( fabs(matchingPho.superCluster()->position().eta() ) < 1.479 ) {
        phoIsInBarrel=true;
      } else {
        phoIsInEndcap=true;
        if ( matchingPho.superCluster()->position().eta() > 0) phoIsInEndcapP=true;
        if ( matchingPho.superCluster()->position().eta() < 0) phoIsInEndcapM=true;

      }
      edm::Handle<EcalRecHitCollection>   ecalRecHitHandle;
      if ( phoIsInBarrel ) {
        // Get handle to rec hits ecal barrel
        e.getByLabel(barrelEcalHits_, ecalRecHitHandle);
        if (!ecalRecHitHandle.isValid()) {
          edm::LogError("PhotonProducer") << "Error! Can't get the product "<<barrelEcalHits_.label();
          return;
        }

      } else if ( phoIsInEndcap ) {

        // Get handle to rec hits ecal encap
        e.getByLabel(endcapEcalHits_, ecalRecHitHandle);
        if (!ecalRecHitHandle.isValid()) {
          edm::LogError("PhotonProducer") << "Error! Can't get the product "<<endcapEcalHits_.label();
          return;
        }

      }



      int type=0;
      const EcalRecHitCollection ecalRecHitCollection = *(ecalRecHitHandle.product());
      float photonE = matchingPho.energy();
      float photonEt= matchingPho.energy()/cosh( matchingPho.eta()) ;
      float r9 = matchingPho.r9();
      float r1 = matchingPho.r1x5();
      float r2 = matchingPho.r2x5();
      float sigmaIetaIeta =  matchingPho.sigmaIetaIeta();
      float hOverE = matchingPho.hadronicOverEm();
      float ecalIso = matchingPho.ecalRecHitSumEtConeDR04();
      float hcalIso = matchingPho.hcalTowerSumEtConeDR04();
      float trkIso =  matchingPho.trkSumPtSolidConeDR04();
      float nIsoTrk   =  matchingPho.nTrkSolidConeDR04();
      std::vector< std::pair<DetId, float> >::const_iterator rhIt;

      bool atLeastOneDeadChannel=false;
      for(reco::CaloCluster_iterator bcIt = matchingPho.superCluster()->clustersBegin();bcIt != matchingPho.superCluster()->clustersEnd(); ++bcIt) {
        for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {

          for(EcalRecHitCollection::const_iterator it =  ecalRecHitCollection.begin(); it !=  ecalRecHitCollection.end(); ++it) {
            if  (rhIt->first ==  (*it).id() ) {
              if (  (*it).recoFlag() == 9 ) {
                atLeastOneDeadChannel=true;
                break;
              }
            }
          }
        }
      }

      if (   atLeastOneDeadChannel ) {
        h_MatchedSimPhoBadCh_[0]->Fill( mcEta_ ) ;
        h_MatchedSimPhoBadCh_[1]->Fill( mcPhi_ );
        h_MatchedSimPhoBadCh_[2]->Fill(  (*mcPho).fourMomentum().et());

      }


      h_scEta_[type]->Fill( matchingPho.superCluster()->eta() );
      h_scPhi_[type]->Fill( matchingPho.superCluster()->phi() );
      if ( ! isRunCentrally_ ) {
        h_scEtaWidth_[type]->Fill( matchingPho.superCluster()->etaWidth() );
        h_scPhiWidth_[type]->Fill( matchingPho.superCluster()->phiWidth() );
      }
      h_scE_[type][0]->Fill( matchingPho.superCluster()->energy() );
      h_scEt_[type][0]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
      if ( phoIsInEndcap ) h_psE_->Fill( matchingPho.superCluster()->preshowerEnergy() ) ;
      //
      h_r9_[type][0]->Fill( r9 );
      h2_r9VsEta_[0] -> Fill (mcEta_, r9);
      h2_r9VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r9);
      //
      h_r1_[type][0]->Fill( r1 );
      h2_r1VsEta_[0] -> Fill (mcEta_, r1);
      h2_r1VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r1);
      //
      h_r2_[type][0]->Fill( r2 );
      h2_r2VsEta_[0] -> Fill (mcEta_, r2);
      h2_r2VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), r2);
      //
      h_sigmaIetaIeta_[type][0]->Fill( sigmaIetaIeta );
      h2_sigmaIetaIetaVsEta_[0] -> Fill (mcEta_, sigmaIetaIeta );
      h2_sigmaIetaIetaVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), sigmaIetaIeta);
      //
      h_hOverE_[type][0]->Fill( hOverE );
      if ( ! isRunCentrally_ ) { 
        h2_hOverEVsEta_[0] -> Fill (mcEta_, hOverE );
        h2_hOverEVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hOverE);
      }
      p_hOverEVsEta_[0] -> Fill (mcEta_, hOverE );
      p_hOverEVsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hOverE);
      //
      h_ecalRecHitSumEtConeDR04_[type][0]->Fill( ecalIso );
      if ( ! isRunCentrally_ ) { 
        h2_ecalRecHitSumEtConeDR04VsEta_[0] -> Fill (mcEta_, ecalIso );
        h2_ecalRecHitSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
        h2_hcalTowerSumEtConeDR04VsEta_[0] -> Fill (mcEta_, hcalIso );
        h2_hcalTowerSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
 
      }
      p_ecalRecHitSumEtConeDR04VsEta_[0] -> Fill (mcEta_, ecalIso );
      p_ecalRecHitSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
      //
      h_hcalTowerSumEtConeDR04_[type][0]->Fill( hcalIso );
      p_hcalTowerSumEtConeDR04VsEta_[0] -> Fill (mcEta_, hcalIso );
      p_hcalTowerSumEtConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
      //
      h_isoTrkSolidConeDR04_[type][0]->Fill( trkIso );
      h2_isoTrkSolidConeDR04VsEta_[0] -> Fill (mcEta_, trkIso );
      h2_isoTrkSolidConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), trkIso);
      //
      h_nTrkSolidConeDR04_[type][0]->Fill( nIsoTrk );
      h2_nTrkSolidConeDR04VsEta_[0] -> Fill (mcEta_, nIsoTrk );
      h2_nTrkSolidConeDR04VsEt_[0] -> Fill ((*mcPho).fourMomentum().et(), nIsoTrk);
      //
      h_phoEta_[type]->Fill( matchingPho.eta() );
      h_phoPhi_[type]->Fill( matchingPho.phi() );
      h_phoDEta_[0]->Fill (  matchingPho.eta() - (*mcPho).fourMomentum().eta() );
      h_phoDPhi_[0]->Fill (  matchingPho.phi() - mcPhi_ );
      h_phoE_[type][0]->Fill( photonE );
      h_phoEt_[type][0]->Fill( photonEt);
      //
      h_phoERes_[0][0]->Fill( photonE / (*mcPho).fourMomentum().e() );
      h2_eResVsEta_[0]->Fill (mcEta_, photonE/(*mcPho).fourMomentum().e()  ) ;
      p_eResVsEta_[0]->Fill (mcEta_, photonE/(*mcPho).fourMomentum().e()  ) ;

      if ( ! isRunCentrally_ ) h2_eResVsEt_[0][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
      p_eResVsEt_[0][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;

      h2_eResVsR9_[0]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
      h2_sceResVsR9_[0]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
      p_eResVsR9_[0]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
      p_sceResVsR9_[0]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
      //
      if (  (*mcPho).isAConversion() == 0 ) {
        h2_eResVsEta_[1]->Fill (mcEta_, photonE/ (*mcPho).fourMomentum().e()  ) ;



        h2_r9VsEta_[1] -> Fill (mcEta_, r9);
        h2_r9VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r9);
        //
        h2_r1VsEta_[1] -> Fill (mcEta_, r1);
        h2_r1VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r1);
        //
        h2_r2VsEta_[1] -> Fill (mcEta_, r2);
        h2_r2VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), r2);
        //
        h2_sigmaIetaIetaVsEta_[1] -> Fill (mcEta_, sigmaIetaIeta );
        h2_sigmaIetaIetaVsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), sigmaIetaIeta);
        //
        if ( ! isRunCentrally_ ) { 
          h2_hOverEVsEta_[1] -> Fill (mcEta_, hOverE );
          h2_hOverEVsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hOverE);
        }
        //
        if ( ! isRunCentrally_ ) {
          h2_ecalRecHitSumEtConeDR04VsEta_[1] -> Fill (mcEta_, ecalIso );
          h2_hcalTowerSumEtConeDR04VsEta_[1] -> Fill (mcEta_, hcalIso );
        }
        p_ecalRecHitSumEtConeDR04VsEta_[1] -> Fill (mcEta_, ecalIso );
        p_hcalTowerSumEtConeDR04VsEta_[1] -> Fill (mcEta_, hcalIso );
        //
        h2_isoTrkSolidConeDR04VsEta_[1] -> Fill (mcEta_, trkIso );
        h2_isoTrkSolidConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), trkIso);
        //
        h2_nTrkSolidConeDR04VsEta_[1] -> Fill (mcEta_, nIsoTrk );
        h2_nTrkSolidConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), nIsoTrk);

      }




      if ( photonE/(*mcPho).fourMomentum().e()  < 0.3 &&   photonE/(*mcPho).fourMomentum().e() > 0.1 ) {
        //      std::cout << " Eta sim " << mcEta_ << " sc eta " << matchingPho.superCluster()->eta() << " pho eta " << matchingPho.eta() << std::endl;

      }


      if ( (r9>0.94 && phoIsInBarrel) ||   (r9>0.95 && phoIsInEndcap)  )  {
        h_phoERes_[1][0]->Fill( photonE / (*mcPho).fourMomentum().e() );
        if ( ! isRunCentrally_ ) h2_eResVsEt_[0][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
        p_eResVsEt_[0][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
        p_eResVsEta_[1]->Fill (mcEta_,photonE/ (*mcPho).fourMomentum().e()  ) ;

      } else if ( ( r9 <= 0.94&& phoIsInBarrel) ||  ( r9 <= 0.95&& phoIsInEndcap)  ) {
        h_phoERes_[2][0]->Fill(photonE / (*mcPho).fourMomentum().e() );
        p_eResVsEt_[0][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
        p_eResVsEta_[2]->Fill (mcEta_,photonE/ (*mcPho).fourMomentum().e()  ) ;
        if ( ! isRunCentrally_ ) {
          h2_eResVsEt_[0][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
          h_EtR9Less093_[0][0] ->Fill ( photonEt );
        }
        
      }



      if ( phoIsInBarrel ) {
        h_scE_[type][1]->Fill( matchingPho.superCluster()->energy() );
        h_scEt_[type][1]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
        h_r9_[type][1]->Fill( r9 );
        h_r1_[type][1]->Fill( r1 );
        h_r2_[type][1]->Fill( r2 );
        h_sigmaIetaIeta_[type][1]->Fill( sigmaIetaIeta );
        h_hOverE_[type][1]->Fill( hOverE );
        h_ecalRecHitSumEtConeDR04_[type][1]->Fill( ecalIso );
        p_ecalRecHitSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
        h_hcalTowerSumEtConeDR04_[type][1]->Fill( hcalIso );
        p_hcalTowerSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
        h_isoTrkSolidConeDR04_[type][1]->Fill( trkIso );
        h_nTrkSolidConeDR04_[type][1]->Fill( nIsoTrk );
        if ( ! isRunCentrally_ ) {
          h2_ecalRecHitSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
          h2_hcalTowerSumEtConeDR04VsEt_[1] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
        }



        h_phoE_[type][1]->Fill( photonE );
        h_phoEt_[type][1]->Fill( photonEt );
        h_nConv_[type][1]->Fill(float( matchingPho.conversions().size()));


        h_phoERes_[0][1]->Fill( photonE / (*mcPho).fourMomentum().e() );
        h2_eResVsR9_[1]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
        h2_sceResVsR9_[1]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
        p_eResVsR9_[1]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
        p_sceResVsR9_[1]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;

        if ( ! isRunCentrally_ ) h2_eResVsEt_[1][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
        p_eResVsEt_[1][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;


        if ( r9 > 0.94 ) {
          h_phoERes_[1][1]->Fill(  photonE  / (*mcPho).fourMomentum().e() );
          if ( ! isRunCentrally_ ) h2_eResVsEt_[1][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
          p_eResVsEt_[1][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
        }
        if ( r9 <= 0.94 )  {
          h_phoERes_[2][1]->Fill( photonE / (*mcPho).fourMomentum().e() );
          p_eResVsEt_[1][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
          if ( ! isRunCentrally_ ) {
            h2_eResVsEt_[1][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
            h_EtR9Less093_[0][1] ->Fill ( photonEt );
          }
        }
      }
      if ( phoIsInEndcap ) {
        h_scE_[type][2]->Fill( matchingPho.superCluster()->energy() );
        h_scEt_[type][2]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
        h_r9_[type][2]->Fill( r9 );
        h_r1_[type][2]->Fill( r1 );
        h_r2_[type][2]->Fill( r2 );
        h_sigmaIetaIeta_[type][2]->Fill( sigmaIetaIeta );
        h_hOverE_[type][2]->Fill( hOverE );
        h_ecalRecHitSumEtConeDR04_[type][2]->Fill( ecalIso );
        p_ecalRecHitSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
        h_hcalTowerSumEtConeDR04_[type][2]->Fill( hcalIso );
        p_hcalTowerSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
        h_isoTrkSolidConeDR04_[type][2]->Fill( trkIso );
        h_nTrkSolidConeDR04_[type][2]->Fill( nIsoTrk );
        h_phoE_[type][2]->Fill( photonE );
        h_phoEt_[type][2]->Fill( photonEt );
        h_nConv_[type][2]->Fill(float( matchingPho.conversions().size()));
        h_phoERes_[0][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
        h2_eResVsR9_[2]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
        h2_sceResVsR9_[2]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
        p_eResVsR9_[2]->Fill (r9, photonE/(*mcPho).fourMomentum().e()  ) ;
        p_sceResVsR9_[2]->Fill (r9,  matchingPho.superCluster()->energy()/(*mcPho).fourMomentum().e()  ) ;
        if ( ! isRunCentrally_ ) {
          h2_ecalRecHitSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), ecalIso);
          h2_hcalTowerSumEtConeDR04VsEt_[2] -> Fill ((*mcPho).fourMomentum().et(), hcalIso);
          h2_eResVsEt_[2][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
        }

        p_eResVsEt_[2][0]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;

        if ( r9 > 0.95 ) {

          h_phoERes_[1][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
          if ( ! isRunCentrally_ ) h2_eResVsEt_[2][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
          p_eResVsEt_[2][1]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
        }
        if ( r9 <= 0.95 ) {
          h_phoERes_[2][2]->Fill( photonE / (*mcPho).fourMomentum().e() );
          p_eResVsEt_[2][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
          if ( ! isRunCentrally_ ) {
            h2_eResVsEt_[2][2]->Fill ((*mcPho).fourMomentum().et(), photonE/(*mcPho).fourMomentum().e()  ) ;
            h_EtR9Less093_[0][2] ->Fill ( photonEt );
          }
        }
      }




      if ( ! (visibleConversion &&  visibleConversionsWithTwoSimTracks ) ) continue;

      if ( ! isRunCentrally_ ) {
        h_r9_[1][0]->Fill( r9 );
        if ( phoIsInBarrel ) h_r9_[1][1]->Fill( r9 );
        if ( phoIsInEndcap ) h_r9_[1][2]->Fill( r9 );

        h_simConvVtxRvsZ_[0] ->Fill ( fabs (mcConvZ_), mcConvR_  ) ;
        if ( fabs(mcEta_) <=1.) {
          h_simConvVtxRvsZ_[1] ->Fill ( fabs (mcConvZ_), mcConvR_  ) ;
          h_simConvVtxYvsX_ ->Fill ( mcConvX_, mcConvY_  ) ;
        }
        else
          h_simConvVtxRvsZ_[2] ->Fill ( fabs (mcConvZ_), mcConvR_  ) ;
      }


      if ( ! fastSim_) {
        h_nConv_[type][0]->Fill(float( matchingPho.conversions().size()));
        reco::ConversionRefVector conversions = matchingPho.conversions();

        for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
          reco::ConversionRef aConv=conversions[iConv];
          double like = aConv->MVAout();
          if ( like < likelihoodCut_ ) continue;

          if ( ! isRunCentrally_ ) h2_EoverEtrueVsEta_[1]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
          p_EoverEtrueVsEta_[1]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;


          //std::vector<reco::TrackRef> tracks = aConv->tracks();
          const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
          if (tracks.size() < 1 ) continue;


          h_mvaOut_[0]-> Fill(like);

          if ( tracks.size()==2 ) {
            if ( sqrt( aConv->tracksPin()[0].Perp2()) < convTrackMinPtCut_ || sqrt( aConv->tracksPin()[1].Perp2()) < convTrackMinPtCut_) continue;
          } else {
            if ( sqrt( aConv->tracksPin()[0].Perp2()) < convTrackMinPtCut_ ) continue;
          }


          if ( dCotCutOn_ ) {
            if (  (fabs(mcEta_) > 1.1 && fabs (mcEta_)  < 1.4  )  &&
                  fabs( aConv->pairCotThetaSeparation() ) > dCotHardCutValue_ ) continue;
            if ( fabs( aConv->pairCotThetaSeparation() ) > dCotCutValue_ ) continue;
          }

          //std::cout << " PhotonValidator converison algo name " << aConv->algoName() << " " << aConv->algo() << std::endl;

          nRecConv_++;

          std::map<const reco::Track*,TrackingParticleRef> myAss;
          std::map<const reco::Track*,TrackingParticleRef>::const_iterator itAss;
          std::map<reco::TrackRef,TrackingParticleRef>::const_iterator itAssMin;
          std::map<reco::TrackRef,TrackingParticleRef>::const_iterator itAssMax;
          //

          int nAssT2=0;
          for (unsigned int i=0; i<tracks.size(); i++) {
            //      reco::TrackRef track = tracks[i].castTo<reco::TrackRef>();

            type =0;
            if ( ! isRunCentrally_ ) nHitsVsEta_[type] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits())-0.0001 );
            if ( ! isRunCentrally_ ) nHitsVsR_[type] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits())-0.0001 );
            p_nHitsVsEta_[type] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits()) );
            p_nHitsVsR_[type] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits()) );
            h_tkChi2_[type] ->Fill (tracks[i]->normalizedChi2() );


            RefToBase<reco::Track> tfrb = tracks[i];
            RefToBaseVector<reco::Track> tc;
            tc.push_back(tfrb);
            // reco::RecoToSimCollection q = theTrackAssociator_->associateRecoToSim(tc,theConvTP_,&e);
            reco::SimToRecoCollection q = theTrackAssociator_->associateSimToReco(tc,theConvTP_,&e);
            std::vector<std::pair<RefToBase<reco::Track>, double> >  trackV;
            int tpI = 0;

            if (q.find(theConvTP_[0])!=q.end()){
              trackV = (std::vector<std::pair<RefToBase<reco::Track>, double> >) q[theConvTP_[0]];
            } else if (q.find(theConvTP_[1])!=q.end()){
              trackV = (std::vector<std::pair<RefToBase<reco::Track>, double> >) q[theConvTP_[1]];
              tpI = 1;
            }

            if ( !trackV.size() ) continue;
            edm::RefToBase<reco::Track> tr = trackV.front().first;
            myAss.insert( std::make_pair (tr.get(),theConvTP_[tpI] ) );
            nAssT2++;

          }





            /*
            TrackingParticleRef myTP;
            for (size_t j = 0; j < RtoSCollPtrs.size(); j++) {
              reco::RecoToSimCollection q = *(RtoSCollPtrs[j]);

              RefToBase<reco::Track> myTk( track );

              if( q.find(myTk ) != q.end() ) {
                std::vector<std::pair<TrackingParticleRef, double> > tp = q[myTk];
                for (unsigned int itp=0; itp<tp.size(); itp++) {
                  myTP=tp[itp].first;
                  //      std::cout << " associated with TP " << myTP->pdgId() << " pt " << sqrt(myTP->momentum().perp2()) << std::endl;
                  myAss.insert( std::make_pair ( track  , myTP) );
                  nAssT2++;
                }
              }
            }
          }
          */


          type=0;

          //      float totP = sqrt(aConv->pairMomentum().Mag2());
          float refP =-99999.;
          float refPt =-99999.;
          if ( aConv->conversionVertex().isValid() ) {
               refP=sqrt(aConv->refittedPairMomentum().Mag2());
               refPt=sqrt(aConv->refittedPairMomentum().perp2());
          }
          float invM = aConv->pairInvariantMass();

          h_invMass_[type][0] ->Fill( invM);
          if ( phoIsInBarrel ) h_invMass_[type][1] ->Fill(invM);
          if ( phoIsInEndcap ) h_invMass_[type][2] ->Fill(invM);


          if ( tracks.size() ==1  ) {
            h_SimConvOneTracks_[0]->Fill( mcEta_ ) ;
            h_SimConvOneTracks_[1]->Fill( mcPhi_ );
            h_SimConvOneTracks_[2]->Fill( mcConvR_ );
            h_SimConvOneTracks_[3]->Fill( mcConvZ_ );
            h_SimConvOneTracks_[4]->Fill(  (*mcPho).fourMomentum().et());


          } else if ( tracks.size() ==2 ) {

            h_SimConvTwoTracks_[0]->Fill( mcEta_ ) ;
            h_SimConvTwoTracks_[1]->Fill( mcPhi_ );
            h_SimConvTwoTracks_[2]->Fill( mcConvR_ );
            h_SimConvTwoTracks_[3]->Fill( mcConvZ_ );
            h_SimConvTwoTracks_[4]->Fill(  (*mcPho).fourMomentum().et());

            h_convEta_[1]->Fill( aConv->caloCluster()[0]->eta() );

            float trkProvenance=3;
            if ( tracks[0]->algoName() == "outInEcalSeededConv"  &&  tracks[1]->algoName() == "outInEcalSeededConv" ) trkProvenance=0;
            if ( tracks[0]->algoName() == "inOutEcalSeededConv"  &&  tracks[1]->algoName() == "inOutEcalSeededConv" ) trkProvenance=1;
            if ( ( tracks[0]->algoName() == "outInEcalSeededConv"  &&  tracks[1]->algoName() == "inOutEcalSeededConv") ||
                 ( tracks[1]->algoName() == "outInEcalSeededConv"  &&  tracks[0]->algoName() == "inOutEcalSeededConv") ) trkProvenance=2;
            if ( trkProvenance==3 ) {
              // std::cout << " PhotonValidator provenance of tracks is " << tracks[0]->algoName() << " and " << tracks[1]->algoName() << std::endl;
            }
            h_trkProv_[0]->Fill( trkProvenance );



            if ( nAssT2 ==2 ) {



              if ( ! isRunCentrally_ ) {
                h_r9_[2][0]->Fill( r9 );
                if ( phoIsInBarrel ) h_r9_[2][1]->Fill( r9 );
                if ( phoIsInEndcap ) h_r9_[2][2]->Fill( r9 );
              }

              h_convEta_[2]->Fill( aConv->caloCluster()[0]->eta() );
              nRecConvAss_++;


              h_SimConvTwoMTracks_[0]->Fill( mcEta_ ) ;
              h_SimConvTwoMTracks_[1]->Fill( mcPhi_ );
              h_SimConvTwoMTracks_[2]->Fill( mcConvR_ );
              h_SimConvTwoMTracks_[3]->Fill( mcConvZ_ );
              h_SimConvTwoMTracks_[4]->Fill(  (*mcPho).fourMomentum().et());

              if ( aConv->conversionVertex().isValid() ) {
                if ( trkProvenance==3 ) std::cout << " PhotonValidator provenance of tracks is mixed and vertex is valid " << std::endl;
                float chi2Prob = ChiSquaredProbability( aConv->conversionVertex().chi2(),  aConv->conversionVertex().ndof() );
                if (   chi2Prob > 0) {
                  h_SimConvTwoMTracksAndVtxPGT0_[0]->Fill( mcEta_ ) ;
                  h_SimConvTwoMTracksAndVtxPGT0_[1]->Fill( mcPhi_ );
                  h_SimConvTwoMTracksAndVtxPGT0_[2]->Fill( mcConvR_ );
                  h_SimConvTwoMTracksAndVtxPGT0_[3]->Fill( mcConvZ_ );
                  h_SimConvTwoMTracksAndVtxPGT0_[4]->Fill(  (*mcPho).fourMomentum().et());
                }
                if (   chi2Prob > 0.0005) {
                  h_SimConvTwoMTracksAndVtxPGT0005_[0]->Fill( mcEta_ ) ;
                  h_SimConvTwoMTracksAndVtxPGT0005_[1]->Fill( mcPhi_ );
                  h_SimConvTwoMTracksAndVtxPGT0005_[2]->Fill( mcConvR_ );
                  h_SimConvTwoMTracksAndVtxPGT0005_[3]->Fill( mcConvZ_ );
                  h_SimConvTwoMTracksAndVtxPGT0005_[4]->Fill(  (*mcPho).fourMomentum().et());


                }

                if (  chi2Prob > 0.0005 ) {
                  h_convEta_[0]->Fill( aConv->caloCluster()[0]->eta() );
                  h_convPhi_[0]->Fill( aConv->caloCluster()[0]->phi() );
                  h_convERes_[0][0]->Fill( aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
                  if ( ! isRunCentrally_ ) {
                    h_r9VsNofTracks_[0][0]->Fill( r9, aConv->nTracks() ) ;
                    h_EtR9Less093_[1][0] ->Fill ( photonEt );
                    if ( phoIsInBarrel ) h_EtR9Less093_[1][1] ->Fill ( photonEt );
                    if ( phoIsInEndcap ) h_EtR9Less093_[1][2] ->Fill ( photonEt );
                  }

                  if ( phoIsInBarrel )  {
                    h_convERes_[0][1]->Fill(aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
                    if ( ! isRunCentrally_ ) h_r9VsNofTracks_[0][1]->Fill( r9, aConv->nTracks() ) ;
                    h_mvaOut_[1]-> Fill(like);
                  }
                  if ( phoIsInEndcap ) {
                    h_convERes_[0][2]->Fill(aConv->caloCluster()[0]->energy() / (*mcPho).fourMomentum().e() );
                    if ( ! isRunCentrally_ ) h_r9VsNofTracks_[0][2]->Fill( r9, aConv->nTracks() ) ;
                    h_mvaOut_[2]-> Fill(like);
                  }

                }




              }

              type =1;

              h_trkProv_[1]->Fill( trkProvenance );
              h_invMass_[type][0] ->Fill( invM);



              float eoverp= -99999.;

              if ( aConv->conversionVertex().isValid() ) {
                eoverp= aConv->EoverPrefittedTracks();
                h_convPtRes_[type][0]->Fill( refPt / (*mcPho).fourMomentum().et() );
                h_EoverPTracks_[type][0] ->Fill( eoverp ) ;
                h_PoverETracks_[type][0] ->Fill( 1./eoverp ) ;
                if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[0] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
                if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[0] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e()  ) ;
                if ( ! isRunCentrally_ ) h2_EoverPVsEta_[0]->Fill (mcEta_, eoverp);
                if ( ! isRunCentrally_ ) h2_EoverPVsR_[0]->Fill (mcConvR_, eoverp);
                p_EoverPVsEta_[0]->Fill (mcEta_, eoverp);
                p_EoverPVsR_[0]->Fill (mcConvR_, eoverp);
                p_eResVsR_ ->Fill ( mcConvR_, photonE / (*mcPho).fourMomentum().e() );
                 if ( ! isRunCentrally_ ) h2_PoverPtrueVsEta_[0]->Fill (mcEta_,refP/ (*mcPho).fourMomentum().e()  ) ;
                p_PoverPtrueVsEta_[0]->Fill (mcEta_,refP/ (*mcPho).fourMomentum().e()  ) ;


              }


              if ( ! isRunCentrally_ )  h2_EoverEtrueVsEta_[0]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
              if ( ! isRunCentrally_ )  h2_EoverEtrueVsR_[0]->Fill (mcConvR_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
              p_EoverEtrueVsEta_[0]->Fill (mcEta_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
              p_EoverEtrueVsR_[0]->Fill (mcConvR_,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;


              if ( ! isRunCentrally_ ) h2_etaVsRsim_[0]->Fill (mcEta_,mcConvR_);

              /*
              reco::TrackRef track1 = tracks[0].castTo<reco::TrackRef>();
              reco::TrackRef track2 = tracks[1].castTo<reco::TrackRef>();
              reco::TransientTrack tt1 = (*theTTB).build( &track1);
              reco::TransientTrack tt2 = (*theTTB).build( &track2);
              TwoTrackMinimumDistance md;
              md.calculate  (  tt1.initialFreeState(),  tt2.initialFreeState() );
              if (md.status() )  {
                //cout << " Min Dist " << md.distance() << std::endl;
                h_distMinAppTracks_[1][0]->Fill ( md.distance() );
              }  else {
                nInvalidPCA_++;

              }
              */

              //  here original tracks and their inner momentum is considered
              float  dPhiTracksAtVtx =  aConv->dPhiTracksAtVtx();
              h_DPhiTracksAtVtx_[type][0]->Fill( dPhiTracksAtVtx);
              if ( ! isRunCentrally_ ) h2_DPhiTracksAtVtxVsEta_->Fill( mcEta_, dPhiTracksAtVtx);
              if ( ! isRunCentrally_ ) h2_DPhiTracksAtVtxVsR_->Fill( mcConvR_, dPhiTracksAtVtx);
              p_DPhiTracksAtVtxVsEta_->Fill( mcEta_, dPhiTracksAtVtx);
              p_DPhiTracksAtVtxVsR_->Fill( mcConvR_, dPhiTracksAtVtx);

              h_DCotTracks_[type][0] ->Fill ( aConv->pairCotThetaSeparation() );
              if ( ! isRunCentrally_ ) h2_DCotTracksVsEta_->Fill( mcEta_, aConv->pairCotThetaSeparation() );
              if ( ! isRunCentrally_ ) h2_DCotTracksVsR_->Fill( mcConvR_, aConv->pairCotThetaSeparation() );
              p_DCotTracksVsEta_->Fill( mcEta_, aConv->pairCotThetaSeparation() );
              p_DCotTracksVsR_->Fill( mcConvR_, aConv->pairCotThetaSeparation() );


              if ( phoIsInBarrel ) {
                h_invMass_[type][1] ->Fill(invM);
                if ( aConv->conversionVertex().isValid() ) {
                  h_convPtRes_[type][1]->Fill( refPt / (*mcPho).fourMomentum().et() );
                  h_EoverPTracks_[type][1] ->Fill( eoverp ) ;
                  if (  mcConvR_ < 15 )                 h_EoverPTracks_[0][0] ->Fill( eoverp ) ;
                  if (  mcConvR_ > 15 && mcConvR_< 58 ) h_EoverPTracks_[0][1] ->Fill( eoverp ) ;
                  if (  mcConvR_ > 58 )                 h_EoverPTracks_[0][2] ->Fill( eoverp ) ;
                  h_PoverETracks_[type][1] ->Fill( 1./eoverp ) ;
                  if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[1] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
                  if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[1] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e()  ) ;
                }
                h_DPhiTracksAtVtx_[type][1]->Fill( dPhiTracksAtVtx);
                h_DCotTracks_[type][1] ->Fill ( aConv->pairCotThetaSeparation() );


              }


              if ( phoIsInEndcap ) {
                h_invMass_[type][2] ->Fill(invM);
                if ( aConv->conversionVertex().isValid() ) {
                  h_convPtRes_[type][2]->Fill( refPt / (*mcPho).fourMomentum().et() );
                  h_EoverPTracks_[type][2] ->Fill( eoverp ) ;
                  h_PoverETracks_[type][2] ->Fill( 1./eoverp ) ;
                  if ( ! isRunCentrally_ ) h2_EoverEtrueVsEoverP_[2] ->Fill( eoverp,matchingPho.superCluster()->energy()/ (*mcPho).fourMomentum().e()  ) ;
                  if ( ! isRunCentrally_ ) h2_PoverPtrueVsEoverP_[2] ->Fill( eoverp, refP/ (*mcPho).fourMomentum().e()  ) ;
                }
                h_DPhiTracksAtVtx_[type][2]->Fill( dPhiTracksAtVtx);
                h_DCotTracks_[type][2] ->Fill ( aConv->pairCotThetaSeparation() );

              }


              if ( aConv->conversionVertex().isValid() ) {

                h_convVtxdX_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
                h_convVtxdY_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
                h_convVtxdZ_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
                h_convVtxdR_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);

                if ( fabs( mcConvEta_ ) <= 1.2 ) {
                  h_convVtxdX_barrel_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
                  h_convVtxdY_barrel_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
                  h_convVtxdZ_barrel_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
                  h_convVtxdR_barrel_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
                } else {
                  h_convVtxdX_endcap_ ->Fill ( aConv->conversionVertex().position().x() - mcConvX_);
                  h_convVtxdY_endcap_ ->Fill ( aConv->conversionVertex().position().y() - mcConvY_);
                  h_convVtxdZ_endcap_ ->Fill ( aConv->conversionVertex().position().z() - mcConvZ_);
                  h_convVtxdR_endcap_ ->Fill ( sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_);
                }


                h_convVtxdPhi_ ->Fill ( aConv->conversionVertex().position().phi() - mcConvPhi_);
                h_convVtxdEta_ ->Fill ( aConv->conversionVertex().position().eta() - mcConvEta_);
                if ( ! isRunCentrally_ ) h2_convVtxdRVsR_ ->Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
                if ( ! isRunCentrally_ ) h2_convVtxdRVsEta_ ->Fill (mcEta_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
                p_convVtxdRVsR_ ->Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
                p_convVtxdRVsEta_ ->Fill (mcEta_, sqrt(aConv->conversionVertex().position().perp2()) - mcConvR_ );
                float signX= aConv->refittedPairMomentum().x()/fabs(aConv->refittedPairMomentum().x());
                float signY= aConv->refittedPairMomentum().y()/fabs(aConv->refittedPairMomentum().y());
                float signZ= aConv->refittedPairMomentum().z()/fabs(aConv->refittedPairMomentum().z());
                p_convVtxdXVsX_ ->Fill (mcConvX_, (aConv->conversionVertex().position().x() - mcConvX_)*signX );
                p_convVtxdYVsY_ ->Fill (mcConvY_, (aConv->conversionVertex().position().y() - mcConvY_)*signY );
                p_convVtxdZVsZ_ ->Fill (mcConvZ_, (aConv->conversionVertex().position().z() - mcConvZ_)*signZ );


                if ( ! isRunCentrally_ ) h2_convVtxRrecVsTrue_ -> Fill (mcConvR_, sqrt(aConv->conversionVertex().position().perp2()) );



                //float zPV = aConv->zOfPrimaryVertexFromTracks();
                float thetaConv=aConv->refittedPairMomentum().Theta();
                float thetaSC=matchingPho.superCluster()->position().theta();
                float rSC=sqrt(matchingPho.superCluster()->position().x()*matchingPho.superCluster()->position().x() +
                               matchingPho.superCluster()->position().y()*matchingPho.superCluster()->position().y() );
                float zSC=matchingPho.superCluster()->position().z();
                float zPV = sqrt(rSC*rSC+zSC*zSC)*sin( thetaConv - thetaSC)/sin(thetaConv);

                h_zPVFromTracks_[0]->Fill (  zPV );
                h_dzPVFromTracks_[0]->Fill ( zPV- (*mcPho).primaryVertex().z() );


                if ( phoIsInBarrel ) {
                  h_zPVFromTracks_[1]->Fill ( zPV );
                  h_dzPVFromTracks_[1]->Fill ( zPV - (*mcPho).primaryVertex().z() );
                } else if ( phoIsInEndcap) {
                  h_zPVFromTracks_[2]->Fill ( zPV );
                  h_dzPVFromTracks_[2]->Fill ( zPV - (*mcPho).primaryVertex().z() );
                } else if ( phoIsInEndcapP) {
                  h_zPVFromTracks_[3]->Fill ( zPV );
                  h_dzPVFromTracks_[3]->Fill ( zPV - (*mcPho).primaryVertex().z() );
                }  else if ( phoIsInEndcapM) {
                  h_zPVFromTracks_[4]->Fill ( zPV );
                  h_dzPVFromTracks_[4]->Fill ( zPV - (*mcPho).primaryVertex().z() );
                }

                p_dzPVVsR_ ->Fill(mcConvR_, zPV - (*mcPho).primaryVertex().z() );
                p_dzPVVsEta_ ->Fill(mcConvEta_, zPV - (*mcPho).primaryVertex().z() );
                if ( ! isRunCentrally_ ) h2_dzPVVsR_ ->Fill(mcConvR_, zPV - (*mcPho).primaryVertex().z() );

              }

              float  dPhiTracksAtEcal=-99;
              float  dEtaTracksAtEcal=-99;
              if (aConv->bcMatchingWithTracks()[0].isNonnull() && aConv->bcMatchingWithTracks()[1].isNonnull() ) {
                nRecConvAssWithEcal_++;
                float recoPhi1 = aConv->ecalImpactPosition()[0].phi();
                float recoPhi2 = aConv->ecalImpactPosition()[1].phi();
                float recoEta1 = aConv->ecalImpactPosition()[0].eta();
                float recoEta2 = aConv->ecalImpactPosition()[1].eta();
                float bcPhi1 = aConv->bcMatchingWithTracks()[0]->phi();
                float bcPhi2 = aConv->bcMatchingWithTracks()[1]->phi();
                // unused       float bcEta1 = aConv->bcMatchingWithTracks()[0]->eta();
                // unused   float bcEta2 = aConv->bcMatchingWithTracks()[1]->eta();
                recoPhi1 = phiNormalization(recoPhi1);
                recoPhi2 = phiNormalization(recoPhi2);
                bcPhi1 = phiNormalization(bcPhi1);
                bcPhi2 = phiNormalization(bcPhi2);
                dPhiTracksAtEcal = recoPhi1 -recoPhi2;
                dPhiTracksAtEcal = phiNormalization( dPhiTracksAtEcal );
                dEtaTracksAtEcal = recoEta1 -recoEta2;


                h_DPhiTracksAtEcal_[type][0]->Fill( fabs(dPhiTracksAtEcal));
                if ( ! isRunCentrally_ ) h2_DPhiTracksAtEcalVsR_ ->Fill (mcConvR_, fabs(dPhiTracksAtEcal));
                if ( ! isRunCentrally_ ) h2_DPhiTracksAtEcalVsEta_ ->Fill (mcEta_, fabs(dPhiTracksAtEcal));
                p_DPhiTracksAtEcalVsR_ ->Fill (mcConvR_, fabs(dPhiTracksAtEcal));
                p_DPhiTracksAtEcalVsEta_ ->Fill (mcEta_, fabs(dPhiTracksAtEcal));

                h_DEtaTracksAtEcal_[type][0]->Fill( dEtaTracksAtEcal);

                if ( phoIsInBarrel ) {
                  h_DPhiTracksAtEcal_[type][1]->Fill( fabs(dPhiTracksAtEcal));
                  h_DEtaTracksAtEcal_[type][1]->Fill( dEtaTracksAtEcal);
                }
                if ( phoIsInEndcap ) {
                  h_DPhiTracksAtEcal_[type][2]->Fill( fabs(dPhiTracksAtEcal));
                  h_DEtaTracksAtEcal_[type][2]->Fill( dEtaTracksAtEcal);
                }

              }




              for (unsigned int i=0; i<tracks.size(); i++) {
                RefToBase<reco::Track> tfrb(tracks[i] );
                itAss= myAss.find( tfrb.get() );
                if ( itAss == myAss.end()  ) continue;

                float trkProvenance=3;
                if ( tracks[0]->algoName() == "outInEcalSeededConv"  &&  tracks[1]->algoName() == "outInEcalSeededConv" ) trkProvenance=0;
                if ( tracks[0]->algoName() == "inOutEcalSeededConv"  &&  tracks[1]->algoName() == "inOutEcalSeededConv" ) trkProvenance=1;
                if ( ( tracks[0]->algoName() == "outInEcalSeededConv"  &&  tracks[1]->algoName() == "inOutEcalSeededConv") ||
                     ( tracks[1]->algoName() == "outInEcalSeededConv"  &&  tracks[0]->algoName() == "inOutEcalSeededConv") ) trkProvenance=2;


                if ( ! isRunCentrally_ ) nHitsVsEta_[type] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits()) );
                 if ( ! isRunCentrally_ ) nHitsVsR_[type] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits()) );
                p_nHitsVsEta_[type] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits()) -0.0001);
                p_nHitsVsR_[type] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits()) -0.0001);
                h_tkChi2_[type] ->Fill (tracks[i]->normalizedChi2() );
                h_tkChi2Large_[type] ->Fill (tracks[i]->normalizedChi2() );
                if ( ! isRunCentrally_ ) h2_Chi2VsEta_[0] ->Fill(  mcEta_, tracks[i]->normalizedChi2() );
                 if ( ! isRunCentrally_ ) h2_Chi2VsR_[0] ->Fill(  mcConvR_, tracks[i]->normalizedChi2() );
                p_Chi2VsEta_[0] ->Fill(  mcEta_, tracks[i]->normalizedChi2() );
                p_Chi2VsR_[0] ->Fill(  mcConvR_, tracks[i]->normalizedChi2() );


                float simPt = sqrt( ((*itAss).second)->momentum().perp2() );
                //              float recPt =   sqrt( aConv->tracks()[i]->innerMomentum().Perp2() ) ;
                float refPt=-9999.;
                float px=0, py=0;

                if ( aConv->conversionVertex().isValid() ) {
                  reco::Track refTrack= aConv->conversionVertex().refittedTracks()[i];
                  px= refTrack.momentum().x() ;
                  py= refTrack.momentum().y() ;
                  refPt=sqrt (px*px + py*py );

                  float ptres= refPt - simPt ;
                  // float pterror = aConv->tracks()[i]->ptError();
                  float pterror =  aConv->conversionVertex().refittedTracks()[i].ptError();
                  if ( ! isRunCentrally_ ) {
                    h2_PtRecVsPtSim_[0]->Fill ( simPt, refPt);
                    if ( trkProvenance ==3 ) h2_PtRecVsPtSimMixProv_->Fill ( simPt, refPt);
                  }

                  h_TkPtPull_[0] ->Fill(ptres/pterror);
                   if ( ! isRunCentrally_ ) h2_TkPtPull_[0] ->Fill(mcEta_, ptres/pterror);

                  h_TkD0_[0]->Fill ( tracks[i]->d0()* tracks[i]->charge() );


                  if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[0]->Fill  ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2())  );

                  if ( phoIsInBarrel ) {
                    h_TkD0_[1]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
                    h_TkPtPull_[1] ->Fill(ptres/pterror);
                     if ( ! isRunCentrally_ ) h2_PtRecVsPtSim_[1]->Fill ( simPt, refPt);
                    if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[1]->Fill  ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2())  );

                  }
                  if ( phoIsInEndcap ) {
                    h_TkD0_[2]->Fill ( tracks[i]->d0()* tracks[i]->charge() );
                    h_TkPtPull_[2] ->Fill(ptres/pterror);
                     if ( ! isRunCentrally_ ) h2_PtRecVsPtSim_[2]->Fill ( simPt, refPt);
                    if ( aConv->bcMatchingWithTracks()[i].isNonnull() ) hBCEnergyOverTrackPout_[2]->Fill  ( aConv->bcMatchingWithTracks()[i]->energy()/sqrt(aConv->tracks()[i]->outerMomentum().Mag2())  );
                  }

                }

              } // end loop over track
            } // end analysis of two associated tracks
          } // end analysis of two  tracks

        } // loop over conversions
      }  // if !fastSim
    }  // End loop over generated particles
  } // End loop over simulated Photons



  if ( ! isRunCentrally_ ) {
    h_nSimPho_[0]->Fill(float(nSimPho_[0]));
    h_nSimPho_[1]->Fill(float(nSimPho_[1]));
    h_nSimConv_[0]->Fill(float(nSimConv_[0]));
    h_nSimConv_[1]->Fill(float(nSimConv_[1]));
  }

  if ( !fastSim_) {
    for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
      reco::Photon aPho = reco::Photon(*iPho);
      //    float et= aPho.superCluster()->energy()/cosh( aPho.superCluster()->eta()) ;
      reco::ConversionRefVector conversions = aPho.conversions();
      for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
        reco::ConversionRef aConv=conversions[iConv];
        double like = aConv->MVAout();
        if ( like < likelihoodCut_ ) continue;
        //std::vector<reco::TrackRef> tracks = aConv->tracks();
        const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
        if (tracks.size() < 2 ) continue;

        RefToBase<reco::Track> tk1 = aConv->tracks().front();
        RefToBase<reco::Track> tk2 = aConv->tracks().back();
        RefToBaseVector<reco::Track> tc1, tc2;
        tc1.push_back(tk1);
        tc2.push_back(tk2);

        bool  phoIsInBarrel=false;
        bool  phoIsInEndcap=false;
        if ( fabs(aConv->caloCluster()[0]->eta() ) < 1.479 ) {
          phoIsInBarrel=true;
        } else {
          phoIsInEndcap=true;
        }


        if ( dCotCutOn_ ) {
          if ( ( fabs(mcEta_) > 1.1 && fabs (mcEta_)  < 1.4  )  &&
               fabs( aConv->pairCotThetaSeparation() ) > dCotHardCutValue_ )  continue;
          if ( fabs( aConv->pairCotThetaSeparation() ) > dCotCutValue_ ) continue;
        }


        h_RecoConvTwoTracks_[0]->Fill( aPho.eta() ) ;
        h_RecoConvTwoTracks_[1]->Fill( aPho.phi() );
        if (  aConv->conversionVertex().isValid() ) h_RecoConvTwoTracks_[2]->Fill(  aConv->conversionVertex().position().perp2() );
        h_RecoConvTwoTracks_[3]->Fill( aConv->conversionVertex().position().z() );
        h_RecoConvTwoTracks_[4]->Fill( aPho.et() ) ;



        int  nAssT2=0;
        for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
          // mcConvPt_= (*mcPho).fourMomentum().et();
          float mcPhi= (*mcPho).fourMomentum().phi();
          //simPV_Z = (*mcPho).primaryVertex().z();
          mcPhi_= phiNormalization(mcPhi);
          mcEta_= (*mcPho).fourMomentum().pseudoRapidity();
          mcEta_ = etaTransformation(mcEta_, (*mcPho).primaryVertex().z() );
          //mcConvR_= (*mcPho).vertex().perp();
          //mcConvX_= (*mcPho).vertex().x();
          //mcConvY_= (*mcPho).vertex().y();
          //mcConvZ_= (*mcPho).vertex().z();
          //mcConvEta_= (*mcPho).vertex().eta();
          //mcConvPhi_= (*mcPho).vertex().phi();
          if ( fabs(mcEta_) > END_HI ) continue;
          //        if (mcConvPt_<minPhoPtForPurity) continue;
          //if (fabs(mcEta_)>maxPhoEtaForPurity) continue;
          //if (fabs(mcConvZ_)>maxPhoZForPurity) continue;
          //if (mcConvR_>maxPhoRForEffic) continue;

          if (  (*mcPho).isAConversion() != 1 ) continue;
          if (!( ( fabs(mcEta_) <= BARL && mcConvR_ <85 )  ||
                 ( fabs(mcEta_) > BARL && fabs(mcEta_) <=END_HI && fabs( (*mcPho).vertex().z() ) < 210 )  ) )
            continue;


          theConvTP_.clear();
          for(size_t i = 0; i <  trackingParticles.size(); ++i){
            TrackingParticleRef tp (ElectronTPHandle,i);
            if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.0001   &&
                 fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.0001   &&
                 fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.0001) {
              theConvTP_.push_back( tp );
            }
          }

          //std::cout << " ciao 5.3 " << std::endl;
          if ( theConvTP_.size() < 2 )   continue;

          reco::RecoToSimCollection p1 =  theTrackAssociator_->associateRecoToSim(tc1,theConvTP_,&e);
          reco::RecoToSimCollection p2 =  theTrackAssociator_->associateRecoToSim(tc2,theConvTP_,&e);
          std::vector<std::pair<RefToBase<reco::Track>, double> > trackV1, trackV2;
          try {
          std::vector<std::pair<TrackingParticleRef, double> > tp1 = p1[tk1];
          std::vector<std::pair<TrackingParticleRef, double> > tp2 = p2[tk2];

          if (tp1.size()&&tp2.size()) {
            TrackingParticleRef tpr1 = tp1.front().first;
            TrackingParticleRef tpr2 = tp2.front().first;

            if (abs(tpr1->pdgId())==11&&abs(tpr2->pdgId())==11) {
              if ( (tpr1->parentVertex()->sourceTracks_end()-tpr1->parentVertex()->sourceTracks_begin()==1) &&
                   (tpr2->parentVertex()->sourceTracks_end()-tpr2->parentVertex()->sourceTracks_begin()==1)) {
                if (tpr1->parentVertex().key()==tpr2->parentVertex().key() && ((*tpr1->parentVertex()->sourceTracks_begin())->pdgId()==22)) {
                  //              std::cout << " ciao 5.6 " << std::endl;
                  //            mcConvR_ = sqrt(tpr1->parentVertex()->position().Perp2());
                  //mcConvZ_ = tpr1->parentVertex()->position().z();
                  //mcConvX_ = tpr1->parentVertex()->position().x();
                  //mcConvY_ = tpr1->parentVertex()->position().y();
                  //mcConvEta_ = tpr1->parentVertex()->position().eta();
                  //mcConvPhi_ = tpr1->parentVertex()->position().phi();
                  //mcConvPt_ = sqrt((*tpr1->parentVertex()->sourceTracks_begin())->momentum().Perp2());
                  //std::cout << " Reco to Sim mcconvpt " << mcConvPt_ << std::endl;
                  //cout << "associated track1 to " << tpr1->pdgId() << " with p=" << tpr1->p4() << " with pT=" << tpr1->pt() << endl;
                  //cout << "associated track2 to " << tpr2->pdgId() << " with p=" << tpr2->p4() << " with pT=" << tpr2->pt() << endl;
                  nAssT2 = 2;
                  break;
                }
              }
            }
          }

          } catch (Exception event) {
            //cout << "do not continue: " << event.what()  << endl;
            //continue;
          }

        } // end loop over simulated photons



          /*
          TrackingParticleRef myTP;
          for (size_t j = 0; j < RtoSCollPtrs.size(); j++) {
            reco::RecoToSimCollection q = *(RtoSCollPtrs[j]);

            RefToBase<reco::Track> myTk( track );

            if( q.find(myTk ) != q.end() ) {
              std::vector<std::pair<TrackingParticleRef, double> > tp = q[myTk];
              for (unsigned int itp=0; itp<tp.size(); itp++) {
                myTP=tp[itp].first;
                //            std::cout << " associated with TP " << myTP->pdgId() << " pt " << sqrt(myTP->momentum().perp2()) << std::endl;
                myAss.insert( std::make_pair ( track  , myTP) );
                nAssT2++;
              }
            }
          }
          */

          if ( nAssT2 == 2) {


            h_RecoConvTwoMTracks_[0]->Fill( aPho.eta() ) ;
            h_RecoConvTwoMTracks_[1]->Fill( aPho.phi() );
            if (  aConv->conversionVertex().isValid() ) h_RecoConvTwoMTracks_[2]->Fill(  aConv->conversionVertex().position().perp2() );
            h_RecoConvTwoMTracks_[3]->Fill( aConv->conversionVertex().position().z() );
            h_RecoConvTwoMTracks_[4]->Fill( aPho.et() ) ;

          }


        if ( aConv->conversionVertex().isValid() ) {
          float chi2Prob = ChiSquaredProbability( aConv->conversionVertex().chi2(),  aConv->conversionVertex().ndof() );

          double convR= sqrt(aConv->conversionVertex().position().perp2());
          double scalar = aConv->conversionVertex().position().x()*aConv->pairMomentum().x() +
            aConv->conversionVertex().position().y()*aConv->pairMomentum().y();
          if ( scalar < 0 ) convR= -sqrt(aConv->conversionVertex().position().perp2());

          if ( ! isRunCentrally_ ) h2_etaVsRreco_[0]->Fill (aConv->caloCluster()[0]->eta(),sqrt(aConv->conversionVertex().position().perp2()) );
          h_convVtxRvsZ_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  sqrt(aConv->conversionVertex().position().perp2())  ) ;
          if ( fabs(aConv->caloCluster()[0]->eta() ) <= 1.) {

            h_convVtxYvsX_ ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x()  ) ;
            h_convVtxRvsZ_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR  ) ;

            if ( ! isRunCentrally_ ) {
              h_convVtxYvsX_zoom_[0] ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x()  ) ;
              h_convVtxYvsX_zoom_[1] ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x()  ) ;
              h_convVtxRvsZ_zoom_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR  ) ;
              h_convVtxRvsZ_zoom_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR ) ;
            }

          }
          if ( fabs(aConv->caloCluster()[0]->eta() ) > 1.)      h_convVtxRvsZ_[2] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR  ) ;




          h_vtxChi2Prob_[0]->Fill( chi2Prob );
          h_vtxChi2_[0]->Fill(  aConv->conversionVertex().normalizedChi2() );
          if ( phoIsInBarrel ) {
            h_vtxChi2Prob_[1]->Fill( chi2Prob );
            h_vtxChi2_[1]->Fill( aConv->conversionVertex().normalizedChi2() );
          }
          if ( phoIsInEndcap ) {
            h_vtxChi2Prob_[2]->Fill(  chi2Prob );
            h_vtxChi2_[2]->Fill( aConv->conversionVertex().normalizedChi2() );
          }

        } // end conversion vertex valid
      } // end loop over reco conversions
    } // end loop on all reco photons
  } // if !fastSim



  float nPho=0;
  for (reco::GenJetCollection::const_iterator genJetIter = genJetCollection.begin();
       genJetIter != genJetCollection.end();     ++genJetIter) {

    if ( genJetIter->pt() < minPhoEtCut_ ) continue;
    if ( fabs(genJetIter->eta())  > 2.5 ) continue;

    float mcJetPhi= genJetIter->phi();
    mcJetPhi_= phiNormalization(mcJetPhi);
    mcJetEta_= genJetIter->eta();
    float mcJetPt = genJetIter->pt() ;

    h_SimJet_[0]->Fill ( mcJetEta_);
    h_SimJet_[1]->Fill ( mcJetPhi_);
    h_SimJet_[2]->Fill ( mcJetPt );

    std::vector<reco::Photon> thePhotons;
    bool matched=false;

    reco::Photon matchingPho;
    for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
      reco::Photon aPho = reco::Photon(*iPho);
      float phiPho=aPho.phi();
      float etaPho=aPho.eta();
      float deltaPhi = phiPho-mcJetPhi_;
      float deltaEta = etaPho-mcJetEta_;
      if ( deltaPhi > pi )  deltaPhi -= twopi;
      if ( deltaPhi < -pi) deltaPhi += twopi;
      deltaPhi=pow(deltaPhi,2);
      deltaEta=pow(deltaEta,2);
      float delta = sqrt( deltaPhi+deltaEta);
      if ( delta<0.3 ) {
        matchingPho = * iPho;
        matched = true;
      }
    }  // end loop over reco photons

    if (!  matched ) continue;
    nPho++;

    h_MatchedSimJet_[0]->Fill( mcJetEta_ ) ;
    h_MatchedSimJet_[1]->Fill( mcJetPhi_ );
    h_MatchedSimJet_[2]->Fill( mcJetPt );


    bool  phoIsInBarrel=false;
    bool  phoIsInEndcap=false;
    if ( fabs(matchingPho.superCluster()->position().eta() ) < 1.479 ) {
      phoIsInBarrel=true;
    } else {
      phoIsInEndcap=true;
    }
    edm::Handle<EcalRecHitCollection>   ecalRecHitHandle;
    if ( phoIsInBarrel ) {
      // Get handle to rec hits ecal barrel
      e.getByLabel(barrelEcalHits_, ecalRecHitHandle);
      if (!ecalRecHitHandle.isValid()) {
        edm::LogError("PhotonProducer") << "Error! Can't get the product "<<barrelEcalHits_.label();
        return;
      }

    } else if ( phoIsInEndcap ) {

      // Get handle to rec hits ecal encap
      e.getByLabel(endcapEcalHits_, ecalRecHitHandle);
      if (!ecalRecHitHandle.isValid()) {
        edm::LogError("PhotonProducer") << "Error! Can't get the product "<<endcapEcalHits_.label();
        return;
      }

    }



    const EcalRecHitCollection ecalRecHitCollection = *(ecalRecHitHandle.product());
    float photonE = matchingPho.energy();
    float photonEt= matchingPho.et();
    float r9 = matchingPho.r9();
    float r1 = matchingPho.r1x5();
    float r2 = matchingPho.r2x5();
    float sigmaIetaIeta =  matchingPho.sigmaIetaIeta();
    float hOverE = matchingPho.hadronicOverEm();
    float ecalIso = matchingPho.ecalRecHitSumEtConeDR04();
    float hcalIso = matchingPho.hcalTowerSumEtConeDR04();
    float trkIso =  matchingPho.trkSumPtSolidConeDR04();
    float nIsoTrk   =  matchingPho.nTrkSolidConeDR04();
    std::vector< std::pair<DetId, float> >::const_iterator rhIt;

    bool atLeastOneDeadChannel=false;
      for(reco::CaloCluster_iterator bcIt = matchingPho.superCluster()->clustersBegin();bcIt != matchingPho.superCluster()->clustersEnd(); ++bcIt) {
        for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {

          for(EcalRecHitCollection::const_iterator it =  ecalRecHitCollection.begin(); it !=  ecalRecHitCollection.end(); ++it) {
            if  (rhIt->first ==  (*it).id() ) {
              if (  (*it).recoFlag() == 9 ) {
                atLeastOneDeadChannel=true;
                break;
              }
            }
          }
        }
      }

      if (   atLeastOneDeadChannel ) {
        h_MatchedSimJetBadCh_[0]->Fill( mcJetEta_ ) ;
        h_MatchedSimJetBadCh_[1]->Fill( mcJetPhi_ );
        h_MatchedSimJetBadCh_[2]->Fill( mcJetPt );

      }

      h_scBkgEta_->Fill( matchingPho.superCluster()->eta() );
      h_scBkgPhi_->Fill( matchingPho.superCluster()->phi() );
      h_scBkgE_[0]->Fill( matchingPho.superCluster()->energy() );
      h_scBkgEt_[0]->Fill( matchingPho.superCluster()->energy()/cosh( matchingPho.superCluster()->eta()) );
      //
      h_phoBkgEta_->Fill( matchingPho.eta() );
      h_phoBkgPhi_->Fill( matchingPho.phi() );
      h_phoBkgE_[0]->Fill( photonE );
      h_phoBkgEt_[0]->Fill( photonEt);
      h_phoBkgDEta_->Fill (  matchingPho.eta() - mcJetEta_ );
      h_phoBkgDPhi_->Fill (  matchingPho.phi() - mcJetPhi_ );


      h_r9Bkg_[0]->Fill( r9 );
      h_r1Bkg_[0]->Fill( r1 );
      h_r2Bkg_[0]->Fill( r2 );
      h_sigmaIetaIetaBkg_[0]->Fill( sigmaIetaIeta );
      h_hOverEBkg_[0]->Fill( hOverE );
      h_ecalRecHitSumEtConeDR04Bkg_[0]->Fill( ecalIso );
      h_hcalTowerSumEtConeDR04Bkg_[0]->Fill( hcalIso );
      h_isoTrkSolidConeDR04Bkg_[0]->Fill( trkIso );
      h_nTrkSolidConeDR04Bkg_[0]->Fill( nIsoTrk );


      h2_r9VsEtaBkg_ -> Fill (mcJetEta_, r9);
      h2_r9VsEtBkg_ -> Fill (mcJetPt, r9);

      h2_r1VsEtaBkg_ -> Fill (mcJetEta_, r1);
      h2_r1VsEtBkg_ -> Fill (mcJetPt, r1);
      p_r1VsEtaBkg_ -> Fill (mcJetEta_, r1);
      p_r1VsEtBkg_ -> Fill (mcJetPt, r1);

      h2_r2VsEtaBkg_ -> Fill (mcJetEta_, r2);
      h2_r2VsEtBkg_ -> Fill (mcJetPt, r2);
      p_r2VsEtaBkg_ -> Fill (mcJetEta_, r2);
      p_r2VsEtBkg_ -> Fill (mcJetPt, r2);


      h2_sigmaIetaIetaVsEtaBkg_ -> Fill (mcJetEta_, sigmaIetaIeta );
      p_sigmaIetaIetaVsEtaBkg_ -> Fill (mcJetEta_, sigmaIetaIeta );
      h2_sigmaIetaIetaVsEtBkg_[0] -> Fill (mcJetPt, sigmaIetaIeta);
      p_sigmaIetaIetaVsEtBkg_[0] -> Fill (mcJetPt, sigmaIetaIeta);

      if ( ! isRunCentrally_ ) { 
        h2_hOverEVsEtaBkg_ -> Fill (mcJetEta_, hOverE );
        h2_hOverEVsEtBkg_ -> Fill (mcJetPt, hOverE);
      }
      p_hOverEVsEtaBkg_ -> Fill (mcJetEta_, hOverE );
      p_hOverEVsEtBkg_ -> Fill (mcJetPt, hOverE);


      if ( ! isRunCentrally_ ) {
        h2_ecalRecHitSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, ecalIso );
        h2_ecalRecHitSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, ecalIso);
        h2_hcalTowerSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, hcalIso );
        h2_hcalTowerSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, hcalIso);
      }

      p_ecalRecHitSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, ecalIso );
      p_ecalRecHitSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, ecalIso);



      p_hcalTowerSumEtConeDR04VsEtaBkg_ -> Fill (mcJetEta_, hcalIso );

      p_hcalTowerSumEtConeDR04VsEtBkg_[0] -> Fill ( mcJetPt, hcalIso);

      h2_isoTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, trkIso );
      p_isoTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, trkIso );
      h2_isoTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, trkIso);
      p_isoTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, trkIso);


      h2_nTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, nIsoTrk );
      p_nTrkSolidConeDR04VsEtaBkg_ -> Fill (mcJetEta_, nIsoTrk );
      h2_nTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, nIsoTrk);
      p_nTrkSolidConeDR04VsEtBkg_[0] -> Fill (mcJetPt, nIsoTrk);




      if ( phoIsInBarrel ) {

        h_r9Bkg_[1]->Fill( r9 );
        h_r1Bkg_[1]->Fill( r1 );
        h_r2Bkg_[1]->Fill( r2 );


        h_sigmaIetaIetaBkg_[1]->Fill( sigmaIetaIeta );
        h_hOverEBkg_[1]->Fill( hOverE );
        h_ecalRecHitSumEtConeDR04Bkg_[1]->Fill( ecalIso );
        h_hcalTowerSumEtConeDR04Bkg_[1]->Fill( hcalIso );
        h_isoTrkSolidConeDR04Bkg_[1]->Fill( trkIso );
        h_nTrkSolidConeDR04Bkg_[1]->Fill( nIsoTrk );

        h2_sigmaIetaIetaVsEtBkg_[1] -> Fill (mcJetPt, sigmaIetaIeta);
        p_sigmaIetaIetaVsEtBkg_[1] -> Fill (mcJetPt, sigmaIetaIeta);
        p_ecalRecHitSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, ecalIso);
        p_hcalTowerSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, hcalIso);

        h2_isoTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, trkIso);
        p_isoTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, trkIso);

        h2_nTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, nIsoTrk);
        p_nTrkSolidConeDR04VsEtBkg_[1] -> Fill (mcJetPt, nIsoTrk);
        if ( ! isRunCentrally_ ) {
          h2_ecalRecHitSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, ecalIso);
          h2_hcalTowerSumEtConeDR04VsEtBkg_[1] -> Fill ( mcJetPt, hcalIso);
        }

      } else if ( phoIsInEndcap )  {

        h_r9Bkg_[2]->Fill( r9 );
        h_r1Bkg_[2]->Fill( r1 );
        h_r2Bkg_[2]->Fill( r2 );

        h_sigmaIetaIetaBkg_[2]->Fill( sigmaIetaIeta );
        h_hOverEBkg_[2]->Fill( hOverE );
        h_ecalRecHitSumEtConeDR04Bkg_[2]->Fill( ecalIso );
        h_hcalTowerSumEtConeDR04Bkg_[2]->Fill( hcalIso );
        h_isoTrkSolidConeDR04Bkg_[2]->Fill( trkIso );
        h_nTrkSolidConeDR04Bkg_[2]->Fill( nIsoTrk );

        h2_sigmaIetaIetaVsEtBkg_[2] -> Fill (mcJetPt, sigmaIetaIeta);
        p_sigmaIetaIetaVsEtBkg_[2] -> Fill (mcJetPt, sigmaIetaIeta);
        p_ecalRecHitSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, ecalIso);
        p_hcalTowerSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, hcalIso);

        h2_isoTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, trkIso);
        p_isoTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, trkIso);

        h2_nTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, nIsoTrk);
        p_nTrkSolidConeDR04VsEtBkg_[2] -> Fill (mcJetPt, nIsoTrk);
        if ( ! isRunCentrally_ ) {
          h2_ecalRecHitSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, ecalIso);
          h2_hcalTowerSumEtConeDR04VsEtBkg_[2] -> Fill ( mcJetPt, hcalIso);
        }

      }

      if ( !fastSim_) {
        reco::ConversionRefVector conversions = matchingPho.conversions();
        for (unsigned int iConv=0; iConv<conversions.size(); iConv++) {
          reco::ConversionRef aConv=conversions[iConv];
          //std::vector<reco::TrackRef> tracks = aConv->tracks();
          const std::vector<edm::RefToBase<reco::Track> > tracks = aConv->tracks();
          double like = aConv->MVAout();
          if ( like < likelihoodCut_ ) continue;
          if ( tracks.size() < 2 ) continue;
          h_convEtaBkg_->Fill( aConv->caloCluster()[0]->eta() );
          h_convPhiBkg_->Fill( aConv->caloCluster()[0]->phi() );
          h_mvaOutBkg_[0]-> Fill(like);
          float eoverp= aConv->EoverP();
          h_EoverPTracksBkg_[0] ->Fill( eoverp ) ;
          h_PoverETracksBkg_[0] ->Fill( 1./eoverp ) ;
          h_DCotTracksBkg_[0] ->Fill ( aConv->pairCotThetaSeparation() );
          float  dPhiTracksAtVtx =  aConv->dPhiTracksAtVtx();
          h_DPhiTracksAtVtxBkg_[0]->Fill( dPhiTracksAtVtx);

          if ( phoIsInBarrel ) {
            h_mvaOutBkg_[1]-> Fill(like);
            h_EoverPTracksBkg_[1] ->Fill( eoverp ) ;
            h_PoverETracksBkg_[1] ->Fill( 1./eoverp ) ;
            h_DCotTracksBkg_[1] ->Fill ( aConv->pairCotThetaSeparation() );
            h_DPhiTracksAtVtxBkg_[1]->Fill( dPhiTracksAtVtx);
          }     else if ( phoIsInEndcap )  {
            h_mvaOutBkg_[2]-> Fill(like);
            h_EoverPTracksBkg_[2] ->Fill( eoverp ) ;
            h_PoverETracksBkg_[2] ->Fill( 1./eoverp ) ;
            h_DCotTracksBkg_[2] ->Fill ( aConv->pairCotThetaSeparation() );
            h_DPhiTracksAtVtxBkg_[2]->Fill( dPhiTracksAtVtx);
          }

          if ( aConv->conversionVertex().isValid() ) {

            double convR= sqrt(aConv->conversionVertex().position().perp2());
            double scalar = aConv->conversionVertex().position().x()*aConv->pairMomentum().x() +
              aConv->conversionVertex().position().y()*aConv->pairMomentum().y();
            if ( scalar < 0 ) convR= -sqrt(aConv->conversionVertex().position().perp2());

            if ( ! isRunCentrally_ ) {
              h_convVtxRvsZBkg_[0] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  sqrt(aConv->conversionVertex().position().perp2())  ) ;
              if ( fabs(aConv->caloCluster()[0]->eta() ) <= 1.) {
                h_convVtxYvsXBkg_ ->Fill ( aConv->conversionVertex().position().y() , aConv->conversionVertex().position().x()  ) ;
                h_convVtxRvsZBkg_[1] ->Fill ( fabs (aConv->conversionVertex().position().z() ),  convR  ) ;
              }
            }


          } // end vertex valid


        } // end loop over conversions
      } // if !fastSim
  } // end loop over sim jets

  h_nPho_->Fill(float(nPho));

}
void PhotonValidator::beginJob ( void  ) [virtual]

Histograms for efficiencies

Denominators

Numerators

zooms

test track provenance

Reimplemented from edm::EDAnalyzer.

Definition at line 148 of file PhotonValidator.cc.

References DQMStore::book1D(), DQMStore::book2D(), DQMStore::bookProfile(), dbe_, jptDQMConfig_cff::eMax, jptDQMConfig_cff::etaMax, jptDQMConfig_cff::etaMin, jptDQMConfig_cff::etMax, reco::tau::qcuts::etMin(), cmsCodeRules::cppFunctionSkipper::operator, jptDQMConfig_cff::phiMax, jptDQMConfig_cff::phiMin, and DQMStore::setCurrentFolder().

                                {

  nEvt_=0;
  nEntry_=0;
  nRecConv_=0;
  nRecConvAss_=0;
  nRecConvAssWithEcal_=0;

  nInvalidPCA_=0;

  dbe_ = 0;
  dbe_ = edm::Service<DQMStore>().operator->();




  double resMin = parameters_.getParameter<double>("resMin");
  double resMax = parameters_.getParameter<double>("resMax");
  int resBin = parameters_.getParameter<int>("resBin");

  double eMin = parameters_.getParameter<double>("eMin");
  double eMax = parameters_.getParameter<double>("eMax");
  int eBin = parameters_.getParameter<int>("eBin");

  double etMin = parameters_.getParameter<double>("etMin");
  double etMax = parameters_.getParameter<double>("etMax");
  int etBin = parameters_.getParameter<int>("etBin");

  double etScale = parameters_.getParameter<double>("etScale");

  double etaMin = parameters_.getParameter<double>("etaMin");
  double etaMax = parameters_.getParameter<double>("etaMax");
  int etaBin = parameters_.getParameter<int>("etaBin");
  int etaBin2 = parameters_.getParameter<int>("etaBin2");

  double dEtaMin = parameters_.getParameter<double>("dEtaMin");
  double dEtaMax = parameters_.getParameter<double>("dEtaMax");
  int dEtaBin = parameters_.getParameter<int>("dEtaBin");

  double phiMin = parameters_.getParameter<double>("phiMin");
  double phiMax = parameters_.getParameter<double>("phiMax");
  int    phiBin = parameters_.getParameter<int>("phiBin");

  double dPhiMin = parameters_.getParameter<double>("dPhiMin");
  double dPhiMax = parameters_.getParameter<double>("dPhiMax");
  int    dPhiBin = parameters_.getParameter<int>("dPhiBin");

  double rMin = parameters_.getParameter<double>("rMin");
  double rMax = parameters_.getParameter<double>("rMax");
  int    rBin = parameters_.getParameter<int>("rBin");

  double zMin = parameters_.getParameter<double>("zMin");
  double zMax = parameters_.getParameter<double>("zMax");
  int    zBin = parameters_.getParameter<int>("zBin");



  double r9Min = parameters_.getParameter<double>("r9Min");
  double r9Max = parameters_.getParameter<double>("r9Max");
  int r9Bin = parameters_.getParameter<int>("r9Bin");

  double dPhiTracksMin = parameters_.getParameter<double>("dPhiTracksMin");
  double dPhiTracksMax = parameters_.getParameter<double>("dPhiTracksMax");
  int dPhiTracksBin = parameters_.getParameter<int>("dPhiTracksBin");

  double dEtaTracksMin = parameters_.getParameter<double>("dEtaTracksMin");
  double dEtaTracksMax = parameters_.getParameter<double>("dEtaTracksMax");
  int    dEtaTracksBin = parameters_.getParameter<int>("dEtaTracksBin");

  double dCotTracksMin = parameters_.getParameter<double>("dCotTracksMin");
  double dCotTracksMax = parameters_.getParameter<double>("dCotTracksMax");
  int    dCotTracksBin = parameters_.getParameter<int>("dCotTracksBin");


  double povereMin = parameters_.getParameter<double>("povereMin");
  double povereMax = parameters_.getParameter<double>("povereMax");
  int povereBin = parameters_.getParameter<int>("povereBin");

  double eoverpMin = parameters_.getParameter<double>("eoverpMin");
  double eoverpMax = parameters_.getParameter<double>("eoverpMax");
  int    eoverpBin = parameters_.getParameter<int>("eoverpBin");

  double chi2Min = parameters_.getParameter<double>("chi2Min");
  double chi2Max = parameters_.getParameter<double>("chi2Max");

  int    ggMassBin = parameters_.getParameter<int>("ggMassBin");
  double ggMassMin = parameters_.getParameter<double>("ggMassMin");
  double ggMassMax = parameters_.getParameter<double>("ggMassMax");


  double rMinForXray = parameters_.getParameter<double>("rMinForXray");
  double rMaxForXray = parameters_.getParameter<double>("rMaxForXray");
  int    rBinForXray = parameters_.getParameter<int>("rBinForXray");
  double zMinForXray = parameters_.getParameter<double>("zMinForXray");
  double zMaxForXray = parameters_.getParameter<double>("zMaxForXray");
  int    zBinForXray = parameters_.getParameter<int>("zBinForXray");
  int    zBin2ForXray = parameters_.getParameter<int>("zBin2ForXray");



  if (dbe_) {
    // SC from reco photons


    dbe_->setCurrentFolder("EgammaV/PhotonValidator/SimulationInfo");
    //
    // simulation information about all MC photons found
    std::string histname = "nOfSimPhotons";
    if ( ! isRunCentrally_ ) {
      h_nSimPho_[0] = dbe_->book1D(histname,"# of Sim photons per event ",20,-0.5,19.5);
      histname = "SimPhoMotherEt";
      h_SimPhoMotherEt_[0] = dbe_->book1D(histname,"Sim photon Mother tranverse energy spectrum",etBin,etMin,etMax);
      h_SimPhoMotherEta_[0] = dbe_->book1D("SimPhoMotherEta"," Sim Photon Mother Eta ",etaBin,etaMin, etaMax) ;
      histname = "SimPhoMotherEtMatched";
      h_SimPhoMotherEt_[1] = dbe_->book1D(histname,"Sim photon  matched by a reco Photon: Mother tranverse energy spectrum",etBin,etMin,etMax);
      h_SimPhoMotherEta_[1] = dbe_->book1D("SimPhoMotherEtaMatched"," Sim Photon matched by a reco Photon:  Mother Eta ",etaBin,etaMin, etaMax) ;
    }

    histname = "h_SimPhoEta";
    h_SimPho_[0] =  dbe_->book1D(histname," All photons simulated #eta",etaBin,etaMin, etaMax);
    histname = "h_SimPhoPhi";
    h_SimPho_[1] =  dbe_->book1D(histname," All photons simulated #phi",phiBin,phiMin, phiMax);
    histname = "h_SimPhoEt";
    h_SimPho_[2] =  dbe_->book1D(histname," All photons simulated Et",etBin,etMin, etMax);
    // Numerators
    histname = "nOfSimPhotonsMatched";
    h_nSimPho_[1] = dbe_->book1D(histname,"# of Sim photons matched by a reco Photon per event ",20,-0.5,19.5);
    histname = "h_MatchedSimPhoEta";
    h_MatchedSimPho_[0] =  dbe_->book1D(histname," Matching photons simulated #eta",etaBin,etaMin, etaMax);
    histname = "h_MatchedSimPhoPhi";
    h_MatchedSimPho_[1] =  dbe_->book1D(histname," Matching photons simulated #phi",phiBin,phiMin, phiMax);
    histname = "h_MatchedSimPhoEt";
    h_MatchedSimPho_[2] =  dbe_->book1D(histname," Matching photons simulated Et",etBin,etMin, etMax);
    //
    histname = "h_MatchedSimPhoBadChEta";
    h_MatchedSimPhoBadCh_[0] =  dbe_->book1D(histname," Matching photons simulated #eta",etaBin,etaMin, etaMax);
    histname = "h_MatchedSimPhoBadChPhi";
    h_MatchedSimPhoBadCh_[1] =  dbe_->book1D(histname," Matching photons simulated #phi",phiBin,phiMin, phiMax);
    histname = "h_MatchedSimPhoBadChEt";
    h_MatchedSimPhoBadCh_[2] =  dbe_->book1D(histname," Matching photons simulated Et",etBin,etMin, etMax);


    histname = "nOfSimConversions";
    if ( ! isRunCentrally_ ) {
      h_nSimConv_[0] = dbe_->book1D(histname,"# of Sim conversions per event ",20,-0.5,19.5);
      histname = "nOfVisSimConversions";
      h_nSimConv_[1] = dbe_->book1D(histname,"# of Sim conversions per event ",20,-0.5,19.5);
    }
    histname = "h_AllSimConvEta";
    h_AllSimConv_[0] =  dbe_->book1D(histname," All conversions: simulated #eta",etaBin2,etaMin,etaMax);
    histname = "h_AllSimConvPhi";
    h_AllSimConv_[1] =  dbe_->book1D(histname," All conversions: simulated #phi",phiBin,phiMin,phiMax);
    histname = "h_AllSimConvR";
    h_AllSimConv_[2] =  dbe_->book1D(histname," All conversions: simulated R",rBin,rMin,rMax);
    histname = "h_AllSimConvZ";
    h_AllSimConv_[3] =  dbe_->book1D(histname," All conversions: simulated Z",zBin,zMin,zMax);
    histname = "h_AllSimConvEt";
    h_AllSimConv_[4] =  dbe_->book1D(histname," All conversions: simulated Et",etBin,etMin,etMax);
    //
    histname = "h_VisSimConvEta";
    h_VisSimConv_[0] =  dbe_->book1D(histname," All vis conversions: simulated #eta",etaBin2,etaMin, etaMax);
    histname = "h_VisSimConvPhi";
    h_VisSimConv_[1] =  dbe_->book1D(histname," All vis conversions: simulated #phi",phiBin,phiMin, phiMax);
    histname = "h_VisSimConvR";
    h_VisSimConv_[2] =  dbe_->book1D(histname," All vis conversions: simulated R",rBin,rMin,rMax);
    histname = "h_VisSimConvZ";
    h_VisSimConv_[3] =  dbe_->book1D(histname," All vis conversions: simulated Z",zBin,zMin, zMax);
    histname = "h_VisSimConvEt";
    h_VisSimConv_[4] =  dbe_->book1D(histname," All vis conversions: simulated Et",etBin,etMin, etMax);
    histname = "h_SimConvOneTracksEta";
    h_SimConvOneTracks_[0] =  dbe_->book1D(histname," All vis conversions with 1 reco  tracks: simulated #eta",etaBin2,etaMin, etaMax);
    histname = "h_SimConvOneTracksPhi";
    h_SimConvOneTracks_[1] =  dbe_->book1D(histname," All vis conversions with 1 reco  tracks: simulated #phi",phiBin,phiMin, phiMax);
    histname = "h_SimConvOneTracksR";
    h_SimConvOneTracks_[2] =  dbe_->book1D(histname," All vis conversions with 1 reco  tracks: simulated R",rBin,rMin, rMax);
    histname = "h_SimConvOneTracksZ";
    h_SimConvOneTracks_[3] =  dbe_->book1D(histname," All vis conversions with 1 reco  tracks: simulated Z",zBin,zMin, zMax);
    histname = "h_SimConvOneTracksEt";
    h_SimConvOneTracks_[4] =  dbe_->book1D(histname," All vis conversions with 1 reco  tracks: simulated Et",etBin,etMin, etMax);
    //
    histname = "h_SimConvTwoMTracksEta";
    h_SimConvTwoMTracks_[0] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated #eta",etaBin2,etaMin, etaMax);
    histname = "h_SimConvTwoMTracksPhi";
    h_SimConvTwoMTracks_[1] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated #phi",phiBin,phiMin, phiMax);
    histname = "h_SimConvTwoMTracksR";
    h_SimConvTwoMTracks_[2] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated R",rBin,rMin, rMax);
    histname = "h_SimConvTwoMTracksZ";
    h_SimConvTwoMTracks_[3] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated Z",zBin,zMin, zMax);
    histname = "h_SimConvTwoMTracksEt";
    h_SimConvTwoMTracks_[4] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated Et",etBin,etMin, etMax);
    //
    histname = "h_SimConvTwoTracksEta";
    h_SimConvTwoTracks_[0] =  dbe_->book1D(histname," All vis conversions with 2 reco  tracks: simulated #eta",etaBin2,etaMin, etaMax);
    histname = "h_SimConvTwoTracksPhi";
    h_SimConvTwoTracks_[1] =  dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated #phi",phiBin,phiMin, phiMax);
    histname = "h_SimConvTwoTracksR";
    h_SimConvTwoTracks_[2] =  dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated R",rBin,rMin, rMax);
    histname = "h_SimConvTwoTracksZ";
    h_SimConvTwoTracks_[3] =  dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated Z",zBin,zMin, zMax);
    histname = "h_SimConvTwoTracksEt";
    h_SimConvTwoTracks_[4] =  dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated Et",etBin,etMin, etMax);
    //
    histname = "h_SimConvOneMTracksEta";
    h_SimConvOneMTracks_[0] =  dbe_->book1D(histname," All vis conversions with 1 reco-matching tracks: simulated #eta",etaBin2,etaMin, etaMax);
    histname = "h_SimConvOneMTracksPhi";
    h_SimConvOneMTracks_[1] =  dbe_->book1D(histname," All vis conversions with 1 reco-matching tracks: simulated #phi",phiBin,phiMin, phiMax);
    histname = "h_SimConvOneMTracksR";
    h_SimConvOneMTracks_[2] =  dbe_->book1D(histname," All vis conversions with 1 reco-matching tracks: simulated R",rBin,rMin, rMax);
    histname = "h_SimConvOneMTracksZ";
    h_SimConvOneMTracks_[3] =  dbe_->book1D(histname," All vis conversions with 1 reco-matching tracks: simulated Z",zBin,zMin, zMax);
    histname = "h_SimConvOneMTracksEt";
    h_SimConvOneMTracks_[4] =  dbe_->book1D(histname," All vis conversions with 1 reco-matching tracks: simulated Et",etBin,etMin, etMax);
    //
    histname = "h_SimConvTwoMTracksEtaAndVtxPGT0";
    h_SimConvTwoMTracksAndVtxPGT0_[0] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated #eta",etaBin2,etaMin, etaMax);
    histname = "h_SimConvTwoMTracksPhiAndVtxPGT0";
    h_SimConvTwoMTracksAndVtxPGT0_[1] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated #phi",phiBin,phiMin, phiMax);
    histname = "h_SimConvTwoMTracksRAndVtxPGT0";
    h_SimConvTwoMTracksAndVtxPGT0_[2] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated R",rBin,rMin, rMax);
    histname = "h_SimConvTwoMTracksZAndVtxPGT0";
    h_SimConvTwoMTracksAndVtxPGT0_[3] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated Z",zBin,zMin, zMax);
    histname = "h_SimConvTwoMTracksEtAndVtxPGT0";
    h_SimConvTwoMTracksAndVtxPGT0_[4] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated Et",etBin,etMin, etMax);
    //
    histname = "h_SimConvTwoMTracksEtaAndVtxPGT0005";
    h_SimConvTwoMTracksAndVtxPGT0005_[0] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated #eta",etaBin2,etaMin, etaMax);
    histname = "h_SimConvTwoMTracksPhiAndVtxPGT0005";
    h_SimConvTwoMTracksAndVtxPGT0005_[1] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated #phi",phiBin,phiMin, phiMax);
    histname = "h_SimConvTwoMTracksRAndVtxPGT0005";
    h_SimConvTwoMTracksAndVtxPGT0005_[2] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated R",rBin,rMin, rMax);
    histname = "h_SimConvTwoMTracksZAndVtxPGT0005";
    h_SimConvTwoMTracksAndVtxPGT0005_[3] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated Z",zBin,zMin, zMax);
    histname = "h_SimConvTwoMTracksEtAndVtxPGT0005";
    h_SimConvTwoMTracksAndVtxPGT0005_[4] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated Et",etBin,etMin, etMax);



    if ( ! isRunCentrally_ ) {
      h_SimConvEtaPix_[0] = dbe_->book1D("simConvEtaPix"," sim converted Photon Eta: Pix ",etaBin,etaMin, etaMax) ;
      h_simTkPt_ = dbe_->book1D("simTkPt","Sim conversion tracks pt ",etBin*3,0.,etMax);
      h_simTkEta_ = dbe_->book1D("simTkEta","Sim conversion tracks eta ",etaBin,etaMin,etaMax);
      h_simConvVtxRvsZ_[0] =   dbe_->book2D("simConvVtxRvsZAll"," Photon Sim conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
      h_simConvVtxRvsZ_[1] =   dbe_->book2D("simConvVtxRvsZBarrel"," Photon Sim conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
      h_simConvVtxRvsZ_[2] =   dbe_->book2D("simConvVtxRvsZEndcap"," Photon Sim conversion vtx position",zBin2ForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
      h_simConvVtxYvsX_ =   dbe_->book2D("simConvVtxYvsXTrkBarrel"," Photon Sim conversion vtx position, (x,y) eta<1 ",100, -80., 80., 100, -80., 80.);
    }

    histname = "h_SimJetEta";
    h_SimJet_[0] =  dbe_->book1D(histname," Jet bkg simulated #eta",etaBin,etaMin, etaMax);
    histname = "h_SimJetPhi";
    h_SimJet_[1] =  dbe_->book1D(histname," Jet bkg simulated #phi",phiBin,phiMin, phiMax);
    histname = "h_SimJetEt";
    h_SimJet_[2] =  dbe_->book1D(histname," Jet bkg simulated Et",etBin,etMin, etMax);
    //
    histname = "h_MatchedSimJetEta";
    h_MatchedSimJet_[0] =  dbe_->book1D(histname," Matching jet simulated #eta",etaBin,etaMin, etaMax);
    histname = "h_MatchedSimJetPhi";
    h_MatchedSimJet_[1] =  dbe_->book1D(histname," Matching jet simulated #phi",phiBin,phiMin, phiMax);
    histname = "h_MatchedSimJetEt";
    h_MatchedSimJet_[2] =  dbe_->book1D(histname," Matching jet simulated Et",etBin,etMin, etMax);
    //
    histname = "h_MatchedSimJetBadChEta";
    h_MatchedSimJetBadCh_[0] =  dbe_->book1D(histname," Matching jet simulated #eta",etaBin,etaMin, etaMax);
    histname = "h_MatchedSimJetBadChPhi";
    h_MatchedSimJetBadCh_[1] =  dbe_->book1D(histname," Matching jet simulated #phi",phiBin,phiMin, phiMax);
    histname = "h_MatchedSimJetBadChEt";
    h_MatchedSimJetBadCh_[2] =  dbe_->book1D(histname," Matching jet simulated Et",etBin,etMin, etMax);


    dbe_->setCurrentFolder("EgammaV/PhotonValidator/Background");

    histname = "nOfPhotons";
    h_nPho_ = dbe_->book1D(histname,"# of Reco photons per event ",20,-0.5,19.5);

    h_scBkgEta_ = dbe_->book1D("scBkgEta"," SC Bkg Eta ",etaBin,etaMin, etaMax) ;
    h_scBkgPhi_ = dbe_->book1D("scBkgPhi"," SC Bkg  Phi ",phiBin,phiMin,phiMax) ;
    //
    h_phoBkgEta_ = dbe_->book1D("phoBkgEta"," Photon Bkg Eta ",etaBin,etaMin, etaMax) ;
    h_phoBkgPhi_ = dbe_->book1D("phoBkgPhi"," Photon Bkg Phi ",phiBin,phiMin,phiMax) ;
    //
    h_phoBkgDEta_ = dbe_->book1D("phoBkgDEta"," Photon Eta(rec)-Eta(true) ",dEtaBin,dEtaMin, dEtaMax) ;
    h_phoBkgDPhi_ = dbe_->book1D("phoBkgDPhi"," Photon  Phi(rec)-Phi(true) ",dPhiBin,dPhiMin,dPhiMax) ;
    //
    histname = "phoBkgE";
    h_phoBkgE_[0]=dbe_->book1D(histname+"All"," Photon Bkg Energy: All ecal ", eBin,eMin, eMax);
    h_phoBkgE_[1]=dbe_->book1D(histname+"Barrel"," Photon Bkg Energy: barrel ",eBin,eMin, eMax);
    h_phoBkgE_[2]=dbe_->book1D(histname+"Endcap"," Photon Bkg Energy: Endcap ",eBin,eMin, eMax);
    //
    histname = "phoBkgEt";
    h_phoBkgEt_[0] = dbe_->book1D(histname+"All"," Photon Bkg Transverse Energy: All ecal ", etBin,etMin, etMax);
    h_phoBkgEt_[1] = dbe_->book1D(histname+"Barrel"," Photon Bkg Transverse Energy: Barrel ",etBin,etMin, etMax);
    h_phoBkgEt_[2] = dbe_->book1D(histname+"Endcap"," Photon BkgTransverse Energy: Endcap ",etBin,etMin, etMax);

    //
    histname = "scBkgE";
    h_scBkgE_[0] = dbe_->book1D(histname+"All","    SC bkg Energy: All Ecal  ",eBin,eMin, eMax);
    h_scBkgE_[1] = dbe_->book1D(histname+"Barrel"," SC bkg Energy: Barrel ",eBin,eMin, eMax);
    h_scBkgE_[2] = dbe_->book1D(histname+"Endcap"," SC bkg Energy: Endcap ",eBin,eMin, eMax);
    histname = "scBkgEt";
    h_scBkgEt_[0] = dbe_->book1D(histname+"All","    SC bkg Et: All Ecal  ",eBin,eMin, eMax);
    h_scBkgEt_[1] = dbe_->book1D(histname+"Barrel"," SC bkg Et: Barrel ",eBin,eMin, eMax);
    h_scBkgEt_[2] = dbe_->book1D(histname+"Endcap"," SC bkg Et: Endcap ",eBin,eMin, eMax);
    //
    histname = "r9Bkg";
    h_r9Bkg_[0] = dbe_->book1D(histname+"All",   " r9 bkg: All Ecal",r9Bin,r9Min, r9Max) ;
    h_r9Bkg_[1] = dbe_->book1D(histname+"Barrel"," r9 bkg: Barrel ",r9Bin,r9Min, r9Max) ;
    h_r9Bkg_[2] = dbe_->book1D(histname+"Endcap"," r9 bkg: Endcap ",r9Bin,r9Min, r9Max) ;
    //
    histname="R9VsEtaBkg";
    h2_r9VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg r9 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
    //
    histname="R9VsEtBkg";
    h2_r9VsEtBkg_ = dbe_->book2D(histname+"All"," Bkg photons r9 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
    //
    histname = "r1Bkg";
    h_r1Bkg_[0] = dbe_->book1D(histname+"All",   " Bkg photon e1x5/e5x5: All Ecal",r9Bin,r9Min, r9Max) ;
    h_r1Bkg_[1] = dbe_->book1D(histname+"Barrel"," Bkg photon e1x5/e5x5: Barrel ",r9Bin,r9Min, r9Max) ;
    h_r1Bkg_[2] = dbe_->book1D(histname+"Endcap"," Bkg photon e1x5/e5x5: Endcap ",r9Bin,r9Min, r9Max) ;
    //
    histname="R1VsEtaBkg";
    h2_r1VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons e1x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
    histname="pR1VsEtaBkg";
    p_r1VsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons e1x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
    //
    histname="R1VsEtBkg";
    h2_r1VsEtBkg_ = dbe_->book2D(histname+"All"," Bkg photons e1x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
    histname="pR1VsEtBkg";
    p_r1VsEtBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
    //
    histname = "r2Bkg";
    h_r2Bkg_[0] = dbe_->book1D(histname+"All",   " Bkg photon e2x5/e5x5: All Ecal",r9Bin,r9Min, r9Max) ;
    h_r2Bkg_[1] = dbe_->book1D(histname+"Barrel"," Bkg photon e2x5/e5x5: Barrel ",r9Bin,r9Min, r9Max) ;
    h_r2Bkg_[2] = dbe_->book1D(histname+"Endcap"," Bkg photon e2x5/e5x5: Endcap ",r9Bin,r9Min, r9Max) ;
    //
    histname="R2VsEtaBkg";
    h2_r2VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons e2x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
    histname="pR2VsEtaBkg";
    p_r2VsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons e2x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
    //
    histname="R2VsEtBkg";
    h2_r2VsEtBkg_ = dbe_->book2D(histname+"All"," Bkg photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
    histname="pR2VsEtBkg";
    p_r2VsEtBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);


    histname = "sigmaIetaIetaBkg";
    h_sigmaIetaIetaBkg_[0] = dbe_->book1D(histname+"All",   "Bkg sigmaIetaIeta: All Ecal",100,0., 0.1) ;
    h_sigmaIetaIetaBkg_[1] = dbe_->book1D(histname+"Barrel","Bkg sigmaIetaIeta: Barrel ", 100,0., 0.05) ;
    h_sigmaIetaIetaBkg_[2] = dbe_->book1D(histname+"Endcap","Bkg sigmaIetaIeta: Endcap ", 100,0., 0.1) ;
    //
    histname="sigmaIetaIetaVsEtaBkg";
    h2_sigmaIetaIetaVsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons sigmaIetaIeta vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
    histname="pSigmaIetaIetaVsEtaBkg";
    p_sigmaIetaIetaVsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons sigmaIetaIeta vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
    //
    histname="sigmaIetaIetaVsEtBkg";
    h2_sigmaIetaIetaVsEtBkg_[0] = dbe_->book2D(histname+"All"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
    h2_sigmaIetaIetaVsEtBkg_[1] = dbe_->book2D(histname+"Barrel"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
    h2_sigmaIetaIetaVsEtBkg_[2] = dbe_->book2D(histname+"Endcap"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
    //
    histname="pSigmaIetaIetaVsEtBkg";
    p_sigmaIetaIetaVsEtBkg_[0] = dbe_->bookProfile(histname+"All"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
    p_sigmaIetaIetaVsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
    p_sigmaIetaIetaVsEtBkg_[2] = dbe_->bookProfile(histname+"Endcap"," Bkg photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
    //
    histname = "hOverEBkg";
    h_hOverEBkg_[0] = dbe_->book1D(histname+"All",   "H/E bkg: All Ecal",100,0., 1.) ;
    h_hOverEBkg_[1] = dbe_->book1D(histname+"Barrel","H/E bkg: Barrel ", 100,0., 1.) ;
    h_hOverEBkg_[2] = dbe_->book1D(histname+"Endcap","H/E bkg: Endcap ", 100,0., 1.) ;
    //
    histname="pHOverEVsEtaBkg";
    p_hOverEVsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg H/E vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
    histname="pHOverEVsEtBkg";
    p_hOverEVsEtBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
    if ( ! isRunCentrally_ ) { 
      histname="hOverEVsEtaBkg";
      h2_hOverEVsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg H/E vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
      //
      histname="hOverEVsEtBkg";
      h2_hOverEVsEtBkg_ = dbe_->book2D(histname+"All"," Bkg photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
    } 
    //
    histname = "ecalRecHitSumEtConeDR04Bkg";
    h_ecalRecHitSumEtConeDR04Bkg_[0] = dbe_->book1D(histname+"All",   "bkg ecalRecHitSumEtDR04: All Ecal",etBin,etMin,50.);
    h_ecalRecHitSumEtConeDR04Bkg_[1] = dbe_->book1D(histname+"Barrel","bkg ecalRecHitSumEtDR04: Barrel ", etBin,etMin,50.);
    h_ecalRecHitSumEtConeDR04Bkg_[2] = dbe_->book1D(histname+"Endcap","bkg ecalRecHitSumEtDR04: Endcap ", etBin,etMin,50.);
    //
    if ( ! isRunCentrally_ ) { 
      histname="ecalRecHitSumEtConeDR04VsEtaBkg";
      h2_ecalRecHitSumEtConeDR04VsEtaBkg_ = dbe_->book2D(histname+"All"," bkg ecalRecHitSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale);
      histname="ecalRecHitSumEtConeDR04VsEtBkg";
      h2_ecalRecHitSumEtConeDR04VsEtBkg_[0] = dbe_->book2D(histname+"All"," Bkg ecalRecHitSumEtDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
      h2_ecalRecHitSumEtConeDR04VsEtBkg_[1] = dbe_->book2D(histname+"Barrel"," Bkg ecalRecHitSumEtDR04 vs Et: Barrel ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
      h2_ecalRecHitSumEtConeDR04VsEtBkg_[2] = dbe_->book2D(histname+"Endcap"," Bkg ecalRecHitSumEtDR04 vs Et: Endcap ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
      histname="hcalTowerSumEtConeDR04VsEtaBkg";
      h2_hcalTowerSumEtConeDR04VsEtaBkg_ = dbe_->book2D(histname+"All"," bkg hcalTowerSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale);
      histname="hcalTowerSumEtConeDR04VsEtBkg";
      h2_hcalTowerSumEtConeDR04VsEtBkg_[0] = dbe_->book2D(histname+"All"," Bkg hcalTowerSumEtDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
      h2_hcalTowerSumEtConeDR04VsEtBkg_[1] = dbe_->book2D(histname+"Barrel"," Bkg hcalTowerSumEtDR04 vs Et: Barrel ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
      h2_hcalTowerSumEtConeDR04VsEtBkg_[2] = dbe_->book2D(histname+"Endcap"," Bkg hcalTowerSumEtDR04 vs Et: Endcap ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
    }

    histname="pEcalRecHitSumEtConeDR04VsEtaBkg";
    p_ecalRecHitSumEtConeDR04VsEtaBkg_ = dbe_->bookProfile(histname+"All","bkg photons ecalRecHitSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale, "");
    //
    histname="pEcalRecHitSumEtConeDR04VsEtBkg";
    p_ecalRecHitSumEtConeDR04VsEtBkg_[0] = dbe_->bookProfile(histname+"All","Bkg ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
    p_ecalRecHitSumEtConeDR04VsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel","Bkg ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
    p_ecalRecHitSumEtConeDR04VsEtBkg_[2] = dbe_->bookProfile(histname+"Endcap","Bkg ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
    //
    histname = "hcalTowerSumEtConeDR04Bkg";
    h_hcalTowerSumEtConeDR04Bkg_[0] = dbe_->book1D(histname+"All",   "bkg hcalTowerSumEtDR04: All Ecal",etBin,etMin,20.);
    h_hcalTowerSumEtConeDR04Bkg_[1] = dbe_->book1D(histname+"Barrel","bkg hcalTowerSumEtDR04: Barrel ", etBin,etMin,20.);
    h_hcalTowerSumEtConeDR04Bkg_[2] = dbe_->book1D(histname+"Endcap","bkg hcalTowerSumEtDR04: Endcap ", etBin,etMin,20.);
    //
    histname="pHcalTowerSumEtConeDR04VsEtaBkg";
    p_hcalTowerSumEtConeDR04VsEtaBkg_ = dbe_->bookProfile(histname+"All","bkg photons hcalTowerSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale, "");
    //
    histname="pHcalTowerSumEtConeDR04VsEtBkg";
    p_hcalTowerSumEtConeDR04VsEtBkg_[0] = dbe_->bookProfile(histname+"All","Bkg hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
    p_hcalTowerSumEtConeDR04VsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel","Bkg hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
    p_hcalTowerSumEtConeDR04VsEtBkg_[2] = dbe_->bookProfile(histname+"Endcap","Bkg hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
    //
    histname = "isoTrkSolidConeDR04Bkg";
    h_isoTrkSolidConeDR04Bkg_[0] = dbe_->book1D(histname+"All",   "isoTrkSolidConeDR04 Bkg: All Ecal",etBin,etMin,etMax*0.1);
    h_isoTrkSolidConeDR04Bkg_[1] = dbe_->book1D(histname+"Barrel","isoTrkSolidConeDR04 Bkg: Barrel ", etBin,etMin,etMax*0.1);
    h_isoTrkSolidConeDR04Bkg_[2] = dbe_->book1D(histname+"Endcap","isoTrkSolidConeDR04 Bkg: Endcap ", etBin,etMin,etMax*0.1);
    //
    histname="isoTrkSolidConeDR04VsEtaBkg";
    h2_isoTrkSolidConeDR04VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons isoTrkSolidConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1);
    histname="pIsoTrkSolidConeDR04VsEtaBkg";
    p_isoTrkSolidConeDR04VsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons isoTrkSolidConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1);
    //
    histname="isoTrkSolidConeDR04VsEtBkg";
    h2_isoTrkSolidConeDR04VsEtBkg_[0] = dbe_->book2D(histname+"All"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
    h2_isoTrkSolidConeDR04VsEtBkg_[1] = dbe_->book2D(histname+"Barrel"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
    h2_isoTrkSolidConeDR04VsEtBkg_[2] = dbe_->book2D(histname+"Endcap"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
    histname="pIsoTrkSolidConeDR04VsEtBkg";
    p_isoTrkSolidConeDR04VsEtBkg_[0] = dbe_->bookProfile(histname+"All"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
    p_isoTrkSolidConeDR04VsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
    p_isoTrkSolidConeDR04VsEtBkg_[2] = dbe_->bookProfile(histname+"Endcap"," Bkg photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
    //
    histname = "nTrkSolidConeDR04Bkg";
    h_nTrkSolidConeDR04Bkg_[0] = dbe_->book1D(histname+"All",   "Bkg nTrkSolidConeDR04: All Ecal",20,0., 20) ;
    h_nTrkSolidConeDR04Bkg_[1] = dbe_->book1D(histname+"Barrel","Bkg nTrkSolidConeDR04: Barrel ", 20,0., 20) ;
    h_nTrkSolidConeDR04Bkg_[2] = dbe_->book1D(histname+"Endcap","Bkg nTrkSolidConeDR04: Endcap ", 20,0., 20) ;
    //
    histname="nTrkSolidConeDR04VsEtaBkg";
    h2_nTrkSolidConeDR04VsEtaBkg_ = dbe_->book2D(histname+"All"," Bkg photons nTrkSolidConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, 20,0., 20) ;
    histname="p_nTrkSolidConeDR04VsEtaBkg";
    p_nTrkSolidConeDR04VsEtaBkg_ = dbe_->bookProfile(histname+"All"," Bkg photons nTrkSolidConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, 20,0., 20) ;
    //
    histname="nTrkSolidConeDR04VsEtBkg";
    h2_nTrkSolidConeDR04VsEtBkg_[0] = dbe_->book2D(histname+"All","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
    h2_nTrkSolidConeDR04VsEtBkg_[1] = dbe_->book2D(histname+"Barrel","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
    h2_nTrkSolidConeDR04VsEtBkg_[2] = dbe_->book2D(histname+"Endcap","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
    //
    histname="pnTrkSolidConeDR04VsEtBkg";
    p_nTrkSolidConeDR04VsEtBkg_[0] = dbe_->bookProfile(histname+"All","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
    p_nTrkSolidConeDR04VsEtBkg_[1] = dbe_->bookProfile(histname+"Barrel","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
    p_nTrkSolidConeDR04VsEtBkg_[2] = dbe_->bookProfile(histname+"Endcap","Bkg photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
    //
    h_convEtaBkg_ = dbe_->book1D("convEtaBkg"," converted Photon Bkg Eta 2 tracks",etaBin,etaMin, etaMax) ;
    h_convPhiBkg_ = dbe_->book1D("convPhiBkg"," converted Photon Bkg Phi ",phiBin,phiMin,phiMax) ;
    //
    histname="mvaOutBkg";
    h_mvaOutBkg_[0] = dbe_->book1D(histname+"All"," mvaOut  conversions bkg : All Ecal",100, 0., 1.);
    h_mvaOutBkg_[1] = dbe_->book1D(histname+"Barrel"," mvaOut conversions bkg: Barrel Ecal",100, 0., 1.);
    h_mvaOutBkg_[2] = dbe_->book1D(histname+"Endcap"," mvaOut  conversions bkg: Endcap Ecal",100, 0., 1.);

    histname="PoverEtracksBkg";
    h_PoverETracksBkg_[0] = dbe_->book1D(histname+"All"," bkg photons conversion p/E: all Ecal ",povereBin, povereMin, povereMax);
    h_PoverETracksBkg_[1] = dbe_->book1D(histname+"Barrel","bkg photons conversion p/E: Barrel Ecal",povereBin, povereMin, povereMax);
    h_PoverETracksBkg_[2] = dbe_->book1D(histname+"Endcap"," bkg photons conversion p/E: Endcap Ecal ",povereBin, povereMin, povereMax);

    histname="EoverPtracksBkg";
    h_EoverPTracksBkg_[0] = dbe_->book1D(histname+"All"," bkg photons conversion E/p: all Ecal ",eoverpBin, eoverpMin, eoverpMax);
    h_EoverPTracksBkg_[1] = dbe_->book1D(histname+"Barrel","bkg photons conversion E/p: Barrel Ecal",eoverpBin, eoverpMin, eoverpMax);
    h_EoverPTracksBkg_[2] = dbe_->book1D(histname+"Endcap"," bkg photons conversion E/p: Endcap Ecal ",eoverpBin, eoverpMin, eoverpMax);

    histname="hDCotTracksBkg";
    h_DCotTracksBkg_[0]= dbe_->book1D(histname+"All"," bkg Photons:Tracks from conversions #delta cotg(#Theta) Tracks: all Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
    h_DCotTracksBkg_[1]= dbe_->book1D(histname+"Barrel"," bkg Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Barrel Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
    h_DCotTracksBkg_[2]= dbe_->book1D(histname+"Endcap"," bkg Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Endcap Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);

    histname="hDPhiTracksAtVtxBkg";
    h_DPhiTracksAtVtxBkg_[0] =dbe_->book1D(histname+"All", " Bkg Photons:Tracks from conversions: #delta#phi Tracks at vertex: all Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
    h_DPhiTracksAtVtxBkg_[1] =dbe_->book1D(histname+"Barrel", " Bkg Photons:Tracks from conversions: #delta#phi Tracks at vertex: Barrel Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
    h_DPhiTracksAtVtxBkg_[2] =dbe_->book1D(histname+"Endcap", " Bkg Photons:Tracks from conversions: #delta#phi Tracks at vertex: Endcap Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);

    if ( ! isRunCentrally_ ) {
      h_convVtxRvsZBkg_[0] =   dbe_->book2D("convVtxRvsZAllBkg"," Bkg Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
      h_convVtxRvsZBkg_[1] =   dbe_->book2D("convVtxRvsZBarrelBkg"," Bkg Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
      h_convVtxYvsXBkg_ =   dbe_->book2D("convVtxYvsXTrkBarrelBkg"," Bkg Photon Reco conversion vtx position, (x,y) eta<1 ",100, -80., 80., 100, -80., 80.);
    }

    //
    dbe_->setCurrentFolder("EgammaV/PhotonValidator/Photons");

    h_phoEta_[0] = dbe_->book1D("phoEta"," Photon Eta ",etaBin,etaMin, etaMax) ;
    h_phoPhi_[0] = dbe_->book1D("phoPhi"," Photon  Phi ",phiBin,phiMin,phiMax) ;

    h_phoDEta_[0] = dbe_->book1D("phoDEta"," Photon Eta(rec)-Eta(true) ",dEtaBin,dEtaMin, dEtaMax) ;
    h_phoDPhi_[0] = dbe_->book1D("phoDPhi"," Photon  Phi(rec)-Phi(true) ",dPhiBin,dPhiMin,dPhiMax) ;

    h_scEta_[0] =   dbe_->book1D("scEta"," SC Eta ",etaBin,etaMin, etaMax);
    h_scPhi_[0] =   dbe_->book1D("scPhi"," SC Phi ",phiBin,phiMin,phiMax);

    if ( ! isRunCentrally_ ) {
      h_scEtaWidth_[0] =   dbe_->book1D("scEtaWidth"," SC Eta Width ",100,0., 0.1);
      h_scPhiWidth_[0] =   dbe_->book1D("scPhiWidth"," SC Phi Width ",100,0., 1.);
    }

    histname = "scE";
    h_scE_[0][0] = dbe_->book1D(histname+"All"," SC Energy: All Ecal  ",eBin,eMin, eMax);
    h_scE_[0][1] = dbe_->book1D(histname+"Barrel"," SC Energy: Barrel ",eBin,eMin, eMax);
    h_scE_[0][2] = dbe_->book1D(histname+"Endcap"," SC Energy: Endcap ",eBin,eMin, eMax);

    histname = "psE";
    h_psE_ = dbe_->book1D(histname+"Endcap"," ES Energy  ",eBin,eMin, 50.);


    histname = "scEt";
    h_scEt_[0][0] = dbe_->book1D(histname+"All"," SC Et: All Ecal ",etBin,etMin, etMax) ;
    h_scEt_[0][1] = dbe_->book1D(histname+"Barrel"," SC Et: Barrel",etBin,etMin, etMax) ;
    h_scEt_[0][2] = dbe_->book1D(histname+"Endcap"," SC Et: Endcap",etBin,etMin, etMax) ;

    histname = "r9";
    h_r9_[0][0] = dbe_->book1D(histname+"All",   " r9: All Ecal",r9Bin,r9Min, r9Max) ;
    h_r9_[0][1] = dbe_->book1D(histname+"Barrel"," r9: Barrel ",r9Bin,r9Min, r9Max) ;
    h_r9_[0][2] = dbe_->book1D(histname+"Endcap"," r9: Endcap ",r9Bin,r9Min, r9Max) ;
    //

    if ( ! isRunCentrally_ ) {
      histname = "r9ConvFromMC";
      h_r9_[1][0] = dbe_->book1D(histname+"All",   " r9: All Ecal",r9Bin,r9Min, r9Max) ;
      h_r9_[1][1] = dbe_->book1D(histname+"Barrel"," r9: Barrel ",r9Bin,r9Min, r9Max) ;
      h_r9_[1][2] = dbe_->book1D(histname+"Endcap"," r9: Endcap ",r9Bin,r9Min, r9Max) ;
      //
      histname = "r9ConvFromReco";
      h_r9_[2][0] = dbe_->book1D(histname+"All",   " r9: All Ecal",r9Bin,r9Min, r9Max) ;
      h_r9_[2][1] = dbe_->book1D(histname+"Barrel"," r9: Barrel ",r9Bin,r9Min, r9Max) ;
      h_r9_[2][2] = dbe_->book1D(histname+"Endcap"," r9: Endcap ",r9Bin,r9Min, r9Max) ;
      histname = "EtR9Less093";
      h_EtR9Less093_[0][0] = dbe_->book1D(histname+"All",   " r9 < 0.94 or 0.95 : All Ecal",etBin,etMin, etMax);
      h_EtR9Less093_[0][1] = dbe_->book1D(histname+"Barrel"," r9 < 0.94 : Barrel ",etBin,etMin, etMax);
      h_EtR9Less093_[0][2] = dbe_->book1D(histname+"Endcap"," r9 < 0.95 : Endcap ",etBin,etMin, etMax);
      histname = "EtR9Less093Conv";
      h_EtR9Less093_[1][0] = dbe_->book1D(histname+"All",   " r9 < 0.94, 0.95 and good conv : All Ecal",etBin,etMin, etMax);
      h_EtR9Less093_[1][1] = dbe_->book1D(histname+"Barrel"," r9 < 0.94 and good conv : Barrel ",etBin,etMin, etMax);
      h_EtR9Less093_[1][2] = dbe_->book1D(histname+"Endcap"," r9 < 0.95 and good conv : Endcap ",etBin,etMin, etMax);
    }

    histname="R9VsEta";
    h2_r9VsEta_[0] = dbe_->book2D(histname+"All"," All photons r9 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
    h2_r9VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons r9 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
    //
    histname="R9VsEt";
    h2_r9VsEt_[0] = dbe_->book2D(histname+"All"," All photons r9 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
    h2_r9VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons r9 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
    //
    histname = "r1";
    h_r1_[0][0] = dbe_->book1D(histname+"All",   " e1x5/e5x5: All Ecal",r9Bin,r9Min, r9Max) ;
    h_r1_[0][1] = dbe_->book1D(histname+"Barrel"," e1x5/e5x5: Barrel ",r9Bin,r9Min, r9Max) ;
    h_r1_[0][2] = dbe_->book1D(histname+"Endcap"," e1x5/e5x5: Endcap ",r9Bin,r9Min, r9Max) ;
    //
    histname="R1VsEta";
    h2_r1VsEta_[0] = dbe_->book2D(histname+"All"," All photons e1x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
    h2_r1VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons e1x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
    //
    histname="R1VsEt";
    h2_r1VsEt_[0] = dbe_->book2D(histname+"All"," All photons e1x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
    h2_r1VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons e1x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
    //
    histname = "r2";
    h_r2_[0][0] = dbe_->book1D(histname+"All",   " e2x5/e5x5: All Ecal",r9Bin,r9Min, r9Max) ;
    h_r2_[0][1] = dbe_->book1D(histname+"Barrel"," e2x5/e5x5: Barrel ",r9Bin,r9Min, r9Max) ;
    h_r2_[0][2] = dbe_->book1D(histname+"Endcap"," e2x5/e5x5: Endcap ",r9Bin,r9Min, r9Max) ;
    //
    histname="R2VsEta";
    h2_r2VsEta_[0] = dbe_->book2D(histname+"All"," All photons e2x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
    h2_r2VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons e2x5/e5x5 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,1.1);
    //
    histname="R2VsEt";
    h2_r2VsEt_[0] = dbe_->book2D(histname+"All"," All photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
    h2_r2VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons e2x5/e5x5 vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,1.1);
    //
    histname = "sigmaIetaIeta";
    h_sigmaIetaIeta_[0][0] = dbe_->book1D(histname+"All",   "sigmaIetaIeta: All Ecal",100,0., 0.1) ;
    h_sigmaIetaIeta_[0][1] = dbe_->book1D(histname+"Barrel","sigmaIetaIeta: Barrel ", 100,0., 0.05) ;
    h_sigmaIetaIeta_[0][2] = dbe_->book1D(histname+"Endcap","sigmaIetaIeta: Endcap ", 100,0., 0.1) ;
    //
    histname="sigmaIetaIetaVsEta";
    h2_sigmaIetaIetaVsEta_[0] = dbe_->book2D(histname+"All"," All photons sigmaIetaIeta vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
    h2_sigmaIetaIetaVsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons sigmaIetaIeta vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,0.1);
    //
    histname="sigmaIetaIetaVsEt";
    h2_sigmaIetaIetaVsEt_[0] = dbe_->book2D(histname+"All"," All photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
    h2_sigmaIetaIetaVsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons sigmaIetaIeta vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
    //
    histname = "hOverE";
    h_hOverE_[0][0] = dbe_->book1D(histname+"All",   "H/E: All Ecal",100,0., 0.1) ;
    h_hOverE_[0][1] = dbe_->book1D(histname+"Barrel","H/E: Barrel ", 100,0., 0.1) ;
    h_hOverE_[0][2] = dbe_->book1D(histname+"Endcap","H/E: Endcap ", 100,0., 0.1) ;
    //
    if ( ! isRunCentrally_ ) { 
      histname="hOverEVsEta";
      h2_hOverEVsEta_[0] = dbe_->book2D(histname+"All"," All photons H/E vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
      h2_hOverEVsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons H/E vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,0.1);
      //
      histname="hOverEVsEt";
      h2_hOverEVsEt_[0] = dbe_->book2D(histname+"All"," All photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
      h2_hOverEVsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
      //
    }
    histname="pHoverEVsEta";
    p_hOverEVsEta_[0] = dbe_->bookProfile(histname+"All"," All photons H/E vs #eta: all Ecal ",  etaBin2,etaMin, etaMax,100, 0.,0.1);
    p_hOverEVsEta_[1] = dbe_->bookProfile(histname+"Unconv"," All photons H/E vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0.,0.1);
    //
    histname="pHoverEVsEt";
    p_hOverEVsEt_[0] = dbe_->bookProfile(histname+"All"," All photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
    p_hOverEVsEt_[1] = dbe_->bookProfile(histname+"Unconv"," All photons H/E vs Et: all Ecal ",etBin,etMin, etMax,100, 0.,0.1);
    //
    histname = "ecalRecHitSumEtConeDR04";
    h_ecalRecHitSumEtConeDR04_[0][0] = dbe_->book1D(histname+"All",   "ecalRecHitSumEtDR04: All Ecal",etBin,etMin,20.);
    h_ecalRecHitSumEtConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","ecalRecHitSumEtDR04: Barrel ", etBin,etMin,20.);
    h_ecalRecHitSumEtConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","ecalRecHitSumEtDR04: Endcap ", etBin,etMin,20.);
    //

    if ( ! isRunCentrally_ ) { 
      histname="ecalRecHitSumEtConeDR04VsEta";
      h2_ecalRecHitSumEtConeDR04VsEta_[0] = dbe_->book2D(histname+"All"," All photons ecalRecHitSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale);
      h2_ecalRecHitSumEtConeDR04VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons ecalRecHitSumEtDR04 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,etBin,etMin,etMax*etScale);
    }
    histname="pEcalRecHitSumEtConeDR04VsEta";
    p_ecalRecHitSumEtConeDR04VsEta_[0] = dbe_->bookProfile(histname+"All","All photons ecalRecHitSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale, "");
    p_ecalRecHitSumEtConeDR04VsEta_[1] = dbe_->bookProfile(histname+"Unconv","All photons ecalRecHitSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*etScale, "");
    //
    if ( ! isRunCentrally_ ) { 
      histname="ecalRecHitSumEtConeDR04VsEt";
      h2_ecalRecHitSumEtConeDR04VsEt_[0] = dbe_->book2D(histname+"All"," All photons ecalRecHitSumEtDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
      h2_ecalRecHitSumEtConeDR04VsEt_[1] = dbe_->book2D(histname+"Barrel"," All photons ecalRecHitSumEtDR04 vs Et: Barrel ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
      h2_ecalRecHitSumEtConeDR04VsEt_[2] = dbe_->book2D(histname+"Endcap"," All photons ecalRecHitSumEtDR04 vs Et: Endcap ",etBin,etMin, etMax, etBin,etMin,etMax*etScale);
    }
    histname="pEcalRecHitSumEtConeDR04VsEt";
    p_ecalRecHitSumEtConeDR04VsEt_[0] = dbe_->bookProfile(histname+"All","All photons ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
    p_ecalRecHitSumEtConeDR04VsEt_[1] = dbe_->bookProfile(histname+"Barrel","All photons ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
    p_ecalRecHitSumEtConeDR04VsEt_[2] = dbe_->bookProfile(histname+"Endcap","All photons ecalRecHitSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
    //
    histname = "hcalTowerSumEtConeDR04";
    h_hcalTowerSumEtConeDR04_[0][0] = dbe_->book1D(histname+"All",   "hcalTowerSumEtConeDR04: All Ecal",etBin,etMin,20.);
    h_hcalTowerSumEtConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","hcalTowerSumEtConeDR04: Barrel ", etBin,etMin,20.);
    h_hcalTowerSumEtConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","hcalTowerSumEtConeDR04: Endcap ", etBin,etMin,20.);

    //
    if ( ! isRunCentrally_ ) { 
      histname="hcalTowerSumEtConeDR04VsEta";
      h2_hcalTowerSumEtConeDR04VsEta_[0] = dbe_->book2D(histname+"All"," All photons hcalTowerSumEtConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1);
      h2_hcalTowerSumEtConeDR04VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons hcalTowerSumEtConeDR04 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,etBin,etMin,etMax*0.1);
    }
    histname="pHcalTowerSumEtConeDR04VsEta";
    p_hcalTowerSumEtConeDR04VsEta_[0] = dbe_->bookProfile(histname+"All","All photons hcalTowerSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1, "");
    p_hcalTowerSumEtConeDR04VsEta_[1] = dbe_->bookProfile(histname+"Unconv","All photons hcalTowerSumEtDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1, "");
    //
    if ( ! isRunCentrally_ ) { 
      histname="hcalTowerSumEtConeDR04VsEt";
      h2_hcalTowerSumEtConeDR04VsEt_[0] = dbe_->book2D(histname+"All"," All photons hcalTowerSumEtConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
      h2_hcalTowerSumEtConeDR04VsEt_[1] = dbe_->book2D(histname+"Barrel"," All photons hcalTowerSumEtConeDR04 vs Et: Barrel ",etBin,etMin, etMax,etBin,etMin,etMax*0.1);
      h2_hcalTowerSumEtConeDR04VsEt_[2] = dbe_->book2D(histname+"Endcap"," All photons hcalTowerSumEtConeDR04 vs Et: Endcap ",etBin,etMin, etMax,etBin,etMin,etMax*0.1);
    }
    histname="pHcalTowerSumEtConeDR04VsEt";
    p_hcalTowerSumEtConeDR04VsEt_[0] = dbe_->bookProfile(histname+"All","All photons hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
    p_hcalTowerSumEtConeDR04VsEt_[1] = dbe_->bookProfile(histname+"Barrel","All photons hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");
    p_hcalTowerSumEtConeDR04VsEt_[2] = dbe_->bookProfile(histname+"Endcap","All photons hcalTowerSumEtDR04 vs Et: all Ecal ",  etBin,etMin, etMax, etBin,etMin,etMax*etScale, "");

    //
    histname = "isoTrkSolidConeDR04";
    h_isoTrkSolidConeDR04_[0][0] = dbe_->book1D(histname+"All",   "isoTrkSolidConeDR04: All Ecal",etBin,etMin,etMax*0.1);
    h_isoTrkSolidConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","isoTrkSolidConeDR04: Barrel ", etBin,etMin,etMax*0.1);
    h_isoTrkSolidConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","isoTrkSolidConeDR04: Endcap ", etBin,etMin,etMax*0.1);
    //

    histname="isoTrkSolidConeDR04VsEta";
    h2_isoTrkSolidConeDR04VsEta_[0] = dbe_->book2D(histname+"All"," All photons isoTrkSolidConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, etBin,etMin,etMax*0.1);
    h2_isoTrkSolidConeDR04VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons isoTrkSolidConeDR04 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,etBin,etMin,etMax*0.1);

    //
    histname="isoTrkSolidConeDR04VsEt";
    h2_isoTrkSolidConeDR04VsEt_[0] = dbe_->book2D(histname+"All"," All photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
    h2_isoTrkSolidConeDR04VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons isoTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, etBin,etMin,etMax*0.1);
    //
    histname = "nTrkSolidConeDR04";
    h_nTrkSolidConeDR04_[0][0] = dbe_->book1D(histname+"All",   "nTrkSolidConeDR04: All Ecal",20,0., 20) ;
    h_nTrkSolidConeDR04_[0][1] = dbe_->book1D(histname+"Barrel","nTrkSolidConeDR04: Barrel ", 20,0., 20) ;
    h_nTrkSolidConeDR04_[0][2] = dbe_->book1D(histname+"Endcap","nTrkSolidConeDR04: Endcap ", 20,0., 20) ;
    //
    histname="nTrkSolidConeDR04VsEta";
    h2_nTrkSolidConeDR04VsEta_[0] = dbe_->book2D(histname+"All"," All photons nTrkSolidConeDR04 vs #eta: all Ecal ",  etaBin2,etaMin, etaMax, 20,0., 20) ;
    h2_nTrkSolidConeDR04VsEta_[1] = dbe_->book2D(histname+"Unconv"," All photons nTrkSolidConeDR04 vs #eta: all Ecal ",etaBin2,etaMin, etaMax,20,0., 20) ;
    //
    histname="nTrkSolidConeDR04VsEt";
    h2_nTrkSolidConeDR04VsEt_[0] = dbe_->book2D(histname+"All"," All photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax, 20,0., 20) ;
    h2_nTrkSolidConeDR04VsEt_[1] = dbe_->book2D(histname+"Unconv"," All photons nTrkSolidConeDR04 vs Et: all Ecal ",etBin,etMin, etMax,20,0., 20) ;
    //
    histname = "phoE";
    h_phoE_[0][0]=dbe_->book1D(histname+"All"," Photon Energy: All ecal ", eBin,eMin, eMax);
    h_phoE_[0][1]=dbe_->book1D(histname+"Barrel"," Photon Energy: barrel ",eBin,eMin, eMax);
    h_phoE_[0][2]=dbe_->book1D(histname+"Endcap"," Photon Energy: Endcap ",eBin,eMin, eMax);

    histname = "phoEt";
    h_phoEt_[0][0] = dbe_->book1D(histname+"All"," Photon Transverse Energy: All ecal ", etBin,etMin, etMax);
    h_phoEt_[0][1] = dbe_->book1D(histname+"Barrel"," Photon Transverse Energy: Barrel ",etBin,etMin, etMax);
    h_phoEt_[0][2] = dbe_->book1D(histname+"Endcap"," Photon Transverse Energy: Endcap ",etBin,etMin, etMax);

    histname = "eRes";
    h_phoERes_[0][0] = dbe_->book1D(histname+"All"," Photon rec/true Energy: All ecal ", resBin,resMin, resMax);
    h_phoERes_[0][1] = dbe_->book1D(histname+"Barrel"," Photon rec/true Energy: Barrel ",resBin,resMin, resMax);
    h_phoERes_[0][2] = dbe_->book1D(histname+"Endcap"," Photon rec/true Energy: Endcap ",resBin,resMin, resMax);

    h_phoERes_[1][0] = dbe_->book1D(histname+"unconvAll"," Photon rec/true Energy if r9>0.94, 0.95: All ecal ", resBin,resMin, resMax);
    h_phoERes_[1][1] = dbe_->book1D(histname+"unconvBarrel"," Photon rec/true Energy if r9>0.94: Barrel ",resBin,resMin, resMax);
    h_phoERes_[1][2] = dbe_->book1D(histname+"unconvEndcap"," Photon rec/true Energyif r9>0.95: Endcap ",resBin,resMin, resMax);

    h_phoERes_[2][0] = dbe_->book1D(histname+"convAll"," Photon rec/true Energy if r9<0.0.94, 0.95: All ecal ", resBin,resMin, resMax);
    h_phoERes_[2][1] = dbe_->book1D(histname+"convBarrel"," Photon rec/true Energyif r9<0.94: Barrel ",resBin,resMin, resMax);
    h_phoERes_[2][2] = dbe_->book1D(histname+"convEndcap"," Photon rec/true Energyif r9<0.95: Endcap ",resBin,resMin, resMax);


    histname="eResVsEta";
    h2_eResVsEta_[0] = dbe_->book2D(histname+"All"," All photons E/Etrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 2.5);
    h2_eResVsEta_[1] = dbe_->book2D(histname+"Unconv"," Unconv photons E/Etrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 2.5);

    histname="pEResVsEta";
    p_eResVsEta_[0] = dbe_->bookProfile(histname+"All","All photons  E/Etrue vs #eta: all Ecal ",etaBin2,etaMin,etaMax,resBin,resMin, resMax,"");
    p_eResVsEta_[1] = dbe_->bookProfile(histname+"Unconv","Unconv photons  E/Etrue vs #eta: all Ecal",etaBin2,etaMin,etaMax,resBin,resMin, resMax,"");
    p_eResVsEta_[2] = dbe_->bookProfile(histname+"Conv","Conv photons  E/Etrue vs #eta: all Ecal",etaBin2,etaMin,etaMax,resBin,resMin, resMax,"");

    if ( ! isRunCentrally_ ) {
      histname="eResVsEt";
      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);
      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);
      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);
      h2_eResVsEt_[1][0] = dbe_->book2D(histname+"Barrel"," All photons E/Etrue vs true Et: Barrel ",etBin,etMin, etMax,100, 0.9, 1.1);
      h2_eResVsEt_[1][1] = dbe_->book2D(histname+"unconvBarrel"," All photons E/Etrue vs true Et: Barrel ",etBin,etMin, etMax,100, 0.9, 1.1);
      h2_eResVsEt_[1][2] = dbe_->book2D(histname+"convBarrel"," All photons E/Etrue vs true Et: Barrel ",etBin,etMin, etMax,100, 0.9, 1.1);
      h2_eResVsEt_[2][0] = dbe_->book2D(histname+"Endcap"," All photons E/Etrue vs true Et: Endcap ",etBin,etMin, etMax,100, 0.9, 1.1);
      h2_eResVsEt_[2][1] = dbe_->book2D(histname+"unconvEndcap"," All photons E/Etrue vs true Et: Endcap ",etBin,etMin, etMax,100, 0.9, 1.1);
      h2_eResVsEt_[2][2] = dbe_->book2D(histname+"convEndcap"," All photons E/Etrue vs true Et: Endcap ",etBin,etMin, etMax,100, 0.9, 1.1);
    }

    histname="pEResVsEt";
    p_eResVsEt_[0][0] = dbe_->bookProfile(histname+"All","All photons  E/Etrue vs Et: all Ecal ",etBin,etMin,etMax,resBin,resMin, resMax,"");
    p_eResVsEt_[0][1] = dbe_->bookProfile(histname+"unconv","All photons  E/Etrue vs Et: all Ecal ",etBin,etMin,etMax,resBin,resMin, resMax,"");
    p_eResVsEt_[0][2] = dbe_->bookProfile(histname+"conv","All photons  E/Etrue vs Et: all Ecal ",etBin,etMin,etMax,resBin,resMin, resMax,"");
    p_eResVsEt_[1][0] = dbe_->bookProfile(histname+"Barrel","All photons  E/Etrue vs Et: Barrel ",etBin,etMin,etMax,resBin,resMin, resMax,"");
    p_eResVsEt_[1][1] = dbe_->bookProfile(histname+"unconvBarrel","All photons  E/Etrue vs Et: Barrel ",etBin,etMin,etMax,resBin,resMin, resMax,"");
    p_eResVsEt_[1][2] = dbe_->bookProfile(histname+"convBarrel","All photons  E/Etrue vs Et: Barrel ",etBin,etMin,etMax,resBin,resMin, resMax,"");
    p_eResVsEt_[2][0] = dbe_->bookProfile(histname+"Endcap","All photons  E/Etrue vs Et: Endcap ",etBin,etMin,etMax,resBin,resMin, resMax,"");
    p_eResVsEt_[2][1] = dbe_->bookProfile(histname+"unconvEndcap","All photons  E/Etrue vs Et: Endcap ",etBin,etMin,etMax,resBin,resMin, resMax,"");
    p_eResVsEt_[2][2] = dbe_->bookProfile(histname+"convEndcap","All photons  E/Etrue vs Et: Endcap ",etBin,etMin,etMax,resBin,resMin, resMax,"");


    histname="eResVsR9";
    h2_eResVsR9_[0] = dbe_->book2D(histname+"All"," All photons E/Etrue vs R9: all Ecal ",r9Bin*2,r9Min, r9Max,100, 0., 2.5);
    h2_eResVsR9_[1] = dbe_->book2D(histname+"Barrel"," All photons E/Etrue vs R9: Barrel ",  r9Bin*2,r9Min, r9Max,100, 0.,2.5);
    h2_eResVsR9_[2] = dbe_->book2D(histname+"Endcap"," All photons E/Etrue vs R9: Endcap ",  r9Bin*2,r9Min, r9Max,100, 0., 2.5);
    histname="pEResVsR9";
    p_eResVsR9_[0] = dbe_->bookProfile(histname+"All"," All photons  E/Etrue vs R9: all Ecal ",r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
    p_eResVsR9_[1] = dbe_->bookProfile(histname+"Barrel"," All photons  E/Etrue vs R9: Barrel ",  r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
    p_eResVsR9_[2] = dbe_->bookProfile(histname+"Endcap"," All photons  E/Etrue vs R9: Endcap ",  r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
    histname="sceResVsR9";
    h2_sceResVsR9_[0] = dbe_->book2D(histname+"All"," All photons scE/Etrue vs R9: all Ecal ",r9Bin*2,r9Min, r9Max,100, 0., 2.5);
    h2_sceResVsR9_[1] = dbe_->book2D(histname+"Barrel"," All photons scE/Etrue vs R9: Barrel ",  r9Bin*2,r9Min, r9Max,100, 0.,2.5);
    h2_sceResVsR9_[2] = dbe_->book2D(histname+"Endcap"," All photons scE/Etrue vs R9: Endcap ",  r9Bin*2,r9Min, r9Max,100, 0., 2.5);
    histname="scpEResVsR9";
    p_sceResVsR9_[0] = dbe_->bookProfile(histname+"All"," All photons  scE/Etrue vs R9: all Ecal ",r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
    p_sceResVsR9_[1] = dbe_->bookProfile(histname+"Barrel"," All photons  scE/Etrue vs R9: Barrel ",  r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");
    p_sceResVsR9_[2] = dbe_->bookProfile(histname+"Endcap"," All photons  scE/Etrue vs R9: Endcap ",  r9Bin*2,r9Min, r9Max,resBin,resMin, resMax,"");



    if ( ! isRunCentrally_ ) { 
      // Photon pair invariant mass
      histname = "gamgamMass";
      h_gamgamMass_[0][0] = dbe_->book1D(histname+"All","2 photons invariant mass: All ecal ", ggMassBin, ggMassMin, ggMassMax);
      h_gamgamMass_[0][1] = dbe_->book1D(histname+"Barrel","2 photons invariant mass:  Barrel ",ggMassBin, ggMassMin, ggMassMax);
      h_gamgamMass_[0][2] = dbe_->book1D(histname+"Endcap","2 photons invariant mass:  Endcap ",ggMassBin, ggMassMin, ggMassMax);
      //
      histname = "gamgamMassNoConv";
      h_gamgamMass_[1][0] = dbe_->book1D(histname+"All","2 photons with no conversion invariant mass: All ecal ",ggMassBin, ggMassMin, ggMassMax);
      h_gamgamMass_[1][1] = dbe_->book1D(histname+"Barrel","2 photons with no conversion  invariant mass:  Barrel ",ggMassBin, ggMassMin, ggMassMax);
      h_gamgamMass_[1][2] = dbe_->book1D(histname+"Endcap","2 photons with no conversion  invariant mass:  Endcap ",ggMassBin, ggMassMin, ggMassMax);
      //
      histname = "gamgamMassConv";
      h_gamgamMass_[2][0] = dbe_->book1D(histname+"All","2 photons with conversion invariant mass: All ecal ", ggMassBin, ggMassMin, ggMassMax);
      h_gamgamMass_[2][1] = dbe_->book1D(histname+"Barrel","2 photons with  conversion  invariant mass:  Barrel ",ggMassBin, ggMassMin, ggMassMax);
      h_gamgamMass_[2][2] = dbe_->book1D(histname+"Endcap","2 photons with  conversion  invariant mass:  Endcap ",ggMassBin, ggMassMin, ggMassMax);
    }

    dbe_->setCurrentFolder("EgammaV/PhotonValidator/ConversionInfo");

    histname="nOfflineVtx";
    h_nRecoVtx_ = dbe_->book1D(histname,"# of Offline Vertices",30, -0.5, 29.5);

    histname="nConv";
    h_nConv_[0][0] = dbe_->book1D(histname+"All","Number Of Conversions per isolated candidates per events: All Ecal  ",10,-0.5, 9.5);
    h_nConv_[0][1] = dbe_->book1D(histname+"Barrel","Number Of Conversions per isolated candidates per events: Ecal Barrel  ",10,-0.5, 9.5);
    h_nConv_[0][2] = dbe_->book1D(histname+"Endcap","Number Of Conversions per isolated candidates per events: Ecal Endcap ",10,-0.5, 9.5);

    h_convEta_[0] = dbe_->book1D("convEta1"," converted Photon Eta >1 track",etaBin,etaMin, etaMax) ;
    h_convEta_[1] = dbe_->book1D("convEta2"," converted Photon Eta =2 tracks ",etaBin,etaMin, etaMax) ;
    h_convEta_[2] = dbe_->book1D("convEta2ass"," converted Photon Eta =2 tracks, both ass ",etaBin,etaMin, etaMax) ;
    h_convPhi_[0] = dbe_->book1D("convPhi"," converted Photon  Phi ",phiBin,phiMin,phiMax) ;


    histname = "convERes";
    h_convERes_[0][0] = dbe_->book1D(histname+"All"," Conversion rec/true Energy: All ecal ", resBin,resMin, resMax);
    h_convERes_[0][1] = dbe_->book1D(histname+"Barrel"," Conversion rec/true Energy: Barrel ",resBin,resMin, resMax);
    h_convERes_[0][2] = dbe_->book1D(histname+"Endcap"," Conversion rec/true Energy: Endcap ",resBin,resMin, resMax);

    histname="p_EResVsR";
    p_eResVsR_ = dbe_->bookProfile(histname+"All"," photons conversion E/Etrue vs R: all Ecal ",rBin,rMin,rMax, 100, 0.,1.5,"");


    histname = "convPtRes";
    h_convPtRes_[1][0] = dbe_->book1D(histname+"All"," Conversion Pt rec/true  from tracks : All ecal ", resBin,0.,1.5);
    h_convPtRes_[1][1] = dbe_->book1D(histname+"Barrel"," Conversion Pt rec/true  from tracks: Barrel ",resBin,0., 1.5);
    h_convPtRes_[1][2] = dbe_->book1D(histname+"Endcap"," Conversion Pt rec/true  from tracks: Endcap ",resBin,0., 1.5);


    if ( ! isRunCentrally_ ) {
      histname="r9VsTracks";
      h_r9VsNofTracks_[0][0] = dbe_->book2D(histname+"All"," photons r9 vs nTracks from conversions: All Ecal",r9Bin,r9Min, r9Max, 3, -0.5, 2.5) ;
      h_r9VsNofTracks_[0][1] = dbe_->book2D(histname+"Barrel"," photons r9 vs nTracks from conversions: Barrel Ecal",r9Bin,r9Min, r9Max, 3, -0.5, 2.5) ;
      h_r9VsNofTracks_[0][2] = dbe_->book2D(histname+"Endcap"," photons r9 vs nTracks from conversions: Endcap Ecal",r9Bin,r9Min, r9Max, 3, -0.5, 2.5) ;
    }

    histname="mvaOut";
    h_mvaOut_[0] = dbe_->book1D(histname+"All"," mvaOut for all conversions : All Ecal",100, 0., 1.);
    h_mvaOut_[1] = dbe_->book1D(histname+"Barrel"," mvaOut for all conversions : Barrel Ecal",100, 0., 1.);
    h_mvaOut_[2] = dbe_->book1D(histname+"Endcap"," mvaOut for all conversions : Endcap Ecal",100, 0., 1.);



    histname="EoverPtracks";
    h_EoverPTracks_[0][0] = dbe_->book1D(histname+"BarrelPix"," photons conversion E/p: barrel pix",eoverpBin, eoverpMin,eoverpMax);
    h_EoverPTracks_[0][1] = dbe_->book1D(histname+"BarrelTib"," photons conversion E/p: barrel tib",eoverpBin, eoverpMin,eoverpMax);
    h_EoverPTracks_[0][2] = dbe_->book1D(histname+"BarrelTob"," photons conversion E/p: barrel tob ",eoverpBin, eoverpMin,eoverpMax);

    h_EoverPTracks_[1][0] = dbe_->book1D(histname+"All"," photons conversion E/p: all Ecal ",100, 0., 5.);
    h_EoverPTracks_[1][1] = dbe_->book1D(histname+"Barrel"," photons conversion E/p: Barrel Ecal",100, 0., 5.);
    h_EoverPTracks_[1][2] = dbe_->book1D(histname+"Endcap"," photons conversion E/p: Endcap Ecal ",100, 0., 5.);

    histname="PoverEtracks";
    h_PoverETracks_[1][0] = dbe_->book1D(histname+"All"," photons conversion p/E: all Ecal ",povereBin, povereMin, povereMax);
    h_PoverETracks_[1][1] = dbe_->book1D(histname+"Barrel"," photons conversion p/E: Barrel Ecal",povereBin, povereMin, povereMax);
    h_PoverETracks_[1][2] = dbe_->book1D(histname+"Endcap"," photons conversion p/E: Endcap Ecal ",povereBin, povereMin, povereMax);

    histname="pEoverEtrueVsEta";
    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,"");

    histname="pEoverEtrueVsR";
    p_EoverEtrueVsR_[0] = dbe_->bookProfile(histname+"All"," photons conversion E/Etrue vs R: all Ecal ",rBin,rMin,rMax, 100, 0., 2.5, "");

    histname="pEoverEtrueVsEta";
    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,"");

    histname="pPoverPtrueVsEta";
    p_PoverPtrueVsEta_[0] = dbe_->bookProfile(histname+"All"," photons conversion P/Ptrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 5.,"");

    histname="pEoverPVsEta";
    p_EoverPVsEta_[0] = dbe_->bookProfile(histname+"All"," photons conversion E/P vs #eta: all Ecal ",etaBin2,etaMin, etaMax, 100, 0., 5.,"");


    if ( ! isRunCentrally_ ) {
      histname="EoverEtrueVsEoverP";
      h2_EoverEtrueVsEoverP_[0] = dbe_->book2D(histname+"All"," photons conversion E/Etrue vs E/P: all Ecal ",100, 0., 5., 100, 0.5, 1.5);
      h2_EoverEtrueVsEoverP_[1] = dbe_->book2D(histname+"Barrel"," photons conversion  E/Etrue vs E/: Barrel Ecal",100, 0., 5.,100, 0.5, 1.5);
      h2_EoverEtrueVsEoverP_[2] = dbe_->book2D(histname+"Endcap"," photons conversion  E/Etrue vs E/: Endcap Ecal ",100, 0., 5., 100, 0.5, 1.5);
      histname="PoverPtrueVsEoverP";
      h2_PoverPtrueVsEoverP_[0] = dbe_->book2D(histname+"All"," photons conversion P/Ptrue vs E/P: all Ecal ",100, 0., 5., 100, 0., 2.5);
      h2_PoverPtrueVsEoverP_[1] = dbe_->book2D(histname+"Barrel"," photons conversion  P/Ptrue vs E/: Barrel Ecal",100, 0., 5.,100, 0., 2.5);
      h2_PoverPtrueVsEoverP_[2] = dbe_->book2D(histname+"Endcap"," photons conversion  P/Ptrue vs E/: Endcap Ecal ",100, 0., 5., 100, 0., 2.5);

      histname="EoverEtrueVsEta";
      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);


      histname="EoverEtrueVsEta";
      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);

      histname="EoverEtrueVsR";
      h2_EoverEtrueVsR_[0] = dbe_->book2D(histname+"All"," photons conversion E/Etrue vs R: all Ecal ",rBin,rMin, rMax,100, 0., 2.5);

      histname="PoverPtrueVsEta";
      h2_PoverPtrueVsEta_[0] = dbe_->book2D(histname+"All"," photons conversion P/Ptrue vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 5.);

      histname="EoverPVsEta";
      h2_EoverPVsEta_[0] = dbe_->book2D(histname+"All"," photons conversion E/P vs #eta: all Ecal ",etaBin2,etaMin, etaMax,100, 0., 5.);

      histname="EoverPVsR";
      h2_EoverPVsR_[0] = dbe_->book2D(histname+"All"," photons conversion E/P vs R: all Ecal ",rBin,rMin, rMax,100, 0., 5.);

      histname="etaVsRsim";
      h2_etaVsRsim_[0] = dbe_->book2D(histname+"All"," eta(sim) vs R (sim) for associated conversions: all Ecal ",etaBin, etaMin, etaMax,rBin,rMin, rMax);
      histname="etaVsRreco";
      h2_etaVsRreco_[0] = dbe_->book2D(histname+"All"," eta(reco) vs R (reco) for associated conversions: all Ecal ",etaBin, etaMin, etaMax,rBin,rMin, rMax);

    }

    histname="pEoverPVsR";
    p_EoverPVsR_[0] = dbe_->bookProfile(histname+"All"," photons conversion E/P vs R: all Ecal ",rBin,rMin,rMax, 100, 0., 5.,"");


    histname="hInvMass";
    h_invMass_[0][0]= dbe_->book1D(histname+"All_AllTracks"," Photons:Tracks from conversion: Pair invariant mass: all Ecal ",100, 0., 1.5);
    h_invMass_[0][1]= dbe_->book1D(histname+"Barrel_AllTracks"," Photons:Tracks from conversion: Pair invariant mass: Barrel Ecal ",100, 0., 1.5);
    h_invMass_[0][2]= dbe_->book1D(histname+"Endcap_AllTracks"," Photons:Tracks from conversion: Pair invariant mass: Endcap Ecal ",100, 0., 1.5);
    histname="hInvMass";
    h_invMass_[1][0]= dbe_->book1D(histname+"All_AssTracks"," Photons:Tracks from conversion: Pair invariant mass: all Ecal ",100, 0., 1.5);
    h_invMass_[1][1]= dbe_->book1D(histname+"Barrel_AssTracks"," Photons:Tracks from conversion: Pair invariant mass: Barrel Ecal ",100, 0., 1.5);
    h_invMass_[1][2]= dbe_->book1D(histname+"Endcap_AssTracks"," Photons:Tracks from conversion: Pair invariant mass: Endcap Ecal ",100, 0., 1.5);


    histname="hDPhiTracksAtVtx";
    h_DPhiTracksAtVtx_[1][0] =dbe_->book1D(histname+"All", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: all Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
    h_DPhiTracksAtVtx_[1][1] =dbe_->book1D(histname+"Barrel", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Barrel Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
    h_DPhiTracksAtVtx_[1][2] =dbe_->book1D(histname+"Endcap", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Endcap Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);


    if ( ! isRunCentrally_ ) {
      histname="hDPhiTracksAtVtxVsEta";
      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);

      histname="hDPhiTracksAtVtxVsR";
      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);

      histname="hDCotTracksVsEta";
      h2_DCotTracksVsEta_ = dbe_->book2D(histname+"All","  Photons:Tracks from conversions:  #delta cotg(#Theta) Tracks vs #eta",etaBin2,etaMin, etaMax,100, -0.2, 0.2);

      histname="hDCotTracksVsR";
      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);

      histname="h2_DPhiTracksAtEcalVsR";
      h2_DPhiTracksAtEcalVsR_= dbe_->book2D(histname+"All"," Photons:Tracks from conversions:  #delta#phi at Ecal vs R : all Ecal ",rBin,rMin, rMax, dPhiTracksBin,0.,dPhiTracksMax);

      histname="h2_DPhiTracksAtEcalVsEta";
      h2_DPhiTracksAtEcalVsEta_= dbe_->book2D(histname+"All"," Photons:Tracks from conversions:  #delta#phi at Ecal vs #eta : all Ecal ",etaBin2,etaMin, etaMax, dPhiTracksBin,0.,dPhiTracksMax);


    }

    histname="pDPhiTracksAtVtxVsEta";
    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,"");

    histname="pDPhiTracksAtVtxVsR";
    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,"");


    histname="hDCotTracks";
    h_DCotTracks_[1][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: all Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
    h_DCotTracks_[1][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Barrel Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
    h_DCotTracks_[1][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Endcap Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);


    histname="pDCotTracksVsEta";
    p_DCotTracksVsEta_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions:  #delta cotg(#Theta) Tracks vs #eta ",etaBin2,etaMin, etaMax, 100, -0.2, 0.2,"");

    histname="pDCotTracksVsR";
    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,"");


    histname="hDistMinAppTracks";
    h_distMinAppTracks_[1][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions Min Approach Dist Tracks: all Ecal ",dEtaTracksBin,-0.1,0.6);
    h_distMinAppTracks_[1][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions Min Approach Dist Tracks: Barrel Ecal ",dEtaTracksBin,-0.1,0.6);
    h_distMinAppTracks_[1][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions Min Approach Dist Tracks: Endcap Ecal ",dEtaTracksBin,-0.1,0.6);

    histname="hDPhiTracksAtEcal";
    h_DPhiTracksAtEcal_[1][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions:  #delta#phi at Ecal : all Ecal ",dPhiTracksBin,0.,dPhiTracksMax);
    h_DPhiTracksAtEcal_[1][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions:  #delta#phi at Ecal : Barrel Ecal ",dPhiTracksBin,0.,dPhiTracksMax);
    h_DPhiTracksAtEcal_[1][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions:  #delta#phi at Ecal : Endcap Ecal ",dPhiTracksBin,0.,dPhiTracksMax);

    histname="pDPhiTracksAtEcalVsR";
    p_DPhiTracksAtEcalVsR_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions:  #delta#phi at Ecal  vs R ",rBin,rMin, rMax, dPhiTracksBin,0.,dPhiTracksMax,"");

    histname="pDPhiTracksAtEcalVsEta";
    p_DPhiTracksAtEcalVsEta_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions:  #delta#phi at Ecal  vs #eta ",etaBin2,etaMin, etaMax,dPhiTracksBin,0.,dPhiTracksMax,"");


    histname="hDEtaTracksAtEcal";
    h_DEtaTracksAtEcal_[1][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions:  #delta#eta at Ecal : all Ecal ",dEtaTracksBin,dEtaTracksMin,dEtaTracksMax);
    h_DEtaTracksAtEcal_[1][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions:  #delta#eta at Ecal : Barrel Ecal ",dEtaTracksBin,dEtaTracksMin,dEtaTracksMax);
    h_DEtaTracksAtEcal_[1][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions:  #delta#eta at Ecal : Endcap Ecal ",dEtaTracksBin,dEtaTracksMin,dEtaTracksMax);


    h_convVtxRvsZ_[0] =   dbe_->book2D("convVtxRvsZAll"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
    h_convVtxRvsZ_[1] =   dbe_->book2D("convVtxRvsZBarrel"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
    h_convVtxRvsZ_[2] =   dbe_->book2D("convVtxRvsZEndcap"," Photon Reco conversion vtx position",zBin2ForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
    h_convVtxYvsX_ =   dbe_->book2D("convVtxYvsXTrkBarrel"," Photon Reco conversion vtx position, (x,y) eta<1 ",100, -80., 80., 100, -80., 80.);
    if ( ! isRunCentrally_ ) {
      h_convVtxRvsZ_zoom_[0] =  dbe_->book2D("convVtxRvsZBarrelZoom1"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, -10., 40.);
      h_convVtxRvsZ_zoom_[1] =  dbe_->book2D("convVtxRvsZBarrelZoom2"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, -10., 20.);
      h_convVtxYvsX_zoom_[0] =   dbe_->book2D("convVtxYvsXTrkBarrelZoom1"," Photon Reco conversion vtx position, (x,y) eta<1 ",100, -40., 40., 100, -40., 40.);
      h_convVtxYvsX_zoom_[1] =   dbe_->book2D("convVtxYvsXTrkBarrelZoom2"," Photon Reco conversion vtx position, (x,y) eta<1 ",100, -20., 20., 100, -20., 20.);
    }

    h_convVtxdX_ =   dbe_->book1D("convVtxdX"," Photon Reco conversion vtx dX",100, -20.,20.);
    h_convVtxdY_ =   dbe_->book1D("convVtxdY"," Photon Reco conversion vtx dY",100, -20.,20.);
    h_convVtxdZ_ =   dbe_->book1D("convVtxdZ"," Photon Reco conversion vtx dZ",100, -20.,20.);
    h_convVtxdR_ =   dbe_->book1D("convVtxdR"," Photon Reco conversion vtx dR",100, -20.,20.);

    h_convVtxdX_barrel_ =   dbe_->book1D("convVtxdX_barrel"," Photon Reco conversion vtx dX, |eta|<=1.2",100, -20.,20.);
    h_convVtxdY_barrel_ =   dbe_->book1D("convVtxdY_barrel"," Photon Reco conversion vtx dY, |eta|<=1.2 ",100, -20.,20.);
    h_convVtxdZ_barrel_ =   dbe_->book1D("convVtxdZ_barrel"," Photon Reco conversion vtx dZ, |eta|<=1.2,",100, -20.,20.);
    h_convVtxdR_barrel_ =   dbe_->book1D("convVtxdR_barrel"," Photon Reco conversion vtx dR, |eta|<=1.2",100, -20.,20.);
    h_convVtxdX_endcap_ =   dbe_->book1D("convVtxdX_endcap"," Photon Reco conversion vtx dX,  |eta|>1.2",100, -20.,20.);
    h_convVtxdY_endcap_ =   dbe_->book1D("convVtxdY_endcap"," Photon Reco conversion vtx dY,  |eta|>1.2",100, -20.,20.);
    h_convVtxdZ_endcap_ =   dbe_->book1D("convVtxdZ_endcap"," Photon Reco conversion vtx dZ,  |eta|>1.2",100, -20.,20.);
    h_convVtxdR_endcap_ =   dbe_->book1D("convVtxdR_endcap"," Photon Reco conversion vtx dR,  |eta|>1.2 ",100, -20.,20.);


    h_convVtxdPhi_ =   dbe_->book1D("convVtxdPhi"," Photon Reco conversion vtx dPhi",100, -0.005,0.005);
    h_convVtxdEta_ =   dbe_->book1D("convVtxdEta"," Photon Reco conversion vtx dEta",100, -0.5,0.5);

    if ( ! isRunCentrally_ ) {
      h2_convVtxdRVsR_ =  dbe_->book2D("h2ConvVtxdRVsR","Photon Reco conversion vtx dR vsR" ,rBin,rMin, rMax,100, -20.,20.);
      h2_convVtxdRVsEta_ =  dbe_->book2D("h2ConvVtxdRVsEta","Photon Reco conversion vtx dR vs Eta" ,etaBin2,etaMin, etaMax,100, -20.,20.);
    }

    p_convVtxdRVsR_ =  dbe_->bookProfile("pConvVtxdRVsR","Photon Reco conversion vtx dR vsR" ,rBin,rMin, rMax ,100, -20.,20., "");
    p_convVtxdRVsEta_ =  dbe_->bookProfile("pConvVtxdRVsEta","Photon Reco conversion vtx dR vs Eta" ,etaBin2,etaMin, etaMax, 100, -20.,20., "");
    p_convVtxdXVsX_ =  dbe_->bookProfile("pConvVtxdXVsX","Conversion vtx dX vs X" ,120,-60, 60 ,100, -20.,20., "");
    p_convVtxdYVsY_ =  dbe_->bookProfile("pConvVtxdYVsY","Conversion vtx dY vs Y" ,120,-60, 60 ,100, -20.,20., "");
    p_convVtxdZVsZ_ =  dbe_->bookProfile("pConvVtxdZVsZ","Conversion vtx dZ vs Z" ,zBin,zMin,zMax ,100, -20.,20., "");


    if ( ! isRunCentrally_ ) {
      h2_convVtxRrecVsTrue_ =  dbe_->book2D("h2ConvVtxRrecVsTrue","Photon Reco conversion vtx R rec vs true" ,rBin,rMin, rMax,rBin,rMin, rMax);
    }

    histname="vtxChi2";
    h_vtxChi2_[0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 100, chi2Min, chi2Max);
    h_vtxChi2_[1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 100, chi2Min, chi2Max);
    h_vtxChi2_[2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 100, chi2Min, chi2Max);
    histname="vtxChi2Prob";
    h_vtxChi2Prob_[0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 100, 0., 1.);
    h_vtxChi2Prob_[1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 100, 0., 1.);
    h_vtxChi2Prob_[2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 100, 0., 1.);

    histname="zPVFromTracks";
    h_zPVFromTracks_[0] =  dbe_->book1D(histname+"All"," Photons: PV z from conversion tracks",   100, -30., 30.);
    h_zPVFromTracks_[1] =  dbe_->book1D(histname+"Barrel"," Photons: PV z from conversion tracks",100, -30., 30.);
    h_zPVFromTracks_[2] =  dbe_->book1D(histname+"Endcap"," Photons: PV z from conversion tracks",100, -30., 30.);
    h_zPVFromTracks_[3] =  dbe_->book1D(histname+"EndcapP"," Photons: PV z from conversion tracks",100, -30., 30.);
    h_zPVFromTracks_[4] =  dbe_->book1D(histname+"EndcapM"," Photons: PV z from conversion tracks",100, -30., 30.);
    histname="dzPVFromTracks";
    h_dzPVFromTracks_[0] =  dbe_->book1D(histname+"All"," Photons: PV Z_rec - Z_true from conversion tracks",   100, -10., 10.);
    h_dzPVFromTracks_[1] =  dbe_->book1D(histname+"Barrel"," Photons: PV Z_rec - Z_true from conversion tracks",100, -10., 10.);
    h_dzPVFromTracks_[2] =  dbe_->book1D(histname+"Endcap"," Photons: PV Z_rec - Z_true from conversion tracks",100, -10., 10.);
    h_dzPVFromTracks_[3] =  dbe_->book1D(histname+"EndcapP"," Photons: PV Z_rec - Z_true from conversion tracks",100, -10., 10.);
    h_dzPVFromTracks_[4] =  dbe_->book1D(histname+"EndcapM"," Photons: PV Z_rec - Z_true from conversion tracks",100, -10., 10.);
    p_dzPVVsR_ =  dbe_->bookProfile("pdzPVVsR","Photon Reco conversions: dz(PV) vs R" ,rBin,rMin, rMax, 100, -3.,3.,"");
    p_dzPVVsEta_ =  dbe_->bookProfile("pdzPVVsEta","Photon Reco conversions: dz(PV) vs Eta" ,etaBin,etaMin, etaMax, 100, -3.,3.,"");

    if ( ! isRunCentrally_ ) {
      h2_dzPVVsR_ =  dbe_->book2D("h2dzPVVsR","Photon Reco conversions: dz(PV) vs R" ,rBin,rMin, rMax,100, -3.,3.);
    }

    if ( ! isRunCentrally_ ) {
      histname="nHitsVsEta";
      nHitsVsEta_[0] =  dbe_->book2D(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs #eta all tracks",etaBin,etaMin, etaMax,25,0., 25.);

      histname="nHitsVsEta";
      nHitsVsEta_[1] =  dbe_->book2D(histname+"AssTracks","Photons:Tracks from conversions: # of hits vs #eta associated tracks",etaBin,etaMin, etaMax,25,0., 25.);

      histname="nHitsVsR";
      nHitsVsR_[0] =  dbe_->book2D(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs radius all tracks" ,rBin,rMin, rMax,25,0.,25);

      histname="nHitsVsR";
      nHitsVsR_[1] =  dbe_->book2D(histname+"AssTracks","Photons:Tracks from conversions: # of hits vs radius associated tracks" ,rBin,rMin, rMax,25,0.,25);

      histname="h2Chi2VsEta";
      h2_Chi2VsEta_[0]=dbe_->book2D(histname+"All"," Reco Track  #chi^{2} vs #eta: All ",etaBin2,etaMin, etaMax,100, chi2Min, chi2Max);


      histname="h2Chi2VsR";
      h2_Chi2VsR_[0]=dbe_->book2D(histname+"All"," Reco Track  #chi^{2} vs R: All ",rBin,rMin, rMax,100,chi2Min, chi2Max);
    }

    histname="h_nHitsVsEta";
    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,"");

    histname="h_nHitsVsEta";
    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,"");


    histname="h_nHitsVsR";
    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,"");
    histname="tkChi2";
    h_tkChi2_[0] = dbe_->book1D(histname+"AllTracks","Photons:Tracks from conversions: #chi^{2} of all tracks", 100, chi2Min, chi2Max);
    histname="tkChi2Large";
    h_tkChi2Large_[0] = dbe_->book1D(histname+"AllTracks","Photons:Tracks from conversions: #chi^{2} of all tracks", 1000, 0., 5000.0);

    histname="h_nHitsVsR";
    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,"");

    histname="tkChi2";
    h_tkChi2_[1] = dbe_->book1D(histname+"AssTracks","Photons:Tracks from conversions: #chi^{2} of associated  tracks", 100, chi2Min, chi2Max);
    histname="tkChi2Large";
    h_tkChi2Large_[1] = dbe_->book1D(histname+"AssTracks","Photons:Tracks from conversions: #chi^{2} of associated  tracks", 1000, 0., 5000.0);

    histname="pChi2VsEta";
    p_Chi2VsEta_[0]=dbe_->bookProfile(histname+"All"," Reco Track #chi^{2} vs #eta : All ",etaBin2,etaMin, etaMax, 100, chi2Min, chi2Max,"");

    histname="pChi2VsR";
    p_Chi2VsR_[0]=dbe_->bookProfile(histname+"All"," Reco Track #chi^{2} vas R : All ",rBin,rMin,rMax, 100,chi2Min, chi2Max,"");


    histname="hTkD0";
    h_TkD0_[0]=dbe_->book1D(histname+"All"," Reco Track D0*q: All ",100,-0.1,0.6);
    h_TkD0_[1]=dbe_->book1D(histname+"Barrel"," Reco Track D0*q: Barrel ",100,-0.1,0.6);
    h_TkD0_[2]=dbe_->book1D(histname+"Endcap"," Reco Track D0*q: Endcap ",100,-0.1,0.6);


    histname="hTkPtPull";
    h_TkPtPull_[0]=dbe_->book1D(histname+"All"," Reco Track Pt pull: All ",100, -10., 10.);
    histname="hTkPtPull";
    h_TkPtPull_[1]=dbe_->book1D(histname+"Barrel"," Reco Track Pt pull: Barrel ",100, -10., 10.);
    histname="hTkPtPull";
    h_TkPtPull_[2]=dbe_->book1D(histname+"Endcap"," Reco Track Pt pull: Endcap ",100, -10., 10.);

    histname="pTkPtPullEta";
    p_TkPtPull_[0]=dbe_->bookProfile(histname+"All"," Reco Track Pt pull: All ",etaBin2,etaMin, etaMax, 100, -10., 10., " ");

    if ( ! isRunCentrally_ ) {
      histname="h2TkPtPullEta";
      h2_TkPtPull_[0]=dbe_->book2D(histname+"All"," Reco Track Pt pull: All ",etaBin2,etaMin, etaMax,100, -10., 10.);

      histname="PtRecVsPtSim";
      h2_PtRecVsPtSim_[0]=dbe_->book2D(histname+"All", "Pt Rec vs Pt sim: All ", etBin,etMin,etMax,etBin,etMin, etMax);
      h2_PtRecVsPtSim_[1]=dbe_->book2D(histname+"Barrel", "Pt Rec vs Pt sim: Barrel ", etBin,etMin,etMax,etBin,etMin, etMax);
      h2_PtRecVsPtSim_[2]=dbe_->book2D(histname+"Endcap", "Pt Rec vs Pt sim: Endcap ", etBin,etMin,etMax,etBin,etMin, etMax);
      histname="PtRecVsPtSimMixProv";
      h2_PtRecVsPtSimMixProv_ =dbe_->book2D(histname+"All", "Pt Rec vs Pt sim All for mix with general tracks ", etBin,etMin,etMax,etBin,etMin, etMax);
    }


    histname="eBcOverTkPout";
    hBCEnergyOverTrackPout_[0] = dbe_->book1D(histname+"All","Matrching BC E/P_out: all Ecal ",100, 0., 5.);
    hBCEnergyOverTrackPout_[1] = dbe_->book1D(histname+"Barrel","Matrching BC E/P_out: Barrel ",100, 0., 5.);
    hBCEnergyOverTrackPout_[2] = dbe_->book1D(histname+"Endcap","Matrching BC E/P_out: Endcap ",100, 0., 5.);


    h_OIinnermostHitR_ = dbe_->book1D("OIinnermostHitR"," R innermost hit for OI tracks ",50, 0., 25);
    h_IOinnermostHitR_ = dbe_->book1D("IOinnermostHitR"," R innermost hit for IO tracks ",50, 0., 25);

    h_trkProv_[0] = dbe_->book1D("allTrkProv"," Track pair provenance ",4, 0., 4.);
    h_trkProv_[1] = dbe_->book1D("assTrkProv"," Track pair provenance ",4, 0., 4.);

    // histos for fake rate
    histname = "h_RecoConvTwoTracksEta";
    h_RecoConvTwoTracks_[0] =  dbe_->book1D(histname," All reco conversions with 2 reco  tracks: simulated #eta",etaBin2,etaMin, etaMax);
    histname = "h_RecoConvTwoTracksPhi";
    h_RecoConvTwoTracks_[1] =  dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated #phi",phiBin,phiMin, phiMax);
    histname = "h_RecoConvTwoTracksR";
    h_RecoConvTwoTracks_[2] =  dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated R",rBin,rMin, rMax);
    histname = "h_RecoConvTwoTracksZ";
    h_RecoConvTwoTracks_[3] =  dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated Z",zBin,zMin, zMax);
    histname = "h_RecoConvTwoTracksEt";
    h_RecoConvTwoTracks_[4] =  dbe_->book1D(histname," All reco conversions with 2 reco tracks: simulated Et",etBin,etMin, etMax);
    //
    histname = "h_RecoConvTwoMTracksEta";
    h_RecoConvTwoMTracks_[0] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated #eta",etaBin2,etaMin, etaMax);
    histname = "h_RecoConvTwoMTracksPhi";
    h_RecoConvTwoMTracks_[1] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated #phi",phiBin,phiMin, phiMax);
    histname = "h_RecoConvTwoMTracksR";
    h_RecoConvTwoMTracks_[2] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated R",rBin,rMin, rMax);
    histname = "h_RecoConvTwoMTracksZ";
    h_RecoConvTwoMTracks_[3] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated Z",zBin,zMin, zMax);
    histname = "h_RecoConvTwoMTracksEt";
    h_RecoConvTwoMTracks_[4] =  dbe_->book1D(histname," All reco conversions with 2 reco-ass tracks: simulated Et",etBin,etMin, etMax);




  } // if DQM



}
void PhotonValidator::beginRun ( edm::Run const &  r,
edm::EventSetup const &  theEventSetup 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 1352 of file PhotonValidator.cc.

References edm::EventSetup::get(), and edm::ESHandle< T >::product().

                                                                                       {

   //get magnetic field
  edm::LogInfo("ConvertedPhotonProducer") << " get magnetic field" << "\n";
  theEventSetup.get<IdealMagneticFieldRecord>().get(theMF_);


  edm::ESHandle<TrackAssociatorBase> theHitsAssociator;
  theEventSetup.get<TrackAssociatorRecord>().get("trackAssociatorByHitsForPhotonValidation",theHitsAssociator);
  theTrackAssociator_ = (TrackAssociatorBase *) theHitsAssociator.product();

  thePhotonMCTruthFinder_ = new PhotonMCTruthFinder();

}
void PhotonValidator::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 3202 of file PhotonValidator.cc.

References dbe_, dumpDBToFile_GT_ttrig_cfg::outputFileName, and DQMStore::save().

                             {


  std::string outputFileName = parameters_.getParameter<std::string>("OutputFileName");
  if ( ! isRunCentrally_ ) {
    dbe_->save(outputFileName);
  }

  edm::LogInfo("PhotonValidator") << "Analyzed " << nEvt_  << "\n";
  // std::cout  << "::endJob Analyzed " << nEvt_ << " events " << " with total " << nPho_ << " Photons " << "\n";
  //  std::cout  << "PhotonValidator::endJob Analyzed " << nEvt_ << " events " << "\n";

  return ;
}
void PhotonValidator::endRun ( edm::Run r,
edm::EventSetup const &  es 
) [virtual]

Definition at line 1367 of file PhotonValidator.cc.

float PhotonValidator::etaTransformation ( float  a,
float  b 
) [private]

Definition at line 3233 of file PhotonValidator.cc.

References ETA, etaBarrelEndcap, funct::log(), PI, R_ECAL, funct::tan(), and Z_Endcap.

                                                                             {

  //---Definitions
  const float PI    = 3.1415927;

  //---Definitions for ECAL
  const float R_ECAL           = 136.5;
  const float Z_Endcap         = 328.0;
  const float etaBarrelEndcap  = 1.479;

  //---ETA correction

  float Theta = 0.0  ;
  float ZEcal = R_ECAL*sinh(EtaParticle)+Zvertex;

  if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
  if(Theta<0.0) Theta = Theta+PI ;
  float ETA = - log(tan(0.5*Theta));

  if( fabs(ETA) > etaBarrelEndcap )
    {
      float Zend = Z_Endcap ;
      if(EtaParticle<0.0 )  Zend = -Zend ;
      float Zlen = Zend - Zvertex ;
      float RR = Zlen/sinh(EtaParticle);
      Theta = atan(RR/Zend);
      if(Theta<0.0) Theta = Theta+PI ;
      ETA = - log(tan(0.5*Theta));
    }
  //---Return the result
  return ETA;
  //---end
}
float PhotonValidator::phiNormalization ( float &  a) [private]

Definition at line 3217 of file PhotonValidator.cc.

References phi, PI, and TWOPI.

{
  //---Definitions
  const float PI    = 3.1415927;
  const float TWOPI = 2.0*PI;


  if(phi >  PI) {phi = phi - TWOPI;}
  if(phi < -PI) {phi = phi + TWOPI;}

  //  cout << " Float_t PHInormalization out " << PHI << endl;
  return phi;

}

Member Data Documentation

Definition at line 98 of file PhotonValidator.h.

Definition at line 95 of file PhotonValidator.h.

Definition at line 96 of file PhotonValidator.h.

double PhotonValidator::bcEtLow_ [private]

Definition at line 124 of file PhotonValidator.h.

Definition at line 105 of file PhotonValidator.h.

Definition at line 104 of file PhotonValidator.h.

Definition at line 117 of file PhotonValidator.h.

Definition at line 73 of file PhotonValidator.h.

Definition at line 132 of file PhotonValidator.h.

Definition at line 133 of file PhotonValidator.h.

Definition at line 134 of file PhotonValidator.h.

Definition at line 130 of file PhotonValidator.h.

Definition at line 123 of file PhotonValidator.h.

Definition at line 99 of file PhotonValidator.h.

bool PhotonValidator::fastSim_ [private]

Definition at line 112 of file PhotonValidator.h.

std::string PhotonValidator::fName_ [private]

Definition at line 72 of file PhotonValidator.h.

Definition at line 416 of file PhotonValidator.h.

Definition at line 418 of file PhotonValidator.h.

Definition at line 389 of file PhotonValidator.h.

Definition at line 387 of file PhotonValidator.h.

Definition at line 395 of file PhotonValidator.h.

Definition at line 343 of file PhotonValidator.h.

Definition at line 345 of file PhotonValidator.h.

Definition at line 355 of file PhotonValidator.h.

Definition at line 353 of file PhotonValidator.h.

Definition at line 337 of file PhotonValidator.h.

Definition at line 339 of file PhotonValidator.h.

Definition at line 404 of file PhotonValidator.h.

Definition at line 257 of file PhotonValidator.h.

Definition at line 255 of file PhotonValidator.h.

Definition at line 484 of file PhotonValidator.h.

Definition at line 486 of file PhotonValidator.h.

Definition at line 319 of file PhotonValidator.h.

Definition at line 327 of file PhotonValidator.h.

Definition at line 329 of file PhotonValidator.h.

Definition at line 322 of file PhotonValidator.h.

Definition at line 324 of file PhotonValidator.h.

Definition at line 287 of file PhotonValidator.h.

Definition at line 285 of file PhotonValidator.h.

Definition at line 290 of file PhotonValidator.h.

Definition at line 317 of file PhotonValidator.h.

Definition at line 316 of file PhotonValidator.h.

Definition at line 263 of file PhotonValidator.h.

Definition at line 261 of file PhotonValidator.h.

Definition at line 491 of file PhotonValidator.h.

Definition at line 493 of file PhotonValidator.h.

Definition at line 248 of file PhotonValidator.h.

Definition at line 246 of file PhotonValidator.h.

Definition at line 477 of file PhotonValidator.h.

Definition at line 478 of file PhotonValidator.h.

Definition at line 269 of file PhotonValidator.h.

Definition at line 267 of file PhotonValidator.h.

Definition at line 497 of file PhotonValidator.h.

Definition at line 499 of file PhotonValidator.h.

Definition at line 275 of file PhotonValidator.h.

Definition at line 273 of file PhotonValidator.h.

Definition at line 503 of file PhotonValidator.h.

Definition at line 505 of file PhotonValidator.h.

Definition at line 320 of file PhotonValidator.h.

Definition at line 333 of file PhotonValidator.h.

Definition at line 426 of file PhotonValidator.h.

Definition at line 427 of file PhotonValidator.h.

Definition at line 230 of file PhotonValidator.h.

Definition at line 228 of file PhotonValidator.h.

Definition at line 460 of file PhotonValidator.h.

Definition at line 461 of file PhotonValidator.h.

Definition at line 236 of file PhotonValidator.h.

Definition at line 234 of file PhotonValidator.h.

Definition at line 465 of file PhotonValidator.h.

Definition at line 466 of file PhotonValidator.h.

Definition at line 224 of file PhotonValidator.h.

Definition at line 222 of file PhotonValidator.h.

Definition at line 457 of file PhotonValidator.h.

Definition at line 458 of file PhotonValidator.h.

Definition at line 292 of file PhotonValidator.h.

Definition at line 242 of file PhotonValidator.h.

Definition at line 240 of file PhotonValidator.h.

Definition at line 471 of file PhotonValidator.h.

Definition at line 473 of file PhotonValidator.h.

Definition at line 424 of file PhotonValidator.h.

Definition at line 178 of file PhotonValidator.h.

Definition at line 305 of file PhotonValidator.h.

Definition at line 303 of file PhotonValidator.h.

Definition at line 508 of file PhotonValidator.h.

Definition at line 304 of file PhotonValidator.h.

Definition at line 509 of file PhotonValidator.h.

Definition at line 308 of file PhotonValidator.h.

Definition at line 383 of file PhotonValidator.h.

Definition at line 384 of file PhotonValidator.h.

Definition at line 371 of file PhotonValidator.h.

Definition at line 376 of file PhotonValidator.h.

Definition at line 381 of file PhotonValidator.h.

Definition at line 368 of file PhotonValidator.h.

Definition at line 373 of file PhotonValidator.h.

Definition at line 378 of file PhotonValidator.h.

Definition at line 369 of file PhotonValidator.h.

Definition at line 374 of file PhotonValidator.h.

Definition at line 379 of file PhotonValidator.h.

Definition at line 370 of file PhotonValidator.h.

Definition at line 375 of file PhotonValidator.h.

Definition at line 380 of file PhotonValidator.h.

Definition at line 363 of file PhotonValidator.h.

Definition at line 365 of file PhotonValidator.h.

Definition at line 518 of file PhotonValidator.h.

Definition at line 364 of file PhotonValidator.h.

Definition at line 366 of file PhotonValidator.h.

Definition at line 517 of file PhotonValidator.h.

Definition at line 342 of file PhotonValidator.h.

Definition at line 516 of file PhotonValidator.h.

Definition at line 359 of file PhotonValidator.h.

Definition at line 348 of file PhotonValidator.h.

Definition at line 352 of file PhotonValidator.h.

Definition at line 336 of file PhotonValidator.h.

Definition at line 515 of file PhotonValidator.h.

Definition at line 403 of file PhotonValidator.h.

Definition at line 254 of file PhotonValidator.h.

Definition at line 483 of file PhotonValidator.h.

Definition at line 312 of file PhotonValidator.h.

Definition at line 513 of file PhotonValidator.h.

Definition at line 220 of file PhotonValidator.h.

Definition at line 279 of file PhotonValidator.h.

Definition at line 260 of file PhotonValidator.h.

Definition at line 490 of file PhotonValidator.h.

Definition at line 245 of file PhotonValidator.h.

Definition at line 455 of file PhotonValidator.h.

Definition at line 310 of file PhotonValidator.h.

Definition at line 199 of file PhotonValidator.h.

Definition at line 266 of file PhotonValidator.h.

Definition at line 496 of file PhotonValidator.h.

Definition at line 433 of file PhotonValidator.h.

Definition at line 434 of file PhotonValidator.h.

Numerator for efficiencies.

Definition at line 182 of file PhotonValidator.h.

Definition at line 183 of file PhotonValidator.h.

Definition at line 315 of file PhotonValidator.h.

Definition at line 510 of file PhotonValidator.h.

info per conversion

Definition at line 302 of file PhotonValidator.h.

Definition at line 437 of file PhotonValidator.h.

Definition at line 158 of file PhotonValidator.h.

Definition at line 166 of file PhotonValidator.h.

Definition at line 160 of file PhotonValidator.h.

Definition at line 272 of file PhotonValidator.h.

Definition at line 502 of file PhotonValidator.h.

Definition at line 198 of file PhotonValidator.h.

Definition at line 443 of file PhotonValidator.h.

Definition at line 444 of file PhotonValidator.h.

Definition at line 445 of file PhotonValidator.h.

Definition at line 446 of file PhotonValidator.h.

Definition at line 441 of file PhotonValidator.h.

Definition at line 442 of file PhotonValidator.h.

Definition at line 203 of file PhotonValidator.h.

Definition at line 204 of file PhotonValidator.h.

Definition at line 281 of file PhotonValidator.h.

Definition at line 283 of file PhotonValidator.h.

Definition at line 282 of file PhotonValidator.h.

Definition at line 296 of file PhotonValidator.h.

Definition at line 297 of file PhotonValidator.h.

Definition at line 313 of file PhotonValidator.h.

Definition at line 514 of file PhotonValidator.h.

Definition at line 218 of file PhotonValidator.h.

Definition at line 227 of file PhotonValidator.h.

Definition at line 453 of file PhotonValidator.h.

Definition at line 233 of file PhotonValidator.h.

Definition at line 454 of file PhotonValidator.h.

Definition at line 221 of file PhotonValidator.h.

Definition at line 452 of file PhotonValidator.h.

Definition at line 311 of file PhotonValidator.h.

Definition at line 194 of file PhotonValidator.h.

Definition at line 192 of file PhotonValidator.h.

Definition at line 449 of file PhotonValidator.h.

Definition at line 450 of file PhotonValidator.h.

Definition at line 439 of file PhotonValidator.h.

Definition at line 440 of file PhotonValidator.h.

Definition at line 215 of file PhotonValidator.h.

Definition at line 216 of file PhotonValidator.h.

Definition at line 208 of file PhotonValidator.h.

Definition at line 212 of file PhotonValidator.h.

Definition at line 209 of file PhotonValidator.h.

Definition at line 210 of file PhotonValidator.h.

Definition at line 211 of file PhotonValidator.h.

Definition at line 239 of file PhotonValidator.h.

Definition at line 470 of file PhotonValidator.h.

Definition at line 167 of file PhotonValidator.h.

Definition at line 185 of file PhotonValidator.h.

Definition at line 184 of file PhotonValidator.h.

Definition at line 187 of file PhotonValidator.h.

Definition at line 189 of file PhotonValidator.h.

Definition at line 190 of file PhotonValidator.h.

Definition at line 188 of file PhotonValidator.h.

Definition at line 186 of file PhotonValidator.h.

Definition at line 172 of file PhotonValidator.h.

Definition at line 173 of file PhotonValidator.h.

Definition at line 432 of file PhotonValidator.h.

Denominator for efficiencies.

Definition at line 177 of file PhotonValidator.h.

Definition at line 164 of file PhotonValidator.h.

Definition at line 162 of file PhotonValidator.h.

Definition at line 163 of file PhotonValidator.h.

Definition at line 161 of file PhotonValidator.h.

Definition at line 170 of file PhotonValidator.h.

Definition at line 169 of file PhotonValidator.h.

Definition at line 414 of file PhotonValidator.h.

Definition at line 512 of file PhotonValidator.h.

Definition at line 415 of file PhotonValidator.h.

Definition at line 421 of file PhotonValidator.h.

Definition at line 423 of file PhotonValidator.h.

Definition at line 200 of file PhotonValidator.h.

Definition at line 179 of file PhotonValidator.h.

Definition at line 180 of file PhotonValidator.h.

Definition at line 397 of file PhotonValidator.h.

Definition at line 398 of file PhotonValidator.h.

Definition at line 402 of file PhotonValidator.h.

Definition at line 429 of file PhotonValidator.h.

Definition at line 131 of file PhotonValidator.h.

Definition at line 127 of file PhotonValidator.h.

Definition at line 125 of file PhotonValidator.h.

Definition at line 126 of file PhotonValidator.h.

Definition at line 113 of file PhotonValidator.h.

Definition at line 101 of file PhotonValidator.h.

Definition at line 118 of file PhotonValidator.h.

double PhotonValidator::lip_ [private]

Definition at line 122 of file PhotonValidator.h.

double PhotonValidator::mcConvEta_ [private]

Definition at line 145 of file PhotonValidator.h.

double PhotonValidator::mcConvPhi_ [private]

Definition at line 144 of file PhotonValidator.h.

double PhotonValidator::mcConvR_ [private]

Definition at line 140 of file PhotonValidator.h.

double PhotonValidator::mcConvX_ [private]

Definition at line 143 of file PhotonValidator.h.

double PhotonValidator::mcConvY_ [private]

Definition at line 142 of file PhotonValidator.h.

double PhotonValidator::mcConvZ_ [private]

Definition at line 141 of file PhotonValidator.h.

double PhotonValidator::mcEta_ [private]

Definition at line 139 of file PhotonValidator.h.

double PhotonValidator::mcJetEta_ [private]

Definition at line 146 of file PhotonValidator.h.

double PhotonValidator::mcJetPhi_ [private]

Definition at line 147 of file PhotonValidator.h.

double PhotonValidator::mcPhi_ [private]

global variable for the MC photon

Definition at line 138 of file PhotonValidator.h.

Definition at line 116 of file PhotonValidator.h.

int PhotonValidator::nEntry_ [private]

Definition at line 78 of file PhotonValidator.h.

int PhotonValidator::nEvt_ [private]

Definition at line 77 of file PhotonValidator.h.

Definition at line 411 of file PhotonValidator.h.

Definition at line 511 of file PhotonValidator.h.

Definition at line 413 of file PhotonValidator.h.

Definition at line 86 of file PhotonValidator.h.

Definition at line 81 of file PhotonValidator.h.

Definition at line 82 of file PhotonValidator.h.

Definition at line 83 of file PhotonValidator.h.

Definition at line 84 of file PhotonValidator.h.

int PhotonValidator::nSimConv_[2] [private]

Definition at line 80 of file PhotonValidator.h.

int PhotonValidator::nSimPho_[2] [private]

Definition at line 79 of file PhotonValidator.h.

Definition at line 128 of file PhotonValidator.h.

Definition at line 417 of file PhotonValidator.h.

Definition at line 419 of file PhotonValidator.h.

Definition at line 390 of file PhotonValidator.h.

Definition at line 388 of file PhotonValidator.h.

Definition at line 391 of file PhotonValidator.h.

Definition at line 392 of file PhotonValidator.h.

Definition at line 393 of file PhotonValidator.h.

Definition at line 344 of file PhotonValidator.h.

Definition at line 346 of file PhotonValidator.h.

Definition at line 356 of file PhotonValidator.h.

Definition at line 354 of file PhotonValidator.h.

Definition at line 338 of file PhotonValidator.h.

Definition at line 340 of file PhotonValidator.h.

Definition at line 406 of file PhotonValidator.h.

Definition at line 405 of file PhotonValidator.h.

Definition at line 258 of file PhotonValidator.h.

Definition at line 256 of file PhotonValidator.h.

Definition at line 485 of file PhotonValidator.h.

Definition at line 487 of file PhotonValidator.h.

Definition at line 328 of file PhotonValidator.h.

Definition at line 330 of file PhotonValidator.h.

Definition at line 323 of file PhotonValidator.h.

Definition at line 325 of file PhotonValidator.h.

Definition at line 288 of file PhotonValidator.h.

Definition at line 286 of file PhotonValidator.h.

Definition at line 291 of file PhotonValidator.h.

Definition at line 306 of file PhotonValidator.h.

Definition at line 264 of file PhotonValidator.h.

Definition at line 262 of file PhotonValidator.h.

Definition at line 492 of file PhotonValidator.h.

Definition at line 494 of file PhotonValidator.h.

Definition at line 249 of file PhotonValidator.h.

Definition at line 247 of file PhotonValidator.h.

Definition at line 479 of file PhotonValidator.h.

Definition at line 480 of file PhotonValidator.h.

Definition at line 270 of file PhotonValidator.h.

Definition at line 268 of file PhotonValidator.h.

Definition at line 498 of file PhotonValidator.h.

Definition at line 500 of file PhotonValidator.h.

Definition at line 410 of file PhotonValidator.h.

Definition at line 412 of file PhotonValidator.h.

Definition at line 276 of file PhotonValidator.h.

Definition at line 274 of file PhotonValidator.h.

Definition at line 504 of file PhotonValidator.h.

Definition at line 506 of file PhotonValidator.h.

Definition at line 334 of file PhotonValidator.h.

Definition at line 231 of file PhotonValidator.h.

Definition at line 229 of file PhotonValidator.h.

Definition at line 462 of file PhotonValidator.h.

Definition at line 463 of file PhotonValidator.h.

Definition at line 237 of file PhotonValidator.h.

Definition at line 235 of file PhotonValidator.h.

Definition at line 467 of file PhotonValidator.h.

Definition at line 468 of file PhotonValidator.h.

Definition at line 225 of file PhotonValidator.h.

Definition at line 223 of file PhotonValidator.h.

Definition at line 293 of file PhotonValidator.h.

Definition at line 243 of file PhotonValidator.h.

Definition at line 241 of file PhotonValidator.h.

Definition at line 472 of file PhotonValidator.h.

Definition at line 474 of file PhotonValidator.h.

Definition at line 425 of file PhotonValidator.h.

Definition at line 88 of file PhotonValidator.h.

std::string PhotonValidator::photonCollection_ [private]

Definition at line 93 of file PhotonValidator.h.

Definition at line 92 of file PhotonValidator.h.

double PhotonValidator::recMaxPt_ [private]

Definition at line 157 of file PhotonValidator.h.

double PhotonValidator::recMinPt_ [private]

Global variables for reco Photon.

Definition at line 156 of file PhotonValidator.h.

double PhotonValidator::simMaxPt_ [private]

Definition at line 153 of file PhotonValidator.h.

double PhotonValidator::simMinPt_ [private]

Definition at line 152 of file PhotonValidator.h.

Definition at line 89 of file PhotonValidator.h.

Definition at line 90 of file PhotonValidator.h.

Definition at line 149 of file PhotonValidator.h.

Definition at line 74 of file PhotonValidator.h.

Definition at line 109 of file PhotonValidator.h.

Definition at line 110 of file PhotonValidator.h.

Definition at line 119 of file PhotonValidator.h.

Definition at line 120 of file PhotonValidator.h.

double PhotonValidator::trkPtLow_ [private]

Definition at line 121 of file PhotonValidator.h.

Definition at line 129 of file PhotonValidator.h.

Definition at line 76 of file PhotonValidator.h.