Skip to content

Commit

Permalink
Merge pull request #15826 from wmtan/UseUniquePtrInRecoJetAndRecoMET
Browse files Browse the repository at this point in the history
Use unique_ptr, not auto_ptr in RecoJet and RecoMET
  • Loading branch information
davidlange6 authored Sep 16, 2016
2 parents 851461b + f3a8737 commit 12077f8
Show file tree
Hide file tree
Showing 82 changed files with 233 additions and 267 deletions.
8 changes: 4 additions & 4 deletions RecoJets/FFTJetProducers/plugins/FFTJetCorrectionProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void FFTJetCorrectionProducer::applyCorrections(edm::Event& iEvent,

// Create the output collection
const unsigned nJets = jets->size();
std::auto_ptr<MyCollection> coll(new MyCollection());
auto coll = std::make_unique<MyCollection>();
coll->reserve(nJets);

// Cycle over jets and apply the corrector sequences
Expand Down Expand Up @@ -340,18 +340,18 @@ void FFTJetCorrectionProducer::applyCorrections(edm::Event& iEvent,
// Create the uncertainty sequence
if (writeUncertainties)
{
std::auto_ptr<std::vector<float> > unc(new std::vector<float>());
auto unc = std::make_unique<std::vector<float>>();
unc->reserve(nJets);
for (unsigned ijet=0; ijet<nJets; ++ijet)
{
MyJet& j((*coll)[ijet]);
unc->push_back(j.pileup());
j.setPileup(0.f);
}
iEvent.put(unc, outputLabel);
iEvent.put(std::move(unc), outputLabel);
}

iEvent.put(coll, outputLabel);
iEvent.put(std::move(coll), outputLabel);
++eventCount;
}

Expand Down
8 changes: 4 additions & 4 deletions RecoJets/FFTJetProducers/plugins/FFTJetEFlowSmoother.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,11 @@ void FFTJetEFlowSmoother::produce(
const double bin0edge = g.phiBin0Edge();

// We will fill the following histo
std::auto_ptr<TH3F> pTable(
new TH3F("FFTJetEFlowSmoother", "FFTJetEFlowSmoother",
auto pTable = std::make_unique<TH3F>(
"FFTJetEFlowSmoother", "FFTJetEFlowSmoother",
nScales+1U, -1.5, nScales-0.5,
nEta, g.etaMin(), g.etaMax(),
nPhi, bin0edge, bin0edge+2.0*M_PI));
nPhi, bin0edge, bin0edge+2.0*M_PI);
TH3F* h = pTable.get();
h->SetDirectory(0);
h->GetXaxis()->SetTitle("Scale");
Expand Down Expand Up @@ -264,7 +264,7 @@ void FFTJetEFlowSmoother::produce(
}
}

iEvent.put(pTable, outputLabel);
iEvent.put(std::move(pTable), outputLabel);
}


Expand Down
5 changes: 2 additions & 3 deletions RecoJets/FFTJetProducers/plugins/FFTJetPFPileupCleaner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ void FFTJetPFPileupCleaner::produce(
edm::Event& iEvent, const edm::EventSetup& iSetup)
{
// get PFCandidates
std::auto_ptr<reco::PFCandidateCollection>
pOutput(new reco::PFCandidateCollection);
auto pOutput = std::make_unique<reco::PFCandidateCollection>();

edm::Handle<reco::PFCandidateCollection> pfCandidates;
iEvent.getByToken(PFCandidatesToken, pfCandidates);
Expand Down Expand Up @@ -264,7 +263,7 @@ void FFTJetPFPileupCleaner::produce(
}
}

iEvent.put(pOutput);
iEvent.put(std::move(pOutput));
}


Expand Down
15 changes: 7 additions & 8 deletions RecoJets/FFTJetProducers/plugins/FFTJetPatRecoProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ void FFTJetPatRecoProducer::buildSparseProduct(edm::Event& ev) const
{
typedef reco::PattRecoTree<Real,reco::PattRecoPeak<Real> > StoredTree;

std::auto_ptr<StoredTree> tree(new StoredTree());
auto tree = std::make_unique<StoredTree>();

sparsePeakTreeToStorable(sparseTree,
sequencer->maxAdaptiveScales(),
Expand All @@ -388,7 +388,7 @@ void FFTJetPatRecoProducer::buildSparseProduct(edm::Event& ev) const
<< std::endl;
}

ev.put(tree, outputLabel);
ev.put(std::move(tree), outputLabel);
}


Expand All @@ -397,7 +397,7 @@ void FFTJetPatRecoProducer::buildDenseProduct(edm::Event& ev) const
{
typedef reco::PattRecoTree<Real,reco::PattRecoPeak<Real> > StoredTree;

std::auto_ptr<StoredTree> tree(new StoredTree());
auto tree = std::make_unique<StoredTree>();

densePeakTreeToStorable(*clusteringTree,
sequencer->maxAdaptiveScales(),
Expand All @@ -415,7 +415,7 @@ void FFTJetPatRecoProducer::buildDenseProduct(edm::Event& ev) const
<< std::endl;
}

ev.put(tree, outputLabel);
ev.put(std::move(tree), outputLabel);
}


Expand Down Expand Up @@ -460,10 +460,9 @@ void FFTJetPatRecoProducer::produce(
{
const fftjet::Grid2d<Real>& g(*energyFlow);

std::auto_ptr<reco::DiscretizedEnergyFlow> flow(
new reco::DiscretizedEnergyFlow(
auto flow = std::make_unique<reco::DiscretizedEnergyFlow>(
g.data(), g.title(), g.etaMin(), g.etaMax(),
g.phiBin0Edge(), g.nEta(), g.nPhi()));
g.phiBin0Edge(), g.nEta(), g.nPhi());

if (verifyDataConversion)
{
Expand All @@ -474,7 +473,7 @@ void FFTJetPatRecoProducer::produce(
assert(g == check);
}

iEvent.put(flow, outputLabel);
iEvent.put(std::move(flow), outputLabel);
}

if (storeGridsExternally)
Expand Down
20 changes: 8 additions & 12 deletions RecoJets/FFTJetProducers/plugins/FFTJetPileupEstimator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class FFTJetPileupEstimator : public edm::EDProducer
FFTJetPileupEstimator(const FFTJetPileupEstimator&);
FFTJetPileupEstimator& operator=(const FFTJetPileupEstimator&);

std::auto_ptr<reco::FFTJetPileupSummary> calibrateFromConfig(
std::unique_ptr<reco::FFTJetPileupSummary> calibrateFromConfig(
double uncalibrated) const;

std::auto_ptr<reco::FFTJetPileupSummary> calibrateFromDB(
std::unique_ptr<reco::FFTJetPileupSummary> calibrateFromDB(
double uncalibrated, const edm::EventSetup& iSetup) const;

template<class Ptr>
Expand Down Expand Up @@ -171,12 +171,12 @@ void FFTJetPileupEstimator::produce(edm::Event& iEvent,
// Simple fixed-point pile-up estimate
const double curve = h.data()[filterNumber*nCdfvalues + fixedCdfvalueBin];

std::auto_ptr<reco::FFTJetPileupSummary> summary;
std::unique_ptr<reco::FFTJetPileupSummary> summary;
if (loadCalibFromDB)
summary = calibrateFromDB(curve, iSetup);
else
summary = calibrateFromConfig(curve);
iEvent.put(summary, outputLabel);
iEvent.put(std::move(summary), outputLabel);
}


Expand All @@ -190,7 +190,7 @@ void FFTJetPileupEstimator::endJob()
}


std::auto_ptr<reco::FFTJetPileupSummary>
std::unique_ptr<reco::FFTJetPileupSummary>
FFTJetPileupEstimator::calibrateFromConfig(const double curve) const
{
const double pileupRho = ptToDensityFactor*(*calibrationCurve)(curve);
Expand Down Expand Up @@ -222,13 +222,11 @@ FFTJetPileupEstimator::calibrateFromConfig(const double curve) const
}
}

return std::auto_ptr<reco::FFTJetPileupSummary>(
new reco::FFTJetPileupSummary(curve, pileupRho,
rhoUncert, uncertaintyCode));
return std::make_unique<reco::FFTJetPileupSummary>(curve, pileupRho, rhoUncert, uncertaintyCode);
}


std::auto_ptr<reco::FFTJetPileupSummary>
std::unique_ptr<reco::FFTJetPileupSummary>
FFTJetPileupEstimator::calibrateFromDB(
const double curve, const edm::EventSetup& iSetup) const
{
Expand All @@ -246,9 +244,7 @@ FFTJetPileupEstimator::calibrateFromDB(
const double rhoUncert = ptToDensityFactor*(*uc)(&curve, 1U);
const int uncertaintyCode = round((*uz)(&curve, 1U));

return std::auto_ptr<reco::FFTJetPileupSummary>(
new reco::FFTJetPileupSummary(curve, pileupRho,
rhoUncert, uncertaintyCode));
return std::make_unique<reco::FFTJetPileupSummary>(curve, pileupRho, rhoUncert, uncertaintyCode);
}


Expand Down
10 changes: 3 additions & 7 deletions RecoJets/FFTJetProducers/plugins/FFTJetPileupProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,11 @@ void FFTJetPileupProcessor::produce(

// Convert percentile data into a more convenient storable object
// and put it into the event record
std::auto_ptr<reco::DiscretizedEnergyFlow> pTable(
new reco::DiscretizedEnergyFlow(
iEvent.put(std::make_unique<reco::DiscretizedEnergyFlow>(
&percentileData[0], "FFTJetPileupProcessor",
-0.5, nScales-0.5, 0.0, nScales, nPercentiles));
iEvent.put(pTable, outputLabel);
-0.5, nScales-0.5, 0.0, nScales, nPercentiles), outputLabel);

std::auto_ptr<std::pair<double,double> > etSum(
new std::pair<double,double>(densityBeforeMixing, densityAfterMixing));
iEvent.put(etSum, outputLabel);
iEvent.put(std::make_unique<std::pair<double,double>>(densityBeforeMixing, densityAfterMixing), outputLabel);
}


Expand Down
10 changes: 4 additions & 6 deletions RecoJets/FFTJetProducers/plugins/FFTJetProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ void FFTJetProducer::writeJets(edm::Event& iEvent,
pileupEnergyFlow->phiBinWidth();

// allocate output jet collection
std::auto_ptr<OutputCollection> jets(new OutputCollection());
auto jets = std::make_unique<OutputCollection>();
const unsigned nJets = recoJets.size();
jets->reserve(nJets);

Expand Down Expand Up @@ -705,7 +705,7 @@ void FFTJetProducer::writeJets(edm::Event& iEvent,
std::sort(jets->begin(), jets->end(), LocalSortByPt());

// put the collection into the event
iEvent.put(jets, outputLabel);
iEvent.put(std::move(jets), outputLabel);
}


Expand All @@ -732,15 +732,13 @@ void FFTJetProducer::saveResults(edm::Event& ev, const edm::EventSetup& iSetup,
const double maxScale = maxLevel ? sparseTree.getScale(maxLevel) : 0.0;
const double scaleUsed = usedLevel ? sparseTree.getScale(usedLevel) : 0.0;

std::auto_ptr<reco::FFTJetProducerSummary> summary(
new reco::FFTJetProducerSummary(
ev.put(std::make_unique<reco::FFTJetProducerSummary>(
thresholds, occupancy, unclusE,
constituents[0], unused,
minScale, maxScale, scaleUsed,
nPreclustersFound, iterationsPerformed,
iterationsPerformed == 1U ||
iterationsPerformed <= maxIterations));
ev.put(summary, outputLabel);
iterationsPerformed <= maxIterations), outputLabel);
}


Expand Down
4 changes: 2 additions & 2 deletions RecoJets/FFTJetProducers/plugins/FFTJetVertexAdder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void FFTJetVertexAdder::produce(
CLHEP::RandGauss rGauss(rng->getEngine(iEvent.streamID()));

// get PFCandidates
std::auto_ptr<reco::VertexCollection> pOutput(new reco::VertexCollection);
auto pOutput = std::make_unique<reco::VertexCollection>();

double xmean = fixedX;
double ymean = fixedY;
Expand Down Expand Up @@ -193,7 +193,7 @@ void FFTJetVertexAdder::produce(
pOutput->push_back(*iv);
}

iEvent.put(pOutput, outputLabel);
iEvent.put(std::move(pOutput), outputLabel);
}


Expand Down
4 changes: 2 additions & 2 deletions RecoJets/JetAnalyzers/src/JetIdSelector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ JetIdSelector<T>::~JetIdSelector(){
template<typename T>
void JetIdSelector<T>::produce(edm::Event& iEvent,const edm::EventSetup& iSetup)
{
auto_ptr<JetCollection> selectedJets(new JetCollection);
auto selectedJets = std::make_unique<JetCollection>();
edm::Handle<reco::JetView> jets; // uncorrected jets!
iEvent.getByLabel(src_,jets);

Expand Down Expand Up @@ -241,7 +241,7 @@ void JetIdSelector<T>::produce(edm::Event& iEvent,const edm::EventSetup& iSetup)

nJetsTot_ +=jets->size();
nJetsPassed_+=selectedJets->size();
iEvent.put(selectedJets);
iEvent.put(std::move(selectedJets));
}


Expand Down
5 changes: 2 additions & 3 deletions RecoJets/JetAssociationProducers/src/JetExtender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ void JetExtender::produce(edm::Event& fEvent, const edm::EventSetup& fSetup) {
edm::Handle <reco::JetTracksAssociation::Container> j2tCALO_h;
if (!(mJet2TracksAtCALO.label().empty())) fEvent.getByToken (token_mJet2TracksAtCALO, j2tCALO_h);

std::auto_ptr<reco::JetExtendedAssociation::Container>
jetExtender (new reco::JetExtendedAssociation::Container (reco::JetRefBaseProd(jets_h)));
auto jetExtender = std::make_unique<reco::JetExtendedAssociation::Container>(reco::JetRefBaseProd(jets_h));

// loop over jets (make sure jets in associations are the same as in collection

Expand Down Expand Up @@ -69,5 +68,5 @@ void JetExtender::produce(edm::Event& fEvent, const edm::EventSetup& fSetup) {
}
reco::JetExtendedAssociation::setValue (&*jetExtender, jet, extendedData);
}
fEvent.put (jetExtender);
fEvent.put(std::move(jetExtender));
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ void JetSignalVertexCompatibility::produce(edm::Event &event,
edm::Handle<VertexCollection> primaryVertices;
event.getByToken(primaryVerticesToken, primaryVertices);

std::auto_ptr<JetFloatAssociation::Container> result(
new JetFloatAssociation::Container(jetTracksAssoc->keyProduct()));
auto result = std::make_unique<JetFloatAssociation::Container>(jetTracksAssoc->keyProduct());

for(JetTracksAssociationCollection::const_iterator iter =
jetTracksAssoc->begin();
Expand All @@ -70,5 +69,5 @@ void JetSignalVertexCompatibility::produce(edm::Event &event,

algo.resetEvent(0);

event.put(result);
event.put(std::move(result));
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void JetTracksAssociatorAtCaloFace::produce(edm::Event& fEvent, const edm::Event
throw cms::Exception("InvalidInput") << " Jet-track association is only defined for CaloJets.";
}

std::auto_ptr<reco::JetTracksAssociation::Container> jetTracks (new reco::JetTracksAssociation::Container (reco::JetRefBaseProd(jets_h)));
auto jetTracks = std::make_unique<reco::JetTracksAssociation::Container>(reco::JetRefBaseProd(jets_h));


// format inputs
Expand All @@ -67,7 +67,7 @@ void JetTracksAssociatorAtCaloFace::produce(edm::Event& fEvent, const edm::Event


// store output
fEvent.put (jetTracks);
fEvent.put(std::move(jetTracks));
}


Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void JetTracksAssociatorAtVertex::produce(edm::Event& fEvent, const edm::EventSe
edm::Handle <reco::TrackCollection> tracks_h;
fEvent.getByToken (mTracks, tracks_h);

std::auto_ptr<reco::JetTracksAssociation::Container> jetTracks (new reco::JetTracksAssociation::Container (reco::JetRefBaseProd(jets_h)));
auto jetTracks = std::make_unique<reco::JetTracksAssociation::Container>(reco::JetRefBaseProd(jets_h));

// format inputs
std::vector <edm::RefToBase<reco::Jet> > allJets;
Expand All @@ -61,5 +61,5 @@ void JetTracksAssociatorAtVertex::produce(edm::Event& fEvent, const edm::EventSe


// store output
fEvent.put (jetTracks);
fEvent.put(std::move(jetTracks));
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void JetTracksAssociatorExplicit::produce(edm::Event& fEvent, const edm::EventSe
edm::Handle <reco::TrackCollection> tracks_h;
fEvent.getByToken (mTracks, tracks_h);

std::auto_ptr<reco::JetTracksAssociation::Container> jetTracks (new reco::JetTracksAssociation::Container (reco::JetRefBaseProd(jets_h)));
auto jetTracks = std::make_unique<reco::JetTracksAssociation::Container>(reco::JetRefBaseProd(jets_h));

// format inputs
std::vector <edm::RefToBase<reco::Jet> > allJets;
Expand All @@ -50,5 +50,5 @@ void JetTracksAssociatorExplicit::produce(edm::Event& fEvent, const edm::EventSe


// store output
fEvent.put (jetTracks);
fEvent.put(std::move(jetTracks));
}
4 changes: 2 additions & 2 deletions RecoJets/JetAssociationProducers/src/TrackExtrapolator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ TrackExtrapolator::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
edm::Handle <reco::TrackCollection> tracks_h;
iEvent.getByToken (tracksSrc_, tracks_h);

std::auto_ptr< std::vector<reco::TrackExtrapolation> > extrapolations( new std::vector<reco::TrackExtrapolation>() );
auto extrapolations = std::make_unique<std::vector<reco::TrackExtrapolation>>();

// Get list of tracks we want to extrapolate
std::vector <reco::TrackRef> goodTracks;
Expand Down Expand Up @@ -79,7 +79,7 @@ TrackExtrapolator::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
vresultMom ) );
}
}
iEvent.put( extrapolations );
iEvent.put(std::move(extrapolations));
}

// -----------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 12077f8

Please sign in to comment.