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
pat::helper::EfficiencyLoader Class Reference

#include <EfficiencyLoader.h>

Public Member Functions

 EfficiencyLoader ()
 Empty constructor. More...
 
 EfficiencyLoader (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 Constructor from a PSet. More...
 
bool enabled () const
 'true' if this there is at least one efficiency configured More...
 
void newEvent (const edm::Event &event) const
 To be called for each new event, reads in the ValueMaps for efficiencies. More...
 
template<typename T , typename R >
void setEfficiencies (pat::PATObject< T > &obj, const R &originalRef) const
 Sets the efficiencies for this object, using the reference to the original objects. More...
 

Private Attributes

std::vector< edm::Handle
< edm::ValueMap
< pat::LookupTableRecord > > > 
handles_
 
std::vector< std::string > names_
 
std::vector< edm::EDGetTokenT
< edm::ValueMap
< pat::LookupTableRecord > > > 
tokens_
 

Detailed Description

Definition at line 16 of file EfficiencyLoader.h.

Constructor & Destructor Documentation

pat::helper::EfficiencyLoader::EfficiencyLoader ( )
inline

Empty constructor.

Definition at line 19 of file EfficiencyLoader.h.

19 {}
EfficiencyLoader::EfficiencyLoader ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)

Constructor from a PSet.

Definition at line 7 of file EfficiencyLoader.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNamesForType(), handles_, names_, python.multivaluedict::sort(), and tokens_.

8 {
9  // Get the names (sorted)
11  std::sort(names_.begin(), names_.end());
12 
13  // get the InputTags
14  for (std::vector<std::string>::const_iterator it = names_.begin(), ed = names_.end(); it != ed; ++it) {
16  }
17 
18  // prepare the Handles
19  handles_.resize(names_.size());
20 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
std::vector< std::string > names_
std::vector< edm::EDGetTokenT< edm::ValueMap< pat::LookupTableRecord > > > tokens_
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:192
std::vector< edm::Handle< edm::ValueMap< pat::LookupTableRecord > > > handles_

Member Function Documentation

bool pat::helper::EfficiencyLoader::enabled ( ) const
inline
void EfficiencyLoader::newEvent ( const edm::Event event) const

To be called for each new event, reads in the ValueMaps for efficiencies.

Definition at line 23 of file EfficiencyLoader.cc.

References edm::Event::getByToken(), handles_, i, n, names_, and tokens_.

Referenced by pat::PATMETProducer::produce(), pat::PATCompositeCandidateProducer::produce(), pat::PATGenericParticleProducer::produce(), pat::PATPFParticleProducer::produce(), pat::PATMuonProducer::produce(), pat::PATTauProducer::produce(), pat::PATJetProducer::produce(), pat::PATPhotonProducer::produce(), and pat::PATElectronProducer::produce().

23  {
24  for (size_t i = 0, n = names_.size(); i < n; ++i) {
25  iEvent.getByToken(tokens_[i], handles_[i]);
26  }
27 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > names_
std::vector< edm::EDGetTokenT< edm::ValueMap< pat::LookupTableRecord > > > tokens_
int iEvent
Definition: GenABIO.cc:230
std::vector< edm::Handle< edm::ValueMap< pat::LookupTableRecord > > > handles_
template<typename T , typename R >
void pat::helper::EfficiencyLoader::setEfficiencies ( pat::PATObject< T > &  obj,
const R &  originalRef 
) const

Sets the efficiencies for this object, using the reference to the original objects.

Definition at line 42 of file EfficiencyLoader.h.

References handles_, i, n, names_, and pat::PATObject< ObjectType >::setEfficiency().

Referenced by pat::PATElectronProducer::fillElectron(), pat::PATElectronProducer::fillElectron2(), pat::PATMuonProducer::fillMuon(), pat::PATMETProducer::produce(), pat::PATCompositeCandidateProducer::produce(), pat::PATGenericParticleProducer::produce(), pat::PATPFParticleProducer::produce(), pat::PATTauProducer::produce(), pat::PATJetProducer::produce(), and pat::PATPhotonProducer::produce().

43 {
44  for (size_t i = 0, n = names_.size(); i < n; ++i) {
45  obj.setEfficiency(names_[i], (* handles_[i])[originalRef] );
46  }
47 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > names_
void setEfficiency(const std::string &name, const pat::LookupTableRecord &value)
Definition: PATObject.h:639
std::vector< edm::Handle< edm::ValueMap< pat::LookupTableRecord > > > handles_

Member Data Documentation

std::vector<edm::Handle< edm::ValueMap<pat::LookupTableRecord> > > pat::helper::EfficiencyLoader::handles_
mutableprivate

Definition at line 37 of file EfficiencyLoader.h.

Referenced by EfficiencyLoader(), newEvent(), and setEfficiencies().

std::vector<std::string> pat::helper::EfficiencyLoader::names_
private

Definition at line 35 of file EfficiencyLoader.h.

Referenced by EfficiencyLoader(), enabled(), newEvent(), and setEfficiencies().

std::vector<edm::EDGetTokenT<edm::ValueMap<pat::LookupTableRecord> > > pat::helper::EfficiencyLoader::tokens_
private

Definition at line 36 of file EfficiencyLoader.h.

Referenced by EfficiencyLoader(), and newEvent().