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 
edm::StreamID
Definition: StreamID.h:30
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
Muon.h
muon
Definition: MuonCocktails.h:17
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm::Handle
Definition: AssociativeIterator.h:50
AlignmentTracksFromVertexSelector_cfi.vertices
vertices
Definition: AlignmentTracksFromVertexSelector_cfi.py:5
MuonFromPVSelector::v_recoVertexToken_
edm::EDGetTokenT< std::vector< reco::Vertex > > v_recoVertexToken_
Definition: MuonFromPVSelector.cc:30
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MuonFwd.h
MuonFromPVSelector::MuonFromPVSelector
MuonFromPVSelector(edm::ParameterSet const &)
Definition: MuonFromPVSelector.cc:38
edm::global::EDProducer
Definition: EDProducer.h:32
MuonFromPVSelector::v_recoMuonToken_
edm::EDGetTokenT< std::vector< reco::Muon > > v_recoMuonToken_
Definition: MuonFromPVSelector.cc:31
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
InputTag.h
VertexFwd.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
StringCutObjectSelector.h
Vertex.h
MuonFromPVSelector::max_dz_
double max_dz_
Definition: MuonFromPVSelector.cc:29
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MuonFromPVSelector::max_dxy_
double max_dxy_
Definition: MuonFromPVSelector.cc:28
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
MuonFromPVSelector
Definition: MuonFromPVSelector.cc:22
EDProducer.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
goodMuons_cfi.goodMuons
goodMuons
Definition: goodMuons_cfi.py:3
MuonFromPVSelector::produce
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
Definition: MuonFromPVSelector.cc:50