diff --git a/MatEnv/MatDBInfo.cc b/MatEnv/MatDBInfo.cc index 1de5ca7..6d5fd2d 100644 --- a/MatEnv/MatDBInfo.cc +++ b/MatEnv/MatDBInfo.cc @@ -24,15 +24,7 @@ namespace MatEnv { _genMatFactory(RecoMatFactory::getInstance(interface)), _elossmode(elossmode) {;} - MatDBInfo::~MatDBInfo() { - // delete the materials - std::map< std::string*, std::shared_ptr, PtrLess >::iterator - iter = _matList.begin(); - for (; iter != _matList.end(); ++iter) { - delete iter->first; - } - _matList.clear(); - } + MatDBInfo::~MatDBInfo() {;} void MatDBInfo::declareMaterial( const std::string& db_name, @@ -46,8 +38,8 @@ namespace MatEnv { const std::shared_ptr MatDBInfo::findDetMaterial( const std::string& matName ) const { std::shared_ptr theMat; - std::map< std::string*, std::shared_ptr, PtrLess >::const_iterator pos; - if ((pos = _matList.find((std::string*)&matName)) != _matList.end()) { + std::map< std::string, std::shared_ptr >::const_iterator pos; + if ((pos = _matList.find(matName)) != _matList.end()) { theMat = pos->second; } else { // first, look for aliases @@ -80,7 +72,7 @@ namespace MatEnv { if(genMtrProp != 0){ theMat = std::make_shared ( detMatName.c_str(), genMtrProp ) ; theMat->setEnergyLossMode(_elossmode); - that()->_matList[new std::string( detMatName )] = theMat; + that()->_matList[ detMatName ] = theMat; return theMat; } else { return nullptr; diff --git a/MatEnv/MatDBInfo.hh b/MatEnv/MatDBInfo.hh index 0b22732..78bb5b7 100644 --- a/MatEnv/MatDBInfo.hh +++ b/MatEnv/MatDBInfo.hh @@ -50,7 +50,7 @@ namespace MatEnv { // Cache of RecoMatFactory pointer RecoMatFactory* _genMatFactory; // Cache of list of materials for DetectorModel - std::map< std::string*, std::shared_ptr, PtrLess > _matList; + std::map< std::string, std::shared_ptr > _matList; // Map for reco- and DB material names std::map< std::string, std::string > _matNameMap; // function to cast-off const