CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/SimTracker/TrackAssociation/src/ParametersDefinerForTP.cc

Go to the documentation of this file.
00001 #include "SimTracker/TrackAssociation/interface/ParametersDefinerForTP.h"
00002 #include "FWCore/Utilities/interface/typelookup.h"
00003 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00004 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00005 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00006 #include "TrackingTools/PatternTools/interface/TSCBLBuilderNoMaterial.h"
00007 #include "TrackingTools/PatternTools/interface/TSCPBuilderNoMaterial.h"
00008 #include "MagneticField/Engine/interface/MagneticField.h" 
00009 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00010 #include "FWCore/Framework/interface/Event.h"
00011 #include <FWCore/Framework/interface/ESHandle.h>
00012 class TrajectoryStateClosestToBeamLineBuilder;
00013 
00014 ParticleBase::Vector
00015 ParametersDefinerForTP::momentum(const edm::Event& iEvent, const edm::EventSetup& iSetup, const TrackingParticle& tp) const{
00016   // to add a new implementation for cosmic. For the moment, it is just as for the base class:
00017 
00018   using namespace edm;
00019 
00020   edm::ESHandle<MagneticField> theMF;
00021   iSetup.get<IdealMagneticFieldRecord>().get(theMF);
00022   
00023   edm::Handle<reco::BeamSpot> bs;
00024   iEvent.getByLabel(InputTag("offlineBeamSpot"),bs);
00025 
00026   ParticleBase::Vector momentum(0, 0, 0); 
00027 
00028   FreeTrajectoryState ftsAtProduction(GlobalPoint(tp.vertex().x(),tp.vertex().y(),tp.vertex().z()),
00029                                       GlobalVector(tp.momentum().x(),tp.momentum().y(),tp.momentum().z()),
00030                                       TrackCharge(tp.charge()),
00031                                       theMF.product());
00032         
00033   TSCBLBuilderNoMaterial tscblBuilder;
00034   TrajectoryStateClosestToBeamLine tsAtClosestApproach = tscblBuilder(ftsAtProduction,*bs);//as in TrackProducerAlgorithm
00035   if(tsAtClosestApproach.isValid()){
00036     GlobalVector p = tsAtClosestApproach.trackStateAtPCA().momentum();
00037     momentum = ParticleBase::Vector(p.x(), p.y(), p.z());
00038   }
00039   return momentum;
00040 }
00041 
00042 ParticleBase::Point ParametersDefinerForTP::vertex(const edm::Event& iEvent, const edm::EventSetup& iSetup, const TrackingParticle& tp) const{
00043   // to add a new implementation for cosmic. For the moment, it is just as for the base class:
00044   using namespace edm;
00045 
00046   edm::ESHandle<MagneticField> theMF;
00047   iSetup.get<IdealMagneticFieldRecord>().get(theMF);
00048   
00049   edm::Handle<reco::BeamSpot> bs;
00050   iEvent.getByLabel(InputTag("offlineBeamSpot"),bs);
00051 
00052   ParticleBase::Point vertex(0, 0, 0);
00053   
00054   FreeTrajectoryState ftsAtProduction(GlobalPoint(tp.vertex().x(),tp.vertex().y(),tp.vertex().z()),
00055                                       GlobalVector(tp.momentum().x(),tp.momentum().y(),tp.momentum().z()),
00056                                       TrackCharge(tp.charge()),
00057                                       theMF.product());
00058         
00059   TSCBLBuilderNoMaterial tscblBuilder;
00060   TrajectoryStateClosestToBeamLine tsAtClosestApproach = tscblBuilder(ftsAtProduction,*bs);//as in TrackProducerAlgorithm
00061   if(tsAtClosestApproach.isValid()){
00062     GlobalPoint v = tsAtClosestApproach.trackStateAtPCA().position();
00063     vertex = ParticleBase::Point(v.x()-bs->x0(),v.y()-bs->y0(),v.z()-bs->z0());
00064   }
00065   return vertex;
00066 }
00067 
00068 
00069 TYPELOOKUP_DATA_REG(ParametersDefinerForTP);