Skip to content

Commit

Permalink
use unique_ptr, not auto_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
wmtan committed Aug 18, 2016
1 parent a14084c commit 42945c4
Show file tree
Hide file tree
Showing 136 changed files with 462 additions and 475 deletions.
3 changes: 1 addition & 2 deletions PhysicsTools/CandAlgos/plugins/EventShapeVarsProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ EventShapeVarsProducer::EventShapeVarsProducer(const edm::ParameterSet& cfg)

void put(edm::Event& evt, double value, const char* instanceName)
{
std::auto_ptr<double> eventShapeVarPtr(new double(value));
evt.put(eventShapeVarPtr, instanceName);
evt.put(std::make_unique<double>(value), instanceName);
}

void EventShapeVarsProducer::produce(edm::Event& evt, const edm::EventSetup&)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void MCTruthCompositeMatcher<C1, C2>::produce( edm::Event & evt , const edm::Eve
maps.push_back( & * matchMap );
}
MCCandMatcher<C1, C2> match( maps );
auto_ptr<map_type> matchMap( new map_type );
auto matchMap = std::make_unique<map_type>();
for( size_t i = 0; i != cands->size(); ++ i ) {
const typename C1::value_type & cand = ( * cands )[ i ];
reference_type mc(match( cand ));
Expand All @@ -61,7 +61,7 @@ void MCTruthCompositeMatcher<C1, C2>::produce( edm::Event & evt , const edm::Eve
}
}

evt.put( matchMap );
evt.put(std::move(matchMap) );
}

#endif
Expand Down
4 changes: 2 additions & 2 deletions PhysicsTools/HepMCCandAlgos/plugins/FlavorHistoryFilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ FlavorHistoryFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
Handle<FlavorHistoryEvent > cFlavorHistoryEvent;
iEvent.getByToken(csrcToken_,cFlavorHistoryEvent);

std::auto_ptr<unsigned int> selection ( new unsigned int() );
auto selection = std::make_unique<unsigned int>(0);

// Get the number of matched b-jets in the event
unsigned int nb = bFlavorHistoryEvent->nb();
Expand Down Expand Up @@ -238,7 +238,7 @@ FlavorHistoryFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
pass = true;
}

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

return pass;

Expand Down
4 changes: 2 additions & 2 deletions PhysicsTools/HepMCCandAlgos/plugins/FlavorHistoryProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void FlavorHistoryProducer::produce( Event& evt, const EventSetup& )
vector<FlavorHistory::FLAVOR_T> flavorSources;

// Make a new flavor history vector
auto_ptr<FlavorHistoryEvent > flavorHistoryEvent ( new FlavorHistoryEvent () ) ;
auto flavorHistoryEvent = std::make_unique<FlavorHistoryEvent>();

// ------------------------------------------------------------
// Loop over partons
Expand Down Expand Up @@ -321,7 +321,7 @@ void FlavorHistoryProducer::produce( Event& evt, const EventSetup& )
}

// Now add the flavor history to the event record
evt.put( flavorHistoryEvent, flavorHistoryName_ );
evt.put(std::move(flavorHistoryEvent), flavorHistoryName_ );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ void GenParticleDecaySelector::produce(edm::Event& evt, const edm::EventSetup& e

Handle<GenParticleCollection> genParticles;
evt.getByToken(srcToken_, genParticles);
auto_ptr<GenParticleCollection> decay(new GenParticleCollection);
auto decay = std::make_unique<GenParticleCollection>();
const GenParticleRefProd ref = evt.getRefBeforePut<GenParticleCollection>();
for(GenParticleCollection::const_iterator g = genParticles->begin();
g != genParticles->end(); ++g)
if(g->pdgId() == particle_.pdgId() && g->status() == status_)
add(*decay, *g, ref);
evt.put(decay);
evt.put(std::move(decay));
}

pair<GenParticleRef, GenParticle*> GenParticleDecaySelector::add(GenParticleCollection & decay, const GenParticle & p,
Expand Down
8 changes: 4 additions & 4 deletions PhysicsTools/HepMCCandAlgos/plugins/GenParticleProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ void GenParticleProducer::produce( Event& evt, const EventSetup& es ) {
// initialise containers
const size_t size = totalSize;
vector<const HepMC::GenParticle *> particles( size );
auto_ptr<GenParticleCollection> candsPtr( new GenParticleCollection( size ) );
auto_ptr<vector<int> > barCodeVector( new vector<int>( size ) );
auto candsPtr = std::make_unique<GenParticleCollection>(size);
auto barCodeVector = std::make_unique<vector<int>>(size);
ref_ = evt.getRefBeforePut<GenParticleCollection>();
GenParticleCollection & cands = * candsPtr;
size_t offset = 0;
Expand Down Expand Up @@ -257,8 +257,8 @@ void GenParticleProducer::produce( Event& evt, const EventSetup& es ) {
}
}

evt.put( candsPtr );
if(saveBarCodes_) evt.put( barCodeVector );
evt.put(std::move(candsPtr));
if(saveBarCodes_) evt.put(std::move(barCodeVector));
if(cfhepmcprod) delete cfhepmcprod;

}
Expand Down
8 changes: 4 additions & 4 deletions PhysicsTools/HepMCCandAlgos/plugins/GenParticlePruner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void GenParticlePruner::produce(Event& evt, const EventSetup& es) {
}
}

auto_ptr<GenParticleCollection> out(new GenParticleCollection);
auto out = std::make_unique<GenParticleCollection>();
GenParticleRefProd outRef = evt.getRefBeforePut<GenParticleCollection>();
out->reserve(counter);

Expand Down Expand Up @@ -261,12 +261,12 @@ void GenParticlePruner::produce(Event& evt, const EventSetup& es) {
}


edm::OrphanHandle<reco::GenParticleCollection> oh = evt.put(out);
std::auto_ptr<edm::Association<reco::GenParticleCollection> > orig2new(new edm::Association<reco::GenParticleCollection>(oh ));
edm::OrphanHandle<reco::GenParticleCollection> oh = evt.put(std::move(out));
auto orig2new = std::make_unique<edm::Association<reco::GenParticleCollection>>(oh);
edm::Association<reco::GenParticleCollection>::Filler orig2newFiller(*orig2new);
orig2newFiller.insert(src, flags_.begin(), flags_.end());
orig2newFiller.fill();
evt.put(orig2new);
evt.put(std::move(orig2new));


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class GenPlusSimParticleProducer : public edm::EDProducer {
std::vector<PdtEntry> pdts_; // these are needed before we get the EventSetup

typedef StringCutObjectSelector<reco::GenParticle> StrFilter;
std::auto_ptr<StrFilter> filter_;
std::unique_ptr<StrFilter> filter_;

/// Collection of GenParticles I need to make refs to. It must also have its associated vector<int> of barcodes, aligned with them.
edm::EDGetTokenT<reco::GenParticleCollection> gensToken_;
Expand Down Expand Up @@ -113,7 +113,7 @@ GenPlusSimParticleProducer::GenPlusSimParticleProducer(const ParameterSet& cfg)
if (cfg.existsAs<string>("filter")) {
string filter = cfg.getParameter<string>("filter");
if (!filter.empty()) {
filter_ = auto_ptr<StrFilter>(new StrFilter(filter));
filter_ = std::make_unique<StrFilter>(filter);
}
}
produces<GenParticleCollection>();
Expand Down Expand Up @@ -197,7 +197,7 @@ void GenPlusSimParticleProducer::produce(Event& event,
event.getByToken(simtracksToken_, simtracks);

// Need to check that SimTrackContainer is sorted; otherwise, copy and sort :-(
std::auto_ptr<SimTrackContainer> simtracksTmp;
std::unique_ptr<SimTrackContainer> simtracksTmp;
const SimTrackContainer * simtracksSorted = &* simtracks;
if (!__gnu_cxx::is_sorted(simtracks->begin(), simtracks->end(), LessById())) {
simtracksTmp.reset(new SimTrackContainer(*simtracks));
Expand All @@ -218,7 +218,7 @@ void GenPlusSimParticleProducer::produce(Event& event,
if (gens->size() != genBarcodes->size()) throw cms::Exception("Corrupt data") << "Barcodes not of the same size as GenParticles!\n";

// make the output collection
auto_ptr<GenParticleCollection> candsPtr(new GenParticleCollection);
auto candsPtr = std::make_unique<GenParticleCollection>();
GenParticleCollection & cands = * candsPtr;

const GenParticleRefProd ref = event.getRefBeforePut<GenParticleCollection>();
Expand All @@ -230,7 +230,7 @@ void GenPlusSimParticleProducer::produce(Event& event,
}

// make new barcodes vector and fill it with the original list
auto_ptr<vector<int> > newGenBarcodes( new vector<int>() );
auto newGenBarcodes = std::make_unique<vector<int>>();
for (unsigned int i = 0; i < genBarcodes->size(); ++i) {
newGenBarcodes->push_back((*genBarcodes)[i]);
}
Expand Down Expand Up @@ -300,8 +300,8 @@ void GenPlusSimParticleProducer::produce(Event& event,
}
}

event.put(candsPtr);
event.put(newGenBarcodes);
event.put(std::move(candsPtr));
event.put(std::move(newGenBarcodes));
}

DEFINE_FWK_MODULE(GenPlusSimParticleProducer);
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace reco {
maps.push_back(& * matchMap);
}
utilsNew::CandMatcher<GenParticleCollection> match(maps);
auto_ptr<GenParticleMatch> matchMap(new GenParticleMatch(match.ref()));
auto matchMap = std::make_unique<GenParticleMatch>(match.ref());
int size = cands->size();
vector<int>::const_iterator begin = pdgId_.begin(), end = pdgId_.end();
if(size != 0) {
Expand All @@ -74,7 +74,7 @@ namespace reco {
filler.insert(ref, indices.begin(), indices.end());
filler.fill();
}
evt.put(matchMap);
evt.put(std::move(matchMap));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace reco {
private:
edm::EDGetTokenT<edm::View<reco::Candidate> > src_;
std::vector<Direction> items_;
std::auto_ptr<AbsVeto> veto_;
std::unique_ptr<AbsVeto> veto_;
};

class OtherJetConstituentsDeltaRVeto : public EventDependentAbsVeto {
Expand Down
4 changes: 2 additions & 2 deletions PhysicsTools/IsolationAlgos/interface/IsolationProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ void IsolationProducer<C1, C2, Alg, OutputCollection, Setup>::produce( edm::Even
Setup::init( alg_, es );

typename OutputCollection::refprod_type ref( src );
auto_ptr<OutputCollection> isolations( new OutputCollection( ref ) );
auto isolations = std::make_unique<OutputCollection>( ref );

size_t i = 0;
for( typename C1::const_iterator lep = src->begin(); lep != src->end(); ++ lep ) {
typename Alg::value_type iso= alg_(*lep,*elements);
isolations->setValue( i++, iso );
}
evt.put( isolations );
evt.put(std::move(isolations) );
}

#endif
4 changes: 2 additions & 2 deletions PhysicsTools/IsolationAlgos/interface/IsolationProducerNew.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace reco {
Setup::init(alg_, es);

::helper::MasterCollection<C1> master(src, evt);
auto_ptr<OutputCollection> isolations(new OutputCollection);
auto isolations = std::make_unique<OutputCollection>();
if(src->size()!= 0) {
typename OutputCollection::Filler filler(*isolations);
vector<double> iso(master.size(),-1);
Expand All @@ -83,7 +83,7 @@ namespace reco {
filler.insert(master.get(), iso.begin(), iso.end());
filler.fill();
}
evt.put( isolations );
evt.put(std::move(isolations) );
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ namespace citk {

void PFIsolationSumProducer::
produce(edm::Event& ev, const edm::EventSetup& es) {
typedef std::auto_ptr<edm::ValueMap<float> > product_type;
typedef std::unique_ptr<edm::ValueMap<float> > product_type;
typedef std::vector<float> product_values;
edm::Handle<CandView> to_isolate;
edm::Handle<CandView> isolate_with;
Expand Down Expand Up @@ -167,7 +167,7 @@ namespace citk {
the_values[i][j].begin(),
the_values[i][j].end());
fillerprod.fill();
ev.put(the_product,_product_names[i][j]);
ev.put(std::move(the_product),_product_names[i][j]);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ namespace citk {

void PFIsolationSumProducerForPUPPI::
produce(edm::Event& ev, const edm::EventSetup& es) {
typedef std::auto_ptr<edm::ValueMap<float> > product_type;
typedef std::unique_ptr<edm::ValueMap<float> > product_type;
typedef std::vector<float> product_values;
edm::Handle<CandView> to_isolate;
edm::Handle<CandView> isolate_with;
Expand Down Expand Up @@ -175,7 +175,7 @@ namespace citk {
the_values[i][j].begin(),
the_values[i][j].end());
fillerprod.fill();
ev.put(the_product,_product_names[i][j]);
ev.put(std::move(the_product),_product_names[i][j]);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void CandIsoDepositProducer::produce(Event& event, const EventSetup& eventSetup)
}

//! fill the maps here
std::unique_ptr<reco::IsoDepositMap> depMap(new reco::IsoDepositMap());
auto depMap = std::make_unique<reco::IsoDepositMap>();
reco::IsoDepositMap::Filler filler(*depMap);
filler.insert(hCands, deps2D[iDep].begin(), deps2D[iDep].end());
deps2D[iDep].clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ void CandIsolatorFromDeposits::produce(Event& event, const EventSetup& eventSetu
const IsoDepositMap & map = begin->map();

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

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

DEFINE_FWK_MODULE( CandIsolatorFromDeposits );
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ IsolationProducerForTracks::IsolationProducerForTracks(const ParameterSet & pset
}

void IsolationProducerForTracks::produce(Event & event, const EventSetup & setup) {
std::auto_ptr<TkIsoMap> caloIsolations(new TkIsoMap);
auto caloIsolations = std::make_unique<TkIsoMap>();
TkIsoMap::Filler filler(*caloIsolations);
{
Handle<CandidateView> tracks;
Expand Down Expand Up @@ -86,7 +86,7 @@ void IsolationProducerForTracks::produce(Event & event, const EventSetup & setup

// really fill the association map
filler.fill();
event.put(caloIsolations);
event.put(std::move(caloIsolations));
}

#include "FWCore/Framework/interface/MakerMacros.h"
Expand Down
4 changes: 2 additions & 2 deletions PhysicsTools/IsolationAlgos/src/IsoDepositVetoFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace reco { namespace isodeposit {
veto_->centerOn(eta,phi);
}
private:
std::auto_ptr<AbsVeto> veto_;
std::unique_ptr<AbsVeto> veto_;
bool barrel_;
};

Expand Down Expand Up @@ -72,7 +72,7 @@ namespace reco { namespace isodeposit {
reco::isodeposit::AbsVeto *
IsoDepositVetoFactory::make(const char *string, edm::ConsumesCollector& iC) {
reco::isodeposit::EventDependentAbsVeto * evdep = 0;
std::auto_ptr<reco::isodeposit::AbsVeto> ret(make(string,evdep, iC));
std::unique_ptr<reco::isodeposit::AbsVeto> ret(make(string,evdep, iC));
if (evdep != 0) {
throw cms::Exception("Configuration") << "The resulting AbsVeto depends on the edm::Event.\n"
<< "Please use the two-arguments IsoDepositVetoFactory::make.\n";
Expand Down
7 changes: 3 additions & 4 deletions PhysicsTools/JetCharge/plugins/JetChargeProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ void JetChargeProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::Ev

if (hJTAs->keyProduct().isNull()) {
// need to work around this bug someway, altough it's not stricly my fault
std::auto_ptr<JetChargeCollection> ret(new JetChargeCollection());
iEvent.put(ret);
iEvent.put(std::make_unique<JetChargeCollection>());
return;
}
std::auto_ptr<JetChargeCollection> ret(new JetChargeCollection(hJTAs->keyProduct()));
auto ret = std::make_unique<JetChargeCollection>(hJTAs->keyProduct());
for (IT it = hJTAs->begin(), ed = hJTAs->end(); it != ed; ++it) {
const JetRef &jet = it->first;
const reco::TrackRefVector &tracks = it->second;
float val = static_cast<float>( algo_.charge(jet->p4(), tracks) );
reco::JetFloatAssociation::setValue(*ret, jet, val);
}

iEvent.put(ret);
iEvent.put(std::move(ret));
}
2 changes: 1 addition & 1 deletion PhysicsTools/JetMCAlgos/interface/BasePartonSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BasePartonSelector
~BasePartonSelector();

virtual void run(const edm::Handle<reco::GenParticleCollection> & particles,
std::auto_ptr<reco::GenParticleRefVector> & partons);
std::unique_ptr<reco::GenParticleRefVector> & partons);
};

#endif
2 changes: 1 addition & 1 deletion PhysicsTools/JetMCAlgos/interface/Herwig6PartonSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Herwig6PartonSelector : public BasePartonSelector
virtual ~Herwig6PartonSelector();

void run(const edm::Handle<reco::GenParticleCollection> & particles,
std::auto_ptr<reco::GenParticleRefVector> & partons);
std::unique_ptr<reco::GenParticleRefVector> & partons);
};

#endif
2 changes: 1 addition & 1 deletion PhysicsTools/JetMCAlgos/interface/HerwigppPartonSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class HerwigppPartonSelector : public BasePartonSelector
virtual ~HerwigppPartonSelector();

void run(const edm::Handle<reco::GenParticleCollection> & particles,
std::auto_ptr<reco::GenParticleRefVector> & partons);
std::unique_ptr<reco::GenParticleRefVector> & partons);
};

#endif
Loading

0 comments on commit 42945c4

Please sign in to comment.