82 const size_t npf = pfcands->size();
83 const size_t npacked = packed->size();
84 const size_t nlost = lost_tracks->size();
85 const size_t ntracks = tracks->size();
86 const size_t ngsf = gsftracks->size();
89 std::vector<size_t> trk2packed(ntracks, npacked);
90 std::vector<size_t> trk2lost(ntracks, nlost);
93 std::vector<int> gsf2pack(ngsf, -1);
94 std::vector<int> gsf2lost(ngsf, -1);
98 for(
unsigned int icand=0; icand < npf; ++icand) {
101 auto packed_ref = (*pf2packed)[pf_ref];
105 size_t packid = packed_ref.index();
106 trk2packed[trkid] = packid;
111 for(
unsigned int itrk=0; itrk < ntracks; ++itrk) {
115 size_t ilost = lostTrack.
index();
116 trk2lost[itrk] = ilost;
121 for(
unsigned int igsf=0; igsf < ngsf; ++igsf) {
124 if(trk.
id() != tracks.
id()) {
125 throw cms::Exception(
"WrongCollection",
"The reco::Track collection used to match against the GSF Tracks was not used to produce such tracks");
127 size_t trkid = trk.
index();
129 if(trk2packed[trkid] != npacked) {
130 gsf2pack[igsf] = trk2packed[trkid];
132 if(trk2lost[trkid] != nlost) {
133 gsf2lost[igsf] = trk2lost[trkid];
138 auto assoc_gsf2pack = std::make_unique< edm::Association<pat::PackedCandidateCollection> >(packed);
140 gsf2pack_filler.insert(gsftracks, gsf2pack.begin(), gsf2pack.end());
141 gsf2pack_filler.fill();
142 iEvent.
put(
std::move(assoc_gsf2pack),
"packedCandidates");
144 auto assoc_gsf2lost = std::make_unique< edm::Association<pat::PackedCandidateCollection> >(lost_tracks);
146 gsf2lost_filler.insert(gsftracks, gsf2lost.begin(), gsf2lost.end());
147 gsf2lost_filler.fill();
const edm::EDGetTokenT< pat::PackedCandidateCollection > packed_
const edm::EDGetTokenT< reco::PFCandidateCollection > pfcands_
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.
const edm::EDGetTokenT< std::vector< reco::GsfTrack > > gsftracks_
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_