84 const size_t npf = pfcands->size();
85 const size_t npacked = packed->size();
86 const size_t nlost = lost_tracks->size();
87 const size_t ntracks = tracks->size();
88 const size_t ngsf = gsftracks->size();
91 std::vector<size_t> trk2packed(ntracks, npacked);
92 std::vector<size_t> trk2lost(ntracks, nlost);
95 std::vector<int> gsf2pack(ngsf, -1);
96 std::vector<int> gsf2lost(ngsf, -1);
100 for (
unsigned int icand = 0; icand < npf; ++icand) {
103 auto packed_ref = (*pf2packed)[pf_ref];
106 size_t packid = packed_ref.index();
107 trk2packed[trkid] = packid;
112 for (
unsigned int itrk = 0; itrk < ntracks; ++itrk) {
116 size_t ilost = lostTrack.
index();
117 trk2lost[itrk] = ilost;
122 for (
unsigned int igsf = 0; igsf < ngsf; ++igsf) {
125 if (trk.
id() != tracks.
id()) {
128 "The reco::Track collection used to match against the GSF Tracks was not used to produce such tracks");
130 size_t trkid = trk.
index();
132 if (trk2packed[trkid] != npacked) {
133 gsf2pack[igsf] = trk2packed[trkid];
135 if (trk2lost[trkid] != nlost) {
136 gsf2lost[igsf] = trk2lost[trkid];
141 auto assoc_gsf2pack = std::make_unique<edm::Association<pat::PackedCandidateCollection> >(packed);
143 gsf2pack_filler.insert(gsftracks, gsf2pack.begin(), gsf2pack.end());
144 gsf2pack_filler.fill();
145 iEvent.
put(
std::move(assoc_gsf2pack),
"packedCandidates");
147 auto assoc_gsf2lost = std::make_unique<edm::Association<pat::PackedCandidateCollection> >(lost_tracks);
149 gsf2lost_filler.insert(gsftracks, gsf2lost.begin(), gsf2lost.end());
150 gsf2lost_filler.fill();
const edm::EDGetTokenT< pat::PackedCandidateCollection > packed_
const edm::EDGetTokenT< reco::PFCandidateCollection > pfcands_
const edm::EDGetTokenT< std::vector< reco::GsfTrack > > gsftracks_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2packed_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const edm::EDGetTokenT< reco::TrackCollection > tracks_
int charge() const final
electric charge
ProductID id() const
Accessor for product ID.
reco::TrackRef trackRef() const
const edm::EDGetTokenT< pat::PackedCandidateCollection > lost_tracks_
const edm::EDGetTokenT< edm::Association< reco::TrackCollection > > gsf2trk_
Particle reconstructed by the particle flow algorithm.
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > lost2trk_