CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Validation/RecoEgamma/plugins/TkConvValidator.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 //
00003 #include "FWCore/ServiceRegistry/interface/Service.h"
00004 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00005 //
00006 #include "Validation/RecoEgamma/plugins/TkConvValidator.h"
00007 
00008 //
00009 #include "FWCore/Framework/interface/MakerMacros.h"
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 #include "FWCore/Utilities/interface/Exception.h"
00012 //
00013 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00014 #include "SimDataFormats/Track/interface/SimTrack.h"
00015 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00016 #include "SimDataFormats/Vertex/interface/SimVertex.h"
00017 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
00018 //
00019 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h"
00020 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
00021 #include "SimDataFormats/TrackingAnalysis/interface/TrackingVertexContainer.h"
00022 //
00023 #include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h"
00024 #include "SimTracker/Records/interface/TrackAssociatorRecord.h"
00025 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00026 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00027 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00028 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00029 //
00030 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00031 #include "TrackingTools/PatternTools/interface/TwoTrackMinimumDistance.h"
00032 #include "TrackingTools/TransientTrack/interface/TrackTransientTrack.h"
00033 //
00034 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
00035 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
00036 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00037 #include "CommonTools/Statistics/interface/ChiSquaredProbability.h"
00038 //
00039 #include "MagneticField/Engine/interface/MagneticField.h"
00040 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00041 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00042 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00043 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
00044 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00045 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00046 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00047 #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
00048 
00049 //
00050 #include "DataFormats/Common/interface/Handle.h"
00051 #include "DataFormats/TrackReco/interface/Track.h"
00052 #include "DataFormats/TrackReco/interface/TrackExtra.h"
00053 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00054 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
00055 #include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
00056 #include "DataFormats/EgammaCandidates/interface/Photon.h"
00057 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
00058 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00059 #include "DataFormats/TrackCandidate/interface/TrackCandidateCollection.h"
00060 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
00061 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00062 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00063 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00064 #include "DataFormats/CaloRecHit/interface/CaloCluster.h"
00065 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
00066 #include "DataFormats/DetId/interface/DetId.h"
00067 #include "DataFormats/JetReco/interface/GenJetCollection.h"
00068 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00069 #include "DataFormats/GeometrySurface/interface/BoundCylinder.h"
00070 #include "DataFormats/GeometrySurface/interface/BoundDisk.h"
00071 #include "DataFormats/GeometrySurface/interface/SimpleCylinderBounds.h"
00072 #include "DataFormats/GeometrySurface/interface/SimpleDiskBounds.h"
00073 #include "DataFormats/Math/interface/deltaPhi.h"
00074 
00075 //
00076 #include "RecoEgamma/EgammaMCTools/interface/PhotonMCTruthFinder.h"
00077 #include "RecoEgamma/EgammaMCTools/interface/PhotonMCTruth.h"
00078 #include "RecoEgamma/EgammaMCTools/interface/ElectronMCTruth.h"
00079 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h"
00080 #include "RecoCaloTools/MetaCollections/interface/CaloRecHitMetaCollections.h"
00081 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00082 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00083 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
00084 
00085 #include "RecoEgamma/EgammaPhotonAlgos/interface/ConversionHitChecker.h"
00086 
00087 //
00088 //
00089 #include "TFile.h"
00090 #include "TH1.h"
00091 #include "TH2.h"
00092 #include "TTree.h"
00093 #include "TVector3.h"
00094 #include "TProfile.h"
00095 //
00106 using namespace std;
00107 
00108 
00109 TkConvValidator::TkConvValidator( const edm::ParameterSet& pset )
00110   {
00111 
00112     fName_     = pset.getUntrackedParameter<std::string>("Name");
00113     verbosity_ = pset.getUntrackedParameter<int>("Verbosity");
00114     parameters_ = pset;
00115     
00116     photonCollectionProducer_ = pset.getParameter<std::string>("phoProducer");
00117     photonCollection_ = pset.getParameter<std::string>("photonCollection");
00118 
00119     conversionCollectionProducer_ = pset.getParameter<std::string>("convProducer");
00120     conversionCollection_ = pset.getParameter<std::string>("conversionCollection");
00121     // conversionTrackProducer_ = pset.getParameter<std::string>("trackProducer");
00122     dqmpath_ = pset.getParameter<std::string>("dqmpath");
00123     minPhoEtCut_ = pset.getParameter<double>("minPhoEtCut");
00124     generalTracksOnly_ = pset.getParameter<bool>("generalTracksOnly");
00125     arbitratedMerged_ = pset.getParameter<bool>("arbitratedMerged");
00126     arbitratedEcalSeeded_ = pset.getParameter<bool>("arbitratedEcalSeeded");
00127     ecalalgotracks_ = pset.getParameter<bool>("ecalalgotracks");
00128     highPurity_ = pset.getParameter<bool>("highPurity");
00129     minProb_ = pset.getParameter<double>("minProb");
00130     maxHitsBeforeVtx_ = pset.getParameter<uint>("maxHitsBeforeVtx");
00131     minLxy_           = pset.getParameter<double>("minLxy");
00132     isRunCentrally_=   pset.getParameter<bool>("isRunCentrally");
00133   }
00134 
00135 
00136 
00137 
00138 
00139 TkConvValidator::~TkConvValidator() {}
00140 
00141 
00142 
00143 
00144 void  TkConvValidator::beginJob() {
00145 
00146   nEvt_=0;
00147   nEntry_=0;
00148   nRecConv_=0;
00149   nRecConvAss_=0;
00150   nRecConvAssWithEcal_=0;
00151 
00152   nInvalidPCA_=0;
00153 
00154   dbe_ = 0;
00155   dbe_ = edm::Service<DQMStore>().operator->();
00156 
00157 
00158   double etMin = parameters_.getParameter<double>("etMin");
00159   double etMax = parameters_.getParameter<double>("etMax");
00160   int etBin = parameters_.getParameter<int>("etBin");
00161 
00162 
00163   double resMin = parameters_.getParameter<double>("resMin");
00164   double resMax = parameters_.getParameter<double>("resMax");
00165   int resBin = parameters_.getParameter<int>("resBin");
00166 
00167   double etaMin = parameters_.getParameter<double>("etaMin");
00168   double etaMax = parameters_.getParameter<double>("etaMax");
00169   int etaBin = parameters_.getParameter<int>("etaBin");
00170   int etaBin2 = parameters_.getParameter<int>("etaBin2");
00171 
00172 
00173   double phiMin = parameters_.getParameter<double>("phiMin");
00174   double phiMax = parameters_.getParameter<double>("phiMax");
00175   int    phiBin = parameters_.getParameter<int>("phiBin");
00176 
00177 
00178   double rMin = parameters_.getParameter<double>("rMin");
00179   double rMax = parameters_.getParameter<double>("rMax");
00180   int    rBin = parameters_.getParameter<int>("rBin");
00181 
00182   double zMin = parameters_.getParameter<double>("zMin");
00183   double zMax = parameters_.getParameter<double>("zMax");
00184   int    zBin = parameters_.getParameter<int>("zBin");
00185 
00186   double dPhiTracksMin = parameters_.getParameter<double>("dPhiTracksMin");
00187   double dPhiTracksMax = parameters_.getParameter<double>("dPhiTracksMax");
00188   int dPhiTracksBin = parameters_.getParameter<int>("dPhiTracksBin");
00189 
00190   double eoverpMin = parameters_.getParameter<double>("eoverpMin");
00191   double eoverpMax = parameters_.getParameter<double>("eoverpMax");
00192   int    eoverpBin = parameters_.getParameter<int>("eoverpBin");
00193 
00194 
00195   //  double dEtaTracksMin = parameters_.getParameter<double>("dEtaTracksMin");  // unused
00196   //  double dEtaTracksMax = parameters_.getParameter<double>("dEtaTracksMax"); // unused
00197   //  int    dEtaTracksBin = parameters_.getParameter<int>("dEtaTracksBin");  // unused
00198 
00199   double dCotTracksMin = parameters_.getParameter<double>("dCotTracksMin");
00200   double dCotTracksMax = parameters_.getParameter<double>("dCotTracksMax");
00201   int    dCotTracksBin = parameters_.getParameter<int>("dCotTracksBin");
00202 
00203 
00204   double chi2Min = parameters_.getParameter<double>("chi2Min");
00205   double chi2Max = parameters_.getParameter<double>("chi2Max");
00206 
00207 
00208   double rMinForXray = parameters_.getParameter<double>("rMinForXray");
00209   double rMaxForXray = parameters_.getParameter<double>("rMaxForXray");
00210   int    rBinForXray = parameters_.getParameter<int>("rBinForXray");
00211   double zMinForXray = parameters_.getParameter<double>("zMinForXray");
00212   double zMaxForXray = parameters_.getParameter<double>("zMaxForXray");
00213   int    zBinForXray = parameters_.getParameter<int>("zBinForXray");
00214   int    zBin2ForXray = parameters_.getParameter<int>("zBin2ForXray");
00215 
00216   minPhoPtForEffic = parameters_.getParameter<double>("minPhoPtForEffic");
00217   maxPhoEtaForEffic = parameters_.getParameter<double>("maxPhoEtaForEffic");
00218   maxPhoZForEffic = parameters_.getParameter<double>("maxPhoZForEffic");
00219   maxPhoRForEffic = parameters_.getParameter<double>("maxPhoRForEffic");
00220   minPhoPtForPurity = parameters_.getParameter<double>("minPhoPtForPurity");
00221   maxPhoEtaForPurity = parameters_.getParameter<double>("maxPhoEtaForPurity");
00222   maxPhoZForPurity = parameters_.getParameter<double>("maxPhoZForPurity");
00223   maxPhoRForPurity = parameters_.getParameter<double>("maxPhoRForPurity");
00224 
00225   if (dbe_) {
00226 
00228     // SC from reco photons
00229 
00230     //TString simfolder = TString(
00231     std::string simpath = dqmpath_ + "SimulationInfo";
00232     dbe_->setCurrentFolder(simpath);
00233     //
00234     // simulation information about conversions
00236     std::string histname = "nOfSimConversions";
00237     h_nSimConv_[0] = dbe_->book1D(histname,"# of Sim conversions per event ",20,-0.5,19.5);
00239     histname = "h_AllSimConvEta";
00240     h_AllSimConv_[0] =  dbe_->book1D(histname," All conversions: simulated #eta",etaBin2,etaMin,etaMax);
00241     histname = "h_AllSimConvPhi";
00242     h_AllSimConv_[1] =  dbe_->book1D(histname," All conversions: simulated #phi",phiBin,phiMin,phiMax);
00243     histname = "h_AllSimConvR";
00244     h_AllSimConv_[2] =  dbe_->book1D(histname," All conversions: simulated R",rBin,rMin,rMax);
00245     histname = "h_AllSimConvZ";
00246     h_AllSimConv_[3] =  dbe_->book1D(histname," All conversions: simulated Z",zBin,zMin,zMax);
00247     histname = "h_AllSimConvEt";
00248     h_AllSimConv_[4] =  dbe_->book1D(histname," All conversions: simulated Et",etBin,etMin,etMax);
00249     //
00250     histname = "nOfVisSimConversions";
00251     h_nSimConv_[1] = dbe_->book1D(histname,"# of Sim conversions per event ",20,-0.5,19.5);
00252     histname = "h_VisSimConvEta";
00253     h_VisSimConv_[0] =  dbe_->book1D(histname," All vis conversions: simulated #eta",etaBin2,etaMin, etaMax);
00254     histname = "h_VisSimConvPhi";
00255     h_VisSimConv_[1] =  dbe_->book1D(histname," All vis conversions: simulated #phi",phiBin,phiMin, phiMax);
00256     histname = "h_VisSimConvR";
00257     h_VisSimConv_[2] =  dbe_->book1D(histname," All vis conversions: simulated R",rBin,rMin,rMax);
00258     histname = "h_VisSimConvZ";
00259     h_VisSimConv_[3] =  dbe_->book1D(histname," All vis conversions: simulated Z",zBin,zMin, zMax);
00260     histname = "h_VisSimConvEt";
00261     h_VisSimConv_[4] =  dbe_->book1D(histname," All vis conversions: simulated Et",etBin,etMin, etMax);
00262 
00263     //
00264     histname = "h_SimConvTwoMTracksEta";
00265     h_SimConvTwoMTracks_[0] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated #eta",etaBin2,etaMin, etaMax);
00266     histname = "h_SimConvTwoMTracksPhi";
00267     h_SimConvTwoMTracks_[1] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated #phi",phiBin,phiMin, phiMax);
00268     histname = "h_SimConvTwoMTracksR";
00269     h_SimConvTwoMTracks_[2] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated R",rBin,rMin, rMax);
00270     histname = "h_SimConvTwoMTracksZ";
00271     h_SimConvTwoMTracks_[3] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated Z",zBin,zMin, zMax);
00272     histname = "h_SimConvTwoMTracksEt";
00273     h_SimConvTwoMTracks_[4] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated Et",etBin,etMin, etMax);
00274     //
00275     histname = "h_SimConvTwoTracksEta";
00276     h_SimConvTwoTracks_[0] =  dbe_->book1D(histname," All vis conversions with 2 reco  tracks: simulated #eta",etaBin2,etaMin, etaMax);
00277     histname = "h_SimConvTwoTracksPhi";
00278     h_SimConvTwoTracks_[1] =  dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated #phi",phiBin,phiMin, phiMax);
00279     histname = "h_SimConvTwoTracksR";
00280     h_SimConvTwoTracks_[2] =  dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated R",rBin,rMin, rMax);
00281     histname = "h_SimConvTwoTracksZ";
00282     h_SimConvTwoTracks_[3] =  dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated Z",zBin,zMin, zMax);
00283     histname = "h_SimConvTwoTracksEt";
00284     h_SimConvTwoTracks_[4] =  dbe_->book1D(histname," All vis conversions with 2 reco tracks: simulated Et",etBin,etMin, etMax);
00285     //
00286     histname = "h_SimConvTwoMTracksEtaAndVtxPGT0";
00287     h_SimConvTwoMTracksAndVtxPGT0_[0] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated #eta",etaBin2,etaMin, etaMax);
00288     histname = "h_SimConvTwoMTracksPhiAndVtxPGT0";
00289     h_SimConvTwoMTracksAndVtxPGT0_[1] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated #phi",phiBin,phiMin, phiMax);
00290     histname = "h_SimConvTwoMTracksRAndVtxPGT0";
00291     h_SimConvTwoMTracksAndVtxPGT0_[2] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated R",rBin,rMin, rMax);
00292     histname = "h_SimConvTwoMTracksZAndVtxPGT0";
00293     h_SimConvTwoMTracksAndVtxPGT0_[3] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated Z",zBin,zMin, zMax);
00294     histname = "h_SimConvTwoMTracksEtAndVtxPGT0";
00295     h_SimConvTwoMTracksAndVtxPGT0_[4] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated Et",etBin,etMin, etMax);
00296 
00297     //
00298     histname = "h_SimConvTwoMTracksEtaAndVtxPGT0005";
00299     h_SimConvTwoMTracksAndVtxPGT0005_[0] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated #eta",etaBin2,etaMin, etaMax);
00300     histname = "h_SimConvTwoMTracksPhiAndVtxPGT0005";
00301     h_SimConvTwoMTracksAndVtxPGT0005_[1] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated #phi",phiBin,phiMin, phiMax);
00302     histname = "h_SimConvTwoMTracksRAndVtxPGT0005";
00303     h_SimConvTwoMTracksAndVtxPGT0005_[2] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated R",rBin,rMin, rMax);
00304     histname = "h_SimConvTwoMTracksZAndVtxPGT0005";
00305     h_SimConvTwoMTracksAndVtxPGT0005_[3] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated Z",zBin,zMin, zMax);
00306     histname = "h_SimConvTwoMTracksEtAndVtxPGT0005";
00307     h_SimConvTwoMTracksAndVtxPGT0005_[4] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks + vertex: simulated Et",etBin,etMin, etMax);
00308 
00309     histname = "h_SimRecConvTwoMTracksEta";
00310     h_SimRecConvTwoMTracks_[0] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated #eta",etaBin2,etaMin, etaMax);
00311     histname = "h_SimRecConvTwoMTracksPhi";
00312     h_SimRecConvTwoMTracks_[1] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated #phi",phiBin,phiMin, phiMax);
00313     histname = "h_SimRecConvTwoMTracksR";
00314     h_SimRecConvTwoMTracks_[2] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated R",rBin,rMin, rMax);
00315     histname = "h_SimRecConvTwoMTracksZ";
00316     h_SimRecConvTwoMTracks_[3] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated Z",zBin,zMin, zMax);
00317     histname = "h_SimRecConvTwoMTracksEt";
00318     h_SimRecConvTwoMTracks_[4] =  dbe_->book1D(histname," All vis conversions with 2 reco-matching tracks: simulated Et",etBin,etMin, etMax);
00319     //
00320 
00321 
00322     h_SimConvEtaPix_[0] = dbe_->book1D("simConvEtaPix"," sim converted Photon Eta: Pix ",etaBin,etaMin, etaMax) ;
00323     h_simTkPt_ = dbe_->book1D("simTkPt","Sim conversion tracks pt ",etBin*3,0.,etMax);
00324     h_simTkEta_ = dbe_->book1D("simTkEta","Sim conversion tracks eta ",etaBin,etaMin,etaMax);
00325 
00326     h_simConvVtxRvsZ_[0] =   dbe_->book2D("simConvVtxRvsZAll"," Photon Sim conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
00327     h_simConvVtxRvsZ_[1] =   dbe_->book2D("simConvVtxRvsZBarrel"," Photon Sim conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
00328     h_simConvVtxRvsZ_[2] =   dbe_->book2D("simConvVtxRvsZEndcap"," Photon Sim conversion vtx position",zBin2ForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
00329     h_simConvVtxRvsZ_[3] =   dbe_->book2D("simConvVtxRvsZBarrel2"," Photon Sim conversion vtx position when reco R<4cm",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
00330     h_simConvVtxYvsX_ =   dbe_->book2D("simConvVtxYvsXTrkBarrel"," Photon Sim conversion vtx position, (x,y) eta<1 ",100, -80., 80., 100, -80., 80.);
00331 
00332     std::string convpath = dqmpath_ + "ConversionInfo";
00333     dbe_->setCurrentFolder(convpath);
00334 
00335     histname="nConv";
00336     h_nConv_[0][0] = dbe_->book1D(histname+"All","Number Of Conversions per isolated candidates per events: All Ecal  ",10,-0.5, 9.5);
00337     h_nConv_[0][1] = dbe_->book1D(histname+"Barrel","Number Of Conversions per isolated candidates per events: Ecal Barrel  ",10,-0.5, 9.5);
00338     h_nConv_[0][2] = dbe_->book1D(histname+"Endcap","Number Of Conversions per isolated candidates per events: Ecal Endcap ",10,-0.5, 9.5);
00339     h_nConv_[1][0] = dbe_->book1D(histname+"All_Ass","Number Of associated Conversions per isolated candidates per events: All Ecal  ",10,-0.5, 9.5);
00340 
00341     h_convEta_[0][0] = dbe_->book1D("convEta"," converted Photon  Eta ",etaBin,etaMin, etaMax) ;
00342     h_convEtaMatchSC_[0][0] = dbe_->book1D("convEtaMatchSC"," converted Photon  Eta when SC is matched ",etaBin,etaMin, etaMax) ;
00343     h_convEta2_[0][0] = dbe_->book1D("convEta2"," converted Photon  Eta ",etaBin2,etaMin, etaMax) ;
00344     h_convPhi_[0][0] = dbe_->book1D("convPhi"," converted Photon  Phi ",phiBin,phiMin,phiMax) ;
00345     h_convR_[0][0]  =  dbe_->book1D("convR"," converted photon R",rBin,rMin, rMax);
00346     h_convZ_[0][0] =  dbe_->book1D("convZ"," converted photon Z",zBin,zMin, zMax);
00347     h_convPt_[0][0] = dbe_->book1D("convPt","  conversions Transverse Energy: all eta ", etBin,etMin, etMax);
00348 
00349     h_convEta_[1][0] = dbe_->book1D("convEtaAss2"," Matched converted Photon  Eta ",etaBin2,etaMin, etaMax) ;
00350     h_convEta_[1][1] = dbe_->book1D("convEtaAss"," Matched converted Photon  Eta ",etaBin,etaMin, etaMax) ;
00351     h_convEtaMatchSC_[1][0] = dbe_->book1D("convEtaMatchSCAss"," converted Photon  Eta when SC is matched ",etaBin,etaMin, etaMax) ;
00352     h_convPhi_[1][0] = dbe_->book1D("convPhiAss"," Matched converted Photon  Phi ",phiBin,phiMin,phiMax) ;
00353     h_convR_[1][0]  =  dbe_->book1D("convRAss"," Matched converted photon R",rBin,rMin, rMax);
00354     h_convZ_[1][0] =  dbe_->book1D("convZAss"," Matched converted photon Z",zBin,zMin, zMax);
00355     h_convPt_[1][0] = dbe_->book1D("convPtAss","Matched conversions Transverse Energy: all eta ", etBin,etMin, etMax);
00356 
00357     h_convEta_[2][0] = dbe_->book1D("convEtaFake2"," Fake converted Photon  Eta ",etaBin2,etaMin, etaMax) ;
00358     h_convEta_[2][1] = dbe_->book1D("convEtaFake"," Fake converted Photon  Eta ",etaBin,etaMin, etaMax) ;
00359     h_convEtaMatchSC_[2][0] = dbe_->book1D("convEtaMatchSCFake"," converted Photon  Eta when SC is matched ",etaBin,etaMin, etaMax) ;
00360     h_convPhi_[2][0] = dbe_->book1D("convPhiFake"," Fake converted Photon  Phi ",phiBin,phiMin,phiMax) ;
00361     h_convR_[2][0]  =  dbe_->book1D("convRFake"," Fake converted photon R",rBin,rMin, rMax);
00362     h_convZ_[2][0] =  dbe_->book1D("convZFake"," Fake converted photon Z",zBin,zMin, zMax);
00363     h_convPt_[2][0] = dbe_->book1D("convPtFake","Fake conversions Transverse Energy: all eta ", etBin,etMin, etMax);
00364 
00365     h_convRplot_  =  dbe_->book1D("convRplot"," converted photon R",600, 0.,120.);
00366     h_convZplot_  =  dbe_->book1D("convZplot"," converted photon Z",320,-160.,160.);
00367 
00368     histname = "convSCdPhi";
00369     h_convSCdPhi_[0][0] =   dbe_->book1D(histname+"All","dPhi between SC and conversion",100, -0.1,0.1);
00370     h_convSCdPhi_[0][1] =   dbe_->book1D(histname+"Barrel"," dPhi between SC and conversion: Barrel",100, -0.1,0.1);
00371     h_convSCdPhi_[0][2] =   dbe_->book1D(histname+"Endcap"," dPhi between SC and conversion: Endcap",100, -0.1,0.1);
00372     h_convSCdPhi_[1][0] =   dbe_->book1D(histname+"All_Ass","dPhi between SC and conversion",100, -0.1,0.1);
00373     h_convSCdPhi_[1][1] =   dbe_->book1D(histname+"Barrel_Ass"," dPhi between SC and conversion: Barrel",100, -0.1,0.1);
00374     h_convSCdPhi_[1][2] =   dbe_->book1D(histname+"Endcap_Ass"," dPhi between SC and conversion: Endcap",100, -0.1,0.1);
00375     h_convSCdPhi_[2][0] =   dbe_->book1D(histname+"All_Fakes","dPhi between SC and conversion",100, -0.1,0.1);
00376     h_convSCdPhi_[2][1] =   dbe_->book1D(histname+"Barrel_Fakes"," dPhi between SC and conversion: Barrel",100, -0.1,0.1);
00377     h_convSCdPhi_[2][2] =   dbe_->book1D(histname+"Endcap_Fakes"," dPhi between SC and conversion: Endcap",100, -0.1,0.1);
00378     histname = "convSCdEta";
00379     h_convSCdEta_[0][0] =   dbe_->book1D(histname+"All"," dEta between SC and conversion",100, -0.1,0.1);
00380     h_convSCdEta_[0][1] =   dbe_->book1D(histname+"Barrel"," dEta between SC and conversion: Barrel",100, -0.1,0.1);
00381     h_convSCdEta_[0][2] =   dbe_->book1D(histname+"Endcap"," dEta between SC and conversion: Endcap",100, -0.1,0.1);
00382     h_convSCdEta_[1][0] =   dbe_->book1D(histname+"All_Ass"," dEta between SC and conversion",100, -0.1,0.1);
00383     h_convSCdEta_[1][1] =   dbe_->book1D(histname+"Barrel_Ass"," dEta between SC and conversion: Barrel",100, -0.1,0.1);
00384     h_convSCdEta_[1][2] =   dbe_->book1D(histname+"Endcap_Ass"," dEta between SC and conversion: Endcap",100, -0.1,0.1);
00385     h_convSCdEta_[2][0] =   dbe_->book1D(histname+"All_Fakes"," dEta between SC and conversion",100, -0.1,0.1);
00386     h_convSCdEta_[2][1] =   dbe_->book1D(histname+"Barrel_Fakes"," dEta between SC and conversion: Barrel",100, -0.1,0.1);
00387     h_convSCdEta_[2][2] =   dbe_->book1D(histname+"Endcap_Fakes"," dEta between SC and conversion: Endcap",100, -0.1,0.1);
00388 
00389     histname = "convPtRes";
00390     h_convPtRes_[0] = dbe_->book1D(histname+"All"," Conversion Pt rec/true : All ecal ", resBin,resMin, resMax);
00391     h_convPtRes_[1] = dbe_->book1D(histname+"Barrel"," Conversion Pt rec/true : Barrel ",resBin,resMin, resMax);
00392     h_convPtRes_[2] = dbe_->book1D(histname+"Endcap"," Conversion Pt rec/true : Endcap ",resBin,resMin, resMax);
00393 
00394 
00395     histname="hInvMass";
00396     h_invMass_[0][0]= dbe_->book1D(histname+"All_AllTracks"," Photons:Tracks from conversion: Pair invariant mass: all Ecal ",100, 0., 1.5);
00397     h_invMass_[0][1]= dbe_->book1D(histname+"Barrel_AllTracks"," Photons:Tracks from conversion: Pair invariant mass: Barrel Ecal ",100, 0., 1.5);
00398     h_invMass_[0][2]= dbe_->book1D(histname+"Endcap_AllTracks"," Photons:Tracks from conversion: Pair invariant mass: Endcap Ecal ",100, 0., 1.5);
00399     //
00400     h_invMass_[1][0]= dbe_->book1D(histname+"All_AssTracks"," Photons:Tracks from conversion: Pair invariant mass: all Ecal ",100, 0., 1.5);
00401     h_invMass_[1][1]= dbe_->book1D(histname+"Barrel_AssTracks"," Photons:Tracks from conversion: Pair invariant mass: Barrel Ecal ",100, 0., 1.5);
00402     h_invMass_[1][2]= dbe_->book1D(histname+"Endcap_AssTracks"," Photons:Tracks from conversion: Pair invariant mass: Endcap Ecal ",100, 0., 1.5);
00403     //
00404     h_invMass_[2][0]= dbe_->book1D(histname+"All_FakeTracks"," Photons:Tracks from conversion: Pair invariant mass: all Ecal ",100, 0., 1.5);
00405     h_invMass_[2][1]= dbe_->book1D(histname+"Barrel_FakeTracks"," Photons:Tracks from conversion: Pair invariant mass: Barrel Ecal ",100, 0., 1.5);
00406     h_invMass_[2][2]= dbe_->book1D(histname+"Endcap_FaleTracks"," Photons:Tracks from conversion: Pair invariant mass: Endcap Ecal ",100, 0., 1.5);
00407 
00408 
00409 
00410     histname="hDPhiTracksAtVtx";
00411     h_DPhiTracksAtVtx_[0][0] =dbe_->book1D(histname+"All", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: all Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
00412     h_DPhiTracksAtVtx_[0][1] =dbe_->book1D(histname+"Barrel", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Barrel Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
00413     h_DPhiTracksAtVtx_[0][2] =dbe_->book1D(histname+"Endcap", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Endcap Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
00414     h_DPhiTracksAtVtx_[1][0] =dbe_->book1D(histname+"All_Ass", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: all Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
00415     h_DPhiTracksAtVtx_[1][1] =dbe_->book1D(histname+"Barrel_Ass", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Barrel Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
00416     h_DPhiTracksAtVtx_[1][2] =dbe_->book1D(histname+"Endcap_Ass", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Endcap Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
00417     h_DPhiTracksAtVtx_[2][0] =dbe_->book1D(histname+"All_Fakes", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: all Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
00418     h_DPhiTracksAtVtx_[2][1] =dbe_->book1D(histname+"Barrel_Fakes", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Barrel Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
00419     h_DPhiTracksAtVtx_[2][2] =dbe_->book1D(histname+"Endcap_Fakes", " Photons:Tracks from conversions: #delta#phi Tracks at vertex: Endcap Ecal",dPhiTracksBin,dPhiTracksMin,dPhiTracksMax);
00420 
00421 
00422 
00423     histname="hDPhiTracksAtVtxVsEta";
00424     h2_DPhiTracksAtVtxVsEta_ = dbe_->book2D(histname+"All","  Photons:Tracks from conversions: #delta#phi Tracks at vertex vs #eta",etaBin2,etaMin, etaMax,100, -0.5, 0.5);
00425     histname="pDPhiTracksAtVtxVsEta";
00426     p_DPhiTracksAtVtxVsEta_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions: #delta#phi Tracks at vertex vs #eta ",etaBin2,etaMin, etaMax, 100, -0.5, 0.5,"");
00427 
00428     histname="hDPhiTracksAtVtxVsR";
00429     h2_DPhiTracksAtVtxVsR_ = dbe_->book2D(histname+"All","  Photons:Tracks from conversions: #delta#phi Tracks at vertex vs R",rBin,rMin, rMax,100, -0.5, 0.5);
00430     histname="pDPhiTracksAtVtxVsR";
00431     p_DPhiTracksAtVtxVsR_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions: #delta#phi Tracks at vertex vs R ",rBin,rMin, rMax,100, -0.5, 0.5,"");
00432 
00433 
00434     histname="hDCotTracks";
00435     h_DCotTracks_[0][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: all Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
00436     h_DCotTracks_[0][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Barrel Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
00437     h_DCotTracks_[0][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Endcap Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
00438     h_DCotTracks_[1][0]= dbe_->book1D(histname+"All_Ass"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: all Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
00439     h_DCotTracks_[1][1]= dbe_->book1D(histname+"Barrel_Ass"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Barrel Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
00440     h_DCotTracks_[1][2]= dbe_->book1D(histname+"Endcap_Ass"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Endcap Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
00441     h_DCotTracks_[2][0]= dbe_->book1D(histname+"All_Fakes"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: all Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
00442     h_DCotTracks_[2][1]= dbe_->book1D(histname+"Barrel_Fakes"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Barrel Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
00443     h_DCotTracks_[2][2]= dbe_->book1D(histname+"Endcap_Fakes"," Photons:Tracks from conversions #delta cotg(#Theta) Tracks: Endcap Ecal ",dCotTracksBin,dCotTracksMin,dCotTracksMax);
00444 
00445 
00446     histname="hDCotTracksVsEta";
00447     h2_DCotTracksVsEta_ = dbe_->book2D(histname+"All","  Photons:Tracks from conversions:  #delta cotg(#Theta) Tracks vs #eta",etaBin2,etaMin, etaMax,100, -0.2, 0.2);
00448     histname="pDCotTracksVsEta";
00449     p_DCotTracksVsEta_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions:  #delta cotg(#Theta) Tracks vs #eta ",etaBin2,etaMin, etaMax, 100, -0.2, 0.2,"");
00450 
00451     histname="hDCotTracksVsR";
00452     h2_DCotTracksVsR_ = dbe_->book2D(histname+"All","  Photons:Tracks from conversions:  #delta cotg(#Theta)  Tracks at vertex vs R",rBin,rMin, rMax,100, -0.2, 0.2);
00453     histname="pDCotTracksVsR";
00454     p_DCotTracksVsR_ = dbe_->bookProfile(histname+"All"," Photons:Tracks from conversions:  #delta cotg(#Theta) Tracks at vertex vs R ",rBin,rMin, rMax,100, -0.2, 0.2,"");
00455 
00456 
00457     histname="hDistMinAppTracks";
00458     h_distMinAppTracks_[0][0]= dbe_->book1D(histname+"All"," Photons:Tracks from conversions Min Approach Dist Tracks: all Ecal ",120, -0.5, 1.0);
00459     h_distMinAppTracks_[0][1]= dbe_->book1D(histname+"Barrel"," Photons:Tracks from conversions Min Approach Dist Tracks: Barrel Ecal ",120, -0.5, 1.0);
00460     h_distMinAppTracks_[0][2]= dbe_->book1D(histname+"Endcap"," Photons:Tracks from conversions Min Approach Dist Tracks: Endcap Ecal ",120, -0.5, 1.0);
00461     h_distMinAppTracks_[1][0]= dbe_->book1D(histname+"All_Ass"," Photons:Tracks from conversions Min Approach Dist Tracks: all Ecal ",120, -0.5, 1.0);
00462     h_distMinAppTracks_[1][1]= dbe_->book1D(histname+"Barrel_Ass"," Photons:Tracks from conversions Min Approach Dist Tracks: Barrel Ecal ",120, -0.5, 1.0);
00463     h_distMinAppTracks_[1][2]= dbe_->book1D(histname+"Endcap_Ass"," Photons:Tracks from conversions Min Approach Dist Tracks: Endcap Ecal ",120, -0.5, 1.0);
00464     h_distMinAppTracks_[2][0]= dbe_->book1D(histname+"All_Fakes"," Photons:Tracks from conversions Min Approach Dist Tracks: all Ecal ",120, -0.5, 1.0);
00465     h_distMinAppTracks_[2][1]= dbe_->book1D(histname+"Barrel_Fakes"," Photons:Tracks from conversions Min Approach Dist Tracks: Barrel Ecal ",120, -0.5, 1.0);
00466     h_distMinAppTracks_[2][2]= dbe_->book1D(histname+"Endcap_Fakes"," Photons:Tracks from conversions Min Approach Dist Tracks: Endcap Ecal ",120, -0.5, 1.0);
00467 
00468 
00469     h_convVtxRvsZ_[0] =   dbe_->book2D("convVtxRvsZAll"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
00470     h_convVtxRvsZ_[1] =   dbe_->book2D("convVtxRvsZBarrel"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
00471     h_convVtxRvsZ_[2] =   dbe_->book2D("convVtxRvsZEndcap"," Photon Reco conversion vtx position",zBin2ForXray, zMinForXray, zMaxForXray, rBinForXray, rMinForXray, rMaxForXray);
00472     h_convVtxYvsX_ =   dbe_->book2D("convVtxYvsXTrkBarrel"," Photon Reco conversion vtx position, (x,y) eta<1 ", 1000, -60., 60., 1000, -60., 60.);
00474     h_convVtxRvsZ_zoom_[0] =  dbe_->book2D("convVtxRvsZBarrelZoom1"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, -10., 40.);
00475     h_convVtxRvsZ_zoom_[1] =  dbe_->book2D("convVtxRvsZBarrelZoom2"," Photon Reco conversion vtx position",zBinForXray, zMinForXray, zMaxForXray, rBinForXray, -10., 20.);
00476     h_convVtxYvsX_zoom_[0] =   dbe_->book2D("convVtxYvsXTrkBarrelZoom1"," Photon Reco conversion vtx position, (x,y) eta<1 ",100, -40., 40., 100, -40., 40.);
00477     h_convVtxYvsX_zoom_[1] =   dbe_->book2D("convVtxYvsXTrkBarrelZoom2"," Photon Reco conversion vtx position, (x,y) eta<1 ",100, -20., 20., 100, -20., 20.);
00478 
00479     h_convVtxdR_ =   dbe_->book1D("convVtxdR"," Photon Reco conversion vtx dR",100, -10.,10.);
00480     h_convVtxdX_ =   dbe_->book1D("convVtxdX"," Photon Reco conversion vtx dX",100, -10.,10.);
00481     h_convVtxdY_ =   dbe_->book1D("convVtxdY"," Photon Reco conversion vtx dY",100, -10.,10.);
00482     h_convVtxdZ_ =   dbe_->book1D("convVtxdZ"," Photon Reco conversion vtx dZ",100, -20.,20.);
00483 
00484     h_convVtxdPhi_ =   dbe_->book1D("convVtxdPhi"," Photon Reco conversion vtx dPhi",100, -0.01,0.01);
00485     h_convVtxdEta_ =   dbe_->book1D("convVtxdEta"," Photon Reco conversion vtx dEta",100, -0.5,0.5);
00486 
00487     h_convVtxdR_barrel_ =   dbe_->book1D("convVtxdR_barrel"," Photon Reco conversion vtx dR, |eta|<=1.2",100, -10.,10.);
00488     h_convVtxdX_barrel_ =   dbe_->book1D("convVtxdX_barrel"," Photon Reco conversion vtx dX, |eta|<=1.2",100, -10.,10.);
00489     h_convVtxdY_barrel_ =   dbe_->book1D("convVtxdY_barrel"," Photon Reco conversion vtx dY, |eta|<=1.2 ",100, -10.,10.);
00490     h_convVtxdZ_barrel_ =   dbe_->book1D("convVtxdZ_barrel"," Photon Reco conversion vtx dZ, |eta|<=1.2,",100, -20.,20.);
00491 
00492     h_convVtxdR_endcap_ =   dbe_->book1D("convVtxdR_endcap"," Photon Reco conversion vtx dR,  |eta|>1.2 ",100, -10.,10.);
00493     h_convVtxdX_endcap_ =   dbe_->book1D("convVtxdX_endcap"," Photon Reco conversion vtx dX,  |eta|>1.2",100, -10.,10.);
00494     h_convVtxdY_endcap_ =   dbe_->book1D("convVtxdY_endcap"," Photon Reco conversion vtx dY,  |eta|>1.2",100, -10.,10.);
00495     h_convVtxdZ_endcap_ =   dbe_->book1D("convVtxdZ_endcap"," Photon Reco conversion vtx dZ,  |eta|>1.2",100, -20.,20.);
00496 
00497 
00498 
00499     h2_convVtxdRVsR_ =  dbe_->book2D("h2ConvVtxdRVsR"," Conversion vtx dR vsR" ,rBin,rMin, rMax,100, -20.,20.);
00500     h2_convVtxdRVsEta_ =  dbe_->book2D("h2ConvVtxdRVsEta","Conversion vtx dR vs Eta" ,etaBin2,etaMin, etaMax,100, -20.,20.);
00501 
00502     p_convVtxdRVsR_ =  dbe_->bookProfile("pConvVtxdRVsR"," Conversion vtx dR vsR" ,rBin,rMin, rMax ,100, -20.,20., "");
00503     p_convVtxdRVsEta_ =  dbe_->bookProfile("pConvVtxdRVsEta","Conversion vtx dR vs Eta" ,etaBin2,etaMin, etaMax, 100, -20.,20., "");
00504     p_convVtxdXVsX_ =  dbe_->bookProfile("pConvVtxdXVsX","Conversion vtx dX vs X" ,120,-60, 60 ,100, -20.,20., "");
00505     p_convVtxdYVsY_ =  dbe_->bookProfile("pConvVtxdYVsY","Conversion vtx dY vs Y" ,120,-60, 60 ,100, -20.,20., "");
00506     p_convVtxdZVsZ_ =  dbe_->bookProfile("pConvVtxdZVsZ","Conversion vtx dZ vs Z" ,zBin,zMin,zMax ,100, -20.,20., "");
00507 
00508     p_convVtxdZVsR_ =  dbe_->bookProfile("pConvVtxdZVsR","Conversion vtx dZ vs R" ,rBin,rMin,rMax ,100, -20.,20., "");
00509     p2_convVtxdRVsRZ_ =  dbe_->bookProfile2D("p2ConvVtxdRVsRZ","Conversion vtx dR vs RZ" ,zBin,zMin, zMax,rBin,rMin,rMax,100, 0.,20.,"s");
00510     p2_convVtxdZVsRZ_ =  dbe_->bookProfile2D("p2ConvVtxdZVsRZ","Conversion vtx dZ vs RZ" ,zBin,zMin, zMax,rBin,rMin,rMax,100, 0.,20.,"s");
00511 
00512 
00513     histname="EoverPtracks";
00514     h_EoverPTracks_[0][0] = dbe_->book1D(histname+"All"," photons conversion E/p: all Ecal ",       eoverpBin, eoverpMin, eoverpMax );
00515     h_EoverPTracks_[0][1] = dbe_->book1D(histname+"Barrel"," photons conversion E/p: Barrel Ecal",  eoverpBin, eoverpMin,  eoverpMax);
00516     h_EoverPTracks_[0][2] = dbe_->book1D(histname+"Endcap"," photons conversion E/p: Endcap Ecal ", eoverpBin, eoverpMin,  eoverpMax);
00517     h_EoverPTracks_[1][0] = dbe_->book1D(histname+"All_Ass"," photons conversion E/p: all Ecal ",   eoverpBin, eoverpMin,  eoverpMax);
00518     h_EoverPTracks_[1][1] = dbe_->book1D(histname+"Barrel_Ass"," photons conversion E/p: Barrel Ecal", eoverpBin, eoverpMin,  eoverpMax);
00519     h_EoverPTracks_[1][2] = dbe_->book1D(histname+"Endcap_Ass"," photons conversion E/p: Endcap Ecal ", eoverpBin, eoverpMin,  eoverpMax);
00520     h_EoverPTracks_[2][0] = dbe_->book1D(histname+"All_Fakes"," photons conversion E/p: all Ecal ",     eoverpBin, eoverpMin,  eoverpMax);
00521     h_EoverPTracks_[2][1] = dbe_->book1D(histname+"Barrel_Fakes"," photons conversion E/p: Barrel Ecal", eoverpBin, eoverpMin,  eoverpMax);
00522     h_EoverPTracks_[2][2] = dbe_->book1D(histname+"Endcap_Fakes"," photons conversion E/p: Endcap Ecal ", eoverpBin, eoverpMin,  eoverpMax);
00523 
00524 
00525     h2_convVtxRrecVsTrue_ =  dbe_->book2D("h2ConvVtxRrecVsTrue","Photon Reco conversion vtx R rec vs true" ,rBin,rMin, rMax,rBin,rMin, rMax);
00526 
00527     histname="vtxChi2Prob";
00528     h_vtxChi2Prob_[0][0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 100, 0., 1.);
00529     h_vtxChi2Prob_[0][1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 100, 0., 1.);
00530     h_vtxChi2Prob_[0][2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 100, 0., 1.);
00531     h_vtxChi2Prob_[1][0] = dbe_->book1D(histname+"All_Ass","vertex #chi^{2} all", 100, 0., 1.);
00532     h_vtxChi2Prob_[1][1] = dbe_->book1D(histname+"Barrel_Ass","vertex #chi^{2} barrel", 100, 0., 1.);
00533     h_vtxChi2Prob_[1][2] = dbe_->book1D(histname+"Endcap_Ass","vertex #chi^{2} endcap", 100, 0., 1.);
00534     h_vtxChi2Prob_[2][0] = dbe_->book1D(histname+"All_Fakes","vertex #chi^{2} all", 100, 0., 1.);
00535     h_vtxChi2Prob_[2][1] = dbe_->book1D(histname+"Barrel_Fakes","vertex #chi^{2} barrel", 100, 0., 1.);
00536     h_vtxChi2Prob_[2][2] = dbe_->book1D(histname+"Endcap_Fakes","vertex #chi^{2} endcap", 100, 0., 1.);
00537 
00538 
00539     h_zPVFromTracks_[1] =  dbe_->book1D("zPVFromTracks"," Photons: PV z from conversion tracks",100, -25., 25.);
00540     h_dzPVFromTracks_[1] =  dbe_->book1D("dzPVFromTracks"," Photons: PV Z_rec - Z_true from conversion tracks",100, -5., 5.);
00541     h2_dzPVVsR_ =  dbe_->book2D("h2dzPVVsR","Photon Reco conversions: dz(PV) vs R" ,rBin,rMin, rMax,100, -3.,3.);
00542     p_dzPVVsR_ =  dbe_->bookProfile("pdzPVVsR","Photon Reco conversions: dz(PV) vs R" ,rBin,rMin, rMax, 100, -3.,3.,"");
00543 
00544 
00545     histname="lxybs";
00546     h_lxybs_[0][0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 200, -100., 100.);
00547     h_lxybs_[0][1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 200, -100., 100.);
00548     h_lxybs_[0][2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 200, -100., 100.);
00549     h_lxybs_[1][0] = dbe_->book1D(histname+"All_Ass","vertex #chi^{2} all", 200, -100., 100.);
00550     h_lxybs_[1][1] = dbe_->book1D(histname+"Barrel_Ass","vertex #chi^{2} barrel", 200, -100., 100.);
00551     h_lxybs_[1][2] = dbe_->book1D(histname+"Endcap_Ass","vertex #chi^{2} endcap", 200, -100., 100.);
00552     h_lxybs_[2][0] = dbe_->book1D(histname+"All_Fakes","vertex #chi^{2} all", 200, -100., 100.);
00553     h_lxybs_[2][1] = dbe_->book1D(histname+"Barrel_Fakes","vertex #chi^{2} barrel", 200, -100., 100.);
00554     h_lxybs_[2][2] = dbe_->book1D(histname+"Endcap_Fakes","vertex #chi^{2} endcap", 200, -100., 100.);
00555 
00556     histname="maxNHitsBeforeVtx";
00557     h_maxNHitsBeforeVtx_[0][0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 16, -0.5, 15.5);
00558     h_maxNHitsBeforeVtx_[0][1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00559     h_maxNHitsBeforeVtx_[0][2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00560     h_maxNHitsBeforeVtx_[1][0] = dbe_->book1D(histname+"All_Ass","vertex #chi^{2} all", 16, -0.5, 15.5);
00561     h_maxNHitsBeforeVtx_[1][1] = dbe_->book1D(histname+"Barrel_Ass","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00562     h_maxNHitsBeforeVtx_[1][2] = dbe_->book1D(histname+"Endcap_Ass","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00563     h_maxNHitsBeforeVtx_[2][0] = dbe_->book1D(histname+"All_Fakes","vertex #chi^{2} all", 16, -0.5, 15.5);
00564     h_maxNHitsBeforeVtx_[2][1] = dbe_->book1D(histname+"Barrel_Fakes","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00565     h_maxNHitsBeforeVtx_[2][2] = dbe_->book1D(histname+"Endcap_Fakes","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00566 
00567     histname="leadNHitsBeforeVtx";
00568     h_leadNHitsBeforeVtx_[0][0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 16, -0.5, 15.5);
00569     h_leadNHitsBeforeVtx_[0][1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00570     h_leadNHitsBeforeVtx_[0][2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00571     h_leadNHitsBeforeVtx_[1][0] = dbe_->book1D(histname+"All_Ass","vertex #chi^{2} all", 16, -0.5, 15.5);
00572     h_leadNHitsBeforeVtx_[1][1] = dbe_->book1D(histname+"Barrel_Ass","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00573     h_leadNHitsBeforeVtx_[1][2] = dbe_->book1D(histname+"Endcap_Ass","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00574     h_leadNHitsBeforeVtx_[2][0] = dbe_->book1D(histname+"All_Fakes","vertex #chi^{2} all", 16, -0.5, 15.5);
00575     h_leadNHitsBeforeVtx_[2][1] = dbe_->book1D(histname+"Barrel_Fakes","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00576     h_leadNHitsBeforeVtx_[2][2] = dbe_->book1D(histname+"Endcap_Fakes","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00577 
00578     histname="trailNHitsBeforeVtx";
00579     h_trailNHitsBeforeVtx_[0][0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 16, -0.5, 15.5);
00580     h_trailNHitsBeforeVtx_[0][1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00581     h_trailNHitsBeforeVtx_[0][2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00582     h_trailNHitsBeforeVtx_[1][0] = dbe_->book1D(histname+"All_Ass","vertex #chi^{2} all", 16, -0.5, 15.5);
00583     h_trailNHitsBeforeVtx_[1][1] = dbe_->book1D(histname+"Barrel_Ass","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00584     h_trailNHitsBeforeVtx_[1][2] = dbe_->book1D(histname+"Endcap_Ass","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00585     h_trailNHitsBeforeVtx_[2][0] = dbe_->book1D(histname+"All_Fakes","vertex #chi^{2} all", 16, -0.5, 15.5);
00586     h_trailNHitsBeforeVtx_[2][1] = dbe_->book1D(histname+"Barrel_Fakes","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00587     h_trailNHitsBeforeVtx_[2][2] = dbe_->book1D(histname+"Endcap_Fakes","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00588 
00589     histname="sumNHitsBeforeVtx";
00590     h_sumNHitsBeforeVtx_[0][0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 16, -0.5, 15.5);
00591     h_sumNHitsBeforeVtx_[0][1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00592     h_sumNHitsBeforeVtx_[0][2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00593     h_sumNHitsBeforeVtx_[1][0] = dbe_->book1D(histname+"All_Ass","vertex #chi^{2} all", 16, -0.5, 15.5);
00594     h_sumNHitsBeforeVtx_[1][1] = dbe_->book1D(histname+"Barrel_Ass","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00595     h_sumNHitsBeforeVtx_[1][2] = dbe_->book1D(histname+"Endcap_Ass","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00596     h_sumNHitsBeforeVtx_[2][0] = dbe_->book1D(histname+"All_Fakes","vertex #chi^{2} all", 16, -0.5, 15.5);
00597     h_sumNHitsBeforeVtx_[2][1] = dbe_->book1D(histname+"Barrel_Fakes","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00598     h_sumNHitsBeforeVtx_[2][2] = dbe_->book1D(histname+"Endcap_Fakes","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00599 
00600     histname="maxDlClosestHitToVtx";
00601     h_maxDlClosestHitToVtx_[0][0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 100, -10., 10.);
00602     h_maxDlClosestHitToVtx_[0][1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 100, -10., 10.);
00603     h_maxDlClosestHitToVtx_[0][2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 100, -10., 10.);
00604     h_maxDlClosestHitToVtx_[1][0] = dbe_->book1D(histname+"All_Ass","vertex #chi^{2} all", 100, -10., 10.);
00605     h_maxDlClosestHitToVtx_[1][1] = dbe_->book1D(histname+"Barrel_Ass","vertex #chi^{2} barrel", 100, -10., 10.);
00606     h_maxDlClosestHitToVtx_[1][2] = dbe_->book1D(histname+"Endcap_Ass","vertex #chi^{2} endcap", 100, -10., 10.);
00607     h_maxDlClosestHitToVtx_[2][0] = dbe_->book1D(histname+"All_Fakes","vertex #chi^{2} all", 100, -10., 10.);
00608     h_maxDlClosestHitToVtx_[2][1] = dbe_->book1D(histname+"Barrel_Fakes","vertex #chi^{2} barrel", 100, -10., 10.);
00609     h_maxDlClosestHitToVtx_[2][2] = dbe_->book1D(histname+"Endcap_Fakes","vertex #chi^{2} endcap", 100, -10., 10.);
00610 
00611     histname="maxDlClosestHitToVtxSig";
00612     h_maxDlClosestHitToVtxSig_[0][0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 100, -8., 8.);
00613     h_maxDlClosestHitToVtxSig_[0][1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 100, -8., 8.);
00614     h_maxDlClosestHitToVtxSig_[0][2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 100, -8., 8.);
00615     h_maxDlClosestHitToVtxSig_[1][0] = dbe_->book1D(histname+"All_Ass","vertex #chi^{2} all", 100, -8., 8.);
00616     h_maxDlClosestHitToVtxSig_[1][1] = dbe_->book1D(histname+"Barrel_Ass","vertex #chi^{2} barrel", 100, -8., 8.);
00617     h_maxDlClosestHitToVtxSig_[1][2] = dbe_->book1D(histname+"Endcap_Ass","vertex #chi^{2} endcap", 100, -8., 8.);
00618     h_maxDlClosestHitToVtxSig_[2][0] = dbe_->book1D(histname+"All_Fakes","vertex #chi^{2} all", 100, -8., 8.);
00619     h_maxDlClosestHitToVtxSig_[2][1] = dbe_->book1D(histname+"Barrel_Fakes","vertex #chi^{2} barrel", 100, -8., 8.);
00620     h_maxDlClosestHitToVtxSig_[2][2] = dbe_->book1D(histname+"Endcap_Fakes","vertex #chi^{2} endcap", 100, -8., 8.);
00621 
00622     histname="deltaExpectedHitsInner";
00623     h_deltaExpectedHitsInner_[0][0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 31, -15.5, 15.5);
00624     h_deltaExpectedHitsInner_[0][1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 31, -15.5, 15.5);
00625     h_deltaExpectedHitsInner_[0][2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 31, -15.5, 15.5);
00626     h_deltaExpectedHitsInner_[1][0] = dbe_->book1D(histname+"All_Ass","vertex #chi^{2} all", 31, -15.5, 15.5);
00627     h_deltaExpectedHitsInner_[1][1] = dbe_->book1D(histname+"Barrel_Ass","vertex #chi^{2} barrel", 31, -15.5, 15.5);
00628     h_deltaExpectedHitsInner_[1][2] = dbe_->book1D(histname+"Endcap_Ass","vertex #chi^{2} endcap", 31, -15.5, 15.5);
00629     h_deltaExpectedHitsInner_[2][0] = dbe_->book1D(histname+"All_Fakes","vertex #chi^{2} all", 31, -15.5, 15.5);
00630     h_deltaExpectedHitsInner_[2][1] = dbe_->book1D(histname+"Barrel_Fakes","vertex #chi^{2} barrel", 31, -15.5, 15.5);
00631     h_deltaExpectedHitsInner_[2][2] = dbe_->book1D(histname+"Endcap_Fakes","vertex #chi^{2} endcap", 31, -15.5, 15.5);
00632 
00633     histname="leadExpectedHitsInner";
00634     h_leadExpectedHitsInner_[0][0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 16, -0.5, 15.5);
00635     h_leadExpectedHitsInner_[0][1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00636     h_leadExpectedHitsInner_[0][2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00637     h_leadExpectedHitsInner_[1][0] = dbe_->book1D(histname+"All_Ass","vertex #chi^{2} all", 16, -0.5, 15.5);
00638     h_leadExpectedHitsInner_[1][1] = dbe_->book1D(histname+"Barrel_Ass","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00639     h_leadExpectedHitsInner_[1][2] = dbe_->book1D(histname+"Endcap_Ass","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00640     h_leadExpectedHitsInner_[2][0] = dbe_->book1D(histname+"All_Fakes","vertex #chi^{2} all", 16, -0.5, 15.5);
00641     h_leadExpectedHitsInner_[2][1] = dbe_->book1D(histname+"Barrel_Fakes","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00642     h_leadExpectedHitsInner_[2][2] = dbe_->book1D(histname+"Endcap_Fakes","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00643 
00644     histname="nSharedHits";
00645     h_nSharedHits_[0][0] = dbe_->book1D(histname+"All","vertex #chi^{2} all", 16, -0.5, 15.5);
00646     h_nSharedHits_[0][1] = dbe_->book1D(histname+"Barrel","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00647     h_nSharedHits_[0][2] = dbe_->book1D(histname+"Endcap","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00648     h_nSharedHits_[1][0] = dbe_->book1D(histname+"All_Ass","vertex #chi^{2} all", 16, -0.5, 15.5);
00649     h_nSharedHits_[1][1] = dbe_->book1D(histname+"Barrel_Ass","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00650     h_nSharedHits_[1][2] = dbe_->book1D(histname+"Endcap_Ass","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00651     h_nSharedHits_[2][0] = dbe_->book1D(histname+"All_Fakes","vertex #chi^{2} all", 16, -0.5, 15.5);
00652     h_nSharedHits_[2][1] = dbe_->book1D(histname+"Barrel_Fakes","vertex #chi^{2} barrel", 16, -0.5, 15.5);
00653     h_nSharedHits_[2][2] = dbe_->book1D(histname+"Endcap_Fakes","vertex #chi^{2} endcap", 16, -0.5, 15.5);
00654 
00656     histname="nHits";
00657     nHits_[0] =  dbe_->book2D(histname+"AllTracks","Photons:Tracks from conversions: # of hits all tracks",etaBin,etaMin, etaMax,30,0., 30.);
00658     nHits_[1] =  dbe_->book2D(histname+"AllTracks_Ass","Photons:Tracks from conversions: # of hits  all tracks ass",etaBin,etaMin, etaMax,30,0., 30.);
00659     nHits_[2] =  dbe_->book2D(histname+"AllTracks_Fakes","Photons:Tracks from conversions: # of hits all tracks fakes",etaBin,etaMin, etaMax,30,0., 30.);
00660 
00661 
00662     histname="nHitsVsEta";
00663     nHitsVsEta_[0] =  dbe_->book2D(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs #eta all tracks",etaBin,etaMin, etaMax,30,0., 30.);
00664     nHitsVsEta_[1] =  dbe_->book2D(histname+"AllTracks_Ass","Photons:Tracks from conversions: # of hits vs #eta all tracks",etaBin,etaMin, etaMax,30,0., 30.);
00665     nHitsVsEta_[2] =  dbe_->book2D(histname+"AllTracks_Fakes","Photons:Tracks from conversions: # of hits vs #eta all tracks",etaBin,etaMin, etaMax,30,0., 30.);
00666     histname="h_nHitsVsEta";
00667     p_nHitsVsEta_[0] =  dbe_->bookProfile(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs #eta all tracks",etaBin,etaMin, etaMax, 30,-0.5, 29.5,"");
00668     p_nHitsVsEta_[1] =  dbe_->bookProfile(histname+"AllTracks_Ass","Photons:Tracks from conversions: # of hits vs #eta all tracks",etaBin,etaMin, etaMax, 30,-0.5, 29.5,"");
00669     p_nHitsVsEta_[2] =  dbe_->bookProfile(histname+"AllTracks_Fakes","Photons:Tracks from conversions: # of hits vs #eta all tracks",etaBin,etaMin, etaMax, 30,-0.5, 29.5,"");
00670 
00671 
00672     histname="nHitsVsR";
00673     nHitsVsR_[0] =  dbe_->book2D(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs radius all tracks" ,rBin,rMin, rMax,30,0., 30.);
00674     nHitsVsR_[1] =  dbe_->book2D(histname+"AllTracks_Ass","Photons:Tracks from conversions: # of hits vs radius all tracks" ,rBin,rMin, rMax,30,0., 30.);
00675     nHitsVsR_[2] =  dbe_->book2D(histname+"AllTracks_Fakes","Photons:Tracks from conversions: # of hits vs radius all tracks" ,rBin,rMin, rMax,30,0., 30.);
00676 
00677     histname="h_nHitsVsR";
00678     p_nHitsVsR_[0] =  dbe_->bookProfile(histname+"AllTracks","Photons:Tracks from conversions: # of hits vs radius all tracks",rBin,rMin, rMax, 30,-0.5, 29.5,"");
00679     p_nHitsVsR_[1] =  dbe_->bookProfile(histname+"AllTracks_Ass","Photons:Tracks from conversions: # of hits vs radius all tracks",rBin,rMin, rMax, 30,-0.5, 29.5,"");
00680     p_nHitsVsR_[2] =  dbe_->bookProfile(histname+"AllTracks_Fakes","Photons:Tracks from conversions: # of hits vs radius all tracks",rBin,rMin, rMax, 30,-0.5, 29.5,"");
00681 
00682     histname="tkChi2";
00683     h_tkChi2_[0] = dbe_->book1D(histname+"AllTracks","Photons:Tracks from conversions: #chi^{2} of all tracks", 100, chi2Min, chi2Max);
00684     h_tkChi2_[1] = dbe_->book1D(histname+"AllTracks_Ass","Photons:Tracks from conversions: #chi^{2} of all tracks", 100, chi2Min, chi2Max);
00685     h_tkChi2_[2] = dbe_->book1D(histname+"AllTracks_Fakes","Photons:Tracks from conversions: #chi^{2} of all tracks", 100, chi2Min, chi2Max);
00686 
00687     histname="tkChi2Large";
00688     h_tkChi2Large_[0] = dbe_->book1D(histname+"AllTracks","Photons:Tracks from conversions: #chi^{2} of all tracks", 1000, 0., 5000.0);
00689     h_tkChi2Large_[1] = dbe_->book1D(histname+"AllTracks_Ass","Photons:Tracks from conversions: #chi^{2} of all tracks", 1000, 0., 5000.0);
00690     h_tkChi2Large_[2] = dbe_->book1D(histname+"AllTracks_Fakes","Photons:Tracks from conversions: #chi^{2} of all tracks", 1000, 0., 5000.0);
00691 
00692 
00693     histname="h2Chi2VsEta";
00694     h2_Chi2VsEta_[0]=dbe_->book2D(histname+"All"," Reco Track  #chi^{2} vs #eta: All ",etaBin2,etaMin, etaMax,100, chi2Min, chi2Max);
00695     h2_Chi2VsEta_[1]=dbe_->book2D(histname+"All_Ass"," Reco Track  #chi^{2} vs #eta: All ",etaBin2,etaMin, etaMax,100, chi2Min, chi2Max);
00696     h2_Chi2VsEta_[2]=dbe_->book2D(histname+"All_Fakes"," Reco Track  #chi^{2} vs #eta: All ",etaBin2,etaMin, etaMax,100, chi2Min, chi2Max);
00697     histname="pChi2VsEta";
00698     p_Chi2VsEta_[0]=dbe_->bookProfile(histname+"All"," Reco Track #chi^{2} vs #eta : All ",etaBin2,etaMin, etaMax, 100, chi2Min, chi2Max,"");
00699     p_Chi2VsEta_[1]=dbe_->bookProfile(histname+"All_Ass"," Reco Track #chi^{2} vs #eta : All ",etaBin2,etaMin, etaMax, 100, chi2Min, chi2Max,"");
00700     p_Chi2VsEta_[2]=dbe_->bookProfile(histname+"All_Fakes"," Reco Track #chi^{2} vs #eta : All ",etaBin2,etaMin, etaMax, 100, chi2Min, chi2Max,"");
00701 
00702     histname="h2Chi2VsR";
00703     h2_Chi2VsR_[0]=dbe_->book2D(histname+"All"," Reco Track  #chi^{2} vs R: All ",rBin,rMin, rMax,100,chi2Min, chi2Max);
00704     h2_Chi2VsR_[1]=dbe_->book2D(histname+"All_Ass"," Reco Track  #chi^{2} vs R: All ",rBin,rMin, rMax,100,chi2Min, chi2Max);
00705     h2_Chi2VsR_[2]=dbe_->book2D(histname+"All_Fakes"," Reco Track  #chi^{2} vs R: All ",rBin,rMin, rMax,100,chi2Min, chi2Max);
00706     histname="pChi2VsR";
00707     p_Chi2VsR_[0]=dbe_->bookProfile(histname+"All"," Reco Track #chi^{2} vas R : All ",rBin,rMin,rMax, 100,chi2Min, chi2Max,"");
00708     p_Chi2VsR_[1]=dbe_->bookProfile(histname+"All_Ass"," Reco Track #chi^{2} vas R : All ",rBin,rMin,rMax, 100,chi2Min, chi2Max,"");
00709     p_Chi2VsR_[2]=dbe_->bookProfile(histname+"All_Fakes"," Reco Track #chi^{2} vas R : All ",rBin,rMin,rMax, 100,chi2Min, chi2Max,"");
00710 
00711     histname="hTkD0";
00712     h_TkD0_[0]=dbe_->book1D(histname+"All"," Reco Track D0*q: All ",200,-0.1,60);
00713     h_TkD0_[1]=dbe_->book1D(histname+"All_Ass"," Reco Track D0*q: Barrel ",200,-0.1,60);
00714     h_TkD0_[2]=dbe_->book1D(histname+"All_Fakes"," Reco Track D0*q: Endcap ",200,-0.1,60);
00715 
00716 
00717 
00718     histname="hTkPtPull";
00719     h_TkPtPull_[0]=dbe_->book1D(histname+"All"," Reco Track Pt pull: All ",100, -20., 10.);
00720     histname="hTkPtPull";
00721     h_TkPtPull_[1]=dbe_->book1D(histname+"Barrel"," Reco Track Pt pull: Barrel ",100, -20., 10.);
00722     histname="hTkPtPull";
00723     h_TkPtPull_[2]=dbe_->book1D(histname+"Endcap"," Reco Track Pt pull: Endcap ",100, -20., 10.);
00724 
00725     histname="h2TkPtPullEta";
00726     h2_TkPtPull_[0]=dbe_->book2D(histname+"All"," Reco Track Pt pull: All ",etaBin2,etaMin, etaMax,100, -20., 10.);
00727     histname="pTkPtPullEta";
00728     p_TkPtPull_[0]=dbe_->bookProfile(histname+"All"," Reco Track Pt pull: All ",etaBin2,etaMin, etaMax, 100, -20., 10., " ");
00729 
00730 
00731     histname="PtRecVsPtSim";
00732     h2_PtRecVsPtSim_[0]=dbe_->book2D(histname+"All", "Pt Rec vs Pt sim: All ", etBin,etMin,etMax,etBin,etMin, etMax);
00733     h2_PtRecVsPtSim_[1]=dbe_->book2D(histname+"Barrel", "Pt Rec vs Pt sim: Barrel ", etBin,etMin,etMax,etBin,etMin, etMax);
00734     h2_PtRecVsPtSim_[2]=dbe_->book2D(histname+"Endcap", "Pt Rec vs Pt sim: Endcap ", etBin,etMin,etMax,etBin,etMin, etMax);
00735 
00736     histname="photonPtRecVsPtSim";
00737     h2_photonPtRecVsPtSim_=dbe_->book2D(histname+"All", "Pt Rec vs Pt sim: All ", etBin,etMin,etMax,etBin,etMin, etMax);
00738 
00739     histname="nHitsBeforeVtx";
00740     h_nHitsBeforeVtx_[0]=dbe_->book1D(histname+"All", "Pt Rec vs Pt sim: All ", 16, -0.5, 15.5);
00741     h_nHitsBeforeVtx_[1]=dbe_->book1D(histname+"Barrel", "Pt Rec vs Pt sim: Barrel ", 16, -0.5, 15.5);
00742     h_nHitsBeforeVtx_[2]=dbe_->book1D(histname+"Endcap", "Pt Rec vs Pt sim: Endcap ", 16, -0.5, 15.5);
00743 
00744     histname="dlClosestHitToVtx";
00745     h_dlClosestHitToVtx_[0]=dbe_->book1D(histname+"All", "Pt Rec vs Pt sim: All ", 100, -10., 10.);
00746     h_dlClosestHitToVtx_[1]=dbe_->book1D(histname+"Barrel", "Pt Rec vs Pt sim: Barrel ", 100, -10., 10.);
00747     h_dlClosestHitToVtx_[2]=dbe_->book1D(histname+"Endcap", "Pt Rec vs Pt sim: Endcap ", 100, -10., 10.);
00748 
00749     histname="dlClosestHitToVtxSig";
00750     h_dlClosestHitToVtxSig_[0]=dbe_->book1D(histname+"All", "Pt Rec vs Pt sim: All ", 100, -8., 8.);
00751     h_dlClosestHitToVtxSig_[1]=dbe_->book1D(histname+"Barrel", "Pt Rec vs Pt sim: Barrel ", 100, -8., 8.);
00752     h_dlClosestHitToVtxSig_[2]=dbe_->book1D(histname+"Endcap", "Pt Rec vs Pt sim: Endcap ", 100, -8., 8.);
00753 
00754     h_match_= dbe_->book1D("h_match"," ", 3, -0.5,2.5);
00755 
00756 
00757   } // if DQM
00758 
00759 
00760 
00761 }
00762 
00763 
00764 
00765  void  TkConvValidator::beginRun (edm::Run const & r, edm::EventSetup const & theEventSetup) {
00766 
00767    //get magnetic field
00768   edm::LogInfo("ConvertedPhotonProducer") << " get magnetic field" << "\n";
00769   theEventSetup.get<IdealMagneticFieldRecord>().get(theMF_);
00770 
00771 
00772   edm::ESHandle<TrackAssociatorBase> theHitsAssociator;
00773   theEventSetup.get<TrackAssociatorRecord>().get("trackAssociatorByHitsForConversionValidation",theHitsAssociator);
00774   theTrackAssociator_ = (TrackAssociatorBase *) theHitsAssociator.product();
00775 
00776 
00777 
00778 
00779   thePhotonMCTruthFinder_ = new PhotonMCTruthFinder();
00780 
00781 }
00782 
00783 void  TkConvValidator::endRun (edm::Run& r, edm::EventSetup const & theEventSetup) {
00784 
00785   delete thePhotonMCTruthFinder_;
00786 
00787 }
00788 
00789 
00790 
00791 void TkConvValidator::analyze( const edm::Event& e, const edm::EventSetup& esup ) {
00792 
00793   using namespace edm;
00794   //  const float etaPhiDistance=0.01;
00795   // Fiducial region
00796   // const float TRK_BARL =0.9;
00797   const float BARL = 1.4442; // DAQ TDR p.290
00798   //  const float END_LO = 1.566; // unused
00799   const float END_HI = 2.5;
00800   // Electron mass
00801   //  const Float_t mElec= 0.000511; // unused
00802 
00803 
00804   nEvt_++;
00805   LogInfo("TkConvValidator") << "TkConvValidator Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n";
00806   //  std::cout << "TkConvValidator Analyzing event number: "  << e.id() << " Global Counter " << nEvt_ <<"\n";
00807 
00808 
00809   // get the geometry from the event setup:
00810   esup.get<CaloGeometryRecord>().get(theCaloGeom_);
00811 
00812 
00813   // Transform Track into TransientTrack (needed by the Vertex fitter)
00814   edm::ESHandle<TransientTrackBuilder> theTTB;
00815   esup.get<TransientTrackRecord>().get("TransientTrackBuilder",theTTB);
00816 
00817 
00819   Handle<reco::ConversionCollection> convHandle;
00820   e.getByLabel(conversionCollectionProducer_, conversionCollection_ , convHandle);
00821   const reco::ConversionCollection convCollection = *(convHandle.product());
00822   if (!convHandle.isValid()) {
00823     edm::LogError("ConversionsProducer") << "Error! Can't get the  collection "<< std::endl;
00824     return;
00825   }
00826 
00828   Handle<reco::PhotonCollection> photonHandle;
00829   e.getByLabel(photonCollectionProducer_, photonCollection_ , photonHandle);
00830   const reco::PhotonCollection photonCollection = *(photonHandle.product());
00831   if (!photonHandle.isValid()) {
00832     edm::LogError("PhotonProducer") << "Error! Can't get the Photon collection "<< std::endl;
00833     return;
00834   }
00835 
00836 
00837   // offline  Primary vertex
00838   edm::Handle<reco::VertexCollection> vertexHandle;
00839   reco::VertexCollection vertexCollection;
00840   e.getByLabel("offlinePrimaryVertices", vertexHandle);
00841   if (!vertexHandle.isValid()) {
00842       edm::LogError("TrackerOnlyConversionProducer") << "Error! Can't get the product primary Vertex Collection "<< "\n";
00843   } else {
00844       vertexCollection = *(vertexHandle.product());
00845   }
00846   reco::Vertex the_pvtx;
00847   bool valid_pvtx = false;
00848   if (!vertexCollection.empty()){
00849       the_pvtx = *(vertexCollection.begin());
00850       //asking for one good vertex
00851       if (the_pvtx.isValid() && fabs(the_pvtx.position().z())<=15 && the_pvtx.position().Rho()<=2){
00852           valid_pvtx = true;
00853       }
00854   }
00855 
00856   edm::Handle<reco::BeamSpot> bsHandle;
00857   e.getByLabel("offlineBeamSpot", bsHandle);
00858   if (!bsHandle.isValid()) {
00859       edm::LogError("TrackerOnlyConversionProducer") << "Error! Can't get the product primary Vertex Collection "<< "\n";
00860       return;
00861   }
00862   const reco::BeamSpot &thebs = *bsHandle.product();
00863 
00864  //get tracker geometry for hits positions
00865   edm::ESHandle<TrackerGeometry> tracker;
00866   esup.get<TrackerDigiGeometryRecord>().get(tracker);
00867   const TrackerGeometry* trackerGeom = tracker.product();
00868 
00869 
00870 
00872   //get simtrack info
00873   std::vector<SimTrack> theSimTracks;
00874   std::vector<SimVertex> theSimVertices;
00875 
00876   edm::Handle<SimTrackContainer> SimTk;
00877   edm::Handle<SimVertexContainer> SimVtx;
00878   e.getByLabel("g4SimHits",SimTk);
00879   e.getByLabel("g4SimHits",SimVtx);
00880 
00881   bool useTP= parameters_.getParameter<bool>("useTP");
00882   TrackingParticleCollection tpForEfficiency;
00883   TrackingParticleCollection tpForFakeRate;
00884   edm::Handle<TrackingParticleCollection> TPHandleForEff;
00885   edm::Handle<TrackingParticleCollection> TPHandleForFakeRate;
00886   if ( useTP) {
00887     e.getByLabel("tpSelecForEfficiency",TPHandleForEff);
00888     tpForEfficiency = *(TPHandleForEff.product());
00889     e.getByLabel("tpSelecForFakeRate",TPHandleForFakeRate);
00890     tpForFakeRate = *(TPHandleForFakeRate.product());
00891   }
00892 
00893 
00894 
00895   theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
00896   theSimVertices.insert(theSimVertices.end(),SimVtx->begin(),SimVtx->end());
00897   std::vector<PhotonMCTruth> mcPhotons=thePhotonMCTruthFinder_->find (theSimTracks,  theSimVertices);
00898 
00899   edm::Handle<edm::HepMCProduct> hepMC;
00900   e.getByLabel("generator",hepMC);
00901   //  const HepMC::GenEvent *myGenEvent = hepMC->GetEvent(); // unused
00902 
00903 
00904   // get generated jets
00905   edm::Handle<reco::GenJetCollection> GenJetsHandle ;
00906   e.getByLabel("iterativeCone5GenJets","",GenJetsHandle);
00907   reco::GenJetCollection genJetCollection = *(GenJetsHandle.product());
00908 
00909   ConversionHitChecker hitChecker;
00910 
00911   // ################  SIM to RECO ######################### //
00912   std::map<const reco::Track*,TrackingParticleRef> myAss;
00913   std::map<const reco::Track*,TrackingParticleRef>::const_iterator itAss;
00914 
00915   for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
00916 
00917     mcConvPt_= (*mcPho).fourMomentum().et();
00918     float mcPhi= (*mcPho).fourMomentum().phi();
00919     mcPhi_= phiNormalization(mcPhi);
00920     mcEta_= (*mcPho).fourMomentum().pseudoRapidity();
00921     mcEta_ = etaTransformation(mcEta_, (*mcPho).primaryVertex().z() );
00922     mcConvR_= (*mcPho).vertex().perp();
00923     mcConvX_= (*mcPho).vertex().x();
00924     mcConvY_= (*mcPho).vertex().y();
00925     mcConvZ_= (*mcPho).vertex().z();
00926     mcConvEta_= (*mcPho).vertex().eta();
00927     mcConvPhi_= (*mcPho).vertex().phi();
00928 
00929     if ( fabs(mcEta_) > END_HI ) continue;
00930 
00931     if (mcConvPt_<minPhoPtForEffic) continue;
00932     if (fabs(mcEta_)>maxPhoEtaForEffic) continue;
00933     if (fabs(mcConvZ_)>maxPhoZForEffic) continue;
00934     if (mcConvR_>maxPhoRForEffic) continue;
00936 
00937     bool goodSimConversion=false;
00938     bool visibleConversion=false;
00939     bool visibleConversionsWithTwoSimTracks=false;
00940     if (  (*mcPho).isAConversion() == 1 ) {
00941       nSimConv_[0]++;
00942       h_AllSimConv_[0]->Fill( mcEta_ ) ;
00943       h_AllSimConv_[1]->Fill( mcPhi_ );
00944       h_AllSimConv_[2]->Fill( mcConvR_ );
00945       h_AllSimConv_[3]->Fill( mcConvZ_ );
00946       h_AllSimConv_[4]->Fill(  (*mcPho).fourMomentum().et());
00947 
00948       if ( mcConvR_ <15) h_SimConvEtaPix_[0]->Fill( mcEta_ ) ;
00949 
00950       if ( ( fabs(mcEta_) <= BARL && mcConvR_ <85 )  ||
00951            ( fabs(mcEta_) > BARL && fabs(mcEta_) <=END_HI && fabs( (*mcPho).vertex().z() ) < 210 )  ) visibleConversion=true;
00952 
00953       theConvTP_.clear();
00954       //      std::cout << " TkConvValidator TrackingParticles   TrackingParticleCollection size "<<  trackingParticles.size() <<  "\n";
00955       //duplicated TP collections for two associations
00956       for(size_t i = 0; i < tpForEfficiency.size(); ++i){
00957         TrackingParticleRef tp (TPHandleForEff,i);
00958         if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.0001   &&
00959              fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.0001   &&
00960              fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.0001) {
00961           theConvTP_.push_back( tp );
00962         }
00963       }
00964       //std::cout << " TkConvValidator  theConvTP_ size " <<   theConvTP_.size() << std::endl;
00965 
00966       if ( theConvTP_.size() == 2 )   visibleConversionsWithTwoSimTracks=true;
00967       goodSimConversion=false;
00968 
00969       if (   visibleConversion && visibleConversionsWithTwoSimTracks )  goodSimConversion=true;
00970       if ( goodSimConversion ) {
00971         nSimConv_[1]++;
00972         h_VisSimConv_[0]->Fill( mcEta_ ) ;
00973         h_VisSimConv_[1]->Fill( mcPhi_ );
00974         h_VisSimConv_[2]->Fill( mcConvR_ );
00975         h_VisSimConv_[3]->Fill( mcConvZ_ );
00976         h_VisSimConv_[4]->Fill(  (*mcPho).fourMomentum().et());
00977 
00978       }
00979 
00980       for ( edm::RefVector<TrackingParticleCollection>::iterator iTrk=theConvTP_.begin(); iTrk!=theConvTP_.end(); ++iTrk) {
00981         h_simTkPt_ -> Fill ( (*iTrk)->pt() );
00982         h_simTkEta_ -> Fill ( (*iTrk)->eta() );
00983       }
00984 
00985 
00986     }  
00987 
00988     if ( ! (visibleConversion &&  visibleConversionsWithTwoSimTracks ) ) continue;
00989 
00990       h_simConvVtxRvsZ_[0] ->Fill ( fabs (mcConvZ_), mcConvR_  ) ;
00991       if ( fabs(mcEta_) <=1.) {
00992         h_simConvVtxRvsZ_[1] ->Fill ( fabs (mcConvZ_), mcConvR_  ) ;
00993         h_simConvVtxYvsX_ ->Fill ( mcConvX_, mcConvY_  ) ;
00994       }
00995       else
00996         h_simConvVtxRvsZ_[2] ->Fill ( fabs (mcConvZ_), mcConvR_  ) ;
00997 
00998       //std::cout << " TkConvValidator  theConvTP_ size " <<   theConvTP_.size() << std::endl;
00999       for ( edm::RefVector<TrackingParticleCollection>::iterator iTP= theConvTP_.begin(); iTP!=theConvTP_.end(); iTP++)
01000         {
01001           //  std::cout << " SIM to RECO TP vertex " << (*iTP)->vx() << " " <<  (*iTP)->vy() << " " << (*iTP)->vz() << " pt " << (*iTP)->pt() << std::endl;
01002         }
01003 
01004      bool recomatch = false;
01005      float chi2Prob = 0.;
01007      // cout << " size of conversions " << convHandle->size() << endl;
01008      for (reco::ConversionCollection::const_iterator conv = convHandle->begin();conv!=convHandle->end();++conv) {
01009 
01010         const reco::Conversion aConv = (*conv);
01011         if ( arbitratedMerged_ && !aConv.quality(reco::Conversion::arbitratedMerged)  ) continue;
01012         if ( generalTracksOnly_ && !aConv.quality(reco::Conversion::generalTracksOnly) ) continue;
01013         if ( arbitratedEcalSeeded_ && !aConv.quality(reco::Conversion::arbitratedEcalSeeded)  ) continue;
01014 
01015 
01016         if ( highPurity_ && !aConv.quality(reco::Conversion::highPurity) ) continue;
01017 
01018         //problematic?
01019         std::vector<edm::RefToBase<reco::Track> > tracks = aConv.tracks();
01020 
01021 
01022         const reco::Vertex& vtx = aConv.conversionVertex();
01023         //requires two tracks and a valid vertex
01024         if (tracks.size() !=2 || !(vtx.isValid())) continue;
01025 
01026 
01027         if (ChiSquaredProbability( aConv.conversionVertex().chi2(),  aConv.conversionVertex().ndof() ) <= minProb_) continue;
01028         if (aConv.nHitsBeforeVtx().size()>1 && max(aConv.nHitsBeforeVtx().at(0),aConv.nHitsBeforeVtx().at(1)) > maxHitsBeforeVtx_ ) continue;
01029 
01030 
01031         //compute transverse decay length with respect to beamspot
01032         math::XYZVectorF  themom = aConv.refittedPairMomentum();
01033         double dbsx = aConv.conversionVertex().x() - thebs.x0();
01034         double dbsy = aConv.conversionVertex().y() - thebs.y0();
01035         double lxy = (themom.x()*dbsx + themom.y()*dbsy)/themom.rho();
01036 
01037         if (lxy<minLxy_) continue;
01038 
01039         //      bool  phoIsInBarrel=false; // unused
01040         //      bool  phoIsInEndcap=false; // unused
01041         RefToBase<reco::Track> tfrb1 = aConv.tracks().front();
01042         RefToBase<reco::Track> tfrb2 = aConv.tracks().back();
01043 
01044         if ( ecalalgotracks_ && ( !(tfrb1->algo()==15 || tfrb1->algo()==16) || !(tfrb2->algo()==15 || tfrb2->algo()==16)  )  ) continue;
01045 
01046 
01047         //reco::TrackRef tk1 = aConv.tracks().front();
01048         //reco::TrackRef tk2 = aConv.tracks().back();
01049         //std::cout << "SIM to RECO  conversion track pt " << tk1->pt() << " " << tk2->pt() << endl;
01050         //
01051         //Use two RefToBaseVector and do two association actions to avoid that if two tracks from different collection
01052         RefToBaseVector<reco::Track> tc1, tc2;
01053         tc1.push_back(tfrb1);
01054         tc2.push_back(tfrb2);
01055         bool isAssociated = false;
01056         reco::SimToRecoCollection q1 = theTrackAssociator_->associateSimToReco(tc1,theConvTP_,&e,&esup);
01057         reco::SimToRecoCollection q2 = theTrackAssociator_->associateSimToReco(tc2,theConvTP_,&e,&esup);
01058         //try {
01059           std::vector<std::pair<RefToBase<reco::Track>, double> > trackV1, trackV2;
01060 
01061           int tp_1 = 0, tp_2 = 1;//the index of associated tp in theConvTP_ for two tracks
01062           if (q1.find(theConvTP_[0])!=q1.end()){
01063               trackV1 = (std::vector<std::pair<RefToBase<reco::Track>, double> >) q1[theConvTP_[0]];
01064           } else if (q1.find(theConvTP_[1])!=q1.end()){
01065               trackV1 = (std::vector<std::pair<RefToBase<reco::Track>, double> >) q1[theConvTP_[1]];
01066               tp_1 = 1;
01067           }
01068           if (q2.find(theConvTP_[1])!=q2.end()){
01069               trackV2 = (std::vector<std::pair<RefToBase<reco::Track>, double> >) q2[theConvTP_[1]];
01070           } else if (q2.find(theConvTP_[0])!=q2.end()){
01071               trackV2 = (std::vector<std::pair<RefToBase<reco::Track>, double> >) q2[theConvTP_[0]];
01072               tp_2 = 0;
01073           }
01074           if (!(trackV1.size()&&trackV2.size()))
01075               continue;
01076           if (tp_1 == tp_2) continue;
01077 
01078           edm::RefToBase<reco::Track> tr1 = trackV1.front().first;
01079           edm::RefToBase<reco::Track> tr2 = trackV2.front().first;
01080           //std::cout << "associated tp1 " <<theConvTP_[0]->pt() << " to track with  pT=" << tr1->pt() << " " << (tr1.get())->pt() << endl;
01081           //std::cout << "associated tp2 " <<theConvTP_[1]->pt() << " to track with  pT=" << tr2->pt() << " " << (tr2.get())->pt() << endl;
01082           myAss.insert( std::make_pair (tr1.get(),theConvTP_[tp_1] ) );
01083           myAss.insert( std::make_pair (tr2.get(),theConvTP_[tp_2]) );
01084 
01085         //} catch (Exception event) {
01086           //cout << "continue: " << event.what()  << endl;
01087         //  continue;
01088         //}
01089 
01090 
01091         isAssociated = true;
01092         recomatch = true;
01093         chi2Prob = ChiSquaredProbability( aConv.conversionVertex().chi2(),  aConv.conversionVertex().ndof() );
01094 
01095         if (isAssociated) {
01096           h_SimRecConvTwoMTracks_[0]->Fill( mcEta_ ) ;
01097           h_SimRecConvTwoMTracks_[1]->Fill( mcPhi_ );
01098           h_SimRecConvTwoMTracks_[2]->Fill( mcConvR_ );
01099           h_SimRecConvTwoMTracks_[3]->Fill( mcConvZ_ );
01100           h_SimRecConvTwoMTracks_[4]->Fill(  (*mcPho).fourMomentum().et());
01101         }
01102 
01103        // break;
01104       } // loop over reco conversions
01105       if (recomatch) {
01107         h_SimConvTwoMTracks_[0]->Fill( mcEta_ ) ;
01108         h_SimConvTwoMTracks_[1]->Fill( mcPhi_ );
01109         h_SimConvTwoMTracks_[2]->Fill( mcConvR_ );
01110         h_SimConvTwoMTracks_[3]->Fill( mcConvZ_ );
01111         h_SimConvTwoMTracks_[4]->Fill(  (*mcPho).fourMomentum().et());
01112 
01113 
01114         if (   chi2Prob > 0) {
01115           h_SimConvTwoMTracksAndVtxPGT0_[0]->Fill( mcEta_ ) ;
01116           h_SimConvTwoMTracksAndVtxPGT0_[1]->Fill( mcPhi_ );
01117           h_SimConvTwoMTracksAndVtxPGT0_[2]->Fill( mcConvR_ );
01118           h_SimConvTwoMTracksAndVtxPGT0_[3]->Fill( mcConvZ_ );
01119           h_SimConvTwoMTracksAndVtxPGT0_[4]->Fill(  (*mcPho).fourMomentum().et());
01120         }
01121         if (   chi2Prob > 0.0005) {
01122           h_SimConvTwoMTracksAndVtxPGT0005_[0]->Fill( mcEta_ ) ;
01123           h_SimConvTwoMTracksAndVtxPGT0005_[1]->Fill( mcPhi_ );
01124           h_SimConvTwoMTracksAndVtxPGT0005_[2]->Fill( mcConvR_ );
01125           h_SimConvTwoMTracksAndVtxPGT0005_[3]->Fill( mcConvZ_ );
01126           h_SimConvTwoMTracksAndVtxPGT0005_[4]->Fill(  (*mcPho).fourMomentum().et());
01127 
01128         }
01129       }
01130 
01131   } //End loop over simulated conversions
01132 
01133 
01134   // ########################### RECO to SIM ############################## //
01135 
01136   for (reco::ConversionCollection::const_iterator conv = convHandle->begin();conv!=convHandle->end();++conv) {
01137     const reco::Conversion aConv = (*conv);
01138     if ( arbitratedMerged_ && !aConv.quality(reco::Conversion::arbitratedMerged)  ) continue;
01139     if ( generalTracksOnly_ && !aConv.quality(reco::Conversion::generalTracksOnly) ) continue;
01140     if ( arbitratedEcalSeeded_ && !aConv.quality(reco::Conversion::arbitratedEcalSeeded)  ) continue;
01141 
01142 
01143     if ( highPurity_ && !aConv.quality(reco::Conversion::highPurity) ) continue;
01144 
01145     //problematic?
01146     std::vector<edm::RefToBase<reco::Track> > tracks = aConv.tracks();
01147 
01148     const reco::Vertex& vtx = aConv.conversionVertex();
01149     //requires two tracks and a valid vertex
01150     if (tracks.size() !=2 || !(vtx.isValid())) continue;
01151     //if (tracks.size() !=2) continue;
01152 
01153 
01154     if (ChiSquaredProbability( aConv.conversionVertex().chi2(),  aConv.conversionVertex().ndof() ) <= minProb_) continue;
01155     if (aConv.nHitsBeforeVtx().size()>1 && max(aConv.nHitsBeforeVtx().at(0),aConv.nHitsBeforeVtx().at(1)) > maxHitsBeforeVtx_ ) continue;
01156 
01157     //compute transverse decay length with respect to beamspot
01158     math::XYZVectorF  themom = aConv.refittedPairMomentum();
01159     double dbsx = aConv.conversionVertex().x() - thebs.x0();
01160     double dbsy = aConv.conversionVertex().y() - thebs.y0();
01161     double lxy = (themom.x()*dbsx + themom.y()*dbsy)/themom.rho();
01162 
01163     if (lxy<minLxy_) continue;
01164 
01165     bool  phoIsInBarrel=false;
01166     bool  phoIsInEndcap=false;
01167     RefToBase<reco::Track> tk1 = aConv.tracks().front();
01168     RefToBase<reco::Track> tk2 = aConv.tracks().back();
01169     RefToBaseVector<reco::Track> tc1, tc2;
01170     tc1.push_back(tk1);
01171     tc2.push_back(tk2);
01172 
01173    if ( ecalalgotracks_ && ( !(tk1->algo()==15 || tk1->algo()==16) || !(tk2->algo()==15 || tk2->algo()==16)  )  ) continue;
01174 
01175 
01176     //std::cout << " RECO to SIM conversion track pt " << tk1->pt() << " " << tk2->pt() << endl;
01177     const reco::Track refTk1 = aConv.conversionVertex().refittedTracks().front();
01178     const reco::Track refTk2 = aConv.conversionVertex().refittedTracks().back();
01179 
01180     //TODO replace it with phi at vertex
01181     float  dPhiTracksAtVtx =  aConv.dPhiTracksAtVtx();
01182     // override with the phi calculated at the vertex
01183     math::XYZVector p1AtVtx= recalculateMomentumAtFittedVertex (  (*theMF_), *trackerGeom, tk1,  aConv.conversionVertex() );
01184     math::XYZVector p2AtVtx= recalculateMomentumAtFittedVertex (  (*theMF_), *trackerGeom, tk2,  aConv.conversionVertex() );
01185     if (  sqrt(p1AtVtx.perp2())  >  sqrt(p2AtVtx.perp2())  )
01186       dPhiTracksAtVtx = p1AtVtx.phi() - p2AtVtx.phi();
01187     else
01188       dPhiTracksAtVtx = p2AtVtx.phi() - p1AtVtx.phi();
01189 
01190 
01191     math::XYZVectorF refittedMom =  aConv.refittedPairMomentum();
01192 
01193 
01194     if (fabs(refittedMom.eta())< 1.479 ) {
01195       phoIsInBarrel=true;
01196     } else {
01197       phoIsInEndcap=true;
01198     }
01199 
01200     nRecConv_++;
01201 
01202     // check matching with reco photon 
01203     double Mindeltaeta = 999999;
01204     double Mindeltaphi = 999999;
01205     bool matchConvSC=false;
01206     reco::PhotonCollection::const_iterator  iMatchingSC;
01207     for( reco::PhotonCollection::const_iterator  iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
01208       reco::Photon aPho = reco::Photon(*iPho);
01209       const double deltaphi= reco::deltaPhi( aConv.refittedPairMomentum().phi(), aPho.superCluster()->position().phi());
01210       double ConvEta = etaTransformation(aConv.refittedPairMomentum().eta(),aConv.zOfPrimaryVertexFromTracks());
01211       double deltaeta = abs( aPho.superCluster()->position().eta() -ConvEta);
01212       if (abs(deltaeta)<abs(Mindeltaeta) && abs(deltaphi)<abs(Mindeltaphi)) {
01213         Mindeltaphi=abs(deltaphi);
01214         Mindeltaeta=abs(deltaeta);
01215         iMatchingSC = iPho ;
01216       }
01217     }
01218     if (abs(Mindeltaeta)<0.1 && abs(Mindeltaphi)<0.1) {
01219       matchConvSC=true;
01220     }
01221   
01222 
01224     int match =0;
01225     float invM=aConv.pairInvariantMass();
01226     float chi2Prob = ChiSquaredProbability( aConv.conversionVertex().chi2(),  aConv.conversionVertex().ndof() );
01227     uint maxNHitsBeforeVtx = aConv.nHitsBeforeVtx().size()>1 ? max(aConv.nHitsBeforeVtx().at(0),aConv.nHitsBeforeVtx().at(1)) : 0;
01228     uint sumNHitsBeforeVtx = aConv.nHitsBeforeVtx().size()>1 ? aConv.nHitsBeforeVtx().at(0) + aConv.nHitsBeforeVtx().at(1) : 0;
01229     float maxDlClosestHitToVtx = aConv.dlClosestHitToVtx().size()>1 ? max(aConv.dlClosestHitToVtx().at(0).value(),aConv.dlClosestHitToVtx().at(1).value()) : 0;
01230     float maxDlClosestHitToVtxSig = aConv.dlClosestHitToVtx().size()>1 ? max(aConv.dlClosestHitToVtx().at(0).value()/aConv.dlClosestHitToVtx().at(0).error(),aConv.dlClosestHitToVtx().at(1).value()/aConv.dlClosestHitToVtx().at(1).error()) : 0;
01231 
01232     int ilead = 0, itrail = 1;
01233     if (tk2->pt() > tk1->pt()) {
01234       ilead = 1;
01235       itrail = 0;
01236     }
01237     RefToBase<reco::Track> tklead = aConv.tracks().at(ilead);
01238     RefToBase<reco::Track> tktrail = aConv.tracks().at(itrail);
01239 
01240     int deltaExpectedHitsInner = tklead->trackerExpectedHitsInner().numberOfHits() - tktrail->trackerExpectedHitsInner().numberOfHits();
01241     int leadExpectedHitsInner = tklead->trackerExpectedHitsInner().numberOfHits();
01242     uint leadNHitsBeforeVtx = aConv.nHitsBeforeVtx().size()>1 ? aConv.nHitsBeforeVtx().at(ilead) : 0;
01243     uint trailNHitsBeforeVtx = aConv.nHitsBeforeVtx().size()>1 ? aConv.nHitsBeforeVtx().at(itrail) : 0;
01244 
01245 
01246     h_convEta_[match][0]->Fill( refittedMom.eta() );
01247     h_convEta2_[match][0]->Fill( refittedMom.eta() );
01248 
01249     h_convPhi_[match][0]->Fill( refittedMom.phi() );
01250     h_convR_[match][0]->Fill( sqrt(aConv.conversionVertex().position().perp2()) );
01251     h_convRplot_->Fill( sqrt(aConv.conversionVertex().position().perp2()) );
01252     h_convZ_[match][0]->Fill( aConv.conversionVertex().position().z() );
01253     h_convZplot_->Fill( aConv.conversionVertex().position().z() );
01254     h_convPt_[match][0]->Fill(  sqrt(refittedMom.perp2()) );
01255     h_invMass_[match][0] ->Fill( invM);
01256     h_vtxChi2Prob_[match][0] ->Fill (chi2Prob);
01257     h_lxybs_[match][0] ->Fill (lxy);
01258     h_maxNHitsBeforeVtx_[match][0] ->Fill (maxNHitsBeforeVtx);
01259     h_leadNHitsBeforeVtx_[match][0] ->Fill (leadNHitsBeforeVtx);
01260     h_trailNHitsBeforeVtx_[match][0] ->Fill (trailNHitsBeforeVtx);
01261     h_sumNHitsBeforeVtx_[match][0] ->Fill (sumNHitsBeforeVtx);
01262     h_deltaExpectedHitsInner_[match][0] ->Fill (deltaExpectedHitsInner);
01263     h_leadExpectedHitsInner_[match][0] ->Fill (leadExpectedHitsInner);
01264     h_maxDlClosestHitToVtx_[match][0] ->Fill (maxDlClosestHitToVtx);
01265     h_maxDlClosestHitToVtxSig_[match][0] ->Fill (maxDlClosestHitToVtxSig);
01266     h_nSharedHits_[match][0] ->Fill (aConv.nSharedHits());
01267 
01268 
01269     if (  matchConvSC ) {
01270       h_convEtaMatchSC_[match][0]->Fill( refittedMom.eta() );
01271       h_EoverPTracks_[match][0] ->Fill (iMatchingSC->superCluster()->energy()/sqrt(refittedMom.mag2()));
01272       h_convSCdPhi_[match][0]->Fill( iMatchingSC->superCluster()->position().phi() - refittedMom.phi() );
01273       double ConvEta = etaTransformation(aConv.refittedPairMomentum().eta(),aConv.zOfPrimaryVertexFromTracks());
01274       h_convSCdEta_[match][0]->Fill( iMatchingSC->superCluster()->position().eta() - ConvEta );
01275     }
01276 
01277     h_distMinAppTracks_[match][0] ->Fill (aConv.distOfMinimumApproach());
01278     h_DPhiTracksAtVtx_[match][0]->Fill( dPhiTracksAtVtx);
01279     h2_DPhiTracksAtVtxVsEta_->Fill( mcEta_, dPhiTracksAtVtx);
01280     h2_DPhiTracksAtVtxVsR_->Fill( mcConvR_, dPhiTracksAtVtx);
01281     p_DPhiTracksAtVtxVsEta_->Fill( mcEta_, dPhiTracksAtVtx);
01282     p_DPhiTracksAtVtxVsR_->Fill( mcConvR_, dPhiTracksAtVtx);
01283 
01284     h_DCotTracks_[match][0] ->Fill ( aConv.pairCotThetaSeparation() );
01285     h2_DCotTracksVsEta_->Fill( mcEta_, aConv.pairCotThetaSeparation() );
01286     h2_DCotTracksVsR_->Fill( mcConvR_, aConv.pairCotThetaSeparation() );
01287     p_DCotTracksVsEta_->Fill( mcEta_, aConv.pairCotThetaSeparation() );
01288     p_DCotTracksVsR_->Fill( mcConvR_, aConv.pairCotThetaSeparation() );
01289 
01290     if ( phoIsInBarrel ) {
01291       h_invMass_[match][1] ->Fill(invM);
01292       h_vtxChi2Prob_[match][1] ->Fill (chi2Prob);
01293       h_distMinAppTracks_[match][1] ->Fill (aConv.distOfMinimumApproach());
01294       h_DPhiTracksAtVtx_[match][1]->Fill( dPhiTracksAtVtx);
01295       h_DCotTracks_[match][1] ->Fill ( aConv.pairCotThetaSeparation() );
01296       h_lxybs_[match][1] ->Fill (lxy);
01297       h_maxNHitsBeforeVtx_[match][1] ->Fill (maxNHitsBeforeVtx);
01298       h_leadNHitsBeforeVtx_[match][1] ->Fill (leadNHitsBeforeVtx);
01299       h_trailNHitsBeforeVtx_[match][1] ->Fill (trailNHitsBeforeVtx);
01300       h_sumNHitsBeforeVtx_[match][1] ->Fill (sumNHitsBeforeVtx);
01301       h_deltaExpectedHitsInner_[match][1] ->Fill (deltaExpectedHitsInner);
01302       h_leadExpectedHitsInner_[match][1] ->Fill (leadExpectedHitsInner);
01303       h_maxDlClosestHitToVtx_[match][1] ->Fill (maxDlClosestHitToVtx);
01304       h_maxDlClosestHitToVtxSig_[match][1] ->Fill (maxDlClosestHitToVtxSig);
01305       h_nSharedHits_[match][1] ->Fill (aConv.nSharedHits());
01306 
01307       /*
01308       if ( aConv.caloCluster().size() ) { 
01309         h_convSCdPhi_[match][1]->Fill(  aConv.caloCluster()[0]->phi() - refittedMom.phi() );
01310         double ConvEta = etaTransformation(aConv.refittedPairMomentum().eta(),aConv.zOfPrimaryVertexFromTracks());  
01311         h_convSCdEta_[match][1]->Fill( aConv.caloCluster()[0]->eta() - ConvEta );
01312       }
01313       */
01314 
01315       if (  matchConvSC ) {
01316         h_EoverPTracks_[match][1] -> Fill(iMatchingSC->superCluster()->energy()/sqrt(refittedMom.mag2()));
01317         h_convSCdPhi_[match][1]->Fill( iMatchingSC->superCluster()->position().phi() - refittedMom.phi() );
01318         double ConvEta = etaTransformation(aConv.refittedPairMomentum().eta(),aConv.zOfPrimaryVertexFromTracks());
01319         h_convSCdEta_[match][1]->Fill( iMatchingSC->superCluster()->position().eta() - ConvEta );
01320       }
01321     }
01322 
01323 
01324     if ( phoIsInEndcap ) {
01325       h_invMass_[match][2] ->Fill(invM);
01326       h_vtxChi2Prob_[match][2] ->Fill (chi2Prob);
01327       h_distMinAppTracks_[match][2] ->Fill (aConv.distOfMinimumApproach());
01328       h_DPhiTracksAtVtx_[match][2]->Fill( dPhiTracksAtVtx);
01329       h_DCotTracks_[match][2] ->Fill ( aConv.pairCotThetaSeparation() );
01330       h_lxybs_[match][2] ->Fill (lxy);
01331       h_maxNHitsBeforeVtx_[match][2] ->Fill (maxNHitsBeforeVtx);
01332       h_leadNHitsBeforeVtx_[match][2] ->Fill (leadNHitsBeforeVtx);
01333       h_trailNHitsBeforeVtx_[match][2] ->Fill (trailNHitsBeforeVtx);
01334       h_sumNHitsBeforeVtx_[match][2] ->Fill (sumNHitsBeforeVtx);
01335       h_deltaExpectedHitsInner_[match][2] ->Fill (deltaExpectedHitsInner);
01336       h_leadExpectedHitsInner_[match][2] ->Fill (leadExpectedHitsInner);
01337       h_maxDlClosestHitToVtx_[match][2] ->Fill (maxDlClosestHitToVtx);
01338       h_maxDlClosestHitToVtxSig_[match][2] ->Fill (maxDlClosestHitToVtxSig);
01339       h_nSharedHits_[match][2] ->Fill (aConv.nSharedHits());
01340       if (  matchConvSC ) {
01341         h_EoverPTracks_[match][2] ->Fill (iMatchingSC->superCluster()->energy()/sqrt(refittedMom.mag2()));
01342         h_convSCdPhi_[match][2]->Fill( iMatchingSC->superCluster()->position().phi() - refittedMom.phi() );
01343         double ConvEta = etaTransformation(aConv.refittedPairMomentum().eta(),aConv.zOfPrimaryVertexFromTracks());
01344         h_convSCdEta_[match][2]->Fill( iMatchingSC->superCluster()->position().eta() - ConvEta );
01345 
01346       }
01347     }
01348 
01349     h_convVtxRvsZ_[0] ->Fill ( fabs (aConv.conversionVertex().position().z() ),  sqrt(aConv.conversionVertex().position().perp2())  ) ;
01350     h_convVtxYvsX_ ->Fill (  aConv.conversionVertex().position().x(), aConv.conversionVertex().position().y() );
01351     h_convVtxYvsX_zoom_[0] ->Fill (  aConv.conversionVertex().position().x(), aConv.conversionVertex().position().y() );
01352     h_convVtxYvsX_zoom_[1] ->Fill (  aConv.conversionVertex().position().x(), aConv.conversionVertex().position().y() );
01353 
01354 
01355     // quantities per track: all conversions
01356     for (unsigned int i=0; i<tracks.size(); i++) {
01357       double d0;
01358       if (valid_pvtx){
01359         d0 = - tracks[i]->dxy(the_pvtx.position());
01360       } else {
01361         d0 = tracks[i]->d0();
01362       }
01363       h_TkD0_[match]->Fill ( d0* tracks[i]->charge() );
01364       h_nHitsBeforeVtx_[match]->Fill ( aConv.nHitsBeforeVtx().size()>1 ? aConv.nHitsBeforeVtx().at(i) : 0 );
01365       h_dlClosestHitToVtx_[match]->Fill ( aConv.dlClosestHitToVtx().size()>1 ? aConv.dlClosestHitToVtx().at(i).value() : 0 );
01366       h_dlClosestHitToVtxSig_[match]->Fill ( aConv.dlClosestHitToVtx().size()>1 ? aConv.dlClosestHitToVtx().at(i).value()/aConv.dlClosestHitToVtx().at(i).error() : 0 );
01367 
01368       nHitsVsEta_[match] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits()) );
01369       nHitsVsR_[match] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits()) );
01370       p_nHitsVsEta_[match] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits()) -0.0001);
01371       p_nHitsVsR_[match] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits()) -0.0001);
01372       h_tkChi2_[match] ->Fill (tracks[i]->normalizedChi2() );
01373       h_tkChi2Large_[match] ->Fill (tracks[i]->normalizedChi2() );
01374       h2_Chi2VsEta_[match] ->Fill(  mcEta_, tracks[i]->normalizedChi2() );
01375       h2_Chi2VsR_[match] ->Fill(  mcConvR_, tracks[i]->normalizedChi2() );
01376       p_Chi2VsEta_[match] ->Fill(  mcEta_, tracks[i]->normalizedChi2() );
01377       p_Chi2VsR_[match] ->Fill(  mcConvR_, tracks[i]->normalizedChi2() );
01378 
01379     }
01380 
01381     bool associated = false;
01382     float mcConvPt_= -99999999;
01383     //    float mcPhi= 0; // unused
01384     float simPV_Z=0;
01385     for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
01386       mcConvPt_= (*mcPho).fourMomentum().et();
01387       float mcPhi= (*mcPho).fourMomentum().phi();
01388       simPV_Z = (*mcPho).primaryVertex().z();
01389       mcPhi_= phiNormalization(mcPhi);
01390       mcEta_= (*mcPho).fourMomentum().pseudoRapidity();
01391       mcEta_ = etaTransformation(mcEta_, (*mcPho).primaryVertex().z() );
01392       mcConvR_= (*mcPho).vertex().perp();
01393       mcConvX_= (*mcPho).vertex().x();
01394       mcConvY_= (*mcPho).vertex().y();
01395       mcConvZ_= (*mcPho).vertex().z();
01396       mcConvEta_= (*mcPho).vertex().eta();
01397       mcConvPhi_= (*mcPho).vertex().phi();
01398       if ( fabs(mcEta_) > END_HI ) continue;
01399       if (mcConvPt_<minPhoPtForPurity) continue;
01400       if (fabs(mcEta_)>maxPhoEtaForPurity) continue;
01401       if (fabs(mcConvZ_)>maxPhoZForPurity) continue;
01402       if (mcConvR_>maxPhoRForEffic) continue;
01403 
01404       if (  (*mcPho).isAConversion() != 1 ) continue;
01405       if (!( ( fabs(mcEta_) <= BARL && mcConvR_ <85 )  ||
01406              ( fabs(mcEta_) > BARL && fabs(mcEta_) <=END_HI && fabs( (*mcPho).vertex().z() ) < 210 )  ) )
01407         continue;
01408 
01409 
01410       theConvTP_.clear();
01411       for(size_t i = 0; i < tpForFakeRate.size(); ++i){
01412         TrackingParticleRef tp (TPHandleForFakeRate,i);
01413         if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.0001   &&
01414              fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.0001   &&
01415              fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.0001) {
01416           theConvTP_.push_back( tp );
01417 
01418 
01419         }
01420       }
01421 
01422       if ( theConvTP_.size() < 2 )   continue;
01423 
01424       //associated = false;
01425       reco::RecoToSimCollection p1 =  theTrackAssociator_->associateRecoToSim(tc1,theConvTP_,&e,&esup);
01426       reco::RecoToSimCollection p2 =  theTrackAssociator_->associateRecoToSim(tc2,theConvTP_,&e,&esup);
01427       try{
01428         std::vector<std::pair<TrackingParticleRef, double> > tp1 = p1[tk1];
01429         std::vector<std::pair<TrackingParticleRef, double> > tp2 = p2[tk2];
01430         if (!(tp1.size()&&tp2.size())){
01431             tp1 = p1[tk2];
01432             tp2 = p2[tk1];
01433         }
01434         if (tp1.size()&&tp2.size()) {
01435           TrackingParticleRef tpr1 = tp1.front().first;
01436           TrackingParticleRef tpr2 = tp2.front().first;
01437           if (abs(tpr1->pdgId())==11&&abs(tpr2->pdgId())==11&& tpr1->pdgId()*tpr2->pdgId()<0) {
01438             if ( (tpr1->parentVertex()->sourceTracks_end()-tpr1->parentVertex()->sourceTracks_begin()==1) &&
01439                  (tpr2->parentVertex()->sourceTracks_end()-tpr2->parentVertex()->sourceTracks_begin()==1)) {
01440               if (tpr1->parentVertex().key()==tpr2->parentVertex().key() && ((*tpr1->parentVertex()->sourceTracks_begin())->pdgId()==22)) {
01441                 mcConvR_ = sqrt(tpr1->parentVertex()->position().Perp2());
01442                 mcConvZ_ = tpr1->parentVertex()->position().z();
01443                 mcConvX_ = tpr1->parentVertex()->position().x();
01444                 mcConvY_ = tpr1->parentVertex()->position().y();
01445                 mcConvEta_ = tpr1->parentVertex()->position().eta();
01446                 mcConvPhi_ = tpr1->parentVertex()->position().phi();
01447                 mcConvPt_ = sqrt((*tpr1->parentVertex()->sourceTracks_begin())->momentum().Perp2());
01448                 //std::cout << " Reco to Sim mcconvpt " << mcConvPt_ << std::endl;
01449                 //cout << "associated track1 to " << tpr1->pdgId() << " with p=" << tpr1->p4() << " with pT=" << tpr1->pt() << endl;
01450                 //cout << "associated track2 to " << tpr2->pdgId() << " with p=" << tpr2->p4() << " with pT=" << tpr2->pt() << endl;
01451                 associated = true;
01452                 break;
01453               }
01454             }
01455           }
01456         }
01457       } catch (Exception event) {
01458         //cout << "do not continue: " << event.what()  << endl;
01459         //continue;
01460       }
01461 
01462     }// end loop on sim photons
01463 
01464 
01465     if (0) {
01466         theConvTP_.clear();
01467         for(size_t i = 0; i < tpForFakeRate.size(); ++i){
01468           TrackingParticleRef tp (TPHandleForFakeRate,i);
01469             theConvTP_.push_back( tp );
01470         }
01471         reco::RecoToSimCollection p1incl =  theTrackAssociator_->associateRecoToSim(tc1,theConvTP_,&e,&esup);
01472         reco::RecoToSimCollection p2incl =  theTrackAssociator_->associateRecoToSim(tc2,theConvTP_,&e,&esup);
01473 
01474 
01475       for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
01476         mcConvPt_= (*mcPho).fourMomentum().et();
01477         float mcPhi= (*mcPho).fourMomentum().phi();
01478         simPV_Z = (*mcPho).primaryVertex().z();
01479         mcPhi_= phiNormalization(mcPhi);
01480         mcEta_= (*mcPho).fourMomentum().pseudoRapidity();
01481         mcEta_ = etaTransformation(mcEta_, (*mcPho).primaryVertex().z() );
01482         mcConvR_= (*mcPho).vertex().perp();
01483         mcConvX_= (*mcPho).vertex().x();
01484         mcConvY_= (*mcPho).vertex().y();
01485         mcConvZ_= (*mcPho).vertex().z();
01486         mcConvEta_= (*mcPho).vertex().eta();
01487         mcConvPhi_= (*mcPho).vertex().phi();
01488         if ( fabs(mcEta_) > END_HI ) continue;
01489         if (mcConvPt_<minPhoPtForPurity) continue;
01490         if (fabs(mcEta_)>maxPhoEtaForPurity) continue;
01491         if (fabs(mcConvZ_)>maxPhoZForPurity) continue;
01492         if (mcConvR_>maxPhoRForEffic) continue;
01493 
01494         if (  (*mcPho).isAConversion() != 1 ) continue;
01495         if (!( ( fabs(mcEta_) <= BARL && mcConvR_ <85 )  ||
01496               ( fabs(mcEta_) > BARL && fabs(mcEta_) <=END_HI && fabs( (*mcPho).vertex().z() ) < 210 )  ) )
01497           continue;
01498 
01499 
01500         theConvTP_.clear();
01501         for(size_t i = 0; i < tpForFakeRate.size(); ++i){
01502           TrackingParticleRef tp (TPHandleForFakeRate,i);
01503           if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.0001   &&
01504               fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.0001   &&
01505               fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.0001) {
01506             theConvTP_.push_back( tp );
01507 
01508 
01509           }
01510         }
01511 
01512         if ( theConvTP_.size() < 2 )   continue;
01513 
01514         //associated = false;
01515         reco::RecoToSimCollection p1 =  theTrackAssociator_->associateRecoToSim(tc1,theConvTP_,&e,&esup);
01516         reco::RecoToSimCollection p2 =  theTrackAssociator_->associateRecoToSim(tc2,theConvTP_,&e,&esup);
01517 
01518 
01519 
01520 
01521 
01522           if ( (p1incl.size() && p2incl.size()) && (p1.size() || p2.size()) ) { // associated = true;
01523             try{
01524               std::vector<std::pair<TrackingParticleRef, double> > tp1 = p1incl[tk1];
01525               std::vector<std::pair<TrackingParticleRef, double> > tp2 = p2incl[tk2];
01526               if (!(tp1.size()&&tp2.size())){
01527                   tp1 = p1[tk2];
01528                   tp2 = p2[tk1];
01529               }
01530               if (tp1.size()&&tp2.size()) {
01531                 TrackingParticleRef tpr1 = tp1.front().first;
01532                 TrackingParticleRef tpr2 = tp2.front().first;
01533                 if (abs(tpr1->pdgId())==11&&abs(tpr2->pdgId())==11 && tpr1->pdgId()*tpr2->pdgId()<0) {
01534                   if ( ((tpr1->parentVertex()->sourceTracks_end()-tpr1->parentVertex()->sourceTracks_begin()>=1) && (*tpr1->parentVertex()->sourceTracks_begin())->pdgId()==22) &&
01535                       ((tpr2->parentVertex()->sourceTracks_end()-tpr2->parentVertex()->sourceTracks_begin()>=1) && (*tpr2->parentVertex()->sourceTracks_begin())->pdgId()==22) ) {
01536 
01537                    // if ( fabs(tpr1->vx() - tpr2->vx()) < 0.1 && fabs(tpr1->vy() - tpr2->vy()) < 0.1 && fabs(tpr1->vz() - tpr2->vz()) < 0.1) {
01538                     //if (((*tpr1->parentVertex()->sourceTracks_begin())->pdgId()==22) || ((*tpr2->parentVertex()->sourceTracks_begin())->pdgId()==22)) {
01539 //                       mcConvR_ = sqrt(tpr1->parentVertex()->position().Perp2());
01540 //                       mcConvZ_ = tpr1->parentVertex()->position().z();
01541 //                       mcConvX_ = tpr1->parentVertex()->position().x();
01542 //                       mcConvY_ = tpr1->parentVertex()->position().y();
01543 //                       mcConvEta_ = tpr1->parentVertex()->position().eta();
01544 //                       mcConvPhi_ = tpr1->parentVertex()->position().phi();
01545 //                       mcConvPt_ = sqrt((*tpr1->parentVertex()->sourceTracks_begin())->momentum().Perp2());
01546                       //std::cout << " Reco to Sim mcconvpt " << mcConvPt_ << std::endl;
01547                       //cout << "associated track1 to " << tpr1->pdgId() << " with p=" << tpr1->p4() << " with pT=" << tpr1->pt() << endl;
01548                       //cout << "associated track2 to " << tpr2->pdgId() << " with p=" << tpr2->p4() << " with pT=" << tpr2->pt() << endl;
01549                       associated = true;
01550                       break;
01551                     //}
01552                     //}
01553                   }
01554                 }
01555               }
01556             } catch (Exception event) {
01557               //cout << "do not continue: " << event.what()  << endl;
01558               //continue;
01559             }
01560 
01561           }
01562 
01563         }
01564       }
01565 
01566       if ( associated ) match=1;
01567       else
01568         match=2;
01569 
01570       h_match_->Fill(float(match));
01572       if ( match == 1) nRecConvAss_++;
01573       h_convEta_[match][0]->Fill( refittedMom.eta() );
01574       h_convEta_[match][1]->Fill( refittedMom.eta() );
01575       if (matchConvSC) h_convEtaMatchSC_[match][0]->Fill( refittedMom.eta() );
01576       h_convPhi_[match][0]->Fill( refittedMom.phi() );
01577       h_convR_[match][0]->Fill( sqrt(aConv.conversionVertex().position().perp2()) );
01578       h_convZ_[match][0]->Fill( aConv.conversionVertex().position().z() );
01579       h_convPt_[match][0]->Fill(  sqrt(refittedMom.perp2()) );
01580       h_invMass_[match][0] ->Fill( invM);
01581       h_vtxChi2Prob_[match][0] ->Fill (chi2Prob);
01582       h_DPhiTracksAtVtx_[match][0]->Fill( dPhiTracksAtVtx);
01583       h_DCotTracks_[match][0] ->Fill ( aConv.pairCotThetaSeparation() );
01584       h_distMinAppTracks_[match][0] ->Fill (aConv.distOfMinimumApproach());
01585       h_lxybs_[match][0] ->Fill (lxy);
01586       h_maxNHitsBeforeVtx_[match][0] ->Fill (maxNHitsBeforeVtx);
01587       h_leadNHitsBeforeVtx_[match][0] ->Fill (leadNHitsBeforeVtx);
01588       h_trailNHitsBeforeVtx_[match][0] ->Fill (trailNHitsBeforeVtx);
01589       h_sumNHitsBeforeVtx_[match][0] ->Fill (sumNHitsBeforeVtx);
01590       h_deltaExpectedHitsInner_[match][0] ->Fill (deltaExpectedHitsInner);
01591       h_leadExpectedHitsInner_[match][0] ->Fill (leadExpectedHitsInner);
01592       h_maxDlClosestHitToVtx_[match][0] ->Fill (maxDlClosestHitToVtx);
01593       h_maxDlClosestHitToVtxSig_[match][0] ->Fill (maxDlClosestHitToVtxSig);
01594       h_nSharedHits_[match][0] ->Fill (aConv.nSharedHits());
01595       if (  matchConvSC ) {
01596         //h_EoverPTracks_[match][0] ->Fill (aConv.EoverPrefittedTracks());
01597         h_EoverPTracks_[match][0] ->Fill (iMatchingSC->superCluster()->energy()/sqrt(refittedMom.mag2()));
01598         h_convSCdPhi_[match][0]->Fill( iMatchingSC->superCluster()->position().phi() - refittedMom.phi() );
01599         double ConvEta = etaTransformation(aConv.refittedPairMomentum().eta(),aConv.zOfPrimaryVertexFromTracks());
01600         h_convSCdEta_[match][0]->Fill( iMatchingSC->superCluster()->position().eta() - ConvEta );
01601         
01602       }
01603       if ( match==1) {
01604         h2_photonPtRecVsPtSim_->Fill ( mcConvPt_, sqrt(refittedMom.perp2()) );
01605         h_convPtRes_[0]->Fill (  sqrt(refittedMom.perp2())/mcConvPt_);
01606       }
01607 
01608     if ( phoIsInBarrel ) {
01609       h_invMass_[match][1] ->Fill(invM);
01610       h_vtxChi2Prob_[match][1] ->Fill (chi2Prob);
01611       h_DPhiTracksAtVtx_[match][1]->Fill( dPhiTracksAtVtx);
01612       h_DCotTracks_[match][1] ->Fill ( aConv.pairCotThetaSeparation() );
01613       h_distMinAppTracks_[match][1] ->Fill (aConv.distOfMinimumApproach());
01614       h_lxybs_[match][1] ->Fill (lxy);
01615       h_maxNHitsBeforeVtx_[match][1] ->Fill (maxNHitsBeforeVtx);
01616       h_leadNHitsBeforeVtx_[match][1] ->Fill (leadNHitsBeforeVtx);
01617       h_trailNHitsBeforeVtx_[match][1] ->Fill (trailNHitsBeforeVtx);
01618       h_sumNHitsBeforeVtx_[match][1] ->Fill (sumNHitsBeforeVtx);
01619       h_deltaExpectedHitsInner_[match][1] ->Fill (deltaExpectedHitsInner);
01620       h_leadExpectedHitsInner_[match][1] ->Fill (leadExpectedHitsInner);
01621       h_maxDlClosestHitToVtx_[match][1] ->Fill (maxDlClosestHitToVtx);
01622       h_maxDlClosestHitToVtxSig_[match][1] ->Fill (maxDlClosestHitToVtxSig);
01623       h_nSharedHits_[match][1] ->Fill (aConv.nSharedHits());
01624       if (  matchConvSC ) {
01625         //      h_EoverPTracks_[match][1] ->Fill (aConv.EoverPrefittedTracks());
01626         h_EoverPTracks_[match][1] ->Fill (iMatchingSC->superCluster()->energy()/sqrt(refittedMom.mag2()));
01627         h_convSCdPhi_[match][1]->Fill( iMatchingSC->superCluster()->position().phi() - refittedMom.phi() );
01628         double ConvEta = etaTransformation(aConv.refittedPairMomentum().eta(),aConv.zOfPrimaryVertexFromTracks());
01629         h_convSCdEta_[match][1]->Fill( iMatchingSC->superCluster()->position().eta() - ConvEta );
01630 
01631       }
01632       if ( match==1) h_convPtRes_[1]->Fill (  sqrt(refittedMom.perp2())/mcConvPt_);
01633     }
01634 
01635 
01636     if ( phoIsInEndcap ) {
01637       h_invMass_[match][2] ->Fill(invM);
01638       h_vtxChi2Prob_[match][2] ->Fill (chi2Prob);
01639       h_DPhiTracksAtVtx_[match][2]->Fill( dPhiTracksAtVtx);
01640       h_DCotTracks_[match][2] ->Fill ( aConv.pairCotThetaSeparation() );
01641       h_distMinAppTracks_[match][2] ->Fill (aConv.distOfMinimumApproach());
01642       h_lxybs_[match][2] ->Fill (lxy);
01643       h_maxNHitsBeforeVtx_[match][2] ->Fill (maxNHitsBeforeVtx);
01644       h_leadNHitsBeforeVtx_[match][2] ->Fill (leadNHitsBeforeVtx);
01645       h_trailNHitsBeforeVtx_[match][2] ->Fill (trailNHitsBeforeVtx);
01646       h_sumNHitsBeforeVtx_[match][2] ->Fill (sumNHitsBeforeVtx);
01647       h_deltaExpectedHitsInner_[match][2] ->Fill (deltaExpectedHitsInner);
01648       h_leadExpectedHitsInner_[match][2] ->Fill (leadExpectedHitsInner);
01649       h_maxDlClosestHitToVtx_[match][2] ->Fill (maxDlClosestHitToVtx);
01650       h_maxDlClosestHitToVtxSig_[match][2] ->Fill (maxDlClosestHitToVtxSig);
01651       h_nSharedHits_[match][2] ->Fill (aConv.nSharedHits());
01652       if (  matchConvSC ) {
01653         //      h_EoverPTracks_[match][2] ->Fill (aConv.EoverPrefittedTracks());
01654         h_EoverPTracks_[match][2] ->Fill (iMatchingSC->superCluster()->energy()/sqrt(refittedMom.mag2()));
01655         h_convSCdPhi_[match][2]->Fill( iMatchingSC->superCluster()->position().phi() - refittedMom.phi() );
01656         double ConvEta = etaTransformation(aConv.refittedPairMomentum().eta(),aConv.zOfPrimaryVertexFromTracks());
01657         h_convSCdEta_[match][2]->Fill( iMatchingSC->superCluster()->position().eta() - ConvEta );
01658       }
01659       if ( match==1) h_convPtRes_[2]->Fill (  sqrt(refittedMom.perp2())/mcConvPt_);
01660     }
01661 
01662 
01663     if ( match == 1 ) {
01664       h_convVtxdX_ ->Fill ( aConv.conversionVertex().position().x() - mcConvX_);
01665       h_convVtxdY_ ->Fill ( aConv.conversionVertex().position().y() - mcConvY_);
01666       h_convVtxdZ_ ->Fill ( aConv.conversionVertex().position().z() - mcConvZ_);
01667       h_convVtxdR_ ->Fill ( sqrt(aConv.conversionVertex().position().perp2()) - mcConvR_);
01668       h_convVtxdPhi_ ->Fill ( aConv.conversionVertex().position().phi() - mcConvPhi_);
01669       h_convVtxdEta_ ->Fill ( aConv.conversionVertex().position().eta() - mcConvEta_);
01670       h2_convVtxdRVsR_ ->Fill (mcConvR_, sqrt(aConv.conversionVertex().position().perp2()) - mcConvR_ );
01671       h2_convVtxdRVsEta_ ->Fill (mcEta_, sqrt(aConv.conversionVertex().position().perp2()) - mcConvR_ );
01672       p_convVtxdRVsR_ ->Fill (mcConvR_, sqrt(aConv.conversionVertex().position().perp2()) - mcConvR_ );
01673       p_convVtxdRVsEta_ ->Fill (mcEta_, sqrt(aConv.conversionVertex().position().perp2()) - mcConvR_ );
01674       p_convVtxdXVsX_ ->Fill (mcConvX_, aConv.conversionVertex().position().x() - mcConvX_ );
01675       p_convVtxdYVsY_ ->Fill (mcConvY_, aConv.conversionVertex().position().y() - mcConvY_ );
01676       p_convVtxdZVsZ_ ->Fill (mcConvZ_, aConv.conversionVertex().position().z() - mcConvZ_ );
01677       p_convVtxdZVsR_ ->Fill (mcConvR_, aConv.conversionVertex().position().z() - mcConvZ_ );
01678 
01679       float dR=sqrt(aConv.conversionVertex().position().perp2()) - mcConvR_;
01680       float dZ=aConv.conversionVertex().position().z() - mcConvZ_;
01681       p2_convVtxdRVsRZ_ ->Fill (mcConvZ_,mcConvR_, dR );
01682       p2_convVtxdZVsRZ_ ->Fill (mcConvZ_,mcConvR_, dZ );
01683 
01684 
01685 
01686 
01687       h2_convVtxRrecVsTrue_ -> Fill (mcConvR_, sqrt(aConv.conversionVertex().position().perp2()) );
01688 
01689 
01690       h_zPVFromTracks_[match]->Fill ( aConv.zOfPrimaryVertexFromTracks() );
01691       h_dzPVFromTracks_[match]->Fill ( aConv.zOfPrimaryVertexFromTracks() - simPV_Z );
01692       h2_dzPVVsR_ ->Fill(mcConvR_, aConv.zOfPrimaryVertexFromTracks() - simPV_Z );
01693       p_dzPVVsR_ ->Fill(mcConvR_, aConv.zOfPrimaryVertexFromTracks() - simPV_Z );
01694 
01695       if ( phoIsInBarrel ) {
01696         h_convVtxdX_barrel_ ->Fill ( aConv.conversionVertex().position().x() - mcConvX_);
01697         h_convVtxdY_barrel_ ->Fill ( aConv.conversionVertex().position().y() - mcConvY_);
01698         h_convVtxdZ_barrel_ ->Fill ( aConv.conversionVertex().position().z() - mcConvZ_);
01699         h_convVtxdR_barrel_ ->Fill ( sqrt(aConv.conversionVertex().position().perp2()) - mcConvR_);
01700 
01701       }
01702       if ( phoIsInEndcap ) {
01703         h_convVtxdX_endcap_ ->Fill ( aConv.conversionVertex().position().x() - mcConvX_);
01704         h_convVtxdY_endcap_ ->Fill ( aConv.conversionVertex().position().y() - mcConvY_);
01705         h_convVtxdZ_endcap_ ->Fill ( aConv.conversionVertex().position().z() - mcConvZ_);
01706         h_convVtxdR_endcap_ ->Fill ( sqrt(aConv.conversionVertex().position().perp2()) - mcConvR_);
01707 
01708       }
01709 
01710 
01711     }
01712 
01714     for (unsigned int i=0; i<tracks.size(); i++) {
01715       //std::cout << " Loop over tracks  pt " << tracks[i]->pt() << std::endl;
01716       RefToBase<reco::Track> tfrb(aConv.tracks()[i] );
01717       itAss= myAss.find( tfrb.get() );
01718 
01719       nHitsVsEta_[match] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits()) );
01720       nHitsVsR_[match] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits()) );
01721       p_nHitsVsEta_[match] ->Fill (mcEta_,   float(tracks[i]->numberOfValidHits()) -0.0001);
01722       p_nHitsVsR_[match] ->Fill (mcConvR_,   float(tracks[i]->numberOfValidHits()) -0.0001);
01723       h_tkChi2_[match] ->Fill (tracks[i]->normalizedChi2() );
01724       h_tkChi2Large_[match] ->Fill (tracks[i]->normalizedChi2() );
01725       h2_Chi2VsEta_[match] ->Fill(  mcEta_, tracks[i]->normalizedChi2() );
01726       h2_Chi2VsR_[match] ->Fill(  mcConvR_, tracks[i]->normalizedChi2() );
01727       p_Chi2VsEta_[match] ->Fill(  mcEta_, tracks[i]->normalizedChi2() );
01728       p_Chi2VsR_[match] ->Fill(  mcConvR_, tracks[i]->normalizedChi2() );
01729       double d0;
01730       if (valid_pvtx){
01731         d0 = - tracks[i]->dxy(the_pvtx.position());
01732       } else {
01733         d0 = tracks[i]->d0();
01734       }
01735       h_TkD0_[match]->Fill (d0* tracks[i]->charge() );
01736       h_nHitsBeforeVtx_[match]->Fill ( aConv.nHitsBeforeVtx().size()>1 ? aConv.nHitsBeforeVtx().at(i) : 0 );
01737       h_dlClosestHitToVtx_[match]->Fill ( aConv.dlClosestHitToVtx().size()>1 ? aConv.dlClosestHitToVtx().at(i).value() : 0 );
01738       h_dlClosestHitToVtxSig_[match]->Fill ( aConv.dlClosestHitToVtx().size()>1 ? aConv.dlClosestHitToVtx().at(i).value()/aConv.dlClosestHitToVtx().at(i).error() : 0 );
01739 
01740 
01741       if ( itAss == myAss.end()  ) continue;
01742       reco::Track refTrack= aConv.conversionVertex().refittedTracks()[i];
01743 
01744       float simPt = sqrt( ((*itAss).second)->momentum().perp2() );
01745       float recPt = refTrack.pt();
01746       float ptres= recPt - simPt ;
01747       //float pterror = aConv.tracks()[i]->ptError();
01748       float pterror = aConv.conversionVertex().refittedTracks()[i].ptError();
01749       h2_PtRecVsPtSim_[0]->Fill ( simPt, recPt);
01750       h_TkPtPull_[0] ->Fill(ptres/pterror);
01751       h2_TkPtPull_[0] ->Fill(mcEta_, ptres/pterror);
01752 
01753       if ( phoIsInBarrel ) {
01754         h_TkPtPull_[1] ->Fill(ptres/pterror);
01755         h2_PtRecVsPtSim_[1]->Fill ( simPt, recPt);
01756       }
01757       if ( phoIsInEndcap ) {
01758         h_TkPtPull_[2] ->Fill(ptres/pterror);
01759         h2_PtRecVsPtSim_[2]->Fill ( simPt, recPt);
01760       }
01761     } // end loop over track
01762 
01763 
01764 
01765   } // loop over reco conversions
01766 
01767 
01768   h_nConv_[0][0]->Fill (float(nRecConv_));
01769   h_nConv_[1][0]->Fill (float(nRecConvAss_));
01770 
01771 
01772 
01773 }
01774 
01775 
01776 
01777 
01778 
01779 void TkConvValidator::endJob() {
01780 
01781 
01782   std::string outputFileName = parameters_.getParameter<std::string>("OutputFileName");
01783   if ( ! isRunCentrally_ ) {
01784     dbe_->save(outputFileName);
01785   }
01786 
01787   edm::LogInfo("TkConvValidator") << "Analyzed " << nEvt_  << "\n";
01788   // std::cout  << "::endJob Analyzed " << nEvt_ << " events " << " with total " << nPho_ << " Photons " << "\n";
01789   //  std::cout  << "TkConvValidator::endJob Analyzed " << nEvt_ << " events " << "\n";
01790 
01791   return ;
01792 }
01793 
01794 
01795 math::XYZVector TkConvValidator::recalculateMomentumAtFittedVertex ( const MagneticField& mf, const TrackerGeometry& trackerGeom, const  edm::RefToBase<reco::Track>&   tk, const reco::Vertex& vtx) {
01796 
01797   math::XYZVector result;
01798   Surface::RotationType rot;
01799   auto scp = new SimpleCylinderBounds(  sqrt(vtx.position().perp2())-0.001f,
01800                                         sqrt(vtx.position().perp2())+0.001f,
01801                                         -fabs(vtx.position().z()),
01802                                          fabs(vtx.position().z())
01803                                      );
01804   ReferenceCountingPointer<Cylinder>  theBarrel_(new Cylinder(Cylinder::computeRadius(*scp), Surface::PositionType(0,0,0), rot,scp));
01805 
01806   ReferenceCountingPointer<Disk>      theDisk_(new Disk( Surface::PositionType( 0, 0, vtx.position().z()), rot,
01807                                                                    new SimpleDiskBounds( 0,  sqrt(vtx.position().perp2()), -0.001, 0.001) )
01808                                               );
01809 
01810   
01811   const TrajectoryStateOnSurface myTSOS = trajectoryStateTransform::innerStateOnSurface(*tk, trackerGeom, &mf);
01812   PropagatorWithMaterial propag( anyDirection, 0.000511, &mf );
01813   TrajectoryStateOnSurface  stateAtVtx;
01814   stateAtVtx = propag.propagate(myTSOS, *theBarrel_);
01815   if (!stateAtVtx.isValid() ) {
01816     stateAtVtx = propag.propagate(myTSOS, *theDisk_);
01817   }
01818   if (stateAtVtx.isValid()){
01819     return  math::XYZVector ( double(stateAtVtx.globalMomentum().x()), double(stateAtVtx.globalMomentum().y()), double(stateAtVtx.globalMomentum().z()));
01820   } else {
01821     return  math::XYZVector(0.,0.,0.);
01822   }
01823 
01824 
01825 
01826 }
01827 
01828 
01829 float TkConvValidator::phiNormalization(float & phi)
01830 {
01831   //---Definitions
01832   const float PI    = 3.1415927;
01833   const float TWOPI = 2.0*PI;
01834 
01835 
01836   if(phi >  PI) {phi = phi - TWOPI;}
01837   if(phi < -PI) {phi = phi + TWOPI;}
01838 
01839   //  cout << " Float_t PHInormalization out " << PHI << endl;
01840   return phi;
01841 
01842 }
01843 
01844 
01845 float TkConvValidator::etaTransformation(  float EtaParticle , float Zvertex)  {
01846 
01847   //---Definitions
01848   const float PI    = 3.1415927;
01849 
01850   //---Definitions for ECAL
01851   const float R_ECAL           = 136.5;
01852   const float Z_Endcap         = 328.0;
01853   const float etaBarrelEndcap  = 1.479;
01854 
01855   //---ETA correction
01856 
01857   float Theta = 0.0  ;
01858   float ZEcal = R_ECAL*sinh(EtaParticle)+Zvertex;
01859 
01860   if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
01861   if(Theta<0.0) Theta = Theta+PI ;
01862   float ETA = - log(tan(0.5*Theta));
01863 
01864   if( fabs(ETA) > etaBarrelEndcap )
01865     {
01866       float Zend = Z_Endcap ;
01867       if(EtaParticle<0.0 )  Zend = -Zend ;
01868       float Zlen = Zend - Zvertex ;
01869       float RR = Zlen/sinh(EtaParticle);
01870       Theta = atan(RR/Zend);
01871       if(Theta<0.0) Theta = Theta+PI ;
01872       ETA = - log(tan(0.5*Theta));
01873     }
01874   //---Return the result
01875   return ETA;
01876   //---end
01877 }
01878 
01879