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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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, float field_z) const
 

Private Attributes

const edm::EDGetTokenT< edm::View< reco::GsfElectron > > electrons_
 
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_
 
const std::string version_
 

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 28 of file LowPtGsfElectronIDProducer.cc.

Constructor & Destructor Documentation

◆ LowPtGsfElectronIDProducer()

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

Definition at line 54 of file LowPtGsfElectronIDProducer.cc.

56  rho_(consumes<double>(conf.getParameter<edm::InputTag>("rho"))),
58  names_(conf.getParameter<std::vector<std::string> >("ModelNames")),
59  passThrough_(conf.getParameter<bool>("PassThrough")),
60  minPtThreshold_(conf.getParameter<double>("MinPtThreshold")),
61  maxPtThreshold_(conf.getParameter<double>("MaxPtThreshold")),
62  thresholds_(conf.getParameter<std::vector<double> >("ModelThresholds")),
63  version_(conf.getParameter<std::string>("Version")) {
64  for (auto& weights : conf.getParameter<std::vector<std::string> >("ModelWeights")) {
66  }
67  if (names_.size() != models_.size()) {
68  throw cms::Exception("Incorrect configuration")
69  << "'ModelNames' size (" << names_.size() << ") != 'ModelWeights' size (" << models_.size() << ").\n";
70  }
71  if (models_.size() != thresholds_.size()) {
72  throw cms::Exception("Incorrect configuration")
73  << "'ModelWeights' size (" << models_.size() << ") != 'ModelThresholds' size (" << thresholds_.size() << ").\n";
74  }
75  if (version_ != "V0" && version_ != "V1") {
76  throw cms::Exception("Incorrect configuration") << "Unknown Version: " << version_ << "\n";
77  }
78  for (const auto& name : names_) {
79  produces<edm::ValueMap<float> >(name);
80  }
81 }

References createGBRForest(), Exception, edm::ParameterSet::getParameter(), models_, Skims_PA_cff::name, names_, thresholds_, version_, 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,
float  field_z 
) const
private

Definition at line 148 of file LowPtGsfElectronIDProducer.cc.

149  {
150  auto iter = std::find(names_.begin(), names_.end(), name);
151  if (iter != names_.end()) {
152  int index = std::distance(names_.begin(), iter);
153  std::vector<float> inputs;
154  if (version_ == "V0") {
156  } else if (version_ == "V1") {
157  inputs = lowptgsfeleid::features_V1(*ele, rho, unbiased, field_z);
158  }
159  return models_.at(index)->GetResponse(inputs.data());
160  } else {
161  throw cms::Exception("Unknown model name") << "'Name given: '" << name << "'. Check against configuration file.\n";
162  }
163  return 0.;
164 }

References HLT_FULL_cff::distance, Exception, lowptgsfeleid::features_V0(), lowptgsfeleid::features_V1(), spr::find(), PixelMapPlotter::inputs, models_, Skims_PA_cff::name, names_, rho, lowPtElectronProducer_cff::unbiased, and version_.

Referenced by produce().

◆ fillDescriptions()

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

Definition at line 168 of file LowPtGsfElectronIDProducer.cc.

168  {
170  desc.add<edm::InputTag>("electrons", edm::InputTag("lowPtGsfElectrons"));
171  desc.add<edm::InputTag>("unbiased", edm::InputTag("lowPtGsfElectronSeedValueMaps:unbiased"));
172  desc.add<edm::InputTag>("rho", edm::InputTag("fixedGridRhoFastjetAll"));
173  desc.add<std::vector<std::string> >("ModelNames", {""});
174  desc.add<std::vector<std::string> >(
175  "ModelWeights", {"RecoEgamma/ElectronIdentification/data/LowPtElectrons/LowPtElectrons_ID_2020Nov28.root"});
176  desc.add<std::vector<double> >("ModelThresholds", {-99.});
177  desc.add<bool>("PassThrough", false);
178  desc.add<double>("MinPtThreshold", 0.5);
179  desc.add<double>("MaxPtThreshold", 15.);
180  desc.add<std::string>("Version", "V1");
181  descriptions.add("lowPtGsfElectronID", desc);
182 }

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

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 85 of file LowPtGsfElectronIDProducer.cc.

85  {
86  // Get z-component of B field
88  setup.get<IdealMagneticFieldRecord>().get(field);
89  math::XYZVector zfield(field->inTesla(GlobalPoint(0, 0, 0)));
90 
91  // Pileup
93  event.getByToken(rho_, rho);
94  if (!rho.isValid()) {
95  std::ostringstream os;
96  os << "Problem accessing rho collection for low-pT electrons" << std::endl;
97  throw cms::Exception("InvalidHandle", os.str());
98  }
99 
100  // Retrieve GsfElectrons from Event
102  event.getByToken(electrons_, electrons);
103  if (!electrons.isValid()) {
104  std::ostringstream os;
105  os << "Problem accessing low-pT electrons collection" << std::endl;
106  throw cms::Exception("InvalidHandle", os.str());
107  }
108 
109  // ElectronSeed unbiased BDT
111  event.getByToken(unbiased_, unbiasedH);
112 
113  // Iterate through Electrons, evaluate BDT, and store result
114  std::vector<std::vector<float> > output;
115  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
116  output.emplace_back(electrons->size(), -999.);
117  }
118  for (unsigned int iele = 0; iele < electrons->size(); iele++) {
120 
121  if (ele->core().isNull()) {
122  continue;
123  }
124  const auto& gsf = ele->core()->gsfTrack(); // reco::GsfTrackRef
125  if (gsf.isNull()) {
126  continue;
127  }
128  float unbiased = (*unbiasedH)[gsf];
129 
130  //if ( !passThrough_ && ( ele->pt() < minPtThreshold_ ) ) { continue; }
131  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
132  output[iname][iele] = eval(names_[iname], ele, *rho, unbiased, zfield.z());
133  }
134  }
135 
136  // Create and put ValueMap in Event
137  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
138  auto ptr = std::make_unique<edm::ValueMap<float> >(edm::ValueMap<float>());
140  filler.insert(electrons, output[iname].begin(), output[iname].end());
141  filler.fill();
142  event.put(std::move(ptr), names_[iname]);
143  }
144 }

References reco::GsfElectron::core(), pwdgSkimBPark_cfi::electrons, electrons_, mps_fire::end, eval(), Exception, trigObjTnPSource_cfi::filler, get, ntupleEnum::gsf, MagneticField::inTesla(), edm::Ref< C, T, F >::isNull(), eostools::move(), names_, convertSQLitetoXML_cfg::output, rho, rho_, singleTopDQM_cfi::setup, lowPtElectronProducer_cff::unbiased, and unbiased_.

Member Data Documentation

◆ electrons_

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

Definition at line 40 of file LowPtGsfElectronIDProducer.cc.

Referenced by produce().

◆ maxPtThreshold_

const double LowPtGsfElectronIDProducer::maxPtThreshold_
private

Definition at line 46 of file LowPtGsfElectronIDProducer.cc.

◆ minPtThreshold_

const double LowPtGsfElectronIDProducer::minPtThreshold_
private

Definition at line 45 of file LowPtGsfElectronIDProducer.cc.

◆ models_

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

Definition at line 47 of file LowPtGsfElectronIDProducer.cc.

Referenced by eval(), and LowPtGsfElectronIDProducer().

◆ names_

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

Definition at line 43 of file LowPtGsfElectronIDProducer.cc.

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

◆ passThrough_

const bool LowPtGsfElectronIDProducer::passThrough_
private

Definition at line 44 of file LowPtGsfElectronIDProducer.cc.

◆ rho_

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

Definition at line 41 of file LowPtGsfElectronIDProducer.cc.

Referenced by produce().

◆ thresholds_

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

Definition at line 48 of file LowPtGsfElectronIDProducer.cc.

Referenced by LowPtGsfElectronIDProducer().

◆ unbiased_

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

Definition at line 42 of file LowPtGsfElectronIDProducer.cc.

Referenced by produce().

◆ version_

const std::string LowPtGsfElectronIDProducer::version_
private

Definition at line 49 of file LowPtGsfElectronIDProducer.cc.

Referenced by eval(), and LowPtGsfElectronIDProducer().

MagneticField::inTesla
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
lowptgsfeleid::features_V1
std::vector< float > features_V1(reco::GsfElectron const &ele, float rho, float unbiased, float field_z)
Definition: LowPtGsfElectronFeatures.cc:134
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
createGBRForest
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)
Definition: GBRForestTools.cc:257
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Handle< double >
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
LowPtGsfElectronIDProducer::models_
std::vector< std::unique_ptr< const GBRForest > > models_
Definition: LowPtGsfElectronIDProducer.cc:47
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
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:99170
LowPtGsfElectronIDProducer::thresholds_
const std::vector< double > thresholds_
Definition: LowPtGsfElectronIDProducer.cc:48
mps_fire.end
end
Definition: mps_fire.py:242
edm::ESHandle< MagneticField >
Point3DBase< float, GlobalTag >
DDAxes::rho
lowPtElectronProducer_cff.unbiased
unbiased
Definition: lowPtElectronProducer_cff.py:24
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::View
Definition: CaloClusterFwd.h:14
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
lowptgsfeleid::features_V0
std::vector< float > features_V0(reco::GsfElectron const &ele, float rho, float unbiased)
Definition: LowPtGsfElectronFeatures.cc:363
LowPtGsfElectronIDProducer::maxPtThreshold_
const double maxPtThreshold_
Definition: LowPtGsfElectronIDProducer.cc:46
PixelMapPlotter.inputs
inputs
Definition: PixelMapPlotter.py:490
ntupleEnum.gsf
gsf
Definition: ntupleEnum.py:49
get
#define get
edm::Ptr< reco::GsfElectron >
LowPtGsfElectronIDProducer::eval
double eval(const std::string &name, const edm::Ptr< reco::GsfElectron > &, double rho, float unbiased, float field_z) const
Definition: LowPtGsfElectronIDProducer.cc:148
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
LowPtGsfElectronIDProducer::electrons_
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > electrons_
Definition: LowPtGsfElectronIDProducer.cc:40
eostools.move
def move(src, dest)
Definition: eostools.py:511
pwdgSkimBPark_cfi.electrons
electrons
Definition: pwdgSkimBPark_cfi.py:6
edm::ValueMap< float >
Exception
Definition: hltDiff.cc:245
LowPtGsfElectronIDProducer::rho_
const edm::EDGetTokenT< double > rho_
Definition: LowPtGsfElectronIDProducer.cc:41
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:42
LowPtGsfElectronIDProducer::minPtThreshold_
const double minPtThreshold_
Definition: LowPtGsfElectronIDProducer.cc:45
LowPtGsfElectronIDProducer::names_
const std::vector< std::string > names_
Definition: LowPtGsfElectronIDProducer.cc:43
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:155
LowPtGsfElectronIDProducer::version_
const std::string version_
Definition: LowPtGsfElectronIDProducer.cc:49
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7733
LowPtGsfElectronIDProducer::passThrough_
const bool passThrough_
Definition: LowPtGsfElectronIDProducer.cc:44
edm::InputTag
Definition: InputTag.h:15