CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/CommonTools/RecoAlgos/src/TrackToCandidate.h

Go to the documentation of this file.
00001 #ifndef RecoAlgos_TrackToCandidate_h
00002 #define RecoAlgos_TrackToCandidate_h
00003 #include "CommonTools/RecoAlgos/src/MassiveCandidateConverter.h"
00004 #include "CommonTools/RecoAlgos/src/CandidateProducer.h"
00005 #include "DataFormats/TrackReco/interface/Track.h"
00006 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
00007 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
00008 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00009 
00010 namespace converter {
00011 
00012   struct TrackToCandidate : public MassiveCandidateConverter {
00013     typedef reco::Track value_type;
00014     typedef reco::TrackCollection Components;
00015     typedef reco::RecoChargedCandidate Candidate;
00016     TrackToCandidate(const edm::ParameterSet & cfg) : 
00017       MassiveCandidateConverter(cfg) {
00018     }
00019     void convert(reco::TrackRef trkRef, reco::RecoChargedCandidate & c) const {
00020       const reco::Track & trk = * trkRef;
00021       c.setCharge(trk.charge());
00022       c.setVertex(trk.vertex());
00023       reco::Track::Vector p = trk.momentum();
00024       double t = sqrt(massSqr_ + p.mag2());
00025       c.setP4(reco::Candidate::LorentzVector(p.x(), p.y(), p.z(), t));
00026       c.setTrack(trkRef);
00027       c.setPdgId(particle_.pdgId());
00028     }  
00029   };
00030 
00031   namespace helper {
00032     template<>
00033     struct CandConverter<reco::Track> { 
00034       typedef TrackToCandidate type;
00035     };
00036   }
00037 
00038 }
00039 
00040 #endif