CMS 3D CMS Logo

Public Member Functions | Private Attributes

TrackFromPVSelector Class Reference

Inheritance diagram for TrackFromPVSelector:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

void endJob ()
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 TrackFromPVSelector (const edm::ParameterSet &iConfig)
virtual ~TrackFromPVSelector ()

Private Attributes

double max_dxy_
double max_dz_
edm::InputTag srcPart_
edm::InputTag srcPV_

Detailed Description

Definition at line 25 of file TrackFromPVSelector.cc.


Constructor & Destructor Documentation

TrackFromPVSelector::TrackFromPVSelector ( const edm::ParameterSet iConfig)

Definition at line 51 of file TrackFromPVSelector.cc.

  : srcPart_(iConfig.getParameter<edm::InputTag>("srcTrack"))
  , srcPV_  (iConfig.getParameter<edm::InputTag>("srcVertex"))
  , max_dxy_(iConfig.getParameter<double>("max_dxy"))
  , max_dz_ (iConfig.getParameter<double>("max_dz"))
{
  produces<std::vector<reco::Track> >();
}
TrackFromPVSelector::~TrackFromPVSelector ( ) [virtual]

Definition at line 62 of file TrackFromPVSelector.cc.

{}

Member Function Documentation

void TrackFromPVSelector::endJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 100 of file TrackFromPVSelector.cc.

{
}
void TrackFromPVSelector::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 69 of file TrackFromPVSelector.cc.

References edm::Event::getByLabel(), goodTracks_cfi::goodTracks, max_dxy_, max_dz_, reco::Vertex::position(), edm::Event::put(), srcPart_, and srcPV_.

{  
  std::auto_ptr<std::vector<reco::Track> > goodTracks(new std::vector<reco::Track >);
  
  edm::Handle< std::vector<reco::Vertex> > VertexHandle;
  iEvent.getByLabel(srcPV_,VertexHandle);

  edm::Handle< std::vector<reco::Track> > TrackHandle;
  iEvent.getByLabel(srcPart_,TrackHandle);
  
  if( (VertexHandle->size() == 0) || (TrackHandle->size() == 0) ) 
  {
    iEvent.put(goodTracks);
    return ;
  }
  
  reco::Vertex PV = VertexHandle->front();   
  //typename std::vector<reco::Track>::const_iterator TrackIt ;
  std::vector<reco::Track>::const_iterator TrackIt ;

  for (TrackIt = TrackHandle->begin(); TrackIt != TrackHandle->end(); ++TrackIt) {
    if ( fabs(TrackIt->dxy(PV.position())) < max_dxy_ &&
         fabs(TrackIt->dz(PV.position()))  < max_dz_  ){
      goodTracks -> push_back(*TrackIt) ;
    }
  }  
  
  iEvent.put(goodTracks);
  
}

Member Data Documentation

Definition at line 40 of file TrackFromPVSelector.cc.

Referenced by produce().

double TrackFromPVSelector::max_dz_ [private]

Definition at line 41 of file TrackFromPVSelector.cc.

Referenced by produce().

Definition at line 38 of file TrackFromPVSelector.cc.

Referenced by produce().

Definition at line 39 of file TrackFromPVSelector.cc.

Referenced by produce().