CMS 3D CMS Logo

Public Member Functions | Private Attributes

MuonFromPVSelector Class Reference

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

List of all members.

Public Member Functions

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

Private Attributes

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

Detailed Description

Definition at line 25 of file MuonFromPVSelector.cc.


Constructor & Destructor Documentation

MuonFromPVSelector::MuonFromPVSelector ( const edm::ParameterSet iConfig)

Definition at line 51 of file MuonFromPVSelector.cc.

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

Definition at line 62 of file MuonFromPVSelector.cc.

{}

Member Function Documentation

void MuonFromPVSelector::endJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 102 of file MuonFromPVSelector.cc.

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

Implements edm::EDProducer.

Definition at line 69 of file MuonFromPVSelector.cc.

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

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

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

  for (MuonIt = MuonHandle->begin(); MuonIt != MuonHandle->end(); ++MuonIt) {
    if ( MuonIt->innerTrack().isNonnull()                          &&
         fabs(MuonIt->innerTrack()->dxy(PV.position())) < max_dxy_ &&
         fabs(MuonIt->innerTrack()->dz(PV.position()))  < max_dz_  ){
      goodMuons -> push_back(*MuonIt) ;
    }
  }  
  
  iEvent.put(goodMuons);
  
}

Member Data Documentation

double MuonFromPVSelector::max_dxy_ [private]

Definition at line 40 of file MuonFromPVSelector.cc.

Referenced by produce().

double MuonFromPVSelector::max_dz_ [private]

Definition at line 41 of file MuonFromPVSelector.cc.

Referenced by produce().

Definition at line 38 of file MuonFromPVSelector.cc.

Referenced by produce().

Definition at line 39 of file MuonFromPVSelector.cc.

Referenced by produce().