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 22, 2016
1 parent 9837ca8 commit 0fb96b8
Show file tree
Hide file tree
Showing 28 changed files with 127 additions and 127 deletions.
8 changes: 4 additions & 4 deletions GeneratorInterface/AlpgenInterface/plugins/AlpgenSource.cc
Expand Up @@ -255,7 +255,7 @@ void AlpgenSource::beginRun(edm::Run &run)
}

// Build the final Run info object. Backwards-compatible order.
std::auto_ptr<LHERunInfoProduct> runInfo(new LHERunInfoProduct(heprup));
std::unique_ptr<LHERunInfoProduct> runInfo(new LHERunInfoProduct(heprup));
runInfo->addHeader(comments);
runInfo->addHeader(lheAlpgenUnwParHeader);
if (writeAlpgenWgtFile)
Expand All @@ -265,7 +265,7 @@ void AlpgenSource::beginRun(edm::Run &run)
runInfo->addHeader(slha);
if(writeExtraHeader)
runInfo->addHeader(extraHeader);
run.put(runInfo);
run.put(std::move(runInfo));

// Open the .unw file in the heap, and set the global pointer to it.
inputFile_.reset(new std::ifstream((fileName_ + ".unw").c_str()));
Expand Down Expand Up @@ -476,8 +476,8 @@ void AlpgenSource::produce(edm::Event &event)
}

// Create the LHEEventProduct and put it into the Event.
std::auto_ptr<LHEEventProduct> lheEvent(new LHEEventProduct(hepeup));
event.put(lheEvent);
std::unique_ptr<LHEEventProduct> lheEvent(new LHEEventProduct(hepeup));
event.put(std::move(lheEvent));

hepeup_.reset();
}
Expand Down
14 changes: 7 additions & 7 deletions GeneratorInterface/BeamHaloGenerator/src/BeamHaloProducer.cc
Expand Up @@ -119,7 +119,7 @@ void BeamHaloProducer::produce(Event & e, const EventSetup & es) {

// cout << "in produce " << endl;

// auto_ptr<HepMCProduct> bare_product(new HepMCProduct());
// unique_ptr<HepMCProduct> bare_product(new HepMCProduct());

// cout << "apres autoptr " << endl;

Expand Down Expand Up @@ -155,21 +155,21 @@ void BeamHaloProducer::produce(Event & e, const EventSetup & es) {
HepMC::WeightContainer& weights = evt -> weights();
weights.push_back(weight);
// evt->print();
std::auto_ptr<HepMCProduct> CMProduct(new HepMCProduct());
std::unique_ptr<HepMCProduct> CMProduct(new HepMCProduct());
if (evt) CMProduct->addHepMCData(evt);
e.put(CMProduct, "unsmeared");
e.put(std::move(CMProduct), "unsmeared");

auto_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(evt));
e.put(genEventInfo);
unique_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(evt));
e.put(std::move(genEventInfo));
}

void BeamHaloProducer::endRunProduce( Run &run, const EventSetup& es )
{
// just create an empty product
// to keep the EventContent definitions happy
// later on we might put the info into the run info that this is a PGun
auto_ptr<GenRunInfoProduct> genRunInfo( new GenRunInfoProduct() );
run.put( genRunInfo );
unique_ptr<GenRunInfoProduct> genRunInfo( new GenRunInfoProduct() );
run.put(std::move(genRunInfo));
}

bool BeamHaloProducer::call_bh_set_parameters(int* ival, float* fval, const std::string cval_string) {
Expand Down
22 changes: 11 additions & 11 deletions GeneratorInterface/Core/interface/GeneratorFilter.h
Expand Up @@ -132,7 +132,7 @@ namespace edm
//added for selecting/filtering gen events, in the case of hadronizer+externalDecayer

bool passEvtGenSelector = false;
std::auto_ptr<HepMC::GenEvent> event(0);
std::auto_ptr<HepMC::GenEvent> event(nullptr);

while(!passEvtGenSelector)
{
Expand Down Expand Up @@ -186,18 +186,18 @@ namespace edm
//
// tutto bene - finally, form up EDM products !
//
std::auto_ptr<GenEventInfoProduct> genEventInfo(hadronizer_.getGenEventInfo());
std::unique_ptr<GenEventInfoProduct> genEventInfo(hadronizer_.getGenEventInfo());
if (!genEventInfo.get())
{
// create GenEventInfoProduct from HepMC event in case hadronizer didn't provide one
genEventInfo.reset(new GenEventInfoProduct(event.get()));
}

ev.put(genEventInfo);
ev.put(std::move(genEventInfo));

std::auto_ptr<HepMCProduct> bare_product(new HepMCProduct());
std::unique_ptr<HepMCProduct> bare_product(new HepMCProduct());
bare_product->addHepMCData( event.release() );
ev.put(bare_product, "unsmeared");
ev.put(std::move(bare_product), "unsmeared");
nEventsInLumiBlock_ ++;
return true;
}
Expand All @@ -215,8 +215,8 @@ namespace edm

if ( decayer_ ) decayer_->statistics();

std::auto_ptr<GenRunInfoProduct> griproduct(new GenRunInfoProduct(hadronizer_.getGenRunInfo()));
r.put(griproduct);
std::unique_ptr<GenRunInfoProduct> griproduct(new GenRunInfoProduct(hadronizer_.getGenRunInfo()));
r.put(std::move(griproduct));
}

template <class HAD, class DEC>
Expand Down Expand Up @@ -261,8 +261,8 @@ namespace edm
<< hadronizer_.classname()
<< " for internal parton generation\n";

std::auto_ptr<GenLumiInfoHeader> genLumiInfoHeader(hadronizer_.getGenLumiInfoHeader());
lumi.put(genLumiInfoHeader);
std::unique_ptr<GenLumiInfoHeader> genLumiInfoHeader(hadronizer_.getGenLumiInfoHeader());
lumi.put(std::move(genLumiInfoHeader));

}

Expand Down Expand Up @@ -297,11 +297,11 @@ namespace edm
temp.setAcceptedBr(0,-1,-1);
GenLumiProcess.push_back(temp);

std::auto_ptr<GenLumiInfoProduct> genLumiInfo(new GenLumiInfoProduct());
std::unique_ptr<GenLumiInfoProduct> genLumiInfo(new GenLumiInfoProduct());
genLumiInfo->setHEPIDWTUP(-1);
genLumiInfo->setProcessInfo( GenLumiProcess );

lumi.put(genLumiInfo);
lumi.put(std::move(genLumiInfo));

nEventsInLumiBlock_ = 0;

Expand Down
30 changes: 15 additions & 15 deletions GeneratorInterface/Core/interface/HadronizerFilter.h
Expand Up @@ -189,8 +189,8 @@ namespace edm
edm::Handle<LHEEventProduct> product;
ev.getByToken(eventProductToken_, product);

std::auto_ptr<HepMC::GenEvent> finalEvent;
std::auto_ptr<GenEventInfoProduct> finalGenEventInfo;
std::unique_ptr<HepMC::GenEvent> finalEvent;
std::unique_ptr<GenEventInfoProduct> finalGenEventInfo;

//sum of weights for events passing hadronization
double waccept = 0;
Expand All @@ -214,7 +214,7 @@ namespace edm
//
if ( !hadronizer_.decay() ) continue;

std::auto_ptr<HepMC::GenEvent> event (hadronizer_.getGenEvent());
std::unique_ptr<HepMC::GenEvent> event (hadronizer_.getGenEvent());
if( !event.get() ) continue;

// The external decay driver is being added to the system,
Expand All @@ -240,7 +240,7 @@ namespace edm

event->set_event_number( ev.id().event() );

std::auto_ptr<GenEventInfoProduct> genEventInfo(hadronizer_.getGenEventInfo());
std::unique_ptr<GenEventInfoProduct> genEventInfo(hadronizer_.getGenEventInfo());
if (!genEventInfo.get())
{
// create GenEventInfoProduct from HepMC event in case hadronizer didn't provide one
Expand Down Expand Up @@ -274,11 +274,11 @@ namespace edm
finalEvent->weights()[0] *= multihadweight;
}

ev.put(finalGenEventInfo);
ev.put(std::move(finalGenEventInfo));

std::auto_ptr<HepMCProduct> bare_product(new HepMCProduct());
std::unique_ptr<HepMCProduct> bare_product(new HepMCProduct());
bare_product->addHepMCData( finalEvent.release() );
ev.put(bare_product, "unsmeared");
ev.put(std::move(bare_product), "unsmeared");

return true;
}
Expand Down Expand Up @@ -338,8 +338,8 @@ namespace edm
if ( filter_ ) filter_->statistics();
lheRunInfo->statistics();

std::auto_ptr<GenRunInfoProduct> griproduct( new GenRunInfoProduct(genRunInfo) );
r.put(griproduct);
std::unique_ptr<GenRunInfoProduct> griproduct( new GenRunInfoProduct(genRunInfo) );
r.put(std::move(griproduct));
}

template <class HAD, class DEC>
Expand Down Expand Up @@ -389,8 +389,8 @@ namespace edm
<< hadronizer_.classname()
<< " for external parton generation\n";

std::auto_ptr<GenLumiInfoHeader> genLumiInfoHeader(hadronizer_.getGenLumiInfoHeader());
lumi.put(genLumiInfoHeader);
std::unique_ptr<GenLumiInfoHeader> genLumiInfoHeader(hadronizer_.getGenLumiInfoHeader());
lumi.put(std::move(genLumiInfoHeader));

}

Expand Down Expand Up @@ -425,17 +425,17 @@ namespace edm
temp.setAcceptedBr(thisProcess.acceptedBr().n(), thisProcess.acceptedBr().sum(), thisProcess.acceptedBr().sum2());
GenLumiProcess.push_back(temp);
}
std::auto_ptr<GenLumiInfoProduct> genLumiInfo(new GenLumiInfoProduct());
std::unique_ptr<GenLumiInfoProduct> genLumiInfo(new GenLumiInfoProduct());
genLumiInfo->setHEPIDWTUP(lheRunInfo->getHEPRUP()->IDWTUP);
genLumiInfo->setProcessInfo( GenLumiProcess );

lumi.put(genLumiInfo);
lumi.put(std::move(genLumiInfo));


// produce GenFilterInfo if HepMCFilter is called
if (filter_) {

std::auto_ptr<GenFilterInfo> thisProduct(new GenFilterInfo(
std::unique_ptr<GenFilterInfo> thisProduct(new GenFilterInfo(
filter_->numEventsPassPos(),
filter_->numEventsPassNeg(),
filter_->numEventsTotalPos(),
Expand All @@ -445,7 +445,7 @@ namespace edm
filter_->sumtotal_w(),
filter_->sumtotal_w2()
));
lumi.put(thisProduct);
lumi.put(std::move(thisProduct));
}


Expand Down
Expand Up @@ -119,7 +119,7 @@ GenFilterEfficiencyProducer::endLuminosityBlock(edm::LuminosityBlock const& iLum
void
GenFilterEfficiencyProducer::endLuminosityBlockProduce(edm::LuminosityBlock & iLumi, const edm::EventSetup&) {

std::auto_ptr<GenFilterInfo> thisProduct(new GenFilterInfo(
std::unique_ptr<GenFilterInfo> thisProduct(new GenFilterInfo(
numEventsPassPos_,
numEventsPassNeg_,
numEventsTotalPos_,
Expand All @@ -129,5 +129,5 @@ GenFilterEfficiencyProducer::endLuminosityBlockProduce(edm::LuminosityBlock & iL
sumtotal_w_,
sumtotal_w2_
));
iLumi.put(thisProduct);
iLumi.put(std::move(thisProduct));
}
12 changes: 6 additions & 6 deletions GeneratorInterface/CosmicMuonGenerator/src/CosMuoGenProducer.cc
Expand Up @@ -114,15 +114,15 @@ void edm::CosMuoGenProducer::beginLuminosityBlock(LuminosityBlock const& lumi, E

void edm::CosMuoGenProducer::endRunProduce( Run &run, const EventSetup& es )
{
std::auto_ptr<GenRunInfoProduct> genRunInfo(new GenRunInfoProduct());
std::unique_ptr<GenRunInfoProduct> genRunInfo(new GenRunInfoProduct());

double cs = CosMuoGen->getRate(); // flux in Hz, not s^-1m^-2
if (MultiMuon) genRunInfo->setInternalXSec(0.);
else genRunInfo->setInternalXSec(cs);
genRunInfo->setExternalXSecLO(extCrossSect);
genRunInfo->setFilterEfficiency(extFilterEff);

run.put(genRunInfo);
run.put(std::move(genRunInfo));

CosMuoGen->terminate();
}
Expand Down Expand Up @@ -232,11 +232,11 @@ void edm::CosMuoGenProducer::produce(Event &e, const edm::EventSetup &es)

if (cmVerbosity_) fEvt->print();

std::auto_ptr<HepMCProduct> CMProduct(new HepMCProduct());
std::unique_ptr<HepMCProduct> CMProduct(new HepMCProduct());
CMProduct->addHepMCData( fEvt );
e.put(CMProduct, "unsmeared");
e.put(std::move(CMProduct), "unsmeared");

std::auto_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct( fEvt ));
e.put(genEventInfo);
std::unique_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct( fEvt ));
e.put(std::move(genEventInfo));

}
2 changes: 1 addition & 1 deletion GeneratorInterface/GenFilters/src/MCPdgIndexFilter.cc
Expand Up @@ -26,7 +26,7 @@ bool MCPdgIndexFilter::filter(edm::Event& evt, const edm::EventSetup&) {
bool result = pass(evt);
LogDebug("FilterResult") << (result?"Pass":"Fail");
if (!taggingMode) return result;
evt.put( std::auto_ptr<bool>(new bool(result)), tag);
evt.put(std::move(std::unique_ptr<bool>(new bool(result))), tag);
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions GeneratorInterface/GenFilters/src/MCZll.cc
Expand Up @@ -58,7 +58,7 @@ void MCZll::endJob()
// ------------ method called to skim the data ------------
bool MCZll::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
{
std::auto_ptr<HepMCProduct> bare_product(new HepMCProduct());
std::unique_ptr<HepMCProduct> bare_product(new HepMCProduct());

nEvents_++;
using namespace edm;
Expand Down Expand Up @@ -130,7 +130,7 @@ bool MCZll::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
if(zEvent)
bare_product->addHepMCData(zEvent);
if (filter_)
iEvent.put(bare_product);
iEvent.put(std::move(bare_product));
nAccepted_++;
// std::cout << "+++++++++++++++++++++++++++++++++++++++++++++++++"<< std::endl;
LogDebug("MCZll") << "Event " << iEvent.id().event() << " accepted" << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions GeneratorInterface/HiGenCommon/plugins/GenHIEventProducer.cc
Expand Up @@ -184,7 +184,7 @@ GenHIEventProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
meanPt /= nCharged;
}

std::auto_ptr<edm::GenHIEvent> pGenHI(new edm::GenHIEvent(b,
std::unique_ptr<edm::GenHIEvent> pGenHI(new edm::GenHIEvent(b,
npart,
ncoll,
nhard,
Expand All @@ -199,7 +199,7 @@ GenHIEventProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
nChargedPtCutMR
));

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

}

Expand Down
6 changes: 3 additions & 3 deletions GeneratorInterface/LHEInterface/interface/LHEReader.h
Expand Up @@ -39,10 +39,10 @@ class LHEReader {
unsigned int curIndex;
std::vector<std::string> weightsinconfig;

std::auto_ptr<Source> curSource;
std::auto_ptr<XMLDocument> curDoc;
std::unique_ptr<Source> curSource;
std::unique_ptr<XMLDocument> curDoc;
boost::shared_ptr<LHERunInfo> curRunInfo;
std::auto_ptr<XMLHandler> handler;
std::unique_ptr<XMLHandler> handler;
};

} // namespace lhef
Expand Down

0 comments on commit 0fb96b8

Please sign in to comment.