CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
LowPtGsfElectronSeedValueMapsProducer Class Reference
Inheritance diagram for LowPtGsfElectronSeedValueMapsProducer:
edm::stream::EDProducer<>

Public Member Functions

 LowPtGsfElectronSeedValueMapsProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
- Public Member Functions inherited from edm::stream::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
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 

Private Attributes

std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > floatValueMaps_
 
edm::EDGetTokenT< reco::GsfElectronCollectiongsfElectrons_
 
edm::EDGetTokenT< reco::GsfTrackCollectiongsfTracks_
 
std::vector< std::string > names_
 
edm::EDGetTokenT< edm::ValueMap< reco::PreIdRef > > preIdsValueMap_
 
const bool rekey_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 23 of file LowPtGsfElectronSeedValueMapsProducer.cc.

Constructor & Destructor Documentation

◆ LowPtGsfElectronSeedValueMapsProducer()

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

Definition at line 42 of file LowPtGsfElectronSeedValueMapsProducer.cc.

43  : gsfTracks_(),
45  names_(),
46  rekey_(conf.getParameter<bool>("rekey")),
47  gsfElectrons_(),
48  floatValueMaps_() {
49  if (rekey_) {
50  gsfElectrons_ = consumes<reco::GsfElectronCollection>(conf.getParameter<edm::InputTag>("gsfElectrons"));
51  std::vector<edm::InputTag> tags = conf.getParameter<std::vector<edm::InputTag> >("floatValueMaps");
52  for (const auto& tag : tags) {
54  tags, [this](edm::InputTag const& tag) { return consumes<edm::ValueMap<float> >(tag); });
55  names_.push_back(tag.instance());
56  produces<edm::ValueMap<float> >(tag.instance());
57  }
58  } else {
59  gsfTracks_ = consumes<reco::GsfTrackCollection>(conf.getParameter<edm::InputTag>("gsfTracks"));
60  preIdsValueMap_ = consumes<edm::ValueMap<reco::PreIdRef> >(conf.getParameter<edm::InputTag>("preIdsValueMap"));
61  names_ = conf.getParameter<std::vector<std::string> >("ModelNames");
62  for (const auto& name : names_) {
63  produces<edm::ValueMap<float> >(name);
64  }
65  }
66 }

References floatValueMaps_, edm::ParameterSet::getParameter(), gsfElectrons_, gsfTracks_, Skims_PA_cff::name, names_, preIdsValueMap_, rekey_, makeGlobalPositionRcd_cfg::tag, triggerMatcherToHLTDebug_cfi::tags, and edm::vector_transform().

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 143 of file LowPtGsfElectronSeedValueMapsProducer.cc.

143  {
145  desc.add<edm::InputTag>("gsfTracks", edm::InputTag("lowPtGsfEleGsfTracks"));
146  desc.add<edm::InputTag>("preIdsValueMap", edm::InputTag("lowPtGsfElectronSeeds"));
147  desc.add<std::vector<std::string> >("ModelNames", {"unbiased", "ptbiased"});
148  desc.add<bool>("rekey", false);
149  desc.add<edm::InputTag>("gsfElectrons", edm::InputTag());
150  desc.add<std::vector<edm::InputTag> >("floatValueMaps", std::vector<edm::InputTag>());
151  descriptions.add("lowPtGsfElectronSeedValueMaps", desc);
152 }

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

◆ produce()

void LowPtGsfElectronSeedValueMapsProducer::produce ( edm::Event event,
const edm::EventSetup  
)
override

Definition at line 70 of file LowPtGsfElectronSeedValueMapsProducer.cc.

70  {
71  if (rekey_ == false) {
72  // TRANSFORM VALUEMAP OF PREID OBJECTS KEYED BY KF TRACK ...
73  // .. INTO VALUEMAP OF FLOATS (BDT SCORE) KEYED BY GSF TRACK ...
74 
75  // Retrieve GsfTracks from Event
76  auto gsfTracks = event.getHandle(gsfTracks_);
77 
78  // Retrieve PreIds from Event
79  auto preIdsValueMap = event.getHandle(preIdsValueMap_);
80 
81  // Iterate through GsfTracks, extract BDT output, and store result in ValueMap for each model
82  std::vector<std::vector<float> > output;
83  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
84  output.push_back(std::vector<float>(gsfTracks->size(), -999.));
85  }
86  auto const& gsfTracksV = *gsfTracks;
87  for (unsigned int igsf = 0; igsf < gsfTracksV.size(); igsf++) {
88  const reco::GsfTrack& gsf = gsfTracksV[igsf];
89  if (gsf.extra().isNonnull() && gsf.extra()->seedRef().isNonnull()) {
90  reco::ElectronSeedRef seed = gsf.extra()->seedRef().castTo<reco::ElectronSeedRef>();
91  if (seed.isNonnull() && seed->ctfTrack().isNonnull()) {
92  const reco::PreIdRef preid = (*preIdsValueMap)[seed->ctfTrack()];
93  if (preid.isNonnull()) {
94  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
95  output[iname][igsf] = preid->mva(iname);
96  }
97  }
98  }
99  }
100  }
101 
102  // Create and put ValueMap in Event
103  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
104  auto ptr = std::make_unique<edm::ValueMap<float> >(edm::ValueMap<float>());
106  filler.insert(gsfTracks, output[iname].begin(), output[iname].end());
107  filler.fill();
108  event.put(std::move(ptr), names_[iname]);
109  }
110 
111  } else {
112  // TRANSFORM VALUEMAP OF FLOATS (BDT SCORE) KEYED BY GSF TRACK ...
113  // .. INTO VALUEMAP OF FLOATS (BDT SCORE) KEYED BY GSF ELECTRON ...
114 
115  // Retrieve GsfElectrons from Event
116  auto gsfElectrons = event.getHandle(gsfElectrons_);
117 
118  // Retrieve float ValueMaps from Event
119  for (unsigned int idx = 0; idx < names_.size(); ++idx) {
120  // Extract ValueMap from Event
121  auto const& floatValueMap = event.get(floatValueMaps_[idx]);
122 
123  // Store BDT scores in vector
124  std::vector<float> output(gsfElectrons->size(), -99.);
125  auto const& gsfElectronsV = *gsfElectrons;
126  for (unsigned int iele = 0; iele < gsfElectronsV.size(); iele++) {
127  const reco::GsfElectron& ele = gsfElectronsV[iele];
129  output[iele] = floatValueMap[gsf];
130  }
131  // Create and put ValueMap in Event
132  auto ptr = std::make_unique<edm::ValueMap<float> >(edm::ValueMap<float>());
134  filler.insert(gsfElectrons, output.begin(), output.end());
135  filler.fill();
136  event.put(std::move(ptr), names_[idx]);
137  }
138  }
139 }

References mps_fire::end, trigObjTnPSource_cfi::filler, floatValueMaps_, ntupleEnum::gsf, electronIsolatorFromEffectiveArea_cfi::gsfElectrons, gsfElectrons_, reco::GsfElectron::gsfTrack(), ecalDrivenGsfElectronCoresFromMultiCl_cff::gsfTracks, gsfTracks_, heavyIonCSV_trainingSettings::idx, edm::Ref< C, T, F >::isNonnull(), eostools::move(), names_, convertSQLitetoXML_cfg::output, preIdsValueMap_, rekey_, and fileCollector::seed.

Member Data Documentation

◆ floatValueMaps_

std::vector<edm::EDGetTokenT<edm::ValueMap<float> > > LowPtGsfElectronSeedValueMapsProducer::floatValueMaps_
private

◆ gsfElectrons_

edm::EDGetTokenT<reco::GsfElectronCollection> LowPtGsfElectronSeedValueMapsProducer::gsfElectrons_
private

◆ gsfTracks_

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

◆ names_

std::vector<std::string> LowPtGsfElectronSeedValueMapsProducer::names_
private

◆ preIdsValueMap_

edm::EDGetTokenT<edm::ValueMap<reco::PreIdRef> > LowPtGsfElectronSeedValueMapsProducer::preIdsValueMap_
private

◆ rekey_

const bool LowPtGsfElectronSeedValueMapsProducer::rekey_
private
reco::GsfElectron::gsfTrack
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:164
LowPtGsfElectronSeedValueMapsProducer::preIdsValueMap_
edm::EDGetTokenT< edm::ValueMap< reco::PreIdRef > > preIdsValueMap_
Definition: LowPtGsfElectronSeedValueMapsProducer.cc:33
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
electronIsolatorFromEffectiveArea_cfi.gsfElectrons
gsfElectrons
Definition: electronIsolatorFromEffectiveArea_cfi.py:4
LowPtGsfElectronSeedValueMapsProducer::rekey_
const bool rekey_
Definition: LowPtGsfElectronSeedValueMapsProducer.cc:35
edm::Ref< ElectronSeedCollection >
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
fileCollector.seed
seed
Definition: fileCollector.py:127
reco::GsfTrack
Definition: GsfTrack.h:12
LowPtGsfElectronSeedValueMapsProducer::names_
std::vector< std::string > names_
Definition: LowPtGsfElectronSeedValueMapsProducer.cc:34
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
LowPtGsfElectronSeedValueMapsProducer::gsfElectrons_
edm::EDGetTokenT< reco::GsfElectronCollection > gsfElectrons_
Definition: LowPtGsfElectronSeedValueMapsProducer.cc:36
mps_fire.end
end
Definition: mps_fire.py:242
reco::GsfElectron
Definition: GsfElectron.h:35
ecalDrivenGsfElectronCoresFromMultiCl_cff.gsfTracks
gsfTracks
Definition: ecalDrivenGsfElectronCoresFromMultiCl_cff.py:4
edm::vector_transform
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
LowPtGsfElectronSeedValueMapsProducer::floatValueMaps_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > floatValueMaps_
Definition: LowPtGsfElectronSeedValueMapsProducer.cc:37
makeGlobalPositionRcd_cfg.tag
tag
Definition: makeGlobalPositionRcd_cfg.py:6
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
ntupleEnum.gsf
gsf
Definition: ntupleEnum.py:48
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ValueMap< float >
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
triggerMatcherToHLTDebug_cfi.tags
tags
Definition: triggerMatcherToHLTDebug_cfi.py:9
edm::helper::Filler
Definition: ValueMap.h:22
edm::InputTag
Definition: InputTag.h:15
LowPtGsfElectronSeedValueMapsProducer::gsfTracks_
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTracks_
Definition: LowPtGsfElectronSeedValueMapsProducer.cc:32