CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/CommonTools/RecoAlgos/src/StandAloneMuonTrackToCandidate.h

Go to the documentation of this file.
00001 #ifndef RecoAlgos_StandAloneMuonTrackToCandidate_h
00002 #define RecoAlgos_StandAloneMuonTrackToCandidate_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/RecoStandAloneMuonCandidate.h"
00007 #include "DataFormats/RecoCandidate/interface/RecoStandAloneMuonCandidateFwd.h"
00008 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00009 
00010 namespace converter {
00011 
00012   struct StandAloneMuonTrackToCandidate : public MassiveCandidateConverter {
00013     typedef reco::Track value_type;
00014     typedef reco::TrackCollection Components;
00015     typedef reco::RecoStandAloneMuonCandidate Candidate;
00016     StandAloneMuonTrackToCandidate(const edm::ParameterSet & cfg) : 
00017       MassiveCandidateConverter(cfg) {
00018     }
00019     void convert(reco::TrackRef trkRef, reco::RecoStandAloneMuonCandidate & 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 StandAloneMuonTrackToCandidate type;
00035     };
00036   }
00037 
00038 }
00039 
00040 #endif