CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronFromPVSelector.cc
Go to the documentation of this file.
1 // Includes
8 
10 
13 
16 
19 
22 
23 #include <memory>
24 #include <vector>
25 #include <sstream>
26 
27 
29 // class definition
32 {
33 public:
34  // construction/destruction
37 
38  // member functions
39  void produce(edm::Event& iEvent,const edm::EventSetup& iSetup) override;
40  void endJob() override;
41 
42 private:
43  // member data
44  double max_dxy_ ;
45  double max_dz_ ;
48 };
49 
50 
51 
53 // construction/destruction
55 
56 //______________________________________________________________________________
58  : max_dxy_ ( iConfig.getParameter<double>( "max_dxy" ) )
59  , max_dz_ ( iConfig.getParameter<double>( "max_dz" ) )
60  , v_recoVertexToken_ ( consumes< std::vector<reco::Vertex> >( iConfig.getParameter<edm::InputTag>( "srcVertex" ) ) )
61  , v_recoGsfElectronToken_( consumes< std::vector<reco::GsfElectron> >( iConfig.getParameter<edm::InputTag>( "srcElectron" ) ) )
62 {
63  produces<std::vector<reco::GsfElectron> >();
64 }
65 
66 
67 //______________________________________________________________________________
69 
71 // implementation of member functions
73 
74 //______________________________________________________________________________
76 {
77  std::auto_ptr<std::vector<reco::GsfElectron> > goodGsfElectrons(new std::vector<reco::GsfElectron >);
78 
80  iEvent.getByToken( v_recoVertexToken_, VertexHandle );
81 
83  iEvent.getByToken( v_recoGsfElectronToken_, GsfElectronHandle );
84 
85  if( (VertexHandle->size() == 0) || (GsfElectronHandle->size() == 0) )
86  {
87  iEvent.put(goodGsfElectrons);
88  return ;
89  }
90 
91 
92  reco::Vertex PV = VertexHandle->front();
93  std::vector<reco::GsfElectron>::const_iterator GsfElectronIt ;
94 // typename std::vector<reco::GsfElectron>::const_iterator GsfElectronIt ;
95 
96  for (GsfElectronIt = GsfElectronHandle->begin(); GsfElectronIt != GsfElectronHandle->end(); ++GsfElectronIt) {
97 
98  //int q = GsfElectronIt->gsfTrack()->charge() ;
99 
100  if ( fabs(GsfElectronIt->gsfTrack()->dxy(PV.position())) < max_dxy_ &&
101  fabs(GsfElectronIt->gsfTrack()->dz(PV.position())) < max_dz_ ) {
102  goodGsfElectrons -> push_back(*GsfElectronIt) ;
103  }
104  }
105 
106  iEvent.put(goodGsfElectrons);
107 
108 }
109 
111 {
112 }
113 
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
const Point & position() const
position
Definition: Vertex.h:92
edm::EDGetTokenT< std::vector< reco::GsfElectron > > v_recoGsfElectronToken_
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
GsfElectronFromPVSelector(const edm::ParameterSet &iConfig)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
return(e1-e2)*(e1-e2)+dp *dp
edm::EDGetTokenT< std::vector< reco::Vertex > > v_recoVertexToken_