CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
bestPVselector< T1 > Class Template Reference
Inheritance diagram for bestPVselector< T1 >:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 bestPVselector (const edm::ParameterSet &iConfig)
 
void endJob ()
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual ~bestPVselector ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

edm::InputTag src_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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.

48  : src_(iConfig.getParameter<edm::InputTag>("src"))
49 {
50  produces<std::vector<T1> >();
51 }
T getParameter(std::string const &) const
edm::InputTag src_
template<typename T1 >
bestPVselector< T1 >::~bestPVselector ( )
virtual

Definition at line 56 of file PVSorterBySumP.cc.

56 {}

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 97 of file PVSorterBySumP.cc.

98 {
99 }
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, edm::Event::put(), and hitfit::return.

65 {
66  std::auto_ptr<std::vector<T1> > theBestPV(new std::vector<T1 >);
67 
68  edm::Handle< std::vector<T1> > VertexHandle;
69  iEvent.getByLabel(src_,VertexHandle);
70 
71  if( VertexHandle->size() == 0 )
72  {
73  iEvent.put(theBestPV);
74  return ;
75  }
76 
77  typename std::vector<T1>::const_iterator PVit ;
78  typename std::vector<T1>::const_iterator bestPV ;
79 
80  double bestP4 = 0 ;
81  double sumSquarePt = 0 ;
82 
83  for (PVit = VertexHandle->begin(); PVit != VertexHandle->end(); ++PVit) {
84  sumSquarePt = (PVit -> p4().pt())*(PVit -> p4().pt()) ;
85  if( sumSquarePt > bestP4 ){
86  bestP4 = sumSquarePt ;
87  bestPV = PVit ;
88  }
89  }
90 
91  theBestPV->push_back( *bestPV );
92  iEvent.put(theBestPV);
93 
94 }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
double p4[4]
Definition: TauolaWrapper.h:92
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
edm::InputTag src_

Member Data Documentation

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

Definition at line 36 of file PVSorterBySumP.cc.