CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | 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

Public Member Functions

 ElectronIdMVABased (const edm::ParameterSet &)
 
 ~ElectronIdMVABased ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
typedef WorkerT< EDFilterWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDFilter
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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

76  {
77  vertexTag = iConfig.getParameter<edm::InputTag>("vertexTag");
78  electronTag = iConfig.getParameter<edm::InputTag>("electronTag");
79  mvaWeightFileEleID = iConfig.getParameter<string>("HZZmvaWeightFile");
80  thresholdBarrel = iConfig.getParameter<double>("thresholdBarrel");
81  thresholdEndcap = iConfig.getParameter<double>("thresholdEndcap");
82  thresholdIsoBarrel = iConfig.getParameter<double>("thresholdIsoDR03Barrel");
83  thresholdIsoEndcap = iConfig.getParameter<double>("thresholdIsoDR03Endcap");
84 
85  produces<reco::GsfElectronCollection>();
86  path_mvaWeightFileEleID = edm::FileInPath ( mvaWeightFileEleID.c_str() ).fullPath();
87  FILE * fileEleID = fopen(path_mvaWeightFileEleID.c_str(), "r");
88  if (fileEleID) {
89  fclose(fileEleID);
90  }
91  else {
92  string err = "ElectronIdMVABased: cannot open weight file '";
94  err += "'";
95  throw invalid_argument( err );
96  }
97 
98  mvaID_ = new ElectronMVAEstimator(path_mvaWeightFileEleID);
99 }
T getParameter(std::string const &) const
ElectronMVAEstimator * mvaID_
edm::InputTag electronTag
ElectronIdMVABased::~ElectronIdMVABased ( )

Definition at line 102 of file ElectronIdMVABased.cc.

103 {
104 
105  delete mvaID_;
106  // do anything here that needs to be done at desctruction time
107  // (e.g. close files, deallocate resources etc.)
108 
109 }
ElectronMVAEstimator * mvaID_

Member Function Documentation

bool ElectronIdMVABased::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

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.

117  {
118  using namespace edm;
119 
120  std::auto_ptr<reco::GsfElectronCollection> mvaElectrons(new reco::GsfElectronCollection);
121 
124  int nVtx = vertexCollection->size();
125 
127  iEvent.getByLabel(electronTag,egCollection);
128  const reco::GsfElectronCollection egCandidates = (*egCollection.product());
129  for ( reco::GsfElectronCollection::const_iterator egIter = egCandidates.begin(); egIter != egCandidates.end(); ++egIter) {
130  double mvaVal = mvaID_->mva( *egIter, nVtx );
131  double isoDr03 = egIter->dr03TkSumPt() + egIter->dr03EcalRecHitSumEt() + egIter->dr03HcalTowerSumEt();
132  double eleEta = fabs(egIter->eta());
133  if (eleEta <= 1.485 && mvaVal > thresholdBarrel && isoDr03 < thresholdIsoBarrel) {
134  mvaElectrons->push_back( *egIter );
135  reco::GsfElectron::MvaOutput myMvaOutput;
136  myMvaOutput.mva = mvaVal;
137  mvaElectrons->back().setMvaOutput(myMvaOutput);
138  }
139  else if (eleEta > 1.485 && mvaVal > thresholdEndcap && isoDr03 < thresholdIsoEndcap) {
140  mvaElectrons->push_back( *egIter );
141  reco::GsfElectron::MvaOutput myMvaOutput;
142  myMvaOutput.mva = mvaVal;
143  mvaElectrons->back().setMvaOutput(myMvaOutput);
144  }
145 
146 
147  }
148 
149 
150  iEvent.put(mvaElectrons);
151 
152  return true;
153 }
ElectronMVAEstimator * mvaID_
tuple vertexCollection
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
double mva(const reco::GsfElectron &myElectron, int nvertices=0)
edm::InputTag electronTag

Member Data Documentation

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.