CMS 3D CMS Logo

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

#include <GEDGsfElectronFinalizer.h>

Inheritance diagram for GEDGsfElectronFinalizer:
edm::stream::EDProducer<>

Public Member Functions

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

Private Attributes

std::unique_ptr< ModifyObjectValueBasegedRegression_
 
unsigned nDeps_
 
std::string outputCollectionLabel_
 
edm::EDGetTokenT< reco::PFCandidateCollectionpfCandidates_
 
edm::EDGetTokenT< reco::GsfElectronCollectionpreviousGsfElectrons_
 
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > tokenElectronIsoVals_
 

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 18 of file GEDGsfElectronFinalizer.h.

Constructor & Destructor Documentation

GEDGsfElectronFinalizer::GEDGsfElectronFinalizer ( const edm::ParameterSet cfg)
explicit

Definition at line 17 of file GEDGsfElectronFinalizer.cc.

References edm::ParameterSet::existsAs(), reco::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), fwrapper::plugin, and AlCaHLTBitMon_QueryRunRegistry::string.

18  {
19  previousGsfElectrons_ = consumes<reco::GsfElectronCollection>(cfg.getParameter<edm::InputTag>("previousGsfElectronsTag"));
20  pfCandidates_ = consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("pfCandidatesTag"));
21  outputCollectionLabel_ = cfg.getParameter<std::string>("outputCollectionLabel");
22  edm::ParameterSet pfIsoVals(cfg.getParameter<edm::ParameterSet> ("pfIsolationValues"));
23 
24  tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumChargedHadronPt")));
25  tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumPhotonEt")));
26  tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumNeutralHadronEt")));
27  tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumPUPt")));
28  tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumEcalClusterEt")));
29  tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumHcalClusterEt")));
30 
32 
33  if( cfg.existsAs<edm::ParameterSet>("regressionConfig") ) {
34  const edm::ParameterSet& iconf = cfg.getParameterSet("regressionConfig");
35  const std::string& mname = iconf.getParameter<std::string>("modifierName");
37  ModifyObjectValueFactory::get()->create(mname,iconf);
38  gedRegression_.reset(plugin);
39  edm::ConsumesCollector sumes = consumesCollector();
40  gedRegression_->setConsumes(sumes);
41  } else {
42  gedRegression_.reset(nullptr);
43  }
44 
45  produces<reco::GsfElectronCollection> (outputCollectionLabel_);
46 }
edm::EDGetTokenT< reco::GsfElectronCollection > previousGsfElectrons_
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:185
std::unique_ptr< ModifyObjectValueBase > gedRegression_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > tokenElectronIsoVals_
unique_ptr< JetDefinition::Plugin > plugin
ParameterSet const & getParameterSet(std::string const &) const
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
T get(const Candidate &c)
Definition: component.h:55
GEDGsfElectronFinalizer::~GEDGsfElectronFinalizer ( )
override

Definition at line 48 of file GEDGsfElectronFinalizer.cc.

49  {}

Member Function Documentation

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

Definition at line 52 of file GEDGsfElectronFinalizer.cc.

References funct::abs(), reco::GsfElectron::gsfTrack(), mps_fire::i, eostools::move(), reco::GsfElectron::mvaOutput(), reco::GsfElectron::setMvaOutput(), reco::GsfElectron::setPassPflowPreselection(), reco::GsfElectron::setPfIsolationVariables(), reco::GsfElectron::MvaOutput::status, reco::GsfElectron::PflowIsolationVariables::sumChargedHadronPt, reco::GsfElectron::PflowIsolationVariables::sumEcalClusterEt, reco::GsfElectron::PflowIsolationVariables::sumHcalClusterEt, reco::GsfElectron::PflowIsolationVariables::sumNeutralHadronEt, reco::GsfElectron::PflowIsolationVariables::sumPhotonEt, and reco::GsfElectron::PflowIsolationVariables::sumPUPt.

53  {
54 
55  // Output collection
56  auto outputElectrons_p = std::make_unique<reco::GsfElectronCollection>();
57 
58  if( gedRegression_ ) {
59  gedRegression_->setEvent(event);
60  gedRegression_->setEventContent(setup);
61  }
62 
63  // read input collections
64  // electrons
66  event.getByToken(previousGsfElectrons_,gedElectronHandle);
67 
68  // PFCandidates
70  event.getByToken(pfCandidates_,pfCandidateHandle);
71  // value maps
72  std::vector< edm::Handle< edm::ValueMap<float> > > isolationValueMaps(nDeps_);
73 
74  for(unsigned i=0; i < nDeps_ ; ++i) {
75  event.getByToken(tokenElectronIsoVals_[i],isolationValueMaps[i]);
76  }
77 
78  // prepare a map of PFCandidates having a valid GsfTrackRef to save time
79  std::map<reco::GsfTrackRef, const reco::PFCandidate* > gsfPFMap;
80  reco::PFCandidateCollection::const_iterator it = pfCandidateHandle->begin();
81  reco::PFCandidateCollection::const_iterator itend = pfCandidateHandle->end() ;
82  for(;it!=itend;++it) {
83  // First check that the GsfTrack is non null
84  if( it->gsfTrackRef().isNonnull()) {
85  if(abs(it->pdgId())==11) // consider only the electrons
86  gsfPFMap[it->gsfTrackRef()]=&(*it);
87  }
88  }
89 
90 
91  // Now loop on the electrons
92  unsigned nele=gedElectronHandle->size();
93  for(unsigned iele=0; iele<nele;++iele) {
94  reco::GsfElectronRef myElectronRef(gedElectronHandle,iele);
95 
96  reco::GsfElectron newElectron(*myElectronRef);
98  isoVariables.sumChargedHadronPt = (*(isolationValueMaps)[0])[myElectronRef];
99  isoVariables.sumPhotonEt = (*(isolationValueMaps)[1])[myElectronRef];
100  isoVariables.sumNeutralHadronEt = (*(isolationValueMaps)[2])[myElectronRef];
101  isoVariables.sumPUPt = (*(isolationValueMaps)[3])[myElectronRef];
102  isoVariables.sumEcalClusterEt = (*(isolationValueMaps)[4])[myElectronRef];
103  isoVariables.sumHcalClusterEt = (*(isolationValueMaps)[5])[myElectronRef];
104 
105  newElectron.setPfIsolationVariables(isoVariables);
106 
107  // now set a status if not already done (in GEDGsfElectronProducer.cc)
108  // std::cout << " previous status " << newElectron.mvaOutput().status << std::endl;
109  if(newElectron.mvaOutput().status<=0) {
110  std::map<reco::GsfTrackRef, const reco::PFCandidate * >::const_iterator itcheck=gsfPFMap.find(newElectron.gsfTrack());
111  reco::GsfElectron::MvaOutput myMvaOutput(newElectron.mvaOutput());
112  if(itcheck!=gsfPFMap.end()) {
113  // it means that there is a PFCandidate with the same GsfTrack
114  myMvaOutput.status = 3; //as defined in PFCandidateEGammaExtra.h
115  newElectron.setPassPflowPreselection(true); //this is currently fully redundant with mvaOutput.stats so candidate for removal
116  }
117  else{
118  myMvaOutput.status = 4 ; //
119  newElectron.setPassPflowPreselection(false);//this is currently fully redundant with mvaOutput.stats so candidate for removal
120  }
121  newElectron.setMvaOutput(myMvaOutput);
122  }
123 
124  if( gedRegression_ ) {
125  gedRegression_->modifyObject(newElectron);
126  }
127  outputElectrons_p->push_back(newElectron);
128  }
129 
130  event.put(std::move(outputElectrons_p),outputCollectionLabel_);
131  }
edm::EDGetTokenT< reco::GsfElectronCollection > previousGsfElectrons_
std::unique_ptr< ModifyObjectValueBase > gedRegression_
float sumPUPt
sum pt of charged Particles not from PV (for Pu corrections)
Definition: GsfElectron.h:636
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > tokenElectronIsoVals_
float sumPhotonEt
sum pt of PF photons // old float photonIso ;
Definition: GsfElectron.h:631
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float sumNeutralHadronEt
sum pt of neutral hadrons // old float neutralHadronIso ;
Definition: GsfElectron.h:630
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
float sumChargedHadronPt
sum-pt of charged Hadron // old float chargedHadronIso ;
Definition: GsfElectron.h:629
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

std::unique_ptr<ModifyObjectValueBase> GEDGsfElectronFinalizer::gedRegression_
private

Definition at line 31 of file GEDGsfElectronFinalizer.h.

unsigned GEDGsfElectronFinalizer::nDeps_
private

Definition at line 32 of file GEDGsfElectronFinalizer.h.

std::string GEDGsfElectronFinalizer::outputCollectionLabel_
private

Definition at line 29 of file GEDGsfElectronFinalizer.h.

edm::EDGetTokenT<reco::PFCandidateCollection> GEDGsfElectronFinalizer::pfCandidates_
private

Definition at line 28 of file GEDGsfElectronFinalizer.h.

edm::EDGetTokenT<reco::GsfElectronCollection> GEDGsfElectronFinalizer::previousGsfElectrons_
private

Definition at line 27 of file GEDGsfElectronFinalizer.h.

std::vector<edm::EDGetTokenT<edm::ValueMap<float> > > GEDGsfElectronFinalizer::tokenElectronIsoVals_
private

Definition at line 30 of file GEDGsfElectronFinalizer.h.