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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 GEDGsfElectronFinalizer (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~GEDGsfElectronFinalizer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 // std::vector<std::string> isoNames = pfIsoVals.getParameterNamesForType<edm::InputTag>();
29 // for(const std::string& name : isoNames) {
30 // edm::InputTag tag =
31 // pfIsoVals.getParameter<edm::InputTag>(name);
32 // tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<double> >(tag));
33 // }
34 
36 
37  if( cfg.existsAs<edm::ParameterSet>("regressionConfig") ) {
38  const edm::ParameterSet& iconf = cfg.getParameterSet("regressionConfig");
39  const std::string& mname = iconf.getParameter<std::string>("modifierName");
41  ModifyObjectValueFactory::get()->create(mname,iconf);
42  gedRegression_.reset(plugin);
44  gedRegression_->setConsumes(sumes);
45  } else {
46  gedRegression_.reset(nullptr);
47  }
48 
49  produces<reco::GsfElectronCollection> (outputCollectionLabel_);
50 }
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:186
auto_ptr< JetDefinition::Plugin > plugin
std::unique_ptr< ModifyObjectValueBase > gedRegression_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > tokenElectronIsoVals_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
ParameterSet const & getParameterSet(std::string const &) const
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
T get(const Candidate &c)
Definition: component.h:55
GEDGsfElectronFinalizer::~GEDGsfElectronFinalizer ( )

Definition at line 52 of file GEDGsfElectronFinalizer.cc.

53  {}

Member Function Documentation

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

Definition at line 56 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::sumNeutralHadronEt, reco::GsfElectron::PflowIsolationVariables::sumPhotonEt, and reco::GsfElectron::PflowIsolationVariables::sumPUPt.

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

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.