CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ElectronIdMVAProducer Class Reference
Inheritance diagram for ElectronIdMVAProducer:
edm::stream::EDFilter<> edm::stream::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ElectronIdMVAProducer (const edm::ParameterSet &)
 
 ~ElectronIdMVAProducer () override
 
- Public Member Functions inherited from edm::stream::EDFilter<>
 EDFilter ()=default
 
 EDFilter (const EDFilter &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDFilteroperator= (const EDFilter &)=delete
 
- Public Member Functions inherited from edm::stream::EDFilterBase
 EDFilterBase ()
 
 EDFilterBase (const EDFilterBase &)=delete
 
ModuleDescription const & moduleDescription () const
 
const EDFilterBaseoperator= (const EDFilterBase &)=delete
 
 ~EDFilterBase () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

bool filter (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

double _Rho
 
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
 
edm::EDGetTokenT< reco::GsfElectronCollectionelectronToken_
 
edm::EDGetTokenT< double > eventrhoToken_
 
std::string method_
 
EGammaMvaEleEstimatormvaID_
 
std::vector< std::string > mvaWeightFiles_
 
bool NoIP_
 
edm::EDGetTokenT< EcalRecHitCollectionreducedEBRecHitCollectionToken_
 
edm::EDGetTokenT< EcalRecHitCollectionreducedEERecHitCollectionToken_
 
bool Trig_
 
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecordttrackbuilderToken_
 
bool verbose_
 
edm::EDGetTokenT< reco::VertexCollectionvertexToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDFilter<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Public Types inherited from edm::stream::EDFilterBase
typedef EDFilterAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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::stream::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 24 of file ElectronIdMVAProducer.cc.

Constructor & Destructor Documentation

◆ ElectronIdMVAProducer()

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

Definition at line 62 of file ElectronIdMVAProducer.cc.

References edm::EDConsumerBase::consumesCollector().

64  verbose_ = iConfig.getUntrackedParameter<bool>("verbose", false);
65  vertexToken_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexTag"));
66  electronToken_ = consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("electronTag"));
67  eventrhoToken_ = consumes<double>(edm::InputTag("kt6PFJets", "rho"));
69  consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEBRecHitCollection"));
71  consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEERecHitCollection"));
72  method_ = iConfig.getParameter<std::string>("method");
73  std::vector<std::string> fpMvaWeightFiles = iConfig.getParameter<std::vector<std::string> >("mvaWeightFile");
74  Trig_ = iConfig.getParameter<bool>("Trig");
75  NoIP_ = iConfig.getParameter<bool>("NoIP");
76 
77  ttrackbuilderToken_ = esConsumes(edm::ESInputTag("", "TransientTrackBuilder"));
78 
79  produces<edm::ValueMap<float> >("");
80 
82 
84  if (Trig_ && !NoIP_) {
86  }
87 
88  if (Trig_ && NoIP_) {
90  }
91 
92  if (!Trig_) {
94  }
95 
96  bool manualCat_ = true;
97 
98  std::string path_mvaWeightFileEleID;
99  for (unsigned ifile = 0; ifile < fpMvaWeightFiles.size(); ++ifile) {
100  path_mvaWeightFileEleID = edm::FileInPath(fpMvaWeightFiles[ifile].c_str()).fullPath();
101  mvaWeightFiles_.push_back(path_mvaWeightFileEleID);
102  }
103 
104  mvaID_->initialize(method_, type_, manualCat_, mvaWeightFiles_);
105 }
edm::EDGetTokenT< double > eventrhoToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::string fullPath() const
Definition: FileInPath.cc:161
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > ttrackbuilderToken_
edm::EDGetTokenT< EcalRecHitCollection > reducedEBRecHitCollectionToken_
edm::EDGetTokenT< EcalRecHitCollection > reducedEERecHitCollectionToken_
T getUntrackedParameter(std::string const &, T const &) const
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void initialize(std::string methodName, std::string weightsfile, EGammaMvaEleEstimator::MVAType type)
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
std::vector< std::string > mvaWeightFiles_
edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
EGammaMvaEleEstimator * mvaID_

◆ ~ElectronIdMVAProducer()

ElectronIdMVAProducer::~ElectronIdMVAProducer ( )
override

Definition at line 107 of file ElectronIdMVAProducer.cc.

107  {
108  // do anything here that needs to be done at desctruction time
109  // (e.g. close files, deallocate resources etc.)
110 }

Member Function Documentation

◆ filter()

bool ElectronIdMVAProducer::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::stream::EDFilterBase.

Definition at line 117 of file ElectronIdMVAProducer.cc.

References _Rho, MillePedeFileConverter_cfg::e, ecalClusterToolsESGetTokens_, electronToken_, eventrhoToken_, trigObjTnPSource_cfi::filler, EcalClusterLazyToolsBase::ESGetTokens::get(), edm::EventSetup::getData(), iEvent, eostools::move(), mvaID_, EGammaMvaEleEstimator::mvaValue(), NoIP_, MillePedeFileConverter_cfg::out, AlCaHLTBitMon_ParallelJobs::p, edm::Handle< T >::product(), reducedEBRecHitCollectionToken_, reducedEERecHitCollectionToken_, ttrackbuilderToken_, contentValuesCheck::values, verbose_, HltBtagValidation_cff::Vertex, spclusmultinvestigator_cfi::vertexCollection, and vertexToken_.

117  {
118  std::unique_ptr<edm::ValueMap<float> > out(new edm::ValueMap<float>());
119 
121  iEvent.getByToken(vertexToken_, vertexCollection);
122 
124  const reco::Vertex* pv = &dummy;
125  if (!vertexCollection->empty()) {
126  pv = &*vertexCollection->begin();
127  } else { // create a dummy PV
129  e(0, 0) = 0.0015 * 0.0015;
130  e(1, 1) = 0.0015 * 0.0015;
131  e(2, 2) = 15. * 15.;
132  reco::Vertex::Point p(0, 0, 0);
133  dummy = reco::Vertex(p, e, 0, 0, 0);
134  }
135 
136  EcalClusterLazyTools lazyTools(iEvent,
140  auto const& thebuilder = iSetup.getData(ttrackbuilderToken_);
141 
143  iEvent.getByToken(electronToken_, egCollection);
144  const reco::GsfElectronCollection egCandidates = (*egCollection.product());
145 
146  _Rho = 0;
147  edm::Handle<double> rhoPtr;
148  iEvent.getByToken(eventrhoToken_, rhoPtr);
149  _Rho = *rhoPtr;
150 
151  std::vector<float> values;
152  values.reserve(egCollection->size());
153 
154  for (reco::GsfElectronCollection::const_iterator egIter = egCandidates.begin(); egIter != egCandidates.end();
155  ++egIter) {
156  double mvaVal = -999999;
157  if (!NoIP_) {
158  mvaVal = mvaID_->mvaValue(*egIter, *pv, thebuilder, lazyTools, verbose_);
159  }
160  if (NoIP_) {
161  mvaVal = mvaID_->mvaValue(*egIter, *pv, _Rho, /*thebuilder,*/ lazyTools, verbose_);
162  }
163 
164  values.push_back(mvaVal);
165  }
166 
168  filler.insert(egCollection, values.begin(), values.end());
169  filler.fill();
170 
171  iEvent.put(std::move(out));
172 
173  return true;
174 }
edm::EDGetTokenT< double > eventrhoToken_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > ttrackbuilderToken_
edm::EDGetTokenT< EcalRecHitCollection > reducedEBRecHitCollectionToken_
T const * product() const
Definition: Handle.h:70
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
Double_t mvaValue(const reco::GsfElectron &ele, const reco::Vertex &vertex, const TransientTrackBuilder &transientTrackBuilder, EcalClusterLazyTools const &myEcalCluster, bool printDebug=kFALSE)
edm::EDGetTokenT< EcalRecHitCollection > reducedEERecHitCollectionToken_
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
ESData get(edm::EventSetup const &eventSetup) const
int iEvent
Definition: GenABIO.cc:224
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
def move(src, dest)
Definition: eostools.py:511
EGammaMvaEleEstimator * mvaID_

Member Data Documentation

◆ _Rho

double ElectronIdMVAProducer::_Rho
private

Definition at line 42 of file ElectronIdMVAProducer.cc.

Referenced by filter().

◆ ecalClusterToolsESGetTokens_

const EcalClusterLazyTools::ESGetTokens ElectronIdMVAProducer::ecalClusterToolsESGetTokens_
private

Definition at line 39 of file ElectronIdMVAProducer.cc.

Referenced by filter().

◆ electronToken_

edm::EDGetTokenT<reco::GsfElectronCollection> ElectronIdMVAProducer::electronToken_
private

Definition at line 35 of file ElectronIdMVAProducer.cc.

Referenced by filter().

◆ eventrhoToken_

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

Definition at line 36 of file ElectronIdMVAProducer.cc.

Referenced by filter().

◆ method_

std::string ElectronIdMVAProducer::method_
private

Definition at line 43 of file ElectronIdMVAProducer.cc.

◆ mvaID_

EGammaMvaEleEstimator* ElectronIdMVAProducer::mvaID_
private

Definition at line 48 of file ElectronIdMVAProducer.cc.

Referenced by filter().

◆ mvaWeightFiles_

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

Definition at line 44 of file ElectronIdMVAProducer.cc.

◆ NoIP_

bool ElectronIdMVAProducer::NoIP_
private

Definition at line 46 of file ElectronIdMVAProducer.cc.

Referenced by filter().

◆ reducedEBRecHitCollectionToken_

edm::EDGetTokenT<EcalRecHitCollection> ElectronIdMVAProducer::reducedEBRecHitCollectionToken_
private

Definition at line 37 of file ElectronIdMVAProducer.cc.

Referenced by filter().

◆ reducedEERecHitCollectionToken_

edm::EDGetTokenT<EcalRecHitCollection> ElectronIdMVAProducer::reducedEERecHitCollectionToken_
private

Definition at line 38 of file ElectronIdMVAProducer.cc.

Referenced by filter().

◆ Trig_

bool ElectronIdMVAProducer::Trig_
private

Definition at line 45 of file ElectronIdMVAProducer.cc.

◆ ttrackbuilderToken_

edm::ESGetToken<TransientTrackBuilder, TransientTrackRecord> ElectronIdMVAProducer::ttrackbuilderToken_
private

Definition at line 40 of file ElectronIdMVAProducer.cc.

Referenced by filter().

◆ verbose_

bool ElectronIdMVAProducer::verbose_
private

Definition at line 33 of file ElectronIdMVAProducer.cc.

Referenced by filter().

◆ vertexToken_

edm::EDGetTokenT<reco::VertexCollection> ElectronIdMVAProducer::vertexToken_
private

Definition at line 34 of file ElectronIdMVAProducer.cc.

Referenced by filter().