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)
 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::InputTagtags_
 

Detailed Description

Definition at line 15 of file EfficiencyLoader.h.

Constructor & Destructor Documentation

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

Empty constructor.

Definition at line 18 of file EfficiencyLoader.h.

18 {}
EfficiencyLoader::EfficiencyLoader ( const edm::ParameterSet iConfig)

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 tags_.

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) {
15  tags_.push_back( iConfig.getParameter<edm::InputTag>(*it) );
16  }
17 
18  // prepare the Handles
19  handles_.resize(names_.size());
20 }
T getParameter(std::string const &) const
std::vector< std::string > names_
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:195
std::vector< edm::Handle< edm::ValueMap< pat::LookupTableRecord > > > handles_
std::vector< edm::InputTag > tags_

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::getByLabel(), handles_, i, n, names_, and tags_.

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

23  {
24  for (size_t i = 0, n = names_.size(); i < n; ++i) {
25  iEvent.getByLabel(tags_[i], handles_[i]);
26  }
27 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > names_
int iEvent
Definition: GenABIO.cc:243
std::vector< edm::Handle< edm::ValueMap< pat::LookupTableRecord > > > handles_
std::vector< edm::InputTag > tags_
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 41 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::PATPhotonProducer::produce(), pat::PATCompositeCandidateProducer::produce(), pat::PATPFParticleProducer::produce(), pat::PATGenericParticleProducer::produce(), pat::PATJetProducer::produce(), and pat::PATTauProducer::produce().

42 {
43  for (size_t i = 0, n = names_.size(); i < n; ++i) {
44  obj.setEfficiency(names_[i], (* handles_[i])[originalRef] );
45  }
46 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > names_
void setEfficiency(const std::string &name, const pat::LookupTableRecord &value)
Definition: PATObject.h:637
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 36 of file EfficiencyLoader.h.

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

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

Definition at line 34 of file EfficiencyLoader.h.

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

std::vector<edm::InputTag> pat::helper::EfficiencyLoader::tags_
private

Definition at line 35 of file EfficiencyLoader.h.

Referenced by EfficiencyLoader(), and newEvent().