Skip to content

Commit

Permalink
Remove boost::ptr_deque dependency
Browse files Browse the repository at this point in the history
In this case we don't need boost::ptr_deque. Its possible to use std::deque<std::unique_ptr> without a loss in readability
  • Loading branch information
camolezi committed Jul 17, 2020
1 parent ad1f132 commit 7fdc00a
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 0 additions & 1 deletion GeneratorInterface/LHEInterface/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
<use name="FWCore/Utilities"/>
<use name="GeneratorInterface/LHEInterface"/>
<use name="GeneratorInterface/Core"/>
<use name="boost"/>
<use name="stdcxx-fs"/>
<library name="GeneratorInterfaceLHEProducer" file="LHEFilter.cc LHE2HepMCConverter.cc ExternalLHEProducer.cc ExternalLHEAsciiDumper.cc">
<use name="FWCore/Framework"/>
14 changes: 8 additions & 6 deletions GeneratorInterface/LHEInterface/plugins/ExternalLHEProducer.cc
Original file line number Diff line number Diff line change
@@ -102,10 +102,10 @@ class ExternalLHEProducer : public edm::one::EDProducer<edm::BeginRunProducer, e
std::shared_ptr<lhef::LHERunInfo> runInfoLast_;
std::shared_ptr<lhef::LHERunInfo> runInfo_;
std::shared_ptr<lhef::LHEEvent> partonLevel_;
boost::ptr_deque<LHERunInfoProduct> runInfoProducts_;
std::deque<std::unique_ptr<LHERunInfoProduct>> runInfoProducts_;
bool wasMerged;

class FileCloseSentry{
class FileCloseSentry {
public:
explicit FileCloseSentry(int fd) : fd_(fd){};

@@ -114,6 +114,7 @@ class ExternalLHEProducer : public edm::one::EDProducer<edm::BeginRunProducer, e
//Make this noncopyable
FileCloseSentry(const FileCloseSentry&) = delete;
FileCloseSentry& operator=(const FileCloseSentry&) = delete;

private:
int fd_;
};
@@ -235,10 +236,10 @@ void ExternalLHEProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
std::bind(&LHERunInfoProduct::addComment, product.get(), std::placeholders::_1));

if (!runInfoProducts_.empty()) {
runInfoProducts_.front().mergeProduct(*product);
runInfoProducts_.front()->mergeProduct(*product);
if (!wasMerged) {
runInfoProducts_.pop_front();
runInfoProducts_.push_front(product.release());
runInfoProducts_.emplace_front(product.release());
wasMerged = true;
}
}
@@ -356,7 +357,7 @@ void ExternalLHEProducer::beginRunProduce(edm::Run& run, edm::EventSetup const&
std::bind(&LHERunInfoProduct::addComment, product.get(), std::placeholders::_1));

// keep a copy around in case of merging
runInfoProducts_.push_back(new LHERunInfoProduct(*product));
runInfoProducts_.emplace_back(new LHERunInfoProduct(*product));
wasMerged = false;

run.put(std::move(product));
@@ -368,7 +369,8 @@ void ExternalLHEProducer::beginRunProduce(edm::Run& run, edm::EventSetup const&
// ------------ method called when ending the processing of a run ------------
void ExternalLHEProducer::endRunProduce(edm::Run& run, edm::EventSetup const& es) {
if (!runInfoProducts_.empty()) {
std::unique_ptr<LHERunInfoProduct> product(runInfoProducts_.pop_front().release());
std::unique_ptr<LHERunInfoProduct> product(runInfoProducts_.front().release());
runInfoProducts_.pop_front();
run.put(std::move(product));
}

0 comments on commit 7fdc00a

Please sign in to comment.