CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
LowPtGsfElectronSeedValueMapsProducer Class Reference

#include <LowPtGsfElectronSeedValueMapsProducer.h>

Inheritance diagram for LowPtGsfElectronSeedValueMapsProducer:
edm::stream::EDProducer<>

Public Member Functions

 LowPtGsfElectronSeedValueMapsProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~LowPtGsfElectronSeedValueMapsProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 

Private Attributes

const edm::EDGetTokenT< reco::GsfTrackCollectiongsfTracks_
 
const std::vector< std::string > names_
 
const edm::EDGetTokenT< edm::ValueMap< reco::PreIdRef > > preIdsValueMap_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
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 13 of file LowPtGsfElectronSeedValueMapsProducer.h.

Constructor & Destructor Documentation

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

Definition at line 15 of file LowPtGsfElectronSeedValueMapsProducer.cc.

References Skims_PA_cff::name, and names_.

16  : gsfTracks_(consumes<reco::GsfTrackCollection>(conf.getParameter<edm::InputTag>("gsfTracks"))),
17  preIdsValueMap_(consumes<edm::ValueMap<reco::PreIdRef> >(conf.getParameter<edm::InputTag>("preIdsValueMap"))),
18  names_(conf.getParameter<std::vector<std::string> >("ModelNames")) {
19  for (const auto& name : names_) {
20  produces<edm::ValueMap<float> >(name);
21  }
22 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< reco::GsfTrackCollection > gsfTracks_
const edm::EDGetTokenT< edm::ValueMap< reco::PreIdRef > > preIdsValueMap_
LowPtGsfElectronSeedValueMapsProducer::~LowPtGsfElectronSeedValueMapsProducer ( )
override

Definition at line 26 of file LowPtGsfElectronSeedValueMapsProducer.cc.

26 {}

Member Function Documentation

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

Definition at line 77 of file LowPtGsfElectronSeedValueMapsProducer.cc.

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

77  {
79  desc.add<edm::InputTag>("gsfTracks", edm::InputTag("lowPtGsfEleGsfTracks"));
80  desc.add<edm::InputTag>("preIdsValueMap", edm::InputTag("lowPtGsfElectronSeeds"));
81  desc.add<std::vector<std::string> >("ModelNames", {"unbiased", "ptbiased"});
82  descriptions.add("lowPtGsfElectronSeedValueMaps", desc);
83 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void LowPtGsfElectronSeedValueMapsProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
override

Definition at line 30 of file LowPtGsfElectronSeedValueMapsProducer.cc.

References begin, end, edm::helper::Filler< Map >::fill(), trigObjTnPSource_cfi::filler, ntupleEnum::gsf, ecalDrivenGsfElectronCoresFromMultiCl_cff::gsfTracks, gsfTracks_, edm::helper::Filler< Map >::insert(), edm::Ref< C, T, F >::isNonnull(), edm::HandleBase::isValid(), eostools::move(), names_, convertSQLitetoXML_cfg::output, preIdsValueMap_, and SurveyInfoScenario_cff::seed.

30  {
31  // Retrieve GsfTracks from Event
33  event.getByToken(gsfTracks_, gsfTracks);
34  if (!gsfTracks.isValid()) {
35  edm::LogError("Problem with gsfTracks handle");
36  }
37 
38  // Retrieve PreIds from Event
40  event.getByToken(preIdsValueMap_, preIdsValueMap);
41  if (!preIdsValueMap.isValid()) {
42  edm::LogError("Problem with preIdsValueMap handle");
43  }
44 
45  // Iterate through GsfTracks, extract BDT output, and store result in ValueMap for each model
46  std::vector<std::vector<float> > output;
47  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
48  output.push_back(std::vector<float>(gsfTracks->size(), -999.));
49  }
50  for (unsigned int igsf = 0; igsf < gsfTracks->size(); igsf++) {
51  reco::GsfTrackRef gsf(gsfTracks, igsf);
52  if (gsf.isNonnull() && gsf->extra().isNonnull() && gsf->extra()->seedRef().isNonnull()) {
53  reco::ElectronSeedRef seed = gsf->extra()->seedRef().castTo<reco::ElectronSeedRef>();
54  if (seed.isNonnull() && seed->ctfTrack().isNonnull()) {
55  const reco::PreIdRef preid = (*preIdsValueMap)[seed->ctfTrack()];
56  if (preid.isNonnull()) {
57  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
58  output[iname][igsf] = preid->mva(iname);
59  }
60  }
61  }
62  }
63  }
64 
65  // Create and put ValueMap in Event
66  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
67  auto ptr = std::make_unique<edm::ValueMap<float> >(edm::ValueMap<float>());
69  filler.insert(gsfTracks, output[iname].begin(), output[iname].end());
70  filler.fill();
71  event.put(std::move(ptr), names_[iname]);
72  }
73 }
const edm::EDGetTokenT< reco::GsfTrackCollection > gsfTracks_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
const edm::EDGetTokenT< edm::ValueMap< reco::PreIdRef > > preIdsValueMap_
#define end
Definition: vmac.h:39
bool isValid() const
Definition: HandleBase.h:70
#define begin
Definition: vmac.h:32
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

const edm::EDGetTokenT<reco::GsfTrackCollection> LowPtGsfElectronSeedValueMapsProducer::gsfTracks_
private

Definition at line 24 of file LowPtGsfElectronSeedValueMapsProducer.h.

Referenced by produce().

const std::vector<std::string> LowPtGsfElectronSeedValueMapsProducer::names_
private
const edm::EDGetTokenT<edm::ValueMap<reco::PreIdRef> > LowPtGsfElectronSeedValueMapsProducer::preIdsValueMap_
private

Definition at line 25 of file LowPtGsfElectronSeedValueMapsProducer.h.

Referenced by produce().