CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ElectronIdMVABased Class Reference

#include <MyAnalyzer/ElectronIdMVABased/src/ElectronIdMVABased.cc>

Inheritance diagram for ElectronIdMVABased:
edm::EDFilter edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 ElectronIdMVABased (const edm::ParameterSet &)
 ~ElectronIdMVABased ()

Private Member Functions

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

Private Attributes

edm::InputTag electronTag
ElectronMVAEstimatormvaID_
string mvaWeightFileEleID
string path_mvaWeightFileEleID
double thresholdBarrel
double thresholdEndcap
double thresholdIsoBarrel
double thresholdIsoEndcap
edm::InputTag vertexTag

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 43 of file ElectronIdMVABased.cc.


Constructor & Destructor Documentation

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

}

Member Function Documentation

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;
}

Member Data Documentation

Definition at line 54 of file ElectronIdMVABased.cc.

Definition at line 62 of file ElectronIdMVABased.cc.

Definition at line 55 of file ElectronIdMVABased.cc.

Definition at line 56 of file ElectronIdMVABased.cc.

Definition at line 57 of file ElectronIdMVABased.cc.

Definition at line 58 of file ElectronIdMVABased.cc.

Definition at line 59 of file ElectronIdMVABased.cc.

Definition at line 60 of file ElectronIdMVABased.cc.

Definition at line 53 of file ElectronIdMVABased.cc.