43 packed_{consumes<pat::PackedCandidateCollection>(iConfig.getParameter<
edm::InputTag>(
"packedCandidates"))},
46 pf2packed_{consumes<edm::Association<pat::PackedCandidateCollection> >(iConfig.getParameter<
edm::InputTag>(
"packedCandidates"))},
47 lost2trk_{consumes<edm::Association<pat::PackedCandidateCollection> >(iConfig.getParameter<
edm::InputTag>(
"lostTracks"))},
48 gsf2trk_{consumes<edm::Association<reco::TrackCollection> >(iConfig.getParameter<
edm::InputTag>(
"gsfToTrack"))},
50 produces< edm::Association<pat::PackedCandidateCollection> > (
"packedCandidates");
51 produces< edm::Association<pat::PackedCandidateCollection> > (
"lostTracks");
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();
159 descriptions.
add(
"lowPtGsfLinksDefault", desc);
T getParameter(std::string const &) const
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
#define DEFINE_FWK_MODULE(type)
const edm::EDGetTokenT< pat::PackedCandidateCollection > lost_tracks_
const edm::EDGetTokenT< edm::Association< reco::TrackCollection > > gsf2trk_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
~LowPtGSFToPackedCandidateLinker() override
Particle reconstructed by the particle flow algorithm.
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > lost2trk_
static void fillDescriptions(edm::ConfigurationDescriptions &)
LowPtGSFToPackedCandidateLinker(const edm::ParameterSet &)