32 std::vector<edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection>>>
pf2pcs_;
39 pf_(consumes<std::vector<
reco::PFCandidate>>(iConfig.getParameter<edm::
InputTag>(
"pf"))),
45 produces<edm::ValueMap<reco::CandidatePtr>>();
53 std::vector<edm::Handle<edm::Association<pat::PackedCandidateCollection>>> pf2pcs(pf2pcs_.size());
56 for (
unsigned int i = 0,
n = pf2pcs.size();
i <
n; ++
i) {
59 std::vector<reco::CandidatePtr> outptrs;
60 outptrs.reserve(pf->size());
61 for (
unsigned int i = 0, n = pf->size();
i <
n; ++
i) {
63 const auto & newpfRef = (*pf2pf)[oldpfRef];
65 for (
const auto & pf2pc : pf2pcs) {
66 if (pf2pc->contains(newpfRef.id())) {
67 outptrs.push_back(
refToPtr((*pf2pc)[newpfRef]));
73 edm::LogPrint(
"PackedPFCandidateRefMixer") <<
"oldpfRef: " << oldpfRef.
id() <<
" / " << oldpfRef.
key() <<
"\n";
74 edm::LogPrint(
"PackedPFCandidateRefMixer") <<
"newpfRef: " << newpfRef.id() <<
" / " << newpfRef.key() <<
"\n";
75 edm::LogPrint(
"PackedPFCandidateRefMixer") <<
"and I have " << pf2pcs.size() <<
" rekey maps." <<
"\n";
76 for (
const auto & pf2pc : pf2pcs) {
77 edm::LogPrint(
"PackedPFCandidateRefMixer") <<
"this map has keys in: " <<
"\n";
78 for (
const auto & pair : pf2pc->ids()) {
edm::LogPrint(
"PackedPFCandidateRefMixer") <<
"\t" << pair.first <<
"\n"; }
80 throw cms::Exception(
"LogicError") <<
"A packed candidate has refs that we don't understand\n";
85 filler.
insert(pf, outptrs.begin(), outptrs.end());
T getParameter(std::string const &) const
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
void insert(const H &h, I begin, I end)
key_type key() const
Accessor for product key.
ProductID id() const
Accessor for product ID.
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< std::vector< reco::PFCandidate > > pf_
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
edm::EDGetTokenT< edm::ValueMap< reco::PFCandidateRef > > pf2pf_
PackedPFCandidateRefMixer(const edm::ParameterSet &iConfig)
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
std::vector< edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > > pf2pcs_
virtual ~PackedPFCandidateRefMixer()