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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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(), timingPdfMaker::get, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), and AlCaHLTBitMon_QueryRunRegistry::string.

17  {
19  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(
25  consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumChargedHadronPt")));
26  tokenElectronIsoVals_.push_back(
27  consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumPhotonEt")));
28  tokenElectronIsoVals_.push_back(
29  consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumNeutralHadronEt")));
30  tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumPUPt")));
31  tokenElectronIsoVals_.push_back(
32  consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumEcalClusterEt")));
33  tokenElectronIsoVals_.push_back(
34  consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumHcalClusterEt")));
35 
37 
38  if (cfg.existsAs<edm::ParameterSet>("regressionConfig")) {
39  const edm::ParameterSet& iconf = cfg.getParameterSet("regressionConfig");
40  const std::string& mname = iconf.getParameter<std::string>("modifierName");
41  auto cc = consumesCollector();
42  gedRegression_ = ModifyObjectValueFactory::get()->create(mname, iconf, cc);
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:160
std::unique_ptr< ModifyObjectValueBase > gedRegression_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > tokenElectronIsoVals_
ParameterSet const & getParameterSet(std::string const &) const
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
GEDGsfElectronFinalizer::~GEDGsfElectronFinalizer ( )
override

Definition at line 48 of file GEDGsfElectronFinalizer.cc.

48 {}

Member Function Documentation

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

Definition at line 51 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.

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

Member Data Documentation

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

Definition at line 30 of file GEDGsfElectronFinalizer.h.

unsigned GEDGsfElectronFinalizer::nDeps_
private

Definition at line 31 of file GEDGsfElectronFinalizer.h.

std::string GEDGsfElectronFinalizer::outputCollectionLabel_
private

Definition at line 28 of file GEDGsfElectronFinalizer.h.

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

Definition at line 27 of file GEDGsfElectronFinalizer.h.

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

Definition at line 26 of file GEDGsfElectronFinalizer.h.

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

Definition at line 29 of file GEDGsfElectronFinalizer.h.