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 Apr 25, 2016
1 parent 427461b commit b8366ba
Show file tree
Hide file tree
Showing 104 changed files with 389 additions and 389 deletions.
8 changes: 4 additions & 4 deletions HLTrigger/Egamma/src/HLTScoutingEgammaProducer.cc
Expand Up @@ -147,8 +147,8 @@ void HLTScoutingEgammaProducer::produce(edm::StreamID sid, edm::Event & iEvent,
}

// Produce electrons and photons
std::auto_ptr<ScoutingElectronCollection> outElectrons(new ScoutingElectronCollection());
std::auto_ptr<ScoutingPhotonCollection> outPhotons(new ScoutingPhotonCollection());
std::unique_ptr<ScoutingElectronCollection> outElectrons(new ScoutingElectronCollection());
std::unique_ptr<ScoutingPhotonCollection> outPhotons(new ScoutingPhotonCollection());
int index = 0;
for (auto &candidate : *EgammaCandidateCollection) {
reco::RecoEcalCandidateRef candidateRef = getRef(EgammaCandidateCollection, index);
Expand Down Expand Up @@ -200,8 +200,8 @@ void HLTScoutingEgammaProducer::produce(edm::StreamID sid, edm::Event & iEvent,
}

// Put output
iEvent.put(outElectrons);
iEvent.put(outPhotons);
iEvent.put(std::move(outElectrons));
iEvent.put(std::move(outPhotons));
}

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
Expand Down
12 changes: 6 additions & 6 deletions HLTrigger/HLTcore/plugins/HLTPrescaleRecorder.cc
Expand Up @@ -203,8 +203,8 @@ void HLTPrescaleRecorder::produce(edm::Event& iEvent, const edm::EventSetup& iSe

if (event_) {
/// Writing to Event
auto_ptr<HLTPrescaleTable> product (new HLTPrescaleTable(hlt_));
iEvent.put(product,"Event");
unique_ptr<HLTPrescaleTable> product (new HLTPrescaleTable(hlt_));
iEvent.put(std::move(product),"Event");
}

return;
Expand All @@ -216,8 +216,8 @@ void HLTPrescaleRecorder::endLuminosityBlockProduce(edm::LuminosityBlock& iLumi,

if (lumi_) {
/// Writing to Lumi Block
auto_ptr<HLTPrescaleTable> product (new HLTPrescaleTable(hlt_));
iLumi.put(product,"Lumi");
unique_ptr<HLTPrescaleTable> product (new HLTPrescaleTable(hlt_));
iLumi.put(std::move(product),"Lumi");
}
return;
}
Expand Down Expand Up @@ -273,7 +273,7 @@ void HLTPrescaleRecorder::endRun(edm::Run const& iRun, const edm::EventSetup& iS
void HLTPrescaleRecorder::endRunProduce(edm::Run& iRun, const edm::EventSetup& iSetup) {
if (run_) {
/// Writing to Run Block
auto_ptr<HLTPrescaleTable> product (new HLTPrescaleTable(hlt_));
iRun.put(product,"Run");
unique_ptr<HLTPrescaleTable> product (new HLTPrescaleTable(hlt_));
iRun.put(std::move(product),"Run");
}
}
4 changes: 2 additions & 2 deletions HLTrigger/HLTcore/plugins/TriggerSummaryProducerAOD.cc
Expand Up @@ -299,7 +299,7 @@ TriggerSummaryProducerAOD::produce(edm::Event& iEvent, const edm::EventSetup& iS

///
/// construct single AOD product, reserving capacity
auto_ptr<TriggerEvent> product(new TriggerEvent(pn_,nk,no,nf));
unique_ptr<TriggerEvent> product(new TriggerEvent(pn_,nk,no,nf));

/// fill trigger object collection
product->addCollections(tags_,keys_);
Expand Down Expand Up @@ -339,7 +339,7 @@ TriggerSummaryProducerAOD::produce(edm::Event& iEvent, const edm::EventSetup& iS
}
}

OrphanHandle<TriggerEvent> ref = iEvent.put(product);
OrphanHandle<TriggerEvent> ref = iEvent.put(std::move(product));
LogTrace("TriggerSummaryProducerAOD") << "Number of physics objects packed: " << ref->sizeObjects();
LogTrace("TriggerSummaryProducerAOD") << "Number of filter objects packed: " << ref->sizeFilters();

Expand Down
4 changes: 2 additions & 2 deletions HLTrigger/HLTcore/plugins/TriggerSummaryProducerRAW.cc
Expand Up @@ -79,7 +79,7 @@ TriggerSummaryProducerRAW::produce(edm::Event& iEvent, const edm::EventSetup&)
LogDebug("TriggerSummaryProducerRaw") << "Number of filter objects found: " << nfob;

// construct single RAW product
auto_ptr<TriggerEventWithRefs> product(new TriggerEventWithRefs(pn_,nfob));
unique_ptr<TriggerEventWithRefs> product(new TriggerEventWithRefs(pn_,nfob));
for (unsigned int ifob=0; ifob!=nfob; ++ifob) {
const string& label (fobs[ifob].provenance()->moduleLabel());
const string& instance (fobs[ifob].provenance()->productInstanceName());
Expand Down Expand Up @@ -130,7 +130,7 @@ TriggerSummaryProducerRAW::produce(edm::Event& iEvent, const edm::EventSetup&)
}

// place product in Event
OrphanHandle<TriggerEventWithRefs> ref = iEvent.put(product);
OrphanHandle<TriggerEventWithRefs> ref = iEvent.put(std::move(product));
LogTrace("TriggerSummaryProducerRaw") << "Number of filter objects packed: " << ref->size();

return;
Expand Down
4 changes: 2 additions & 2 deletions HLTrigger/HLTcore/src/HLTFilter.cc
Expand Up @@ -34,13 +34,13 @@ HLTFilter::~HLTFilter()
{ }

bool HLTFilter::filter(edm::StreamID, edm::Event & event, const edm::EventSetup & setup) const {
std::auto_ptr<trigger::TriggerFilterObjectWithRefs> filterproduct( new trigger::TriggerFilterObjectWithRefs(path(event), module(event)) );
std::unique_ptr<trigger::TriggerFilterObjectWithRefs> filterproduct( new trigger::TriggerFilterObjectWithRefs(path(event), module(event)) );

// compute the result of the HLTFilter implementation
bool result = hltFilter(event, setup, * filterproduct);

// put filter object into the Event
event.put(filterproduct);
event.put(std::move(filterproduct));

// retunr the result of the HLTFilter
return result;
Expand Down
4 changes: 2 additions & 2 deletions HLTrigger/HLTcore/src/HLTStreamFilter.cc
Expand Up @@ -34,13 +34,13 @@ HLTStreamFilter::~HLTStreamFilter()
{ }

bool HLTStreamFilter::filter(edm::Event & event, const edm::EventSetup & setup) {
std::auto_ptr<trigger::TriggerFilterObjectWithRefs> filterproduct( new trigger::TriggerFilterObjectWithRefs(path(event), module(event)) );
std::unique_ptr<trigger::TriggerFilterObjectWithRefs> filterproduct( new trigger::TriggerFilterObjectWithRefs(path(event), module(event)) );

// compute the result of the HLTStreamFilter implementation
bool result = hltFilter(event, setup, * filterproduct);

// put filter object into the Event
event.put(filterproduct);
event.put(std::move(filterproduct));

// retunr the result of the HLTStreamFilter
return result;
Expand Down
8 changes: 4 additions & 4 deletions HLTrigger/HLTfilters/src/TestBXVectorRefProducer.cc
Expand Up @@ -111,8 +111,8 @@ TestBXVectorRefProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet
{
using namespace edm;

auto_ptr<vector<int>> jetMom ( new vector<int> );
auto_ptr<l1t::JetRefVector> jetRef ( new l1t::JetRefVector );
unique_ptr<vector<int>> jetMom ( new vector<int> );
unique_ptr<l1t::JetRefVector> jetRef ( new l1t::JetRefVector );

// retrieve the tracks
Handle<l1t::JetBxCollection> jets;
Expand All @@ -134,9 +134,9 @@ TestBXVectorRefProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet

} // end for

iEvent.put(jetMom,"jetPt");
iEvent.put(std::move(jetMom),"jetPt");

if (doRefs_) iEvent.put(jetRef,"l1tJetRef");
if (doRefs_) iEvent.put(std::move(jetRef),"l1tJetRef");

return;

Expand Down
6 changes: 3 additions & 3 deletions HLTrigger/JetMET/interface/HLTJetsCleanedFromLeadingLeptons.h
Expand Up @@ -266,10 +266,10 @@ void HLTJetsCleanedFromLeadingLeptons<JetType>::produce(edm::Event &iEvent,


// Store the collection in the event
std::auto_ptr<JetCollectionVector> product(new JetCollectionVector);
//^ Have to use the depricated auto_ptr here because this is what edm::Event::put expects
std::unique_ptr<JetCollectionVector> product(new JetCollectionVector);
//^ Have to use the depricated unique_ptr here because this is what edm::Event::put expects
product->emplace_back(cleanedJetRefs);
iEvent.put(product);
iEvent.put(std::move(product));
}

#endif // HLTJetsCleanedFromLeadingLeptons_h
2 changes: 1 addition & 1 deletion HLTrigger/JetMET/interface/HLTRHemisphere.h
Expand Up @@ -47,7 +47,7 @@ class HLTRHemisphere : public edm::stream::EDFilter<> {
int max_NJ_; // don't calculate R if event has more than NJ jets
bool accNJJets_; // accept or reject events with high NJ

void ComputeHemispheres(std::auto_ptr<std::vector<math::XYZTLorentzVector> >& hlist, const std::vector<math::XYZTLorentzVector>& JETS, std::vector<math::XYZTLorentzVector> *extraJets=0);
void ComputeHemispheres(std::unique_ptr<std::vector<math::XYZTLorentzVector> >& hlist, const std::vector<math::XYZTLorentzVector>& JETS, std::vector<math::XYZTLorentzVector> *extraJets=0);
};

#endif //HLTRHemisphere_h
4 changes: 2 additions & 2 deletions HLTrigger/JetMET/plugins/HLTJetHbbFilter.cc
Expand Up @@ -185,14 +185,14 @@ HLTJetHbbFilter<T>::hltFilter(edm::Event& event, const edm::EventSetup& setup,tr
filterproduct.addObject(triggerType_,ref2);

//create METCollection for storing csv tag1 and tag2 results
std::auto_ptr<reco::METCollection> csvObject(new reco::METCollection());
std::unique_ptr<reco::METCollection> csvObject(new reco::METCollection());
reco::MET::LorentzVector csvP4(tag1,tag2,0,0);
reco::MET::Point vtx(0,0,0);
reco::MET csvTags(csvP4, vtx);
csvObject->push_back(csvTags);
edm::RefProd<reco::METCollection > ref_before_put = event.getRefBeforePut<reco::METCollection >();
//put the METCollection into the event (necessary because of how addCollectionTag works...)
event.put(csvObject);
event.put(std::move(csvObject));
edm::Ref<reco::METCollection> csvRef(ref_before_put, 0);
if (saveTags()) filterproduct.addCollectionTag(edm::InputTag( *moduleLabel()));
filterproduct.addObject(trigger::TriggerMET, csvRef); //give it the ID of a MET object
Expand Down
4 changes: 2 additions & 2 deletions HLTrigger/JetMET/plugins/HLTRFilter.cc
Expand Up @@ -189,7 +189,7 @@ HLTRFilter::hltFilter(edm::Event& iEvent, const edm::EventSetup& iSetup, trigger
void HLTRFilter::addObjects(edm::Event& iEvent, trigger::TriggerFilterObjectWithRefs & filterproduct, double MR, double Rsq) const{

//create METCollection for storing MR and Rsq results
std::auto_ptr<reco::METCollection> razorObject(new reco::METCollection());
std::unique_ptr<reco::METCollection> razorObject(new reco::METCollection());

reco::MET::LorentzVector mrRsqP4(MR,Rsq,0,0);
reco::MET::Point vtx(0,0,0);
Expand All @@ -200,7 +200,7 @@ void HLTRFilter::addObjects(edm::Event& iEvent, trigger::TriggerFilterObjectWith
edm::RefProd<reco::METCollection > ref_before_put = iEvent.getRefBeforePut<reco::METCollection >();

//put the METCollection into the event (necessary because of how addCollectionTag works...)
iEvent.put(razorObject);
iEvent.put(std::move(razorObject));
edm::Ref<reco::METCollection> mrRsqRef(ref_before_put, 0);

//add it to the trigger object collection
Expand Down
10 changes: 5 additions & 5 deletions HLTrigger/JetMET/plugins/HLTRHemisphere.cc
Expand Up @@ -93,7 +93,7 @@ HLTRHemisphere::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
if(doMuonCorrection_) iEvent.getByToken( m_theMuonToken,muons );

// The output Collection
std::auto_ptr<vector<math::XYZTLorentzVector> > Hemispheres(new vector<math::XYZTLorentzVector> );
std::unique_ptr<vector<math::XYZTLorentzVector> > Hemispheres(new vector<math::XYZTLorentzVector> );

// look at all objects, check cuts and add to filter object
int n(0);
Expand All @@ -106,7 +106,7 @@ HLTRHemisphere::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
}

if(n>max_NJ_ && max_NJ_!=-1){
iEvent.put(Hemispheres);
iEvent.put(std::move(Hemispheres));
return accNJJets_; // too many jets, accept for timing
}

Expand All @@ -119,7 +119,7 @@ HLTRHemisphere::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
for(muonIt = muons->begin(); muonIt!=muons->end(); muonIt++,index++){
if(std::abs(muonIt->eta()) > muonEta_ || muonIt->pt() < min_Jet_Pt_) continue; // skip muons out of eta range or too low pT
if(nPassMu >= 2){ // if we have already accepted two muons, accept the event
iEvent.put(Hemispheres); // too many muons, accept for timing
iEvent.put(std::move(Hemispheres)); // too many muons, accept for timing
return true;
}
muonIndex[nPassMu++] = index;
Expand Down Expand Up @@ -151,12 +151,12 @@ HLTRHemisphere::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
// 0 muon: 2 hemispheres (2)
// 1 muon: 2 hemisheress + leadMuP4 + 2 hemispheres (5)
// 2 muon: 2 hemispheres + leadMuP4 + 2 hemispheres + 2ndMuP4 + 4 Hemispheres (10)
iEvent.put(Hemispheres);
iEvent.put(std::move(Hemispheres));
return true;
}

void
HLTRHemisphere::ComputeHemispheres(std::auto_ptr<std::vector<math::XYZTLorentzVector> >& hlist, const std::vector<math::XYZTLorentzVector>& JETS,
HLTRHemisphere::ComputeHemispheres(std::unique_ptr<std::vector<math::XYZTLorentzVector> >& hlist, const std::vector<math::XYZTLorentzVector>& JETS,
std::vector<math::XYZTLorentzVector>* extraJets){
using namespace math;
using namespace reco;
Expand Down
20 changes: 10 additions & 10 deletions HLTrigger/JetMET/plugins/HLTScoutingCaloProducer.cc
Expand Up @@ -85,7 +85,7 @@ HLTScoutingCaloProducer::produce(edm::StreamID sid, edm::Event & iEvent, edm::Ev

//get calo jets
Handle<reco::CaloJetCollection> caloJetCollection;
std::auto_ptr<ScoutingCaloJetCollection> outCaloJets(new ScoutingCaloJetCollection());
std::unique_ptr<ScoutingCaloJetCollection> outCaloJets(new ScoutingCaloJetCollection());
if(iEvent.getByToken(caloJetCollection_, caloJetCollection)){
for(auto &jet : *caloJetCollection){
if(jet.pt() > caloJetPtCut && fabs(jet.eta()) < caloJetEtaCut){
Expand All @@ -102,7 +102,7 @@ HLTScoutingCaloProducer::produce(edm::StreamID sid, edm::Event & iEvent, edm::Ev

//get vertices
Handle<reco::VertexCollection> vertexCollection;
std::auto_ptr<ScoutingVertexCollection> outVertices(new ScoutingVertexCollection());
std::unique_ptr<ScoutingVertexCollection> outVertices(new ScoutingVertexCollection());
if(iEvent.getByToken(vertexCollection_, vertexCollection)){
//produce vertices (only if present; otherwise return an empty collection)
for(auto &vtx : *vertexCollection){
Expand All @@ -114,26 +114,26 @@ HLTScoutingCaloProducer::produce(edm::StreamID sid, edm::Event & iEvent, edm::Ev

//get rho
Handle<double>rho;
std::auto_ptr<double> outRho(new double(-999));
std::unique_ptr<double> outRho(new double(-999));
if(iEvent.getByToken(rho_, rho)){
outRho.reset(new double(*rho));
}

//get MET
Handle<reco::CaloMETCollection> metCollection;
std::auto_ptr<double> outMetPt(new double(-999));
std::auto_ptr<double> outMetPhi(new double(-999));
std::unique_ptr<double> outMetPt(new double(-999));
std::unique_ptr<double> outMetPhi(new double(-999));
if(doMet && iEvent.getByToken(metCollection_, metCollection)){
outMetPt.reset(new double(metCollection->front().pt()));
outMetPhi.reset(new double(metCollection->front().phi()));
}

//put output
iEvent.put(outCaloJets);
iEvent.put(outVertices);
iEvent.put(outRho, "rho");
iEvent.put(outMetPt, "caloMetPt");
iEvent.put(outMetPhi, "caloMetPhi");
iEvent.put(std::move(outCaloJets));
iEvent.put(std::move(outVertices));
iEvent.put(std::move(outRho), "rho");
iEvent.put(std::move(outMetPt), "caloMetPt");
iEvent.put(std::move(outMetPhi), "caloMetPhi");
}

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
Expand Down
24 changes: 12 additions & 12 deletions HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc
Expand Up @@ -101,7 +101,7 @@ void HLTScoutingPFProducer::produce(edm::StreamID sid, edm::Event & iEvent, edm:

//get vertices
Handle<reco::VertexCollection> vertexCollection;
std::auto_ptr<ScoutingVertexCollection> outVertices(new ScoutingVertexCollection());
std::unique_ptr<ScoutingVertexCollection> outVertices(new ScoutingVertexCollection());
if(iEvent.getByToken(vertexCollection_, vertexCollection)){
for(auto &vtx : *vertexCollection){
outVertices->emplace_back(
Expand All @@ -112,23 +112,23 @@ void HLTScoutingPFProducer::produce(edm::StreamID sid, edm::Event & iEvent, edm:

//get rho
Handle<double> rho;
std::auto_ptr<double> outRho(new double(-999));
std::unique_ptr<double> outRho(new double(-999));
if(iEvent.getByToken(rho_, rho)){
outRho.reset(new double(*rho));
}

//get MET
Handle<reco::METCollection> metCollection;
std::auto_ptr<double> outMetPt(new double(-999));
std::auto_ptr<double> outMetPhi(new double(-999));
std::unique_ptr<double> outMetPt(new double(-999));
std::unique_ptr<double> outMetPhi(new double(-999));
if(doMet && iEvent.getByToken(metCollection_, metCollection)){
outMetPt.reset(new double(metCollection->front().pt()));
outMetPhi.reset(new double(metCollection->front().phi()));
}

//get PF candidates
Handle<reco::PFCandidateCollection> pfCandidateCollection;
std::auto_ptr<ScoutingParticleCollection> outPFCandidates(new ScoutingParticleCollection());
std::unique_ptr<ScoutingParticleCollection> outPFCandidates(new ScoutingParticleCollection());
if(doCandidates && iEvent.getByToken(pfCandidateCollection_, pfCandidateCollection)){
for(auto &cand : *pfCandidateCollection){
if(cand.pt() > pfCandidatePtCut){
Expand All @@ -155,7 +155,7 @@ void HLTScoutingPFProducer::produce(edm::StreamID sid, edm::Event & iEvent, edm:

//get PF jets
Handle<reco::PFJetCollection> pfJetCollection;
std::auto_ptr<ScoutingPFJetCollection> outPFJets(new ScoutingPFJetCollection());
std::unique_ptr<ScoutingPFJetCollection> outPFJets(new ScoutingPFJetCollection());
if(iEvent.getByToken(pfJetCollection_, pfJetCollection)){
//get PF jet tags
Handle<reco::JetTagCollection> pfJetTagCollection;
Expand Down Expand Up @@ -215,12 +215,12 @@ void HLTScoutingPFProducer::produce(edm::StreamID sid, edm::Event & iEvent, edm:
}

//put output
iEvent.put(outVertices);
iEvent.put(outPFCandidates);
iEvent.put(outPFJets);
iEvent.put(outRho, "rho");
iEvent.put(outMetPt, "pfMetPt");
iEvent.put(outMetPhi, "pfMetPhi");
iEvent.put(std::move(outVertices));
iEvent.put(std::move(outPFCandidates));
iEvent.put(std::move(outPFJets));
iEvent.put(std::move(outRho), "rho");
iEvent.put(std::move(outMetPt), "pfMetPt");
iEvent.put(std::move(outMetPhi), "pfMetPhi");
}

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
Expand Down
8 changes: 4 additions & 4 deletions HLTrigger/JetMET/plugins/PixelJetPuId.cc
Expand Up @@ -142,8 +142,8 @@ PixelJetPuId::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
void PixelJetPuId::produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const
{
using namespace edm;
std::auto_ptr<std::vector<reco::CaloJet> > pOut(new std::vector<reco::CaloJet> );
std::auto_ptr<std::vector<reco::CaloJet> > pOut_PUjets(new std::vector<reco::CaloJet> );
std::unique_ptr<std::vector<reco::CaloJet> > pOut(new std::vector<reco::CaloJet> );
std::unique_ptr<std::vector<reco::CaloJet> > pOut_PUjets(new std::vector<reco::CaloJet> );

//get tracks
Handle<std::vector<reco::Track> > tracks;
Expand Down Expand Up @@ -212,8 +212,8 @@ void PixelJetPuId::produce(edm::StreamID sid, edm::Event& iEvent, const edm::Eve
}
}
}
iEvent.put(pOut);
iEvent.put(pOut_PUjets,"PUjets");
iEvent.put(std::move(pOut));
iEvent.put(std::move(pOut_PUjets),"PUjets");

}

Expand Down

0 comments on commit b8366ba

Please sign in to comment.