CMS 3D CMS Logo

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<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("src"))),
28  consumes<edm::Association<reco::TrackExtraCollection>>(iConfig.getParameter<edm::InputTag>("association"))),
30 
31 // ------------ method called for each event ------------
33  using namespace edm;
34 
35  auto const &tracks = iEvent.get(inputTrack_);
36  auto const &assoc = iEvent.get(inputAssoc_);
37 
38  reco::TrackCollection tracksOut;
39 
40  for (auto const &track : tracks) {
41  if (!assoc.contains(track.extra().id())) {
42  continue;
43  }
44  const reco::TrackExtraRef &trackextraref = assoc[track.extra()];
45  if (trackextraref.isNonnull()) {
46  auto &trackout = tracksOut.emplace_back(track);
47  trackout.setExtra(trackextraref);
48  }
49  }
50 
51  iEvent.emplace(outputTrack_, std::move(tracksOut));
52 }
53 
56  desc.setComment("Simple prooducer to re-key muon tracks for refit");
57  desc.add<edm::InputTag>("src", edm::InputTag("generalTracks"))->setComment("input track collections");
58  desc.add<edm::InputTag>("association", edm::InputTag("muonReducedTrackExtras"))
59  ->setComment("input track association collection");
60  descriptions.addWithDefaultLabel(desc);
61 }
62 
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:15
const edm::EDPutTokenT< reco::TrackCollection > outputTrack_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< reco::TrackCollection > inputTrack_
void setComment(std::string const &value)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:326
ParameterDescriptionBase * add(U const &iLabel, T const &value)
TrackExtraRekeyer(const edm::ParameterSet &)
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:413
~TrackExtraRekeyer() override=default
fixed size matrix
const edm::EDGetTokenT< edm::Association< reco::TrackExtraCollection > > inputAssoc_
HLT enums.
def move(src, dest)
Definition: eostools.py:511