Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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