Skip to content
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

Use unique_ptr, not auto_ptr, in CommonTools #14277

Merged
merged 1 commit into from
Apr 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions CommonTools/CandAlgos/interface/CandCombiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ namespace reco {
for(int i = 0; i < n; ++i)
evt.getByToken(tokens_[i], colls[i]);

auto_ptr<OutputCollection> out = combiner_.combine(colls, names_.roles());
unique_ptr<OutputCollection> out = combiner_.combine(colls, names_.roles());
if(setLongLived_ || setMassConstraint_ || setPdgId_) {
typename OutputCollection::iterator i = out->begin(), e = out->end();
for(; i != e; ++i) {
Expand All @@ -164,7 +164,7 @@ namespace reco {
if(setPdgId_) i->setPdgId(pdgId_);
}
}
evt.put(out);
evt.put(std::move(out));
}
/// combiner utility
::CandCombiner<Selector, PairSelector, Cloner, OutputCollection, Setup> combiner_;
Expand Down
4 changes: 2 additions & 2 deletions CommonTools/CandAlgos/interface/ShallowCloneProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ ShallowCloneProducer<C>::~ShallowCloneProducer() {

template<typename C>
void ShallowCloneProducer<C>::produce( edm::Event& evt, const edm::EventSetup& ) {
std::auto_ptr<reco::CandidateCollection> coll( new reco::CandidateCollection );
std::unique_ptr<reco::CandidateCollection> coll( new reco::CandidateCollection );
edm::Handle<C> masterCollection;
evt.getByToken( srcToken_, masterCollection );
for( size_t i = 0; i < masterCollection->size(); ++i ) {
reco::CandidateBaseRef masterClone( edm::Ref<C>( masterCollection, i ) );
coll->push_back( new reco::ShallowCloneCandidate( masterClone ) );
}
evt.put( coll );
evt.put(std::move(coll));
}

#endif
4 changes: 2 additions & 2 deletions CommonTools/CandAlgos/plugins/CandPtrProjector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ CandPtrProjector::produce(edm::Event & iEvent, const edm::EventSetup & iSetup)
Handle<View<reco::Candidate> > vetos;
iEvent.getByToken(vetoSrcToken_, vetos);

std::auto_ptr<PtrVector<reco::Candidate> > result(new PtrVector<reco::Candidate>());
std::unique_ptr<PtrVector<reco::Candidate> > result(new PtrVector<reco::Candidate>());
std::set<reco::CandidatePtr> vetoedPtrs;
for(size_t i = 0; i< vetos->size(); ++i) {
for(size_t j=0,n=(*vetos)[i].numberOfSourceCandidatePtrs(); j<n;j++ ) {
Expand All @@ -61,7 +61,7 @@ CandPtrProjector::produce(edm::Event & iEvent, const edm::EventSetup & iSetup)
result->push_back(c);
}
}
iEvent.put(result);
iEvent.put(std::move(result));
}

void CandPtrProjector::endJob()
Expand Down
6 changes: 3 additions & 3 deletions CommonTools/CandAlgos/plugins/CandReducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ CandReducer::~CandReducer() {
void CandReducer::produce( Event& evt, const EventSetup& ) {
Handle<reco::CandidateView> cands;
evt.getByToken( srcToken_, cands );
std::auto_ptr<CandidateCollection> comp( new CandidateCollection );
std::unique_ptr<CandidateCollection> comp( new CandidateCollection );
for( reco::CandidateView::const_iterator c = cands->begin(); c != cands->end(); ++c ) {
std::auto_ptr<Candidate> cand( new LeafCandidate( * c ) );
std::unique_ptr<Candidate> cand( new LeafCandidate( * c ) );
comp->push_back( cand.release() );
}
evt.put( comp );
evt.put(std::move(comp));
}

#include "FWCore/Framework/interface/MakerMacros.h"
Expand Down
4 changes: 2 additions & 2 deletions CommonTools/CandAlgos/plugins/CandViewRefMerger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ class CandViewRefMerger : public edm::EDProducer {
}
private:
void produce(edm::Event & evt, const edm::EventSetup &) override {
std::auto_ptr<std::vector<reco::CandidateBaseRef> > out(new std::vector<reco::CandidateBaseRef>);
std::unique_ptr<std::vector<reco::CandidateBaseRef> > out(new std::vector<reco::CandidateBaseRef>);
for(std::vector<edm::EDGetTokenT<reco::CandidateView> >::const_iterator i = srcTokens_.begin(); i != srcTokens_.end(); ++i) {
edm::Handle<reco::CandidateView> src;
evt.getByToken(*i, src);
for(size_t j = 0; j < src->size(); ++j)
out->push_back(src->refAt(j));
}
evt.put(out);
evt.put(std::move(out));
}
std::vector<edm::EDGetTokenT<reco::CandidateView> > srcTokens_;
};
Expand Down
10 changes: 5 additions & 5 deletions CommonTools/CandAlgos/plugins/ParticleDecayProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ void ParticleDecayProducer::produce(edm::Event& iEvent, const edm::EventSetup& i
edm::Handle<CandidateCollection> genCandidatesCollection;
iEvent.getByToken(genCandidatesToken_, genCandidatesCollection);

auto_ptr<CandidateCollection> mothercands(new CandidateCollection);
auto_ptr<CandidateCollection> daughterscands(new CandidateCollection);
unique_ptr<CandidateCollection> mothercands(new CandidateCollection);
unique_ptr<CandidateCollection> daughterscands(new CandidateCollection);
size_t daughtersize = daughtersPdgId_.size();
for( CandidateCollection::const_iterator p = genCandidatesCollection->begin();p != genCandidatesCollection->end(); ++ p ) {
if (p->pdgId() == motherPdgId_ && p->status() == 3){
Expand All @@ -79,13 +79,13 @@ void ParticleDecayProducer::produce(edm::Event& iEvent, const edm::EventSetup& i
}
}

iEvent.put(mothercands, decayChain_ + "Mother");
iEvent.put(std::move(mothercands), decayChain_ + "Mother");
daughterscands->sort(GreaterByPt<reco::Candidate>());

for (unsigned int row = 0; row < daughtersize; ++ row ){
auto_ptr<CandidateCollection> leptonscands_(new CandidateCollection);
unique_ptr<CandidateCollection> leptonscands_(new CandidateCollection);
leptonscands_->push_back((daughterscands->begin()+row)->clone());
iEvent.put(leptonscands_, valias.at(row));
iEvent.put(std::move(leptonscands_), valias.at(row));
}
}

Expand Down
4 changes: 2 additions & 2 deletions CommonTools/ParticleFlow/plugins/DeltaBetaWeights.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ DeltaBetaWeights::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
double sumNPU = .0;
double sumPU = .0;

std::auto_ptr<reco::PFCandidateCollection> out(new reco::PFCandidateCollection);
std::unique_ptr<reco::PFCandidateCollection> out(new reco::PFCandidateCollection);


for (const reco::Candidate & cand : *src) {
Expand Down Expand Up @@ -85,6 +85,6 @@ DeltaBetaWeights::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)

}

iEvent.put(out);
iEvent.put(std::move(out));

}
6 changes: 3 additions & 3 deletions CommonTools/ParticleFlow/plugins/PFCandIsolatorFromDeposit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ void PFCandIsolatorFromDeposits::produce(Event& event, const EventSetup& eventSe
const IsoDepositMap & map = begin->map();

if (map.size()==0) { // !!???
event.put(std::auto_ptr<CandDoubleMap>(new CandDoubleMap()));
event.put(std::unique_ptr<CandDoubleMap>(new CandDoubleMap()));
return;
}
std::auto_ptr<CandDoubleMap> ret(new CandDoubleMap());
std::unique_ptr<CandDoubleMap> ret(new CandDoubleMap());
CandDoubleMap::Filler filler(*ret);

typedef reco::IsoDepositMap::const_iterator iterator_i;
Expand All @@ -212,7 +212,7 @@ void PFCandIsolatorFromDeposits::produce(Event& event, const EventSetup& eventSe
filler.insert(candH, retV.begin(), retV.end());
}
filler.fill();
event.put(ret);
event.put(std::move(ret));
}

DEFINE_FWK_MODULE( PFCandIsolatorFromDeposits );
4 changes: 2 additions & 2 deletions CommonTools/ParticleFlow/plugins/PFMET.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ void PFMET::produce(Event& iEvent,
Handle<PFCandidateCollection> pfCandidates;
iEvent.getByToken( tokenPFCandidates_, pfCandidates);

auto_ptr< METCollection >
unique_ptr< METCollection >
pOutput( new METCollection() );



pOutput->push_back( pfMETAlgo_.produce( *pfCandidates ) );
iEvent.put( pOutput );
iEvent.put(std::move(pOutput));

LogDebug("PFMET")<<"STOP event: "<<iEvent.id().event()
<<" in run "<<iEvent.id().run()<<endl;
Expand Down
8 changes: 4 additions & 4 deletions CommonTools/ParticleFlow/plugins/PFPileUp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ void PFPileUp::produce(Event& iEvent,

// get PFCandidates

auto_ptr< PFCollection >
unique_ptr< PFCollection >
pOutput( new PFCollection );

auto_ptr< PFCollectionByValue >
unique_ptr< PFCollectionByValue >
pOutputByValue ( new PFCollectionByValue );

if(enable_) {
Expand Down Expand Up @@ -118,7 +118,7 @@ void PFPileUp::produce(Event& iEvent,

} // end if enabled
// outsize of the loop to fill the collection anyway even when disabled
iEvent.put( pOutput );
// iEvent.put( pOutputByValue );
iEvent.put(std::move(pOutput));
// iEvent.put(std::move(pOutputByValue));
}

4 changes: 2 additions & 2 deletions CommonTools/ParticleFlow/plugins/TopProjector.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void TopProjector< Top, Bottom, Matcher >::produce( edm::Event& iEvent,

// output collection of FwdPtrs to objects,
// selected from the Bottom collection
std::auto_ptr< BottomFwdPtrCollection >
std::unique_ptr< BottomFwdPtrCollection >
pBottomFwdPtrOutput( new BottomFwdPtrCollection );

LogDebug("TopProjection")<<" Remaining candidates in the bottom collection ------ ";
Expand Down Expand Up @@ -297,7 +297,7 @@ void TopProjector< Top, Bottom, Matcher >::produce( edm::Event& iEvent,
}
}

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


Expand Down
4 changes: 2 additions & 2 deletions CommonTools/ParticleFlow/plugins/Type1PFMET.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ Type1PFMET::~Type1PFMET() {}
iEvent.getByToken( correctorToken, corrector );
Handle<METCollection> inputUncorMet; //Define Inputs
iEvent.getByToken( tokenUncorMet, inputUncorMet ); //Get Inputs
std::auto_ptr<METCollection> output( new METCollection() ); //Create empty output
std::unique_ptr<METCollection> output( new METCollection() ); //Create empty output
run( *(inputUncorMet.product()), *(corrector.product()), *(inputUncorJets.product()),
jetPTthreshold, jetEMfracLimit, jetMufracLimit,
&*output ); //Invoke the algorithm
iEvent.put( output ); //Put output into Event
iEvent.put(std::move(output)); //Put output into Event
}

void Type1PFMET::run(const METCollection& uncorMET,
Expand Down
8 changes: 4 additions & 4 deletions CommonTools/PileupAlgos/plugins/PuppiPhoton.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void PuppiPhoton::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
//Get Weights
edm::Handle<edm::ValueMap<float> > pupWeights;
iEvent.getByToken(tokenWeights_,pupWeights);
std::auto_ptr<edm::ValueMap<LorentzVector> > p4PupOut(new edm::ValueMap<LorentzVector>());
std::unique_ptr<edm::ValueMap<LorentzVector> > p4PupOut(new edm::ValueMap<LorentzVector>());
LorentzVectorCollection puppiP4s;
std::vector<reco::CandidatePtr> values(hPFProduct->size());
int iPF = 0;
Expand Down Expand Up @@ -156,16 +156,16 @@ void PuppiPhoton::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
corrCandidates_->push_back(pCand);
}
//Fill it into the event
edm::OrphanHandle<reco::PFCandidateCollection> oh = iEvent.put( corrCandidates_ );
edm::OrphanHandle<reco::PFCandidateCollection> oh = iEvent.put(std::move(corrCandidates_));
for(unsigned int ic=0, nc = pupCol->size(); ic < nc; ++ic) {
reco::CandidatePtr pkref( oh, ic );
values[ic] = pkref;
}
std::auto_ptr<edm::ValueMap<reco::CandidatePtr> > pfMap_p(new edm::ValueMap<reco::CandidatePtr>());
std::unique_ptr<edm::ValueMap<reco::CandidatePtr> > pfMap_p(new edm::ValueMap<reco::CandidatePtr>());
edm::ValueMap<reco::CandidatePtr>::Filler filler(*pfMap_p);
filler.insert(hPFProduct, values.begin(), values.end());
filler.fill();
iEvent.put(pfMap_p);
iEvent.put(std::move(pfMap_p));
}
// ------------------------------------------------------------------------------------------
bool PuppiPhoton::matchPFCandidate(const reco::Candidate *iPF,const reco::Candidate *iPho) {
Expand Down
2 changes: 1 addition & 1 deletion CommonTools/PileupAlgos/plugins/PuppiPhoton.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class PuppiPhoton : public edm::stream::EDProducer<> {
bool usePhotonId_;
std::vector<double> dRMatch_;
std::vector<int32_t> pdgIds_;
std::auto_ptr< PFOutputCollection > corrCandidates_;
std::unique_ptr< PFOutputCollection > corrCandidates_;
double weight_;
bool useValueMap_;
};
Expand Down
36 changes: 18 additions & 18 deletions CommonTools/PileupAlgos/plugins/PuppiProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
}

//Fill it into the event
std::auto_ptr<edm::ValueMap<float> > lPupOut(new edm::ValueMap<float>());
std::unique_ptr<edm::ValueMap<float> > lPupOut(new edm::ValueMap<float>());
edm::ValueMap<float>::Filler lPupFiller(*lPupOut);
lPupFiller.insert(hPFProduct,lWeights.begin(),lWeights.end());
lPupFiller.fill();
Expand All @@ -229,7 +229,7 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
// the input is set to have a four-vector of 0,0,0,0
fPuppiCandidates.reset( new PFOutputCollection );
fPackedPuppiCandidates.reset( new PackedOutputCollection );
std::auto_ptr<edm::ValueMap<LorentzVector> > p4PupOut(new edm::ValueMap<LorentzVector>());
std::unique_ptr<edm::ValueMap<LorentzVector> > p4PupOut(new edm::ValueMap<LorentzVector>());
LorentzVectorCollection puppiP4s;
std::vector<reco::CandidatePtr> values(hPFProduct->size());

Expand Down Expand Up @@ -276,44 +276,44 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
p4PupFiller.insert(hPFProduct,puppiP4s.begin(), puppiP4s.end() );
p4PupFiller.fill();

iEvent.put(lPupOut);
iEvent.put(p4PupOut);
iEvent.put(std::move(lPupOut));
iEvent.put(std::move(p4PupOut));
if (fUseExistingWeights || fClonePackedCands) {
edm::OrphanHandle<pat::PackedCandidateCollection> oh = iEvent.put( fPackedPuppiCandidates );
edm::OrphanHandle<pat::PackedCandidateCollection> oh = iEvent.put(std::move(fPackedPuppiCandidates));
for(unsigned int ic=0, nc = oh->size(); ic < nc; ++ic) {
reco::CandidatePtr pkref( oh, ic );
values[ic] = pkref;
}
} else {
edm::OrphanHandle<reco::PFCandidateCollection> oh = iEvent.put( fPuppiCandidates );
edm::OrphanHandle<reco::PFCandidateCollection> oh = iEvent.put(std::move(fPuppiCandidates));
for(unsigned int ic=0, nc = oh->size(); ic < nc; ++ic) {
reco::CandidatePtr pkref( oh, ic );
values[ic] = pkref;
}
}
std::auto_ptr<edm::ValueMap<reco::CandidatePtr> > pfMap_p(new edm::ValueMap<reco::CandidatePtr>());
std::unique_ptr<edm::ValueMap<reco::CandidatePtr> > pfMap_p(new edm::ValueMap<reco::CandidatePtr>());
edm::ValueMap<reco::CandidatePtr>::Filler filler(*pfMap_p);
filler.insert(hPFProduct, values.begin(), values.end());
filler.fill();
iEvent.put(pfMap_p);
iEvent.put(std::move(pfMap_p));


//////////////////////////////////////////////
if (fPuppiDiagnostics && !fUseExistingWeights){

// all the different alphas per particle
// THE alpha per particle
std::auto_ptr<std::vector<double> > theAlphas(new std::vector<double>(fPuppiContainer->puppiAlphas()));
std::auto_ptr<std::vector<double> > theAlphasMed(new std::vector<double>(fPuppiContainer->puppiAlphasMed()));
std::auto_ptr<std::vector<double> > theAlphasRms(new std::vector<double>(fPuppiContainer->puppiAlphasRMS()));
std::auto_ptr<std::vector<double> > alphas(new std::vector<double>(fPuppiContainer->puppiRawAlphas()));
std::auto_ptr<double> nalgos(new double(fPuppiContainer->puppiNAlgos()));
std::unique_ptr<std::vector<double> > theAlphas(new std::vector<double>(fPuppiContainer->puppiAlphas()));
std::unique_ptr<std::vector<double> > theAlphasMed(new std::vector<double>(fPuppiContainer->puppiAlphasMed()));
std::unique_ptr<std::vector<double> > theAlphasRms(new std::vector<double>(fPuppiContainer->puppiAlphasRMS()));
std::unique_ptr<std::vector<double> > alphas(new std::vector<double>(fPuppiContainer->puppiRawAlphas()));
std::unique_ptr<double> nalgos(new double(fPuppiContainer->puppiNAlgos()));

iEvent.put(alphas,"PuppiRawAlphas");
iEvent.put(nalgos,"PuppiNAlgos");
iEvent.put(theAlphas,"PuppiAlphas");
iEvent.put(theAlphasMed,"PuppiAlphasMed");
iEvent.put(theAlphasRms,"PuppiAlphasRms");
iEvent.put(std::move(alphas),"PuppiRawAlphas");
iEvent.put(std::move(nalgos),"PuppiNAlgos");
iEvent.put(std::move(theAlphas),"PuppiAlphas");
iEvent.put(std::move(theAlphasMed),"PuppiAlphasMed");
iEvent.put(std::move(theAlphasRms),"PuppiAlphasRms");
}

}
Expand Down
4 changes: 2 additions & 2 deletions CommonTools/PileupAlgos/plugins/PuppiProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class PuppiProducer : public edm::stream::EDProducer<> {
double fVtxZCut;
std::unique_ptr<PuppiContainer> fPuppiContainer;
std::vector<RecoObj> fRecoObjCollection;
std::auto_ptr< PFOutputCollection > fPuppiCandidates;
std::auto_ptr< PackedOutputCollection > fPackedPuppiCandidates;
std::unique_ptr< PFOutputCollection > fPuppiCandidates;
std::unique_ptr< PackedOutputCollection > fPackedPuppiCandidates;
};
#endif
8 changes: 4 additions & 4 deletions CommonTools/PileupAlgos/plugins/SoftKillerProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void
SoftKillerProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
{

std::auto_ptr< PFOutputCollection > pOutput( new PFOutputCollection );
std::unique_ptr< PFOutputCollection > pOutput( new PFOutputCollection );

// get PF Candidates
edm::Handle<reco::CandidateView> pfCandidates;
Expand All @@ -123,7 +123,7 @@ SoftKillerProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
std::vector<fastjet::PseudoJet> soft_killed_event;
soft_killer.apply(fjInputs, soft_killed_event, pt_threshold);

std::auto_ptr<edm::ValueMap<LorentzVector> > p4SKOut(new edm::ValueMap<LorentzVector>());
std::unique_ptr<edm::ValueMap<LorentzVector> > p4SKOut(new edm::ValueMap<LorentzVector>());
LorentzVectorCollection skP4s;

static const reco::PFCandidate dummySinceTranslateIsNotStatic;
Expand Down Expand Up @@ -154,8 +154,8 @@ SoftKillerProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
p4SKFiller.insert(pfCandidates,skP4s.begin(), skP4s.end() );
p4SKFiller.fill();

iEvent.put(p4SKOut,"SoftKillerP4s");
iEvent.put( pOutput );
iEvent.put(std::move(p4SKOut),"SoftKillerP4s");
iEvent.put(std::move(pOutput));

}

Expand Down