Skip to content

Commit

Permalink
Fix memory leaks in FastSimulation/TrackingRecHitProducer
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr15Jones committed Dec 5, 2016
1 parent e7b6730 commit 8f67d96
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
Expand Up @@ -30,6 +30,7 @@
// STL
#include <vector>
#include <string>
#include <memory>

class TFile;
class RandomEngineAndDistribution;
Expand Down Expand Up @@ -65,17 +66,17 @@ class PixelTemplateSmearerBase:
std::map<unsigned int, const SimpleHistogramGenerator*> theXHistos;
std::map<unsigned int, const SimpleHistogramGenerator*> theYHistos;

TFile* theEdgePixelResolutionFile;
std::unique_ptr<TFile> theEdgePixelResolutionFile;
std::string theEdgePixelResolutionFileName;
TFile* theBigPixelResolutionFile;
std::unique_ptr<TFile> theBigPixelResolutionFile;
std::string theBigPixelResolutionFileName;
TFile* theRegularPixelResolutionFile;
std::unique_ptr<TFile> theRegularPixelResolutionFile;
std::string theRegularPixelResolutionFileName;
TFile* theMergingProbabilityFile;
std::unique_ptr<TFile> theMergingProbabilityFile;
std::string theMergingProbabilityFileName;
TFile* theMergedPixelResolutionXFile;
std::unique_ptr<TFile> theMergedPixelResolutionXFile;
std::string theMergedPixelResolutionXFileName;
TFile* theMergedPixelResolutionYFile;
std::unique_ptr<TFile> theMergedPixelResolutionYFile;
std::string theMergedPixelResolutionYFileName;

unsigned int theLayer;
Expand Down
Expand Up @@ -52,18 +52,18 @@ PixelBarrelTemplateSmearerPlugin::PixelBarrelTemplateSmearerPlugin(
isForward = false;

theBigPixelResolutionFileName = config.getParameter<string>( "BigPixelBarrelResolutionFile" );
theBigPixelResolutionFile = new TFile( edm::FileInPath( theBigPixelResolutionFileName ).fullPath().c_str() ,"READ");
theBigPixelResolutionFile = std::make_unique<TFile>( edm::FileInPath( theBigPixelResolutionFileName ).fullPath().c_str() ,"READ");
theEdgePixelResolutionFileName = config.getParameter<string>( "EdgePixelBarrelResolutionFile" );
theEdgePixelResolutionFile = new TFile( edm::FileInPath( theEdgePixelResolutionFileName ).fullPath().c_str() ,"READ");
theEdgePixelResolutionFile = std::make_unique<TFile>( edm::FileInPath( theEdgePixelResolutionFileName ).fullPath().c_str() ,"READ");
theRegularPixelResolutionFileName = config.getParameter<string>( "RegularPixelBarrelResolutionFile" );
theRegularPixelResolutionFile = new TFile( edm::FileInPath( theRegularPixelResolutionFileName ).fullPath().c_str() ,"READ");
theRegularPixelResolutionFile = std::make_unique<TFile>( edm::FileInPath( theRegularPixelResolutionFileName ).fullPath().c_str() ,"READ");

theMergingProbabilityFileName = config.getParameter<string>( "MergingProbabilityBarrelFile" );
theMergingProbabilityFile = new TFile( edm::FileInPath( theMergingProbabilityFileName ).fullPath().c_str() ,"READ");
theMergingProbabilityFile = std::make_unique<TFile>( edm::FileInPath( theMergingProbabilityFileName ).fullPath().c_str() ,"READ");
theMergedPixelResolutionXFileName = config.getParameter<string>( "MergedPixelBarrelResolutionXFile" );
theMergedPixelResolutionXFile = new TFile( edm::FileInPath( theMergedPixelResolutionXFileName ).fullPath().c_str() ,"READ");
theMergedPixelResolutionXFile = std::make_unique<TFile>( edm::FileInPath( theMergedPixelResolutionXFileName ).fullPath().c_str() ,"READ");
theMergedPixelResolutionYFileName = config.getParameter<string>( "MergedPixelBarrelResolutionYFile" );
theMergedPixelResolutionYFile = new TFile( edm::FileInPath( theMergedPixelResolutionYFileName ).fullPath().c_str() ,"READ");
theMergedPixelResolutionYFile = std::make_unique<TFile>( edm::FileInPath( theMergedPixelResolutionYFileName ).fullPath().c_str() ,"READ");

initializeBarrel();

Expand Down
Expand Up @@ -69,18 +69,18 @@ PixelForwardTemplateSmearerPlugin::PixelForwardTemplateSmearerPlugin(
isForward = true;

theEdgePixelResolutionFileName = config.getParameter<string>( "EdgePixelForwardResolutionFile" );
theEdgePixelResolutionFile = new TFile( edm::FileInPath( theEdgePixelResolutionFileName ).fullPath().c_str() ,"READ");
theEdgePixelResolutionFile = std::make_unique<TFile>( edm::FileInPath( theEdgePixelResolutionFileName ).fullPath().c_str() ,"READ");
theBigPixelResolutionFileName = config.getParameter<string>( "BigPixelForwardResolutionFile" );
theBigPixelResolutionFile = new TFile( edm::FileInPath( theBigPixelResolutionFileName ).fullPath().c_str() ,"READ");
theBigPixelResolutionFile = std::make_unique<TFile>( edm::FileInPath( theBigPixelResolutionFileName ).fullPath().c_str() ,"READ");
theRegularPixelResolutionFileName = config.getParameter<string>( "RegularPixelForwardResolutionFile" );
theRegularPixelResolutionFile = new TFile( edm::FileInPath( theRegularPixelResolutionFileName ).fullPath().c_str() ,"READ");
theRegularPixelResolutionFile = std::make_unique<TFile>( edm::FileInPath( theRegularPixelResolutionFileName ).fullPath().c_str() ,"READ");

theMergingProbabilityFileName = config.getParameter<string>( "MergingProbabilityForwardFile" );
theMergingProbabilityFile =new TFile( edm::FileInPath( theMergingProbabilityFileName ).fullPath().c_str() ,"READ");
theMergingProbabilityFile =std::make_unique<TFile>( edm::FileInPath( theMergingProbabilityFileName ).fullPath().c_str() ,"READ");
theMergedPixelResolutionXFileName = config.getParameter<string>( "MergedPixelForwardResolutionXFile" );
theMergedPixelResolutionXFile = new TFile( edm::FileInPath( theMergedPixelResolutionXFileName ).fullPath().c_str() ,"READ");
theMergedPixelResolutionXFile = std::make_unique<TFile>( edm::FileInPath( theMergedPixelResolutionXFileName ).fullPath().c_str() ,"READ");
theMergedPixelResolutionYFileName = config.getParameter<string>( "MergedPixelForwardResolutionYFile" );
theMergedPixelResolutionYFile = new TFile( edm::FileInPath( theMergedPixelResolutionYFileName ).fullPath().c_str() ,"READ");
theMergedPixelResolutionYFile = std::make_unique<TFile>( edm::FileInPath( theMergedPixelResolutionYFileName ).fullPath().c_str() ,"READ");

initializeForward();

Expand Down
Expand Up @@ -59,6 +59,7 @@ PixelTemplateSmearerBase::~PixelTemplateSmearerBase()
}
theXHistos.clear();
theYHistos.clear();

}

TrackingRecHitProductPtr
Expand Down

0 comments on commit 8f67d96

Please sign in to comment.