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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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 &)
 
- 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
ProducesCollector producesCollector ()
 
- 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

Definition at line 22 of file LowPtGSFToPackedCandidateLinker.cc.

Constructor & Destructor Documentation

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

Definition at line 41 of file LowPtGSFToPackedCandidateLinker.cc.

References edm::ParameterSet::getParameter(), gsf2trk_, gsftracks_, lost2trk_, lost_tracks_, packed_, pf2packed_, and tracks_.

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 }
T getParameter(std::string const &) const
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_
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_
LowPtGSFToPackedCandidateLinker::~LowPtGSFToPackedCandidateLinker ( )
override

Definition at line 56 of file LowPtGSFToPackedCandidateLinker.cc.

56 {}

Member Function Documentation

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

Definition at line 154 of file LowPtGSFToPackedCandidateLinker.cc.

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

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 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void LowPtGSFToPackedCandidateLinker::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
override

Definition at line 58 of file LowPtGSFToPackedCandidateLinker.cc.

References reco::LeafCandidate::charge(), Exception, edm::Event::getByToken(), gsf2trk_, gsftracks_, edm::HandleBase::id(), edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::index(), edm::Ref< C, T, F >::isNonnull(), crabWrapper::key, lost2trk_, lost_tracks_, eostools::move(), packed_, packedPFCandidateRefMixer_cfi::pf2packed, pf2packed_, pfcands_, edm::Event::put(), reco::PFCandidate::trackRef(), PDWG_EXOHSCP_cff::tracks, and tracks_.

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 }
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_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
ProductID id() const
Definition: HandleBase.cc:13
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const edm::EDGetTokenT< reco::TrackCollection > tracks_
key_type index() const
Definition: Ref.h:253
int charge() const final
electric charge
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:408
const edm::EDGetTokenT< pat::PackedCandidateCollection > lost_tracks_
const edm::EDGetTokenT< edm::Association< reco::TrackCollection > > gsf2trk_
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > lost2trk_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

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

Definition at line 37 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by LowPtGSFToPackedCandidateLinker(), and produce().

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

Definition at line 38 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by LowPtGSFToPackedCandidateLinker(), and produce().

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

Definition at line 36 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by LowPtGSFToPackedCandidateLinker(), and produce().

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

Definition at line 33 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by LowPtGSFToPackedCandidateLinker(), and produce().

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

Definition at line 32 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by LowPtGSFToPackedCandidateLinker(), and produce().

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

Definition at line 35 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by LowPtGSFToPackedCandidateLinker(), and produce().

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

Definition at line 31 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by produce().

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

Definition at line 34 of file LowPtGSFToPackedCandidateLinker.cc.

Referenced by LowPtGSFToPackedCandidateLinker(), and produce().