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
 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 (const std::string &iProcessName, std::vector< const char * > &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

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
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 16 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::getParameter(), 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  produces<reco::GsfElectronCollection> (outputCollectionLabel_);
38 }
edm::EDGetTokenT< reco::GsfElectronCollection > previousGsfElectrons_
T getParameter(std::string const &) const
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > tokenElectronIsoVals_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
GEDGsfElectronFinalizer::~GEDGsfElectronFinalizer ( )

Definition at line 40 of file GEDGsfElectronFinalizer.cc.

41  {}

Member Function Documentation

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

Implements edm::stream::EDProducerBase.

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

45  {
46 
47  // Output collection
48  std::auto_ptr<reco::GsfElectronCollection> outputElectrons_p(new reco::GsfElectronCollection);
49 
50  // read input collections
51  // electrons
53  event.getByToken(previousGsfElectrons_,gedElectronHandle);
54 
55  // PFCandidates
57  event.getByToken(pfCandidates_,pfCandidateHandle);
58  // value maps
59  std::vector< edm::Handle< edm::ValueMap<double> > > isolationValueMaps(nDeps_);
60 
61  for(unsigned i=0; i < nDeps_ ; ++i) {
62  event.getByToken(tokenElectronIsoVals_[i],isolationValueMaps[i]);
63  }
64 
65  // prepare a map of PFCandidates having a valid GsfTrackRef to save time
66  std::map<reco::GsfTrackRef, const reco::PFCandidate* > gsfPFMap;
67  reco::PFCandidateCollection::const_iterator it = pfCandidateHandle->begin();
68  reco::PFCandidateCollection::const_iterator itend = pfCandidateHandle->end() ;
69  for(;it!=itend;++it) {
70  // First check that the GsfTrack is non null
71  if( it->gsfTrackRef().isNonnull()) {
72  if(abs(it->pdgId())==11) // consider only the electrons
73  gsfPFMap[it->gsfTrackRef()]=&(*it);
74  }
75  }
76 
77 
78  // Now loop on the electrons
79  unsigned nele=gedElectronHandle->size();
80  for(unsigned iele=0; iele<nele;++iele) {
81  reco::GsfElectronRef myElectronRef(gedElectronHandle,iele);
82 
83  reco::GsfElectron newElectron(*myElectronRef);
85  isoVariables.sumChargedHadronPt = (*(isolationValueMaps)[0])[myElectronRef];
86  isoVariables.sumPhotonEt = (*(isolationValueMaps)[1])[myElectronRef];
87  isoVariables.sumNeutralHadronEt = (*(isolationValueMaps)[2])[myElectronRef];
88  isoVariables.sumPUPt = (*(isolationValueMaps)[3])[myElectronRef];
89  newElectron.setPfIsolationVariables(isoVariables);
90 
91  // now set a status if not already done (in GEDGsfElectronProducer.cc)
92  // std::cout << " previous status " << newElectron.mvaOutput().status << std::endl;
93  if(newElectron.mvaOutput().status<=0) {
94  std::map<reco::GsfTrackRef, const reco::PFCandidate * >::const_iterator itcheck=gsfPFMap.find(newElectron.gsfTrack());
95  reco::GsfElectron::MvaOutput myMvaOutput(newElectron.mvaOutput());
96  if(itcheck!=gsfPFMap.end()) {
97  // it means that there is a PFCandidate with the same GsfTrack
98  myMvaOutput.status = 3; //as defined in PFCandidateEGammaExtra.h
99  newElectron.setPassPflowPreselection(true); //this is currently fully redundant with mvaOutput.stats so candidate for removal
100  }
101  else{
102  myMvaOutput.status = 4 ; //
103  newElectron.setPassPflowPreselection(false);//this is currently fully redundant with mvaOutput.stats so candidate for removal
104  }
105  newElectron.setMvaOutput(myMvaOutput);
106  }
107  outputElectrons_p->push_back(newElectron);
108  }
109 
110  event.put(outputElectrons_p,outputCollectionLabel_);
111  }
edm::EDGetTokenT< reco::GsfElectronCollection > previousGsfElectrons_
int i
Definition: DBlmapReader.cc:9
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > tokenElectronIsoVals_
float sumPUPt
sum pt of charged Particles not from PV (for Pu corrections)
Definition: GsfElectron.h:566
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
float sumPhotonEt
sum pt of PF photons // old float photonIso ;
Definition: GsfElectron.h:561
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float sumNeutralHadronEt
sum pt of neutral hadrons // old float neutralHadronIso ;
Definition: GsfElectron.h:560
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
float sumChargedHadronPt
sum-pt of charged Hadron // old float chargedHadronIso ;
Definition: GsfElectron.h:559

Member Data Documentation

unsigned GEDGsfElectronFinalizer::nDeps_
private

Definition at line 29 of file GEDGsfElectronFinalizer.h.

std::string GEDGsfElectronFinalizer::outputCollectionLabel_
private

Definition at line 27 of file GEDGsfElectronFinalizer.h.

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

Definition at line 26 of file GEDGsfElectronFinalizer.h.

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

Definition at line 25 of file GEDGsfElectronFinalizer.h.

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

Definition at line 28 of file GEDGsfElectronFinalizer.h.