CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TrackExtraRekeyer.cc
Go to the documentation of this file.
4 
8 
10 public:
11  explicit TrackExtraRekeyer(const edm::ParameterSet &);
12  ~TrackExtraRekeyer() override = default;
13 
14  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
15 
16 private:
17  void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
18 
19  // memeber data
23 };
24 
26  : inputTrack_(consumes(iConfig.getParameter<edm::InputTag>("src"))),
27  inputAssoc_(consumes(iConfig.getParameter<edm::InputTag>("association"))),
28  outputTrack_(produces<reco::TrackCollection>()) {}
29 
30 // ------------ method called for each event ------------
32  using namespace edm;
33 
34  auto const &tracks = iEvent.get(inputTrack_);
35  auto const &assoc = iEvent.get(inputAssoc_);
36 
37  reco::TrackCollection tracksOut;
38 
39  for (auto const &track : tracks) {
40  if (!assoc.contains(track.extra().id())) {
41  continue;
42  }
43  const reco::TrackExtraRef &trackextraref = assoc[track.extra()];
44  if (trackextraref.isNonnull()) {
45  auto &trackout = tracksOut.emplace_back(track);
46  trackout.setExtra(trackextraref);
47  }
48  }
49  iEvent.emplace(outputTrack_, std::move(tracksOut));
50 }
51 
54  desc.setComment("Simple prooducer to re-key muon tracks for refit");
55  desc.add<edm::InputTag>("src", edm::InputTag("generalTracks"))->setComment("input track collections");
56  desc.add<edm::InputTag>("association", edm::InputTag("muonReducedTrackExtras"))
57  ->setComment("input track association collection");
58  descriptions.addWithDefaultLabel(desc);
59 }
60 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
const edm::EDPutTokenT< reco::TrackCollection > outputTrack_
auto const & tracks
cannot be loose
const edm::EDGetTokenT< reco::TrackCollection > inputTrack_
void setComment(std::string const &value)
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
ParameterDescriptionBase * add(U const &iLabel, T const &value)
TrackExtraRekeyer(const edm::ParameterSet &)
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:433
~TrackExtraRekeyer() override=default
const edm::EDGetTokenT< edm::Association< reco::TrackExtraCollection > > inputAssoc_
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override