CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
pat::PackedPFCandidateRefMixer Class Reference
Inheritance diagram for pat::PackedPFCandidateRefMixer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PackedPFCandidateRefMixer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual ~PackedPFCandidateRefMixer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 22 of file PackedPFCandidateRefMixer.cc.

Constructor & Destructor Documentation

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

Definition at line 38 of file PackedPFCandidateRefMixer.cc.

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

38  :
39  pf_(consumes<std::vector<reco::PFCandidate>>(iConfig.getParameter<edm::InputTag>("pf"))),
41 {
42  for (edm::InputTag tag : iConfig.getParameter<std::vector<edm::InputTag>>("pf2packed")) {
44  }
45  produces<edm::ValueMap<reco::CandidatePtr>>();
46 }
T getParameter(std::string const &) const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< std::vector< reco::PFCandidate > > pf_
edm::EDGetTokenT< edm::ValueMap< reco::PFCandidateRef > > pf2pf_
std::vector< edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > > pf2pcs_
virtual pat::PackedPFCandidateRefMixer::~PackedPFCandidateRefMixer ( )
inlinevirtual

Definition at line 25 of file PackedPFCandidateRefMixer.cc.

25 { }

Member Function Documentation

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

Implements edm::stream::EDProducerBase.

Definition at line 50 of file PackedPFCandidateRefMixer.cc.

References Exception, edm::helper::Filler< Map >::fill(), newFWLiteAna::found, edm::Event::getByToken(), i, edm::Ref< C, T, F >::id(), edm::helper::Filler< Map >::insert(), edm::Ref< C, T, F >::key(), eostools::move(), gen::n, GenerateHcalLaserBadRunList::out, edm::Event::put(), and edm::refToPtr().

50  {
53  std::vector<edm::Handle<edm::Association<pat::PackedCandidateCollection>>> pf2pcs(pf2pcs_.size());
54  iEvent.getByToken(pf_, pf);
55  iEvent.getByToken(pf2pf_, pf2pf);
56  for (unsigned int i = 0, n = pf2pcs.size(); i < n; ++i) {
57  iEvent.getByToken(pf2pcs_[i], pf2pcs[i]);
58  }
59  std::vector<reco::CandidatePtr> outptrs;
60  outptrs.reserve(pf->size());
61  for (unsigned int i = 0, n = pf->size(); i < n; ++i) {
62  reco::PFCandidateRef oldpfRef(pf, i);
63  const auto & newpfRef = (*pf2pf)[oldpfRef];
64  bool found = false;
65  for (const auto & pf2pc : pf2pcs) {
66  if (pf2pc->contains(newpfRef.id())) {
67  outptrs.push_back(refToPtr((*pf2pc)[newpfRef]));
68  found = true;
69  break;
70  }
71  }
72  if (!found) {
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"; }
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 }
int i
Definition: DBlmapReader.cc:9
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
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
def move
Definition: eostools.py:510
edm::EDGetTokenT< std::vector< reco::PFCandidate > > pf_
edm::EDGetTokenT< edm::ValueMap< reco::PFCandidateRef > > pf2pf_
std::vector< edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > > pf2pcs_

Member Data Documentation

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

Definition at line 32 of file PackedPFCandidateRefMixer.cc.

Referenced by PackedPFCandidateRefMixer().

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

Definition at line 31 of file PackedPFCandidateRefMixer.cc.

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

Definition at line 30 of file PackedPFCandidateRefMixer.cc.