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

Public Member Functions

 ElectronIdMVAProducer (const edm::ParameterSet &)
 
 ~ElectronIdMVAProducer ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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 &)
 

Private Attributes

double _Rho
 
edm::EDGetTokenT
< reco::GsfElectronCollection
electronToken_
 
edm::EDGetTokenT< double > eventrhoToken_
 
string method_
 
EGammaMvaEleEstimatormvaID_
 
vector< string > mvaWeightFiles_
 
bool NoIP_
 
edm::EDGetTokenT
< EcalRecHitCollection
reducedEBRecHitCollectionToken_
 
edm::EDGetTokenT
< EcalRecHitCollection
reducedEERecHitCollectionToken_
 
bool Trig_
 
bool verbose_
 
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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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::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

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, HLT_25ns14e33_v1_cff::InputTag, EGammaMvaEleEstimator::kNonTrig, EGammaMvaEleEstimator::kTrig, and EGammaMvaEleEstimator::kTrigNoIP.

62  {
63  verbose_ = iConfig.getUntrackedParameter<bool>("verbose", false);
64  vertexToken_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexTag"));
65  electronToken_ = consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("electronTag"));
66  eventrhoToken_ = consumes<double>(edm::InputTag("kt6PFJets", "rho"));
67  reducedEBRecHitCollectionToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEBRecHitCollection"));
68  reducedEERecHitCollectionToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEERecHitCollection"));
69  method_ = iConfig.getParameter<string>("method");
70  std::vector<string> fpMvaWeightFiles = iConfig.getParameter<std::vector<std::string> >("mvaWeightFile");
71  Trig_ = iConfig.getParameter<bool>("Trig");
72  NoIP_ = iConfig.getParameter<bool>("NoIP");
73 
74  produces<edm::ValueMap<float> >("");
75 
77 
79  if(Trig_ && !NoIP_){type_ = EGammaMvaEleEstimator::kTrig;}
80 
82 
84 
85  bool manualCat_ = true;
86 
87  string path_mvaWeightFileEleID;
88  for(unsigned ifile=0 ; ifile < fpMvaWeightFiles.size() ; ++ifile) {
89  path_mvaWeightFileEleID = edm::FileInPath ( fpMvaWeightFiles[ifile].c_str() ).fullPath();
90  mvaWeightFiles_.push_back(path_mvaWeightFileEleID);
91  }
92 
93  mvaID_->initialize(method_, type_, manualCat_, mvaWeightFiles_);
94 
95 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
vector< string > mvaWeightFiles_
edm::EDGetTokenT< double > eventrhoToken_
edm::EDGetTokenT< EcalRecHitCollection > reducedEBRecHitCollectionToken_
edm::EDGetTokenT< EcalRecHitCollection > reducedEERecHitCollectionToken_
void initialize(std::string methodName, std::string weightsfile, EGammaMvaEleEstimator::MVAType type)
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
std::string fullPath() const
Definition: FileInPath.cc:165
EGammaMvaEleEstimator * mvaID_
ElectronIdMVAProducer::~ElectronIdMVAProducer ( )

Definition at line 98 of file ElectronIdMVAProducer.cc.

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

Member Function Documentation

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

Implements edm::EDFilter.

Definition at line 112 of file ElectronIdMVAProducer.cc.

References alignCSCRings::e, edm::helper::Filler< Map >::fill(), edm::EventSetup::get(), edm::Event::getByToken(), edm::helper::Filler< Map >::insert(), dbtoconf::out, AlCaHLTBitMon_ParallelJobs::p, edm::Event::put(), MetAnalyzer::pv(), 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().

112  {
113  using namespace edm;
114 
115  std::auto_ptr<edm::ValueMap<float> > out(new edm::ValueMap<float>() );
116 
119 
120  Vertex dummy;
121  const Vertex *pv = &dummy;
122  if ( vertexCollection->size() != 0) {
123  pv = &*vertexCollection->begin();
124  } else { // create a dummy PV
126  e(0, 0) = 0.0015 * 0.0015;
127  e(1, 1) = 0.0015 * 0.0015;
128  e(2, 2) = 15. * 15.;
129  Vertex::Point p(0, 0, 0);
130  dummy = Vertex(p, e, 0, 0, 0);
131  }
132 
134 
136  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
137  TransientTrackBuilder thebuilder = *(builder.product());
138 
140  iEvent.getByToken(electronToken_,egCollection);
141  const reco::GsfElectronCollection egCandidates = (*egCollection.product());
142 
143  _Rho=0;
144  edm::Handle<double> rhoPtr;
145  iEvent.getByToken(eventrhoToken_,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 }
edm::EDGetTokenT< double > eventrhoToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
edm::EDGetTokenT< EcalRecHitCollection > reducedEBRecHitCollectionToken_
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
edm::EDGetTokenT< EcalRecHitCollection > reducedEERecHitCollectionToken_
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:120
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
Double_t mvaValue(const reco::GsfElectron &ele, const reco::Vertex &vertex, const TransientTrackBuilder &transientTrackBuilder, EcalClusterLazyTools myEcalCluster, bool printDebug=kFALSE)
tuple out
Definition: dbtoconf.py:99
edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
const T & get() const
Definition: EventSetup.h:56
EGammaMvaEleEstimator * mvaID_

Member Data Documentation

double ElectronIdMVAProducer::_Rho
private

Definition at line 42 of file ElectronIdMVAProducer.cc.

edm::EDGetTokenT<reco::GsfElectronCollection> ElectronIdMVAProducer::electronToken_
private

Definition at line 37 of file ElectronIdMVAProducer.cc.

edm::EDGetTokenT<double> ElectronIdMVAProducer::eventrhoToken_
private

Definition at line 38 of file ElectronIdMVAProducer.cc.

string ElectronIdMVAProducer::method_
private

Definition at line 43 of file ElectronIdMVAProducer.cc.

EGammaMvaEleEstimator* ElectronIdMVAProducer::mvaID_
private

Definition at line 48 of file ElectronIdMVAProducer.cc.

vector<string> ElectronIdMVAProducer::mvaWeightFiles_
private

Definition at line 44 of file ElectronIdMVAProducer.cc.

bool ElectronIdMVAProducer::NoIP_
private

Definition at line 46 of file ElectronIdMVAProducer.cc.

edm::EDGetTokenT<EcalRecHitCollection> ElectronIdMVAProducer::reducedEBRecHitCollectionToken_
private

Definition at line 39 of file ElectronIdMVAProducer.cc.

edm::EDGetTokenT<EcalRecHitCollection> ElectronIdMVAProducer::reducedEERecHitCollectionToken_
private

Definition at line 40 of file ElectronIdMVAProducer.cc.

bool ElectronIdMVAProducer::Trig_
private

Definition at line 45 of file ElectronIdMVAProducer.cc.

bool ElectronIdMVAProducer::verbose_
private

Definition at line 35 of file ElectronIdMVAProducer.cc.

edm::EDGetTokenT<reco::VertexCollection> ElectronIdMVAProducer::vertexToken_
private

Definition at line 36 of file ElectronIdMVAProducer.cc.