test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonFromPVSelector.cc
Go to the documentation of this file.
1 // Includes
8 
10 
13 
16 
17 #include <memory>
18 #include <vector>
19 #include <sstream>
20 
21 
23 // class definition
26 {
27 public:
28  // construction/destruction
29  MuonFromPVSelector(const edm::ParameterSet& iConfig);
30  virtual ~MuonFromPVSelector();
31 
32  // member functions
33  void produce(edm::Event& iEvent,const edm::EventSetup& iSetup) override;
34 
35 private:
36  // member data
37  double max_dxy_ ;
38  double max_dz_ ;
41 };
42 
43 
44 
46 // construction/destruction
48 
49 //______________________________________________________________________________
51  : max_dxy_ ( iConfig.getParameter<double>( "max_dxy" ) )
52  , max_dz_ ( iConfig.getParameter<double>( "max_dz" ) )
53  , v_recoVertexToken_( consumes< std::vector<reco::Vertex> >( iConfig.getParameter<edm::InputTag>( "srcVertex" ) ) )
54  , v_recoMuonToken_ ( consumes< std::vector<reco::Muon> >( iConfig.getParameter<edm::InputTag>( "srcMuon" ) ) )
55 {
56  produces<std::vector<reco::Muon> >();
57 }
58 
59 
60 //______________________________________________________________________________
62 
64 // implementation of member functions
66 
67 //______________________________________________________________________________
69 {
70  std::auto_ptr<std::vector<reco::Muon> > goodMuons(new std::vector<reco::Muon >);
71 
73  iEvent.getByToken( v_recoVertexToken_, VertexHandle );
74 
76  iEvent.getByToken( v_recoMuonToken_, MuonHandle );
77 
78  if( (VertexHandle->size() == 0) || (MuonHandle->size() == 0) )
79  {
80  iEvent.put(goodMuons);
81  return ;
82  }
83 
84 
85  reco::Vertex PV = VertexHandle->front();
86  //typename std::vector<reco::Muon>::const_iterator MuonIt ;
87  std::vector<reco::Muon>::const_iterator MuonIt ;
88 
89  for (MuonIt = MuonHandle->begin(); MuonIt != MuonHandle->end(); ++MuonIt) {
90  if ( MuonIt->innerTrack().isNonnull() &&
91  fabs(MuonIt->innerTrack()->dxy(PV.position())) < max_dxy_ &&
92  fabs(MuonIt->innerTrack()->dz(PV.position())) < max_dz_ ){
93  goodMuons -> push_back(*MuonIt) ;
94  }
95  }
96 
97  iEvent.put(goodMuons);
98 
99 }
100 
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
const Point & position() const
position
Definition: Vertex.h:99
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
edm::EDGetTokenT< std::vector< reco::Vertex > > v_recoVertexToken_
MuonFromPVSelector(const edm::ParameterSet &iConfig)
return(e1-e2)*(e1-e2)+dp *dp
edm::EDGetTokenT< std::vector< reco::Muon > > v_recoMuonToken_