CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
MVAValueMapProducer< ParticleType > Class Template Reference

#include <MVAValueMapProducer.h>

Inheritance diagram for MVAValueMapProducer< ParticleType >:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MVAValueMapProducer (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

const std::vector< std::string > mvaCategoriesMapNames_
 
const std::vector< std::unique_ptr< AnyMVAEstimatorRun2Base > > mvaEstimators_
 
const std::vector< std::string > mvaRawValueMapNames_
 
const std::vector< std::string > mvaValueMapNames_
 
const edm::EDGetTokenT< edm::View< ParticleType > > src_
 
const MVAVariableHelper variableHelper_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

template<class ParticleType>
class MVAValueMapProducer< ParticleType >

Definition at line 24 of file MVAValueMapProducer.h.

Constructor & Destructor Documentation

◆ MVAValueMapProducer()

template<class ParticleType >
MVAValueMapProducer< ParticleType >::MVAValueMapProducer ( const edm::ParameterSet iConfig)

Definition at line 93 of file MVAValueMapProducer.h.

95  mvaEstimators_(getMVAEstimators(iConfig.getParameterSetVector("mvaConfigurations"))),
96  mvaValueMapNames_(getValueMapNames(iConfig.getParameterSetVector("mvaConfigurations"), "Values")),
97  mvaRawValueMapNames_(getValueMapNames(iConfig.getParameterSetVector("mvaConfigurations"), "RawValues")),
98  mvaCategoriesMapNames_(getValueMapNames(iConfig.getParameterSetVector("mvaConfigurations"), "Categories")),
100  for (auto const& name : mvaValueMapNames_)
101  produces<edm::ValueMap<float>>(name);
102  for (auto const& name : mvaRawValueMapNames_)
103  produces<edm::ValueMap<float>>(name);
104  for (auto const& name : mvaCategoriesMapNames_)
105  produces<edm::ValueMap<int>>(name);
106 }

References MVAValueMapProducer< ParticleType >::mvaCategoriesMapNames_, MVAValueMapProducer< ParticleType >::mvaRawValueMapNames_, MVAValueMapProducer< ParticleType >::mvaValueMapNames_, and Skims_PA_cff::name.

Member Function Documentation

◆ fillDescriptions()

template<class ParticleType >
void MVAValueMapProducer< ParticleType >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 139 of file MVAValueMapProducer.h.

139  {
140  //The following says we do not know what parameters are allowed so do no validation
141  // Please change this to state exactly what you do use, even if it is no parameters
143  desc.setUnknown();
144  descriptions.addDefault(desc);
145 }

References edm::ConfigurationDescriptions::addDefault(), and edm::ParameterSetDescription::setUnknown().

◆ produce()

template<class ParticleType >
void MVAValueMapProducer< ParticleType >::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 109 of file MVAValueMapProducer.h.

111  {
112  std::vector<float> auxVariables = variableHelper_.getAuxVariables(iEvent);
113 
114  auto src = iEvent.getHandle(src_);
115 
116  // Loop over MVA estimators
117  for (unsigned iEstimator = 0; iEstimator < mvaEstimators_.size(); iEstimator++) {
118  std::vector<float> mvaValues;
119  std::vector<float> mvaRawValues;
120  std::vector<int> mvaCategories;
121 
122  // Loop over particles
123  for (auto const& cand : src->ptrs()) {
124  int cat = -1; // Passed by reference to the mvaValue function to store the category
125  const float response = mvaEstimators_[iEstimator]->mvaValue(cand.get(), auxVariables, cat);
126  mvaRawValues.push_back(response); // The MVA score
127  mvaValues.push_back(2.0 / (1.0 + exp(-2.0 * response)) - 1); // MVA output between -1 and 1
128  mvaCategories.push_back(cat);
129  } // end loop over particles
130 
131  writeValueMap(iEvent, src, mvaValues, mvaValueMapNames_[iEstimator]);
132  writeValueMap(iEvent, src, mvaRawValues, mvaRawValueMapNames_[iEstimator]);
133  writeValueMap(iEvent, src, mvaCategories, mvaCategoriesMapNames_[iEstimator]);
134 
135  } // end loop over estimators
136 }

References eostools::cat(), JetChargeProducer_cfi::exp, iEvent, and TrackRefitter_38T_cff::src.

Member Data Documentation

◆ mvaCategoriesMapNames_

template<class ParticleType >
const std::vector<std::string> MVAValueMapProducer< ParticleType >::mvaCategoriesMapNames_
private

◆ mvaEstimators_

template<class ParticleType >
const std::vector<std::unique_ptr<AnyMVAEstimatorRun2Base> > MVAValueMapProducer< ParticleType >::mvaEstimators_
private

Definition at line 37 of file MVAValueMapProducer.h.

◆ mvaRawValueMapNames_

template<class ParticleType >
const std::vector<std::string> MVAValueMapProducer< ParticleType >::mvaRawValueMapNames_
private

◆ mvaValueMapNames_

template<class ParticleType >
const std::vector<std::string> MVAValueMapProducer< ParticleType >::mvaValueMapNames_
private

◆ src_

template<class ParticleType >
const edm::EDGetTokenT<edm::View<ParticleType> > MVAValueMapProducer< ParticleType >::src_
private

Definition at line 34 of file MVAValueMapProducer.h.

◆ variableHelper_

template<class ParticleType >
const MVAVariableHelper MVAValueMapProducer< ParticleType >::variableHelper_
private

Definition at line 45 of file MVAValueMapProducer.h.

MVAValueMapProducer::src_
const edm::EDGetTokenT< edm::View< ParticleType > > src_
Definition: MVAValueMapProducer.h:34
eostools.cat
def cat(path)
Definition: eostools.py:401
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:71
MVAVariableHelper::getAuxVariables
const std::vector< float > getAuxVariables(const edm::Event &iEvent) const
Definition: MVAVariableHelper.cc:7
MVAValueMapProducer::mvaValueMapNames_
const std::vector< std::string > mvaValueMapNames_
Definition: MVAValueMapProducer.h:40
MVAValueMapProducer::mvaCategoriesMapNames_
const std::vector< std::string > mvaCategoriesMapNames_
Definition: MVAValueMapProducer.h:42
edm::View
Definition: CaloClusterFwd.h:14
MVAValueMapProducer::mvaRawValueMapNames_
const std::vector< std::string > mvaRawValueMapNames_
Definition: MVAValueMapProducer.h:41
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
cand
Definition: decayParser.h:34
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::ParameterSetDescription::setUnknown
void setUnknown()
Definition: ParameterSetDescription.cc:39
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
MVAValueMapProducer::mvaEstimators_
const std::vector< std::unique_ptr< AnyMVAEstimatorRun2Base > > mvaEstimators_
Definition: MVAValueMapProducer.h:37
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edm::ParameterSet::getParameterSetVector
VParameterSet const & getParameterSetVector(std::string const &name) const
Definition: ParameterSet.cc:2153
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:126
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
MVAValueMapProducer::variableHelper_
const MVAVariableHelper variableHelper_
Definition: MVAValueMapProducer.h:45
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::InputTag
Definition: InputTag.h:15