Skip to content

Commit

Permalink
Merge pull request #13504 from jolange/memLeakFix
Browse files Browse the repository at this point in the history
fix memory leaks in EcalClusterLazyTools
  • Loading branch information
cmsbuild committed Mar 8, 2016
2 parents e36c353 + 7ea1052 commit 5f0f0e4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
4 changes: 3 additions & 1 deletion RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class EcalClusterLazyToolsBase {
// mapping for preshower rechits
std::map<DetId, EcalRecHit> rechits_map_;
// get Preshower hit array
std::vector<float> getESHits(double X, double Y, double Z, const std::map<DetId, EcalRecHit>& rechits_map, const CaloGeometry* geometry, CaloSubdetectorTopology *topology_p, int row=0, int plane=1);
std::vector<float> getESHits(double X, double Y, double Z, const std::map<DetId, EcalRecHit>& rechits_map, const CaloGeometry* geometry, CaloSubdetectorTopology const *topology_p, int row=0, int plane=1);
// get Preshower hit shape
float getESShape(const std::vector<float>& ESHits0);
// get Preshower effective sigmaRR
Expand Down Expand Up @@ -78,6 +78,8 @@ class EcalClusterLazyToolsBase {

edm::EDGetTokenT<EcalRecHitCollection> ebRHToken_, eeRHToken_, esRHToken_;

std::shared_ptr<CaloSubdetectorTopology const> ecalPS_topology_;

//const EcalIntercalibConstantMap& icalMap;
edm::ESHandle<EcalIntercalibConstants> ical;
const EcalIntercalibConstantMap* icalMap;
Expand Down
30 changes: 16 additions & 14 deletions RecoEcal/EgammaCoreTools/src/EcalClusterLazyTools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ void EcalClusterLazyToolsBase::getGeometry( const edm::EventSetup &es ) {
edm::ESHandle<CaloGeometry> pGeometry;
es.get<CaloGeometryRecord>().get(pGeometry);
geometry_ = pGeometry.product();

const CaloSubdetectorGeometry *geometryES = geometry_->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
if (geometryES) {
ecalPS_topology_.reset(new EcalPreshowerTopology(geometry_));
} else {
ecalPS_topology_.reset();
edm::LogWarning("subdetector geometry not available") << "EcalPreshower geometry is missing" << std::endl;
}
}

void EcalClusterLazyToolsBase::getTopology( const edm::EventSetup &es ) {
Expand Down Expand Up @@ -256,12 +264,10 @@ float EcalClusterLazyToolsBase::eseffsirir(const reco::SuperCluster &cluster)
{
if (!(fabs(cluster.eta()) > 1.6 && fabs(cluster.eta()) < 3.)) return 0.;

const CaloSubdetectorGeometry *geometryES = geometry_->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
CaloSubdetectorTopology *topology_p = 0;
if (geometryES) topology_p = new EcalPreshowerTopology(geometry_);
if (!ecalPS_topology_) return 0.;

std::vector<float> phoESHitsIXIX = getESHits(cluster.x(), cluster.y(), cluster.z(), rechits_map_, geometry_, topology_p, 0, 1);
std::vector<float> phoESHitsIYIY = getESHits(cluster.x(), cluster.y(), cluster.z(), rechits_map_, geometry_, topology_p, 0, 2);
std::vector<float> phoESHitsIXIX = getESHits(cluster.x(), cluster.y(), cluster.z(), rechits_map_, geometry_, ecalPS_topology_.get(), 0, 1);
std::vector<float> phoESHitsIYIY = getESHits(cluster.x(), cluster.y(), cluster.z(), rechits_map_, geometry_, ecalPS_topology_.get(), 0, 2);
float phoESShapeIXIX = getESShape(phoESHitsIXIX);
float phoESShapeIYIY = getESShape(phoESHitsIYIY);

Expand All @@ -273,11 +279,9 @@ float EcalClusterLazyToolsBase::eseffsixix(const reco::SuperCluster &cluster)
{
if (!(fabs(cluster.eta()) > 1.6 && fabs(cluster.eta()) < 3.)) return 0.;

const CaloSubdetectorGeometry *geometryES = geometry_->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
CaloSubdetectorTopology *topology_p = 0;
if (geometryES) topology_p = new EcalPreshowerTopology(geometry_);
if (!ecalPS_topology_) return 0.;

std::vector<float> phoESHitsIXIX = getESHits(cluster.x(), cluster.y(), cluster.z(), rechits_map_, geometry_, topology_p, 0, 1);
std::vector<float> phoESHitsIXIX = getESHits(cluster.x(), cluster.y(), cluster.z(), rechits_map_, geometry_, ecalPS_topology_.get(), 0, 1);
float phoESShapeIXIX = getESShape(phoESHitsIXIX);

return phoESShapeIXIX;
Expand All @@ -288,18 +292,16 @@ float EcalClusterLazyToolsBase::eseffsiyiy(const reco::SuperCluster &cluster)
{
if (!(fabs(cluster.eta()) > 1.6 && fabs(cluster.eta()) < 3.)) return 0.;

const CaloSubdetectorGeometry *geometryES = geometry_->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
CaloSubdetectorTopology *topology_p = 0;
if (geometryES) topology_p = new EcalPreshowerTopology(geometry_);
if (!ecalPS_topology_) return 0.;

std::vector<float> phoESHitsIYIY = getESHits(cluster.x(), cluster.y(), cluster.z(), rechits_map_, geometry_, topology_p, 0, 2);
std::vector<float> phoESHitsIYIY = getESHits(cluster.x(), cluster.y(), cluster.z(), rechits_map_, geometry_, ecalPS_topology_.get(), 0, 2);
float phoESShapeIYIY = getESShape(phoESHitsIYIY);

return phoESShapeIYIY;
}

// get Preshower Rechits
std::vector<float> EcalClusterLazyToolsBase::getESHits(double X, double Y, double Z, const std::map<DetId, EcalRecHit>& _rechits_map, const CaloGeometry* geometry, CaloSubdetectorTopology *topology_p, int row, int plane)
std::vector<float> EcalClusterLazyToolsBase::getESHits(double X, double Y, double Z, const std::map<DetId, EcalRecHit>& _rechits_map, const CaloGeometry* geometry, CaloSubdetectorTopology const *topology_p, int row, int plane)
{
std::map<DetId, EcalRecHit> rechits_map = _rechits_map;
std::vector<float> esHits;
Expand Down

0 comments on commit 5f0f0e4

Please sign in to comment.