test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

std::unique_ptr
< ModifyObjectValueBase
gedRegression_
 
unsigned nDeps_
 
std::string outputCollectionLabel_
 
edm::EDGetTokenT
< reco::PFCandidateCollection
pfCandidates_
 
edm::EDGetTokenT
< reco::GsfElectronCollection
previousGsfElectrons_
 
std::vector< edm::EDGetTokenT
< edm::ValueMap< double > > > 
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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
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<double> >(pfIsoVals.getParameter<edm::InputTag>("pfSumChargedHadronPt")));
25  tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<double> >(pfIsoVals.getParameter<edm::InputTag>("pfSumPhotonEt")));
26  tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<double> >(pfIsoVals.getParameter<edm::InputTag>("pfSumNeutralHadronEt")));
27  tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<double> >(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< double > > > 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

Implements edm::stream::EDProducerBase.

Definition at line 56 of file GEDGsfElectronFinalizer.cc.

References funct::abs(), reco::GsfElectron::gsfTrack(), i, 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  std::auto_ptr<reco::GsfElectronCollection> outputElectrons_p(new 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<double> > > 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(outputElectrons_p,outputCollectionLabel_);
132  }
edm::EDGetTokenT< reco::GsfElectronCollection > previousGsfElectrons_
int i
Definition: DBlmapReader.cc:9
std::unique_ptr< ModifyObjectValueBase > gedRegression_
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > tokenElectronIsoVals_
float sumPUPt
sum pt of charged Particles not from PV (for Pu corrections)
Definition: GsfElectron.h:580
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
float sumPhotonEt
sum pt of PF photons // old float photonIso ;
Definition: GsfElectron.h:575
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float sumNeutralHadronEt
sum pt of neutral hadrons // old float neutralHadronIso ;
Definition: GsfElectron.h:574
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
float sumChargedHadronPt
sum-pt of charged Hadron // old float chargedHadronIso ;
Definition: GsfElectron.h:573

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<double> > > GEDGsfElectronFinalizer::tokenElectronIsoVals_
private

Definition at line 30 of file GEDGsfElectronFinalizer.h.