CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
LowPtGsfElectronIDProducer Class Referencefinal

#include <LowPtGsfElectronIDProducer.h>

Inheritance diagram for LowPtGsfElectronIDProducer:
edm::stream::EDProducer< edm::GlobalCache< lowptgsfeleid::HeavyObjectCache > >

Public Member Functions

 LowPtGsfElectronIDProducer (const edm::ParameterSet &, const lowptgsfeleid::HeavyObjectCache *)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~LowPtGsfElectronIDProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< lowptgsfeleid::HeavyObjectCache > >
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 
static void globalEndJob (lowptgsfeleid::HeavyObjectCache const *)
 
static std::unique_ptr< lowptgsfeleid::HeavyObjectCacheinitializeGlobalCache (const edm::ParameterSet &conf)
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< lowptgsfeleid::HeavyObjectCache > >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 12 of file LowPtGsfElectronIDProducer.h.

Constructor & Destructor Documentation

LowPtGsfElectronIDProducer::LowPtGsfElectronIDProducer ( const edm::ParameterSet conf,
const lowptgsfeleid::HeavyObjectCache  
)
explicit

Definition at line 11 of file LowPtGsfElectronIDProducer.cc.

References dataset::name, and names_.

12  :
13  gsfElectrons_(consumes<reco::GsfElectronCollection>(conf.getParameter<edm::InputTag>("electrons"))),
14  rho_(consumes<double>(conf.getParameter<edm::InputTag>("rho"))),
15  names_(conf.getParameter< std::vector<std::string> >("ModelNames")),
16  passThrough_(conf.getParameter<bool>("PassThrough")),
17  minPtThreshold_(conf.getParameter<double>("MinPtThreshold")),
18  maxPtThreshold_(conf.getParameter<double>("MaxPtThreshold"))
19 {
20  for ( const auto& name : names_ ) {
21  produces< edm::ValueMap<float> >(name);
22  }
23 }
T getParameter(std::string const &) const
const std::vector< std::string > names_
const edm::EDGetTokenT< reco::GsfElectronCollection > gsfElectrons_
const edm::EDGetTokenT< double > rho_
LowPtGsfElectronIDProducer::~LowPtGsfElectronIDProducer ( )
override

Definition at line 27 of file LowPtGsfElectronIDProducer.cc.

27 {}

Member Function Documentation

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

Definition at line 70 of file LowPtGsfElectronIDProducer.cc.

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

Referenced by globalEndJob().

71 {
73  desc.add<edm::InputTag>("electrons",edm::InputTag("lowPtGsfElectrons"));
74  desc.add<edm::InputTag>("rho",edm::InputTag("fixedGridRhoFastjetAllTmp"));
75  desc.add< std::vector<std::string> >("ModelNames",std::vector<std::string>());
76  desc.add< std::vector<std::string> >("ModelWeights",std::vector<std::string>());
77  desc.add< std::vector<double> >("ModelThresholds",std::vector<double>());
78  desc.add<bool>("PassThrough",false);
79  desc.add<double>("MinPtThreshold",0.5);
80  desc.add<double>("MaxPtThreshold",15.);
81  descriptions.add("defaultLowPtGsfElectronID",desc);
82 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void LowPtGsfElectronIDProducer::globalEndJob ( lowptgsfeleid::HeavyObjectCache const *  )
inlinestatic

Definition at line 27 of file LowPtGsfElectronIDProducer.h.

References fillDescriptions(), and produce().

27 {}
static std::unique_ptr<lowptgsfeleid::HeavyObjectCache> LowPtGsfElectronIDProducer::initializeGlobalCache ( const edm::ParameterSet conf)
inlinestatic

Definition at line 23 of file LowPtGsfElectronIDProducer.h.

23  {
24  return std::make_unique<lowptgsfeleid::HeavyObjectCache>(lowptgsfeleid::HeavyObjectCache(conf));
25  }
void LowPtGsfElectronIDProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
override

Definition at line 31 of file LowPtGsfElectronIDProducer.cc.

References begin, end, edm::helper::Filler< Map >::fill(), objects.autophobj::filler, gsfElectrons_cfi::gsfElectrons, gsfElectrons_, edm::helper::Filler< Map >::insert(), edm::HandleBase::isValid(), eostools::move(), names_, convertSQLitetoXML_cfg::output, rho, and rho_.

Referenced by globalEndJob().

31  {
32 
33  // Pileup
35  event.getByToken(rho_,rho);
36  if ( !rho.isValid() ) { edm::LogError("Problem with rho handle"); }
37 
38  // Retrieve GsfElectrons from Event
40  event.getByToken(gsfElectrons_,gsfElectrons);
41  if ( !gsfElectrons.isValid() ) { edm::LogError("Problem with gsfElectrons handle"); }
42 
43  // Iterate through Electrons, evaluate BDT, and store result
44  std::vector< std::vector<float> > output;
45  for ( unsigned int iname = 0; iname < names_.size(); ++iname ) {
46  output.push_back( std::vector<float>(gsfElectrons->size(),-999.) );
47  }
48  for ( unsigned int iele = 0; iele < gsfElectrons->size(); iele++ ) {
49  reco::GsfElectronRef ele(gsfElectrons,iele);
50  //if ( !passThrough_ && ( ele->pt() < minPtThreshold_ ) ) { continue; }
51  for ( unsigned int iname = 0; iname < names_.size(); ++iname ) {
52  output[iname][iele] = globalCache()->eval( names_[iname], ele, *rho );
53  }
54  }
55 
56  // Create and put ValueMap in Event
57  for ( unsigned int iname = 0; iname < names_.size(); ++iname ) {
58  auto ptr = std::make_unique< edm::ValueMap<float> >( edm::ValueMap<float>() );
60  filler.insert(gsfElectrons, output[iname].begin(), output[iname].end());
61  filler.fill();
62  reco::GsfElectronRef ele(gsfElectrons,0);
63  event.put(std::move(ptr),names_[iname]);
64  }
65 
66 }
const std::vector< std::string > names_
const edm::EDGetTokenT< reco::GsfElectronCollection > gsfElectrons_
#define end
Definition: vmac.h:39
bool isValid() const
Definition: HandleBase.h:74
const edm::EDGetTokenT< double > rho_
#define begin
Definition: vmac.h:32
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

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

Definition at line 35 of file LowPtGsfElectronIDProducer.h.

Referenced by produce().

const double LowPtGsfElectronIDProducer::maxPtThreshold_
private

Definition at line 40 of file LowPtGsfElectronIDProducer.h.

const double LowPtGsfElectronIDProducer::minPtThreshold_
private

Definition at line 39 of file LowPtGsfElectronIDProducer.h.

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

Definition at line 37 of file LowPtGsfElectronIDProducer.h.

Referenced by LowPtGsfElectronIDProducer(), and produce().

const bool LowPtGsfElectronIDProducer::passThrough_
private

Definition at line 38 of file LowPtGsfElectronIDProducer.h.

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

Definition at line 36 of file LowPtGsfElectronIDProducer.h.

Referenced by produce().