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 30, 2016
1 parent ba7bdf3 commit 157b8ce
Show file tree
Hide file tree
Showing 47 changed files with 153 additions and 200 deletions.
10 changes: 5 additions & 5 deletions RecoBTag/ImpactParameter/plugins/IPProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ IPProducer<Container,Base,Helper>::produce(edm::Event& iEvent, const edm::EventS
// m_algo.setTransientTrackBuilder(builder.product());

// output collections
std::auto_ptr<Product> result(new Product);
auto result = std::make_unique<Product>();

std::auto_ptr<reco::TrackCollection> ghostTracks;
std::unique_ptr<reco::TrackCollection> ghostTracks;
reco::TrackRefProd ghostTrackRefProd;
if (m_computeGhostTrack) {
ghostTracks.reset(new reco::TrackCollection);
ghostTracks = std::make_unique<reco::TrackCollection>();
ghostTrackRefProd = iEvent.getRefBeforePut<reco::TrackCollection>("ghostTracks");
}

Expand Down Expand Up @@ -417,8 +417,8 @@ IPProducer<Container,Base,Helper>::produce(edm::Event& iEvent, const edm::EventS
}

if (m_computeGhostTrack)
iEvent.put(ghostTracks, "ghostTracks");
iEvent.put(result);
iEvent.put(std::move(ghostTracks), "ghostTracks");
iEvent.put(std::move(result));
}


Expand Down
4 changes: 2 additions & 2 deletions RecoBTag/SecondaryVertex/plugins/BVertexFilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ BVertexFilterT<VTX>::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
edm::Handle<edm::View<VTX> > svHandle;
iEvent.getByToken(token_secondaryVertex, svHandle);

std::auto_ptr<std::vector<VTX> > recoVertices(new std::vector<VTX>);
auto recoVertices = std::make_unique<std::vector<VTX>>();

if(pvHandle->size()!=0) {
const reco::Vertex & primary = (*pvHandle.product())[0];
Expand All @@ -102,7 +102,7 @@ BVertexFilterT<VTX>::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
}
}
}
iEvent.put(recoVertices);
iEvent.put(std::move(recoVertices));

return(count >= minVertices);
}
Expand Down
7 changes: 3 additions & 4 deletions RecoBTag/SecondaryVertex/plugins/BtoCharmDecayVertexMerger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,12 @@ void BtoCharmDecayVertexMergerT<VTX>::produce(edm::Event &iEvent, const edm::Eve
}

// now create new vertex collection and add to event
std::auto_ptr<std::vector<VTX> > bvertColl(new std::vector<VTX>);
auto bvertColl = std::make_unique<std::vector<VTX>>();
for(typename std::vector<VertexProxy>::const_iterator it=vertexProxyColl.begin(); it!=vertexProxyColl.end(); ++it) bvertColl->push_back((*it).vert);
iEvent.put(bvertColl);
iEvent.put(std::move(bvertColl));
}
else{
std::auto_ptr<std::vector<VTX> > bvertCollEmpty(new std::vector<VTX>);
iEvent.put(bvertCollEmpty);
iEvent.put(std::make_unique<std::vector<VTX>>());
}
}
//------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ void TemplatedSecondaryVertexProducer<IPTI,VTX>::produce(edm::Event &event,

// result secondary vertices

std::auto_ptr<Product> tagInfos(new Product);
auto tagInfos = std::make_unique<Product>();

for(typename std::vector<IPTI>::const_iterator iterJets =
trackIPTagInfos->begin(); iterJets != trackIPTagInfos->end();
Expand Down Expand Up @@ -908,7 +908,7 @@ void TemplatedSecondaryVertexProducer<IPTI,VTX>::produce(edm::Event &event,
iterJets - trackIPTagInfos->begin())));
}

event.put(tagInfos);
event.put(std::move(tagInfos));
}

//Need specialized template because reco::Vertex iterators are TrackBase and it is a mess to make general
Expand Down
4 changes: 2 additions & 2 deletions RecoBTag/SoftLepton/interface/GenericSelectorByValueMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ GenericSelectorByValueMap<T,C>::GenericSelectorByValueMap(edm::ParameterSet cons
template <typename T, typename C>
void GenericSelectorByValueMap<T, C>::produce(edm::Event & event, const edm::EventSetup & setup)
{
std::auto_ptr<edm::RefToBaseVector<candidate_type> > candidates(new edm::RefToBaseVector<candidate_type>());
auto candidates = std::make_unique<edm::RefToBaseVector<candidate_type>>();

// read the collection of GsfElectrons from the Event
edm::Handle<edm::View<candidate_type> > h_electrons;
Expand All @@ -102,7 +102,7 @@ void GenericSelectorByValueMap<T, C>::produce(edm::Event & event, const edm::Eve
}

// put the product in the event
event.put(candidates);
event.put(std::move(candidates));
}

} // namespace edm;
Expand Down
4 changes: 2 additions & 2 deletions RecoBTag/SoftLepton/plugins/SoftLepton.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ SoftLepton::produce(edm::Event & event, const edm::EventSetup & setup) {
}

// output collections
std::auto_ptr<reco::SoftLeptonTagInfoCollection> outputCollection( new reco::SoftLeptonTagInfoCollection() );
auto outputCollection = std::make_unique<reco::SoftLeptonTagInfoCollection>();
for (unsigned int i = 0; i < jets.size(); ++i) {
reco::SoftLeptonTagInfo result = tag( jets[i], tracks[i], leptons, vertex );
outputCollection->push_back( result );
}
event.put( outputCollection );
event.put(std::move(outputCollection));
}

// ---------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions RecoBTag/SoftLepton/plugins/SoftPFElectronTagInfoProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ SoftPFElectronTagInfoProducer::~SoftPFElectronTagInfoProducer()

void SoftPFElectronTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
{
std::auto_ptr<reco::CandSoftLeptonTagInfoCollection> theElecTagInfo(new reco::CandSoftLeptonTagInfoCollection);
auto theElecTagInfo = std::make_unique<reco::CandSoftLeptonTagInfoCollection>();
edm::ESHandle<TransientTrackBuilder> builder;
iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
transientTrackBuilder=builder.product();
Expand Down Expand Up @@ -120,7 +120,7 @@ void SoftPFElectronTagInfoProducer::produce(edm::Event& iEvent, const edm::Event
}
theElecTagInfo->push_back(tagInfo);
}
iEvent.put(theElecTagInfo);
iEvent.put(std::move(theElecTagInfo));
}

bool SoftPFElectronTagInfoProducer::isElecClean(edm::Event& iEvent,const reco::GsfElectron*candidate)
Expand Down
4 changes: 2 additions & 2 deletions RecoBTag/SoftLepton/plugins/SoftPFMuonTagInfoProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ SoftPFMuonTagInfoProducer::~SoftPFMuonTagInfoProducer() {}

void SoftPFMuonTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
// Declare produced collection
std::auto_ptr<reco::CandSoftLeptonTagInfoCollection> theMuonTagInfo(new reco::CandSoftLeptonTagInfoCollection);
auto theMuonTagInfo = std::make_unique<reco::CandSoftLeptonTagInfoCollection>();

// Declare and open Jet collection
edm::Handle<edm::View<reco::Jet> > theJetCollection;
Expand Down Expand Up @@ -149,7 +149,7 @@ void SoftPFMuonTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetu
} // --- End loop on jets

// Put the TagInfo collection in the event
iEvent.put(theMuonTagInfo);
iEvent.put(std::move(theMuonTagInfo));
}


Expand Down
13 changes: 6 additions & 7 deletions RecoBTau/JetCrystalsAssociator/src/JetCrystalsAssociator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class JetCrystalsAssociator : public edm::EDProducer {

virtual void produce(edm::Event&, const edm::EventSetup&) override;
private:
std::auto_ptr<JetCrystalsAssociationCollection> associate(
std::unique_ptr<JetCrystalsAssociationCollection> associate(
const edm::Handle<CaloJetCollection> & jets,
const edm::OrphanHandle<EMLorentzVectorCollection> & myLorentzRecHits) const;

Expand Down Expand Up @@ -140,7 +140,7 @@ JetCrystalsAssociator::produce(edm::Event& iEvent, const edm::EventSetup& iSetup
iEvent.getByLabel( m_EBRecHits, EBRecHits );
iEvent.getByLabel( m_EERecHits, EERecHits );

std::auto_ptr<EMLorentzVectorCollection> jetRecHits( new EMLorentzVectorCollection() );
auto jetRecHits = std::make_unique<EMLorentzVectorCollection>();
//loop on jets and associate
for (size_t t = 0; t < jets->size(); t++)
{
Expand Down Expand Up @@ -201,18 +201,17 @@ JetCrystalsAssociator::produce(edm::Event& iEvent, const edm::EventSetup& iSetup
}
}

edm::OrphanHandle <reco::EMLorentzVectorCollection> myRecHits = iEvent.put(jetRecHits);
edm::OrphanHandle <reco::EMLorentzVectorCollection> myRecHits = iEvent.put(std::move(jetRecHits));

std::auto_ptr<JetCrystalsAssociationCollection> jetCrystals = associate(jets,myRecHits);
iEvent.put( jetCrystals );
iEvent.put(associate(jets,myRecHits));
}

std::auto_ptr<JetCrystalsAssociationCollection> JetCrystalsAssociator::associate(
std::unique_ptr<JetCrystalsAssociationCollection> JetCrystalsAssociator::associate(
const edm::Handle<CaloJetCollection> & jets,
const edm::OrphanHandle<EMLorentzVectorCollection> & myLorentzRecHits) const
{
// we know we will save an element per input jet
std::auto_ptr<JetCrystalsAssociationCollection> outputCollection( new JetCrystalsAssociationCollection( jets->size() ) );
auto outputCollection = std::make_unique<JetCrystalsAssociationCollection>(jets->size());

//loop on jets and associate
for (size_t j = 0; j < jets->size(); j++) {
Expand Down
8 changes: 4 additions & 4 deletions RecoBTau/JetTagComputer/plugins/JetTagProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ JetTagProducer::produce(Event& iEvent, const EventSetup& iSetup)

// take first tagInfo
Handle< View<BaseTagInfo> > &tagInfoHandle = tagInfoHandles[0];
auto_ptr<JetTagCollection> jetTagCollection;
std::unique_ptr<JetTagCollection> jetTagCollection;
if (tagInfoHandle.product()->size() > 0) {
RefToBase<Jet> jj = tagInfoHandle->begin()->jet();
jetTagCollection.reset(new JetTagCollection(edm::makeRefToBaseProdFrom(jj, iEvent)));
jetTagCollection = std::make_unique<JetTagCollection>(edm::makeRefToBaseProdFrom(jj, iEvent));
} else
jetTagCollection.reset(new JetTagCollection());
jetTagCollection = std::make_unique<JetTagCollection>();

// now loop over the map and compute all JetTags
for(JetToTagInfoMap::const_iterator iter = jetToTagInfos.begin();
Expand All @@ -149,7 +149,7 @@ JetTagProducer::produce(Event& iEvent, const EventSetup& iSetup)
(*jetTagCollection)[iter->first] = discriminator;
}

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

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
Expand Down
8 changes: 2 additions & 6 deletions RecoLuminosity/LumiProducer/plugins/BunchSpacingProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ BunchSpacingProducer::~BunchSpacingProducer(){
void BunchSpacingProducer::produce(edm::Event& e, const edm::EventSetup& iSetup)
{
if ( overRide_ ) {
std::auto_ptr<unsigned int> pOut1(new unsigned int);
*pOut1=bunchSpacingOverride_;
e.put(pOut1);
e.put(std::make_unique<unsigned int>(bunchSpacingOverride_));
return;
}

Expand All @@ -91,9 +89,7 @@ void BunchSpacingProducer::produce(edm::Event& e, const edm::EventSetup& iSetup)
bunchSpacing = *bunchSpacingH;
}

std::auto_ptr<unsigned int> pOut1(new unsigned int);
*pOut1=bunchSpacing;
e.put(pOut1);
e.put(std::make_unique<unsigned int>(bunchSpacing));
return;
}

Expand Down
28 changes: 8 additions & 20 deletions RecoLuminosity/LumiProducer/plugins/ExpressLumiProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,8 @@ ExpressLumiProducer::produce(edm::Event& e, const edm::EventSetup& iSetup)

void
ExpressLumiProducer::writeEmptyProductForEntry(edm::LuminosityBlock &iLBlock){
std::auto_ptr<LumiSummary> pOut1;
std::auto_ptr<LumiDetails> pOut2;
LumiSummary* pIn1=new LumiSummary;
LumiDetails* pIn2=new LumiDetails;
pOut1.reset(pIn1);
iLBlock.put(pOut1);
pOut2.reset(pIn2);
iLBlock.put(pOut2);
iLBlock.put(std::make_unique<LumiSummary>());
iLBlock.put(std::make_unique<LumiDetails>());
}
void
ExpressLumiProducer::beginLuminosityBlockProduce(edm::LuminosityBlock &iLBlock, edm::EventSetup const &iSetup)
Expand Down Expand Up @@ -357,17 +351,13 @@ ExpressLumiProducer::fillLSCache(unsigned int runnumber,unsigned int currentlsnu
void
ExpressLumiProducer::writeProductsForEntry(edm::LuminosityBlock & iLBlock,unsigned int luminum){
//std::cout<<"writing runnumber,luminum "<<runnumber<<" "<<luminum<<std::endl;
std::auto_ptr<LumiSummary> pOut1;
std::auto_ptr<LumiDetails> pOut2;
LumiSummary* pIn1=new LumiSummary;
LumiDetails* pIn2=new LumiDetails;
auto pIn1 = std::make_unique<LumiSummary>();
auto pIn2 = std::make_unique<LumiDetails>();
if(m_isNullRun){
pIn1->setLumiVersion("DIP");
pIn2->setLumiVersion("DIP");
pOut1.reset(pIn1);
iLBlock.put(pOut1);
pOut2.reset(pIn2);
iLBlock.put(pOut2);
iLBlock.put(std::move(pIn1));
iLBlock.put(std::move(pIn2));
return;
}
PerLSData& lsdata=m_lscache[luminum];
Expand All @@ -380,10 +370,8 @@ ExpressLumiProducer::writeProductsForEntry(edm::LuminosityBlock & iLBlock,unsign

pIn2->setLumiVersion("DIP");
pIn2->fill(LumiDetails::kOCC1,lsdata.bunchlumivalue,lsdata.bunchlumierror,lsdata.bunchlumiquality);
pOut1.reset(pIn1);
iLBlock.put(pOut1);
pOut2.reset(pIn2);
iLBlock.put(pOut2);
iLBlock.put(std::move(pIn1));
iLBlock.put(std::move(pIn2));
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(ExpressLumiProducer);
32 changes: 10 additions & 22 deletions RecoLuminosity/LumiProducer/plugins/LumiProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,8 @@ void LumiProducer::beginLuminosityBlockProduce(edm::LuminosityBlock &iLBlock, ed
//std::cout<<"beg of beginLuminosityBlock "<<luminum<<std::endl;
//if is null run, fill empty values and return
if(m_isNullRun){
std::auto_ptr<LumiSummary> pOut1;
std::auto_ptr<LumiDetails> pOut2;
LumiSummary* pIn1=new LumiSummary;
LumiDetails* pIn2=new LumiDetails;
pOut1.reset(pIn1);
iLBlock.put(pOut1);
pOut2.reset(pIn2);
iLBlock.put(pOut2);
iLBlock.put(std::make_unique<LumiSummary>());
iLBlock.put(std::make_unique<LumiDetails>());
return;
}
if(m_lscache.find(luminum)==m_lscache.end()){
Expand All @@ -472,10 +466,10 @@ LumiProducer::endRun(edm::Run const& run,edm::EventSetup const &iSetup)
void
LumiProducer::endRunProduce(edm::Run& run,edm::EventSetup const &iSetup)
{
std::auto_ptr<LumiSummaryRunHeader> lsrh(new LumiSummaryRunHeader());
auto lsrh = std::make_unique<LumiSummaryRunHeader>();
lsrh->swapL1Names(m_runcache.TRGBitNames);
lsrh->swapHLTNames(m_runcache.HLTPathNames);
run.put(lsrh);
run.put(std::move(lsrh));
m_runcache.TRGBitNameToIndex.clear();
m_runcache.HLTPathNameToIndex.clear();
}
Expand Down Expand Up @@ -818,17 +812,13 @@ LumiProducer::fillLSCache(unsigned int luminum){
void
LumiProducer::writeProductsForEntry(edm::LuminosityBlock & iLBlock,unsigned int runnumber,unsigned int luminum){
//std::cout<<"writing runnumber,luminum "<<runnumber<<" "<<luminum<<std::endl;
std::auto_ptr<LumiSummary> pOut1;
std::auto_ptr<LumiDetails> pOut2;
LumiSummary* pIn1=new LumiSummary;
LumiDetails* pIn2=new LumiDetails;
auto pIn1 = std::make_unique<LumiSummary>();
auto pIn2 = std::make_unique<LumiDetails>();
if(m_isNullRun){
pIn1->setLumiVersion("-1");
pIn2->setLumiVersion("-1");
pOut1.reset(pIn1);
iLBlock.put(pOut1);
pOut2.reset(pIn2);
iLBlock.put(pOut2);
iLBlock.put(std::move(pIn1));
iLBlock.put(std::move(pIn2));
return;
}
PerLSData& lsdata=m_lscache[luminum];
Expand Down Expand Up @@ -873,10 +863,8 @@ LumiProducer::writeProductsForEntry(edm::LuminosityBlock & iLBlock,unsigned int
}
}
pIn2->setLumiVersion(m_lumiversion);
pOut1.reset(pIn1);
iLBlock.put(pOut1);
pOut2.reset(pIn2);
iLBlock.put(pOut2);
iLBlock.put(std::move(pIn1));
iLBlock.put(std::move(pIn2));
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(LumiProducer);
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void PixelVertexProducerClusters::produce

const SiPixelRecHitCollection* thePixelHits = pixelColl.product();

std::auto_ptr<reco::VertexCollection> vertices(new reco::VertexCollection);
auto vertices = std::make_unique<reco::VertexCollection>();

if(thePixelHits->size() > 0)
{
Expand Down Expand Up @@ -177,6 +177,6 @@ void PixelVertexProducerClusters::produce
vertices->push_back(ver);
}

ev.put(vertices);
ev.put(std::move(vertices));
}

Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void PixelVertexProducerMedian::produce
<< tracks.size() << " (out of " << tracks_.size()
<< ")";

std::auto_ptr<reco::VertexCollection> vertices(new reco::VertexCollection);
auto vertices = std::make_unique<reco::VertexCollection>();

if(tracks.size() > 0)
{
Expand Down Expand Up @@ -138,6 +138,6 @@ void PixelVertexProducerMedian::produce
vertices->push_back(ver);
}
}
ev.put(vertices);
ev.put(std::move(vertices));
}

Loading

0 comments on commit 157b8ce

Please sign in to comment.