CMS 3D CMS Logo

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

#include <GEDGsfElectronProducer.h>

Inheritance diagram for GEDGsfElectronProducer:
GsfElectronBaseProducer edm::stream::EDProducer< edm::GlobalCache< gsfAlgoHelpers::HeavyObjectCache > >

Public Member Functions

 GEDGsfElectronProducer (const edm::ParameterSet &, const gsfAlgoHelpers::HeavyObjectCache *)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~GEDGsfElectronProducer () override
 
- Public Member Functions inherited from GsfElectronBaseProducer
 GsfElectronBaseProducer (const edm::ParameterSet &, const gsfAlgoHelpers::HeavyObjectCache *)
 
 ~GsfElectronBaseProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< gsfAlgoHelpers::HeavyObjectCache > >
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

void fillGsfElectronValueMap (edm::Event &event, edm::ValueMap< reco::GsfElectronRef >::Filler &filler)
 
void matchWithPFCandidates (edm::Event &event)
 

Private Attributes

edm::EDGetTokenT< reco::PFCandidateCollectionegmPFCandidateCollection_
 
std::map< reco::GsfTrackRef, reco::GsfElectron::MvaInputgsfMVAInputMap_
 
std::map< reco::GsfTrackRef, reco::GsfElectron::MvaOutputgsfMVAOutputMap_
 
std::string outputValueMapLabel_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< gsfAlgoHelpers::HeavyObjectCache > >
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
 
- Static Public Member Functions inherited from GsfElectronBaseProducer
static void fillDescription (edm::ParameterSetDescription &)
 
static void globalEndJob (gsfAlgoHelpers::HeavyObjectCache const *)
 
static std::unique_ptr< gsfAlgoHelpers::HeavyObjectCacheinitializeGlobalCache (const edm::ParameterSet &conf)
 
- Protected Member Functions inherited from GsfElectronBaseProducer
void beginEvent (edm::Event &, const edm::EventSetup &)
 
void endEvent ()
 
void fillEvent (edm::Event &)
 
reco::GsfElectronnewElectron ()
 
const edm::OrphanHandle< reco::GsfElectronCollection > & orphanHandle () const
 
- Protected Attributes inherited from GsfElectronBaseProducer
GsfElectronAlgoalgo_
 
GsfElectronAlgo::CutsConfiguration cutsCfg_
 
GsfElectronAlgo::CutsConfiguration cutsCfgPflow_
 
ElectronHcalHelper::Configuration hcalCfg_
 
ElectronHcalHelper::Configuration hcalCfgPflow_
 
GsfElectronAlgo::InputTagsConfiguration inputCfg_
 
ElectronMVAEstimator::Configuration mva_Iso_Cfg_
 
SoftElectronMVAEstimator::Configuration mva_NIso_Cfg_
 
GsfElectronAlgo::StrategyConfiguration strategyCfg_
 

Detailed Description

Definition at line 9 of file GEDGsfElectronProducer.h.

Constructor & Destructor Documentation

GEDGsfElectronProducer::GEDGsfElectronProducer ( const edm::ParameterSet cfg,
const gsfAlgoHelpers::HeavyObjectCache hoc 
)
explicit

Definition at line 31 of file GEDGsfElectronProducer.cc.

References egmPFCandidateCollection_, edm::ParameterSet::getParameter(), outputValueMapLabel_, and AlCaHLTBitMon_QueryRunRegistry::string.

32  : GsfElectronBaseProducer(cfg,hoc)
33  {
34  egmPFCandidateCollection_ = consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("egmPFCandidatesTag"));
35  outputValueMapLabel_ = cfg.getParameter<std::string>("outputEGMPFValueMap");
36 
37  produces<edm::ValueMap<reco::GsfElectronRef> >(outputValueMapLabel_);
38 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::PFCandidateCollection > egmPFCandidateCollection_
GsfElectronBaseProducer(const edm::ParameterSet &, const gsfAlgoHelpers::HeavyObjectCache *)
GEDGsfElectronProducer::~GEDGsfElectronProducer ( )
override

Definition at line 40 of file GEDGsfElectronProducer.cc.

41  {}

Member Function Documentation

void GEDGsfElectronProducer::fillGsfElectronValueMap ( edm::Event event,
edm::ValueMap< reco::GsfElectronRef >::Filler &  filler 
)
private

Definition at line 64 of file GEDGsfElectronProducer.cc.

References begin, egmPFCandidateCollection_, end, runEdmFileComparison::found, edm::helper::Filler< Map >::insert(), GsfElectronBaseProducer::orphanHandle(), slimmedMuons_cfi::pfCandidates, and MuonErrorMatrixValues_cff::values.

Referenced by produce().

65 {
66  // Read the collection of PFCandidates
68 
69  bool found = event.getByToken(egmPFCandidateCollection_, pfCandidates);
70  if(!found) {
71  edm::LogError("GEDGsfElectronProducer")
72  <<" cannot get PFCandidates! ";
73  }
74 
75  //Loop over the collection of PFFCandidates
76  reco::PFCandidateCollection::const_iterator it = pfCandidates->begin();
77  reco::PFCandidateCollection::const_iterator itend = pfCandidates->end() ;
78  std::vector<reco::GsfElectronRef> values;
79 
80  for ( ; it != itend ; ++it) {
82  // First check that the GsfTrack is non null
83  if( it->gsfTrackRef().isNonnull()) {
84  // now look for the corresponding GsfElectron
85  GsfElectronEqual myEqual(it->gsfTrackRef());
86  const reco::GsfElectronCollection::const_iterator itcheck=
87  std::find_if(orphanHandle()->begin(),orphanHandle()->end(),myEqual);
88  if (itcheck != orphanHandle()->end()) {
89  // Build the Ref from the handle and the index
90  myRef = reco::GsfElectronRef(orphanHandle(),itcheck-orphanHandle()->begin());
91  }
92  }
93  values.push_back(myRef);
94  }
95  filler.insert(pfCandidates,values.begin(),values.end());
96 }
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
#define end
Definition: vmac.h:39
edm::EDGetTokenT< reco::PFCandidateCollection > egmPFCandidateCollection_
edm::Ref< GsfElectronCollection > GsfElectronRef
reference to an object in a collection of GsfElectron objects
const edm::OrphanHandle< reco::GsfElectronCollection > & orphanHandle() const
#define begin
Definition: vmac.h:32
void GEDGsfElectronProducer::matchWithPFCandidates ( edm::Event event)
private

Definition at line 102 of file GEDGsfElectronProducer.cc.

References reco::GsfElectron::MvaInput::deltaEta, reco::GsfElectron::MvaInput::earlyBrem, egmPFCandidateCollection_, runEdmFileComparison::found, gsfMVAInputMap_, gsfMVAOutputMap_, reco::GsfElectron::MvaInput::hadEnergy, reco::GsfElectron::MvaInput::lateBrem, reco::PFCandidateEGammaExtra::MVA_DeltaEtaTrackCluster, reco::PFCandidateEGammaExtra::MVA_FirstBrem, reco::PFCandidateEGammaExtra::MVA_LateBrem, slimmedMuons_cfi::pfCandidates, reco::GsfElectron::MvaInput::sigmaEtaEta, and reco::GsfElectron::MvaOutput::status.

Referenced by produce().

103 {
104  gsfMVAInputMap_.clear();
105  gsfMVAOutputMap_.clear();
106 
107  // Read the collection of PFCandidates
109 
110  bool found = event.getByToken(egmPFCandidateCollection_, pfCandidates);
111  if(!found) {
112  edm::LogError("GEDGsfElectronProducer")
113  <<" cannot get PFCandidates! ";
114  }
115 
116  //Loop over the collection of PFFCandidates
117  reco::PFCandidateCollection::const_iterator it = pfCandidates->begin();
118  reco::PFCandidateCollection::const_iterator itend = pfCandidates->end() ;
119 
120  for ( ; it != itend ; ++it) {
121  reco::GsfElectronRef myRef;
122  // First check that the GsfTrack is non null
123  if( it->gsfTrackRef().isNonnull()) {
124 
125  reco::GsfElectron::MvaOutput myMvaOutput;
126  // at the moment, undefined
127  myMvaOutput.status = it->egammaExtraRef()->electronStatus() ;
128  gsfMVAOutputMap_[it->gsfTrackRef()] = myMvaOutput;
129 
130  reco::GsfElectron::MvaInput myMvaInput;
131  myMvaInput.earlyBrem = it->egammaExtraRef()->mvaVariable(reco::PFCandidateEGammaExtra::MVA_FirstBrem);
132  myMvaInput.lateBrem = it->egammaExtraRef()->mvaVariable(reco::PFCandidateEGammaExtra::MVA_LateBrem);
133  myMvaInput.deltaEta = it->egammaExtraRef()->mvaVariable(reco::PFCandidateEGammaExtra::MVA_DeltaEtaTrackCluster);
134  myMvaInput.sigmaEtaEta = it->egammaExtraRef()->sigmaEtaEta();
135  myMvaInput.hadEnergy = it->egammaExtraRef()->hadEnergy();
136  gsfMVAInputMap_[it->gsfTrackRef()] = myMvaInput;
137  }
138  }
139 }
edm::EDGetTokenT< reco::PFCandidateCollection > egmPFCandidateCollection_
std::map< reco::GsfTrackRef, reco::GsfElectron::MvaOutput > gsfMVAOutputMap_
std::map< reco::GsfTrackRef, reco::GsfElectron::MvaInput > gsfMVAInputMap_
void GEDGsfElectronProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
override

Definition at line 44 of file GEDGsfElectronProducer.cc.

References GsfElectronBaseProducer::algo_, GsfElectronBaseProducer::beginEvent(), GsfElectronAlgo::completeElectrons(), GsfElectronBaseProducer::endEvent(), GsfElectronBaseProducer::fillEvent(), fillGsfElectronValueMap(), gsfMVAInputMap_, gsfMVAOutputMap_, matchWithPFCandidates(), eostools::move(), outputValueMapLabel_, GsfElectronAlgo::setMVAInputs(), and GsfElectronAlgo::setMVAOutputs().

45  {
46  beginEvent(event,setup) ;
47  matchWithPFCandidates(event);
48  algo_->completeElectrons(globalCache()) ;
49  algo_->setMVAOutputs(globalCache(),gsfMVAOutputMap_);
51  fillEvent(event) ;
52 
53  // ValueMap
54  auto valMap_p = std::make_unique<edm::ValueMap<reco::GsfElectronRef>>();
55  edm::ValueMap<reco::GsfElectronRef>::Filler valMapFiller(*valMap_p);
56  fillGsfElectronValueMap(event,valMapFiller);
57  valMapFiller.fill();
58  event.put(std::move(valMap_p),outputValueMapLabel_);
59  // Done with the ValueMap
60 
61  endEvent() ;
62  }
void matchWithPFCandidates(edm::Event &event)
void setMVAOutputs(const gsfAlgoHelpers::HeavyObjectCache *, const std::map< reco::GsfTrackRef, reco::GsfElectron::MvaOutput > &mvaOutputs)
void setMVAInputs(const std::map< reco::GsfTrackRef, reco::GsfElectron::MvaInput > &mvaInputs)
void completeElectrons(const gsfAlgoHelpers::HeavyObjectCache *)
void fillGsfElectronValueMap(edm::Event &event, edm::ValueMap< reco::GsfElectronRef >::Filler &filler)
std::map< reco::GsfTrackRef, reco::GsfElectron::MvaOutput > gsfMVAOutputMap_
void beginEvent(edm::Event &, const edm::EventSetup &)
def move(src, dest)
Definition: eostools.py:510
std::map< reco::GsfTrackRef, reco::GsfElectron::MvaInput > gsfMVAInputMap_

Member Data Documentation

edm::EDGetTokenT<reco::PFCandidateCollection> GEDGsfElectronProducer::egmPFCandidateCollection_
private
std::map<reco::GsfTrackRef,reco::GsfElectron::MvaInput> GEDGsfElectronProducer::gsfMVAInputMap_
private

Definition at line 22 of file GEDGsfElectronProducer.h.

Referenced by matchWithPFCandidates(), and produce().

std::map<reco::GsfTrackRef,reco::GsfElectron::MvaOutput> GEDGsfElectronProducer::gsfMVAOutputMap_
private

Definition at line 23 of file GEDGsfElectronProducer.h.

Referenced by matchWithPFCandidates(), and produce().

std::string GEDGsfElectronProducer::outputValueMapLabel_
private

Definition at line 21 of file GEDGsfElectronProducer.h.

Referenced by GEDGsfElectronProducer(), and produce().