-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Copy pathTrackToCandidate.h
38 lines (33 loc) · 1.37 KB
/
TrackToCandidate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef RecoAlgos_TrackToCandidate_h
#define RecoAlgos_TrackToCandidate_h
#include "CommonTools/RecoAlgos/interface/MassiveCandidateConverter.h"
#include "CommonTools/RecoAlgos/interface/CandidateProducer.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
#include "DataFormats/Candidate/interface/CandidateFwd.h"
namespace converter {
struct TrackToCandidate : public MassiveCandidateConverter {
typedef reco::Track value_type;
typedef reco::TrackCollection Components;
typedef reco::RecoChargedCandidate Candidate;
TrackToCandidate(const edm::ParameterSet& cfg, edm::ConsumesCollector iC) : MassiveCandidateConverter(cfg, iC) {}
void convert(reco::TrackRef trkRef, reco::RecoChargedCandidate& c) const {
const reco::Track& trk = *trkRef;
c.setCharge(trk.charge());
c.setVertex(trk.vertex());
const reco::Track::Vector& p = trk.momentum();
double t = sqrt(massSqr_ + p.mag2());
c.setP4(reco::Candidate::LorentzVector(p.x(), p.y(), p.z(), t));
c.setTrack(trkRef);
c.setPdgId(particle_.pdgId());
}
};
namespace helper {
template <>
struct CandConverter<reco::Track> {
typedef TrackToCandidate type;
};
} // namespace helper
} // namespace converter
#endif