CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
bool isAvailable() const
Definition: Ref.h:537
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
~TrackProducerFromPatMuons() override=default
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
TrackProducerFromPatMuons(const edm::ParameterSet &)
void setComment(std::string const &value)
int iEvent
Definition: GenABIO.cc:224
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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)
const edm::EDPutTokenT< reco::TrackCollection > outputTrack_
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:433
tuple muons
Definition: patZpeak.py:39
const edm::EDGetTokenT< std::vector< pat::Muon > > inputMuons_