Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-23 03:25:43

0001 #include <iostream>
0002 //
0003 #include "FWCore/ServiceRegistry/interface/Service.h"
0004 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0005 //
0006 #include "Validation/RecoEgamma/plugins/TkConvValidator.h"
0007 
0008 //
0009 #include "FWCore/Framework/interface/MakerMacros.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include "FWCore/Utilities/interface/Exception.h"
0012 //
0013 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
0014 #include "SimDataFormats/Track/interface/SimTrack.h"
0015 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0016 #include "SimDataFormats/Vertex/interface/SimVertex.h"
0017 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
0018 //
0019 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h"
0020 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
0021 #include "SimDataFormats/TrackingAnalysis/interface/TrackingVertexContainer.h"
0022 //
0023 #include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h"
0024 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0025 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0026 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0027 //
0028 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
0029 #include "TrackingTools/PatternTools/interface/TwoTrackMinimumDistance.h"
0030 #include "TrackingTools/TransientTrack/interface/TrackTransientTrack.h"
0031 //
0032 #include "CLHEP/Units/GlobalPhysicalConstants.h"
0033 #include "CommonTools/Statistics/interface/ChiSquaredProbability.h"
0034 //
0035 #include "MagneticField/Engine/interface/MagneticField.h"
0036 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0037 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0038 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0039 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
0040 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0041 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
0042 #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
0043 
0044 //
0045 #include "DataFormats/Common/interface/Handle.h"
0046 #include "DataFormats/TrackReco/interface/Track.h"
0047 #include "DataFormats/TrackReco/interface/TrackExtra.h"
0048 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0049 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
0050 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0051 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
0052 #include "DataFormats/TrackCandidate/interface/TrackCandidateCollection.h"
0053 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0054 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
0055 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
0056 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
0057 #include "DataFormats/CaloRecHit/interface/CaloCluster.h"
0058 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
0059 #include "DataFormats/DetId/interface/DetId.h"
0060 #include "DataFormats/JetReco/interface/GenJetCollection.h"
0061 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0062 #include "DataFormats/GeometrySurface/interface/BoundCylinder.h"
0063 #include "DataFormats/GeometrySurface/interface/BoundDisk.h"
0064 #include "DataFormats/GeometrySurface/interface/SimpleCylinderBounds.h"
0065 #include "DataFormats/GeometrySurface/interface/SimpleDiskBounds.h"
0066 #include "DataFormats/Math/interface/deltaPhi.h"
0067 
0068 //
0069 #include "RecoEgamma/EgammaMCTools/interface/PhotonMCTruthFinder.h"
0070 #include "RecoEgamma/EgammaMCTools/interface/PhotonMCTruth.h"
0071 #include "RecoEgamma/EgammaMCTools/interface/ElectronMCTruth.h"
0072 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h"
0073 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0074 #include "Geometry/Records/interface/CaloTopologyRecord.h"
0075 
0076 //
0077 //
0078 #include "TFile.h"
0079 #include "TH1.h"
0080 #include "TH2.h"
0081 #include "TTree.h"
0082 #include "TVector3.h"
0083 #include "TProfile.h"
0084 //
0085 /** \class TkConvValidator
0086  **
0087  **
0088  **  $Id: TkConvValidator
0089  **  \author N.Marinelli - Univ. of Notre Dame
0090  **
0091  ***/
0092 
0093 using namespace std;
0094 
0095 TkConvValidator::TkConvValidator(const edm::ParameterSet& pset)
0096     : magneticFieldToken_{esConsumes<edm::Transition::BeginRun>()},
0097       caloGeometryToken_{esConsumes()},
0098       transientTrackBuilderToken_{esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))},
0099       trackerGeometryToken_{esConsumes()} {
0100   fName_ = pset.getUntrackedParameter<std::string>("Name");
0101   verbosity_ = pset.getUntrackedParameter<int>("Verbosity");
0102   parameters_ = pset;
0103 
0104   photonCollectionProducer_ = pset.getParameter<std::string>("phoProducer");
0105   photonCollection_ = pset.getParameter<std::string>("photonCollection");
0106   photonCollectionPr_Token_ =
0107       consumes<reco::PhotonCollection>(edm::InputTag(photonCollectionProducer_, photonCollection_));
0108 
0109   conversionCollectionProducer_ = pset.getParameter<std::string>("convProducer");
0110   conversionCollection_ = pset.getParameter<std::string>("conversionCollection");
0111   conversionCollectionPr_Token_ =
0112       consumes<reco::ConversionCollection>(edm::InputTag(conversionCollectionProducer_, conversionCollection_));
0113 
0114   // conversionTrackProducer_ = pset.getParameter<std::string>("trackProducer");
0115   dqmpath_ = pset.getParameter<std::string>("dqmpath");
0116   minPhoEtCut_ = pset.getParameter<double>("minPhoEtCut");
0117   generalTracksOnly_ = pset.getParameter<bool>("generalTracksOnly");
0118   arbitratedMerged_ = pset.getParameter<bool>("arbitratedMerged");
0119   arbitratedEcalSeeded_ = pset.getParameter<bool>("arbitratedEcalSeeded");
0120   ecalalgotracks_ = pset.getParameter<bool>("ecalalgotracks");
0121   highPurity_ = pset.getParameter<bool>("highPurity");
0122   minProb_ = pset.getParameter<double>("minProb");
0123   maxHitsBeforeVtx_ = pset.getParameter<uint>("maxHitsBeforeVtx");
0124   minLxy_ = pset.getParameter<double>("minLxy");
0125   isRunCentrally_ = pset.getParameter<bool>("isRunCentrally");
0126 
0127   offline_pvToken_ = consumes<reco::VertexCollection>(
0128       pset.getUntrackedParameter<edm::InputTag>("offlinePV", edm::InputTag("offlinePrimaryVertices")));
0129   beamspotToken_ =
0130       consumes<reco::BeamSpot>(pset.getUntrackedParameter<edm::InputTag>("beamspot", edm::InputTag("offlineBeamSpot")));
0131   g4_simTk_Token_ = consumes<edm::SimTrackContainer>(pset.getParameter<edm::InputTag>("simTracks"));
0132   g4_simVtx_Token_ = consumes<edm::SimVertexContainer>(pset.getParameter<edm::InputTag>("simTracks"));
0133 
0134   tpSelForEff_Token_ = consumes<TrackingParticleRefVector>(edm::InputTag("tpSelecForEfficiency"));
0135   tpSelForFake_Token_ = consumes<TrackingParticleRefVector>(edm::InputTag("tpSelecForFakeRate"));
0136   //hepMC_Token_ = consumes<edm::HepMCProduct>(edm::InputTag("generatorSmeared"));
0137   //genjets_Token_ = consumes<reco::GenJetCollection>(
0138   //    edm::InputTag("ak4GenJets"));
0139 
0140   trackAssociator_Token_ =
0141       consumes<reco::TrackToTrackingParticleAssociator>(edm::InputTag("trackAssociatorByHitsForConversionValidation"));
0142 }
0143 
0144 TkConvValidator::~TkConvValidator() {}
0145 
0146 void TkConvValidator::bookHistograms(DQMStore::IBooker& iBooker, edm::Run const& run, edm::EventSetup const&) {
0147   nEvt_ = 0;
0148   nEntry_ = 0;
0149   nRecConv_ = 0;
0150   nRecConvAss_ = 0;
0151   nRecConvAssWithEcal_ = 0;
0152 
0153   nInvalidPCA_ = 0;
0154 
0155   dbe_ = nullptr;
0156   dbe_ = edm::Service<DQMStore>().operator->();
0157 
0158   double etMin = parameters_.getParameter<double>("etMin");
0159   double etMax = parameters_.getParameter<double>("etMax");
0160   int etBin = parameters_.getParameter<int>("etBin");
0161 
0162   double resMin = parameters_.getParameter<double>("resMin");
0163   double resMax = parameters_.getParameter<double>("resMax");
0164   int resBin = parameters_.getParameter<int>("resBin");
0165 
0166   double etaMin = parameters_.getParameter<double>("etaMin");
0167   double etaMax = parameters_.getParameter<double>("etaMax");
0168   int etaBin = parameters_.getParameter<int>("etaBin");
0169   int etaBin2 = parameters_.getParameter<int>("etaBin2");
0170 
0171   double phiMin = parameters_.getParameter<double>("phiMin");
0172   double phiMax = parameters_.getParameter<double>("phiMax");
0173   int phiBin = parameters_.getParameter<int>("phiBin");
0174 
0175   double rMin = parameters_.getParameter<double>("rMin");
0176   double rMax = parameters_.getParameter<double>("rMax");
0177   int rBin = parameters_.getParameter<int>("rBin");
0178 
0179   double zMin = parameters_.getParameter<double>("zMin");
0180   double zMax = parameters_.getParameter<double>("zMax");
0181   int zBin = parameters_.getParameter<int>("zBin");
0182 
0183   double dPhiTracksMin = parameters_.getParameter<double>("dPhiTracksMin");
0184   double dPhiTracksMax = parameters_.getParameter<double>("dPhiTracksMax");
0185   int dPhiTracksBin = parameters_.getParameter<int>("dPhiTracksBin");
0186 
0187   double eoverpMin = parameters_.getParameter<double>("eoverpMin");
0188   double eoverpMax = parameters_.getParameter<double>("eoverpMax");
0189   int eoverpBin = parameters_.getParameter<int>("eoverpBin");
0190 
0191   //  double dEtaTracksMin = parameters_.getParameter<double>("dEtaTracksMin");  // unused
0192   //  double dEtaTracksMax = parameters_.getParameter<double>("dEtaTracksMax"); // unused
0193   //  int    dEtaTracksBin = parameters_.getParameter<int>("dEtaTracksBin");  // unused
0194 
0195   double dCotTracksMin = parameters_.getParameter<double>("dCotTracksMin");
0196   double dCotTracksMax = parameters_.getParameter<double>("dCotTracksMax");
0197   int dCotTracksBin = parameters_.getParameter<int>("dCotTracksBin");
0198 
0199   double chi2Min = parameters_.getParameter<double>("chi2Min");
0200   double chi2Max = parameters_.getParameter<double>("chi2Max");
0201 
0202   double rMinForXray = parameters_.getParameter<double>("rMinForXray");
0203   double rMaxForXray = parameters_.getParameter<double>("rMaxForXray");
0204   int rBinForXray = parameters_.getParameter<int>("rBinForXray");
0205   double zMinForXray = parameters_.getParameter<double>("zMinForXray");
0206   double zMaxForXray = parameters_.getParameter<double>("zMaxForXray");
0207   int zBinForXray = parameters_.getParameter<int>("zBinForXray");
0208   int zBin2ForXray = parameters_.getParameter<int>("zBin2ForXray");
0209 
0210   minPhoPtForEffic = parameters_.getParameter<double>("minPhoPtForEffic");
0211   maxPhoEtaForEffic = parameters_.getParameter<double>("maxPhoEtaForEffic");
0212   maxPhoZForEffic = parameters_.getParameter<double>("maxPhoZForEffic");
0213   maxPhoRForEffic = parameters_.getParameter<double>("maxPhoRForEffic");
0214   minPhoPtForPurity = parameters_.getParameter<double>("minPhoPtForPurity");
0215   maxPhoEtaForPurity = parameters_.getParameter<double>("maxPhoEtaForPurity");
0216   maxPhoZForPurity = parameters_.getParameter<double>("maxPhoZForPurity");
0217   maxPhoRForPurity = parameters_.getParameter<double>("maxPhoRForPurity");
0218 
0219   if (dbe_) {
0220     //// All MC photons
0221     // SC from reco photons
0222 
0223     //TString simfolder = TString(
0224     std::string simpath = dqmpath_ + "SimulationInfo";
0225     iBooker.setCurrentFolder(simpath);
0226     //
0227     // simulation information about conversions
0228     /// Histograms for efficiencies
0229     std::string histname = "nOfSimConversions";
0230     h_nSimConv_[0] = iBooker.book1D(histname, "# of Sim conversions per event ", 20, -0.5, 19.5);
0231     /// Denominators
0232     histname = "h_AllSimConvEta";
0233     h_AllSimConv_[0] = iBooker.book1D(histname, " All conversions: simulated #eta", etaBin2, etaMin, etaMax);
0234     histname = "h_AllSimConvPhi";
0235     h_AllSimConv_[1] = iBooker.book1D(histname, " All conversions: simulated #phi", phiBin, phiMin, phiMax);
0236     histname = "h_AllSimConvR";
0237     h_AllSimConv_[2] = iBooker.book1D(histname, " All conversions: simulated R", rBin, rMin, rMax);
0238     histname = "h_AllSimConvZ";
0239     h_AllSimConv_[3] = iBooker.book1D(histname, " All conversions: simulated Z", zBin, zMin, zMax);
0240     histname = "h_AllSimConvEt";
0241     h_AllSimConv_[4] = iBooker.book1D(histname, " All conversions: simulated Et", etBin, etMin, etMax);
0242     //
0243     histname = "nOfVisSimConversions";
0244     h_nSimConv_[1] = iBooker.book1D(histname, "# of Sim conversions per event ", 20, -0.5, 19.5);
0245     histname = "h_VisSimConvEta";
0246     h_VisSimConv_[0] = iBooker.book1D(histname, " All vis conversions: simulated #eta", etaBin2, etaMin, etaMax);
0247     histname = "h_VisSimConvPhi";
0248     h_VisSimConv_[1] = iBooker.book1D(histname, " All vis conversions: simulated #phi", phiBin, phiMin, phiMax);
0249     histname = "h_VisSimConvR";
0250     h_VisSimConv_[2] = iBooker.book1D(histname, " All vis conversions: simulated R", rBin, rMin, rMax);
0251     histname = "h_VisSimConvZ";
0252     h_VisSimConv_[3] = iBooker.book1D(histname, " All vis conversions: simulated Z", zBin, zMin, zMax);
0253     histname = "h_VisSimConvEt";
0254     h_VisSimConv_[4] = iBooker.book1D(histname, " All vis conversions: simulated Et", etBin, etMin, etMax);
0255 
0256     //
0257     histname = "h_SimConvTwoMTracksEta";
0258     h_SimConvTwoMTracks_[0] = iBooker.book1D(
0259         histname, " All vis conversions with 2 reco-matching tracks: simulated #eta", etaBin2, etaMin, etaMax);
0260     histname = "h_SimConvTwoMTracksPhi";
0261     h_SimConvTwoMTracks_[1] = iBooker.book1D(
0262         histname, " All vis conversions with 2 reco-matching tracks: simulated #phi", phiBin, phiMin, phiMax);
0263     histname = "h_SimConvTwoMTracksR";
0264     h_SimConvTwoMTracks_[2] =
0265         iBooker.book1D(histname, " All vis conversions with 2 reco-matching tracks: simulated R", rBin, rMin, rMax);
0266     histname = "h_SimConvTwoMTracksZ";
0267     h_SimConvTwoMTracks_[3] =
0268         iBooker.book1D(histname, " All vis conversions with 2 reco-matching tracks: simulated Z", zBin, zMin, zMax);
0269     histname = "h_SimConvTwoMTracksEt";
0270     h_SimConvTwoMTracks_[4] =
0271         iBooker.book1D(histname, " All vis conversions with 2 reco-matching tracks: simulated Et", etBin, etMin, etMax);
0272     //
0273     histname = "h_SimConvTwoTracksEta";
0274     h_SimConvTwoTracks_[0] =
0275         iBooker.book1D(histname, " All vis conversions with 2 reco  tracks: simulated #eta", etaBin2, etaMin, etaMax);
0276     histname = "h_SimConvTwoTracksPhi";
0277     h_SimConvTwoTracks_[1] =
0278         iBooker.book1D(histname, " All vis conversions with 2 reco tracks: simulated #phi", phiBin, phiMin, phiMax);
0279     histname = "h_SimConvTwoTracksR";
0280     h_SimConvTwoTracks_[2] =
0281         iBooker.book1D(histname, " All vis conversions with 2 reco tracks: simulated R", rBin, rMin, rMax);
0282     histname = "h_SimConvTwoTracksZ";
0283     h_SimConvTwoTracks_[3] =
0284         iBooker.book1D(histname, " All vis conversions with 2 reco tracks: simulated Z", zBin, zMin, zMax);
0285     histname = "h_SimConvTwoTracksEt";
0286     h_SimConvTwoTracks_[4] =
0287         iBooker.book1D(histname, " All vis conversions with 2 reco tracks: simulated Et", etBin, etMin, etMax);
0288     //
0289     histname = "h_SimConvTwoMTracksEtaAndVtxPGT0";
0290     h_SimConvTwoMTracksAndVtxPGT0_[0] = iBooker.book1D(
0291         histname, " All vis conversions with 2 reco-matching tracks + vertex: simulated #eta", etaBin2, etaMin, etaMax);
0292     histname = "h_SimConvTwoMTracksPhiAndVtxPGT0";
0293     h_SimConvTwoMTracksAndVtxPGT0_[1] = iBooker.book1D(
0294         histname, " All vis conversions with 2 reco-matching tracks + vertex: simulated #phi", phiBin, phiMin, phiMax);
0295     histname = "h_SimConvTwoMTracksRAndVtxPGT0";
0296     h_SimConvTwoMTracksAndVtxPGT0_[2] = iBooker.book1D(
0297         histname, " All vis conversions with 2 reco-matching tracks + vertex: simulated R", rBin, rMin, rMax);
0298     histname = "h_SimConvTwoMTracksZAndVtxPGT0";
0299     h_SimConvTwoMTracksAndVtxPGT0_[3] = iBooker.book1D(
0300         histname, " All vis conversions with 2 reco-matching tracks + vertex: simulated Z", zBin, zMin, zMax);
0301     histname = "h_SimConvTwoMTracksEtAndVtxPGT0";
0302     h_SimConvTwoMTracksAndVtxPGT0_[4] = iBooker.book1D(
0303         histname, " All vis conversions with 2 reco-matching tracks + vertex: simulated Et", etBin, etMin, etMax);
0304 
0305     //
0306     histname = "h_SimConvTwoMTracksEtaAndVtxPGT0005";
0307     h_SimConvTwoMTracksAndVtxPGT0005_[0] = iBooker.book1D(
0308         histname, " All vis conversions with 2 reco-matching tracks + vertex: simulated #eta", etaBin2, etaMin, etaMax);
0309     histname = "h_SimConvTwoMTracksPhiAndVtxPGT0005";
0310     h_SimConvTwoMTracksAndVtxPGT0005_[1] = iBooker.book1D(
0311         histname, " All vis conversions with 2 reco-matching tracks + vertex: simulated #phi", phiBin, phiMin, phiMax);
0312     histname = "h_SimConvTwoMTracksRAndVtxPGT0005";
0313     h_SimConvTwoMTracksAndVtxPGT0005_[2] = iBooker.book1D(
0314         histname, " All vis conversions with 2 reco-matching tracks + vertex: simulated R", rBin, rMin, rMax);
0315     histname = "h_SimConvTwoMTracksZAndVtxPGT0005";
0316     h_SimConvTwoMTracksAndVtxPGT0005_[3] = iBooker.book1D(
0317         histname, " All vis conversions with 2 reco-matching tracks + vertex: simulated Z", zBin, zMin, zMax);
0318     histname = "h_SimConvTwoMTracksEtAndVtxPGT0005";
0319     h_SimConvTwoMTracksAndVtxPGT0005_[4] = iBooker.book1D(
0320         histname, " All vis conversions with 2 reco-matching tracks + vertex: simulated Et", etBin, etMin, etMax);
0321 
0322     histname = "h_SimRecConvTwoMTracksEta";
0323     h_SimRecConvTwoMTracks_[0] = iBooker.book1D(
0324         histname, " All vis conversions with 2 reco-matching tracks: simulated #eta", etaBin2, etaMin, etaMax);
0325     histname = "h_SimRecConvTwoMTracksPhi";
0326     h_SimRecConvTwoMTracks_[1] = iBooker.book1D(
0327         histname, " All vis conversions with 2 reco-matching tracks: simulated #phi", phiBin, phiMin, phiMax);
0328     histname = "h_SimRecConvTwoMTracksR";
0329     h_SimRecConvTwoMTracks_[2] =
0330         iBooker.book1D(histname, " All vis conversions with 2 reco-matching tracks: simulated R", rBin, rMin, rMax);
0331     histname = "h_SimRecConvTwoMTracksZ";
0332     h_SimRecConvTwoMTracks_[3] =
0333         iBooker.book1D(histname, " All vis conversions with 2 reco-matching tracks: simulated Z", zBin, zMin, zMax);
0334     histname = "h_SimRecConvTwoMTracksEt";
0335     h_SimRecConvTwoMTracks_[4] =
0336         iBooker.book1D(histname, " All vis conversions with 2 reco-matching tracks: simulated Et", etBin, etMin, etMax);
0337     //
0338 
0339     h_SimConvEtaPix_[0] = iBooker.book1D("simConvEtaPix", " sim converted Photon Eta: Pix ", etaBin, etaMin, etaMax);
0340     h_simTkPt_ = iBooker.book1D("simTkPt", "Sim conversion tracks pt ", etBin * 3, 0., etMax);
0341     h_simTkEta_ = iBooker.book1D("simTkEta", "Sim conversion tracks eta ", etaBin, etaMin, etaMax);
0342 
0343     h_simConvVtxRvsZ_[0] = iBooker.book2D("simConvVtxRvsZAll",
0344                                           " Photon Sim conversion vtx position",
0345                                           zBinForXray,
0346                                           zMinForXray,
0347                                           zMaxForXray,
0348                                           rBinForXray,
0349                                           rMinForXray,
0350                                           rMaxForXray);
0351     h_simConvVtxRvsZ_[1] = iBooker.book2D("simConvVtxRvsZBarrel",
0352                                           " Photon Sim conversion vtx position",
0353                                           zBinForXray,
0354                                           zMinForXray,
0355                                           zMaxForXray,
0356                                           rBinForXray,
0357                                           rMinForXray,
0358                                           rMaxForXray);
0359     h_simConvVtxRvsZ_[2] = iBooker.book2D("simConvVtxRvsZEndcap",
0360                                           " Photon Sim conversion vtx position",
0361                                           zBin2ForXray,
0362                                           zMinForXray,
0363                                           zMaxForXray,
0364                                           rBinForXray,
0365                                           rMinForXray,
0366                                           rMaxForXray);
0367     h_simConvVtxRvsZ_[3] = iBooker.book2D("simConvVtxRvsZBarrel2",
0368                                           " Photon Sim conversion vtx position when reco R<4cm",
0369                                           zBinForXray,
0370                                           zMinForXray,
0371                                           zMaxForXray,
0372                                           rBinForXray,
0373                                           rMinForXray,
0374                                           rMaxForXray);
0375     h_simConvVtxYvsX_ = iBooker.book2D(
0376         "simConvVtxYvsXTrkBarrel", " Photon Sim conversion vtx position, (x,y) eta<1 ", 100, -80., 80., 100, -80., 80.);
0377 
0378     std::string convpath = dqmpath_ + "ConversionInfo";
0379     iBooker.setCurrentFolder(convpath);
0380 
0381     histname = "nConv";
0382     h_nConv_[0][0] = iBooker.book1D(
0383         histname + "All", "Number Of Conversions per isolated candidates per events: All Ecal  ", 10, -0.5, 9.5);
0384     h_nConv_[0][1] = iBooker.book1D(
0385         histname + "Barrel", "Number Of Conversions per isolated candidates per events: Ecal Barrel  ", 10, -0.5, 9.5);
0386     h_nConv_[0][2] = iBooker.book1D(
0387         histname + "Endcap", "Number Of Conversions per isolated candidates per events: Ecal Endcap ", 10, -0.5, 9.5);
0388     h_nConv_[1][0] = iBooker.book1D(histname + "All_Ass",
0389                                     "Number Of associated Conversions per isolated candidates per events: All Ecal  ",
0390                                     10,
0391                                     -0.5,
0392                                     9.5);
0393 
0394     h_convEta_[0][0] = iBooker.book1D("convEta", " converted Photon  Eta ", etaBin, etaMin, etaMax);
0395     h_convEtaMatchSC_[0][0] =
0396         iBooker.book1D("convEtaMatchSC", " converted Photon  Eta when SC is matched ", etaBin, etaMin, etaMax);
0397     h_convEta2_[0][0] = iBooker.book1D("convEta2", " converted Photon  Eta ", etaBin2, etaMin, etaMax);
0398     h_convPhi_[0][0] = iBooker.book1D("convPhi", " converted Photon  Phi ", phiBin, phiMin, phiMax);
0399     h_convR_[0][0] = iBooker.book1D("convR", " converted photon R", rBin, rMin, rMax);
0400     h_convZ_[0][0] = iBooker.book1D("convZ", " converted photon Z", zBin, zMin, zMax);
0401     h_convPt_[0][0] = iBooker.book1D("convPt", "  conversions Transverse Energy: all eta ", etBin, etMin, etMax);
0402 
0403     h_convEta_[1][0] = iBooker.book1D("convEtaAss2", " Matched converted Photon  Eta ", etaBin2, etaMin, etaMax);
0404     h_convEta_[1][1] = iBooker.book1D("convEtaAss", " Matched converted Photon  Eta ", etaBin, etaMin, etaMax);
0405     h_convEtaMatchSC_[1][0] =
0406         iBooker.book1D("convEtaMatchSCAss", " converted Photon  Eta when SC is matched ", etaBin, etaMin, etaMax);
0407     h_convPhi_[1][0] = iBooker.book1D("convPhiAss", " Matched converted Photon  Phi ", phiBin, phiMin, phiMax);
0408     h_convR_[1][0] = iBooker.book1D("convRAss", " Matched converted photon R", rBin, rMin, rMax);
0409     h_convZ_[1][0] = iBooker.book1D("convZAss", " Matched converted photon Z", zBin, zMin, zMax);
0410     h_convPt_[1][0] =
0411         iBooker.book1D("convPtAss", "Matched conversions Transverse Energy: all eta ", etBin, etMin, etMax);
0412 
0413     h_convEta_[2][0] = iBooker.book1D("convEtaFake2", " Fake converted Photon  Eta ", etaBin2, etaMin, etaMax);
0414     h_convEta_[2][1] = iBooker.book1D("convEtaFake", " Fake converted Photon  Eta ", etaBin, etaMin, etaMax);
0415     h_convEtaMatchSC_[2][0] =
0416         iBooker.book1D("convEtaMatchSCFake", " converted Photon  Eta when SC is matched ", etaBin, etaMin, etaMax);
0417     h_convPhi_[2][0] = iBooker.book1D("convPhiFake", " Fake converted Photon  Phi ", phiBin, phiMin, phiMax);
0418     h_convR_[2][0] = iBooker.book1D("convRFake", " Fake converted photon R", rBin, rMin, rMax);
0419     h_convZ_[2][0] = iBooker.book1D("convZFake", " Fake converted photon Z", zBin, zMin, zMax);
0420     h_convPt_[2][0] = iBooker.book1D("convPtFake", "Fake conversions Transverse Energy: all eta ", etBin, etMin, etMax);
0421 
0422     h_convRplot_ = iBooker.book1D("convRplot", " converted photon R", 600, 0., 120.);
0423     h_convZplot_ = iBooker.book1D("convZplot", " converted photon Z", 320, -160., 160.);
0424 
0425     histname = "convSCdPhi";
0426     h_convSCdPhi_[0][0] = iBooker.book1D(histname + "All", "dPhi between SC and conversion", 100, -0.1, 0.1);
0427     h_convSCdPhi_[0][1] =
0428         iBooker.book1D(histname + "Barrel", " dPhi between SC and conversion: Barrel", 100, -0.1, 0.1);
0429     h_convSCdPhi_[0][2] =
0430         iBooker.book1D(histname + "Endcap", " dPhi between SC and conversion: Endcap", 100, -0.1, 0.1);
0431     h_convSCdPhi_[1][0] = iBooker.book1D(histname + "All_Ass", "dPhi between SC and conversion", 100, -0.1, 0.1);
0432     h_convSCdPhi_[1][1] =
0433         iBooker.book1D(histname + "Barrel_Ass", " dPhi between SC and conversion: Barrel", 100, -0.1, 0.1);
0434     h_convSCdPhi_[1][2] =
0435         iBooker.book1D(histname + "Endcap_Ass", " dPhi between SC and conversion: Endcap", 100, -0.1, 0.1);
0436     h_convSCdPhi_[2][0] = iBooker.book1D(histname + "All_Fakes", "dPhi between SC and conversion", 100, -0.1, 0.1);
0437     h_convSCdPhi_[2][1] =
0438         iBooker.book1D(histname + "Barrel_Fakes", " dPhi between SC and conversion: Barrel", 100, -0.1, 0.1);
0439     h_convSCdPhi_[2][2] =
0440         iBooker.book1D(histname + "Endcap_Fakes", " dPhi between SC and conversion: Endcap", 100, -0.1, 0.1);
0441     histname = "convSCdEta";
0442     h_convSCdEta_[0][0] = iBooker.book1D(histname + "All", " dEta between SC and conversion", 100, -0.1, 0.1);
0443     h_convSCdEta_[0][1] =
0444         iBooker.book1D(histname + "Barrel", " dEta between SC and conversion: Barrel", 100, -0.1, 0.1);
0445     h_convSCdEta_[0][2] =
0446         iBooker.book1D(histname + "Endcap", " dEta between SC and conversion: Endcap", 100, -0.1, 0.1);
0447     h_convSCdEta_[1][0] = iBooker.book1D(histname + "All_Ass", " dEta between SC and conversion", 100, -0.1, 0.1);
0448     h_convSCdEta_[1][1] =
0449         iBooker.book1D(histname + "Barrel_Ass", " dEta between SC and conversion: Barrel", 100, -0.1, 0.1);
0450     h_convSCdEta_[1][2] =
0451         iBooker.book1D(histname + "Endcap_Ass", " dEta between SC and conversion: Endcap", 100, -0.1, 0.1);
0452     h_convSCdEta_[2][0] = iBooker.book1D(histname + "All_Fakes", " dEta between SC and conversion", 100, -0.1, 0.1);
0453     h_convSCdEta_[2][1] =
0454         iBooker.book1D(histname + "Barrel_Fakes", " dEta between SC and conversion: Barrel", 100, -0.1, 0.1);
0455     h_convSCdEta_[2][2] =
0456         iBooker.book1D(histname + "Endcap_Fakes", " dEta between SC and conversion: Endcap", 100, -0.1, 0.1);
0457 
0458     histname = "convPtRes";
0459     h_convPtRes_[0] = iBooker.book1D(histname + "All", " Conversion Pt rec/true : All ecal ", resBin, resMin, resMax);
0460     h_convPtRes_[1] = iBooker.book1D(histname + "Barrel", " Conversion Pt rec/true : Barrel ", resBin, resMin, resMax);
0461     h_convPtRes_[2] = iBooker.book1D(histname + "Endcap", " Conversion Pt rec/true : Endcap ", resBin, resMin, resMax);
0462 
0463     histname = "hInvMass";
0464     h_invMass_[0][0] = iBooker.book1D(
0465         histname + "All_AllTracks", " Photons:Tracks from conversion: Pair invariant mass: all Ecal ", 100, 0., 1.5);
0466     h_invMass_[0][1] = iBooker.book1D(histname + "Barrel_AllTracks",
0467                                       " Photons:Tracks from conversion: Pair invariant mass: Barrel Ecal ",
0468                                       100,
0469                                       0.,
0470                                       1.5);
0471     h_invMass_[0][2] = iBooker.book1D(histname + "Endcap_AllTracks",
0472                                       " Photons:Tracks from conversion: Pair invariant mass: Endcap Ecal ",
0473                                       100,
0474                                       0.,
0475                                       1.5);
0476     //
0477     h_invMass_[1][0] = iBooker.book1D(
0478         histname + "All_AssTracks", " Photons:Tracks from conversion: Pair invariant mass: all Ecal ", 100, 0., 1.5);
0479     h_invMass_[1][1] = iBooker.book1D(histname + "Barrel_AssTracks",
0480                                       " Photons:Tracks from conversion: Pair invariant mass: Barrel Ecal ",
0481                                       100,
0482                                       0.,
0483                                       1.5);
0484     h_invMass_[1][2] = iBooker.book1D(histname + "Endcap_AssTracks",
0485                                       " Photons:Tracks from conversion: Pair invariant mass: Endcap Ecal ",
0486                                       100,
0487                                       0.,
0488                                       1.5);
0489     //
0490     h_invMass_[2][0] = iBooker.book1D(
0491         histname + "All_FakeTracks", " Photons:Tracks from conversion: Pair invariant mass: all Ecal ", 100, 0., 1.5);
0492     h_invMass_[2][1] = iBooker.book1D(histname + "Barrel_FakeTracks",
0493                                       " Photons:Tracks from conversion: Pair invariant mass: Barrel Ecal ",
0494                                       100,
0495                                       0.,
0496                                       1.5);
0497     h_invMass_[2][2] = iBooker.book1D(histname + "Endcap_FaleTracks",
0498                                       " Photons:Tracks from conversion: Pair invariant mass: Endcap Ecal ",
0499                                       100,
0500                                       0.,
0501                                       1.5);
0502 
0503     histname = "hDPhiTracksAtVtx";
0504     h_DPhiTracksAtVtx_[0][0] = iBooker.book1D(histname + "All",
0505                                               " Photons:Tracks from conversions: #delta#phi Tracks at vertex: all Ecal",
0506                                               dPhiTracksBin,
0507                                               dPhiTracksMin,
0508                                               dPhiTracksMax);
0509     h_DPhiTracksAtVtx_[0][1] =
0510         iBooker.book1D(histname + "Barrel",
0511                        " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Barrel Ecal",
0512                        dPhiTracksBin,
0513                        dPhiTracksMin,
0514                        dPhiTracksMax);
0515     h_DPhiTracksAtVtx_[0][2] =
0516         iBooker.book1D(histname + "Endcap",
0517                        " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Endcap Ecal",
0518                        dPhiTracksBin,
0519                        dPhiTracksMin,
0520                        dPhiTracksMax);
0521     h_DPhiTracksAtVtx_[1][0] = iBooker.book1D(histname + "All_Ass",
0522                                               " Photons:Tracks from conversions: #delta#phi Tracks at vertex: all Ecal",
0523                                               dPhiTracksBin,
0524                                               dPhiTracksMin,
0525                                               dPhiTracksMax);
0526     h_DPhiTracksAtVtx_[1][1] =
0527         iBooker.book1D(histname + "Barrel_Ass",
0528                        " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Barrel Ecal",
0529                        dPhiTracksBin,
0530                        dPhiTracksMin,
0531                        dPhiTracksMax);
0532     h_DPhiTracksAtVtx_[1][2] =
0533         iBooker.book1D(histname + "Endcap_Ass",
0534                        " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Endcap Ecal",
0535                        dPhiTracksBin,
0536                        dPhiTracksMin,
0537                        dPhiTracksMax);
0538     h_DPhiTracksAtVtx_[2][0] = iBooker.book1D(histname + "All_Fakes",
0539                                               " Photons:Tracks from conversions: #delta#phi Tracks at vertex: all Ecal",
0540                                               dPhiTracksBin,
0541                                               dPhiTracksMin,
0542                                               dPhiTracksMax);
0543     h_DPhiTracksAtVtx_[2][1] =
0544         iBooker.book1D(histname + "Barrel_Fakes",
0545                        " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Barrel Ecal",
0546                        dPhiTracksBin,
0547                        dPhiTracksMin,
0548                        dPhiTracksMax);
0549     h_DPhiTracksAtVtx_[2][2] =
0550         iBooker.book1D(histname + "Endcap_Fakes",
0551                        " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Endcap Ecal",
0552                        dPhiTracksBin,
0553                        dPhiTracksMin,
0554                        dPhiTracksMax);
0555 
0556     histname = "hDPhiTracksAtVtxVsEta";
0557     h2_DPhiTracksAtVtxVsEta_ = iBooker.book2D(histname + "All",
0558                                               "  Photons:Tracks from conversions: #delta#phi Tracks at vertex vs #eta",
0559                                               etaBin2,
0560                                               etaMin,
0561                                               etaMax,
0562                                               100,
0563                                               -0.5,
0564                                               0.5);
0565     histname = "pDPhiTracksAtVtxVsEta";
0566     p_DPhiTracksAtVtxVsEta_ =
0567         iBooker.bookProfile(histname + "All",
0568                             " Photons:Tracks from conversions: #delta#phi Tracks at vertex vs #eta ",
0569                             etaBin2,
0570                             etaMin,
0571                             etaMax,
0572                             100,
0573                             -0.5,
0574                             0.5,
0575                             "");
0576 
0577     histname = "hDPhiTracksAtVtxVsR";
0578     h2_DPhiTracksAtVtxVsR_ = iBooker.book2D(histname + "All",
0579                                             "  Photons:Tracks from conversions: #delta#phi Tracks at vertex vs R",
0580                                             rBin,
0581                                             rMin,
0582                                             rMax,
0583                                             100,
0584                                             -0.5,
0585                                             0.5);
0586     histname = "pDPhiTracksAtVtxVsR";
0587     p_DPhiTracksAtVtxVsR_ = iBooker.bookProfile(histname + "All",
0588                                                 " Photons:Tracks from conversions: #delta#phi Tracks at vertex vs R ",
0589                                                 rBin,
0590                                                 rMin,
0591                                                 rMax,
0592                                                 100,
0593                                                 -0.5,
0594                                                 0.5,
0595                                                 "");
0596 
0597     histname = "hDCotTracks";
0598     h_DCotTracks_[0][0] = iBooker.book1D(histname + "All",
0599                                          " Photons:Tracks from conversions #delta cotg(#Theta) Tracks: all Ecal ",
0600                                          dCotTracksBin,
0601                                          dCotTracksMin,
0602                                          dCotTracksMax);
0603     h_DCotTracks_[0][1] = iBooker.book1D(histname + "Barrel",
0604                                          " Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Barrel Ecal ",
0605                                          dCotTracksBin,
0606                                          dCotTracksMin,
0607                                          dCotTracksMax);
0608     h_DCotTracks_[0][2] = iBooker.book1D(histname + "Endcap",
0609                                          " Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Endcap Ecal ",
0610                                          dCotTracksBin,
0611                                          dCotTracksMin,
0612                                          dCotTracksMax);
0613     h_DCotTracks_[1][0] = iBooker.book1D(histname + "All_Ass",
0614                                          " Photons:Tracks from conversions #delta cotg(#Theta) Tracks: all Ecal ",
0615                                          dCotTracksBin,
0616                                          dCotTracksMin,
0617                                          dCotTracksMax);
0618     h_DCotTracks_[1][1] = iBooker.book1D(histname + "Barrel_Ass",
0619                                          " Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Barrel Ecal ",
0620                                          dCotTracksBin,
0621                                          dCotTracksMin,
0622                                          dCotTracksMax);
0623     h_DCotTracks_[1][2] = iBooker.book1D(histname + "Endcap_Ass",
0624                                          " Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Endcap Ecal ",
0625                                          dCotTracksBin,
0626                                          dCotTracksMin,
0627                                          dCotTracksMax);
0628     h_DCotTracks_[2][0] = iBooker.book1D(histname + "All_Fakes",
0629                                          " Photons:Tracks from conversions #delta cotg(#Theta) Tracks: all Ecal ",
0630                                          dCotTracksBin,
0631                                          dCotTracksMin,
0632                                          dCotTracksMax);
0633     h_DCotTracks_[2][1] = iBooker.book1D(histname + "Barrel_Fakes",
0634                                          " Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Barrel Ecal ",
0635                                          dCotTracksBin,
0636                                          dCotTracksMin,
0637                                          dCotTracksMax);
0638     h_DCotTracks_[2][2] = iBooker.book1D(histname + "Endcap_Fakes",
0639                                          " Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Endcap Ecal ",
0640                                          dCotTracksBin,
0641                                          dCotTracksMin,
0642                                          dCotTracksMax);
0643 
0644     histname = "hDCotTracksVsEta";
0645     h2_DCotTracksVsEta_ = iBooker.book2D(histname + "All",
0646                                          "  Photons:Tracks from conversions:  #delta cotg(#Theta) Tracks vs #eta",
0647                                          etaBin2,
0648                                          etaMin,
0649                                          etaMax,
0650                                          100,
0651                                          -0.2,
0652                                          0.2);
0653     histname = "pDCotTracksVsEta";
0654     p_DCotTracksVsEta_ = iBooker.bookProfile(histname + "All",
0655                                              " Photons:Tracks from conversions:  #delta cotg(#Theta) Tracks vs #eta ",
0656                                              etaBin2,
0657                                              etaMin,
0658                                              etaMax,
0659                                              100,
0660                                              -0.2,
0661                                              0.2,
0662                                              "");
0663 
0664     histname = "hDCotTracksVsR";
0665     h2_DCotTracksVsR_ = iBooker.book2D(histname + "All",
0666                                        "  Photons:Tracks from conversions:  #delta cotg(#Theta)  Tracks at vertex vs R",
0667                                        rBin,
0668                                        rMin,
0669                                        rMax,
0670                                        100,
0671                                        -0.2,
0672                                        0.2);
0673     histname = "pDCotTracksVsR";
0674     p_DCotTracksVsR_ =
0675         iBooker.bookProfile(histname + "All",
0676                             " Photons:Tracks from conversions:  #delta cotg(#Theta) Tracks at vertex vs R ",
0677                             rBin,
0678                             rMin,
0679                             rMax,
0680                             100,
0681                             -0.2,
0682                             0.2,
0683                             "");
0684 
0685     histname = "hDistMinAppTracks";
0686     h_distMinAppTracks_[0][0] = iBooker.book1D(
0687         histname + "All", " Photons:Tracks from conversions Min Approach Dist Tracks: all Ecal ", 120, -0.5, 1.0);
0688     h_distMinAppTracks_[0][1] = iBooker.book1D(
0689         histname + "Barrel", " Photons:Tracks from conversions Min Approach Dist Tracks: Barrel Ecal ", 120, -0.5, 1.0);
0690     h_distMinAppTracks_[0][2] = iBooker.book1D(
0691         histname + "Endcap", " Photons:Tracks from conversions Min Approach Dist Tracks: Endcap Ecal ", 120, -0.5, 1.0);
0692     h_distMinAppTracks_[1][0] = iBooker.book1D(
0693         histname + "All_Ass", " Photons:Tracks from conversions Min Approach Dist Tracks: all Ecal ", 120, -0.5, 1.0);
0694     h_distMinAppTracks_[1][1] =
0695         iBooker.book1D(histname + "Barrel_Ass",
0696                        " Photons:Tracks from conversions Min Approach Dist Tracks: Barrel Ecal ",
0697                        120,
0698                        -0.5,
0699                        1.0);
0700     h_distMinAppTracks_[1][2] =
0701         iBooker.book1D(histname + "Endcap_Ass",
0702                        " Photons:Tracks from conversions Min Approach Dist Tracks: Endcap Ecal ",
0703                        120,
0704                        -0.5,
0705                        1.0);
0706     h_distMinAppTracks_[2][0] = iBooker.book1D(
0707         histname + "All_Fakes", " Photons:Tracks from conversions Min Approach Dist Tracks: all Ecal ", 120, -0.5, 1.0);
0708     h_distMinAppTracks_[2][1] =
0709         iBooker.book1D(histname + "Barrel_Fakes",
0710                        " Photons:Tracks from conversions Min Approach Dist Tracks: Barrel Ecal ",
0711                        120,
0712                        -0.5,
0713                        1.0);
0714     h_distMinAppTracks_[2][2] =
0715         iBooker.book1D(histname + "Endcap_Fakes",
0716                        " Photons:Tracks from conversions Min Approach Dist Tracks: Endcap Ecal ",
0717                        120,
0718                        -0.5,
0719                        1.0);
0720 
0721     h_convVtxRvsZ_[0] = iBooker.book2D("convVtxRvsZAll",
0722                                        " Photon Reco conversion vtx position",
0723                                        zBinForXray,
0724                                        zMinForXray,
0725                                        zMaxForXray,
0726                                        rBinForXray,
0727                                        rMinForXray,
0728                                        rMaxForXray);
0729     h_convVtxRvsZ_[1] = iBooker.book2D("convVtxRvsZBarrel",
0730                                        " Photon Reco conversion vtx position",
0731                                        zBinForXray,
0732                                        zMinForXray,
0733                                        zMaxForXray,
0734                                        rBinForXray,
0735                                        rMinForXray,
0736                                        rMaxForXray);
0737     h_convVtxRvsZ_[2] = iBooker.book2D("convVtxRvsZEndcap",
0738                                        " Photon Reco conversion vtx position",
0739                                        zBin2ForXray,
0740                                        zMinForXray,
0741                                        zMaxForXray,
0742                                        rBinForXray,
0743                                        rMinForXray,
0744                                        rMaxForXray);
0745     h_convVtxYvsX_ = iBooker.book2D(
0746         "convVtxYvsXTrkBarrel", " Photon Reco conversion vtx position, (x,y) eta<1 ", 1000, -60., 60., 1000, -60., 60.);
0747     /// zooms
0748     h_convVtxRvsZ_zoom_[0] = iBooker.book2D("convVtxRvsZBarrelZoom1",
0749                                             " Photon Reco conversion vtx position",
0750                                             zBinForXray,
0751                                             zMinForXray,
0752                                             zMaxForXray,
0753                                             rBinForXray,
0754                                             -10.,
0755                                             40.);
0756     h_convVtxRvsZ_zoom_[1] = iBooker.book2D("convVtxRvsZBarrelZoom2",
0757                                             " Photon Reco conversion vtx position",
0758                                             zBinForXray,
0759                                             zMinForXray,
0760                                             zMaxForXray,
0761                                             rBinForXray,
0762                                             -10.,
0763                                             20.);
0764     h_convVtxYvsX_zoom_[0] = iBooker.book2D("convVtxYvsXTrkBarrelZoom1",
0765                                             " Photon Reco conversion vtx position, (x,y) eta<1 ",
0766                                             100,
0767                                             -40.,
0768                                             40.,
0769                                             100,
0770                                             -40.,
0771                                             40.);
0772     h_convVtxYvsX_zoom_[1] = iBooker.book2D("convVtxYvsXTrkBarrelZoom2",
0773                                             " Photon Reco conversion vtx position, (x,y) eta<1 ",
0774                                             100,
0775                                             -20.,
0776                                             20.,
0777                                             100,
0778                                             -20.,
0779                                             20.);
0780 
0781     h_convVtxdR_ = iBooker.book1D("convVtxdR", " Photon Reco conversion vtx dR", 100, -10., 10.);
0782     h_convVtxdX_ = iBooker.book1D("convVtxdX", " Photon Reco conversion vtx dX", 100, -10., 10.);
0783     h_convVtxdY_ = iBooker.book1D("convVtxdY", " Photon Reco conversion vtx dY", 100, -10., 10.);
0784     h_convVtxdZ_ = iBooker.book1D("convVtxdZ", " Photon Reco conversion vtx dZ", 100, -20., 20.);
0785 
0786     h_convVtxdPhi_ = iBooker.book1D("convVtxdPhi", " Photon Reco conversion vtx dPhi", 100, -0.01, 0.01);
0787     h_convVtxdEta_ = iBooker.book1D("convVtxdEta", " Photon Reco conversion vtx dEta", 100, -0.5, 0.5);
0788 
0789     h_convVtxdR_barrel_ =
0790         iBooker.book1D("convVtxdR_barrel", " Photon Reco conversion vtx dR, |eta|<=1.2", 100, -10., 10.);
0791     h_convVtxdX_barrel_ =
0792         iBooker.book1D("convVtxdX_barrel", " Photon Reco conversion vtx dX, |eta|<=1.2", 100, -10., 10.);
0793     h_convVtxdY_barrel_ =
0794         iBooker.book1D("convVtxdY_barrel", " Photon Reco conversion vtx dY, |eta|<=1.2 ", 100, -10., 10.);
0795     h_convVtxdZ_barrel_ =
0796         iBooker.book1D("convVtxdZ_barrel", " Photon Reco conversion vtx dZ, |eta|<=1.2,", 100, -20., 20.);
0797 
0798     h_convVtxdR_endcap_ =
0799         iBooker.book1D("convVtxdR_endcap", " Photon Reco conversion vtx dR,  |eta|>1.2 ", 100, -10., 10.);
0800     h_convVtxdX_endcap_ =
0801         iBooker.book1D("convVtxdX_endcap", " Photon Reco conversion vtx dX,  |eta|>1.2", 100, -10., 10.);
0802     h_convVtxdY_endcap_ =
0803         iBooker.book1D("convVtxdY_endcap", " Photon Reco conversion vtx dY,  |eta|>1.2", 100, -10., 10.);
0804     h_convVtxdZ_endcap_ =
0805         iBooker.book1D("convVtxdZ_endcap", " Photon Reco conversion vtx dZ,  |eta|>1.2", 100, -20., 20.);
0806 
0807     h2_convVtxdRVsR_ = iBooker.book2D("h2ConvVtxdRVsR", " Conversion vtx dR vsR", rBin, rMin, rMax, 100, -20., 20.);
0808     h2_convVtxdRVsEta_ =
0809         iBooker.book2D("h2ConvVtxdRVsEta", "Conversion vtx dR vs Eta", etaBin2, etaMin, etaMax, 100, -20., 20.);
0810 
0811     p_convVtxdRVsR_ =
0812         iBooker.bookProfile("pConvVtxdRVsR", " Conversion vtx dR vsR", rBin, rMin, rMax, 100, -20., 20., "");
0813     p_convVtxdRVsEta_ =
0814         iBooker.bookProfile("pConvVtxdRVsEta", "Conversion vtx dR vs Eta", etaBin2, etaMin, etaMax, 100, -20., 20., "");
0815     p_convVtxdXVsX_ = iBooker.bookProfile("pConvVtxdXVsX", "Conversion vtx dX vs X", 120, -60, 60, 100, -20., 20., "");
0816     p_convVtxdYVsY_ = iBooker.bookProfile("pConvVtxdYVsY", "Conversion vtx dY vs Y", 120, -60, 60, 100, -20., 20., "");
0817     p_convVtxdZVsZ_ =
0818         iBooker.bookProfile("pConvVtxdZVsZ", "Conversion vtx dZ vs Z", zBin, zMin, zMax, 100, -20., 20., "");
0819 
0820     p_convVtxdZVsR_ =
0821         iBooker.bookProfile("pConvVtxdZVsR", "Conversion vtx dZ vs R", rBin, rMin, rMax, 100, -20., 20., "");
0822     p2_convVtxdRVsRZ_ = iBooker.bookProfile2D(
0823         "p2ConvVtxdRVsRZ", "Conversion vtx dR vs RZ", zBin, zMin, zMax, rBin, rMin, rMax, 100, 0., 20., "s");
0824     p2_convVtxdZVsRZ_ = iBooker.bookProfile2D(
0825         "p2ConvVtxdZVsRZ", "Conversion vtx dZ vs RZ", zBin, zMin, zMax, rBin, rMin, rMax, 100, 0., 20., "s");
0826 
0827     histname = "EoverPtracks";
0828     h_EoverPTracks_[0][0] =
0829         iBooker.book1D(histname + "All", " photons conversion E/p: all Ecal ", eoverpBin, eoverpMin, eoverpMax);
0830     h_EoverPTracks_[0][1] =
0831         iBooker.book1D(histname + "Barrel", " photons conversion E/p: Barrel Ecal", eoverpBin, eoverpMin, eoverpMax);
0832     h_EoverPTracks_[0][2] =
0833         iBooker.book1D(histname + "Endcap", " photons conversion E/p: Endcap Ecal ", eoverpBin, eoverpMin, eoverpMax);
0834     h_EoverPTracks_[1][0] =
0835         iBooker.book1D(histname + "All_Ass", " photons conversion E/p: all Ecal ", eoverpBin, eoverpMin, eoverpMax);
0836     h_EoverPTracks_[1][1] = iBooker.book1D(
0837         histname + "Barrel_Ass", " photons conversion E/p: Barrel Ecal", eoverpBin, eoverpMin, eoverpMax);
0838     h_EoverPTracks_[1][2] = iBooker.book1D(
0839         histname + "Endcap_Ass", " photons conversion E/p: Endcap Ecal ", eoverpBin, eoverpMin, eoverpMax);
0840     h_EoverPTracks_[2][0] =
0841         iBooker.book1D(histname + "All_Fakes", " photons conversion E/p: all Ecal ", eoverpBin, eoverpMin, eoverpMax);
0842     h_EoverPTracks_[2][1] = iBooker.book1D(
0843         histname + "Barrel_Fakes", " photons conversion E/p: Barrel Ecal", eoverpBin, eoverpMin, eoverpMax);
0844     h_EoverPTracks_[2][2] = iBooker.book1D(
0845         histname + "Endcap_Fakes", " photons conversion E/p: Endcap Ecal ", eoverpBin, eoverpMin, eoverpMax);
0846 
0847     h2_convVtxRrecVsTrue_ = iBooker.book2D(
0848         "h2ConvVtxRrecVsTrue", "Photon Reco conversion vtx R rec vs true", rBin, rMin, rMax, rBin, rMin, rMax);
0849 
0850     histname = "vtxChi2Prob";
0851     h_vtxChi2Prob_[0][0] = iBooker.book1D(histname + "All", "vertex #chi^{2} all", 100, 0., 1.);
0852     h_vtxChi2Prob_[0][1] = iBooker.book1D(histname + "Barrel", "vertex #chi^{2} barrel", 100, 0., 1.);
0853     h_vtxChi2Prob_[0][2] = iBooker.book1D(histname + "Endcap", "vertex #chi^{2} endcap", 100, 0., 1.);
0854     h_vtxChi2Prob_[1][0] = iBooker.book1D(histname + "All_Ass", "vertex #chi^{2} all", 100, 0., 1.);
0855     h_vtxChi2Prob_[1][1] = iBooker.book1D(histname + "Barrel_Ass", "vertex #chi^{2} barrel", 100, 0., 1.);
0856     h_vtxChi2Prob_[1][2] = iBooker.book1D(histname + "Endcap_Ass", "vertex #chi^{2} endcap", 100, 0., 1.);
0857     h_vtxChi2Prob_[2][0] = iBooker.book1D(histname + "All_Fakes", "vertex #chi^{2} all", 100, 0., 1.);
0858     h_vtxChi2Prob_[2][1] = iBooker.book1D(histname + "Barrel_Fakes", "vertex #chi^{2} barrel", 100, 0., 1.);
0859     h_vtxChi2Prob_[2][2] = iBooker.book1D(histname + "Endcap_Fakes", "vertex #chi^{2} endcap", 100, 0., 1.);
0860 
0861     h_zPVFromTracks_[1] = iBooker.book1D("zPVFromTracks", " Photons: PV z from conversion tracks", 100, -25., 25.);
0862     h_dzPVFromTracks_[1] =
0863         iBooker.book1D("dzPVFromTracks", " Photons: PV Z_rec - Z_true from conversion tracks", 100, -5., 5.);
0864     h2_dzPVVsR_ = iBooker.book2D("h2dzPVVsR", "Photon Reco conversions: dz(PV) vs R", rBin, rMin, rMax, 100, -3., 3.);
0865     p_dzPVVsR_ =
0866         iBooker.bookProfile("pdzPVVsR", "Photon Reco conversions: dz(PV) vs R", rBin, rMin, rMax, 100, -3., 3., "");
0867 
0868     histname = "lxybs";
0869     h_lxybs_[0][0] = iBooker.book1D(histname + "All", "vertex #chi^{2} all", 200, -100., 100.);
0870     h_lxybs_[0][1] = iBooker.book1D(histname + "Barrel", "vertex #chi^{2} barrel", 200, -100., 100.);
0871     h_lxybs_[0][2] = iBooker.book1D(histname + "Endcap", "vertex #chi^{2} endcap", 200, -100., 100.);
0872     h_lxybs_[1][0] = iBooker.book1D(histname + "All_Ass", "vertex #chi^{2} all", 200, -100., 100.);
0873     h_lxybs_[1][1] = iBooker.book1D(histname + "Barrel_Ass", "vertex #chi^{2} barrel", 200, -100., 100.);
0874     h_lxybs_[1][2] = iBooker.book1D(histname + "Endcap_Ass", "vertex #chi^{2} endcap", 200, -100., 100.);
0875     h_lxybs_[2][0] = iBooker.book1D(histname + "All_Fakes", "vertex #chi^{2} all", 200, -100., 100.);
0876     h_lxybs_[2][1] = iBooker.book1D(histname + "Barrel_Fakes", "vertex #chi^{2} barrel", 200, -100., 100.);
0877     h_lxybs_[2][2] = iBooker.book1D(histname + "Endcap_Fakes", "vertex #chi^{2} endcap", 200, -100., 100.);
0878 
0879     histname = "maxNHitsBeforeVtx";
0880     h_maxNHitsBeforeVtx_[0][0] = iBooker.book1D(histname + "All", "vertex #chi^{2} all", 16, -0.5, 15.5);
0881     h_maxNHitsBeforeVtx_[0][1] = iBooker.book1D(histname + "Barrel", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0882     h_maxNHitsBeforeVtx_[0][2] = iBooker.book1D(histname + "Endcap", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0883     h_maxNHitsBeforeVtx_[1][0] = iBooker.book1D(histname + "All_Ass", "vertex #chi^{2} all", 16, -0.5, 15.5);
0884     h_maxNHitsBeforeVtx_[1][1] = iBooker.book1D(histname + "Barrel_Ass", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0885     h_maxNHitsBeforeVtx_[1][2] = iBooker.book1D(histname + "Endcap_Ass", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0886     h_maxNHitsBeforeVtx_[2][0] = iBooker.book1D(histname + "All_Fakes", "vertex #chi^{2} all", 16, -0.5, 15.5);
0887     h_maxNHitsBeforeVtx_[2][1] = iBooker.book1D(histname + "Barrel_Fakes", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0888     h_maxNHitsBeforeVtx_[2][2] = iBooker.book1D(histname + "Endcap_Fakes", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0889 
0890     histname = "leadNHitsBeforeVtx";
0891     h_leadNHitsBeforeVtx_[0][0] = iBooker.book1D(histname + "All", "vertex #chi^{2} all", 16, -0.5, 15.5);
0892     h_leadNHitsBeforeVtx_[0][1] = iBooker.book1D(histname + "Barrel", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0893     h_leadNHitsBeforeVtx_[0][2] = iBooker.book1D(histname + "Endcap", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0894     h_leadNHitsBeforeVtx_[1][0] = iBooker.book1D(histname + "All_Ass", "vertex #chi^{2} all", 16, -0.5, 15.5);
0895     h_leadNHitsBeforeVtx_[1][1] = iBooker.book1D(histname + "Barrel_Ass", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0896     h_leadNHitsBeforeVtx_[1][2] = iBooker.book1D(histname + "Endcap_Ass", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0897     h_leadNHitsBeforeVtx_[2][0] = iBooker.book1D(histname + "All_Fakes", "vertex #chi^{2} all", 16, -0.5, 15.5);
0898     h_leadNHitsBeforeVtx_[2][1] = iBooker.book1D(histname + "Barrel_Fakes", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0899     h_leadNHitsBeforeVtx_[2][2] = iBooker.book1D(histname + "Endcap_Fakes", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0900 
0901     histname = "trailNHitsBeforeVtx";
0902     h_trailNHitsBeforeVtx_[0][0] = iBooker.book1D(histname + "All", "vertex #chi^{2} all", 16, -0.5, 15.5);
0903     h_trailNHitsBeforeVtx_[0][1] = iBooker.book1D(histname + "Barrel", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0904     h_trailNHitsBeforeVtx_[0][2] = iBooker.book1D(histname + "Endcap", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0905     h_trailNHitsBeforeVtx_[1][0] = iBooker.book1D(histname + "All_Ass", "vertex #chi^{2} all", 16, -0.5, 15.5);
0906     h_trailNHitsBeforeVtx_[1][1] = iBooker.book1D(histname + "Barrel_Ass", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0907     h_trailNHitsBeforeVtx_[1][2] = iBooker.book1D(histname + "Endcap_Ass", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0908     h_trailNHitsBeforeVtx_[2][0] = iBooker.book1D(histname + "All_Fakes", "vertex #chi^{2} all", 16, -0.5, 15.5);
0909     h_trailNHitsBeforeVtx_[2][1] = iBooker.book1D(histname + "Barrel_Fakes", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0910     h_trailNHitsBeforeVtx_[2][2] = iBooker.book1D(histname + "Endcap_Fakes", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0911 
0912     histname = "sumNHitsBeforeVtx";
0913     h_sumNHitsBeforeVtx_[0][0] = iBooker.book1D(histname + "All", "vertex #chi^{2} all", 16, -0.5, 15.5);
0914     h_sumNHitsBeforeVtx_[0][1] = iBooker.book1D(histname + "Barrel", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0915     h_sumNHitsBeforeVtx_[0][2] = iBooker.book1D(histname + "Endcap", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0916     h_sumNHitsBeforeVtx_[1][0] = iBooker.book1D(histname + "All_Ass", "vertex #chi^{2} all", 16, -0.5, 15.5);
0917     h_sumNHitsBeforeVtx_[1][1] = iBooker.book1D(histname + "Barrel_Ass", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0918     h_sumNHitsBeforeVtx_[1][2] = iBooker.book1D(histname + "Endcap_Ass", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0919     h_sumNHitsBeforeVtx_[2][0] = iBooker.book1D(histname + "All_Fakes", "vertex #chi^{2} all", 16, -0.5, 15.5);
0920     h_sumNHitsBeforeVtx_[2][1] = iBooker.book1D(histname + "Barrel_Fakes", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0921     h_sumNHitsBeforeVtx_[2][2] = iBooker.book1D(histname + "Endcap_Fakes", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0922 
0923     histname = "maxDlClosestHitToVtx";
0924     h_maxDlClosestHitToVtx_[0][0] = iBooker.book1D(histname + "All", "vertex #chi^{2} all", 100, -10., 10.);
0925     h_maxDlClosestHitToVtx_[0][1] = iBooker.book1D(histname + "Barrel", "vertex #chi^{2} barrel", 100, -10., 10.);
0926     h_maxDlClosestHitToVtx_[0][2] = iBooker.book1D(histname + "Endcap", "vertex #chi^{2} endcap", 100, -10., 10.);
0927     h_maxDlClosestHitToVtx_[1][0] = iBooker.book1D(histname + "All_Ass", "vertex #chi^{2} all", 100, -10., 10.);
0928     h_maxDlClosestHitToVtx_[1][1] = iBooker.book1D(histname + "Barrel_Ass", "vertex #chi^{2} barrel", 100, -10., 10.);
0929     h_maxDlClosestHitToVtx_[1][2] = iBooker.book1D(histname + "Endcap_Ass", "vertex #chi^{2} endcap", 100, -10., 10.);
0930     h_maxDlClosestHitToVtx_[2][0] = iBooker.book1D(histname + "All_Fakes", "vertex #chi^{2} all", 100, -10., 10.);
0931     h_maxDlClosestHitToVtx_[2][1] = iBooker.book1D(histname + "Barrel_Fakes", "vertex #chi^{2} barrel", 100, -10., 10.);
0932     h_maxDlClosestHitToVtx_[2][2] = iBooker.book1D(histname + "Endcap_Fakes", "vertex #chi^{2} endcap", 100, -10., 10.);
0933 
0934     histname = "maxDlClosestHitToVtxSig";
0935     h_maxDlClosestHitToVtxSig_[0][0] = iBooker.book1D(histname + "All", "vertex #chi^{2} all", 100, -8., 8.);
0936     h_maxDlClosestHitToVtxSig_[0][1] = iBooker.book1D(histname + "Barrel", "vertex #chi^{2} barrel", 100, -8., 8.);
0937     h_maxDlClosestHitToVtxSig_[0][2] = iBooker.book1D(histname + "Endcap", "vertex #chi^{2} endcap", 100, -8., 8.);
0938     h_maxDlClosestHitToVtxSig_[1][0] = iBooker.book1D(histname + "All_Ass", "vertex #chi^{2} all", 100, -8., 8.);
0939     h_maxDlClosestHitToVtxSig_[1][1] = iBooker.book1D(histname + "Barrel_Ass", "vertex #chi^{2} barrel", 100, -8., 8.);
0940     h_maxDlClosestHitToVtxSig_[1][2] = iBooker.book1D(histname + "Endcap_Ass", "vertex #chi^{2} endcap", 100, -8., 8.);
0941     h_maxDlClosestHitToVtxSig_[2][0] = iBooker.book1D(histname + "All_Fakes", "vertex #chi^{2} all", 100, -8., 8.);
0942     h_maxDlClosestHitToVtxSig_[2][1] =
0943         iBooker.book1D(histname + "Barrel_Fakes", "vertex #chi^{2} barrel", 100, -8., 8.);
0944     h_maxDlClosestHitToVtxSig_[2][2] =
0945         iBooker.book1D(histname + "Endcap_Fakes", "vertex #chi^{2} endcap", 100, -8., 8.);
0946 
0947     histname = "deltaExpectedHitsInner";
0948     h_deltaExpectedHitsInner_[0][0] = iBooker.book1D(histname + "All", "vertex #chi^{2} all", 31, -15.5, 15.5);
0949     h_deltaExpectedHitsInner_[0][1] = iBooker.book1D(histname + "Barrel", "vertex #chi^{2} barrel", 31, -15.5, 15.5);
0950     h_deltaExpectedHitsInner_[0][2] = iBooker.book1D(histname + "Endcap", "vertex #chi^{2} endcap", 31, -15.5, 15.5);
0951     h_deltaExpectedHitsInner_[1][0] = iBooker.book1D(histname + "All_Ass", "vertex #chi^{2} all", 31, -15.5, 15.5);
0952     h_deltaExpectedHitsInner_[1][1] =
0953         iBooker.book1D(histname + "Barrel_Ass", "vertex #chi^{2} barrel", 31, -15.5, 15.5);
0954     h_deltaExpectedHitsInner_[1][2] =
0955         iBooker.book1D(histname + "Endcap_Ass", "vertex #chi^{2} endcap", 31, -15.5, 15.5);
0956     h_deltaExpectedHitsInner_[2][0] = iBooker.book1D(histname + "All_Fakes", "vertex #chi^{2} all", 31, -15.5, 15.5);
0957     h_deltaExpectedHitsInner_[2][1] =
0958         iBooker.book1D(histname + "Barrel_Fakes", "vertex #chi^{2} barrel", 31, -15.5, 15.5);
0959     h_deltaExpectedHitsInner_[2][2] =
0960         iBooker.book1D(histname + "Endcap_Fakes", "vertex #chi^{2} endcap", 31, -15.5, 15.5);
0961 
0962     histname = "leadExpectedHitsInner";
0963     h_leadExpectedHitsInner_[0][0] = iBooker.book1D(histname + "All", "vertex #chi^{2} all", 16, -0.5, 15.5);
0964     h_leadExpectedHitsInner_[0][1] = iBooker.book1D(histname + "Barrel", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0965     h_leadExpectedHitsInner_[0][2] = iBooker.book1D(histname + "Endcap", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0966     h_leadExpectedHitsInner_[1][0] = iBooker.book1D(histname + "All_Ass", "vertex #chi^{2} all", 16, -0.5, 15.5);
0967     h_leadExpectedHitsInner_[1][1] = iBooker.book1D(histname + "Barrel_Ass", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0968     h_leadExpectedHitsInner_[1][2] = iBooker.book1D(histname + "Endcap_Ass", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0969     h_leadExpectedHitsInner_[2][0] = iBooker.book1D(histname + "All_Fakes", "vertex #chi^{2} all", 16, -0.5, 15.5);
0970     h_leadExpectedHitsInner_[2][1] =
0971         iBooker.book1D(histname + "Barrel_Fakes", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0972     h_leadExpectedHitsInner_[2][2] =
0973         iBooker.book1D(histname + "Endcap_Fakes", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0974 
0975     histname = "nSharedHits";
0976     h_nSharedHits_[0][0] = iBooker.book1D(histname + "All", "vertex #chi^{2} all", 16, -0.5, 15.5);
0977     h_nSharedHits_[0][1] = iBooker.book1D(histname + "Barrel", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0978     h_nSharedHits_[0][2] = iBooker.book1D(histname + "Endcap", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0979     h_nSharedHits_[1][0] = iBooker.book1D(histname + "All_Ass", "vertex #chi^{2} all", 16, -0.5, 15.5);
0980     h_nSharedHits_[1][1] = iBooker.book1D(histname + "Barrel_Ass", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0981     h_nSharedHits_[1][2] = iBooker.book1D(histname + "Endcap_Ass", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0982     h_nSharedHits_[2][0] = iBooker.book1D(histname + "All_Fakes", "vertex #chi^{2} all", 16, -0.5, 15.5);
0983     h_nSharedHits_[2][1] = iBooker.book1D(histname + "Barrel_Fakes", "vertex #chi^{2} barrel", 16, -0.5, 15.5);
0984     h_nSharedHits_[2][2] = iBooker.book1D(histname + "Endcap_Fakes", "vertex #chi^{2} endcap", 16, -0.5, 15.5);
0985 
0986     //////////////////// plots per track
0987     histname = "nHits";
0988     nHits_[0] = iBooker.book2D(histname + "AllTracks",
0989                                "Photons:Tracks from conversions: # of hits all tracks",
0990                                etaBin,
0991                                etaMin,
0992                                etaMax,
0993                                30,
0994                                0.,
0995                                30.);
0996     nHits_[1] = iBooker.book2D(histname + "AllTracks_Ass",
0997                                "Photons:Tracks from conversions: # of hits  all tracks ass",
0998                                etaBin,
0999                                etaMin,
1000                                etaMax,
1001                                30,
1002                                0.,
1003                                30.);
1004     nHits_[2] = iBooker.book2D(histname + "AllTracks_Fakes",
1005                                "Photons:Tracks from conversions: # of hits all tracks fakes",
1006                                etaBin,
1007                                etaMin,
1008                                etaMax,
1009                                30,
1010                                0.,
1011                                30.);
1012 
1013     histname = "nHitsVsEta";
1014     nHitsVsEta_[0] = iBooker.book2D(histname + "AllTracks",
1015                                     "Photons:Tracks from conversions: # of hits vs #eta all tracks",
1016                                     etaBin,
1017                                     etaMin,
1018                                     etaMax,
1019                                     30,
1020                                     0.,
1021                                     30.);
1022     nHitsVsEta_[1] = iBooker.book2D(histname + "AllTracks_Ass",
1023                                     "Photons:Tracks from conversions: # of hits vs #eta all tracks",
1024                                     etaBin,
1025                                     etaMin,
1026                                     etaMax,
1027                                     30,
1028                                     0.,
1029                                     30.);
1030     nHitsVsEta_[2] = iBooker.book2D(histname + "AllTracks_Fakes",
1031                                     "Photons:Tracks from conversions: # of hits vs #eta all tracks",
1032                                     etaBin,
1033                                     etaMin,
1034                                     etaMax,
1035                                     30,
1036                                     0.,
1037                                     30.);
1038     histname = "h_nHitsVsEta";
1039     p_nHitsVsEta_[0] = iBooker.bookProfile(histname + "AllTracks",
1040                                            "Photons:Tracks from conversions: # of hits vs #eta all tracks",
1041                                            etaBin,
1042                                            etaMin,
1043                                            etaMax,
1044                                            30,
1045                                            -0.5,
1046                                            29.5,
1047                                            "");
1048     p_nHitsVsEta_[1] = iBooker.bookProfile(histname + "AllTracks_Ass",
1049                                            "Photons:Tracks from conversions: # of hits vs #eta all tracks",
1050                                            etaBin,
1051                                            etaMin,
1052                                            etaMax,
1053                                            30,
1054                                            -0.5,
1055                                            29.5,
1056                                            "");
1057     p_nHitsVsEta_[2] = iBooker.bookProfile(histname + "AllTracks_Fakes",
1058                                            "Photons:Tracks from conversions: # of hits vs #eta all tracks",
1059                                            etaBin,
1060                                            etaMin,
1061                                            etaMax,
1062                                            30,
1063                                            -0.5,
1064                                            29.5,
1065                                            "");
1066 
1067     histname = "nHitsVsR";
1068     nHitsVsR_[0] = iBooker.book2D(histname + "AllTracks",
1069                                   "Photons:Tracks from conversions: # of hits vs radius all tracks",
1070                                   rBin,
1071                                   rMin,
1072                                   rMax,
1073                                   30,
1074                                   0.,
1075                                   30.);
1076     nHitsVsR_[1] = iBooker.book2D(histname + "AllTracks_Ass",
1077                                   "Photons:Tracks from conversions: # of hits vs radius all tracks",
1078                                   rBin,
1079                                   rMin,
1080                                   rMax,
1081                                   30,
1082                                   0.,
1083                                   30.);
1084     nHitsVsR_[2] = iBooker.book2D(histname + "AllTracks_Fakes",
1085                                   "Photons:Tracks from conversions: # of hits vs radius all tracks",
1086                                   rBin,
1087                                   rMin,
1088                                   rMax,
1089                                   30,
1090                                   0.,
1091                                   30.);
1092 
1093     histname = "h_nHitsVsR";
1094     p_nHitsVsR_[0] = iBooker.bookProfile(histname + "AllTracks",
1095                                          "Photons:Tracks from conversions: # of hits vs radius all tracks",
1096                                          rBin,
1097                                          rMin,
1098                                          rMax,
1099                                          30,
1100                                          -0.5,
1101                                          29.5,
1102                                          "");
1103     p_nHitsVsR_[1] = iBooker.bookProfile(histname + "AllTracks_Ass",
1104                                          "Photons:Tracks from conversions: # of hits vs radius all tracks",
1105                                          rBin,
1106                                          rMin,
1107                                          rMax,
1108                                          30,
1109                                          -0.5,
1110                                          29.5,
1111                                          "");
1112     p_nHitsVsR_[2] = iBooker.bookProfile(histname + "AllTracks_Fakes",
1113                                          "Photons:Tracks from conversions: # of hits vs radius all tracks",
1114                                          rBin,
1115                                          rMin,
1116                                          rMax,
1117                                          30,
1118                                          -0.5,
1119                                          29.5,
1120                                          "");
1121 
1122     histname = "tkChi2";
1123     h_tkChi2_[0] = iBooker.book1D(
1124         histname + "AllTracks", "Photons:Tracks from conversions: #chi^{2} of all tracks", 100, chi2Min, chi2Max);
1125     h_tkChi2_[1] = iBooker.book1D(
1126         histname + "AllTracks_Ass", "Photons:Tracks from conversions: #chi^{2} of all tracks", 100, chi2Min, chi2Max);
1127     h_tkChi2_[2] = iBooker.book1D(
1128         histname + "AllTracks_Fakes", "Photons:Tracks from conversions: #chi^{2} of all tracks", 100, chi2Min, chi2Max);
1129 
1130     histname = "tkChi2Large";
1131     h_tkChi2Large_[0] = iBooker.book1D(
1132         histname + "AllTracks", "Photons:Tracks from conversions: #chi^{2} of all tracks", 1000, 0., 5000.0);
1133     h_tkChi2Large_[1] = iBooker.book1D(
1134         histname + "AllTracks_Ass", "Photons:Tracks from conversions: #chi^{2} of all tracks", 1000, 0., 5000.0);
1135     h_tkChi2Large_[2] = iBooker.book1D(
1136         histname + "AllTracks_Fakes", "Photons:Tracks from conversions: #chi^{2} of all tracks", 1000, 0., 5000.0);
1137 
1138     histname = "h2Chi2VsEta";
1139     h2_Chi2VsEta_[0] = iBooker.book2D(
1140         histname + "All", " Reco Track  #chi^{2} vs #eta: All ", etaBin2, etaMin, etaMax, 100, chi2Min, chi2Max);
1141     h2_Chi2VsEta_[1] = iBooker.book2D(
1142         histname + "All_Ass", " Reco Track  #chi^{2} vs #eta: All ", etaBin2, etaMin, etaMax, 100, chi2Min, chi2Max);
1143     h2_Chi2VsEta_[2] = iBooker.book2D(
1144         histname + "All_Fakes", " Reco Track  #chi^{2} vs #eta: All ", etaBin2, etaMin, etaMax, 100, chi2Min, chi2Max);
1145     histname = "pChi2VsEta";
1146     p_Chi2VsEta_[0] = iBooker.bookProfile(
1147         histname + "All", " Reco Track #chi^{2} vs #eta : All ", etaBin2, etaMin, etaMax, 100, chi2Min, chi2Max, "");
1148     p_Chi2VsEta_[1] = iBooker.bookProfile(
1149         histname + "All_Ass", " Reco Track #chi^{2} vs #eta : All ", etaBin2, etaMin, etaMax, 100, chi2Min, chi2Max, "");
1150     p_Chi2VsEta_[2] = iBooker.bookProfile(histname + "All_Fakes",
1151                                           " Reco Track #chi^{2} vs #eta : All ",
1152                                           etaBin2,
1153                                           etaMin,
1154                                           etaMax,
1155                                           100,
1156                                           chi2Min,
1157                                           chi2Max,
1158                                           "");
1159 
1160     histname = "h2Chi2VsR";
1161     h2_Chi2VsR_[0] =
1162         iBooker.book2D(histname + "All", " Reco Track  #chi^{2} vs R: All ", rBin, rMin, rMax, 100, chi2Min, chi2Max);
1163     h2_Chi2VsR_[1] = iBooker.book2D(
1164         histname + "All_Ass", " Reco Track  #chi^{2} vs R: All ", rBin, rMin, rMax, 100, chi2Min, chi2Max);
1165     h2_Chi2VsR_[2] = iBooker.book2D(
1166         histname + "All_Fakes", " Reco Track  #chi^{2} vs R: All ", rBin, rMin, rMax, 100, chi2Min, chi2Max);
1167     histname = "pChi2VsR";
1168     p_Chi2VsR_[0] = iBooker.bookProfile(
1169         histname + "All", " Reco Track #chi^{2} vas R : All ", rBin, rMin, rMax, 100, chi2Min, chi2Max, "");
1170     p_Chi2VsR_[1] = iBooker.bookProfile(
1171         histname + "All_Ass", " Reco Track #chi^{2} vas R : All ", rBin, rMin, rMax, 100, chi2Min, chi2Max, "");
1172     p_Chi2VsR_[2] = iBooker.bookProfile(
1173         histname + "All_Fakes", " Reco Track #chi^{2} vas R : All ", rBin, rMin, rMax, 100, chi2Min, chi2Max, "");
1174 
1175     histname = "hTkD0";
1176     h_TkD0_[0] = iBooker.book1D(histname + "All", " Reco Track D0*q: All ", 200, -0.1, 60);
1177     h_TkD0_[1] = iBooker.book1D(histname + "All_Ass", " Reco Track D0*q: Barrel ", 200, -0.1, 60);
1178     h_TkD0_[2] = iBooker.book1D(histname + "All_Fakes", " Reco Track D0*q: Endcap ", 200, -0.1, 60);
1179 
1180     histname = "hTkPtPull";
1181     h_TkPtPull_[0] = iBooker.book1D(histname + "All", " Reco Track Pt pull: All ", 100, -20., 10.);
1182     histname = "hTkPtPull";
1183     h_TkPtPull_[1] = iBooker.book1D(histname + "Barrel", " Reco Track Pt pull: Barrel ", 100, -20., 10.);
1184     histname = "hTkPtPull";
1185     h_TkPtPull_[2] = iBooker.book1D(histname + "Endcap", " Reco Track Pt pull: Endcap ", 100, -20., 10.);
1186 
1187     histname = "h2TkPtPullEta";
1188     h2_TkPtPull_[0] =
1189         iBooker.book2D(histname + "All", " Reco Track Pt pull: All ", etaBin2, etaMin, etaMax, 100, -20., 10.);
1190     histname = "pTkPtPullEta";
1191     p_TkPtPull_[0] = iBooker.bookProfile(
1192         histname + "All", " Reco Track Pt pull: All ", etaBin2, etaMin, etaMax, 100, -20., 10., " ");
1193 
1194     histname = "PtRecVsPtSim";
1195     h2_PtRecVsPtSim_[0] =
1196         iBooker.book2D(histname + "All", "Pt Rec vs Pt sim: All ", etBin, etMin, etMax, etBin, etMin, etMax);
1197     h2_PtRecVsPtSim_[1] =
1198         iBooker.book2D(histname + "Barrel", "Pt Rec vs Pt sim: Barrel ", etBin, etMin, etMax, etBin, etMin, etMax);
1199     h2_PtRecVsPtSim_[2] =
1200         iBooker.book2D(histname + "Endcap", "Pt Rec vs Pt sim: Endcap ", etBin, etMin, etMax, etBin, etMin, etMax);
1201 
1202     histname = "photonPtRecVsPtSim";
1203     h2_photonPtRecVsPtSim_ =
1204         iBooker.book2D(histname + "All", "Pt Rec vs Pt sim: All ", etBin, etMin, etMax, etBin, etMin, etMax);
1205 
1206     histname = "nHitsBeforeVtx";
1207     h_nHitsBeforeVtx_[0] = iBooker.book1D(histname + "All", "Pt Rec vs Pt sim: All ", 16, -0.5, 15.5);
1208     h_nHitsBeforeVtx_[1] = iBooker.book1D(histname + "Barrel", "Pt Rec vs Pt sim: Barrel ", 16, -0.5, 15.5);
1209     h_nHitsBeforeVtx_[2] = iBooker.book1D(histname + "Endcap", "Pt Rec vs Pt sim: Endcap ", 16, -0.5, 15.5);
1210 
1211     histname = "dlClosestHitToVtx";
1212     h_dlClosestHitToVtx_[0] = iBooker.book1D(histname + "All", "Pt Rec vs Pt sim: All ", 100, -10., 10.);
1213     h_dlClosestHitToVtx_[1] = iBooker.book1D(histname + "Barrel", "Pt Rec vs Pt sim: Barrel ", 100, -10., 10.);
1214     h_dlClosestHitToVtx_[2] = iBooker.book1D(histname + "Endcap", "Pt Rec vs Pt sim: Endcap ", 100, -10., 10.);
1215 
1216     histname = "dlClosestHitToVtxSig";
1217     h_dlClosestHitToVtxSig_[0] = iBooker.book1D(histname + "All", "Pt Rec vs Pt sim: All ", 100, -8., 8.);
1218     h_dlClosestHitToVtxSig_[1] = iBooker.book1D(histname + "Barrel", "Pt Rec vs Pt sim: Barrel ", 100, -8., 8.);
1219     h_dlClosestHitToVtxSig_[2] = iBooker.book1D(histname + "Endcap", "Pt Rec vs Pt sim: Endcap ", 100, -8., 8.);
1220 
1221     h_match_ = iBooker.book1D("h_match", " ", 3, -0.5, 2.5);
1222 
1223   }  // if DQM
1224 }
1225 
1226 void TkConvValidator::dqmBeginRun(edm::Run const& r, edm::EventSetup const& theEventSetup) {
1227   //get magnetic field
1228   edm::LogInfo("ConvertedPhotonProducer") << " get magnetic field"
1229                                           << "\n";
1230   theMF_ = theEventSetup.getHandle(magneticFieldToken_);
1231 
1232   thePhotonMCTruthFinder_ = new PhotonMCTruthFinder();
1233 }
1234 
1235 void TkConvValidator::dqmEndRun(edm::Run const& r, edm::EventSetup const&) { delete thePhotonMCTruthFinder_; }
1236 
1237 void TkConvValidator::analyze(const edm::Event& e, const edm::EventSetup& esup) {
1238   thePhotonMCTruthFinder_->clear();
1239   using namespace edm;
1240   //  const float etaPhiDistance=0.01;
1241   // Fiducial region
1242   // const float TRK_BARL =0.9;
1243   const float BARL = 1.4442;  // DAQ TDR p.290
1244   //  const float END_LO = 1.566; // unused
1245   const float END_HI = 2.5;
1246   // Electron mass
1247   //  const Float_t mElec= 0.000511; // unused
1248 
1249   Handle<reco::TrackToTrackingParticleAssociator> theTrackAssociator;
1250   e.getByToken(trackAssociator_Token_, theTrackAssociator);
1251 
1252   nEvt_++;
1253   LogInfo("TkConvValidator") << "TkConvValidator Analyzing event number: " << e.id() << " Global Counter " << nEvt_
1254                              << "\n";
1255   //  std::cout << "TkConvValidator Analyzing event number: "  << e.id() << " Global Counter " << nEvt_ <<"\n";
1256 
1257   // get the geometry from the event setup:
1258   theCaloGeom_ = esup.getHandle(caloGeometryToken_);
1259 
1260   // Transform Track into TransientTrack (needed by the Vertex fitter)
1261   auto theTTB = esup.getHandle(transientTrackBuilderToken_);
1262 
1263   ///// Get the recontructed  conversions
1264   Handle<reco::ConversionCollection> convHandle;
1265   e.getByToken(conversionCollectionPr_Token_, convHandle);
1266   const reco::ConversionCollection convCollection = *(convHandle.product());
1267   if (!convHandle.isValid()) {
1268     edm::LogError("ConversionsProducer") << "Error! Can't get the  collection " << std::endl;
1269     return;
1270   }
1271 
1272   ///// Get the recontructed  photons
1273   Handle<reco::PhotonCollection> photonHandle;
1274   e.getByToken(photonCollectionPr_Token_, photonHandle);
1275   const reco::PhotonCollection photonCollection = *(photonHandle.product());
1276   if (!photonHandle.isValid()) {
1277     edm::LogError("PhotonProducer") << "Error! Can't get the Photon collection " << std::endl;
1278     return;
1279   }
1280 
1281   // offline  Primary vertex
1282   edm::Handle<reco::VertexCollection> vertexHandle;
1283   reco::VertexCollection vertexCollection;
1284   e.getByToken(offline_pvToken_, vertexHandle);
1285   if (!vertexHandle.isValid()) {
1286     edm::LogError("TrackerOnlyConversionProducer") << "Error! Can't get the product primary Vertex Collection "
1287                                                    << "\n";
1288   } else {
1289     vertexCollection = *(vertexHandle.product());
1290   }
1291   reco::Vertex the_pvtx;
1292   bool valid_pvtx = false;
1293   if (!vertexCollection.empty()) {
1294     the_pvtx = *(vertexCollection.begin());
1295     //asking for one good vertex
1296     if (the_pvtx.isValid() && fabs(the_pvtx.position().z()) <= 15 && the_pvtx.position().Rho() <= 2) {
1297       valid_pvtx = true;
1298     }
1299   }
1300 
1301   edm::Handle<reco::BeamSpot> bsHandle;
1302   e.getByToken(beamspotToken_, bsHandle);
1303   if (!bsHandle.isValid()) {
1304     edm::LogError("TrackerOnlyConversionProducer") << "Error! Can't get the product primary Vertex Collection "
1305                                                    << "\n";
1306     return;
1307   }
1308   const reco::BeamSpot& thebs = *bsHandle.product();
1309 
1310   //get tracker geometry for hits positions
1311   //edm::ESHandle<TrackerGeometry> tracker;
1312   //esup.get<TrackerDigiGeometryRecord>().get(tracker);
1313   auto tracker = esup.getHandle(trackerGeometryToken_);
1314   const TrackerGeometry* trackerGeom = tracker.product();
1315 
1316   //////////////////// Get the MC truth
1317   //get simtrack info
1318   //std::vector<SimTrack> theSimTracks;
1319   //std::vector<SimVertex> theSimVertices;
1320 
1321   edm::Handle<SimTrackContainer> SimTk;
1322   edm::Handle<SimVertexContainer> SimVtx;
1323   e.getByToken(g4_simTk_Token_, SimTk);
1324   e.getByToken(g4_simVtx_Token_, SimVtx);
1325 
1326   bool useTP = parameters_.getParameter<bool>("useTP");
1327   TrackingParticleRefVector dummy;
1328   edm::Handle<TrackingParticleRefVector> TPHandleForEff;
1329   edm::Handle<TrackingParticleRefVector> TPHandleForFakeRate;
1330   if (useTP) {
1331     e.getByToken(tpSelForEff_Token_, TPHandleForEff);
1332     e.getByToken(tpSelForFake_Token_, TPHandleForFakeRate);
1333   }
1334 
1335   const TrackingParticleRefVector& tpForEfficiency = useTP ? *(TPHandleForEff.product()) : dummy;
1336   const TrackingParticleRefVector& tpForFakeRate = useTP ? *(TPHandleForFakeRate.product()) : dummy;
1337 
1338   const std::vector<SimTrack>& theSimTracks = *SimTk;
1339   const std::vector<SimVertex>& theSimVertices = *SimVtx;
1340 
1341   //theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
1342   //theSimVertices.insert(theSimVertices.end(),SimVtx->begin(),SimVtx->end());
1343   std::vector<PhotonMCTruth> mcPhotons = thePhotonMCTruthFinder_->find(theSimTracks, theSimVertices);
1344 
1345   //edm::Handle<edm::HepMCProduct> hepMC;
1346   //e.getByToken(hepMC_Token_, hepMC);
1347   //  const HepMC::GenEvent *myGenEvent = hepMC->GetEvent(); // unused
1348 
1349   // get generated jets
1350   //edm::Handle<reco::GenJetCollection> GenJetsHandle;
1351   //e.getByToken(genjets_Token_, GenJetsHandle);
1352   //const reco::GenJetCollection &genJetCollection = *(GenJetsHandle.product());
1353 
1354   // ################  SIM to RECO ######################### //
1355   std::map<const reco::Track*, TrackingParticleRef> myAss;
1356   std::map<const reco::Track*, TrackingParticleRef>::const_iterator itAss;
1357 
1358   for (std::vector<PhotonMCTruth>::const_iterator mcPho = mcPhotons.begin(); mcPho != mcPhotons.end(); mcPho++) {
1359     mcConvPt_ = (*mcPho).fourMomentum().et();
1360     float mcPhi = (*mcPho).fourMomentum().phi();
1361     mcPhi_ = phiNormalization(mcPhi);
1362     mcEta_ = (*mcPho).fourMomentum().pseudoRapidity();
1363     mcEta_ = etaTransformation(mcEta_, (*mcPho).primaryVertex().z());
1364     mcConvR_ = (*mcPho).vertex().perp();
1365     mcConvX_ = (*mcPho).vertex().x();
1366     mcConvY_ = (*mcPho).vertex().y();
1367     mcConvZ_ = (*mcPho).vertex().z();
1368     mcConvEta_ = (*mcPho).vertex().eta();
1369     mcConvPhi_ = (*mcPho).vertex().phi();
1370 
1371     if (fabs(mcEta_) > END_HI)
1372       continue;
1373 
1374     if (mcConvPt_ < minPhoPtForEffic)
1375       continue;
1376     if (fabs(mcEta_) > maxPhoEtaForEffic)
1377       continue;
1378     if (fabs(mcConvZ_) > maxPhoZForEffic)
1379       continue;
1380     if (mcConvR_ > maxPhoRForEffic)
1381       continue;
1382     ////////////////////////////////// extract info about simulated conversions
1383 
1384     bool goodSimConversion = false;
1385     bool visibleConversion = false;
1386     bool visibleConversionsWithTwoSimTracks = false;
1387     if ((*mcPho).isAConversion() == 1) {
1388       nSimConv_[0]++;
1389       h_AllSimConv_[0]->Fill(mcEta_);
1390       h_AllSimConv_[1]->Fill(mcPhi_);
1391       h_AllSimConv_[2]->Fill(mcConvR_);
1392       h_AllSimConv_[3]->Fill(mcConvZ_);
1393       h_AllSimConv_[4]->Fill((*mcPho).fourMomentum().et());
1394 
1395       if (mcConvR_ < 15)
1396         h_SimConvEtaPix_[0]->Fill(mcEta_);
1397 
1398       if ((fabs(mcEta_) <= BARL && mcConvR_ < 85) ||
1399           (fabs(mcEta_) > BARL && fabs(mcEta_) <= END_HI && fabs((*mcPho).vertex().z()) < 210))
1400         visibleConversion = true;
1401 
1402       theConvTP_.clear();
1403       //      std::cout << " TkConvValidator TrackingParticles   TrackingParticleCollection size "<<  trackingParticles.size() <<  "\n";
1404       //duplicated TP collections for two associations
1405       for (const TrackingParticleRef& tp : tpForEfficiency) {
1406         if (fabs(tp->vx() - (*mcPho).vertex().x()) < 0.0001 && fabs(tp->vy() - (*mcPho).vertex().y()) < 0.0001 &&
1407             fabs(tp->vz() - (*mcPho).vertex().z()) < 0.0001) {
1408           theConvTP_.push_back(tp);
1409         }
1410       }
1411       //std::cout << " TkConvValidator  theConvTP_ size " <<   theConvTP_.size() << std::endl;
1412 
1413       if (theConvTP_.size() == 2)
1414         visibleConversionsWithTwoSimTracks = true;
1415       goodSimConversion = false;
1416 
1417       if (visibleConversion && visibleConversionsWithTwoSimTracks)
1418         goodSimConversion = true;
1419       if (goodSimConversion) {
1420         nSimConv_[1]++;
1421         h_VisSimConv_[0]->Fill(mcEta_);
1422         h_VisSimConv_[1]->Fill(mcPhi_);
1423         h_VisSimConv_[2]->Fill(mcConvR_);
1424         h_VisSimConv_[3]->Fill(mcConvZ_);
1425         h_VisSimConv_[4]->Fill((*mcPho).fourMomentum().et());
1426       }
1427 
1428       for (edm::RefVector<TrackingParticleCollection>::iterator iTrk = theConvTP_.begin(); iTrk != theConvTP_.end();
1429            ++iTrk) {
1430         h_simTkPt_->Fill((*iTrk)->pt());
1431         h_simTkEta_->Fill((*iTrk)->eta());
1432       }
1433 
1434     }  ////////////// End of info from sim conversions //////////////////////////////////////////////////
1435 
1436     if (!(visibleConversion && visibleConversionsWithTwoSimTracks))
1437       continue;
1438 
1439     h_simConvVtxRvsZ_[0]->Fill(fabs(mcConvZ_), mcConvR_);
1440     if (fabs(mcEta_) <= 1.) {
1441       h_simConvVtxRvsZ_[1]->Fill(fabs(mcConvZ_), mcConvR_);
1442       h_simConvVtxYvsX_->Fill(mcConvX_, mcConvY_);
1443     } else
1444       h_simConvVtxRvsZ_[2]->Fill(fabs(mcConvZ_), mcConvR_);
1445 
1446     //std::cout << " TkConvValidator  theConvTP_ size " <<   theConvTP_.size() << std::endl;
1447     for (edm::RefVector<TrackingParticleCollection>::iterator iTP = theConvTP_.begin(); iTP != theConvTP_.end();
1448          iTP++) {
1449       //  std::cout << " SIM to RECO TP vertex " << (*iTP)->vx() << " " <<  (*iTP)->vy() << " " << (*iTP)->vz() << " pt " << (*iTP)->pt() << std::endl;
1450     }
1451 
1452     bool recomatch = false;
1453     float chi2Prob = 0.;
1454     //////////////////Measure reco efficiencies
1455     // cout << " size of conversions " << convHandle->size() << endl;
1456     for (reco::ConversionCollection::const_iterator conv = convHandle->begin(); conv != convHandle->end(); ++conv) {
1457       const reco::Conversion aConv = (*conv);
1458       if (arbitratedMerged_ && !aConv.quality(reco::Conversion::arbitratedMerged))
1459         continue;
1460       if (generalTracksOnly_ && !aConv.quality(reco::Conversion::generalTracksOnly))
1461         continue;
1462       if (arbitratedEcalSeeded_ && !aConv.quality(reco::Conversion::arbitratedEcalSeeded))
1463         continue;
1464 
1465       if (highPurity_ && !aConv.quality(reco::Conversion::highPurity))
1466         continue;
1467 
1468       //problematic?
1469       const std::vector<edm::RefToBase<reco::Track> >& tracks = aConv.tracks();
1470 
1471       const reco::Vertex& vtx = aConv.conversionVertex();
1472       //requires two tracks and a valid vertex
1473       if (tracks.size() != 2 || !(vtx.isValid()))
1474         continue;
1475 
1476       if (ChiSquaredProbability(aConv.conversionVertex().chi2(), aConv.conversionVertex().ndof()) <= minProb_)
1477         continue;
1478       if (aConv.nHitsBeforeVtx().size() > 1 &&
1479           max(aConv.nHitsBeforeVtx().at(0), aConv.nHitsBeforeVtx().at(1)) > maxHitsBeforeVtx_)
1480         continue;
1481 
1482       //compute transverse decay length with respect to beamspot
1483       math::XYZVectorF themom = aConv.refittedPairMomentum();
1484       double dbsx = aConv.conversionVertex().x() - thebs.x0();
1485       double dbsy = aConv.conversionVertex().y() - thebs.y0();
1486       double lxy = (themom.x() * dbsx + themom.y() * dbsy) / themom.rho();
1487 
1488       if (lxy < minLxy_)
1489         continue;
1490 
1491       //    bool  phoIsInBarrel=false; // unused
1492       //    bool  phoIsInEndcap=false; // unused
1493       RefToBase<reco::Track> tfrb1 = aConv.tracks().front();
1494       RefToBase<reco::Track> tfrb2 = aConv.tracks().back();
1495 
1496       if (ecalalgotracks_ && (!(tfrb1->algo() == reco::TrackBase::outInEcalSeededConv ||
1497                                 tfrb1->algo() == reco::TrackBase::inOutEcalSeededConv) ||
1498                               !(tfrb2->algo() == reco::TrackBase::outInEcalSeededConv ||
1499                                 tfrb2->algo() == reco::TrackBase::inOutEcalSeededConv)))
1500         continue;
1501 
1502       //reco::TrackRef tk1 = aConv.tracks().front();
1503       //reco::TrackRef tk2 = aConv.tracks().back();
1504       //std::cout << "SIM to RECO  conversion track pt " << tk1->pt() << " " << tk2->pt() << endl;
1505       //
1506       //Use two RefToBaseVector and do two association actions to avoid that if two tracks from different collection
1507       RefToBaseVector<reco::Track> tc1, tc2;
1508       tc1.push_back(tfrb1);
1509       tc2.push_back(tfrb2);
1510       bool isAssociated = false;
1511       reco::SimToRecoCollection q1 = theTrackAssociator->associateSimToReco(tc1, theConvTP_);
1512       reco::SimToRecoCollection q2 = theTrackAssociator->associateSimToReco(tc2, theConvTP_);
1513       //try {
1514       std::vector<std::pair<RefToBase<reco::Track>, double> > trackV1, trackV2;
1515 
1516       int tp_1 = 0, tp_2 = 1;  //the index of associated tp in theConvTP_ for two tracks
1517       if (q1.find(theConvTP_[0]) != q1.end()) {
1518         trackV1 = (std::vector<std::pair<RefToBase<reco::Track>, double> >)q1[theConvTP_[0]];
1519       } else if (q1.find(theConvTP_[1]) != q1.end()) {
1520         trackV1 = (std::vector<std::pair<RefToBase<reco::Track>, double> >)q1[theConvTP_[1]];
1521         tp_1 = 1;
1522       }
1523       if (q2.find(theConvTP_[1]) != q2.end()) {
1524         trackV2 = (std::vector<std::pair<RefToBase<reco::Track>, double> >)q2[theConvTP_[1]];
1525       } else if (q2.find(theConvTP_[0]) != q2.end()) {
1526         trackV2 = (std::vector<std::pair<RefToBase<reco::Track>, double> >)q2[theConvTP_[0]];
1527         tp_2 = 0;
1528       }
1529       if (!(!trackV1.empty() && !trackV2.empty()))
1530         continue;
1531       if (tp_1 == tp_2)
1532         continue;
1533 
1534       edm::RefToBase<reco::Track> tr1 = trackV1.front().first;
1535       edm::RefToBase<reco::Track> tr2 = trackV2.front().first;
1536       //std::cout << "associated tp1 " <<theConvTP_[0]->pt() << " to track with  pT=" << tr1->pt() << " " << (tr1.get())->pt() << endl;
1537       //std::cout << "associated tp2 " <<theConvTP_[1]->pt() << " to track with  pT=" << tr2->pt() << " " << (tr2.get())->pt() << endl;
1538       myAss.insert(std::make_pair(tr1.get(), theConvTP_[tp_1]));
1539       myAss.insert(std::make_pair(tr2.get(), theConvTP_[tp_2]));
1540 
1541       //} catch (Exception const& event) {
1542       //cout << "continue: " << event.what()  << endl;
1543       //  continue;
1544       //}
1545 
1546       isAssociated = true;
1547       recomatch = true;
1548       chi2Prob = ChiSquaredProbability(aConv.conversionVertex().chi2(), aConv.conversionVertex().ndof());
1549 
1550       if (isAssociated) {
1551         h_SimRecConvTwoMTracks_[0]->Fill(mcEta_);
1552         h_SimRecConvTwoMTracks_[1]->Fill(mcPhi_);
1553         h_SimRecConvTwoMTracks_[2]->Fill(mcConvR_);
1554         h_SimRecConvTwoMTracks_[3]->Fill(mcConvZ_);
1555         h_SimRecConvTwoMTracks_[4]->Fill((*mcPho).fourMomentum().et());
1556       }
1557 
1558       // break;
1559     }  // loop over reco conversions
1560     if (recomatch) {
1561       ////////// Numerators for conversion efficiencies, both tracks are associated
1562       h_SimConvTwoMTracks_[0]->Fill(mcEta_);
1563       h_SimConvTwoMTracks_[1]->Fill(mcPhi_);
1564       h_SimConvTwoMTracks_[2]->Fill(mcConvR_);
1565       h_SimConvTwoMTracks_[3]->Fill(mcConvZ_);
1566       h_SimConvTwoMTracks_[4]->Fill((*mcPho).fourMomentum().et());
1567 
1568       if (chi2Prob > 0) {
1569         h_SimConvTwoMTracksAndVtxPGT0_[0]->Fill(mcEta_);
1570         h_SimConvTwoMTracksAndVtxPGT0_[1]->Fill(mcPhi_);
1571         h_SimConvTwoMTracksAndVtxPGT0_[2]->Fill(mcConvR_);
1572         h_SimConvTwoMTracksAndVtxPGT0_[3]->Fill(mcConvZ_);
1573         h_SimConvTwoMTracksAndVtxPGT0_[4]->Fill((*mcPho).fourMomentum().et());
1574       }
1575       if (chi2Prob > 0.0005) {
1576         h_SimConvTwoMTracksAndVtxPGT0005_[0]->Fill(mcEta_);
1577         h_SimConvTwoMTracksAndVtxPGT0005_[1]->Fill(mcPhi_);
1578         h_SimConvTwoMTracksAndVtxPGT0005_[2]->Fill(mcConvR_);
1579         h_SimConvTwoMTracksAndVtxPGT0005_[3]->Fill(mcConvZ_);
1580         h_SimConvTwoMTracksAndVtxPGT0005_[4]->Fill((*mcPho).fourMomentum().et());
1581       }
1582     }
1583 
1584   }  //End loop over simulated conversions
1585 
1586   // ########################### RECO to SIM ############################## //
1587 
1588   for (reco::ConversionCollection::const_iterator conv = convHandle->begin(); conv != convHandle->end(); ++conv) {
1589     const reco::Conversion aConv = (*conv);
1590     if (arbitratedMerged_ && !aConv.quality(reco::Conversion::arbitratedMerged))
1591       continue;
1592     if (generalTracksOnly_ && !aConv.quality(reco::Conversion::generalTracksOnly))
1593       continue;
1594     if (arbitratedEcalSeeded_ && !aConv.quality(reco::Conversion::arbitratedEcalSeeded))
1595       continue;
1596 
1597     if (highPurity_ && !aConv.quality(reco::Conversion::highPurity))
1598       continue;
1599 
1600     //problematic?
1601     std::vector<edm::RefToBase<reco::Track> > tracks = aConv.tracks();
1602 
1603     const reco::Vertex& vtx = aConv.conversionVertex();
1604     //requires two tracks and a valid vertex
1605     if (tracks.size() != 2 || !(vtx.isValid()))
1606       continue;
1607     //if (tracks.size() !=2) continue;
1608 
1609     if (ChiSquaredProbability(aConv.conversionVertex().chi2(), aConv.conversionVertex().ndof()) <= minProb_)
1610       continue;
1611     if (aConv.nHitsBeforeVtx().size() > 1 &&
1612         max(aConv.nHitsBeforeVtx().at(0), aConv.nHitsBeforeVtx().at(1)) > maxHitsBeforeVtx_)
1613       continue;
1614 
1615     //compute transverse decay length with respect to beamspot
1616     math::XYZVectorF themom = aConv.refittedPairMomentum();
1617     double dbsx = aConv.conversionVertex().x() - thebs.x0();
1618     double dbsy = aConv.conversionVertex().y() - thebs.y0();
1619     double lxy = (themom.x() * dbsx + themom.y() * dbsy) / themom.rho();
1620 
1621     if (lxy < minLxy_)
1622       continue;
1623 
1624     bool phoIsInBarrel = false;
1625     bool phoIsInEndcap = false;
1626     RefToBase<reco::Track> tk1 = aConv.tracks().front();
1627     RefToBase<reco::Track> tk2 = aConv.tracks().back();
1628     RefToBaseVector<reco::Track> tc1, tc2;
1629     tc1.push_back(tk1);
1630     tc2.push_back(tk2);
1631 
1632     if (ecalalgotracks_ &&
1633         (!(tk1->algo() == reco::TrackBase::outInEcalSeededConv ||
1634            tk1->algo() == reco::TrackBase::inOutEcalSeededConv) ||
1635          !(tk2->algo() == reco::TrackBase::outInEcalSeededConv || tk2->algo() == reco::TrackBase::inOutEcalSeededConv)))
1636       continue;
1637 
1638     //std::cout << " RECO to SIM conversion track pt " << tk1->pt() << " " << tk2->pt() << endl;
1639     const reco::Track refTk1 = aConv.conversionVertex().refittedTracks().front();
1640     const reco::Track refTk2 = aConv.conversionVertex().refittedTracks().back();
1641 
1642     float dPhiTracksAtVtx;
1643     // override with the phi calculated at the vertex
1644     math::XYZVector p1AtVtx = recalculateMomentumAtFittedVertex((*theMF_), *trackerGeom, tk1, aConv.conversionVertex());
1645     math::XYZVector p2AtVtx = recalculateMomentumAtFittedVertex((*theMF_), *trackerGeom, tk2, aConv.conversionVertex());
1646     if (p1AtVtx.perp2() > p2AtVtx.perp2())
1647       dPhiTracksAtVtx = p1AtVtx.phi() - p2AtVtx.phi();
1648     else
1649       dPhiTracksAtVtx = p2AtVtx.phi() - p1AtVtx.phi();
1650 
1651     math::XYZVectorF refittedMom = aConv.refittedPairMomentum();
1652 
1653     if (fabs(refittedMom.eta()) < 1.479) {
1654       phoIsInBarrel = true;
1655     } else {
1656       phoIsInEndcap = true;
1657     }
1658 
1659     nRecConv_++;
1660 
1661     // check matching with reco photon
1662     double Mindeltaeta = 999999;
1663     double Mindeltaphi = 999999;
1664     bool matchConvSC = false;
1665     reco::PhotonCollection::const_iterator iMatchingSC;
1666     for (reco::PhotonCollection::const_iterator iPho = photonCollection.begin(); iPho != photonCollection.end();
1667          iPho++) {
1668       reco::Photon aPho = reco::Photon(*iPho);
1669       const double deltaphi = reco::deltaPhi(aConv.refittedPairMomentum().phi(), aPho.superCluster()->position().phi());
1670       double ConvEta = etaTransformation(aConv.refittedPairMomentum().eta(), aConv.zOfPrimaryVertexFromTracks());
1671       double deltaeta = abs(aPho.superCluster()->position().eta() - ConvEta);
1672       if (abs(deltaeta) < abs(Mindeltaeta) && abs(deltaphi) < abs(Mindeltaphi)) {
1673         Mindeltaphi = abs(deltaphi);
1674         Mindeltaeta = abs(deltaeta);
1675         iMatchingSC = iPho;
1676       }
1677     }
1678     if (abs(Mindeltaeta) < 0.1 && abs(Mindeltaphi) < 0.1) {
1679       matchConvSC = true;
1680     }
1681 
1682     ///////////  Quantities per conversion
1683     int match = 0;
1684     float invM = aConv.pairInvariantMass();
1685     float chi2Prob = ChiSquaredProbability(aConv.conversionVertex().chi2(), aConv.conversionVertex().ndof());
1686     uint maxNHitsBeforeVtx =
1687         aConv.nHitsBeforeVtx().size() > 1 ? max(aConv.nHitsBeforeVtx().at(0), aConv.nHitsBeforeVtx().at(1)) : 0;
1688     uint sumNHitsBeforeVtx =
1689         aConv.nHitsBeforeVtx().size() > 1 ? aConv.nHitsBeforeVtx().at(0) + aConv.nHitsBeforeVtx().at(1) : 0;
1690     float maxDlClosestHitToVtx = aConv.dlClosestHitToVtx().size() > 1 ? max(aConv.dlClosestHitToVtx().at(0).value(),
1691                                                                             aConv.dlClosestHitToVtx().at(1).value())
1692                                                                       : 0;
1693     float maxDlClosestHitToVtxSig =
1694         aConv.dlClosestHitToVtx().size() > 1
1695             ? max(aConv.dlClosestHitToVtx().at(0).value() / aConv.dlClosestHitToVtx().at(0).error(),
1696                   aConv.dlClosestHitToVtx().at(1).value() / aConv.dlClosestHitToVtx().at(1).error())
1697             : 0;
1698 
1699     int ilead = 0, itrail = 1;
1700     if (tk2->pt() > tk1->pt()) {
1701       ilead = 1;
1702       itrail = 0;
1703     }
1704     RefToBase<reco::Track> tklead = aConv.tracks().at(ilead);
1705     RefToBase<reco::Track> tktrail = aConv.tracks().at(itrail);
1706 
1707     int deltaExpectedHitsInner = tklead->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) -
1708                                  tktrail->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
1709     int leadExpectedHitsInner = tklead->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
1710     uint leadNHitsBeforeVtx = aConv.nHitsBeforeVtx().size() > 1 ? aConv.nHitsBeforeVtx().at(ilead) : 0;
1711     uint trailNHitsBeforeVtx = aConv.nHitsBeforeVtx().size() > 1 ? aConv.nHitsBeforeVtx().at(itrail) : 0;
1712 
1713     h_convEta_[match][0]->Fill(refittedMom.eta());
1714     h_convEta2_[match][0]->Fill(refittedMom.eta());
1715 
1716     h_convPhi_[match][0]->Fill(refittedMom.phi());
1717     h_convR_[match][0]->Fill(sqrt(aConv.conversionVertex().position().perp2()));
1718     h_convRplot_->Fill(sqrt(aConv.conversionVertex().position().perp2()));
1719     h_convZ_[match][0]->Fill(aConv.conversionVertex().position().z());
1720     h_convZplot_->Fill(aConv.conversionVertex().position().z());
1721     h_convPt_[match][0]->Fill(sqrt(refittedMom.perp2()));
1722     h_invMass_[match][0]->Fill(invM);
1723     h_vtxChi2Prob_[match][0]->Fill(chi2Prob);
1724     h_lxybs_[match][0]->Fill(lxy);
1725     h_maxNHitsBeforeVtx_[match][0]->Fill(maxNHitsBeforeVtx);
1726     h_leadNHitsBeforeVtx_[match][0]->Fill(leadNHitsBeforeVtx);
1727     h_trailNHitsBeforeVtx_[match][0]->Fill(trailNHitsBeforeVtx);
1728     h_sumNHitsBeforeVtx_[match][0]->Fill(sumNHitsBeforeVtx);
1729     h_deltaExpectedHitsInner_[match][0]->Fill(deltaExpectedHitsInner);
1730     h_leadExpectedHitsInner_[match][0]->Fill(leadExpectedHitsInner);
1731     h_maxDlClosestHitToVtx_[match][0]->Fill(maxDlClosestHitToVtx);
1732     h_maxDlClosestHitToVtxSig_[match][0]->Fill(maxDlClosestHitToVtxSig);
1733     h_nSharedHits_[match][0]->Fill(aConv.nSharedHits());
1734 
1735     if (matchConvSC) {
1736       h_convEtaMatchSC_[match][0]->Fill(refittedMom.eta());
1737       h_EoverPTracks_[match][0]->Fill(iMatchingSC->superCluster()->energy() / sqrt(refittedMom.mag2()));
1738       h_convSCdPhi_[match][0]->Fill(iMatchingSC->superCluster()->position().phi() - refittedMom.phi());
1739       double ConvEta = etaTransformation(aConv.refittedPairMomentum().eta(), aConv.zOfPrimaryVertexFromTracks());
1740       h_convSCdEta_[match][0]->Fill(iMatchingSC->superCluster()->position().eta() - ConvEta);
1741     }
1742 
1743     h_distMinAppTracks_[match][0]->Fill(aConv.distOfMinimumApproach());
1744     h_DPhiTracksAtVtx_[match][0]->Fill(dPhiTracksAtVtx);
1745     h2_DPhiTracksAtVtxVsEta_->Fill(mcEta_, dPhiTracksAtVtx);
1746     h2_DPhiTracksAtVtxVsR_->Fill(mcConvR_, dPhiTracksAtVtx);
1747     p_DPhiTracksAtVtxVsEta_->Fill(mcEta_, dPhiTracksAtVtx);
1748     p_DPhiTracksAtVtxVsR_->Fill(mcConvR_, dPhiTracksAtVtx);
1749 
1750     h_DCotTracks_[match][0]->Fill(aConv.pairCotThetaSeparation());
1751     h2_DCotTracksVsEta_->Fill(mcEta_, aConv.pairCotThetaSeparation());
1752     h2_DCotTracksVsR_->Fill(mcConvR_, aConv.pairCotThetaSeparation());
1753     p_DCotTracksVsEta_->Fill(mcEta_, aConv.pairCotThetaSeparation());
1754     p_DCotTracksVsR_->Fill(mcConvR_, aConv.pairCotThetaSeparation());
1755 
1756     if (phoIsInBarrel) {
1757       h_invMass_[match][1]->Fill(invM);
1758       h_vtxChi2Prob_[match][1]->Fill(chi2Prob);
1759       h_distMinAppTracks_[match][1]->Fill(aConv.distOfMinimumApproach());
1760       h_DPhiTracksAtVtx_[match][1]->Fill(dPhiTracksAtVtx);
1761       h_DCotTracks_[match][1]->Fill(aConv.pairCotThetaSeparation());
1762       h_lxybs_[match][1]->Fill(lxy);
1763       h_maxNHitsBeforeVtx_[match][1]->Fill(maxNHitsBeforeVtx);
1764       h_leadNHitsBeforeVtx_[match][1]->Fill(leadNHitsBeforeVtx);
1765       h_trailNHitsBeforeVtx_[match][1]->Fill(trailNHitsBeforeVtx);
1766       h_sumNHitsBeforeVtx_[match][1]->Fill(sumNHitsBeforeVtx);
1767       h_deltaExpectedHitsInner_[match][1]->Fill(deltaExpectedHitsInner);
1768       h_leadExpectedHitsInner_[match][1]->Fill(leadExpectedHitsInner);
1769       h_maxDlClosestHitToVtx_[match][1]->Fill(maxDlClosestHitToVtx);
1770       h_maxDlClosestHitToVtxSig_[match][1]->Fill(maxDlClosestHitToVtxSig);
1771       h_nSharedHits_[match][1]->Fill(aConv.nSharedHits());
1772 
1773       /*
1774       if ( aConv.caloCluster().size() ) {
1775     h_convSCdPhi_[match][1]->Fill(  aConv.caloCluster()[0]->phi() - refittedMom.phi() );
1776     double ConvEta = etaTransformation(aConv.refittedPairMomentum().eta(),aConv.zOfPrimaryVertexFromTracks());
1777     h_convSCdEta_[match][1]->Fill( aConv.caloCluster()[0]->eta() - ConvEta );
1778       }
1779       */
1780 
1781       if (matchConvSC) {
1782         h_EoverPTracks_[match][1]->Fill(iMatchingSC->superCluster()->energy() / sqrt(refittedMom.mag2()));
1783         h_convSCdPhi_[match][1]->Fill(iMatchingSC->superCluster()->position().phi() - refittedMom.phi());
1784         double ConvEta = etaTransformation(aConv.refittedPairMomentum().eta(), aConv.zOfPrimaryVertexFromTracks());
1785         h_convSCdEta_[match][1]->Fill(iMatchingSC->superCluster()->position().eta() - ConvEta);
1786       }
1787     }
1788 
1789     if (phoIsInEndcap) {
1790       h_invMass_[match][2]->Fill(invM);
1791       h_vtxChi2Prob_[match][2]->Fill(chi2Prob);
1792       h_distMinAppTracks_[match][2]->Fill(aConv.distOfMinimumApproach());
1793       h_DPhiTracksAtVtx_[match][2]->Fill(dPhiTracksAtVtx);
1794       h_DCotTracks_[match][2]->Fill(aConv.pairCotThetaSeparation());
1795       h_lxybs_[match][2]->Fill(lxy);
1796       h_maxNHitsBeforeVtx_[match][2]->Fill(maxNHitsBeforeVtx);
1797       h_leadNHitsBeforeVtx_[match][2]->Fill(leadNHitsBeforeVtx);
1798       h_trailNHitsBeforeVtx_[match][2]->Fill(trailNHitsBeforeVtx);
1799       h_sumNHitsBeforeVtx_[match][2]->Fill(sumNHitsBeforeVtx);
1800       h_deltaExpectedHitsInner_[match][2]->Fill(deltaExpectedHitsInner);
1801       h_leadExpectedHitsInner_[match][2]->Fill(leadExpectedHitsInner);
1802       h_maxDlClosestHitToVtx_[match][2]->Fill(maxDlClosestHitToVtx);
1803       h_maxDlClosestHitToVtxSig_[match][2]->Fill(maxDlClosestHitToVtxSig);
1804       h_nSharedHits_[match][2]->Fill(aConv.nSharedHits());
1805       if (matchConvSC) {
1806         h_EoverPTracks_[match][2]->Fill(iMatchingSC->superCluster()->energy() / sqrt(refittedMom.mag2()));
1807         h_convSCdPhi_[match][2]->Fill(iMatchingSC->superCluster()->position().phi() - refittedMom.phi());
1808         double ConvEta = etaTransformation(aConv.refittedPairMomentum().eta(), aConv.zOfPrimaryVertexFromTracks());
1809         h_convSCdEta_[match][2]->Fill(iMatchingSC->superCluster()->position().eta() - ConvEta);
1810       }
1811     }
1812 
1813     h_convVtxRvsZ_[0]->Fill(fabs(aConv.conversionVertex().position().z()),
1814                             sqrt(aConv.conversionVertex().position().perp2()));
1815     h_convVtxYvsX_->Fill(aConv.conversionVertex().position().x(), aConv.conversionVertex().position().y());
1816     h_convVtxYvsX_zoom_[0]->Fill(aConv.conversionVertex().position().x(), aConv.conversionVertex().position().y());
1817     h_convVtxYvsX_zoom_[1]->Fill(aConv.conversionVertex().position().x(), aConv.conversionVertex().position().y());
1818 
1819     // quantities per track: all conversions
1820     for (unsigned int i = 0; i < tracks.size(); i++) {
1821       double d0;
1822       if (valid_pvtx) {
1823         d0 = -tracks[i]->dxy(the_pvtx.position());
1824       } else {
1825         d0 = tracks[i]->d0();
1826       }
1827       h_TkD0_[match]->Fill(d0 * tracks[i]->charge());
1828       h_nHitsBeforeVtx_[match]->Fill(aConv.nHitsBeforeVtx().size() > 1 ? aConv.nHitsBeforeVtx().at(i) : 0);
1829       h_dlClosestHitToVtx_[match]->Fill(aConv.dlClosestHitToVtx().size() > 1 ? aConv.dlClosestHitToVtx().at(i).value()
1830                                                                              : 0);
1831       h_dlClosestHitToVtxSig_[match]->Fill(aConv.dlClosestHitToVtx().size() > 1
1832                                                ? aConv.dlClosestHitToVtx().at(i).value() /
1833                                                      aConv.dlClosestHitToVtx().at(i).error()
1834                                                : 0);
1835 
1836       nHitsVsEta_[match]->Fill(mcEta_, float(tracks[i]->numberOfValidHits()));
1837       nHitsVsR_[match]->Fill(mcConvR_, float(tracks[i]->numberOfValidHits()));
1838       p_nHitsVsEta_[match]->Fill(mcEta_, float(tracks[i]->numberOfValidHits()) - 0.0001);
1839       p_nHitsVsR_[match]->Fill(mcConvR_, float(tracks[i]->numberOfValidHits()) - 0.0001);
1840       h_tkChi2_[match]->Fill(tracks[i]->normalizedChi2());
1841       h_tkChi2Large_[match]->Fill(tracks[i]->normalizedChi2());
1842       h2_Chi2VsEta_[match]->Fill(mcEta_, tracks[i]->normalizedChi2());
1843       h2_Chi2VsR_[match]->Fill(mcConvR_, tracks[i]->normalizedChi2());
1844       p_Chi2VsEta_[match]->Fill(mcEta_, tracks[i]->normalizedChi2());
1845       p_Chi2VsR_[match]->Fill(mcConvR_, tracks[i]->normalizedChi2());
1846     }
1847 
1848     bool associated = false;
1849     float mcConvPt_ = -99999999.0;
1850     //    float mcPhi= 0; // unused
1851     float simPV_Z = 0;
1852     for (std::vector<PhotonMCTruth>::const_iterator mcPho = mcPhotons.begin(); mcPho != mcPhotons.end(); mcPho++) {
1853       mcConvPt_ = (*mcPho).fourMomentum().et();
1854       float mcPhi = (*mcPho).fourMomentum().phi();
1855       simPV_Z = (*mcPho).primaryVertex().z();
1856       mcPhi_ = phiNormalization(mcPhi);
1857       mcEta_ = (*mcPho).fourMomentum().pseudoRapidity();
1858       mcEta_ = etaTransformation(mcEta_, (*mcPho).primaryVertex().z());
1859       mcConvR_ = (*mcPho).vertex().perp();
1860       mcConvX_ = (*mcPho).vertex().x();
1861       mcConvY_ = (*mcPho).vertex().y();
1862       mcConvZ_ = (*mcPho).vertex().z();
1863       mcConvEta_ = (*mcPho).vertex().eta();
1864       mcConvPhi_ = (*mcPho).vertex().phi();
1865       if (fabs(mcEta_) > END_HI)
1866         continue;
1867       if (mcConvPt_ < minPhoPtForPurity)
1868         continue;
1869       if (fabs(mcEta_) > maxPhoEtaForPurity)
1870         continue;
1871       if (fabs(mcConvZ_) > maxPhoZForPurity)
1872         continue;
1873       if (mcConvR_ > maxPhoRForEffic)
1874         continue;
1875 
1876       if ((*mcPho).isAConversion() != 1)
1877         continue;
1878       if (!((fabs(mcEta_) <= BARL && mcConvR_ < 85) ||
1879             (fabs(mcEta_) > BARL && fabs(mcEta_) <= END_HI && fabs((*mcPho).vertex().z()) < 210)))
1880         continue;
1881 
1882       theConvTP_.clear();
1883       for (const TrackingParticleRef& tp : tpForFakeRate) {
1884         if (fabs(tp->vx() - (*mcPho).vertex().x()) < 0.0001 && fabs(tp->vy() - (*mcPho).vertex().y()) < 0.0001 &&
1885             fabs(tp->vz() - (*mcPho).vertex().z()) < 0.0001) {
1886           theConvTP_.push_back(tp);
1887         }
1888       }
1889 
1890       if (theConvTP_.size() < 2)
1891         continue;
1892 
1893       //associated = false;
1894       reco::RecoToSimCollection const& p1 = theTrackAssociator->associateRecoToSim(tc1, theConvTP_);
1895       reco::RecoToSimCollection const& p2 = theTrackAssociator->associateRecoToSim(tc2, theConvTP_);
1896 
1897       auto itP1 = p1.find(tk1);
1898       auto itP2 = p2.find(tk2);
1899       bool good = (itP1 != p1.end()) and (not itP1->val.empty()) and (itP2 != p2.end()) and (not itP2->val.empty());
1900       if (not good) {
1901         itP1 = p1.find(tk2);
1902         itP2 = p2.find(tk1);
1903         good = (itP1 != p1.end()) and (not itP1->val.empty()) and (itP2 != p2.end()) and (not itP2->val.empty());
1904       }
1905 
1906       if (good) {
1907         std::vector<std::pair<TrackingParticleRef, double> > const& tp1 = itP1->val;
1908         std::vector<std::pair<TrackingParticleRef, double> > const& tp2 = itP2->val;
1909         TrackingParticleRef tpr1 = tp1.front().first;
1910         TrackingParticleRef tpr2 = tp2.front().first;
1911         if (abs(tpr1->pdgId()) == 11 && abs(tpr2->pdgId()) == 11 && tpr1->pdgId() * tpr2->pdgId() < 0) {
1912           if ((tpr1->parentVertex()->sourceTracks_end() - tpr1->parentVertex()->sourceTracks_begin() == 1) &&
1913               (tpr2->parentVertex()->sourceTracks_end() - tpr2->parentVertex()->sourceTracks_begin() == 1)) {
1914             if (tpr1->parentVertex().key() == tpr2->parentVertex().key() &&
1915                 ((*tpr1->parentVertex()->sourceTracks_begin())->pdgId() == 22)) {
1916               mcConvR_ = sqrt(tpr1->parentVertex()->position().Perp2());
1917               mcConvZ_ = tpr1->parentVertex()->position().z();
1918               mcConvX_ = tpr1->parentVertex()->position().x();
1919               mcConvY_ = tpr1->parentVertex()->position().y();
1920               mcConvEta_ = tpr1->parentVertex()->position().eta();
1921               mcConvPhi_ = tpr1->parentVertex()->position().phi();
1922               mcConvPt_ = sqrt((*tpr1->parentVertex()->sourceTracks_begin())->momentum().Perp2());
1923               //std::cout << " Reco to Sim mcconvpt " << mcConvPt_ << std::endl;
1924               //cout << "associated track1 to " << tpr1->pdgId() << " with p=" << tpr1->p4() << " with pT=" << tpr1->pt() << endl;
1925               //cout << "associated track2 to " << tpr2->pdgId() << " with p=" << tpr2->p4() << " with pT=" << tpr2->pt() << endl;
1926               associated = true;
1927               break;
1928             }
1929           }
1930         }
1931       }
1932 
1933     }  // end loop on sim photons
1934 
1935     if (false) {
1936       theConvTP_.clear();
1937       theConvTP_ = tpForFakeRate;
1938       reco::RecoToSimCollection p1incl = theTrackAssociator->associateRecoToSim(tc1, theConvTP_);
1939       reco::RecoToSimCollection p2incl = theTrackAssociator->associateRecoToSim(tc2, theConvTP_);
1940 
1941       for (std::vector<PhotonMCTruth>::const_iterator mcPho = mcPhotons.begin(); mcPho != mcPhotons.end(); mcPho++) {
1942         mcConvPt_ = (*mcPho).fourMomentum().et();
1943         float mcPhi = (*mcPho).fourMomentum().phi();
1944         simPV_Z = (*mcPho).primaryVertex().z();
1945         mcPhi_ = phiNormalization(mcPhi);
1946         mcEta_ = (*mcPho).fourMomentum().pseudoRapidity();
1947         mcEta_ = etaTransformation(mcEta_, (*mcPho).primaryVertex().z());
1948         mcConvR_ = (*mcPho).vertex().perp();
1949         mcConvX_ = (*mcPho).vertex().x();
1950         mcConvY_ = (*mcPho).vertex().y();
1951         mcConvZ_ = (*mcPho).vertex().z();
1952         mcConvEta_ = (*mcPho).vertex().eta();
1953         mcConvPhi_ = (*mcPho).vertex().phi();
1954         if (fabs(mcEta_) > END_HI)
1955           continue;
1956         if (mcConvPt_ < minPhoPtForPurity)
1957           continue;
1958         if (fabs(mcEta_) > maxPhoEtaForPurity)
1959           continue;
1960         if (fabs(mcConvZ_) > maxPhoZForPurity)
1961           continue;
1962         if (mcConvR_ > maxPhoRForEffic)
1963           continue;
1964 
1965         if ((*mcPho).isAConversion() != 1)
1966           continue;
1967         if (!((fabs(mcEta_) <= BARL && mcConvR_ < 85) ||
1968               (fabs(mcEta_) > BARL && fabs(mcEta_) <= END_HI && fabs((*mcPho).vertex().z()) < 210)))
1969           continue;
1970 
1971         theConvTP_.clear();
1972         for (const TrackingParticleRef& tp : tpForFakeRate) {
1973           if (fabs(tp->vx() - (*mcPho).vertex().x()) < 0.0001 && fabs(tp->vy() - (*mcPho).vertex().y()) < 0.0001 &&
1974               fabs(tp->vz() - (*mcPho).vertex().z()) < 0.0001) {
1975             theConvTP_.push_back(tp);
1976           }
1977         }
1978 
1979         if (theConvTP_.size() < 2)
1980           continue;
1981 
1982         //associated = false;
1983         reco::RecoToSimCollection p1 = theTrackAssociator->associateRecoToSim(tc1, theConvTP_);
1984         reco::RecoToSimCollection p2 = theTrackAssociator->associateRecoToSim(tc2, theConvTP_);
1985 
1986         if ((!p1incl.empty() && !p2incl.empty()) && (!p1.empty() || !p2.empty())) {  // associated = true;
1987           try {
1988             std::vector<std::pair<TrackingParticleRef, double> > tp1 = p1incl[tk1];
1989             std::vector<std::pair<TrackingParticleRef, double> > tp2 = p2incl[tk2];
1990             if (!(!tp1.empty() && !tp2.empty())) {
1991               tp1 = p1[tk2];
1992               tp2 = p2[tk1];
1993             }
1994             if (!tp1.empty() && !tp2.empty()) {
1995               TrackingParticleRef tpr1 = tp1.front().first;
1996               TrackingParticleRef tpr2 = tp2.front().first;
1997               if (abs(tpr1->pdgId()) == 11 && abs(tpr2->pdgId()) == 11 && tpr1->pdgId() * tpr2->pdgId() < 0) {
1998                 if (((tpr1->parentVertex()->sourceTracks_end() - tpr1->parentVertex()->sourceTracks_begin() >= 1) &&
1999                      (*tpr1->parentVertex()->sourceTracks_begin())->pdgId() == 22) &&
2000                     ((tpr2->parentVertex()->sourceTracks_end() - tpr2->parentVertex()->sourceTracks_begin() >= 1) &&
2001                      (*tpr2->parentVertex()->sourceTracks_begin())->pdgId() == 22)) {
2002                   // if ( fabs(tpr1->vx() - tpr2->vx()) < 0.1 && fabs(tpr1->vy() - tpr2->vy()) < 0.1 && fabs(tpr1->vz() - tpr2->vz()) < 0.1) {
2003                   //if (((*tpr1->parentVertex()->sourceTracks_begin())->pdgId()==22) || ((*tpr2->parentVertex()->sourceTracks_begin())->pdgId()==22)) {
2004                   //                       mcConvR_ = sqrt(tpr1->parentVertex()->position().Perp2());
2005                   //                       mcConvZ_ = tpr1->parentVertex()->position().z();
2006                   //                       mcConvX_ = tpr1->parentVertex()->position().x();
2007                   //                       mcConvY_ = tpr1->parentVertex()->position().y();
2008                   //                       mcConvEta_ = tpr1->parentVertex()->position().eta();
2009                   //                       mcConvPhi_ = tpr1->parentVertex()->position().phi();
2010                   //                       mcConvPt_ = sqrt((*tpr1->parentVertex()->sourceTracks_begin())->momentum().Perp2());
2011                   //std::cout << " Reco to Sim mcconvpt " << mcConvPt_ << std::endl;
2012                   //cout << "associated track1 to " << tpr1->pdgId() << " with p=" << tpr1->p4() << " with pT=" << tpr1->pt() << endl;
2013                   //cout << "associated track2 to " << tpr2->pdgId() << " with p=" << tpr2->p4() << " with pT=" << tpr2->pt() << endl;
2014                   associated = true;
2015                   break;
2016                   //}
2017                   //}
2018                 }
2019               }
2020             }
2021           } catch (Exception const& event) {
2022             //cout << "do not continue: " << event.what()  << endl;
2023             //continue;
2024           }
2025         }
2026       }
2027     }
2028 
2029     if (associated)
2030       match = 1;
2031     else
2032       match = 2;
2033 
2034     h_match_->Fill(float(match));
2035     //////// here reco is matched to sim or is fake
2036     if (match == 1)
2037       nRecConvAss_++;
2038     h_convEta_[match][0]->Fill(refittedMom.eta());
2039     h_convEta_[match][1]->Fill(refittedMom.eta());
2040     if (matchConvSC)
2041       h_convEtaMatchSC_[match][0]->Fill(refittedMom.eta());
2042     h_convPhi_[match][0]->Fill(refittedMom.phi());
2043     h_convR_[match][0]->Fill(sqrt(aConv.conversionVertex().position().perp2()));
2044     h_convZ_[match][0]->Fill(aConv.conversionVertex().position().z());
2045     h_convPt_[match][0]->Fill(sqrt(refittedMom.perp2()));
2046     h_invMass_[match][0]->Fill(invM);
2047     h_vtxChi2Prob_[match][0]->Fill(chi2Prob);
2048     h_DPhiTracksAtVtx_[match][0]->Fill(dPhiTracksAtVtx);
2049     h_DCotTracks_[match][0]->Fill(aConv.pairCotThetaSeparation());
2050     h_distMinAppTracks_[match][0]->Fill(aConv.distOfMinimumApproach());
2051     h_lxybs_[match][0]->Fill(lxy);
2052     h_maxNHitsBeforeVtx_[match][0]->Fill(maxNHitsBeforeVtx);
2053     h_leadNHitsBeforeVtx_[match][0]->Fill(leadNHitsBeforeVtx);
2054     h_trailNHitsBeforeVtx_[match][0]->Fill(trailNHitsBeforeVtx);
2055     h_sumNHitsBeforeVtx_[match][0]->Fill(sumNHitsBeforeVtx);
2056     h_deltaExpectedHitsInner_[match][0]->Fill(deltaExpectedHitsInner);
2057     h_leadExpectedHitsInner_[match][0]->Fill(leadExpectedHitsInner);
2058     h_maxDlClosestHitToVtx_[match][0]->Fill(maxDlClosestHitToVtx);
2059     h_maxDlClosestHitToVtxSig_[match][0]->Fill(maxDlClosestHitToVtxSig);
2060     h_nSharedHits_[match][0]->Fill(aConv.nSharedHits());
2061     if (matchConvSC) {
2062       //h_EoverPTracks_[match][0] ->Fill (aConv.EoverPrefittedTracks());
2063       h_EoverPTracks_[match][0]->Fill(iMatchingSC->superCluster()->energy() / sqrt(refittedMom.mag2()));
2064       h_convSCdPhi_[match][0]->Fill(iMatchingSC->superCluster()->position().phi() - refittedMom.phi());
2065       double ConvEta = etaTransformation(aConv.refittedPairMomentum().eta(), aConv.zOfPrimaryVertexFromTracks());
2066       h_convSCdEta_[match][0]->Fill(iMatchingSC->superCluster()->position().eta() - ConvEta);
2067     }
2068     if (match == 1) {
2069       h2_photonPtRecVsPtSim_->Fill(mcConvPt_, sqrt(refittedMom.perp2()));
2070       h_convPtRes_[0]->Fill(sqrt(refittedMom.perp2()) / mcConvPt_);
2071     }
2072 
2073     if (phoIsInBarrel) {
2074       h_invMass_[match][1]->Fill(invM);
2075       h_vtxChi2Prob_[match][1]->Fill(chi2Prob);
2076       h_DPhiTracksAtVtx_[match][1]->Fill(dPhiTracksAtVtx);
2077       h_DCotTracks_[match][1]->Fill(aConv.pairCotThetaSeparation());
2078       h_distMinAppTracks_[match][1]->Fill(aConv.distOfMinimumApproach());
2079       h_lxybs_[match][1]->Fill(lxy);
2080       h_maxNHitsBeforeVtx_[match][1]->Fill(maxNHitsBeforeVtx);
2081       h_leadNHitsBeforeVtx_[match][1]->Fill(leadNHitsBeforeVtx);
2082       h_trailNHitsBeforeVtx_[match][1]->Fill(trailNHitsBeforeVtx);
2083       h_sumNHitsBeforeVtx_[match][1]->Fill(sumNHitsBeforeVtx);
2084       h_deltaExpectedHitsInner_[match][1]->Fill(deltaExpectedHitsInner);
2085       h_leadExpectedHitsInner_[match][1]->Fill(leadExpectedHitsInner);
2086       h_maxDlClosestHitToVtx_[match][1]->Fill(maxDlClosestHitToVtx);
2087       h_maxDlClosestHitToVtxSig_[match][1]->Fill(maxDlClosestHitToVtxSig);
2088       h_nSharedHits_[match][1]->Fill(aConv.nSharedHits());
2089       if (matchConvSC) {
2090         //  h_EoverPTracks_[match][1] ->Fill (aConv.EoverPrefittedTracks());
2091         h_EoverPTracks_[match][1]->Fill(iMatchingSC->superCluster()->energy() / sqrt(refittedMom.mag2()));
2092         h_convSCdPhi_[match][1]->Fill(iMatchingSC->superCluster()->position().phi() - refittedMom.phi());
2093         double ConvEta = etaTransformation(aConv.refittedPairMomentum().eta(), aConv.zOfPrimaryVertexFromTracks());
2094         h_convSCdEta_[match][1]->Fill(iMatchingSC->superCluster()->position().eta() - ConvEta);
2095       }
2096       if (match == 1)
2097         h_convPtRes_[1]->Fill(sqrt(refittedMom.perp2()) / mcConvPt_);
2098     }
2099 
2100     if (phoIsInEndcap) {
2101       h_invMass_[match][2]->Fill(invM);
2102       h_vtxChi2Prob_[match][2]->Fill(chi2Prob);
2103       h_DPhiTracksAtVtx_[match][2]->Fill(dPhiTracksAtVtx);
2104       h_DCotTracks_[match][2]->Fill(aConv.pairCotThetaSeparation());
2105       h_distMinAppTracks_[match][2]->Fill(aConv.distOfMinimumApproach());
2106       h_lxybs_[match][2]->Fill(lxy);
2107       h_maxNHitsBeforeVtx_[match][2]->Fill(maxNHitsBeforeVtx);
2108       h_leadNHitsBeforeVtx_[match][2]->Fill(leadNHitsBeforeVtx);
2109       h_trailNHitsBeforeVtx_[match][2]->Fill(trailNHitsBeforeVtx);
2110       h_sumNHitsBeforeVtx_[match][2]->Fill(sumNHitsBeforeVtx);
2111       h_deltaExpectedHitsInner_[match][2]->Fill(deltaExpectedHitsInner);
2112       h_leadExpectedHitsInner_[match][2]->Fill(leadExpectedHitsInner);
2113       h_maxDlClosestHitToVtx_[match][2]->Fill(maxDlClosestHitToVtx);
2114       h_maxDlClosestHitToVtxSig_[match][2]->Fill(maxDlClosestHitToVtxSig);
2115       h_nSharedHits_[match][2]->Fill(aConv.nSharedHits());
2116       if (matchConvSC) {
2117         //  h_EoverPTracks_[match][2] ->Fill (aConv.EoverPrefittedTracks());
2118         h_EoverPTracks_[match][2]->Fill(iMatchingSC->superCluster()->energy() / sqrt(refittedMom.mag2()));
2119         h_convSCdPhi_[match][2]->Fill(iMatchingSC->superCluster()->position().phi() - refittedMom.phi());
2120         double ConvEta = etaTransformation(aConv.refittedPairMomentum().eta(), aConv.zOfPrimaryVertexFromTracks());
2121         h_convSCdEta_[match][2]->Fill(iMatchingSC->superCluster()->position().eta() - ConvEta);
2122       }
2123       if (match == 1)
2124         h_convPtRes_[2]->Fill(sqrt(refittedMom.perp2()) / mcConvPt_);
2125     }
2126 
2127     if (match == 1) {
2128       h_convVtxdX_->Fill(aConv.conversionVertex().position().x() - mcConvX_);
2129       h_convVtxdY_->Fill(aConv.conversionVertex().position().y() - mcConvY_);
2130       h_convVtxdZ_->Fill(aConv.conversionVertex().position().z() - mcConvZ_);
2131       h_convVtxdR_->Fill(sqrt(aConv.conversionVertex().position().perp2()) - mcConvR_);
2132       h_convVtxdPhi_->Fill(aConv.conversionVertex().position().phi() - mcConvPhi_);
2133       h_convVtxdEta_->Fill(aConv.conversionVertex().position().eta() - mcConvEta_);
2134       h2_convVtxdRVsR_->Fill(mcConvR_, sqrt(aConv.conversionVertex().position().perp2()) - mcConvR_);
2135       h2_convVtxdRVsEta_->Fill(mcEta_, sqrt(aConv.conversionVertex().position().perp2()) - mcConvR_);
2136       p_convVtxdRVsR_->Fill(mcConvR_, sqrt(aConv.conversionVertex().position().perp2()) - mcConvR_);
2137       p_convVtxdRVsEta_->Fill(mcEta_, sqrt(aConv.conversionVertex().position().perp2()) - mcConvR_);
2138       p_convVtxdXVsX_->Fill(mcConvX_, aConv.conversionVertex().position().x() - mcConvX_);
2139       p_convVtxdYVsY_->Fill(mcConvY_, aConv.conversionVertex().position().y() - mcConvY_);
2140       p_convVtxdZVsZ_->Fill(mcConvZ_, aConv.conversionVertex().position().z() - mcConvZ_);
2141       p_convVtxdZVsR_->Fill(mcConvR_, aConv.conversionVertex().position().z() - mcConvZ_);
2142 
2143       float dR = sqrt(aConv.conversionVertex().position().perp2()) - mcConvR_;
2144       float dZ = aConv.conversionVertex().position().z() - mcConvZ_;
2145       p2_convVtxdRVsRZ_->Fill(mcConvZ_, mcConvR_, dR);
2146       p2_convVtxdZVsRZ_->Fill(mcConvZ_, mcConvR_, dZ);
2147 
2148       h2_convVtxRrecVsTrue_->Fill(mcConvR_, sqrt(aConv.conversionVertex().position().perp2()));
2149 
2150       h_zPVFromTracks_[match]->Fill(aConv.zOfPrimaryVertexFromTracks());
2151       h_dzPVFromTracks_[match]->Fill(aConv.zOfPrimaryVertexFromTracks() - simPV_Z);
2152       h2_dzPVVsR_->Fill(mcConvR_, aConv.zOfPrimaryVertexFromTracks() - simPV_Z);
2153       p_dzPVVsR_->Fill(mcConvR_, aConv.zOfPrimaryVertexFromTracks() - simPV_Z);
2154 
2155       if (phoIsInBarrel) {
2156         h_convVtxdX_barrel_->Fill(aConv.conversionVertex().position().x() - mcConvX_);
2157         h_convVtxdY_barrel_->Fill(aConv.conversionVertex().position().y() - mcConvY_);
2158         h_convVtxdZ_barrel_->Fill(aConv.conversionVertex().position().z() - mcConvZ_);
2159         h_convVtxdR_barrel_->Fill(sqrt(aConv.conversionVertex().position().perp2()) - mcConvR_);
2160       }
2161       if (phoIsInEndcap) {
2162         h_convVtxdX_endcap_->Fill(aConv.conversionVertex().position().x() - mcConvX_);
2163         h_convVtxdY_endcap_->Fill(aConv.conversionVertex().position().y() - mcConvY_);
2164         h_convVtxdZ_endcap_->Fill(aConv.conversionVertex().position().z() - mcConvZ_);
2165         h_convVtxdR_endcap_->Fill(sqrt(aConv.conversionVertex().position().perp2()) - mcConvR_);
2166       }
2167     }
2168 
2169     ///////////  Quantities per track when tracks are associated
2170     for (unsigned int i = 0; i < tracks.size(); i++) {
2171       //std::cout << " Loop over tracks  pt " << tracks[i]->pt() << std::endl;
2172       RefToBase<reco::Track> tfrb(aConv.tracks()[i]);
2173       itAss = myAss.find(tfrb.get());
2174 
2175       nHitsVsEta_[match]->Fill(mcEta_, float(tracks[i]->numberOfValidHits()));
2176       nHitsVsR_[match]->Fill(mcConvR_, float(tracks[i]->numberOfValidHits()));
2177       p_nHitsVsEta_[match]->Fill(mcEta_, float(tracks[i]->numberOfValidHits()) - 0.0001);
2178       p_nHitsVsR_[match]->Fill(mcConvR_, float(tracks[i]->numberOfValidHits()) - 0.0001);
2179       h_tkChi2_[match]->Fill(tracks[i]->normalizedChi2());
2180       h_tkChi2Large_[match]->Fill(tracks[i]->normalizedChi2());
2181       h2_Chi2VsEta_[match]->Fill(mcEta_, tracks[i]->normalizedChi2());
2182       h2_Chi2VsR_[match]->Fill(mcConvR_, tracks[i]->normalizedChi2());
2183       p_Chi2VsEta_[match]->Fill(mcEta_, tracks[i]->normalizedChi2());
2184       p_Chi2VsR_[match]->Fill(mcConvR_, tracks[i]->normalizedChi2());
2185       double d0;
2186       if (valid_pvtx) {
2187         d0 = -tracks[i]->dxy(the_pvtx.position());
2188       } else {
2189         d0 = tracks[i]->d0();
2190       }
2191       h_TkD0_[match]->Fill(d0 * tracks[i]->charge());
2192       h_nHitsBeforeVtx_[match]->Fill(aConv.nHitsBeforeVtx().size() > 1 ? aConv.nHitsBeforeVtx().at(i) : 0);
2193       h_dlClosestHitToVtx_[match]->Fill(aConv.dlClosestHitToVtx().size() > 1 ? aConv.dlClosestHitToVtx().at(i).value()
2194                                                                              : 0);
2195       h_dlClosestHitToVtxSig_[match]->Fill(aConv.dlClosestHitToVtx().size() > 1
2196                                                ? aConv.dlClosestHitToVtx().at(i).value() /
2197                                                      aConv.dlClosestHitToVtx().at(i).error()
2198                                                : 0);
2199 
2200       if (itAss == myAss.end())
2201         continue;
2202       reco::Track refTrack = aConv.conversionVertex().refittedTracks()[i];
2203 
2204       float simPt = sqrt(((*itAss).second)->momentum().perp2());
2205       float recPt = refTrack.pt();
2206       float ptres = recPt - simPt;
2207       //float pterror = aConv.tracks()[i]->ptError();
2208       float pterror = aConv.conversionVertex().refittedTracks()[i].ptError();
2209       h2_PtRecVsPtSim_[0]->Fill(simPt, recPt);
2210       h_TkPtPull_[0]->Fill(ptres / pterror);
2211       h2_TkPtPull_[0]->Fill(mcEta_, ptres / pterror);
2212 
2213       if (phoIsInBarrel) {
2214         h_TkPtPull_[1]->Fill(ptres / pterror);
2215         h2_PtRecVsPtSim_[1]->Fill(simPt, recPt);
2216       }
2217       if (phoIsInEndcap) {
2218         h_TkPtPull_[2]->Fill(ptres / pterror);
2219         h2_PtRecVsPtSim_[2]->Fill(simPt, recPt);
2220       }
2221     }  // end loop over track
2222 
2223   }  // loop over reco conversions
2224 
2225   h_nConv_[0][0]->Fill(float(nRecConv_));
2226   h_nConv_[1][0]->Fill(float(nRecConvAss_));
2227 }
2228 
2229 void TkConvValidator::endJob() {
2230   std::string outputFileName = parameters_.getParameter<std::string>("OutputFileName");
2231   if (!isRunCentrally_) {
2232     dbe_->save(outputFileName);
2233   }
2234 
2235   edm::LogInfo("TkConvValidator") << "Analyzed " << nEvt_ << "\n";
2236   // std::cout  << "::endJob Analyzed " << nEvt_ << " events " << " with total " << nPho_ << " Photons " << "\n";
2237   //  std::cout  << "TkConvValidator::endJob Analyzed " << nEvt_ << " events " << "\n";
2238 
2239   return;
2240 }
2241 
2242 math::XYZVector TkConvValidator::recalculateMomentumAtFittedVertex(const MagneticField& mf,
2243                                                                    const TrackerGeometry& trackerGeom,
2244                                                                    const edm::RefToBase<reco::Track>& tk,
2245                                                                    const reco::Vertex& vtx) {
2246   math::XYZVector result;
2247   Surface::RotationType rot;
2248   auto scp = new SimpleCylinderBounds(sqrt(vtx.position().perp2()) - 0.001f,
2249                                       sqrt(vtx.position().perp2()) + 0.001f,
2250                                       -fabs(vtx.position().z()),
2251                                       fabs(vtx.position().z()));
2252   ReferenceCountingPointer<Cylinder> theBarrel_(
2253       new Cylinder(Cylinder::computeRadius(*scp), Surface::PositionType(0, 0, 0), rot, scp));
2254 
2255   ReferenceCountingPointer<Disk> theDisk_(
2256       new Disk(Surface::PositionType(0, 0, vtx.position().z()),
2257                rot,
2258                new SimpleDiskBounds(0, sqrt(vtx.position().perp2()), -0.001, 0.001)));
2259 
2260   const TrajectoryStateOnSurface myTSOS = trajectoryStateTransform::innerStateOnSurface(*tk, trackerGeom, &mf);
2261   PropagatorWithMaterial propag(anyDirection, 0.000511, &mf);
2262   TrajectoryStateOnSurface stateAtVtx;
2263   stateAtVtx = propag.propagate(myTSOS, *theBarrel_);
2264   if (!stateAtVtx.isValid()) {
2265     stateAtVtx = propag.propagate(myTSOS, *theDisk_);
2266   }
2267   if (stateAtVtx.isValid()) {
2268     return math::XYZVector(double(stateAtVtx.globalMomentum().x()),
2269                            double(stateAtVtx.globalMomentum().y()),
2270                            double(stateAtVtx.globalMomentum().z()));
2271   } else {
2272     return math::XYZVector(0., 0., 0.);
2273   }
2274 }
2275 
2276 float TkConvValidator::phiNormalization(float& phi) {
2277   //---Definitions
2278   const float PI = 3.1415927;
2279   const float TWOPI = 2.0 * PI;
2280 
2281   if (phi > PI) {
2282     phi = phi - TWOPI;
2283   }
2284   if (phi < -PI) {
2285     phi = phi + TWOPI;
2286   }
2287 
2288   //  cout << " Float_t PHInormalization out " << PHI << endl;
2289   return phi;
2290 }
2291 
2292 float TkConvValidator::etaTransformation(float EtaParticle, float Zvertex) {
2293   //---Definitions
2294   const float PI = 3.1415927;
2295 
2296   //---Definitions for ECAL
2297   const float R_ECAL = 136.5;
2298   const float Z_Endcap = 328.0;
2299   const float etaBarrelEndcap = 1.479;
2300 
2301   //---ETA correction
2302 
2303   float Theta = 0.0;
2304   float ZEcal = R_ECAL * sinh(EtaParticle) + Zvertex;
2305 
2306   if (ZEcal != 0.0)
2307     Theta = atan(R_ECAL / ZEcal);
2308   if (Theta < 0.0)
2309     Theta = Theta + PI;
2310   float ETA = -log(tan(0.5 * Theta));
2311 
2312   if (fabs(ETA) > etaBarrelEndcap) {
2313     float Zend = Z_Endcap;
2314     if (EtaParticle < 0.0)
2315       Zend = -Zend;
2316     float Zlen = Zend - Zvertex;
2317     float RR = Zlen / sinh(EtaParticle);
2318     Theta = atan(RR / Zend);
2319     if (Theta < 0.0)
2320       Theta = Theta + PI;
2321     ETA = -log(tan(0.5 * Theta));
2322   }
2323   //---Return the result
2324   return ETA;
2325   //---end
2326 }