CMS 3D CMS Logo

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

Public Member Functions

 ElectronIdMVAProducer (const edm::ParameterSet &)
 
 ~ElectronIdMVAProducer () override
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () 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)
 

Private Member Functions

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

Private Attributes

double _Rho
 
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_
 
bool verbose_
 
edm::EDGetTokenT< reco::VertexCollectionvertexToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter 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::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
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>
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

Definition at line 24 of file ElectronIdMVAProducer.cc.

Constructor & Destructor Documentation

◆ ElectronIdMVAProducer()

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

Definition at line 60 of file ElectronIdMVAProducer.cc.

60  {
61  verbose_ = iConfig.getUntrackedParameter<bool>("verbose", false);
62  vertexToken_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexTag"));
63  electronToken_ = consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("electronTag"));
64  eventrhoToken_ = consumes<double>(edm::InputTag("kt6PFJets", "rho"));
66  consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEBRecHitCollection"));
68  consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEERecHitCollection"));
69  method_ = iConfig.getParameter<std::string>("method");
70  std::vector<std::string> fpMvaWeightFiles = iConfig.getParameter<std::vector<std::string> >("mvaWeightFile");
71  Trig_ = iConfig.getParameter<bool>("Trig");
72  NoIP_ = iConfig.getParameter<bool>("NoIP");
73 
74  produces<edm::ValueMap<float> >("");
75 
77 
79  if (Trig_ && !NoIP_) {
81  }
82 
83  if (Trig_ && NoIP_) {
85  }
86 
87  if (!Trig_) {
89  }
90 
91  bool manualCat_ = true;
92 
93  std::string path_mvaWeightFileEleID;
94  for (unsigned ifile = 0; ifile < fpMvaWeightFiles.size(); ++ifile) {
95  path_mvaWeightFileEleID = edm::FileInPath(fpMvaWeightFiles[ifile].c_str()).fullPath();
96  mvaWeightFiles_.push_back(path_mvaWeightFileEleID);
97  }
98 
99  mvaID_->initialize(method_, type_, manualCat_, mvaWeightFiles_);
100 }

References electronToken_, eventrhoToken_, edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), compare_using_db::ifile, EGammaMvaEleEstimator::initialize(), EGammaMvaEleEstimator::kNonTrig, EGammaMvaEleEstimator::kTrig, EGammaMvaEleEstimator::kTrigNoIP, method_, mvaID_, mvaWeightFiles_, NoIP_, reducedEBRecHitCollectionToken_, reducedEERecHitCollectionToken_, AlCaHLTBitMon_QueryRunRegistry::string, Trig_, verbose_, and vertexToken_.

◆ ~ElectronIdMVAProducer()

ElectronIdMVAProducer::~ElectronIdMVAProducer ( )
override

Definition at line 102 of file ElectronIdMVAProducer.cc.

102  {
103  // do anything here that needs to be done at desctruction time
104  // (e.g. close files, deallocate resources etc.)
105 }

Member Function Documentation

◆ filter()

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

Implements edm::EDFilter.

Definition at line 112 of file ElectronIdMVAProducer.cc.

112  {
113  std::unique_ptr<edm::ValueMap<float> > out(new edm::ValueMap<float>());
114 
116  iEvent.getByToken(vertexToken_, vertexCollection);
117 
119  const reco::Vertex* pv = &dummy;
120  if (!vertexCollection->empty()) {
121  pv = &*vertexCollection->begin();
122  } else { // create a dummy PV
124  e(0, 0) = 0.0015 * 0.0015;
125  e(1, 1) = 0.0015 * 0.0015;
126  e(2, 2) = 15. * 15.;
127  reco::Vertex::Point p(0, 0, 0);
128  dummy = reco::Vertex(p, e, 0, 0, 0);
129  }
130 
132 
134  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
135  TransientTrackBuilder thebuilder = *(builder.product());
136 
138  iEvent.getByToken(electronToken_, egCollection);
139  const reco::GsfElectronCollection egCandidates = (*egCollection.product());
140 
141  _Rho = 0;
142  edm::Handle<double> rhoPtr;
143  iEvent.getByToken(eventrhoToken_, rhoPtr);
144  _Rho = *rhoPtr;
145 
146  std::vector<float> values;
147  values.reserve(egCollection->size());
148 
149  for (reco::GsfElectronCollection::const_iterator egIter = egCandidates.begin(); egIter != egCandidates.end();
150  ++egIter) {
151  double mvaVal = -999999;
152  if (!NoIP_) {
153  mvaVal = mvaID_->mvaValue(*egIter, *pv, thebuilder, lazyTools, verbose_);
154  }
155  if (NoIP_) {
156  mvaVal = mvaID_->mvaValue(*egIter, *pv, _Rho, /*thebuilder,*/ lazyTools, verbose_);
157  }
158 
159  values.push_back(mvaVal);
160  }
161 
163  filler.insert(egCollection, values.begin(), values.end());
164  filler.fill();
165 
166  iEvent.put(std::move(out));
167 
168  return true;
169 }

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

Member Data Documentation

◆ _Rho

double ElectronIdMVAProducer::_Rho
private

Definition at line 40 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 ElectronIdMVAProducer(), and filter().

◆ eventrhoToken_

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

Definition at line 36 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer(), and filter().

◆ method_

std::string ElectronIdMVAProducer::method_
private

Definition at line 41 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer().

◆ mvaID_

EGammaMvaEleEstimator* ElectronIdMVAProducer::mvaID_
private

Definition at line 46 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer(), and filter().

◆ mvaWeightFiles_

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

Definition at line 42 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer().

◆ NoIP_

bool ElectronIdMVAProducer::NoIP_
private

Definition at line 44 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer(), and filter().

◆ reducedEBRecHitCollectionToken_

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

Definition at line 37 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer(), and filter().

◆ reducedEERecHitCollectionToken_

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

Definition at line 38 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer(), and filter().

◆ Trig_

bool ElectronIdMVAProducer::Trig_
private

Definition at line 43 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer().

◆ verbose_

bool ElectronIdMVAProducer::verbose_
private

Definition at line 33 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer(), and filter().

◆ vertexToken_

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

Definition at line 34 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer(), and filter().

EGammaMvaEleEstimator
Definition: EGammaMvaEleEstimator.h:38
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EGammaMvaEleEstimator::mvaValue
Double_t mvaValue(const reco::GsfElectron &ele, const reco::Vertex &vertex, const TransientTrackBuilder &transientTrackBuilder, EcalClusterLazyTools myEcalCluster, bool printDebug=kFALSE)
Definition: EGammaMvaEleEstimator.cc:954
edm::Handle::product
T const * product() const
Definition: Handle.h:70
reco::Vertex::Error
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
EGammaMvaEleEstimator::kTrig
Definition: EGammaMvaEleEstimator.h:44
EGammaMvaEleEstimator::kTrigNoIP
Definition: EGammaMvaEleEstimator.h:45
EGammaMvaEleEstimator::initialize
void initialize(std::string methodName, std::string weightsfile, EGammaMvaEleEstimator::MVAType type)
Definition: EGammaMvaEleEstimator.cc:42
ElectronIdMVAProducer::NoIP_
bool NoIP_
Definition: ElectronIdMVAProducer.cc:44
ElectronIdMVAProducer::Trig_
bool Trig_
Definition: ElectronIdMVAProducer.cc:43
reco::GsfElectronCollection
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
Definition: GsfElectronFwd.h:14
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle< reco::VertexCollection >
EGammaMvaEleEstimator::MVAType
MVAType
Definition: EGammaMvaEleEstimator.h:43
ElectronIdMVAProducer::method_
std::string method_
Definition: ElectronIdMVAProducer.cc:41
ElectronIdMVAProducer::reducedEERecHitCollectionToken_
edm::EDGetTokenT< EcalRecHitCollection > reducedEERecHitCollectionToken_
Definition: ElectronIdMVAProducer.cc:38
edm::FileInPath
Definition: FileInPath.h:64
ElectronIdMVAProducer::eventrhoToken_
edm::EDGetTokenT< double > eventrhoToken_
Definition: ElectronIdMVAProducer.cc:36
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
ElectronIdMVAProducer::verbose_
bool verbose_
Definition: ElectronIdMVAProducer.cc:33
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
compare_using_db.ifile
ifile
Definition: compare_using_db.py:251
TransientTrackRecord
Definition: TransientTrackRecord.h:11
edm::ESHandle< TransientTrackBuilder >
EcalClusterLazyTools
ElectronIdMVAProducer::_Rho
double _Rho
Definition: ElectronIdMVAProducer.cc:40
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
iEvent
int iEvent
Definition: GenABIO.cc:224
TransientTrackBuilder
Definition: TransientTrackBuilder.h:16
get
#define get
EGammaMvaEleEstimator::kNonTrig
Definition: EGammaMvaEleEstimator.h:46
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
ElectronIdMVAProducer::reducedEBRecHitCollectionToken_
edm::EDGetTokenT< EcalRecHitCollection > reducedEBRecHitCollectionToken_
Definition: ElectronIdMVAProducer.cc:37
reco::Vertex::Point
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
eostools.move
def move(src, dest)
Definition: eostools.py:511
HltBtagValidation_cff.Vertex
Vertex
Definition: HltBtagValidation_cff.py:32
ElectronIdMVAProducer::mvaID_
EGammaMvaEleEstimator * mvaID_
Definition: ElectronIdMVAProducer.cc:46
spclusmultinvestigator_cfi.vertexCollection
vertexCollection
Definition: spclusmultinvestigator_cfi.py:4
edm::ValueMap< float >
ElectronIdMVAProducer::electronToken_
edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
Definition: ElectronIdMVAProducer.cc:35
ElectronIdMVAProducer::vertexToken_
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
Definition: ElectronIdMVAProducer.cc:34
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
edm::helper::Filler
Definition: ValueMap.h:22
dummy
Definition: DummySelector.h:38
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:163
ElectronIdMVAProducer::mvaWeightFiles_
std::vector< std::string > mvaWeightFiles_
Definition: ElectronIdMVAProducer.cc:42
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37