CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
pat::helper::KinResolutionsLoader Class Reference

#include <KinResolutionsLoader.h>

Public Member Functions

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

Static Public Member Functions

static void fillDescription (edm::ParameterSetDescription &iDesc)
 Method for documentation and validation of PSet. More...
 

Private Attributes

std::vector< edm::ESGetToken< KinematicResolutionProvider, KinematicResolutionRcd > > estokens_
 Labels of the KinematicResolutionProvider in the EventSetup. More...
 
std::vector< std::string > patlabels_
 Labels of the resolutions in PAT. More...
 
std::vector< KinematicResolutionProvider const * > resolutions_
 Handles to the EventSetup. More...
 

Detailed Description

Definition at line 21 of file KinResolutionsLoader.h.

Constructor & Destructor Documentation

◆ KinResolutionsLoader() [1/2]

pat::helper::KinResolutionsLoader::KinResolutionsLoader ( )
inline

Empty constructor.

Definition at line 24 of file KinResolutionsLoader.h.

24 {}

◆ KinResolutionsLoader() [2/2]

KinResolutionsLoader::KinResolutionsLoader ( const edm::ParameterSet iConfig,
edm::ConsumesCollector  iCollector 
)

Constructor from a PSet.

Definition at line 8 of file KinResolutionsLoader.cc.

References edm::ConsumesCollector::esConsumes(), estokens_, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNamesForType(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, label, patlabels_, resolutions_, and AlCaHLTBitMon_QueryRunRegistry::string.

8  {
9  // Get the names (sorted)
11 
12  // get the InputTags
13  estokens_.reserve(patlabels_.size());
14  for (auto const &label : patlabels_) {
15  estokens_.emplace_back(iCollector.esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>(label))));
16  }
17  // prepare the resolutions
18  resolutions_.resize(patlabels_.size());
19 
20  // 'default' maps to empty string
21  for (std::vector<std::string>::iterator it = patlabels_.begin(), ed = patlabels_.end(); it != ed; ++it) {
22  if (*it == "default")
23  *it = "";
24  }
25 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< KinematicResolutionProvider const * > resolutions_
Handles to the EventSetup.
char const * label
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:180
std::vector< edm::ESGetToken< KinematicResolutionProvider, KinematicResolutionRcd > > estokens_
Labels of the KinematicResolutionProvider in the EventSetup.
std::vector< std::string > patlabels_
Labels of the resolutions in PAT.

Member Function Documentation

◆ enabled()

bool pat::helper::KinResolutionsLoader::enabled ( ) const
inline

◆ fillDescription()

void KinResolutionsLoader::fillDescription ( edm::ParameterSetDescription iDesc)
static

Method for documentation and validation of PSet.

Definition at line 33 of file KinResolutionsLoader.cc.

References edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), edm::ParameterSetDescription::setAllowAnything(), and edm::ParameterDescriptionNode::setComment().

Referenced by pat::PATMETProducer::fillDescriptions(), pat::PATPhotonProducer::fillDescriptions(), pat::PATTauProducer::fillDescriptions(), pat::PATJetProducer::fillDescriptions(), pat::PATElectronProducer::fillDescriptions(), and pat::PATMuonProducer::fillDescriptions().

33  {
34  iDesc.add<bool>("addResolutions", false)->setComment("Add resolutions into this PAT Object");
35  edm::ParameterSetDescription resolutionPSet;
36  resolutionPSet.setAllowAnything();
37  iDesc.addOptional("resolutions", resolutionPSet)->setComment("Resolution values to get from EventSetup");
38 }
void setComment(std::string const &value)
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void setAllowAnything()
allow any parameter label/value pairs
ParameterDescriptionBase * add(U const &iLabel, T const &value)

◆ newEvent()

void KinResolutionsLoader::newEvent ( const edm::Event event,
const edm::EventSetup setup 
)

To be called for each new event, reads in the EventSetup object.

Definition at line 27 of file KinResolutionsLoader.cc.

References estokens_, edm::EventSetup::getData(), mps_fire::i, dqmiodumpmetadata::n, patlabels_, and resolutions_.

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

27  {
28  for (size_t i = 0, n = patlabels_.size(); i < n; ++i) {
29  resolutions_[i] = &iSetup.getData(estokens_[i]);
30  }
31 }
std::vector< KinematicResolutionProvider const * > resolutions_
Handles to the EventSetup.
std::vector< edm::ESGetToken< KinematicResolutionProvider, KinematicResolutionRcd > > estokens_
Labels of the KinematicResolutionProvider in the EventSetup.
std::vector< std::string > patlabels_
Labels of the resolutions in PAT.

◆ setResolutions()

template<typename T >
void pat::helper::KinResolutionsLoader::setResolutions ( pat::PATObject< T > &  obj) const

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

Definition at line 52 of file KinResolutionsLoader.h.

References mps_fire::i, dqmiodumpmetadata::n, getGTfromDQMFile::obj, patlabels_, and resolutions_.

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

52  {
53  for (size_t i = 0, n = patlabels_.size(); i < n; ++i) {
54  obj.setKinResolution(resolutions_[i]->getResolution(obj), patlabels_[i]);
55  }
56  }
std::vector< KinematicResolutionProvider const * > resolutions_
Handles to the EventSetup.
std::vector< std::string > patlabels_
Labels of the resolutions in PAT.

Member Data Documentation

◆ estokens_

std::vector<edm::ESGetToken<KinematicResolutionProvider, KinematicResolutionRcd> > pat::helper::KinResolutionsLoader::estokens_
private

Labels of the KinematicResolutionProvider in the EventSetup.

Definition at line 46 of file KinResolutionsLoader.h.

Referenced by KinResolutionsLoader(), and newEvent().

◆ patlabels_

std::vector<std::string> pat::helper::KinResolutionsLoader::patlabels_
private

Labels of the resolutions in PAT.

Definition at line 44 of file KinResolutionsLoader.h.

Referenced by enabled(), KinResolutionsLoader(), newEvent(), and setResolutions().

◆ resolutions_

std::vector<KinematicResolutionProvider const *> pat::helper::KinResolutionsLoader::resolutions_
private

Handles to the EventSetup.

Definition at line 48 of file KinResolutionsLoader.h.

Referenced by KinResolutionsLoader(), newEvent(), and setResolutions().