CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonSelectorVertex.cc
Go to the documentation of this file.
1 //
2 //
3 
4 
8 
9 
11 
12  public:
13 
14  explicit MuonSelectorVertex( const edm::ParameterSet & iConfig );
16  virtual void produce( edm::Event & iEvent, const edm::EventSetup & iSetup ) override;
17 
18  private:
19 
22  double maxDZ_;
23 
24 };
25 
26 
27 #include <vector>
28 #include <memory>
29 #include <cmath>
30 
33 
34 
36 : muonSource_( iConfig.getParameter< edm::InputTag >( "muonSource" ) )
37 , vertexSource_( iConfig.getParameter< edm::InputTag >( "vertexSource" ) )
38 , maxDZ_( iConfig.getParameter< double >( "maxDZ" ) )
39 {
40 
41  produces< std::vector< pat::Muon > >();
42 
43 }
44 
45 
47 {
48 
50  iEvent.getByLabel( muonSource_, muons );
51 
53  iEvent.getByLabel( vertexSource_, vertices );
54 
55  std::vector< pat::Muon > * selectedMuons( new std::vector< pat::Muon > );
56 
57  if ( vertices->size() > 0 ) {
58 
59  for ( unsigned iMuon = 0; iMuon < muons->size(); ++iMuon ) {
60  if ( std::fabs( muons->at( iMuon ).vertex().z() - vertices->at( 0 ).z() ) < maxDZ_ ) {
61  selectedMuons->push_back( muons->at( iMuon ) );
62  }
63  }
64  }
65 
66  std::auto_ptr< std::vector< pat::Muon > > selectedMuonsPtr( selectedMuons );
67  iEvent.put( selectedMuonsPtr );
68 
69 }
70 
71 
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
edm::InputTag muonSource_
edm::InputTag vertexSource_
tuple muons
Definition: patZpeak.py:38
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
MuonSelectorVertex(const edm::ParameterSet &iConfig)