CMS 3D CMS Logo

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

#include <GsfElectronProducer.h>

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

Public Member Functions

 GsfElectronProducer (const edm::ParameterSet &, const gsfAlgoHelpers::HeavyObjectCache *)
 
void produce (edm::Event &, const edm::EventSetup &) 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
 

Protected Member Functions

void beginEvent (edm::Event &, const edm::EventSetup &)
 
- Protected Member Functions inherited from GsfElectronBaseProducer
void beginEvent (edm::Event &, const edm::EventSetup &)
 
void fillEvent (reco::GsfElectronCollection &electrons, edm::Event &event)
 
const edm::OrphanHandle< reco::GsfElectronCollection > & orphanHandle () const
 

Private Member Functions

void addPflowInfo (reco::GsfElectronCollection &electrons, edm::Event const &event) const
 
void checkPfTranslatorParameters (edm::ParameterSet const &)
 
reco::GsfElectronCollection clonePreviousElectrons (edm::Event const &event) const
 
void setPflowPreselectionFlag (reco::GsfElectron &ele) const
 

Private Attributes

bool pfTranslatorParametersChecked_
 

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 fillDescriptions (edm::ConfigurationDescriptions &)
 
static void globalEndJob (gsfAlgoHelpers::HeavyObjectCache const *)
 
static std::unique_ptr< gsfAlgoHelpers::HeavyObjectCacheinitializeGlobalCache (const edm::ParameterSet &conf)
 
- Protected Attributes inherited from GsfElectronBaseProducer
GsfElectronAlgoalgo_
 
const GsfElectronAlgo::CutsConfiguration cutsCfg_
 
const GsfElectronAlgo::CutsConfiguration cutsCfgPflow_
 
ElectronHcalHelper::Configuration hcalCfg_
 
ElectronHcalHelper::Configuration hcalCfgPflow_
 
GsfElectronAlgo::InputTagsConfiguration inputCfg_
 
edm::EDGetTokenT< edm::ValueMap< float > > pfMVA_
 
GsfElectronAlgo::StrategyConfiguration strategyCfg_
 

Detailed Description

Definition at line 7 of file GsfElectronProducer.h.

Constructor & Destructor Documentation

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

Definition at line 26 of file GsfElectronProducer.cc.

28  {}
GsfElectronBaseProducer(const edm::ParameterSet &, const gsfAlgoHelpers::HeavyObjectCache *)

Member Function Documentation

void GsfElectronProducer::addPflowInfo ( reco::GsfElectronCollection electrons,
edm::Event const &  event 
) const
private

Definition at line 116 of file GsfElectronProducer.cc.

References GsfElectronAlgo::InputTagsConfiguration::edIsoVals, relativeConstraints::empty, edm::ParameterSet::empty(), Exception, runEdmFileComparison::found, edm::ParameterSet::getParameter(), GsfElectronBaseProducer::inputCfg_, gedGsfElectronFinalizer_cfi::pfIsolationValues, GsfElectronAlgo::InputTagsConfiguration::pfIsoVals, GsfElectronAlgo::InputTagsConfiguration::pflowGsfElectronsTag, GsfElectronAlgo::InputTagsConfiguration::previousGsfElectrons, setPflowPreselectionFlag(), reco::GsfElectron::PflowIsolationVariables::sumChargedHadronPt, reco::GsfElectron::PflowIsolationVariables::sumNeutralHadronEt, and reco::GsfElectron::PflowIsolationVariables::sumPhotonEt.

Referenced by produce().

117 {
118  //Isolation Value Maps for PF and EcalDriven electrons
119  typedef std::vector<edm::Handle<edm::ValueMap<double> > > IsolationValueMaps;
120  IsolationValueMaps pfIsolationValues;
121  IsolationValueMaps edIsolationValues;
122 
123  //Fill in the Isolation Value Maps for PF and EcalDriven electrons
124  std::vector<edm::InputTag> inputTagIsoVals;
125  if (!inputCfg_.pfIsoVals.empty()) {
126  inputTagIsoVals.push_back(inputCfg_.pfIsoVals.getParameter<edm::InputTag>("pfSumChargedHadronPt"));
127  inputTagIsoVals.push_back(inputCfg_.pfIsoVals.getParameter<edm::InputTag>("pfSumPhotonEt"));
128  inputTagIsoVals.push_back(inputCfg_.pfIsoVals.getParameter<edm::InputTag>("pfSumNeutralHadronEt"));
129 
130  pfIsolationValues.resize(inputTagIsoVals.size());
131 
132  for (size_t j = 0; j < inputTagIsoVals.size(); ++j) {
133  event.getByLabel(inputTagIsoVals[j], pfIsolationValues[j]);
134  }
135  }
136 
137  if (!inputCfg_.edIsoVals.empty()) {
138  inputTagIsoVals.clear();
139  inputTagIsoVals.push_back(inputCfg_.edIsoVals.getParameter<edm::InputTag>("edSumChargedHadronPt"));
140  inputTagIsoVals.push_back(inputCfg_.edIsoVals.getParameter<edm::InputTag>("edSumPhotonEt"));
141  inputTagIsoVals.push_back(inputCfg_.edIsoVals.getParameter<edm::InputTag>("edSumNeutralHadronEt"));
142 
143  edIsolationValues.resize(inputTagIsoVals.size());
144 
145  for (size_t j = 0; j < inputTagIsoVals.size(); ++j) {
146  event.getByLabel(inputTagIsoVals[j], edIsolationValues[j]);
147  }
148  }
149 
150  bool found;
151  auto edElectrons = event.getHandle(inputCfg_.previousGsfElectrons);
152  auto pfElectrons = event.getHandle(inputCfg_.pflowGsfElectronsTag);
153  reco::GsfElectronCollection::const_iterator pfElectron, edElectron;
154  unsigned int edIndex, pfIndex;
155 
156  for (auto& el : electrons) {
157  // Retreive info from pflow electrons
158  found = false;
159  for (pfIndex = 0, pfElectron = pfElectrons->begin(); pfElectron != pfElectrons->end(); pfIndex++, pfElectron++) {
160  if (pfElectron->gsfTrack() == el.gsfTrack()) {
161  if (found) {
162  edm::LogWarning("GsfElectronProducer") << "associated pfGsfElectron already found";
163  } else {
164  found = true;
165 
166  // Isolation Values
167  if (!(pfIsolationValues).empty()) {
168  reco::GsfElectronRef pfElectronRef(pfElectrons, pfIndex);
170  isoVariables.sumChargedHadronPt = (*(pfIsolationValues)[0])[pfElectronRef];
171  isoVariables.sumPhotonEt = (*(pfIsolationValues)[1])[pfElectronRef];
172  isoVariables.sumNeutralHadronEt = (*(pfIsolationValues)[2])[pfElectronRef];
173  el.setPfIsolationVariables(isoVariables);
174  }
175 
176  // el.setPfIsolationVariables(pfElectron->pfIsolationVariables()) ;
177  el.setMvaInput(pfElectron->mvaInput());
178  el.setMvaOutput(pfElectron->mvaOutput());
179  if (el.ecalDrivenSeed()) {
180  el.setP4(GsfElectron::P4_PFLOW_COMBINATION, pfElectron->p4(GsfElectron::P4_PFLOW_COMBINATION),
181  pfElectron->p4Error(GsfElectron::P4_PFLOW_COMBINATION), false);
182  } else {
183  el.setP4(GsfElectron::P4_PFLOW_COMBINATION, pfElectron->p4(GsfElectron::P4_PFLOW_COMBINATION),
184  pfElectron->p4Error(GsfElectron::P4_PFLOW_COMBINATION), true);
185  }
186  double noCutMin = -999999999.;
187  if (el.mva_e_pi() < noCutMin) {
188  throw cms::Exception("GsfElectronAlgo|UnexpectedMvaValue") << "unexpected MVA value: " << el.mva_e_pi();
189  }
190  }
191  }
192  }
193 
194  // Isolation Values
195  // Retreive not found info from ed electrons
196  if (!(edIsolationValues).empty()) {
197  edIndex = 0, edElectron = edElectrons->begin();
198  while ((found == false) && (edElectron != edElectrons->end())) {
199  if (edElectron->gsfTrack() == el.gsfTrack()) {
200  found = true;
201 
202  // CONSTRUCTION D UNE REF dans le handle previousElectrons avec l'indice edIndex,
203  // puis recuperation dans la ValueMap ED
204 
205  reco::GsfElectronRef edElectronRef(edElectrons, edIndex);
207  isoVariables.sumChargedHadronPt = (*(edIsolationValues)[0])[edElectronRef];
208  isoVariables.sumPhotonEt = (*(edIsolationValues)[1])[edElectronRef];
209  isoVariables.sumNeutralHadronEt = (*(edIsolationValues)[2])[edElectronRef];
210  el.setPfIsolationVariables(isoVariables);
211  }
212 
213  edIndex++;
214  edElectron++;
215  }
216  }
217 
218  // Preselection
220  }
221 }
T getParameter(std::string const &) const
bool empty() const
Definition: ParameterSet.h:191
edm::EDGetTokenT< reco::GsfElectronCollection > previousGsfElectrons
edm::EDGetTokenT< reco::GsfElectronCollection > pflowGsfElectronsTag
GsfElectronAlgo::InputTagsConfiguration inputCfg_
void setPflowPreselectionFlag(reco::GsfElectron &ele) const
float sumPhotonEt
sum pt of PF photons // old float photonIso ;
Definition: GsfElectron.h:641
float sumNeutralHadronEt
sum pt of neutral hadrons // old float neutralHadronIso ;
Definition: GsfElectron.h:640
float sumChargedHadronPt
sum-pt of charged Hadron // old float chargedHadronIso ;
Definition: GsfElectron.h:639
void GsfElectronProducer::beginEvent ( edm::Event event,
const edm::EventSetup setup 
)
protected

Definition at line 64 of file GsfElectronProducer.cc.

References GsfElectronBaseProducer::beginEvent(), checkPfTranslatorParameters(), edm::parameterSet(), GsfElectronBaseProducer::pfMVA_, pfTranslatorParametersChecked_, edm::HandleBase::provenance(), and funct::true.

65  {
66  // extra configuration checks
68  {
71  event.getByToken(pfMVA_,pfMva) ;
73  }
74 
75  // call to base class
76  return GsfElectronBaseProducer::beginEvent(event,setup) ;
77  }
void checkPfTranslatorParameters(edm::ParameterSet const &)
void beginEvent(edm::Event &, const edm::EventSetup &)
edm::EDGetTokenT< edm::ValueMap< float > > pfMVA_
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
Provenance const * provenance() const
Definition: HandleBase.h:83
void GsfElectronProducer::checkPfTranslatorParameters ( edm::ParameterSet const &  pset)
private

Definition at line 79 of file GsfElectronProducer.cc.

References GsfElectronAlgo::StrategyConfiguration::applyPreselection, GsfElectronBaseProducer::cutsCfg_, GsfElectronBaseProducer::cutsCfgPflow_, Exception, edm::ParameterSet::getParameter(), GsfElectronAlgo::CutsConfiguration::minMVA, and GsfElectronBaseProducer::strategyCfg_.

Referenced by beginEvent().

80  {
81  edm::ParameterSet mvaBlock = pset.getParameter<edm::ParameterSet>("MVACutBlock") ;
82  double pfTranslatorMinMva = mvaBlock.getParameter<double>("MVACut") ;
83  double pfTranslatorUndefined = -99. ;
84  if (strategyCfg_.applyPreselection&&(cutsCfgPflow_.minMVA<pfTranslatorMinMva))
85  {
86  // For pure tracker seeded electrons, if MVA is under translatorMinMva, there is no supercluster
87  // of any kind available, so GsfElectronCoreProducer has already discarded the electron.
88  edm::LogWarning("GsfElectronAlgo|MvaCutTooLow")
89  <<"Parameter minMVAPflow ("<<cutsCfgPflow_.minMVA<<") will have no effect on purely tracker seeded electrons."
90  <<" It is inferior to the cut already applied by PFlow translator ("<<pfTranslatorMinMva<<")." ;
91  }
92  if (strategyCfg_.applyPreselection&&(cutsCfg_.minMVA<pfTranslatorMinMva))
93  {
94  // For ecal seeded electrons, there is a cluster and GsfElectronCoreProducer has kept all electrons,
95  // but when MVA is under translatorMinMva, the translator has not stored the supercluster and
96  // forced the MVA value to translatorUndefined
97  if (cutsCfg_.minMVA>pfTranslatorUndefined)
98  {
99  edm::LogWarning("GsfElectronAlgo|IncompletePflowInformation")
100  <<"Parameter minMVA ("<<cutsCfg_.minMVA<<")is inferior to the cut applied by PFlow translator ("<<pfTranslatorMinMva<<")."
101  <<" Some ecal (and eventually tracker) seeded electrons may lack their MVA value and PFlow supercluster." ;
102  }
103  else
104  {
105  // the MVA value has been forced to translatorUndefined, inferior minMVAPflow
106  // so the cut actually applied is the PFlow one
107  throw cms::Exception("GsfElectronAlgo|BadMvaCut")
108  <<"Parameter minMVA is inferior to the lowest possible value."
109  <<" Every electron will be blessed whatever other criteria." ;
110  }
111  }
112  }
T getParameter(std::string const &) const
GsfElectronAlgo::StrategyConfiguration strategyCfg_
const GsfElectronAlgo::CutsConfiguration cutsCfgPflow_
const GsfElectronAlgo::CutsConfiguration cutsCfg_
reco::GsfElectronCollection GsfElectronProducer::clonePreviousElectrons ( edm::Event const &  event) const
private

Definition at line 31 of file GsfElectronProducer.cc.

References lowPtElectrons_cff::electrons, edm::Event::get(), GsfElectronAlgo::InputTagsConfiguration::gsfElectronCores, GsfElectronBaseProducer::inputCfg_, and GsfElectronAlgo::InputTagsConfiguration::previousGsfElectrons.

Referenced by produce().

32 {
34 
35  auto coreElectrons = event.getHandle(inputCfg_.gsfElectronCores);
36  const GsfElectronCoreCollection* newCores = coreElectrons.product();
37 
38  for (auto const& oldElectron : event.get(inputCfg_.previousGsfElectrons)) {
39  const GsfElectronCoreRef oldCoreRef = oldElectron.core();
40  const GsfTrackRef oldElectronGsfTrackRef = oldCoreRef->gsfTrack();
41  unsigned int icore;
42  for (icore = 0; icore < newCores->size(); ++icore) {
43  if (oldElectronGsfTrackRef == (*newCores)[icore].gsfTrack()) {
44  const GsfElectronCoreRef coreRef = edm::Ref<GsfElectronCoreCollection>(coreElectrons, icore);
45  electrons.emplace_back(oldElectron, coreRef);
46  break;
47  }
48  }
49  }
50  return electrons;
51 }
edm::EDGetTokenT< reco::GsfElectronCoreCollection > gsfElectronCores
edm::EDGetTokenT< reco::GsfElectronCollection > previousGsfElectrons
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
GsfElectronAlgo::InputTagsConfiguration inputCfg_
std::vector< GsfElectronCore > GsfElectronCoreCollection
Definition: event.py:1
void GsfElectronProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
override

Definition at line 54 of file GsfElectronProducer.cc.

References GsfElectronAlgo::StrategyConfiguration::addPflowElectrons, addPflowInfo(), GsfElectronBaseProducer::algo_, clonePreviousElectrons(), GsfElectronAlgo::completeElectrons(), lowPtElectrons_cff::electrons, GsfElectronBaseProducer::fillEvent(), and GsfElectronBaseProducer::strategyCfg_.

55  {
56  auto electrons = clonePreviousElectrons(event) ;
57  // don't add pflow only electrons if one so wish
59  { algo_->completeElectrons(electrons, event, setup, globalCache()) ; }
60  addPflowInfo(electrons, event) ;
61  fillEvent(electrons, event) ;
62  }
reco::GsfElectronCollection clonePreviousElectrons(edm::Event const &event) const
void fillEvent(reco::GsfElectronCollection &electrons, edm::Event &event)
void completeElectrons(reco::GsfElectronCollection &electrons, edm::Event const &event, edm::EventSetup const &eventSetup, const gsfAlgoHelpers::HeavyObjectCache *hoc)
void addPflowInfo(reco::GsfElectronCollection &electrons, edm::Event const &event) const
GsfElectronAlgo::StrategyConfiguration strategyCfg_
void GsfElectronProducer::setPflowPreselectionFlag ( reco::GsfElectron ele) const
private

Definition at line 224 of file GsfElectronProducer.cc.

References reco::GsfElectron::core(), GsfElectronBaseProducer::cutsCfg_, GsfElectronBaseProducer::cutsCfgPflow_, LogTrace, GsfElectronAlgo::CutsConfiguration::minMVA, reco::GsfElectron::MvaOutput::mva_e_pi, reco::GsfElectron::mvaOutput(), reco::GsfElectron::passingMvaPreselection(), reco::GsfElectron::setPassMvaPreselection(), and reco::GsfElectron::setPassPflowPreselection().

Referenced by addPflowInfo().

225 {
226  ele.setPassMvaPreselection(false);
227 
228  if (ele.core()->ecalDrivenSeed()) {
229  if (ele.mvaOutput().mva_e_pi >= cutsCfg_.minMVA)
230  ele.setPassMvaPreselection(true);
231  } else {
232  if (ele.mvaOutput().mva_e_pi >= cutsCfgPflow_.minMVA)
233  ele.setPassMvaPreselection(true);
234  }
235 
236  if (ele.passingMvaPreselection()) {
237  LogTrace("GsfElectronAlgo") << "Main mva criterion is satisfied";
238  }
239 
241 }
bool passingMvaPreselection() const
Definition: GsfElectron.h:735
void setPassMvaPreselection(bool flag)
Definition: GsfElectron.h:734
#define LogTrace(id)
const MvaOutput & mvaOutput() const
Definition: GsfElectron.h:693
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
void setPassPflowPreselection(bool flag)
Definition: GsfElectron.h:728
const GsfElectronAlgo::CutsConfiguration cutsCfgPflow_
const GsfElectronAlgo::CutsConfiguration cutsCfg_

Member Data Documentation

bool GsfElectronProducer::pfTranslatorParametersChecked_
private

Definition at line 25 of file GsfElectronProducer.h.

Referenced by beginEvent().