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 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
 
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)
 
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::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 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_.

41  :
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> >(iConfig.getParameter<edm::InputTag>("packedCandidates"))},
47  lost2trk_{consumes<edm::Association<pat::PackedCandidateCollection> >(iConfig.getParameter<edm::InputTag>("lostTracks"))},
48  gsf2trk_{consumes<edm::Association<reco::TrackCollection> >(iConfig.getParameter<edm::InputTag>("gsfToTrack"))},
49  gsftracks_{consumes<std::vector<reco::GsfTrack> >(iConfig.getParameter<edm::InputTag>("gsfTracks"))} {
50  produces< edm::Association<pat::PackedCandidateCollection> > ("packedCandidates");
51  produces< edm::Association<pat::PackedCandidateCollection> > ("lostTracks");
52  }
T getParameter(std::string const &) const
const edm::EDGetTokenT< pat::PackedCandidateCollection > packed_
const edm::EDGetTokenT< reco::PFCandidateCollection > pfcands_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2packed_
const edm::EDGetTokenT< std::vector< reco::GsfTrack > > gsftracks_
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 54 of file LowPtGSFToPackedCandidateLinker.cc.

54 {}

Member Function Documentation

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

Definition at line 151 of file LowPtGSFToPackedCandidateLinker.cc.

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

151  {
153  desc.add<edm::InputTag>("PFCandidates", edm::InputTag("particleFlow"));
154  desc.add<edm::InputTag>("packedCandidates", edm::InputTag("packedPFCandidates"));
155  desc.add<edm::InputTag>("lostTracks", edm::InputTag("lostTracks"));
156  desc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
157  desc.add<edm::InputTag>("gsfToTrack", edm::InputTag("lowPtGsfToTrackLinks"));
158  desc.add<edm::InputTag>("gsfTracks", edm::InputTag("lowPtGsfEleGsfTracks"));
159  descriptions.add("lowPtGsfLinksDefault", desc);
160 }
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 56 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(), l1t::tracks, and tracks_.

56  {
58  iEvent.getByToken(pfcands_, pfcands);
59 
61  iEvent.getByToken(packed_, packed);
62 
64  iEvent.getByToken(lost_tracks_, lost_tracks);
65 
67  iEvent.getByToken(pf2packed_, pf2packed);
68 
70  iEvent.getByToken(lost2trk_, lost2trk_assoc);
71 
73  iEvent.getByToken(gsftracks_, gsftracks);
74 
76  iEvent.getByToken(tracks_, tracks);
77 
79  iEvent.getByToken(gsf2trk_, gsf2trk);
80 
81  // collection sizes, for reference
82  const size_t npf = pfcands->size();
83  const size_t npacked = packed->size();
84  const size_t nlost = lost_tracks->size();
85  const size_t ntracks = tracks->size();
86  const size_t ngsf = gsftracks->size();
87 
88  //store index mapping in vectors for easy and fast access
89  std::vector<size_t> trk2packed(ntracks, npacked);
90  std::vector<size_t> trk2lost(ntracks, nlost);
91 
92  //store auxiliary mappings for association
93  std::vector<int> gsf2pack(ngsf, -1);
94  std::vector<int> gsf2lost(ngsf, -1);
95 
96  //electrons will never store their track (they store the Gsf track)
97  //map PackedPF <--> Track
98  for(unsigned int icand=0; icand < npf; ++icand) {
99  edm::Ref<reco::PFCandidateCollection> pf_ref(pfcands,icand);
100  const reco::PFCandidate &cand = pfcands->at(icand);
101  auto packed_ref = (*pf2packed)[pf_ref];
102  if(cand.charge() && packed_ref.isNonnull() && cand.trackRef().isNonnull()
103  && cand.trackRef().id() == tracks.id() ) {
104  size_t trkid = cand.trackRef().index();
105  size_t packid = packed_ref.index();
106  trk2packed[trkid] = packid;
107  }
108  }
109 
110  //map LostTrack <--> Track
111  for(unsigned int itrk=0; itrk < ntracks; ++itrk) {
112  reco::TrackRef key(tracks, itrk);
113  pat::PackedCandidateRef lostTrack = (*lost2trk_assoc)[key];
114  if(lostTrack.isNonnull()) {
115  size_t ilost = lostTrack.index(); //assumes that LostTracks are all made from the same track collection
116  trk2lost[itrk] = ilost;
117  }
118  }
119 
120  //map Track --> GSF and fill GSF --> PackedCandidates and GSF --> Lost associations
121  for(unsigned int igsf=0; igsf < ngsf; ++igsf) {
122  reco::GsfTrackRef gref(gsftracks, igsf);
123  reco::TrackRef trk = (*gsf2trk)[gref];
124  if(trk.id() != tracks.id()) {
125  throw cms::Exception("WrongCollection", "The reco::Track collection used to match against the GSF Tracks was not used to produce such tracks");
126  }
127  size_t trkid = trk.index();
128 
129  if(trk2packed[trkid] != npacked) {
130  gsf2pack[igsf] = trk2packed[trkid];
131  }
132  if(trk2lost[trkid] != nlost) {
133  gsf2lost[igsf] = trk2lost[trkid];
134  }
135  }
136 
137  // create output collections from the mappings
138  auto assoc_gsf2pack = std::make_unique< edm::Association<pat::PackedCandidateCollection> >(packed);
139  edm::Association<pat::PackedCandidateCollection>::Filler gsf2pack_filler(*assoc_gsf2pack);
140  gsf2pack_filler.insert(gsftracks, gsf2pack.begin(), gsf2pack.end());
141  gsf2pack_filler.fill();
142  iEvent.put(std::move(assoc_gsf2pack), "packedCandidates");
143 
144  auto assoc_gsf2lost = std::make_unique< edm::Association<pat::PackedCandidateCollection> >(lost_tracks);
145  edm::Association<pat::PackedCandidateCollection>::Filler gsf2lost_filler(*assoc_gsf2lost);
146  gsf2lost_filler.insert(gsftracks, gsf2lost.begin(), gsf2lost.end());
147  gsf2lost_filler.fill();
148  iEvent.put(std::move(assoc_gsf2lost), "lostTracks");
149 }
const edm::EDGetTokenT< pat::PackedCandidateCollection > packed_
const edm::EDGetTokenT< reco::PFCandidateCollection > pfcands_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2packed_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
const edm::EDGetTokenT< std::vector< reco::GsfTrack > > gsftracks_
ProductID id() const
Definition: HandleBase.cc:15
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
const edm::EDGetTokenT< reco::TrackCollection > tracks_
key_type index() const
Definition: Ref.h:268
int charge() const final
electric charge
Definition: LeafCandidate.h:91
ProductID id() const
Accessor for product ID.
Definition: Ref.h:259
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:442
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:510

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().