CMS 3D CMS Logo

GEDGsfElectronFinalizer.cc
Go to the documentation of this file.
11 
13 public:
15 
16  void produce(edm::Event&, const edm::EventSetup&) override;
17 
18 private:
21  std::vector<edm::EDGetTokenT<edm::ValueMap<float> > > tokenElectronIsoVals_;
22  std::unique_ptr<ModifyObjectValueBase> gedRegression_;
23 
25 };
26 
27 using edm::InputTag;
28 using edm::ValueMap;
29 
31 
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 }
52 
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 }
126 
GEDGsfElectronFinalizer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: GEDGsfElectronFinalizer.cc:53
mps_fire.i
i
Definition: mps_fire.py:428
reco::GsfElectron::gsfTrack
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:164
MessageLogger.h
GEDGsfElectronFinalizer::tokenElectronIsoVals_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > tokenElectronIsoVals_
Definition: GEDGsfElectronFinalizer.cc:21
PFCandidate.h
GEDGsfElectronFinalizer::gedRegression_
std::unique_ptr< ModifyObjectValueBase > gedRegression_
Definition: GEDGsfElectronFinalizer.cc:22
edm::EDGetTokenT< reco::GsfElectronCollection >
edm::EDPutTokenT< reco::GsfElectronCollection >
reco::GsfElectron::PflowIsolationVariables
Definition: GsfElectron.h:669
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
EDProducer.h
reco::GsfElectronCollection
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
Definition: GsfElectronFwd.h:14
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
edm::Ref
Definition: AssociativeIterator.h:58
reco::GsfElectron::setPassPflowPreselection
void setPassPflowPreselection(bool flag)
Definition: GsfElectron.h:758
MakerMacros.h
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
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ModifyObjectValueBase.h
reco::GsfElectron
Definition: GsfElectron.h:35
ParameterSetDescription.h
GsfElectron.h
GEDGsfElectronFinalizer::previousGsfElectrons_
const edm::EDGetTokenT< reco::GsfElectronCollection > previousGsfElectrons_
Definition: GEDGsfElectronFinalizer.cc:19
edm::ParameterSet
Definition: ParameterSet.h:47
GEDGsfElectronFinalizer::GEDGsfElectronFinalizer
GEDGsfElectronFinalizer(const edm::ParameterSet &)
Definition: GEDGsfElectronFinalizer.cc:32
Event.h
GEDGsfElectronFinalizer
Definition: GEDGsfElectronFinalizer.cc:12
reco::GsfElectron::setPfIsolationVariables
void setPfIsolationVariables(const PflowIsolationVariables &iso)
Definition: GsfElectron.h:730
GEDGsfElectronFinalizer::putToken_
const edm::EDPutTokenT< reco::GsfElectronCollection > putToken_
Definition: GEDGsfElectronFinalizer.cc:24
reco::GsfElectron::setMvaOutput
void setMvaOutput(const MvaOutput &mo)
Definition: GsfElectron.h:732
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
cc
l1t::PFCandidateCollection
std::vector< l1t::PFCandidate > PFCandidateCollection
Definition: PFCandidate.h:57
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
ValueMap.h
reco::GsfElectron::MvaOutput::status
int status
Definition: GsfElectron.h:713
reco::GsfElectron::mvaOutput
const MvaOutput & mvaOutput() const
Definition: GsfElectron.h:727
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ValueMap
Definition: ValueMap.h:107
reco::GsfElectron::PflowIsolationVariables::sumHcalClusterEt
float sumHcalClusterEt
Definition: GsfElectron.h:681
reco::GsfElectron::MvaOutput
Definition: GsfElectron.h:712
EventSetup.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
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