CMS 3D CMS Logo

LowPtGSFToTrackLinker.cc
Go to the documentation of this file.
1 #include <string>
2 
22 
24 public:
26 
27  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
29 
30 private:
34 };
35 
37  : tracks_{consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"))},
38  preid_{consumes<std::vector<reco::PreId> >(iConfig.getParameter<edm::InputTag>("gsfPreID"))},
39  gsftracks_{consumes<std::vector<reco::GsfTrack> >(iConfig.getParameter<edm::InputTag>("gsfTracks"))} {
40  produces<edm::Association<reco::TrackCollection> >();
41 }
42 
44  auto gsftracks = iEvent.getHandle(gsftracks_);
45  auto tracks = iEvent.getHandle(tracks_);
46  auto preid = iEvent.getHandle(preid_);
47 
48  // collection sizes, for reference
49  const size_t ngsf = gsftracks->size();
50 
51  //store mapping for association
52  std::vector<int> gsf2track(ngsf, -1);
53 
54  //map Track --> GSF and fill GSF --> PackedCandidates and GSF --> Lost associations
55  for (unsigned int igsf = 0; igsf < ngsf; ++igsf) {
56  reco::GsfTrackRef gref(gsftracks, igsf);
57  reco::TrackRef trk = preid->at(gref->seedRef().castTo<reco::ElectronSeedRef>().index()).trackRef();
58 
59  if (trk.id() != tracks.id()) {
60  throw cms::Exception(
61  "WrongCollection",
62  "The reco::Track collection used to match against the GSF Tracks was not used to produce such tracks");
63  }
64 
65  size_t trkid = trk.index();
66  gsf2track[igsf] = trkid;
67  }
68 
69  // create output collections from the mappings
70  auto assoc = std::make_unique<edm::Association<reco::TrackCollection> >(tracks);
72  filler.insert(gsftracks, gsf2track.begin(), gsf2track.end());
73  filler.fill();
74  iEvent.put(std::move(assoc));
75 }
76 
79  desc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
80  desc.add<edm::InputTag>("gsfPreID", edm::InputTag("lowPtGsfElectronSeeds"));
81  desc.add<edm::InputTag>("gsfTracks", edm::InputTag("lowPtGsfEleGsfTracks"));
82  descriptions.add("lowPtGsfToTrackLinks", desc);
83 }
84 
edm::StreamID
Definition: StreamID.h:30
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
edm::Association::Filler
Definition: Association.h:78
PFCandidate.h
edm::EDGetTokenT< reco::TrackCollection >
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
LowPtGSFToTrackLinker::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Definition: LowPtGSFToTrackLinker.cc:77
Association.h
edm::Ref::index
key_type index() const
Definition: Ref.h:253
LowPtGSFToTrackLinker::gsftracks_
const edm::EDGetTokenT< std::vector< reco::GsfTrack > > gsftracks_
Definition: LowPtGSFToTrackLinker.cc:33
ElectronSeedFwd.h
edm::Ref< GsfTrackCollection >
PreId.h
trackingPlots.assoc
assoc
Definition: trackingPlots.py:183
MakerMacros.h
Track.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
LowPtGSFToTrackLinker
Definition: LowPtGSFToTrackLinker.cc:23
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
LowPtGSFToTrackLinker::tracks_
const edm::EDGetTokenT< reco::TrackCollection > tracks_
Definition: LowPtGSFToTrackLinker.cc:31
LowPtGSFToTrackLinker::preid_
const edm::EDGetTokenT< std::vector< reco::PreId > > preid_
Definition: LowPtGSFToTrackLinker.cc:32
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
iEvent
int iEvent
Definition: GenABIO.cc:224
GsfTrack.h
LowPtGSFToTrackLinker::LowPtGSFToTrackLinker
LowPtGSFToTrackLinker(const edm::ParameterSet &)
Definition: LowPtGSFToTrackLinker.cc:36
edm::EventSetup
Definition: EventSetup.h:57
PreIdFwd.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
edm::Ref::id
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
eostools.move
def move(src, dest)
Definition: eostools.py:511
GsfTrackFwd.h
Frameworkfwd.h
Exception
Definition: hltDiff.cc:246
EventSetup.h
LowPtGSFToTrackLinker::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: LowPtGSFToTrackLinker.cc:43
Exception.h
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
Candidate.h
ParameterSet.h
EDProducer.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
PFCandidateFwd.h
ElectronSeed.h