CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ElectronPATIdMVAProducer Class Reference
Inheritance diagram for ElectronPATIdMVAProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ElectronPATIdMVAProducer (const edm::ParameterSet &)
 
 ~ElectronPATIdMVAProducer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

double _Rho
 
edm::EDGetTokenT< pat::ElectronCollectionelectronToken_
 
edm::EDGetTokenT< double > eventrhoToken_
 
std::string method_
 
EGammaMvaEleEstimatormvaID_
 
std::vector< std::string > mvaWeightFiles_
 
bool verbose_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 ElectronPATIdMVAProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 56 of file ElectronPATIdMVAProducer.cc.

References electronToken_, eventrhoToken_, edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), compare_using_db::ifile, EGammaMvaEleEstimator::kTrigNoIP, method_, mvaID_, mvaWeightFiles_, AlCaHLTBitMon_QueryRunRegistry::string, and verbose_.

56  {
57  verbose_ = iConfig.getUntrackedParameter<bool>("verbose", false);
58  electronToken_ = consumes<pat::ElectronCollection>(iConfig.getParameter<edm::InputTag>("electronTag"));
59  method_ = iConfig.getParameter<std::string>("method");
60  std::vector<std::string> fpMvaWeightFiles = iConfig.getParameter<std::vector<std::string> >("mvaWeightFile");
61  eventrhoToken_ = consumes<double>(iConfig.getParameter<edm::InputTag>("Rho"));
62 
63  produces<edm::ValueMap<float> >();
64 
66 
68 
69 
71 
72 
73 
74  bool manualCat_ = true;
75 
76  std::string path_mvaWeightFileEleID;
77  for(unsigned ifile=0 ; ifile < fpMvaWeightFiles.size() ; ++ifile) {
78  path_mvaWeightFileEleID = edm::FileInPath ( fpMvaWeightFiles[ifile].c_str() ).fullPath();
79  mvaWeightFiles_.push_back(path_mvaWeightFileEleID);
80  }
81 
82  mvaID_->initialize(method_, type_, manualCat_, mvaWeightFiles_);
83 
84 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > mvaWeightFiles_
void initialize(std::string methodName, std::string weightsfile, EGammaMvaEleEstimator::MVAType type)
edm::EDGetTokenT< pat::ElectronCollection > electronToken_
EGammaMvaEleEstimator * mvaID_
edm::EDGetTokenT< double > eventrhoToken_
std::string fullPath() const
Definition: FileInPath.cc:163
ElectronPATIdMVAProducer::~ElectronPATIdMVAProducer ( )
override

Definition at line 87 of file ElectronPATIdMVAProducer.cc.

88 {
89 
90  // do anything here that needs to be done at desctruction time
91  // (e.g. close files, deallocate resources etc.)
92 
93 }

Member Function Documentation

void ElectronPATIdMVAProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 101 of file ElectronPATIdMVAProducer.cc.

References _Rho, DEFINE_FWK_MODULE, electronToken_, eventrhoToken_, edm::helper::Filler< Map >::fill(), objects.autophobj::filler, edm::Event::getByToken(), edm::helper::Filler< Map >::insert(), eostools::move(), mvaID_, EGammaMvaEleEstimator::mvaValue(), MillePedeFileConverter_cfg::out, edm::Handle< T >::product(), edm::Event::put(), MuonErrorMatrixValues_cff::values, and verbose_.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

101  {
102 
103  std::unique_ptr<edm::ValueMap<float> > out(new edm::ValueMap<float>() );
104 
105 
106 
107 
108 
109 
110 
112  iEvent.getByToken(electronToken_,egCollection);
113  const pat::ElectronCollection egCandidates = (*egCollection.product());
114 
115  _Rho=0;
116  edm::Handle<double> rhoPtr;
117  //const edm::InputTag eventrhoToken_("kt6PFJets", "rho");
118  iEvent.getByToken(eventrhoToken_,rhoPtr);
119  _Rho=*rhoPtr;
120 
121  std::vector<float> values;
122  values.reserve(egCollection->size());
123 
124  for ( pat::ElectronCollection::const_iterator egIter = egCandidates.begin(); egIter != egCandidates.end(); ++egIter) {
125 
126  double mvaVal = -999999;
127 
128 
129 
130 
131  mvaVal = mvaID_->mvaValue( *egIter, _Rho, verbose_);
132 
133 
134  values.push_back( mvaVal );
135  }
136 
138  filler.insert(egCollection, values.begin(), values.end() );
139  filler.fill();
140 
141  iEvent.put(std::move(out));
142 
143 
144 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< Electron > ElectronCollection
Definition: Electron.h:37
Double_t mvaValue(const reco::GsfElectron &ele, const reco::Vertex &vertex, const TransientTrackBuilder &transientTrackBuilder, EcalClusterLazyTools myEcalCluster, bool printDebug=kFALSE)
edm::EDGetTokenT< pat::ElectronCollection > electronToken_
EGammaMvaEleEstimator * mvaID_
T const * product() const
Definition: Handle.h:74
edm::EDGetTokenT< double > eventrhoToken_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

double ElectronPATIdMVAProducer::_Rho
private

Definition at line 35 of file ElectronPATIdMVAProducer.cc.

Referenced by produce().

edm::EDGetTokenT<pat::ElectronCollection> ElectronPATIdMVAProducer::electronToken_
private

Definition at line 34 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer(), and produce().

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

Definition at line 36 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer(), and produce().

std::string ElectronPATIdMVAProducer::method_
private

Definition at line 37 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer().

EGammaMvaEleEstimator* ElectronPATIdMVAProducer::mvaID_
private

Definition at line 41 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer(), and produce().

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

Definition at line 38 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer().

bool ElectronPATIdMVAProducer::verbose_
private

Definition at line 33 of file ElectronPATIdMVAProducer.cc.

Referenced by ElectronPATIdMVAProducer(), and produce().