#include <MyAnalyzer/ElectronIdMVABased/src/ElectronIdMVABased.cc>
Public Member Functions | |
ElectronIdMVABased (const edm::ParameterSet &) | |
~ElectronIdMVABased () | |
Private Member Functions | |
virtual bool | filter (edm::Event &, const edm::EventSetup &) |
Private Attributes | |
edm::InputTag | electronTag |
ElectronMVAEstimator * | mvaID_ |
string | mvaWeightFileEleID |
string | path_mvaWeightFileEleID |
double | thresholdBarrel |
double | thresholdEndcap |
double | thresholdIsoBarrel |
double | thresholdIsoEndcap |
edm::InputTag | vertexTag |
Description: [one line class summary]
Implementation: [Notes on implementation]
Definition at line 43 of file ElectronIdMVABased.cc.
ElectronIdMVABased::ElectronIdMVABased | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 76 of file ElectronIdMVABased.cc.
References edm::ParameterSet::getParameter().
{ vertexTag = iConfig.getParameter<edm::InputTag>("vertexTag"); electronTag = iConfig.getParameter<edm::InputTag>("electronTag"); mvaWeightFileEleID = iConfig.getParameter<string>("HZZmvaWeightFile"); thresholdBarrel = iConfig.getParameter<double>("thresholdBarrel"); thresholdEndcap = iConfig.getParameter<double>("thresholdEndcap"); thresholdIsoBarrel = iConfig.getParameter<double>("thresholdIsoDR03Barrel"); thresholdIsoEndcap = iConfig.getParameter<double>("thresholdIsoDR03Endcap"); produces<reco::GsfElectronCollection>(); path_mvaWeightFileEleID = edm::FileInPath ( mvaWeightFileEleID.c_str() ).fullPath(); FILE * fileEleID = fopen(path_mvaWeightFileEleID.c_str(), "r"); if (fileEleID) { fclose(fileEleID); } else { string err = "ElectronIdMVABased: cannot open weight file '"; err += path_mvaWeightFileEleID; err += "'"; throw invalid_argument( err ); } mvaID_ = new ElectronMVAEstimator(path_mvaWeightFileEleID); }
ElectronIdMVABased::~ElectronIdMVABased | ( | ) |
Definition at line 102 of file ElectronIdMVABased.cc.
{ delete mvaID_; // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) }
bool ElectronIdMVABased::filter | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDFilter.
Definition at line 117 of file ElectronIdMVABased.cc.
References edm::Event::getByLabel(), reco::GsfElectron::MvaOutput::mva, electronIdMVABased_cfi::mvaElectrons, edm::Event::put(), and GoodVertex_cfg::vertexCollection.
{ using namespace edm; std::auto_ptr<reco::GsfElectronCollection> mvaElectrons(new reco::GsfElectronCollection); Handle<reco::VertexCollection> vertexCollection; iEvent.getByLabel(vertexTag, vertexCollection); int nVtx = vertexCollection->size(); Handle<reco::GsfElectronCollection> egCollection; iEvent.getByLabel(electronTag,egCollection); const reco::GsfElectronCollection egCandidates = (*egCollection.product()); for ( reco::GsfElectronCollection::const_iterator egIter = egCandidates.begin(); egIter != egCandidates.end(); ++egIter) { double mvaVal = mvaID_->mva( *egIter, nVtx ); double isoDr03 = egIter->dr03TkSumPt() + egIter->dr03EcalRecHitSumEt() + egIter->dr03HcalTowerSumEt(); double eleEta = fabs(egIter->eta()); if (eleEta <= 1.485 && mvaVal > thresholdBarrel && isoDr03 < thresholdIsoBarrel) { mvaElectrons->push_back( *egIter ); reco::GsfElectron::MvaOutput myMvaOutput; myMvaOutput.mva = mvaVal; mvaElectrons->back().setMvaOutput(myMvaOutput); } else if (eleEta > 1.485 && mvaVal > thresholdEndcap && isoDr03 < thresholdIsoEndcap) { mvaElectrons->push_back( *egIter ); reco::GsfElectron::MvaOutput myMvaOutput; myMvaOutput.mva = mvaVal; mvaElectrons->back().setMvaOutput(myMvaOutput); } } iEvent.put(mvaElectrons); return true; }
edm::InputTag ElectronIdMVABased::electronTag [private] |
Definition at line 54 of file ElectronIdMVABased.cc.
ElectronMVAEstimator* ElectronIdMVABased::mvaID_ [private] |
Definition at line 62 of file ElectronIdMVABased.cc.
string ElectronIdMVABased::mvaWeightFileEleID [private] |
Definition at line 55 of file ElectronIdMVABased.cc.
string ElectronIdMVABased::path_mvaWeightFileEleID [private] |
Definition at line 56 of file ElectronIdMVABased.cc.
double ElectronIdMVABased::thresholdBarrel [private] |
Definition at line 57 of file ElectronIdMVABased.cc.
double ElectronIdMVABased::thresholdEndcap [private] |
Definition at line 58 of file ElectronIdMVABased.cc.
double ElectronIdMVABased::thresholdIsoBarrel [private] |
Definition at line 59 of file ElectronIdMVABased.cc.
double ElectronIdMVABased::thresholdIsoEndcap [private] |
Definition at line 60 of file ElectronIdMVABased.cc.
edm::InputTag ElectronIdMVABased::vertexTag [private] |
Definition at line 53 of file ElectronIdMVABased.cc.