CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
GEDGsfElectronFinalizer Class Reference
Inheritance diagram for GEDGsfElectronFinalizer:
edm::stream::EDProducer<>

Public Member Functions

 GEDGsfElectronFinalizer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

std::unique_ptr< ModifyObjectValueBasegedRegression_
 
const edm::EDGetTokenT< reco::PFCandidateCollectionpfCandidates_
 
const edm::EDGetTokenT< reco::GsfElectronCollectionpreviousGsfElectrons_
 
const edm::EDPutTokenT< reco::GsfElectronCollectionputToken_
 
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > tokenElectronIsoVals_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 12 of file GEDGsfElectronFinalizer.cc.

Constructor & Destructor Documentation

◆ GEDGsfElectronFinalizer()

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

Definition at line 32 of file GEDGsfElectronFinalizer.cc.

33  : previousGsfElectrons_(consumes<GsfElectronCollection>(cfg.getParameter<InputTag>("previousGsfElectronsTag"))),
34  pfCandidates_(consumes<reco::PFCandidateCollection>(cfg.getParameter<InputTag>("pfCandidatesTag"))),
35  putToken_{produces<reco::GsfElectronCollection>()} {
36  edm::ParameterSet pfIsoVals(cfg.getParameter<edm::ParameterSet>("pfIsolationValues"));
37 
38  tokenElectronIsoVals_ = {consumes<ValueMap<float> >(pfIsoVals.getParameter<InputTag>("pfSumChargedHadronPt")),
39  consumes<ValueMap<float> >(pfIsoVals.getParameter<InputTag>("pfSumPhotonEt")),
40  consumes<ValueMap<float> >(pfIsoVals.getParameter<InputTag>("pfSumNeutralHadronEt")),
41  consumes<ValueMap<float> >(pfIsoVals.getParameter<InputTag>("pfSumPUPt")),
42  consumes<ValueMap<float> >(pfIsoVals.getParameter<InputTag>("pfSumEcalClusterEt")),
43  consumes<ValueMap<float> >(pfIsoVals.getParameter<InputTag>("pfSumHcalClusterEt"))};
44 
45  if (cfg.existsAs<edm::ParameterSet>("regressionConfig")) {
46  auto const& iconf = cfg.getParameterSet("regressionConfig");
47  auto const& mname = iconf.getParameter<std::string>("modifierName");
48  auto cc = consumesCollector();
49  gedRegression_ = ModifyObjectValueFactory::get()->create(mname, iconf, cc);
50  }
51 }

Member Function Documentation

◆ produce()

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

Definition at line 53 of file GEDGsfElectronFinalizer.cc.

53  {
54  // Output collection
55  reco::GsfElectronCollection outputElectrons;
56 
57  if (gedRegression_) {
58  gedRegression_->setEvent(event);
59  gedRegression_->setEventContent(setup);
60  }
61 
62  // read input collections
63  // electrons
64  auto gedElectronHandle = event.getHandle(previousGsfElectrons_);
65 
66  // PFCandidates
67  auto pfCandidateHandle = event.getHandle(pfCandidates_);
68  // value maps
69  std::vector<edm::ValueMap<float> const*> isolationValueMaps(tokenElectronIsoVals_.size());
70 
71  for (unsigned i = 0; i < tokenElectronIsoVals_.size(); ++i) {
72  isolationValueMaps[i] = &event.get(tokenElectronIsoVals_[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  for (auto const& pfCand : *pfCandidateHandle) {
78  // First check that the GsfTrack is non null
79  if (pfCand.gsfTrackRef().isNonnull()) {
80  if (abs(pfCand.pdgId()) == 11) // consider only the electrons
81  gsfPFMap[pfCand.gsfTrackRef()] = &pfCand;
82  }
83  }
84 
85  // Now loop on the electrons
86  unsigned nele = gedElectronHandle->size();
87  for (unsigned iele = 0; iele < nele; ++iele) {
88  reco::GsfElectronRef myElectronRef(gedElectronHandle, iele);
89 
90  reco::GsfElectron newElectron(*myElectronRef);
92  isoVariables.sumChargedHadronPt = (*(isolationValueMaps)[0])[myElectronRef];
93  isoVariables.sumPhotonEt = (*(isolationValueMaps)[1])[myElectronRef];
94  isoVariables.sumNeutralHadronEt = (*(isolationValueMaps)[2])[myElectronRef];
95  isoVariables.sumPUPt = (*(isolationValueMaps)[3])[myElectronRef];
96  isoVariables.sumEcalClusterEt = (*(isolationValueMaps)[4])[myElectronRef];
97  isoVariables.sumHcalClusterEt = (*(isolationValueMaps)[5])[myElectronRef];
98 
99  newElectron.setPfIsolationVariables(isoVariables);
100 
101  // now set a status if not already done (in GEDGsfElectronProducer.cc)
102  // std::cout << " previous status " << newElectron.mvaOutput().status << std::endl;
103  if (newElectron.mvaOutput().status <= 0) {
104  reco::GsfElectron::MvaOutput myMvaOutput(newElectron.mvaOutput());
105  if (gsfPFMap.find(newElectron.gsfTrack()) != gsfPFMap.end()) {
106  // it means that there is a PFCandidate with the same GsfTrack
107  myMvaOutput.status = 3; //as defined in PFCandidateEGammaExtra.h
108  //this is currently fully redundant with mvaOutput.stats so candidate for removal
109  newElectron.setPassPflowPreselection(true);
110  } else {
111  myMvaOutput.status = 4; //
112  //this is currently fully redundant with mvaOutput.stats so candidate for removal
113  newElectron.setPassPflowPreselection(false);
114  }
115  newElectron.setMvaOutput(myMvaOutput);
116  }
117 
118  if (gedRegression_) {
119  gedRegression_->modifyObject(newElectron);
120  }
121  outputElectrons.push_back(newElectron);
122  }
123 
124  event.emplace(putToken_, std::move(outputElectrons));
125 }

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

Member Data Documentation

◆ gedRegression_

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

Definition at line 22 of file GEDGsfElectronFinalizer.cc.

Referenced by produce().

◆ pfCandidates_

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

Definition at line 20 of file GEDGsfElectronFinalizer.cc.

Referenced by produce().

◆ previousGsfElectrons_

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

Definition at line 19 of file GEDGsfElectronFinalizer.cc.

Referenced by produce().

◆ putToken_

const edm::EDPutTokenT<reco::GsfElectronCollection> GEDGsfElectronFinalizer::putToken_
private

Definition at line 24 of file GEDGsfElectronFinalizer.cc.

Referenced by produce().

◆ tokenElectronIsoVals_

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

Definition at line 21 of file GEDGsfElectronFinalizer.cc.

Referenced by produce().

mps_fire.i
i
Definition: mps_fire.py:428
GEDGsfElectronFinalizer::tokenElectronIsoVals_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > tokenElectronIsoVals_
Definition: GEDGsfElectronFinalizer.cc:21
GEDGsfElectronFinalizer::gedRegression_
std::unique_ptr< ModifyObjectValueBase > gedRegression_
Definition: GEDGsfElectronFinalizer.cc:22
reco::GsfElectron::PflowIsolationVariables
Definition: GsfElectron.h:669
reco::GsfElectronCollection
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
Definition: GsfElectronFwd.h:14
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
edm::Ref
Definition: AssociativeIterator.h:58
reco::GsfElectron::PflowIsolationVariables::sumPhotonEt
float sumPhotonEt
sum pt of PF photons // old float photonIso ;
Definition: GsfElectron.h:673
reco::GsfElectron::PflowIsolationVariables::sumPUPt
float sumPUPt
sum pt of charged Particles not from PV (for Pu corrections)
Definition: GsfElectron.h:678
reco::GsfElectron
Definition: GsfElectron.h:35
GEDGsfElectronFinalizer::previousGsfElectrons_
const edm::EDGetTokenT< reco::GsfElectronCollection > previousGsfElectrons_
Definition: GEDGsfElectronFinalizer.cc:19
edm::ParameterSet
Definition: ParameterSet.h:47
GEDGsfElectronFinalizer::putToken_
const edm::EDPutTokenT< reco::GsfElectronCollection > putToken_
Definition: GEDGsfElectronFinalizer.cc:24
get
#define get
cc
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
GEDGsfElectronFinalizer::pfCandidates_
const edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
Definition: GEDGsfElectronFinalizer.cc:20
reco::GsfElectron::PflowIsolationVariables::sumNeutralHadronEt
float sumNeutralHadronEt
sum pt of neutral hadrons // old float neutralHadronIso ;
Definition: GsfElectron.h:672
looper.cfg
cfg
Definition: looper.py:296
reco::GsfElectron::MvaOutput::status
int status
Definition: GsfElectron.h:713
eostools.move
def move(src, dest)
Definition: eostools.py:511
reco::GsfElectron::PflowIsolationVariables::sumHcalClusterEt
float sumHcalClusterEt
Definition: GsfElectron.h:681
reco::GsfElectron::MvaOutput
Definition: GsfElectron.h:712
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
event
Definition: event.py:1
reco::GsfElectron::PflowIsolationVariables::sumEcalClusterEt
float sumEcalClusterEt
Definition: GsfElectron.h:680
edm::InputTag
Definition: InputTag.h:15
reco::GsfElectron::PflowIsolationVariables::sumChargedHadronPt
float sumChargedHadronPt
sum-pt of charged Hadron // old float chargedHadronIso ;
Definition: GsfElectron.h:671