CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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
 
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)
 

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, float unbiased, float field_z) const
 

Private Attributes

const edm::EDGetTokenT< reco::GsfElectronCollectionelectrons_
 
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::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 29 of file LowPtGsfElectronIDProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 54 of file LowPtGsfElectronIDProducer.cc.

References createGBRForest(), Exception, edm::ParameterSet::getParameter(), models_, dataset::name, names_, thresholds_, version_, and HGCalRecHit_cfi::weights.

55  : electrons_(consumes<reco::GsfElectronCollection>(conf.getParameter<edm::InputTag>("electrons"))),
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" && !version_.empty()) {
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 }
const edm::EDGetTokenT< edm::ValueMap< float > > unbiased_
T getParameter(std::string const &) const
const std::vector< double > thresholds_
const std::vector< std::string > names_
std::vector< std::unique_ptr< const GBRForest > > models_
const edm::EDGetTokenT< reco::GsfElectronCollection > electrons_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< double > rho_
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)

Member Function Documentation

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

Definition at line 148 of file LowPtGsfElectronIDProducer.cc.

References SoftLeptonByDistance_cfi::distance, Exception, postprocess-scan-build::features, lowptgsfeleid::features_V0(), lowptgsfeleid::features_V1(), spr::find(), lowptgsfeleid::Features::get(), PatBasicFWLiteJetAnalyzer_Selector_cfg::inputs, models_, dataset::name, names_, lowptgsfeleid::Features::set(), and version_.

Referenced by produce().

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_.empty()) { // Original XML model
156  features.set(ele, rho);
157  inputs = features.get();
158  } else if (version_ == "V0") {
159  inputs = lowptgsfeleid::features_V0(*ele, rho, unbiased);
160  } else if (version_ == "V1") {
161  inputs = lowptgsfeleid::features_V1(*ele, rho, unbiased, field_z);
162  }
163  return models_.at(index)->GetResponse(inputs.data());
164  } else {
165  throw cms::Exception("Unknown model name") << "'Name given: '" << name << "'. Check against configuration file.\n";
166  }
167  return 0.;
168 }
const std::vector< std::string > names_
std::vector< std::unique_ptr< const GBRForest > > models_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< float > features_V0(reco::GsfElectron const &ele, float rho, float unbiased)
void set(const reco::GsfElectronRef &ele, double rho)
std::vector< float > features_V1(reco::GsfElectron const &ele, float rho, float unbiased, float field_z)
void LowPtGsfElectronIDProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 172 of file LowPtGsfElectronIDProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), DEFINE_FWK_MODULE, and AlCaHLTBitMon_QueryRunRegistry::string.

172  {
174  desc.add<edm::InputTag>("electrons", edm::InputTag("lowPtGsfElectrons"));
175  desc.add<edm::InputTag>("unbiased", edm::InputTag("lowPtGsfElectronSeedValueMaps:unbiased"));
176  desc.add<edm::InputTag>("rho", edm::InputTag("fixedGridRhoFastjetAllTmp"));
177  desc.add<std::vector<std::string> >("ModelNames", std::vector<std::string>());
178  desc.add<std::vector<std::string> >("ModelWeights", std::vector<std::string>());
179  desc.add<std::vector<double> >("ModelThresholds", std::vector<double>());
180  desc.add<bool>("PassThrough", false);
181  desc.add<double>("MinPtThreshold", 0.5);
182  desc.add<double>("MaxPtThreshold", 15.);
183  desc.add<std::string>("Version", "");
184  descriptions.add("defaultLowPtGsfElectronID", desc);
185 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void LowPtGsfElectronIDProducer::produce ( edm::StreamID  ,
edm::Event event,
const edm::EventSetup setup 
) const
override

Definition at line 85 of file LowPtGsfElectronIDProducer.cc.

References begin, nano_cff::electrons, electrons_, end, eval(), Exception, edm::helper::Filler< Map >::fill(), objects.autophobj::filler, edm::EventSetup::get(), ntupleEnum::gsf, edm::helper::Filler< Map >::insert(), MagneticField::inTesla(), edm::Ref< C, T, F >::isNull(), eostools::move(), names_, convertSQLitetoXML_cfg::output, rho, rho_, lowPtElectronProducer_cff::unbiased, and unbiased_.

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++) {
119  reco::GsfElectronRef ele(electrons, 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 }
const edm::EDGetTokenT< edm::ValueMap< float > > unbiased_
double eval(const std::string &name, const reco::GsfElectronRef &, double rho, float unbiased, float field_z) const
const std::vector< std::string > names_
const edm::EDGetTokenT< reco::GsfElectronCollection > electrons_
#define end
Definition: vmac.h:39
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
const edm::EDGetTokenT< double > rho_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
#define begin
Definition: vmac.h:32
T get() const
Definition: EventSetup.h:71
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

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

Definition at line 40 of file LowPtGsfElectronIDProducer.cc.

Referenced by produce().

const double LowPtGsfElectronIDProducer::maxPtThreshold_
private

Definition at line 46 of file LowPtGsfElectronIDProducer.cc.

const double LowPtGsfElectronIDProducer::minPtThreshold_
private

Definition at line 45 of file LowPtGsfElectronIDProducer.cc.

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

Definition at line 47 of file LowPtGsfElectronIDProducer.cc.

Referenced by eval(), and LowPtGsfElectronIDProducer().

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

Definition at line 43 of file LowPtGsfElectronIDProducer.cc.

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

const bool LowPtGsfElectronIDProducer::passThrough_
private

Definition at line 44 of file LowPtGsfElectronIDProducer.cc.

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

Definition at line 41 of file LowPtGsfElectronIDProducer.cc.

Referenced by produce().

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

Definition at line 48 of file LowPtGsfElectronIDProducer.cc.

Referenced by LowPtGsfElectronIDProducer().

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

Definition at line 42 of file LowPtGsfElectronIDProducer.cc.

Referenced by produce().

const std::string LowPtGsfElectronIDProducer::version_
private

Definition at line 49 of file LowPtGsfElectronIDProducer.cc.

Referenced by eval(), and LowPtGsfElectronIDProducer().