CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
LowPtGSFToPackedCandidateLinker Class Reference
Inheritance diagram for LowPtGSFToPackedCandidateLinker:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 LowPtGSFToPackedCandidateLinker (const edm::ParameterSet &)
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 ~LowPtGSFToPackedCandidateLinker () override
 
- 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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 &)
 
- 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 Attributes

const edm::EDGetTokenT< edm::Association< reco::TrackCollection > > gsf2trk_
 
const edm::EDGetTokenT< std::vector< reco::GsfTrack > > gsftracks_
 
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > lost2trk_
 
const edm::EDGetTokenT< pat::PackedCandidateCollectionlost_tracks_
 
const edm::EDGetTokenT< pat::PackedCandidateCollectionpacked_
 
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2packed_
 
const edm::EDGetTokenT< reco::PFCandidateCollectionpfcands_
 
const edm::EDGetTokenT< reco::TrackCollectiontracks_
 

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::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
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)
 
template<Transition B>
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 (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 22 of file LowPtGSFToPackedCandidateLinker.cc.

Constructor & Destructor Documentation

◆ LowPtGSFToPackedCandidateLinker()

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

Definition at line 41 of file LowPtGSFToPackedCandidateLinker.cc.

42  : pfcands_{consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("PFCandidates"))},
43  packed_{consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("packedCandidates"))},
44  lost_tracks_{consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("lostTracks"))},
45  tracks_{consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"))},
46  pf2packed_{consumes<edm::Association<pat::PackedCandidateCollection> >(
47  iConfig.getParameter<edm::InputTag>("packedCandidates"))},
48  lost2trk_{consumes<edm::Association<pat::PackedCandidateCollection> >(
49  iConfig.getParameter<edm::InputTag>("lostTracks"))},
50  gsf2trk_{consumes<edm::Association<reco::TrackCollection> >(iConfig.getParameter<edm::InputTag>("gsfToTrack"))},
51  gsftracks_{consumes<std::vector<reco::GsfTrack> >(iConfig.getParameter<edm::InputTag>("gsfTracks"))} {
52  produces<edm::Association<pat::PackedCandidateCollection> >("packedCandidates");
53  produces<edm::Association<pat::PackedCandidateCollection> >("lostTracks");
54 }

References edm::ParameterSet::getParameter().

◆ ~LowPtGSFToPackedCandidateLinker()

LowPtGSFToPackedCandidateLinker::~LowPtGSFToPackedCandidateLinker ( )
override

Definition at line 56 of file LowPtGSFToPackedCandidateLinker.cc.

56 {}

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 154 of file LowPtGSFToPackedCandidateLinker.cc.

154  {
156  desc.add<edm::InputTag>("PFCandidates", edm::InputTag("particleFlow"));
157  desc.add<edm::InputTag>("packedCandidates", edm::InputTag("packedPFCandidates"));
158  desc.add<edm::InputTag>("lostTracks", edm::InputTag("lostTracks"));
159  desc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
160  desc.add<edm::InputTag>("gsfToTrack", edm::InputTag("lowPtGsfToTrackLinks"));
161  desc.add<edm::InputTag>("gsfTracks", edm::InputTag("lowPtGsfEleGsfTracks"));
162  descriptions.add("lowPtGsfLinksDefault", desc);
163 }

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

◆ produce()

void LowPtGSFToPackedCandidateLinker::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overridevirtual

Implements edm::global::EDProducerBase.

Definition at line 58 of file LowPtGSFToPackedCandidateLinker.cc.

58  {
60  iEvent.getByToken(pfcands_, pfcands);
61 
63  iEvent.getByToken(packed_, packed);
64 
66  iEvent.getByToken(lost_tracks_, lost_tracks);
67 
69  iEvent.getByToken(pf2packed_, pf2packed);
70 
72  iEvent.getByToken(lost2trk_, lost2trk_assoc);
73 
75  iEvent.getByToken(gsftracks_, gsftracks);
76 
78  iEvent.getByToken(tracks_, tracks);
79 
81  iEvent.getByToken(gsf2trk_, gsf2trk);
82 
83  // collection sizes, for reference
84  const size_t npf = pfcands->size();
85  const size_t npacked = packed->size();
86  const size_t nlost = lost_tracks->size();
87  const size_t ntracks = tracks->size();
88  const size_t ngsf = gsftracks->size();
89 
90  //store index mapping in vectors for easy and fast access
91  std::vector<size_t> trk2packed(ntracks, npacked);
92  std::vector<size_t> trk2lost(ntracks, nlost);
93 
94  //store auxiliary mappings for association
95  std::vector<int> gsf2pack(ngsf, -1);
96  std::vector<int> gsf2lost(ngsf, -1);
97 
98  //electrons will never store their track (they store the Gsf track)
99  //map PackedPF <--> Track
100  for (unsigned int icand = 0; icand < npf; ++icand) {
101  edm::Ref<reco::PFCandidateCollection> pf_ref(pfcands, icand);
102  const reco::PFCandidate& cand = pfcands->at(icand);
103  auto packed_ref = (*pf2packed)[pf_ref];
104  if (cand.charge() && packed_ref.isNonnull() && cand.trackRef().isNonnull() && cand.trackRef().id() == tracks.id()) {
105  size_t trkid = cand.trackRef().index();
106  size_t packid = packed_ref.index();
107  trk2packed[trkid] = packid;
108  }
109  }
110 
111  //map LostTrack <--> Track
112  for (unsigned int itrk = 0; itrk < ntracks; ++itrk) {
113  reco::TrackRef key(tracks, itrk);
114  pat::PackedCandidateRef lostTrack = (*lost2trk_assoc)[key];
115  if (lostTrack.isNonnull()) {
116  size_t ilost = lostTrack.index(); //assumes that LostTracks are all made from the same track collection
117  trk2lost[itrk] = ilost;
118  }
119  }
120 
121  //map Track --> GSF and fill GSF --> PackedCandidates and GSF --> Lost associations
122  for (unsigned int igsf = 0; igsf < ngsf; ++igsf) {
123  reco::GsfTrackRef gref(gsftracks, igsf);
124  reco::TrackRef trk = (*gsf2trk)[gref];
125  if (trk.id() != tracks.id()) {
126  throw cms::Exception(
127  "WrongCollection",
128  "The reco::Track collection used to match against the GSF Tracks was not used to produce such tracks");
129  }
130  size_t trkid = trk.index();
131 
132  if (trk2packed[trkid] != npacked) {
133  gsf2pack[igsf] = trk2packed[trkid];
134  }
135  if (trk2lost[trkid] != nlost) {
136  gsf2lost[igsf] = trk2lost[trkid];
137  }
138  }
139 
140  // create output collections from the mappings
141  auto assoc_gsf2pack = std::make_unique<edm::Association<pat::PackedCandidateCollection> >(packed);
142  edm::Association<pat::PackedCandidateCollection>::Filler gsf2pack_filler(*assoc_gsf2pack);
143  gsf2pack_filler.insert(gsftracks, gsf2pack.begin(), gsf2pack.end());
144  gsf2pack_filler.fill();
145  iEvent.put(std::move(assoc_gsf2pack), "packedCandidates");
146 
147  auto assoc_gsf2lost = std::make_unique<edm::Association<pat::PackedCandidateCollection> >(lost_tracks);
148  edm::Association<pat::PackedCandidateCollection>::Filler gsf2lost_filler(*assoc_gsf2lost);
149  gsf2lost_filler.insert(gsftracks, gsf2lost.begin(), gsf2lost.end());
150  gsf2lost_filler.fill();
151  iEvent.put(std::move(assoc_gsf2lost), "lostTracks");
152 }

References Exception, gsf2trk_, gsftracks_, edm::Ref< C, T, F >::id(), iEvent, edm::Ref< C, T, F >::index(), edm::Ref< C, T, F >::isNonnull(), crabWrapper::key, lost2trk_, lost_tracks_, eostools::move(), vertices_cff::ntracks, packed_, packedPFCandidateRefMixer_cfi::pf2packed, pf2packed_, pfcands_, PDWG_EXOHSCP_cff::tracks, and tracks_.

Member Data Documentation

◆ gsf2trk_

const edm::EDGetTokenT<edm::Association<reco::TrackCollection> > LowPtGSFToPackedCandidateLinker::gsf2trk_
private

Definition at line 37 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

◆ gsftracks_

const edm::EDGetTokenT<std::vector<reco::GsfTrack> > LowPtGSFToPackedCandidateLinker::gsftracks_
private

Definition at line 38 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

◆ lost2trk_

const edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection> > LowPtGSFToPackedCandidateLinker::lost2trk_
private

Definition at line 36 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

◆ lost_tracks_

const edm::EDGetTokenT<pat::PackedCandidateCollection> LowPtGSFToPackedCandidateLinker::lost_tracks_
private

Definition at line 33 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

◆ packed_

const edm::EDGetTokenT<pat::PackedCandidateCollection> LowPtGSFToPackedCandidateLinker::packed_
private

Definition at line 32 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

◆ pf2packed_

const edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection> > LowPtGSFToPackedCandidateLinker::pf2packed_
private

Definition at line 35 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

◆ pfcands_

const edm::EDGetTokenT<reco::PFCandidateCollection> LowPtGSFToPackedCandidateLinker::pfcands_
private

Definition at line 31 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

◆ tracks_

const edm::EDGetTokenT<reco::TrackCollection> LowPtGSFToPackedCandidateLinker::tracks_
private

Definition at line 34 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
LowPtGSFToPackedCandidateLinker::gsf2trk_
const edm::EDGetTokenT< edm::Association< reco::TrackCollection > > gsf2trk_
Definition: LowPtGSFToPackedCandidateLinker.cc:37
edm::Association::Filler
Definition: Association.h:78
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
vertices_cff.ntracks
ntracks
Definition: vertices_cff.py:34
edm::Ref::index
key_type index() const
Definition: Ref.h:253
edm::Handle
Definition: AssociativeIterator.h:50
edm::Ref
Definition: AssociativeIterator.h:58
LowPtGSFToPackedCandidateLinker::lost2trk_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > lost2trk_
Definition: LowPtGSFToPackedCandidateLinker.cc:36
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
LowPtGSFToPackedCandidateLinker::packed_
const edm::EDGetTokenT< pat::PackedCandidateCollection > packed_
Definition: LowPtGSFToPackedCandidateLinker.cc:32
LowPtGSFToPackedCandidateLinker::tracks_
const edm::EDGetTokenT< reco::TrackCollection > tracks_
Definition: LowPtGSFToPackedCandidateLinker.cc:34
packedPFCandidateRefMixer_cfi.pf2packed
pf2packed
Definition: packedPFCandidateRefMixer_cfi.py:6
LowPtGSFToPackedCandidateLinker::pfcands_
const edm::EDGetTokenT< reco::PFCandidateCollection > pfcands_
Definition: LowPtGSFToPackedCandidateLinker.cc:31
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
cand
Definition: decayParser.h:32
iEvent
int iEvent
Definition: GenABIO.cc:224
LowPtGSFToPackedCandidateLinker::gsftracks_
const edm::EDGetTokenT< std::vector< reco::GsfTrack > > gsftracks_
Definition: LowPtGSFToPackedCandidateLinker.cc:38
LowPtGSFToPackedCandidateLinker::pf2packed_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2packed_
Definition: LowPtGSFToPackedCandidateLinker.cc:35
edm::Ref::id
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
LowPtGSFToPackedCandidateLinker::lost_tracks_
const edm::EDGetTokenT< pat::PackedCandidateCollection > lost_tracks_
Definition: LowPtGSFToPackedCandidateLinker.cc:33
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:246
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
crabWrapper.key
key
Definition: crabWrapper.py:19
edm::InputTag
Definition: InputTag.h:15