CMS 3D CMS Logo

MuonSelectorVertex.cc
Go to the documentation of this file.
1 //
2 //
3 
7 
10 
12 public:
13  explicit MuonSelectorVertex(const edm::ParameterSet& iConfig);
14  ~MuonSelectorVertex() override{};
15  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
16 
17 private:
20  double maxDZ_;
21 };
22 
23 #include <vector>
24 #include <memory>
25 #include <cmath>
26 
28  : muonSource_(consumes<std::vector<pat::Muon> >(iConfig.getParameter<edm::InputTag>("muonSource"))),
29  vertexSource_(consumes<std::vector<reco::Vertex> >(iConfig.getParameter<edm::InputTag>("vertexSource"))),
30  maxDZ_(iConfig.getParameter<double>("maxDZ")) {
31  produces<std::vector<pat::Muon> >();
32 }
33 
36  iEvent.getByToken(muonSource_, muons);
37 
39  iEvent.getByToken(vertexSource_, vertices);
40 
41  std::vector<pat::Muon>* selectedMuons(new std::vector<pat::Muon>);
42 
43  if (!vertices->empty()) {
44  for (unsigned iMuon = 0; iMuon < muons->size(); ++iMuon) {
45  if (std::fabs(muons->at(iMuon).vertex().z() - vertices->at(0).z()) < maxDZ_) {
46  selectedMuons->push_back(muons->at(iMuon));
47  }
48  }
49  }
50 
51  std::unique_ptr<std::vector<pat::Muon> > selectedMuonsPtr(selectedMuons);
52  iEvent.put(std::move(selectedMuonsPtr));
53 }
54 
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
MuonSelectorVertex::muonSource_
edm::EDGetTokenT< std::vector< pat::Muon > > muonSource_
Definition: MuonSelectorVertex.cc:18
MuonSelectorVertex::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: MuonSelectorVertex.cc:34
MuonSelectorVertex::vertexSource_
edm::EDGetTokenT< std::vector< reco::Vertex > > vertexSource_
Definition: MuonSelectorVertex.cc:19
EDProducer.h
MuonSelectorVertex::~MuonSelectorVertex
~MuonSelectorVertex() override
Definition: MuonSelectorVertex.cc:14
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
Muon.h
METSignificanceObjects_cfi.selectedMuons
selectedMuons
======================================
Definition: METSignificanceObjects_cfi.py:7
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
edm::Handle
Definition: AssociativeIterator.h:50
MuonSelectorVertex
Definition: MuonSelectorVertex.cc:11
AlignmentTracksFromVertexSelector_cfi.vertices
vertices
Definition: AlignmentTracksFromVertexSelector_cfi.py:5
Muon
Definition: Muon.py:1
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ParameterSet
Definition: ParameterSet.h:47
MuonSelectorVertex::maxDZ_
double maxDZ_
Definition: MuonSelectorVertex.cc:20
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:58
pat
Definition: HeavyIon.h:7
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
HltBtagValidation_cff.Vertex
Vertex
Definition: HltBtagValidation_cff.py:32
Vertex.h
MuonSelectorVertex::MuonSelectorVertex
MuonSelectorVertex(const edm::ParameterSet &iConfig)
Definition: MuonSelectorVertex.cc:27
edm::EDProducer
Definition: EDProducer.h:35
ParameterSet.h
edm::Event
Definition: Event.h:73