CMS 3D CMS Logo

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)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

double _Rho
 
edm::EDGetTokenT< reco::GsfElectronCollectionelectronToken_
 
edm::EDGetTokenT< double > eventrhoToken_
 
std::string method_
 
EGammaMvaEleEstimatormvaID_
 
std::vector< std::string > mvaWeightFiles_
 
bool NoIP_
 
edm::EDGetTokenT< EcalRecHitCollectionreducedEBRecHitCollectionToken_
 
edm::EDGetTokenT< EcalRecHitCollectionreducedEERecHitCollectionToken_
 
bool Trig_
 
bool verbose_
 
edm::EDGetTokenT< reco::VertexCollectionvertexToken_
 

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 24 of file ElectronIdMVAProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 60 of file ElectronIdMVAProducer.cc.

References electronToken_, eventrhoToken_, edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), compare_using_db::ifile, EGammaMvaEleEstimator::kNonTrig, EGammaMvaEleEstimator::kTrig, EGammaMvaEleEstimator::kTrigNoIP, method_, mvaID_, mvaWeightFiles_, NoIP_, reducedEBRecHitCollectionToken_, reducedEERecHitCollectionToken_, AlCaHLTBitMon_QueryRunRegistry::string, Trig_, verbose_, and vertexToken_.

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

Definition at line 96 of file ElectronIdMVAProducer.cc.

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

Member Function Documentation

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

Definition at line 110 of file ElectronIdMVAProducer.cc.

References _Rho, DEFINE_FWK_MODULE, MillePedeFileConverter_cfg::e, electronToken_, eventrhoToken_, edm::helper::Filler< Map >::fill(), objects.autophobj::filler, edm::EventSetup::get(), edm::Event::getByToken(), edm::helper::Filler< Map >::insert(), eostools::move(), mvaID_, EGammaMvaEleEstimator::mvaValue(), NoIP_, MillePedeFileConverter_cfg::out, AlCaHLTBitMon_ParallelJobs::p, edm::Handle< T >::product(), edm::ESHandle< T >::product(), edm::Event::put(), MetAnalyzer::pv(), reducedEBRecHitCollectionToken_, reducedEERecHitCollectionToken_, MuonErrorMatrixValues_cff::values, verbose_, particleFlowSuperClusterECAL_cfi::vertexCollection, and vertexToken_.

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

110  {
111 
112  std::unique_ptr<edm::ValueMap<float> > out(new edm::ValueMap<float>() );
113 
115  iEvent.getByToken(vertexToken_, vertexCollection);
116 
118  const reco::Vertex *pv = &dummy;
119  if ( vertexCollection->size() != 0) {
120  pv = &*vertexCollection->begin();
121  } else { // create a dummy PV
123  e(0, 0) = 0.0015 * 0.0015;
124  e(1, 1) = 0.0015 * 0.0015;
125  e(2, 2) = 15. * 15.;
126  reco::Vertex::Point p(0, 0, 0);
127  dummy = reco::Vertex(p, e, 0, 0, 0);
128  }
129 
131 
133  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
134  TransientTrackBuilder thebuilder = *(builder.product());
135 
137  iEvent.getByToken(electronToken_,egCollection);
138  const reco::GsfElectronCollection egCandidates = (*egCollection.product());
139 
140  _Rho=0;
141  edm::Handle<double> rhoPtr;
142  iEvent.getByToken(eventrhoToken_,rhoPtr);
143  _Rho=*rhoPtr;
144 
145  std::vector<float> values;
146  values.reserve(egCollection->size());
147 
148  for ( reco::GsfElectronCollection::const_iterator egIter = egCandidates.begin(); egIter != egCandidates.end(); ++egIter) {
149 
150  double mvaVal = -999999;
151  if(!NoIP_){
152  mvaVal = mvaID_->mvaValue( *egIter, *pv,thebuilder,lazyTools, verbose_);
153  }
154  if(NoIP_){
155  mvaVal = mvaID_->mvaValue( *egIter, *pv, _Rho,/*thebuilder,*/lazyTools, verbose_);
156  }
157 
158  values.push_back( mvaVal );
159  }
160 
162  filler.insert(egCollection, values.begin(), values.end() );
163  filler.fill();
164 
165  iEvent.put(std::move(out));
166 
167  return true;
168 }
edm::EDGetTokenT< double > eventrhoToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
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
def pv(vc)
Definition: MetAnalyzer.py:6
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)
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510
EGammaMvaEleEstimator * mvaID_

Member Data Documentation

double ElectronIdMVAProducer::_Rho
private

Definition at line 40 of file ElectronIdMVAProducer.cc.

Referenced by filter().

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

Definition at line 35 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer(), and filter().

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

Definition at line 36 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer(), and filter().

std::string ElectronIdMVAProducer::method_
private

Definition at line 41 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer().

EGammaMvaEleEstimator* ElectronIdMVAProducer::mvaID_
private

Definition at line 46 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer(), and filter().

std::vector<std::string> ElectronIdMVAProducer::mvaWeightFiles_
private

Definition at line 42 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer().

bool ElectronIdMVAProducer::NoIP_
private

Definition at line 44 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer(), and filter().

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

Definition at line 37 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer(), and filter().

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

Definition at line 38 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer(), and filter().

bool ElectronIdMVAProducer::Trig_
private

Definition at line 43 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer().

bool ElectronIdMVAProducer::verbose_
private

Definition at line 33 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer(), and filter().

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

Definition at line 34 of file ElectronIdMVAProducer.cc.

Referenced by ElectronIdMVAProducer(), and filter().