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.

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

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 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< edm::ValueMap< reco::PreIdRef > > preIdsValueMap_
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTracks_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > floatValueMaps_
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
edm::EDGetTokenT< reco::GsfElectronCollection > gsfElectrons_

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 143 of file LowPtGsfElectronSeedValueMapsProducer.cc.

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

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 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

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

Definition at line 70 of file LowPtGsfElectronSeedValueMapsProducer.cc.

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

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 }
edm::EDGetTokenT< edm::ValueMap< reco::PreIdRef > > preIdsValueMap_
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTracks_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > floatValueMaps_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:156
edm::EDGetTokenT< reco::GsfElectronCollection > gsfElectrons_
def move(src, dest)
Definition: eostools.py:511

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