New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove redundant unique_ptr constructor calls from Reco #27194
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f92a9db
Remove redundant unique_ptr constructor calls from RecoEcal
makortel 94d207d
Remove redundant unique_ptr constructor calls from RecoEgamma
makortel 731eefa
Remove redundant unique_ptr constructor calls from RecoHGCal
makortel 6392cb7
Remove redundant unique_ptr constructor calls from RecoHI
makortel 4a8a7a1
Remove redundant unique_ptr constructor calls from RecoLocalCalo
makortel b1ca071
Remove redundant unique_ptr constructor calls from RecoLocalFastTime
makortel 19fa5d1
Remove redundant unique_ptr constructor calls from RecoLocalMuon
makortel d15c240
Remove redundant unique_ptr constructor calls from RecoMuon
makortel 4fd510f
Remove redundant unique_ptr constructor calls from RecoParticleFlow
makortel 795712e
Remove redundant unique_ptr constructor calls from RecoPixelVertexing
makortel 67c9759
Remove redundant unique_ptr constructor calls from RecoTauTag
makortel c44598e
Remove redundant unique_ptr constructor calls from RecoTracker
makortel 3f04b29
Remove redundant unique_ptr constructor calls from TrackingTools
makortel 1e8945a
Code format
makortel File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,115 +14,116 @@ | |
|
||
using namespace reco; | ||
|
||
GEDGsfElectronFinalizer::GEDGsfElectronFinalizer( const edm::ParameterSet & cfg ) | ||
{ | ||
previousGsfElectrons_ = consumes<reco::GsfElectronCollection>(cfg.getParameter<edm::InputTag>("previousGsfElectronsTag")); | ||
pfCandidates_ = consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("pfCandidatesTag")); | ||
outputCollectionLabel_ = cfg.getParameter<std::string>("outputCollectionLabel"); | ||
edm::ParameterSet pfIsoVals(cfg.getParameter<edm::ParameterSet> ("pfIsolationValues")); | ||
|
||
tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumChargedHadronPt"))); | ||
tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumPhotonEt"))); | ||
tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumNeutralHadronEt"))); | ||
tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumPUPt"))); | ||
tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumEcalClusterEt"))); | ||
tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumHcalClusterEt"))); | ||
|
||
nDeps_ = tokenElectronIsoVals_.size(); | ||
|
||
if( cfg.existsAs<edm::ParameterSet>("regressionConfig") ) { | ||
const edm::ParameterSet& iconf = cfg.getParameterSet("regressionConfig"); | ||
const std::string& mname = iconf.getParameter<std::string>("modifierName"); | ||
auto cc = consumesCollector(); | ||
gedRegression_ = ModifyObjectValueFactory::get()->create(mname,iconf,cc); | ||
} | ||
|
||
produces<reco::GsfElectronCollection> (outputCollectionLabel_); | ||
GEDGsfElectronFinalizer::GEDGsfElectronFinalizer(const edm::ParameterSet& cfg) { | ||
previousGsfElectrons_ = | ||
consumes<reco::GsfElectronCollection>(cfg.getParameter<edm::InputTag>("previousGsfElectronsTag")); | ||
pfCandidates_ = consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("pfCandidatesTag")); | ||
outputCollectionLabel_ = cfg.getParameter<std::string>("outputCollectionLabel"); | ||
edm::ParameterSet pfIsoVals(cfg.getParameter<edm::ParameterSet>("pfIsolationValues")); | ||
|
||
tokenElectronIsoVals_.push_back( | ||
consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumChargedHadronPt"))); | ||
tokenElectronIsoVals_.push_back( | ||
consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumPhotonEt"))); | ||
tokenElectronIsoVals_.push_back( | ||
consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumNeutralHadronEt"))); | ||
tokenElectronIsoVals_.push_back(consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumPUPt"))); | ||
tokenElectronIsoVals_.push_back( | ||
consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumEcalClusterEt"))); | ||
tokenElectronIsoVals_.push_back( | ||
consumes<edm::ValueMap<float> >(pfIsoVals.getParameter<edm::InputTag>("pfSumHcalClusterEt"))); | ||
|
||
nDeps_ = tokenElectronIsoVals_.size(); | ||
|
||
if (cfg.existsAs<edm::ParameterSet>("regressionConfig")) { | ||
const edm::ParameterSet& iconf = cfg.getParameterSet("regressionConfig"); | ||
const std::string& mname = iconf.getParameter<std::string>("modifierName"); | ||
auto cc = consumesCollector(); | ||
gedRegression_ = ModifyObjectValueFactory::get()->create(mname, iconf, cc); | ||
} | ||
|
||
produces<reco::GsfElectronCollection>(outputCollectionLabel_); | ||
} | ||
|
||
GEDGsfElectronFinalizer::~GEDGsfElectronFinalizer() | ||
{} | ||
GEDGsfElectronFinalizer::~GEDGsfElectronFinalizer() {} | ||
|
||
// ------------ method called to produce the data ------------ | ||
void GEDGsfElectronFinalizer::produce( edm::Event & event, const edm::EventSetup & setup ) | ||
{ | ||
|
||
// Output collection | ||
auto outputElectrons_p = std::make_unique<reco::GsfElectronCollection>(); | ||
|
||
if( gedRegression_ ) { | ||
gedRegression_->setEvent(event); | ||
gedRegression_->setEventContent(setup); | ||
} | ||
|
||
// read input collections | ||
// electrons | ||
edm::Handle<reco::GsfElectronCollection> gedElectronHandle; | ||
event.getByToken(previousGsfElectrons_,gedElectronHandle); | ||
|
||
// PFCandidates | ||
edm::Handle<reco::PFCandidateCollection> pfCandidateHandle; | ||
event.getByToken(pfCandidates_,pfCandidateHandle); | ||
// value maps | ||
std::vector< edm::Handle< edm::ValueMap<float> > > isolationValueMaps(nDeps_); | ||
|
||
for(unsigned i=0; i < nDeps_ ; ++i) { | ||
event.getByToken(tokenElectronIsoVals_[i],isolationValueMaps[i]); | ||
} | ||
|
||
// prepare a map of PFCandidates having a valid GsfTrackRef to save time | ||
std::map<reco::GsfTrackRef, const reco::PFCandidate* > gsfPFMap; | ||
reco::PFCandidateCollection::const_iterator it = pfCandidateHandle->begin(); | ||
reco::PFCandidateCollection::const_iterator itend = pfCandidateHandle->end() ; | ||
for(;it!=itend;++it) { | ||
// First check that the GsfTrack is non null | ||
if( it->gsfTrackRef().isNonnull()) { | ||
if(abs(it->pdgId())==11) // consider only the electrons | ||
gsfPFMap[it->gsfTrackRef()]=&(*it); | ||
} | ||
} | ||
|
||
|
||
// Now loop on the electrons | ||
unsigned nele=gedElectronHandle->size(); | ||
for(unsigned iele=0; iele<nele;++iele) { | ||
reco::GsfElectronRef myElectronRef(gedElectronHandle,iele); | ||
|
||
reco::GsfElectron newElectron(*myElectronRef); | ||
reco::GsfElectron::PflowIsolationVariables isoVariables; | ||
isoVariables.sumChargedHadronPt = (*(isolationValueMaps)[0])[myElectronRef]; | ||
isoVariables.sumPhotonEt = (*(isolationValueMaps)[1])[myElectronRef]; | ||
isoVariables.sumNeutralHadronEt = (*(isolationValueMaps)[2])[myElectronRef]; | ||
isoVariables.sumPUPt = (*(isolationValueMaps)[3])[myElectronRef]; | ||
isoVariables.sumEcalClusterEt = (*(isolationValueMaps)[4])[myElectronRef]; | ||
isoVariables.sumHcalClusterEt = (*(isolationValueMaps)[5])[myElectronRef]; | ||
|
||
newElectron.setPfIsolationVariables(isoVariables); | ||
|
||
// now set a status if not already done (in GEDGsfElectronProducer.cc) | ||
// std::cout << " previous status " << newElectron.mvaOutput().status << std::endl; | ||
if(newElectron.mvaOutput().status<=0) { | ||
std::map<reco::GsfTrackRef, const reco::PFCandidate * >::const_iterator itcheck=gsfPFMap.find(newElectron.gsfTrack()); | ||
reco::GsfElectron::MvaOutput myMvaOutput(newElectron.mvaOutput()); | ||
if(itcheck!=gsfPFMap.end()) { | ||
// it means that there is a PFCandidate with the same GsfTrack | ||
myMvaOutput.status = 3; //as defined in PFCandidateEGammaExtra.h | ||
newElectron.setPassPflowPreselection(true); //this is currently fully redundant with mvaOutput.stats so candidate for removal | ||
} | ||
else{ | ||
myMvaOutput.status = 4 ; // | ||
newElectron.setPassPflowPreselection(false);//this is currently fully redundant with mvaOutput.stats so candidate for removal | ||
} | ||
newElectron.setMvaOutput(myMvaOutput); | ||
} | ||
|
||
if( gedRegression_ ) { | ||
gedRegression_->modifyObject(newElectron); | ||
} | ||
outputElectrons_p->push_back(newElectron); | ||
} | ||
|
||
event.put(std::move(outputElectrons_p),outputCollectionLabel_); | ||
} | ||
|
||
|
||
void GEDGsfElectronFinalizer::produce(edm::Event& event, const edm::EventSetup& setup) { | ||
// Output collection | ||
auto outputElectrons_p = std::make_unique<reco::GsfElectronCollection>(); | ||
|
||
if (gedRegression_) { | ||
gedRegression_->setEvent(event); | ||
gedRegression_->setEventContent(setup); | ||
} | ||
|
||
// read input collections | ||
// electrons | ||
edm::Handle<reco::GsfElectronCollection> gedElectronHandle; | ||
event.getByToken(previousGsfElectrons_, gedElectronHandle); | ||
|
||
// PFCandidates | ||
edm::Handle<reco::PFCandidateCollection> pfCandidateHandle; | ||
event.getByToken(pfCandidates_, pfCandidateHandle); | ||
// value maps | ||
std::vector<edm::Handle<edm::ValueMap<float> > > isolationValueMaps(nDeps_); | ||
|
||
for (unsigned i = 0; i < nDeps_; ++i) { | ||
event.getByToken(tokenElectronIsoVals_[i], isolationValueMaps[i]); | ||
} | ||
|
||
// prepare a map of PFCandidates having a valid GsfTrackRef to save time | ||
std::map<reco::GsfTrackRef, const reco::PFCandidate*> gsfPFMap; | ||
reco::PFCandidateCollection::const_iterator it = pfCandidateHandle->begin(); | ||
reco::PFCandidateCollection::const_iterator itend = pfCandidateHandle->end(); | ||
for (; it != itend; ++it) { | ||
// First check that the GsfTrack is non null | ||
if (it->gsfTrackRef().isNonnull()) { | ||
if (abs(it->pdgId()) == 11) // consider only the electrons | ||
gsfPFMap[it->gsfTrackRef()] = &(*it); | ||
} | ||
} | ||
|
||
// Now loop on the electrons | ||
unsigned nele = gedElectronHandle->size(); | ||
for (unsigned iele = 0; iele < nele; ++iele) { | ||
reco::GsfElectronRef myElectronRef(gedElectronHandle, iele); | ||
|
||
reco::GsfElectron newElectron(*myElectronRef); | ||
reco::GsfElectron::PflowIsolationVariables isoVariables; | ||
isoVariables.sumChargedHadronPt = (*(isolationValueMaps)[0])[myElectronRef]; | ||
isoVariables.sumPhotonEt = (*(isolationValueMaps)[1])[myElectronRef]; | ||
isoVariables.sumNeutralHadronEt = (*(isolationValueMaps)[2])[myElectronRef]; | ||
isoVariables.sumPUPt = (*(isolationValueMaps)[3])[myElectronRef]; | ||
isoVariables.sumEcalClusterEt = (*(isolationValueMaps)[4])[myElectronRef]; | ||
isoVariables.sumHcalClusterEt = (*(isolationValueMaps)[5])[myElectronRef]; | ||
|
||
newElectron.setPfIsolationVariables(isoVariables); | ||
|
||
// now set a status if not already done (in GEDGsfElectronProducer.cc) | ||
// std::cout << " previous status " << newElectron.mvaOutput().status << std::endl; | ||
if (newElectron.mvaOutput().status <= 0) { | ||
std::map<reco::GsfTrackRef, const reco::PFCandidate*>::const_iterator itcheck = | ||
gsfPFMap.find(newElectron.gsfTrack()); | ||
reco::GsfElectron::MvaOutput myMvaOutput(newElectron.mvaOutput()); | ||
if (itcheck != gsfPFMap.end()) { | ||
// it means that there is a PFCandidate with the same GsfTrack | ||
myMvaOutput.status = 3; //as defined in PFCandidateEGammaExtra.h | ||
newElectron.setPassPflowPreselection( | ||
true); //this is currently fully redundant with mvaOutput.stats so candidate for removal | ||
} else { | ||
myMvaOutput.status = 4; // | ||
newElectron.setPassPflowPreselection( | ||
false); //this is currently fully redundant with mvaOutput.stats so candidate for removal | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line break issue (it can be solved in a follow-up patch, as usual) |
||
} | ||
newElectron.setMvaOutput(myMvaOutput); | ||
} | ||
|
||
if (gedRegression_) { | ||
gedRegression_->modifyObject(newElectron); | ||
} | ||
outputElectrons_p->push_back(newElectron); | ||
} | ||
|
||
event.put(std::move(outputElectrons_p), outputCollectionLabel_); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line break issue (it can be solved in a follow-up patch, as usual)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabiocos I can take care of these after this PR has been merged.