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::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 bestPVselector (const edm::ParameterSet &iConfig)
 
void endJob () override
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
virtual ~bestPVselector ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::EDGetTokenT< std::vector
< T1 > > 
src_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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_(consumes<std::vector<T1> >(iConfig.getParameter<edm::InputTag>("src")))
49 {
50  produces<std::vector<T1> >();
51 }
T getParameter(std::string const &) const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< std::vector< T1 > > 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  )
overridevirtual

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 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 64 of file PVSorterBySumP.cc.

References edm::Event::getByToken(), p4, edm::Event::put(), and mathSSE::return().

65 {
66  std::auto_ptr<std::vector<T1> > theBestPV(new std::vector<T1 >);
67 
68  edm::Handle< std::vector<T1> > VertexHandle;
69  iEvent.getByToken(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 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
return((rh^lh)&mask)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
double p4[4]
Definition: TauolaWrapper.h:92
edm::EDGetTokenT< std::vector< T1 > > src_

Member Data Documentation

template<typename T1 >
edm::EDGetTokenT<std::vector<T1> > bestPVselector< T1 >::src_
private

Definition at line 36 of file PVSorterBySumP.cc.