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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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.

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 }

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

◆ ~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.

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 }

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(), dqmiodumpmetadata::n, MillePedeFileConverter_cfg::out, packedPFCandidateRefMixer_cfi::pf, packedPFCandidateRefMixer_cfi::pf2pf, and edm::refToPtr().

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.

mps_fire.i
i
Definition: mps_fire.py:428
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm::LogPrint
Log< level::Warning, true > LogPrint
Definition: MessageLogger.h:130
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Handle
Definition: AssociativeIterator.h:50
edm::Ref< PFCandidateCollection >
edm::refToPtr
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
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
packedPFCandidateRefMixer_cfi.pf2pf
pf2pf
Definition: packedPFCandidateRefMixer_cfi.py:5
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::Association
Definition: Association.h:18
pat::PackedPFCandidateRefMixer::pf_
edm::EDGetTokenT< std::vector< reco::PFCandidate > > pf_
Definition: PackedPFCandidateRefMixer.cc:30
eostools.move
def move(src, dest)
Definition: eostools.py:511
packedPFCandidateRefMixer_cfi.pf
pf
Definition: packedPFCandidateRefMixer_cfi.py:4
edm::ValueMap
Definition: ValueMap.h:107
Exception
Definition: hltDiff.cc:246
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
pat::PackedPFCandidateRefMixer::pf2pf_
edm::EDGetTokenT< edm::ValueMap< reco::PFCandidateRef > > pf2pf_
Definition: PackedPFCandidateRefMixer.cc:31
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
edm::helper::Filler
Definition: ValueMap.h:22
pat::PackedPFCandidateRefMixer::pf2pcs_
std::vector< edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > > pf2pcs_
Definition: PackedPFCandidateRefMixer.cc:32
edm::InputTag
Definition: InputTag.h:15