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 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 &)
 
- 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< std::vector< pat::Electron > > electrons_
 
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
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

Definition at line 26 of file LowPtGSFToPackedCandidateLinker.cc.

Constructor & Destructor Documentation

◆ LowPtGSFToPackedCandidateLinker()

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

Definition at line 46 of file LowPtGSFToPackedCandidateLinker.cc.

References edm::ParameterSet::getParameter().

47  : pfcands_{consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("PFCandidates"))},
48  packed_{consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("packedCandidates"))},
49  lost_tracks_{consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("lostTracks"))},
50  tracks_{consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"))},
51  pf2packed_{consumes<edm::Association<pat::PackedCandidateCollection> >(
52  iConfig.getParameter<edm::InputTag>("packedCandidates"))},
53  lost2trk_{consumes<edm::Association<pat::PackedCandidateCollection> >(
54  iConfig.getParameter<edm::InputTag>("lostTracks"))},
55  gsf2trk_{consumes<edm::Association<reco::TrackCollection> >(iConfig.getParameter<edm::InputTag>("gsfToTrack"))},
56  gsftracks_{consumes<std::vector<reco::GsfTrack> >(iConfig.getParameter<edm::InputTag>("gsfTracks"))},
57  electrons_{consumes<std::vector<pat::Electron> >(iConfig.getParameter<edm::InputTag>("electrons"))} {
58  produces<edm::Association<pat::PackedCandidateCollection> >("gsf2packed");
59  produces<edm::Association<pat::PackedCandidateCollection> >("gsf2lost");
60  produces<edm::ValueMap<PackedCandidatePtr> >("ele2packed");
61  produces<edm::ValueMap<PackedCandidatePtr> >("ele2lost");
62 }
const edm::EDGetTokenT< pat::PackedCandidateCollection > packed_
const edm::EDGetTokenT< reco::PFCandidateCollection > pfcands_
const edm::EDGetTokenT< std::vector< reco::GsfTrack > > gsftracks_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2packed_
const edm::EDGetTokenT< reco::TrackCollection > tracks_
const edm::EDGetTokenT< pat::PackedCandidateCollection > lost_tracks_
const edm::EDGetTokenT< edm::Association< reco::TrackCollection > > gsf2trk_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > lost2trk_
const edm::EDGetTokenT< std::vector< pat::Electron > > electrons_

◆ ~LowPtGSFToPackedCandidateLinker()

LowPtGSFToPackedCandidateLinker::~LowPtGSFToPackedCandidateLinker ( )
override

Definition at line 64 of file LowPtGSFToPackedCandidateLinker.cc.

64 {}

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 181 of file LowPtGSFToPackedCandidateLinker.cc.

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

181  {
183  desc.add<edm::InputTag>("PFCandidates", edm::InputTag("particleFlow"));
184  desc.add<edm::InputTag>("packedCandidates", edm::InputTag("packedPFCandidates"));
185  desc.add<edm::InputTag>("lostTracks", edm::InputTag("lostTracks"));
186  desc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
187  desc.add<edm::InputTag>("gsfToTrack", edm::InputTag("lowPtGsfToTrackLinks"));
188  desc.add<edm::InputTag>("gsfTracks", edm::InputTag("lowPtGsfEleGsfTracks"));
189  desc.add<edm::InputTag>("electrons", edm::InputTag("selectedPatLowPtElectrons"));
190  descriptions.add("lowPtGsfLinksDefault", desc);
191 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 66 of file LowPtGSFToPackedCandidateLinker.cc.

References pwdgSkimBPark_cfi::electrons, electrons_, Exception, gsf2trk_, gsftracks_, edm::Ref< C, T, F >::id(), iEvent, edm::Ref< C, T, F >::index(), edm::Ref< C, T, F >::isNonnull(), submitPVResolutionJobs::key, lost2trk_, lost_tracks_, eostools::move(), vertices_cff::ntracks, packed_, packedPFCandidateRefMixer_cfi::pf2packed, pf2packed_, HLT_2023v12_cff::pfcands, pfcands_, DiMuonV_cfg::tracks, and tracks_.

66  {
67  auto pfcands = iEvent.getHandle(pfcands_);
68  auto packed = iEvent.getHandle(packed_);
69  auto lost_tracks = iEvent.getHandle(lost_tracks_);
70  auto pf2packed = iEvent.getHandle(pf2packed_);
71  auto lost2trk_assoc = iEvent.getHandle(lost2trk_);
72  auto gsftracks = iEvent.getHandle(gsftracks_);
73  auto tracks = iEvent.getHandle(tracks_);
74  auto gsf2trk = iEvent.getHandle(gsf2trk_);
75  auto electrons = iEvent.getHandle(electrons_);
76 
77  // collection sizes, for reference
78  const size_t npf = pfcands->size();
79  const size_t npacked = packed->size();
80  const size_t nlost = lost_tracks->size();
81  const size_t ntracks = tracks->size();
82  const size_t ngsf = gsftracks->size();
83  const size_t nele = electrons->size();
84 
85  //store index mapping in vectors for easy and fast access
86  std::vector<size_t> trk2packed(ntracks, npacked);
87  std::vector<size_t> trk2lost(ntracks, nlost);
88 
89  //store auxiliary mappings for association
90  std::vector<int> gsf2pack(ngsf, -1);
91  std::vector<int> gsf2lost(ngsf, -1);
92  PackedCandidatePtrCollection ele2packedptr(nele, PackedCandidatePtr());
94 
95  //electrons will never store their track (they store the Gsf track)
96  //map PackedPF <--> Track
97  for (unsigned int icand = 0; icand < npf; ++icand) {
99  const reco::PFCandidate& cand = pfcands->at(icand);
100  auto packed_ref = (*pf2packed)[pf_ref];
101  if (cand.charge() && packed_ref.isNonnull() && cand.trackRef().isNonnull() && cand.trackRef().id() == tracks.id()) {
102  size_t trkid = cand.trackRef().index();
103  trk2packed[trkid] = packed_ref.index();
104  }
105  }
106 
107  //map LostTrack <--> Track
108  for (unsigned int itrk = 0; itrk < ntracks; ++itrk) {
109  reco::TrackRef key(tracks, itrk);
110  pat::PackedCandidateRef lostTrack = (*lost2trk_assoc)[key];
111  if (lostTrack.isNonnull()) {
112  trk2lost[itrk] = lostTrack.index(); // assumes that LostTracks are all made from the same track collection
113  }
114  }
115 
116  //map Track --> GSF and fill GSF --> PackedCandidates and GSF --> Lost associations
117  for (unsigned int igsf = 0; igsf < ngsf; ++igsf) {
118  reco::GsfTrackRef gsf_ref(gsftracks, igsf);
119  reco::TrackRef trk_ref = (*gsf2trk)[gsf_ref];
120  if (trk_ref.id() != tracks.id()) {
121  throw cms::Exception(
122  "WrongCollection",
123  "The reco::Track collection used to match against the GSF Tracks was not used to produce such tracks");
124  }
125  size_t trkid = trk_ref.index();
126  if (trk2packed[trkid] != npacked) {
127  gsf2pack[igsf] = trk2packed[trkid];
128  }
129  if (trk2lost[trkid] != nlost) {
130  gsf2lost[igsf] = trk2lost[trkid];
131  }
132  }
133 
134  //map Electron-->pat::PFCandidatePtr via Electron-->GsfTrack-->Track and Track-->pat::PFCandidatePtr
135  for (unsigned int iele = 0; iele < nele; ++iele) {
136  auto const& ele = (*electrons)[iele];
137  reco::GsfTrackRef gsf_ref = ele.core()->gsfTrack();
138  reco::TrackRef trk_ref = (*gsf2trk)[gsf_ref];
139  if (trk_ref.id() != tracks.id()) {
140  throw cms::Exception(
141  "WrongCollection",
142  "The reco::Track collection used to match against the GSF Tracks was not used to produce such tracks");
143  }
144  size_t trkid = trk_ref.index();
145  auto packedIdx = trk2packed[trkid];
146  if (packedIdx != npacked) {
147  ele2packedptr[iele] = PackedCandidatePtr(packed, packedIdx);
148  }
149  auto lostIdx = trk2lost[trkid];
150  if (lostIdx != nlost) {
151  ele2lostptr[iele] = PackedCandidatePtr(lost_tracks, lostIdx);
152  }
153  }
154 
155  // create output collections from the mappings
156  auto assoc_gsf2pack = std::make_unique<edm::Association<pat::PackedCandidateCollection> >(packed);
157  edm::Association<pat::PackedCandidateCollection>::Filler gsf2pack_filler(*assoc_gsf2pack);
158  gsf2pack_filler.insert(gsftracks, gsf2pack.begin(), gsf2pack.end());
159  gsf2pack_filler.fill();
160  iEvent.put(std::move(assoc_gsf2pack), "gsf2packed");
161 
162  auto assoc_gsf2lost = std::make_unique<edm::Association<pat::PackedCandidateCollection> >(lost_tracks);
163  edm::Association<pat::PackedCandidateCollection>::Filler gsf2lost_filler(*assoc_gsf2lost);
164  gsf2lost_filler.insert(gsftracks, gsf2lost.begin(), gsf2lost.end());
165  gsf2lost_filler.fill();
166  iEvent.put(std::move(assoc_gsf2lost), "gsf2lost");
167 
168  auto map_ele2packedptr = std::make_unique<edm::ValueMap<PackedCandidatePtr> >();
169  edm::ValueMap<PackedCandidatePtr>::Filler ele2packedptr_filler(*map_ele2packedptr);
170  ele2packedptr_filler.insert(electrons, ele2packedptr.begin(), ele2packedptr.end());
171  ele2packedptr_filler.fill();
172  iEvent.put(std::move(map_ele2packedptr), "ele2packed");
173 
174  auto map_ele2lostptr = std::make_unique<edm::ValueMap<PackedCandidatePtr> >();
175  edm::ValueMap<PackedCandidatePtr>::Filler ele2lostptr_filler(*map_ele2lostptr);
176  ele2lostptr_filler.insert(electrons, ele2lostptr.begin(), ele2lostptr.end());
177  ele2lostptr_filler.fill();
178  iEvent.put(std::move(map_ele2lostptr), "ele2lost");
179 }
const edm::EDGetTokenT< pat::PackedCandidateCollection > packed_
const edm::EDGetTokenT< reco::PFCandidateCollection > pfcands_
const edm::EDGetTokenT< std::vector< reco::GsfTrack > > gsftracks_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2packed_
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
edm::Ptr< pat::PackedCandidate > PackedCandidatePtr
const edm::EDGetTokenT< reco::TrackCollection > tracks_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
std::vector< PackedCandidatePtr > PackedCandidatePtrCollection
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< pat::PackedCandidateCollection > lost_tracks_
key
prepare the HTCondor submission files and eventually submit them
const edm::EDGetTokenT< edm::Association< reco::TrackCollection > > gsf2trk_
key_type index() const
Definition: Ref.h:253
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > lost2trk_
const edm::EDGetTokenT< std::vector< pat::Electron > > electrons_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ electrons_

const edm::EDGetTokenT<std::vector<pat::Electron> > LowPtGSFToPackedCandidateLinker::electrons_
private

Definition at line 43 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

◆ gsf2trk_

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

Definition at line 41 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

◆ gsftracks_

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

Definition at line 42 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

◆ lost2trk_

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

Definition at line 40 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

◆ lost_tracks_

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

Definition at line 37 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

◆ packed_

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

Definition at line 36 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

◆ pf2packed_

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

Definition at line 39 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

◆ pfcands_

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

Definition at line 35 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

◆ tracks_

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

Definition at line 38 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().