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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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 edm::Ptr< reco::GsfElectron > &, double rho, float unbiased) const
 

Private Attributes

const edm::EDGetTokenT< edm::View< reco::GsfElectron > > gsfElectrons_
 
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_
 
const edm::EDGetTokenT< edm::ValueMap< float > > unbiased_
 

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 = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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 25 of file LowPtGsfElectronIDProducer.cc.

Constructor & Destructor Documentation

◆ LowPtGsfElectronIDProducer()

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

Definition at line 49 of file LowPtGsfElectronIDProducer.cc.

51  rho_(consumes<double>(conf.getParameter<edm::InputTag>("rho"))),
53  names_(conf.getParameter<std::vector<std::string> >("ModelNames")),
54  passThrough_(conf.getParameter<bool>("PassThrough")),
55  minPtThreshold_(conf.getParameter<double>("MinPtThreshold")),
56  maxPtThreshold_(conf.getParameter<double>("MaxPtThreshold")),
57  thresholds_(conf.getParameter<std::vector<double> >("ModelThresholds")) {
58  for (auto& weights : conf.getParameter<std::vector<std::string> >("ModelWeights")) {
60  }
61  if (names_.size() != models_.size()) {
62  throw cms::Exception("Incorrect configuration")
63  << "'ModelNames' size (" << names_.size() << ") != 'ModelWeights' size (" << models_.size() << ").\n";
64  }
65  if (models_.size() != thresholds_.size()) {
66  throw cms::Exception("Incorrect configuration")
67  << "'ModelWeights' size (" << models_.size() << ") != 'ModelThresholds' size (" << thresholds_.size() << ").\n";
68  }
69  for (const auto& name : names_) {
70  produces<edm::ValueMap<float> >(name);
71  }
72 }

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

Member Function Documentation

◆ eval()

double LowPtGsfElectronIDProducer::eval ( const std::string &  name,
const edm::Ptr< reco::GsfElectron > &  ele,
double  rho,
float  unbiased 
) const
private

Definition at line 142 of file LowPtGsfElectronIDProducer.cc.

145  {
146  auto iter = std::find(names_.begin(), names_.end(), name);
147  if (iter != names_.end()) {
148  int index = std::distance(names_.begin(), iter);
149  std::vector<float> inputs = lowptgsfeleid::features(ele, rho, unbiased);
150  return models_.at(index)->GetResponse(inputs.data());
151  } else {
152  throw cms::Exception("Unknown model name") << "'Name given: '" << name << "'. Check against configuration file.\n";
153  }
154  return 0.;
155 }

References HLT_FULL_cff::distance, Exception, lowptgsfeleid::features(), 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 159 of file LowPtGsfElectronIDProducer.cc.

159  {
161  desc.add<edm::InputTag>("electrons", edm::InputTag("lowPtGsfElectrons"));
162  desc.add<edm::InputTag>("unbiased", edm::InputTag("lowPtGsfElectronSeedValueMaps:unbiased"));
163  desc.add<edm::InputTag>("rho", edm::InputTag("fixedGridRhoFastjetAllTmp"));
164  desc.add<std::vector<std::string> >("ModelNames", {""});
165  desc.add<std::vector<std::string> >(
166  "ModelWeights",
167  {"RecoEgamma/ElectronIdentification/data/LowPtElectrons/RunII_Autumn18_LowPtElectrons_mva_id.xml.gz"});
168  desc.add<std::vector<double> >("ModelThresholds", {-10.});
169  desc.add<bool>("PassThrough", false);
170  desc.add<double>("MinPtThreshold", 0.5);
171  desc.add<double>("MaxPtThreshold", 15.);
172  descriptions.add("lowPtGsfElectronID", desc);
173 }

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and HLT_FULL_cff::InputTag.

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 76 of file LowPtGsfElectronIDProducer.cc.

76  {
77  // Pileup
79  event.getByToken(rho_, rho);
80  if (!rho.isValid()) {
81  std::ostringstream os;
82  os << "Problem accessing rho collection for low-pT electrons" << std::endl;
83  edm::LogError("InvalidHandle") << os.str();
84  throw cms::Exception("InvalidHandle", os.str());
85  }
86 
87  // Retrieve GsfElectrons from Event
89  event.getByToken(gsfElectrons_, gsfElectrons);
90  if (!gsfElectrons.isValid()) {
91  std::ostringstream os;
92  os << "Problem accessing low-pT gsfElectrons collection" << std::endl;
93  edm::LogError("InvalidHandle") << os.str();
94  throw cms::Exception("InvalidHandle", os.str());
95  }
96 
97  // ElectronSeed unbiased BDT
99  event.getByToken(unbiased_, unbiasedH);
100  if (!unbiasedH.isValid()) {
101  std::ostringstream os;
102  os << "Problem accessing low-pT 'unbiased' ElectronSeed collection" << std::endl;
103  edm::LogError("InvalidHandle") << os.str();
104  throw cms::Exception("InvalidHandle", os.str());
105  }
106 
107  // Iterate through Electrons, evaluate BDT, and store result
108  std::vector<std::vector<float> > output;
109  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
110  output.emplace_back(gsfElectrons->size(), -999.);
111  }
112  for (unsigned int iele = 0; iele < gsfElectrons->size(); iele++) {
114 
115  if (ele->core().isNull()) {
116  continue;
117  }
118  const auto& gsf = ele->core()->gsfTrack(); // reco::GsfTrackRef
119  if (gsf.isNull()) {
120  continue;
121  }
122  float unbiased = (*unbiasedH)[gsf];
123 
124  //if ( !passThrough_ && ( ele->pt() < minPtThreshold_ ) ) { continue; }
125  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
126  output[iname][iele] = eval(names_[iname], ele, *rho, unbiased);
127  }
128  }
129 
130  // Create and put ValueMap in Event
131  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
132  auto ptr = std::make_unique<edm::ValueMap<float> >(edm::ValueMap<float>());
134  filler.insert(gsfElectrons, output[iname].begin(), output[iname].end());
135  filler.fill();
136  event.put(std::move(ptr), names_[iname]);
137  }
138 }

References reco::GsfElectron::core(), mps_fire::end, eval(), Exception, trigObjTnPSource_cfi::filler, ntupleEnum::gsf, electronIsolatorFromEffectiveArea_cfi::gsfElectrons, gsfElectrons_, edm::Ref< C, T, F >::isNull(), edm::HandleBase::isValid(), eostools::move(), names_, convertSQLitetoXML_cfg::output, rho, rho_, and unbiased_.

Member Data Documentation

◆ gsfElectrons_

const edm::EDGetTokenT<edm::View<reco::GsfElectron> > LowPtGsfElectronIDProducer::gsfElectrons_
private

Definition at line 36 of file LowPtGsfElectronIDProducer.cc.

Referenced by produce().

◆ maxPtThreshold_

const double LowPtGsfElectronIDProducer::maxPtThreshold_
private

Definition at line 42 of file LowPtGsfElectronIDProducer.cc.

◆ minPtThreshold_

const double LowPtGsfElectronIDProducer::minPtThreshold_
private

Definition at line 41 of file LowPtGsfElectronIDProducer.cc.

◆ models_

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

Definition at line 43 of file LowPtGsfElectronIDProducer.cc.

Referenced by eval(), and LowPtGsfElectronIDProducer().

◆ names_

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

Definition at line 39 of file LowPtGsfElectronIDProducer.cc.

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

◆ passThrough_

const bool LowPtGsfElectronIDProducer::passThrough_
private

Definition at line 40 of file LowPtGsfElectronIDProducer.cc.

◆ rho_

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

Definition at line 37 of file LowPtGsfElectronIDProducer.cc.

Referenced by produce().

◆ thresholds_

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

Definition at line 44 of file LowPtGsfElectronIDProducer.cc.

Referenced by LowPtGsfElectronIDProducer().

◆ unbiased_

const edm::EDGetTokenT<edm::ValueMap<float> > LowPtGsfElectronIDProducer::unbiased_
private

Definition at line 38 of file LowPtGsfElectronIDProducer.cc.

Referenced by produce().

lowptgsfeleid::features
std::vector< float > features(edm::Ptr< reco::GsfElectron > const &ele, float rho, float unbiased)
Definition: LowPtGsfElectronFeatures.cc:132
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
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 >
LowPtGsfElectronIDProducer::models_
std::vector< std::unique_ptr< const GBRForest > > models_
Definition: LowPtGsfElectronIDProducer.cc:43
edm::FileInPath
Definition: FileInPath.h:64
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
HLT_FULL_cff.weights
weights
Definition: HLT_FULL_cff.py:99178
LowPtGsfElectronIDProducer::thresholds_
const std::vector< double > thresholds_
Definition: LowPtGsfElectronIDProducer.cc:44
mps_fire.end
end
Definition: mps_fire.py:242
LowPtGsfElectronIDProducer::gsfElectrons_
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > gsfElectrons_
Definition: LowPtGsfElectronIDProducer.cc:36
DDAxes::rho
edm::View
Definition: CaloClusterFwd.h:14
LowPtGsfElectronIDProducer::eval
double eval(const std::string &name, const edm::Ptr< reco::GsfElectron > &, double rho, float unbiased) const
Definition: LowPtGsfElectronIDProducer.cc:142
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
LowPtGsfElectronIDProducer::maxPtThreshold_
const double maxPtThreshold_
Definition: LowPtGsfElectronIDProducer.cc:42
PixelMapPlotter.inputs
inputs
Definition: PixelMapPlotter.py:490
ntupleEnum.gsf
gsf
Definition: ntupleEnum.py:48
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
edm::Ptr< reco::GsfElectron >
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
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:37
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
LowPtGsfElectronIDProducer::unbiased_
const edm::EDGetTokenT< edm::ValueMap< float > > unbiased_
Definition: LowPtGsfElectronIDProducer.cc:38
LowPtGsfElectronIDProducer::minPtThreshold_
const double minPtThreshold_
Definition: LowPtGsfElectronIDProducer.cc:41
LowPtGsfElectronIDProducer::names_
const std::vector< std::string > names_
Definition: LowPtGsfElectronIDProducer.cc:39
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::helper::Filler
Definition: ValueMap.h:22
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:153
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7733
LowPtGsfElectronIDProducer::passThrough_
const bool passThrough_
Definition: LowPtGsfElectronIDProducer.cc:40
edm::InputTag
Definition: InputTag.h:15