CMS 3D CMS Logo

TrackProducerFromPatMuons.cc
Go to the documentation of this file.
4 
9 
11 public:
13  ~TrackProducerFromPatMuons() override = default;
14 
15  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
16 
17 private:
18  void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
19 
22  const bool innerTrackOnly_;
23 };
24 
26  : inputMuons_(consumes<std::vector<pat::Muon>>(iConfig.getParameter<edm::InputTag>("src"))),
27  outputTrack_(produces<reco::TrackCollection>()),
28  innerTrackOnly_(iConfig.getParameter<bool>("innerTrackOnly")) {}
29 
30 // ------------ method called for each event ------------
32  using namespace edm;
33 
34  auto const &muons = iEvent.get(inputMuons_);
35 
36  reco::TrackCollection tracksOut;
37 
38  for (auto const &muon : muons) {
39  const reco::TrackRef trackRef = innerTrackOnly_ ? muon.innerTrack() : muon.muonBestTrack();
40  if (trackRef.isNonnull() && trackRef->extra().isAvailable()) {
41  tracksOut.emplace_back(*trackRef);
42  }
43  }
44  iEvent.emplace(outputTrack_, std::move(tracksOut));
45 }
46 
49  desc.setComment("Simple prooducer to generate track from pat::muons ");
50  desc.add<edm::InputTag>("src", edm::InputTag("slimmedMuons"))->setComment("input track collections");
51  desc.add<bool>("innerTrackOnly", true)->setComment("use only inner track");
52  descriptions.addWithDefaultLabel(desc);
53 }
54 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
~TrackProducerFromPatMuons() override=default
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
Definition: HeavyIon.h:7
TrackProducerFromPatMuons(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:224
Definition: Muon.py:1
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool isAvailable() const
Definition: Ref.h:541
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::EDPutTokenT< reco::TrackCollection > outputTrack_
fixed size matrix
HLT enums.
def move(src, dest)
Definition: eostools.py:511
const edm::EDGetTokenT< std::vector< pat::Muon > > inputMuons_