CMS 3D CMS Logo

Public Member Functions | Private Attributes

bestPVselector< T1 > Class Template Reference

Inheritance diagram for bestPVselector< T1 >:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

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

Private Attributes

edm::InputTag src_

Detailed Description

template<typename T1>
class bestPVselector< T1 >

Definition at line 23 of file PVSorterBySumP.cc.


Constructor & Destructor Documentation

template<typename T1 >
bestPVselector< T1 >::bestPVselector ( const edm::ParameterSet iConfig)

Definition at line 47 of file PVSorterBySumP.cc.

  : src_(iConfig.getParameter<edm::InputTag>("src"))
{
  produces<std::vector<T1> >();
}
template<typename T1 >
bestPVselector< T1 >::~bestPVselector ( ) [virtual]

Definition at line 56 of file PVSorterBySumP.cc.

{}

Member Function Documentation

template<typename T1 >
void bestPVselector< T1 >::endJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 97 of file PVSorterBySumP.cc.

{
}
template<typename T1 >
void bestPVselector< T1 >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 64 of file PVSorterBySumP.cc.

References edm::Event::getByLabel(), p4, and edm::Event::put().

{  
  std::auto_ptr<std::vector<T1> > theBestPV(new std::vector<T1 >);
  
  edm::Handle< std::vector<T1> > VertexHandle;
  iEvent.getByLabel(src_,VertexHandle);
  
  if( VertexHandle->size() == 0 ) 
  {
    iEvent.put(theBestPV);
    return ;
  }
  
  typename std::vector<T1>::const_iterator PVit   ;
  typename std::vector<T1>::const_iterator bestPV ;
  
  double bestP4      = 0 ;
  double sumSquarePt = 0 ;

  for (PVit = VertexHandle->begin(); PVit != VertexHandle->end(); ++PVit) {
    sumSquarePt = (PVit -> p4().pt())*(PVit -> p4().pt()) ;
        if( sumSquarePt > bestP4 ){
          bestP4 = sumSquarePt ;
          bestPV = PVit        ; 
        }
  }

  theBestPV->push_back( *bestPV );  
  iEvent.put(theBestPV);
  
}

Member Data Documentation

template<typename T1 >
edm::InputTag bestPVselector< T1 >::src_ [private]

Definition at line 36 of file PVSorterBySumP.cc.