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::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ElectronIdMVABased (const edm::ParameterSet &)
 
 ~ElectronIdMVABased ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

Private Attributes

edm::EDGetTokenT
< reco::GsfElectronCollection
electronToken
 
ElectronMVAEstimatormvaID_
 
string mvaWeightFileEleID
 
string path_mvaWeightFileEleID
 
double thresholdBarrel
 
double thresholdEndcap
 
double thresholdIsoBarrel
 
double thresholdIsoEndcap
 
edm::EDGetTokenT
< reco::VertexCollection
vertexToken
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, 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 ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 42 of file ElectronIdMVABased.cc.

Constructor & Destructor Documentation

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

Definition at line 75 of file ElectronIdMVABased.cc.

References edm::ParameterSet::getParameter().

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

Definition at line 101 of file ElectronIdMVABased.cc.

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

Member Function Documentation

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

Implements edm::EDFilter.

Definition at line 116 of file ElectronIdMVABased.cc.

References edm::Event::getByToken(), reco::GsfElectron::MvaOutput::mva, electronIdMVABased_cfi::mvaElectrons, edm::Event::put(), and GoodVertex_cfg::vertexCollection.

116  {
117  using namespace edm;
118 
119  std::auto_ptr<reco::GsfElectronCollection> mvaElectrons(new reco::GsfElectronCollection);
120 
123  int nVtx = vertexCollection->size();
124 
126  iEvent.getByToken(electronToken,egCollection);
127  const reco::GsfElectronCollection egCandidates = (*egCollection.product());
128  for ( reco::GsfElectronCollection::const_iterator egIter = egCandidates.begin(); egIter != egCandidates.end(); ++egIter) {
129  double mvaVal = mvaID_->mva( *egIter, nVtx );
130  double isoDr03 = egIter->dr03TkSumPt() + egIter->dr03EcalRecHitSumEt() + egIter->dr03HcalTowerSumEt();
131  double eleEta = fabs(egIter->eta());
132  if (eleEta <= 1.485 && mvaVal > thresholdBarrel && isoDr03 < thresholdIsoBarrel) {
133  mvaElectrons->push_back( *egIter );
134  reco::GsfElectron::MvaOutput myMvaOutput;
135  myMvaOutput.mva = mvaVal;
136  mvaElectrons->back().setMvaOutput(myMvaOutput);
137  }
138  else if (eleEta > 1.485 && mvaVal > thresholdEndcap && isoDr03 < thresholdIsoEndcap) {
139  mvaElectrons->push_back( *egIter );
140  reco::GsfElectron::MvaOutput myMvaOutput;
141  myMvaOutput.mva = mvaVal;
142  mvaElectrons->back().setMvaOutput(myMvaOutput);
143  }
144 
145 
146  }
147 
148 
149  iEvent.put(mvaElectrons);
150 
151  return true;
152 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
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:116
edm::EDGetTokenT< reco::VertexCollection > vertexToken
edm::EDGetTokenT< reco::GsfElectronCollection > electronToken
double mva(const reco::GsfElectron &myElectron, int nvertices=0)

Member Data Documentation

edm::EDGetTokenT<reco::GsfElectronCollection> ElectronIdMVABased::electronToken
private

Definition at line 53 of file ElectronIdMVABased.cc.

ElectronMVAEstimator* ElectronIdMVABased::mvaID_
private

Definition at line 61 of file ElectronIdMVABased.cc.

string ElectronIdMVABased::mvaWeightFileEleID
private

Definition at line 54 of file ElectronIdMVABased.cc.

string ElectronIdMVABased::path_mvaWeightFileEleID
private

Definition at line 55 of file ElectronIdMVABased.cc.

double ElectronIdMVABased::thresholdBarrel
private

Definition at line 56 of file ElectronIdMVABased.cc.

double ElectronIdMVABased::thresholdEndcap
private

Definition at line 57 of file ElectronIdMVABased.cc.

double ElectronIdMVABased::thresholdIsoBarrel
private

Definition at line 58 of file ElectronIdMVABased.cc.

double ElectronIdMVABased::thresholdIsoEndcap
private

Definition at line 59 of file ElectronIdMVABased.cc.

edm::EDGetTokenT<reco::VertexCollection> ElectronIdMVABased::vertexToken
private

Definition at line 52 of file ElectronIdMVABased.cc.