Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-17 23:10:24

0001 #ifndef RecoAlgos_TrackToCandidate_h
0002 #define RecoAlgos_TrackToCandidate_h
0003 #include "CommonTools/RecoAlgos/interface/MassiveCandidateConverter.h"
0004 #include "CommonTools/RecoAlgos/interface/CandidateProducer.h"
0005 #include "DataFormats/TrackReco/interface/Track.h"
0006 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
0007 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
0008 #include "DataFormats/Candidate/interface/CandidateFwd.h"
0009 
0010 namespace converter {
0011 
0012   struct TrackToCandidate : public MassiveCandidateConverter {
0013     typedef reco::Track value_type;
0014     typedef reco::TrackCollection Components;
0015     typedef reco::RecoChargedCandidate Candidate;
0016     TrackToCandidate(const edm::ParameterSet& cfg, edm::ConsumesCollector iC) : MassiveCandidateConverter(cfg, iC) {}
0017     void convert(reco::TrackRef trkRef, reco::RecoChargedCandidate& c) const {
0018       const reco::Track& trk = *trkRef;
0019       c.setCharge(trk.charge());
0020       c.setVertex(trk.vertex());
0021       const reco::Track::Vector& p = trk.momentum();
0022       double t = sqrt(massSqr_ + p.mag2());
0023       c.setP4(reco::Candidate::LorentzVector(p.x(), p.y(), p.z(), t));
0024       c.setTrack(trkRef);
0025       c.setPdgId(particle_.pdgId());
0026     }
0027   };
0028 
0029   namespace helper {
0030     template <>
0031     struct CandConverter<reco::Track> {
0032       typedef TrackToCandidate type;
0033     };
0034   }  // namespace helper
0035 
0036 }  // namespace converter
0037 
0038 #endif