CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
LowPtGsfElectronIDProducer Class Referencefinal
Inheritance diagram for LowPtGsfElectronIDProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 LowPtGsfElectronIDProducer (const edm::ParameterSet &)
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

double eval (const std::string &name, const reco::GsfElectronRef &, double rho) const
 

Private Attributes

const edm::EDGetTokenT< reco::GsfElectronCollectiongsfElectrons_
 
const double maxPtThreshold_
 
const double minPtThreshold_
 
std::vector< std::unique_ptr< const GBRForest > > models_
 
const std::vector< std::string > names_
 
const bool passThrough_
 
const edm::EDGetTokenT< double > rho_
 
const std::vector< double > thresholds_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase 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
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 132 of file LowPtGsfElectronIDProducer.cc.

Constructor & Destructor Documentation

◆ LowPtGsfElectronIDProducer()

LowPtGsfElectronIDProducer::LowPtGsfElectronIDProducer ( const edm::ParameterSet conf)
explicit

Definition at line 155 of file LowPtGsfElectronIDProducer.cc.

156  : gsfElectrons_(consumes<reco::GsfElectronCollection>(conf.getParameter<edm::InputTag>("electrons"))),
157  rho_(consumes<double>(conf.getParameter<edm::InputTag>("rho"))),
158  names_(conf.getParameter<std::vector<std::string> >("ModelNames")),
159  passThrough_(conf.getParameter<bool>("PassThrough")),
160  minPtThreshold_(conf.getParameter<double>("MinPtThreshold")),
161  maxPtThreshold_(conf.getParameter<double>("MaxPtThreshold")),
162  thresholds_(conf.getParameter<std::vector<double> >("ModelThresholds")) {
163  for (auto& weights : conf.getParameter<std::vector<std::string> >("ModelWeights")) {
165  }
166  if (names_.size() != models_.size()) {
167  throw cms::Exception("Incorrect configuration")
168  << "'ModelNames' size (" << names_.size() << ") != 'ModelWeights' size (" << models_.size() << ").\n";
169  }
170  if (models_.size() != thresholds_.size()) {
171  throw cms::Exception("Incorrect configuration")
172  << "'ModelWeights' size (" << models_.size() << ") != 'ModelThresholds' size (" << thresholds_.size() << ").\n";
173  }
174  for (const auto& name : names_) {
175  produces<edm::ValueMap<float> >(name);
176  }
177 }

References createGBRForest(), Exception, edm::ParameterSet::getParameter(), models_, Skims_PA_cff::name, names_, thresholds_, and HLT_2018_cff::weights.

Member Function Documentation

◆ eval()

double LowPtGsfElectronIDProducer::eval ( const std::string &  name,
const reco::GsfElectronRef ele,
double  rho 
) const
private

Definition at line 220 of file LowPtGsfElectronIDProducer.cc.

220  {
221  auto iter = std::find(names_.begin(), names_.end(), name);
222  if (iter != names_.end()) {
223  int index = std::distance(names_.begin(), iter);
224  std::vector<float> inputs = getFeatures(ele, rho);
225  return models_.at(index)->GetResponse(inputs.data());
226  } else {
227  throw cms::Exception("Unknown model name") << "'Name given: '" << name << "'. Check against configuration file.\n";
228  }
229  return 0.;
230 }

References HLT_2018_cff::distance, Exception, spr::find(), PixelMapPlotter::inputs, models_, Skims_PA_cff::name, names_, and rho.

Referenced by produce().

◆ fillDescriptions()

void LowPtGsfElectronIDProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 234 of file LowPtGsfElectronIDProducer.cc.

234  {
236  desc.add<edm::InputTag>("electrons", edm::InputTag("lowPtGsfElectrons"));
237  desc.add<edm::InputTag>("rho", edm::InputTag("fixedGridRhoFastjetAllTmp"));
238  desc.add<std::vector<std::string> >("ModelNames", {""});
239  desc.add<std::vector<std::string> >(
240  "ModelWeights",
241  {"RecoEgamma/ElectronIdentification/data/LowPtElectrons/RunII_Autumn18_LowPtElectrons_mva_id.xml.gz"});
242  desc.add<std::vector<double> >("ModelThresholds", {-10.});
243  desc.add<bool>("PassThrough", false);
244  desc.add<double>("MinPtThreshold", 0.5);
245  desc.add<double>("MaxPtThreshold", 15.);
246  descriptions.add("lowPtGsfElectronID", desc);
247 }

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and HLT_2018_cff::InputTag.

◆ produce()

void LowPtGsfElectronIDProducer::produce ( edm::StreamID  ,
edm::Event event,
const edm::EventSetup setup 
) const
overridevirtual

Implements edm::global::EDProducerBase.

Definition at line 181 of file LowPtGsfElectronIDProducer.cc.

181  {
182  // Pileup
184  event.getByToken(rho_, rho);
185  if (!rho.isValid()) {
186  edm::LogError("Problem with rho handle");
187  }
188 
189  // Retrieve GsfElectrons from Event
191  event.getByToken(gsfElectrons_, gsfElectrons);
192  if (!gsfElectrons.isValid()) {
193  edm::LogError("Problem with gsfElectrons handle");
194  }
195 
196  // Iterate through Electrons, evaluate BDT, and store result
197  std::vector<std::vector<float> > output;
198  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
199  output.emplace_back(gsfElectrons->size(), -999.);
200  }
201  for (unsigned int iele = 0; iele < gsfElectrons->size(); iele++) {
203  //if ( !passThrough_ && ( ele->pt() < minPtThreshold_ ) ) { continue; }
204  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
205  output[iname][iele] = eval(names_[iname], ele, *rho);
206  }
207  }
208 
209  // Create and put ValueMap in Event
210  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
211  auto ptr = std::make_unique<edm::ValueMap<float> >(edm::ValueMap<float>());
213  filler.insert(gsfElectrons, output[iname].begin(), output[iname].end());
214  filler.fill();
216  event.put(std::move(ptr), names_[iname]);
217  }
218 }

References begin, end, eval(), trigObjTnPSource_cfi::filler, electronIsolatorFromEffectiveArea_cfi::gsfElectrons, gsfElectrons_, eostools::move(), names_, convertSQLitetoXML_cfg::output, rho, and rho_.

Member Data Documentation

◆ gsfElectrons_

const edm::EDGetTokenT<reco::GsfElectronCollection> LowPtGsfElectronIDProducer::gsfElectrons_
private

Definition at line 143 of file LowPtGsfElectronIDProducer.cc.

Referenced by produce().

◆ maxPtThreshold_

const double LowPtGsfElectronIDProducer::maxPtThreshold_
private

Definition at line 148 of file LowPtGsfElectronIDProducer.cc.

◆ minPtThreshold_

const double LowPtGsfElectronIDProducer::minPtThreshold_
private

Definition at line 147 of file LowPtGsfElectronIDProducer.cc.

◆ models_

std::vector<std::unique_ptr<const GBRForest> > LowPtGsfElectronIDProducer::models_
private

Definition at line 149 of file LowPtGsfElectronIDProducer.cc.

Referenced by eval(), and LowPtGsfElectronIDProducer().

◆ names_

const std::vector<std::string> LowPtGsfElectronIDProducer::names_
private

Definition at line 145 of file LowPtGsfElectronIDProducer.cc.

Referenced by eval(), LowPtGsfElectronIDProducer(), and produce().

◆ passThrough_

const bool LowPtGsfElectronIDProducer::passThrough_
private

Definition at line 146 of file LowPtGsfElectronIDProducer.cc.

◆ rho_

const edm::EDGetTokenT<double> LowPtGsfElectronIDProducer::rho_
private

Definition at line 144 of file LowPtGsfElectronIDProducer.cc.

Referenced by produce().

◆ thresholds_

const std::vector<double> LowPtGsfElectronIDProducer::thresholds_
private

Definition at line 150 of file LowPtGsfElectronIDProducer.cc.

Referenced by LowPtGsfElectronIDProducer().

HLT_2018_cff.weights
weights
Definition: HLT_2018_cff.py:87167
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
LowPtGsfElectronIDProducer::eval
double eval(const std::string &name, const reco::GsfElectronRef &, double rho) const
Definition: LowPtGsfElectronIDProducer.cc:220
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
createGBRForest
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)
Definition: GBRForestTools.cc:244
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
electronIsolatorFromEffectiveArea_cfi.gsfElectrons
gsfElectrons
Definition: electronIsolatorFromEffectiveArea_cfi.py:4
edm::Handle< double >
end
#define end
Definition: vmac.h:39
edm::Ref
Definition: AssociativeIterator.h:58
LowPtGsfElectronIDProducer::models_
std::vector< std::unique_ptr< const GBRForest > > models_
Definition: LowPtGsfElectronIDProducer.cc:149
edm::FileInPath
Definition: FileInPath.h:64
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
LowPtGsfElectronIDProducer::gsfElectrons_
const edm::EDGetTokenT< reco::GsfElectronCollection > gsfElectrons_
Definition: LowPtGsfElectronIDProducer.cc:143
LowPtGsfElectronIDProducer::thresholds_
const std::vector< double > thresholds_
Definition: LowPtGsfElectronIDProducer.cc:150
DDAxes::rho
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::LogError
Definition: MessageLogger.h:183
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
LowPtGsfElectronIDProducer::maxPtThreshold_
const double maxPtThreshold_
Definition: LowPtGsfElectronIDProducer.cc:148
PixelMapPlotter.inputs
inputs
Definition: PixelMapPlotter.py:490
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ValueMap< float >
Exception
Definition: hltDiff.cc:246
LowPtGsfElectronIDProducer::rho_
const edm::EDGetTokenT< double > rho_
Definition: LowPtGsfElectronIDProducer.cc:144
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
LowPtGsfElectronIDProducer::minPtThreshold_
const double minPtThreshold_
Definition: LowPtGsfElectronIDProducer.cc:147
LowPtGsfElectronIDProducer::names_
const std::vector< std::string > names_
Definition: LowPtGsfElectronIDProducer.cc:145
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::helper::Filler
Definition: ValueMap.h:22
LowPtGsfElectronIDProducer::passThrough_
const bool passThrough_
Definition: LowPtGsfElectronIDProducer.cc:146
edm::InputTag
Definition: InputTag.h:15
begin
#define begin
Definition: vmac.h:32