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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 dataset::name, and names_.

15  :
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 {
20  for ( const auto& name : names_ ) { produces< edm::ValueMap<float> >(name); }
21 }
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 25 of file LowPtGsfElectronSeedValueMapsProducer.cc.

25 {}

Member Function Documentation

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

Definition at line 76 of file LowPtGsfElectronSeedValueMapsProducer.cc.

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

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",std::vector<std::string>());
82  descriptions.add("defaultLowPtGsfElectronSeedValueMaps",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 29 of file LowPtGsfElectronSeedValueMapsProducer.cc.

References begin, end, edm::helper::Filler< Map >::fill(), objects.autophobj::filler, ntupleEnum::gsf, gedGsfElectronCores_cfi::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.

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

Referenced by produce().