CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
pat::PackedPFCandidateRefMixer Class Reference
Inheritance diagram for pat::PackedPFCandidateRefMixer:
edm::stream::EDProducer<>

Public Member Functions

 PackedPFCandidateRefMixer (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~PackedPFCandidateRefMixer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

std::vector< edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > > pf2pcs_
 
edm::EDGetTokenT< edm::ValueMap< reco::PFCandidateRef > > pf2pf_
 
edm::EDGetTokenT< std::vector< reco::PFCandidate > > pf_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 22 of file PackedPFCandidateRefMixer.cc.

Constructor & Destructor Documentation

◆ PackedPFCandidateRefMixer()

pat::PackedPFCandidateRefMixer::PackedPFCandidateRefMixer ( const edm::ParameterSet iConfig)
explicit

Definition at line 37 of file PackedPFCandidateRefMixer.cc.

References edm::ParameterSet::getParameter(), pf2pcs_, and makeGlobalPositionRcd_cfg::tag.

38  : pf_(consumes<std::vector<reco::PFCandidate>>(iConfig.getParameter<edm::InputTag>("pf"))),
40  for (edm::InputTag const& tag : iConfig.getParameter<std::vector<edm::InputTag>>("pf2packed")) {
42  }
43  produces<edm::ValueMap<reco::CandidatePtr>>();
44 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< std::vector< reco::PFCandidate > > pf_
edm::EDGetTokenT< edm::ValueMap< reco::PFCandidateRef > > pf2pf_
std::vector< edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > > pf2pcs_

◆ ~PackedPFCandidateRefMixer()

pat::PackedPFCandidateRefMixer::~PackedPFCandidateRefMixer ( )
inlineoverride

Definition at line 25 of file PackedPFCandidateRefMixer.cc.

25 {}

Member Function Documentation

◆ produce()

void pat::PackedPFCandidateRefMixer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 46 of file PackedPFCandidateRefMixer.cc.

References Exception, trigObjTnPSource_cfi::filler, newFWLiteAna::found, mps_fire::i, edm::Ref< C, T, F >::id(), iEvent, edm::Ref< C, T, F >::key(), eostools::move(), create_idmaps::n, MillePedeFileConverter_cfg::out, packedPFCandidateRefMixer_cfi::pf, packedPFCandidateRefMixer_cfi::pf2pf, and edm::refToPtr().

46  {
49  std::vector<edm::Handle<edm::Association<pat::PackedCandidateCollection>>> pf2pcs(pf2pcs_.size());
50  iEvent.getByToken(pf_, pf);
51  iEvent.getByToken(pf2pf_, pf2pf);
52  for (unsigned int i = 0, n = pf2pcs.size(); i < n; ++i) {
53  iEvent.getByToken(pf2pcs_[i], pf2pcs[i]);
54  }
55  std::vector<reco::CandidatePtr> outptrs;
56  outptrs.reserve(pf->size());
57  for (unsigned int i = 0, n = pf->size(); i < n; ++i) {
58  reco::PFCandidateRef oldpfRef(pf, i);
59  const auto& newpfRef = (*pf2pf)[oldpfRef];
60  bool found = false;
61  for (const auto& pf2pc : pf2pcs) {
62  if (pf2pc->contains(newpfRef.id())) {
63  outptrs.push_back(refToPtr((*pf2pc)[newpfRef]));
64  found = true;
65  break;
66  }
67  }
68  if (!found) {
69  edm::LogPrint("PackedPFCandidateRefMixer") << "oldpfRef: " << oldpfRef.id() << " / " << oldpfRef.key() << "\n";
70  edm::LogPrint("PackedPFCandidateRefMixer") << "newpfRef: " << newpfRef.id() << " / " << newpfRef.key() << "\n";
71  edm::LogPrint("PackedPFCandidateRefMixer") << "and I have " << pf2pcs.size() << " rekey maps."
72  << "\n";
73  for (const auto& pf2pc : pf2pcs) {
74  edm::LogPrint("PackedPFCandidateRefMixer") << "this map has keys in: "
75  << "\n";
76  for (const auto& pair : pf2pc->ids()) {
77  edm::LogPrint("PackedPFCandidateRefMixer") << "\t" << pair.first << "\n";
78  }
79  }
80  throw cms::Exception("LogicError") << "A packed candidate has refs that we don't understand\n";
81  }
82  }
83  std::unique_ptr<edm::ValueMap<reco::CandidatePtr>> out(new edm::ValueMap<reco::CandidatePtr>());
85  filler.insert(pf, outptrs.begin(), outptrs.end());
86  filler.fill();
87  iEvent.put(std::move(out));
88 }
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< std::vector< reco::PFCandidate > > pf_
Log< level::Warning, true > LogPrint
edm::EDGetTokenT< edm::ValueMap< reco::PFCandidateRef > > pf2pf_
std::vector< edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > > pf2pcs_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ pf2pcs_

std::vector<edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection> > > pat::PackedPFCandidateRefMixer::pf2pcs_
private

Definition at line 32 of file PackedPFCandidateRefMixer.cc.

Referenced by PackedPFCandidateRefMixer().

◆ pf2pf_

edm::EDGetTokenT<edm::ValueMap<reco::PFCandidateRef> > pat::PackedPFCandidateRefMixer::pf2pf_
private

Definition at line 31 of file PackedPFCandidateRefMixer.cc.

◆ pf_

edm::EDGetTokenT<std::vector<reco::PFCandidate> > pat::PackedPFCandidateRefMixer::pf_
private

Definition at line 30 of file PackedPFCandidateRefMixer.cc.