CMS 3D CMS Logo

MuonFromPVSelector.cc
Go to the documentation of this file.
6 
8 
11 
14 
15 #include <memory>
16 #include <numeric>
17 #include <vector>
18 
20 // class definition
23 public:
24  explicit MuonFromPVSelector(edm::ParameterSet const&);
25  void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
26 
27 private:
28  double max_dxy_;
29  double max_dz_;
32 };
33 
35 // construction
37 
39  : max_dxy_{iConfig.getParameter<double>("max_dxy")},
40  max_dz_{iConfig.getParameter<double>("max_dz")},
41  v_recoVertexToken_{consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("srcVertex"))},
42  v_recoMuonToken_{consumes<std::vector<reco::Muon>>(iConfig.getParameter<edm::InputTag>("srcMuon"))} {
43  produces<std::vector<reco::Muon>>();
44 }
45 
47 // implementation of member functions
49 
51  auto goodMuons = std::make_unique<std::vector<reco::Muon>>();
52 
54  iEvent.getByToken(v_recoVertexToken_, vertices);
55 
57  iEvent.getByToken(v_recoMuonToken_, muons);
58 
59  if (!vertices->empty()) {
60  auto const& pv = vertices->front();
61  std::copy_if(std::cbegin(*muons), std::cend(*muons), std::back_inserter(*goodMuons), [&pv, this](auto const& muon) {
62  return muon.innerTrack().isNonnull() && std::abs(muon.innerTrack()->dxy(pv.position())) < max_dxy_ &&
63  std::abs(muon.innerTrack()->dz(pv.position())) < max_dz_;
64  });
65  }
66 
68 }
69 
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< std::vector< reco::Muon > > v_recoMuonToken_
int iEvent
Definition: GenABIO.cc:224
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< std::vector< reco::Vertex > > v_recoVertexToken_
MuonFromPVSelector(edm::ParameterSet const &)
def move(src, dest)
Definition: eostools.py:511