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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

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<>
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 23 of file LowPtGsfElectronSeedValueMapsProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 42 of file LowPtGsfElectronSeedValueMapsProducer.cc.

References floatValueMaps_, edm::ParameterSet::getParameter(), gsfElectrons_, gsfTracks_, edm::InputTag::instance(), dataset::name, names_, preIdsValueMap_, rekey_, GlobalPosition_Frontier_DevDB_cff::tag, 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
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_
std::string const & instance() const
Definition: InputTag.h:37

Member Function Documentation

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

Definition at line 143 of file LowPtGsfElectronSeedValueMapsProducer.cc.

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

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 }
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  
)
override

Definition at line 70 of file LowPtGsfElectronSeedValueMapsProducer.cc.

References begin, end, reco::Track::extra(), edm::helper::Filler< Map >::fill(), objects.autophobj::filler, floatValueMaps_, ntupleEnum::gsf, gsfElectrons_cfi::gsfElectrons, gsfElectrons_, reco::GsfElectron::gsfTrack(), gedGsfElectronCores_cfi::gsfTracks, gsfTracks_, training_settings::idx, edm::helper::Filler< Map >::insert(), edm::Ref< C, T, F >::isNonnull(), eostools::move(), names_, convertSQLitetoXML_cfg::output, preIdsValueMap_, rekey_, and SurveyInfoScenario_cff::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];
128  reco::GsfTrackRef gsf = ele.gsfTrack();
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 }
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:186
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
const TrackExtraRef & extra() const
reference to "extra" object
Definition: Track.h:194
edm::EDGetTokenT< edm::ValueMap< reco::PreIdRef > > preIdsValueMap_
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTracks_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > floatValueMaps_
#define end
Definition: vmac.h:39
edm::EDGetTokenT< reco::GsfElectronCollection > gsfElectrons_
#define begin
Definition: vmac.h:32
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

std::vector<edm::EDGetTokenT<edm::ValueMap<float> > > LowPtGsfElectronSeedValueMapsProducer::floatValueMaps_
private
edm::EDGetTokenT<reco::GsfElectronCollection> LowPtGsfElectronSeedValueMapsProducer::gsfElectrons_
private
edm::EDGetTokenT<reco::GsfTrackCollection> LowPtGsfElectronSeedValueMapsProducer::gsfTracks_
private
std::vector<std::string> LowPtGsfElectronSeedValueMapsProducer::names_
private
edm::EDGetTokenT<edm::ValueMap<reco::PreIdRef> > LowPtGsfElectronSeedValueMapsProducer::preIdsValueMap_
private
const bool LowPtGsfElectronSeedValueMapsProducer::rekey_
private