CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ElectronPATIdMVAProducer Class Reference
Inheritance diagram for ElectronPATIdMVAProducer:
edm::stream::EDProducer<>

Public Member Functions

 ElectronPATIdMVAProducer (const edm::ParameterSet &)
 
 ~ElectronPATIdMVAProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=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 EDProduceroperator= (const EDProducer &)=delete
 

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::stream::EDProducer<>
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
 

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.

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_.

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 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::string fullPath() const
Definition: FileInPath.cc:161
std::vector< std::string > mvaWeightFiles_
T getUntrackedParameter(std::string const &, T const &) const
void initialize(std::string methodName, std::string weightsfile, EGammaMvaEleEstimator::MVAType type)
edm::EDGetTokenT< pat::ElectronCollection > electronToken_
EGammaMvaEleEstimator * mvaID_
edm::EDGetTokenT< double > eventrhoToken_

◆ ~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 
)
overrideprivate

Definition at line 90 of file ElectronPATIdMVAProducer.cc.

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

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 }
T const * product() const
Definition: Handle.h:70
Double_t mvaValue(const reco::GsfElectron &ele, const reco::Vertex &vertex, const TransientTrackBuilder &transientTrackBuilder, EcalClusterLazyTools const &myEcalCluster, bool printDebug=kFALSE)
int iEvent
Definition: GenABIO.cc:224
std::vector< Electron > ElectronCollection
Definition: Electron.h:36
edm::EDGetTokenT< pat::ElectronCollection > electronToken_
EGammaMvaEleEstimator * mvaID_
edm::EDGetTokenT< double > eventrhoToken_
def move(src, dest)
Definition: eostools.py:511

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().