Skip to content

Commit

Permalink
Use RunningAverage to guess a reserve size for the product
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Grimes committed May 18, 2015
1 parent a34df87 commit 85e61d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Expand Up @@ -47,6 +47,9 @@ void
std::auto_ptr<reco::PFRecHitCollection> out(new reco::PFRecHitCollection );
std::auto_ptr<reco::PFRecHitCollection> cleaned(new reco::PFRecHitCollection );

out->reserve( outputSizeGuess_.upper() );
cleaned->reserve( cleanedOutputSizeGuess_.upper() );

navigator_->beginEvent(iSetup);

for (unsigned int i=0;i<creators_.size();++i) {
Expand Down Expand Up @@ -75,6 +78,9 @@ void
}
}

outputSizeGuess_.update( out->size() );
cleanedOutputSizeGuess_.update( cleaned->size() );

iEvent.put(out,"");
iEvent.put(cleaned,"Cleaned");
hitmap.clear();
Expand Down
3 changes: 3 additions & 0 deletions RecoParticleFlow/PFClusterProducer/plugins/PFRecHitProducer.h
Expand Up @@ -9,6 +9,7 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/Utilities/interface/RunningAverage.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "RecoParticleFlow/PFClusterProducer/interface/PFRecHitCreatorBase.h"
Expand All @@ -30,6 +31,8 @@ class PFRecHitProducer : public edm::EDProducer {
virtual void produce(edm::Event&, const edm::EventSetup&) override;
std::vector<std::unique_ptr<PFRecHitCreatorBase> > creators_;
std::unique_ptr<PFRecHitNavigatorBase> navigator_;
edm::RunningAverage outputSizeGuess_; ///< Use this to try and accurately reserve space for the output
edm::RunningAverage cleanedOutputSizeGuess_; ///< Use this to try and accurately reserve space for the output
};

#include "FWCore/Framework/interface/MakerMacros.h"
Expand Down

0 comments on commit 85e61d7

Please sign in to comment.