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
 
 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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 41 of file PackedCandidateGenAssociationProducer.cc.

Constructor & Destructor Documentation

◆ PackedCandidateGenAssociationProducer()

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
Definition: ParameterSet.h:307
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

◆ fillDescriptions()

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

Definition at line 132 of file PackedCandidateGenAssociationProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

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 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void PackedCandidateGenAssociationProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 69 of file PackedCandidateGenAssociationProducer.cc.

References trigObjTnPSource_cfi::filler, relval_steps::gen(), genToPrunedToken_, genToPrunedWSOToken_, mps_fire::i, iEvent, dqmdumpme::indices, eostools::move(), or, MillePedeFileConverter_cfg::out, HLT_2024v12_cff::track, DiMuonV_cfg::tracks, tracksToken_, genParticleAssociation_cff::trackToGenAssoc, trackToGenToken_, genParticleAssociation_cff::trackToPackedCandidatesAssoc, and trackToPcToken_.

71  {
72  using namespace edm;
73 
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_
edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > trackToGenToken_
int iEvent
Definition: GenABIO.cc:224
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
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

◆ genToPrunedToken_

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

Definition at line 52 of file PackedCandidateGenAssociationProducer.cc.

Referenced by produce().

◆ genToPrunedWSOToken_

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

Definition at line 53 of file PackedCandidateGenAssociationProducer.cc.

Referenced by produce().

◆ tracksToken_

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

Definition at line 54 of file PackedCandidateGenAssociationProducer.cc.

Referenced by produce().

◆ trackToGenToken_

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

Definition at line 50 of file PackedCandidateGenAssociationProducer.cc.

Referenced by produce().

◆ trackToPcToken_

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

Definition at line 51 of file PackedCandidateGenAssociationProducer.cc.

Referenced by produce().