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
 
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)
 
 ~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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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
ProducesCollector producesCollector ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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<class ParticleType>
class MVAValueMapProducer< ParticleType >

Definition at line 24 of file MVAValueMapProducer.h.

Constructor & Destructor Documentation

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

Definition at line 93 of file MVAValueMapProducer.h.

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

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 }
T getParameter(std::string const &) const
VParameterSet const & getParameterSetVector(std::string const &name) const
const std::vector< std::string > mvaRawValueMapNames_
const MVAVariableHelper variableHelper_
const std::vector< std::unique_ptr< AnyMVAEstimatorRun2Base > > mvaEstimators_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const std::vector< std::string > mvaCategoriesMapNames_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const std::vector< std::string > mvaValueMapNames_
const edm::EDGetTokenT< edm::View< ParticleType > > src_

Member Function Documentation

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

Definition at line 139 of file MVAValueMapProducer.h.

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

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 }
void addDefault(ParameterSetDescription const &psetDescription)
template<class ParticleType >
void MVAValueMapProducer< ParticleType >::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivate

Definition at line 109 of file MVAValueMapProducer.h.

References eostools::cat(), JetChargeProducer_cfi::exp, MVAVariableHelper::getAuxVariables(), edm::Event::getHandle(), MVAValueMapProducer< ParticleType >::mvaCategoriesMapNames_, MVAValueMapProducer< ParticleType >::mvaEstimators_, MVAValueMapProducer< ParticleType >::mvaRawValueMapNames_, MVAValueMapProducer< ParticleType >::mvaValueMapNames_, TrackRefitter_38T_cff::src, MVAValueMapProducer< ParticleType >::src_, and MVAValueMapProducer< ParticleType >::variableHelper_.

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 }
const std::vector< std::string > mvaRawValueMapNames_
const MVAVariableHelper variableHelper_
const std::vector< std::unique_ptr< AnyMVAEstimatorRun2Base > > mvaEstimators_
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:547
def cat(path)
Definition: eostools.py:401
const std::vector< std::string > mvaCategoriesMapNames_
const std::vector< std::string > mvaValueMapNames_
const edm::EDGetTokenT< edm::View< ParticleType > > src_
const std::vector< float > getAuxVariables(const edm::Event &iEvent) const

Member Data Documentation

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

Definition at line 37 of file MVAValueMapProducer.h.

Referenced by MVAValueMapProducer< ParticleType >::produce().

template<class ParticleType >
const std::vector<std::string> MVAValueMapProducer< ParticleType >::mvaRawValueMapNames_
private
template<class ParticleType >
const std::vector<std::string> MVAValueMapProducer< ParticleType >::mvaValueMapNames_
private
template<class ParticleType >
const edm::EDGetTokenT<edm::View<ParticleType> > MVAValueMapProducer< ParticleType >::src_
private

Definition at line 34 of file MVAValueMapProducer.h.

Referenced by MVAValueMapProducer< ParticleType >::produce().

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

Definition at line 45 of file MVAValueMapProducer.h.

Referenced by MVAValueMapProducer< ParticleType >::produce().