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
ElectronIdMVAProducer Class Reference
Inheritance diagram for ElectronIdMVAProducer:
edm::EDFilter edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 ElectronIdMVAProducer (const edm::ParameterSet &)
 
 ~ElectronIdMVAProducer ()
 
- 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

double _Rho
 
edm::InputTag electronTag_
 
string method_
 
EGammaMvaEleEstimatormvaID_
 
vector< string > mvaWeightFiles_
 
bool NoIP_
 
edm::InputTag reducedEBRecHitCollection_
 
edm::InputTag reducedEERecHitCollection_
 
bool Trig_
 
bool verbose_
 
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

Definition at line 26 of file ElectronIdMVAProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 62 of file ElectronIdMVAProducer.cc.

References edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), compare_using_db::ifile, EGammaMvaEleEstimator::kNonTrig, EGammaMvaEleEstimator::kTrig, and EGammaMvaEleEstimator::kTrigNoIP.

62  {
63  verbose_ = iConfig.getUntrackedParameter<bool>("verbose", false);
64  vertexTag_ = iConfig.getParameter<edm::InputTag>("vertexTag");
65  electronTag_ = iConfig.getParameter<edm::InputTag>("electronTag");
66  reducedEBRecHitCollection_ = iConfig.getParameter<edm::InputTag>("reducedEBRecHitCollection");
67  reducedEERecHitCollection_ = iConfig.getParameter<edm::InputTag>("reducedEERecHitCollection");
68  method_ = iConfig.getParameter<string>("method");
69  std::vector<string> fpMvaWeightFiles = iConfig.getParameter<std::vector<std::string> >("mvaWeightFile");
70  Trig_ = iConfig.getParameter<bool>("Trig");
71  NoIP_ = iConfig.getParameter<bool>("NoIP");
72 
73  produces<edm::ValueMap<float> >("");
74 
76 
78  if(Trig_ && !NoIP_){type_ = EGammaMvaEleEstimator::kTrig;}
79 
80  if(Trig_ && NoIP_){type_ = EGammaMvaEleEstimator::kTrigNoIP;}
81 
82  if(!Trig_){type_ = EGammaMvaEleEstimator::kNonTrig;}
83 
84  bool manualCat_ = true;
85 
86  string path_mvaWeightFileEleID;
87  for(unsigned ifile=0 ; ifile < fpMvaWeightFiles.size() ; ++ifile) {
88  path_mvaWeightFileEleID = edm::FileInPath ( fpMvaWeightFiles[ifile].c_str() ).fullPath();
89  mvaWeightFiles_.push_back(path_mvaWeightFileEleID);
90  }
91 
92  mvaID_->initialize(method_, type_, manualCat_, mvaWeightFiles_);
93 
94 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
vector< string > mvaWeightFiles_
edm::InputTag reducedEBRecHitCollection_
edm::InputTag reducedEERecHitCollection_
std::string fullPath() const
Definition: FileInPath.cc:171
EGammaMvaEleEstimator * mvaID_
ElectronIdMVAProducer::~ElectronIdMVAProducer ( )

Definition at line 97 of file ElectronIdMVAProducer.cc.

98 {
99 
100  // do anything here that needs to be done at desctruction time
101  // (e.g. close files, deallocate resources etc.)
102 
103 }

Member Function Documentation

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

Implements edm::EDFilter.

Definition at line 111 of file ElectronIdMVAProducer.cc.

References alignCSCRings::e, edm::helper::Filler< Map >::fill(), edm::EventSetup::get(), edm::Event::getByLabel(), edm::helper::Filler< Map >::insert(), dbtoconf::out, AlCaHLTBitMon_ParallelJobs::p, edm::Event::put(), makeHLTPrescaleTable::values, and GoodVertex_cfg::vertexCollection.

Referenced by Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filter(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setDataAccessor(), and Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView().

111  {
112  using namespace edm;
113 
114  std::auto_ptr<edm::ValueMap<float> > out(new edm::ValueMap<float>() );
115 
118 
119  Vertex dummy;
120  const Vertex *pv = &dummy;
121  if ( vertexCollection->size() != 0) {
122  pv = &*vertexCollection->begin();
123  } else { // create a dummy PV
125  e(0, 0) = 0.0015 * 0.0015;
126  e(1, 1) = 0.0015 * 0.0015;
127  e(2, 2) = 15. * 15.;
128  Vertex::Point p(0, 0, 0);
129  dummy = Vertex(p, e, 0, 0, 0);
130  }
131 
133 
135  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
136  TransientTrackBuilder thebuilder = *(builder.product());
137 
139  iEvent.getByLabel(electronTag_,egCollection);
140  const reco::GsfElectronCollection egCandidates = (*egCollection.product());
141 
142  _Rho=0;
143  edm::Handle<double> rhoPtr;
144  const edm::InputTag eventrho("kt6PFJets", "rho");
145  iEvent.getByLabel(eventrho,rhoPtr);
146  _Rho=*rhoPtr;
147 
148  std::vector<float> values;
149  values.reserve(egCollection->size());
150 
151  for ( reco::GsfElectronCollection::const_iterator egIter = egCandidates.begin(); egIter != egCandidates.end(); ++egIter) {
152 
153  double mvaVal = -999999;
154  if(!NoIP_){
155  mvaVal = mvaID_->mvaValue( *egIter, *pv,thebuilder,lazyTools, verbose_);
156  }
157  if(NoIP_){
158  mvaVal = mvaID_->mvaValue( *egIter, *pv, _Rho,/*thebuilder,*/lazyTools, verbose_);
159  }
160 
161  values.push_back( mvaVal );
162  }
163 
165  filler.insert(egCollection, values.begin(), values.end() );
166  filler.fill();
167 
168  iEvent.put(out);
169 
170  return true;
171 }
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
tuple vertexCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
edm::InputTag reducedEBRecHitCollection_
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
Double_t mvaValue(const reco::GsfElectron &ele, const reco::Vertex &vertex, const TransientTrackBuilder &transientTrackBuilder, EcalClusterLazyTools myEcalCluster, bool printDebug=kFALSE)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
tuple out
Definition: dbtoconf.py:99
const T & get() const
Definition: EventSetup.h:55
edm::InputTag reducedEERecHitCollection_
EGammaMvaEleEstimator * mvaID_

Member Data Documentation

double ElectronIdMVAProducer::_Rho
private

Definition at line 41 of file ElectronIdMVAProducer.cc.

edm::InputTag ElectronIdMVAProducer::electronTag_
private

Definition at line 37 of file ElectronIdMVAProducer.cc.

string ElectronIdMVAProducer::method_
private

Definition at line 42 of file ElectronIdMVAProducer.cc.

EGammaMvaEleEstimator* ElectronIdMVAProducer::mvaID_
private

Definition at line 47 of file ElectronIdMVAProducer.cc.

vector<string> ElectronIdMVAProducer::mvaWeightFiles_
private

Definition at line 43 of file ElectronIdMVAProducer.cc.

bool ElectronIdMVAProducer::NoIP_
private

Definition at line 45 of file ElectronIdMVAProducer.cc.

edm::InputTag ElectronIdMVAProducer::reducedEBRecHitCollection_
private

Definition at line 38 of file ElectronIdMVAProducer.cc.

edm::InputTag ElectronIdMVAProducer::reducedEERecHitCollection_
private

Definition at line 39 of file ElectronIdMVAProducer.cc.

bool ElectronIdMVAProducer::Trig_
private

Definition at line 44 of file ElectronIdMVAProducer.cc.

bool ElectronIdMVAProducer::verbose_
private

Definition at line 35 of file ElectronIdMVAProducer.cc.

edm::InputTag ElectronIdMVAProducer::vertexTag_
private

Definition at line 36 of file ElectronIdMVAProducer.cc.