CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
PackedCandidateGenAssociationProducer Class Reference

#include <MyTemporarySubSystem/PackedCandidateGenAssociationProducer/plugins/PackedCandidateGenAssociationProducer.cc>

Inheritance diagram for PackedCandidateGenAssociationProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PackedCandidateGenAssociationProducer (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > genToPrunedToken_
 
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > genToPrunedWSOToken_
 
edm::EDGetTokenT< edm::View< reco::Track > > tracksToken_
 
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > trackToGenToken_
 
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > trackToPcToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 41 of file PackedCandidateGenAssociationProducer.cc.

Constructor & Destructor Documentation

PackedCandidateGenAssociationProducer::PackedCandidateGenAssociationProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 56 of file PackedCandidateGenAssociationProducer.cc.

58  iConfig.getParameter<edm::InputTag>("trackToGenAssoc"))),
60  iConfig.getParameter<edm::InputTag>("trackToPackedCandidatesAssoc"))),
62  iConfig.getParameter<edm::InputTag>("genToPrunedAssoc"))),
64  iConfig.getParameter<edm::InputTag>("genToPrunedAssocWithStatusOne"))),
66  produces<edm::Association<reco::GenParticleCollection>>();
67 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > trackToPcToken_
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > trackToGenToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > genToPrunedWSOToken_
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > genToPrunedToken_
edm::EDGetTokenT< edm::View< reco::Track > > tracksToken_

Member Function Documentation

void PackedCandidateGenAssociationProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 132 of file PackedCandidateGenAssociationProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and DEFINE_FWK_MODULE.

132  {
134  desc.add<edm::InputTag>("genToPrunedAssoc", edm::InputTag("prunedGenParticles"));
135  desc.add<edm::InputTag>("genToPrunedAssocWithStatusOne", edm::InputTag("prunedGenParticlesWithStatusOne"));
136  desc.add<edm::InputTag>("trackToPackedCandidatesAssoc", edm::InputTag("packedPFCandidates"));
137  desc.add<edm::InputTag>("trackToGenAssoc");
138  desc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
139 
140  descriptions.add("packedCandidatesGenAssociationDefault", desc);
141 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void PackedCandidateGenAssociationProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivate

Definition at line 69 of file PackedCandidateGenAssociationProducer.cc.

References edm::helper::Filler< Map >::fill(), objects.autophobj::filler, relval_steps::gen(), genToPrunedToken_, genToPrunedWSOToken_, edm::Event::get(), edm::Event::getHandle(), mps_fire::i, edm::helper::Filler< Map >::insert(), eostools::move(), or, MillePedeFileConverter_cfg::out, edm::Event::put(), HiIsolationCommonParameters_cff::track, l1t::tracks, tracksToken_, genParticleAssociation_cff::trackToGenAssoc, trackToGenToken_, genParticleAssociation_cff::trackToPackedCandidatesAssoc, and trackToPcToken_.

71  {
72  using namespace edm;
73 
74  const auto& trackToPackedCandidatesAssoc = iEvent.get(trackToPcToken_);
75  auto pcCollection = trackToPackedCandidatesAssoc.ref();
76 
77  const auto& genToPrunedAssoc = iEvent.get(genToPrunedToken_);
78  auto prunedCollection = genToPrunedAssoc.ref();
79 
80  const auto& genToPrunedAssocWSO = iEvent.get(genToPrunedWSOToken_);
81 
82  auto trackHandle = iEvent.getHandle(tracksToken_);
83  const auto& tracks = *trackHandle;
84 
85  auto out = std::make_unique<edm::Association<reco::GenParticleCollection>>(prunedCollection);
86 
87  auto trackToGenAssocHandle = iEvent.getHandle(trackToGenToken_);
88  if (not trackToGenAssocHandle.isValid() or not trackToGenAssocHandle->contains(trackHandle.id())) {
89  // not track to gen association available, possibly an old AODSIM, or a missing RECOSIM step
90  // alternatively, the track association may not contain our tracks, as in the case of RECOSIM run on an old RAWSIM
91  // early exit with an empty collection to avoid crash
92  iEvent.put(std::move(out));
93  return;
94  }
95 
96  const auto& trackToGenAssoc = *trackToGenAssocHandle;
97 
99 
100  std::vector<int> indices(pcCollection->size(), -1);
101 
102  for (size_t i = 0; i < tracks.size(); i++) {
103  auto track = tracks.refAt(i);
104 
106  if (pc.isNull()) {
107  continue;
108  }
109 
110  auto gen = trackToGenAssoc[track];
111  if (gen.isNull()) {
112  continue;
113  }
114 
115  auto newGenWSO = genToPrunedAssocWSO[gen];
116  if (newGenWSO.isNull()) {
117  continue;
118  }
119 
120  auto newGen = genToPrunedAssoc[newGenWSO];
121  if (newGen.isNull()) {
122  continue;
123  }
124 
125  indices[pc.index()] = newGen.index();
126  }
127  filler.insert(pcCollection, indices.begin(), indices.end());
128  filler.fill();
129  iEvent.put(std::move(out));
130 }
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > trackToPcToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > trackToGenToken_
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:539
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > genToPrunedWSOToken_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:326
def gen(fragment, howMuch)
Production test section ####.
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > genToPrunedToken_
HLT enums.
edm::EDGetTokenT< edm::View< reco::Track > > tracksToken_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > PackedCandidateGenAssociationProducer::genToPrunedToken_
private

Definition at line 52 of file PackedCandidateGenAssociationProducer.cc.

Referenced by produce().

edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > PackedCandidateGenAssociationProducer::genToPrunedWSOToken_
private

Definition at line 53 of file PackedCandidateGenAssociationProducer.cc.

Referenced by produce().

edm::EDGetTokenT<edm::View<reco::Track> > PackedCandidateGenAssociationProducer::tracksToken_
private

Definition at line 54 of file PackedCandidateGenAssociationProducer.cc.

Referenced by produce().

edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > PackedCandidateGenAssociationProducer::trackToGenToken_
private

Definition at line 50 of file PackedCandidateGenAssociationProducer.cc.

Referenced by produce().

edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection> > PackedCandidateGenAssociationProducer::trackToPcToken_
private

Definition at line 51 of file PackedCandidateGenAssociationProducer.cc.

Referenced by produce().