CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ElectronPATIdMVAProducer Class Reference
Inheritance diagram for ElectronPATIdMVAProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ElectronPATIdMVAProducer (const edm::ParameterSet &)
 
 ~ElectronPATIdMVAProducer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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)
 

Private Member Functions

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

Private Attributes

double _Rho
 
edm::EDGetTokenT< pat::ElectronCollectionelectronToken_
 
edm::EDGetTokenT< double > eventrhoToken_
 
std::string method_
 
EGammaMvaEleEstimatormvaID_
 
std::vector< std::string > mvaWeightFiles_
 
bool verbose_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer 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
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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

Definition at line 24 of file ElectronPATIdMVAProducer.cc.

Constructor & Destructor Documentation

◆ ElectronPATIdMVAProducer()

ElectronPATIdMVAProducer::ElectronPATIdMVAProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 54 of file ElectronPATIdMVAProducer.cc.

54  {
55  verbose_ = iConfig.getUntrackedParameter<bool>("verbose", false);
56  electronToken_ = consumes<pat::ElectronCollection>(iConfig.getParameter<edm::InputTag>("electronTag"));
57  method_ = iConfig.getParameter<std::string>("method");
58  std::vector<std::string> fpMvaWeightFiles = iConfig.getParameter<std::vector<std::string> >("mvaWeightFile");
59  eventrhoToken_ = consumes<double>(iConfig.getParameter<edm::InputTag>("Rho"));
60 
61  produces<edm::ValueMap<float> >();
62 
64 
66 
68 
69  bool manualCat_ = true;
70 
71  std::string path_mvaWeightFileEleID;
72  for (unsigned ifile = 0; ifile < fpMvaWeightFiles.size(); ++ifile) {
73  path_mvaWeightFileEleID = edm::FileInPath(fpMvaWeightFiles[ifile].c_str()).fullPath();
74  mvaWeightFiles_.push_back(path_mvaWeightFileEleID);
75  }
76 
77  mvaID_->initialize(method_, type_, manualCat_, mvaWeightFiles_);
78 }

References electronToken_, eventrhoToken_, edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), compare_using_db::ifile, EGammaMvaEleEstimator::initialize(), EGammaMvaEleEstimator::kTrigNoIP, method_, mvaID_, mvaWeightFiles_, AlCaHLTBitMon_QueryRunRegistry::string, and verbose_.

◆ ~ElectronPATIdMVAProducer()

ElectronPATIdMVAProducer::~ElectronPATIdMVAProducer ( )
override

Definition at line 80 of file ElectronPATIdMVAProducer.cc.

80  {
81  // do anything here that needs to be done at desctruction time
82  // (e.g. close files, deallocate resources etc.)
83 }

Member Function Documentation

◆ produce()

void ElectronPATIdMVAProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 90 of file ElectronPATIdMVAProducer.cc.

90  {
91  std::unique_ptr<edm::ValueMap<float> > out(new edm::ValueMap<float>());
92 
94  iEvent.getByToken(electronToken_, egCollection);
95  const pat::ElectronCollection egCandidates = (*egCollection.product());
96 
97  _Rho = 0;
98  edm::Handle<double> rhoPtr;
99  //const edm::InputTag eventrhoToken_("kt6PFJets", "rho");
100  iEvent.getByToken(eventrhoToken_, rhoPtr);
101  _Rho = *rhoPtr;
102 
103  std::vector<float> values;
104  values.reserve(egCollection->size());
105 
106  for (pat::ElectronCollection::const_iterator egIter = egCandidates.begin(); egIter != egCandidates.end(); ++egIter) {
107  double mvaVal = -999999;
108 
109  mvaVal = mvaID_->mvaValue(*egIter, _Rho, verbose_);
110 
111  values.push_back(mvaVal);
112  }
113 
115  filler.insert(egCollection, values.begin(), values.end());
116  filler.fill();
117 
118  iEvent.put(std::move(out));
119 }

References _Rho, electronToken_, eventrhoToken_, trigObjTnPSource_cfi::filler, iEvent, eostools::move(), mvaID_, EGammaMvaEleEstimator::mvaValue(), MillePedeFileConverter_cfg::out, edm::Handle< T >::product(), contentValuesCheck::values, and verbose_.

Member Data Documentation

◆ _Rho

double ElectronPATIdMVAProducer::_Rho
private

Definition at line 35 of file ElectronPATIdMVAProducer.cc.

Referenced by produce().

◆ electronToken_

edm::EDGetTokenT<pat::ElectronCollection> ElectronPATIdMVAProducer::electronToken_
private

Definition at line 34 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer(), and produce().

◆ eventrhoToken_

edm::EDGetTokenT<double> ElectronPATIdMVAProducer::eventrhoToken_
private

Definition at line 36 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer(), and produce().

◆ method_

std::string ElectronPATIdMVAProducer::method_
private

Definition at line 37 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer().

◆ mvaID_

EGammaMvaEleEstimator* ElectronPATIdMVAProducer::mvaID_
private

Definition at line 40 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer(), and produce().

◆ mvaWeightFiles_

std::vector<std::string> ElectronPATIdMVAProducer::mvaWeightFiles_
private

Definition at line 38 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer().

◆ verbose_

bool ElectronPATIdMVAProducer::verbose_
private

Definition at line 33 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer(), and produce().

EGammaMvaEleEstimator
Definition: EGammaMvaEleEstimator.h:38
edm::Handle::product
T const * product() const
Definition: Handle.h:70
pat::ElectronCollection
std::vector< Electron > ElectronCollection
Definition: Electron.h:36
ElectronPATIdMVAProducer::mvaID_
EGammaMvaEleEstimator * mvaID_
Definition: ElectronPATIdMVAProducer.cc:40
EGammaMvaEleEstimator::kTrigNoIP
Definition: EGammaMvaEleEstimator.h:45
EGammaMvaEleEstimator::initialize
void initialize(std::string methodName, std::string weightsfile, EGammaMvaEleEstimator::MVAType type)
Definition: EGammaMvaEleEstimator.cc:42
ElectronPATIdMVAProducer::method_
std::string method_
Definition: ElectronPATIdMVAProducer.cc:37
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle
Definition: AssociativeIterator.h:50
EGammaMvaEleEstimator::MVAType
MVAType
Definition: EGammaMvaEleEstimator.h:43
ElectronPATIdMVAProducer::verbose_
bool verbose_
Definition: ElectronPATIdMVAProducer.cc:33
edm::FileInPath
Definition: FileInPath.h:64
ElectronPATIdMVAProducer::eventrhoToken_
edm::EDGetTokenT< double > eventrhoToken_
Definition: ElectronPATIdMVAProducer.cc:36
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
compare_using_db.ifile
ifile
Definition: compare_using_db.py:251
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ElectronPATIdMVAProducer::_Rho
double _Rho
Definition: ElectronPATIdMVAProducer.cc:35
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
iEvent
int iEvent
Definition: GenABIO.cc:224
EGammaMvaEleEstimator::mvaValue
Double_t mvaValue(const reco::GsfElectron &ele, const reco::Vertex &vertex, const TransientTrackBuilder &transientTrackBuilder, EcalClusterLazyTools const &myEcalCluster, bool printDebug=kFALSE)
Definition: EGammaMvaEleEstimator.cc:954
eostools.move
def move(src, dest)
Definition: eostools.py:511
ElectronPATIdMVAProducer::electronToken_
edm::EDGetTokenT< pat::ElectronCollection > electronToken_
Definition: ElectronPATIdMVAProducer.cc:34
edm::ValueMap< float >
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
edm::helper::Filler
Definition: ValueMap.h:22
edm::InputTag
Definition: InputTag.h:15
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161
ElectronPATIdMVAProducer::mvaWeightFiles_
std::vector< std::string > mvaWeightFiles_
Definition: ElectronPATIdMVAProducer.cc:38