CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/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 TrackingParticle::Vector
00015 ParametersDefinerForTP::momentum(const edm::Event& iEvent, const edm::EventSetup& iSetup,
00016         const Charge charge, const Point & vtx, const LorentzVector& lv) const {
00017   // to add a new implementation for cosmic. For the moment, it is just as for the base class:
00018 
00019   using namespace edm;
00020 
00021   edm::ESHandle<MagneticField> theMF;
00022   iSetup.get<IdealMagneticFieldRecord>().get(theMF);
00023   
00024   edm::Handle<reco::BeamSpot> bs;
00025   iEvent.getByLabel(InputTag("offlineBeamSpot"),bs);
00026 
00027   TrackingParticle::Vector momentum(0, 0, 0); 
00028 
00029   FreeTrajectoryState ftsAtProduction(GlobalPoint(vtx.x(),vtx.y(),vtx.z()),
00030                                       GlobalVector(lv.x(),lv.y(),lv.z()),
00031                                       TrackCharge(charge),
00032                                       theMF.product());
00033         
00034   TSCBLBuilderNoMaterial tscblBuilder;
00035   TrajectoryStateClosestToBeamLine tsAtClosestApproach = tscblBuilder(ftsAtProduction,*bs);//as in TrackProducerAlgorithm
00036   if(tsAtClosestApproach.isValid()){
00037     GlobalVector p = tsAtClosestApproach.trackStateAtPCA().momentum();
00038     momentum = TrackingParticle::Vector(p.x(), p.y(), p.z());
00039   }
00040   return momentum;
00041 }
00042 
00043 TrackingParticle::Point ParametersDefinerForTP::vertex(const edm::Event& iEvent, const edm::EventSetup& iSetup,
00044         const Charge charge, const Point & vtx, const LorentzVector& lv) const {
00045   // to add a new implementation for cosmic. For the moment, it is just as for the base class:
00046   using namespace edm;
00047 
00048   edm::ESHandle<MagneticField> theMF;
00049   iSetup.get<IdealMagneticFieldRecord>().get(theMF);
00050   
00051   edm::Handle<reco::BeamSpot> bs;
00052   iEvent.getByLabel(InputTag("offlineBeamSpot"),bs);
00053 
00054   TrackingParticle::Point vertex(0, 0, 0);
00055   
00056   FreeTrajectoryState ftsAtProduction(GlobalPoint(vtx.x(),vtx.y(),vtx.z()),
00057                                       GlobalVector(lv.x(),lv.y(),lv.z()),
00058                                       TrackCharge(charge),
00059                                       theMF.product());
00060         
00061   TSCBLBuilderNoMaterial tscblBuilder;
00062   TrajectoryStateClosestToBeamLine tsAtClosestApproach = tscblBuilder(ftsAtProduction,*bs);//as in TrackProducerAlgorithm
00063   if(tsAtClosestApproach.isValid()){
00064     GlobalPoint v = tsAtClosestApproach.trackStateAtPCA().position();
00065     vertex = TrackingParticle::Point(v.x()-bs->x0(),v.y()-bs->y0(),v.z()-bs->z0());
00066   }
00067   return vertex;
00068 }
00069 
00070 
00071 TYPELOOKUP_DATA_REG(ParametersDefinerForTP);