Skip to content

Commit

Permalink
Merge pull request #200 from Jasonguo9019/jason
Browse files Browse the repository at this point in the history
MatEnv Changes
  • Loading branch information
brownd1978 authored Feb 6, 2025
2 parents 2bd57ef + 9866f84 commit b8e16c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
16 changes: 4 additions & 12 deletions MatEnv/MatDBInfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ namespace MatEnv {
_genMatFactory(RecoMatFactory::getInstance(interface)), _elossmode(elossmode)
{;}

MatDBInfo::~MatDBInfo() {
// delete the materials
std::map< std::string*, std::shared_ptr<DetMaterial>, 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,
Expand All @@ -46,8 +38,8 @@ namespace MatEnv {
const std::shared_ptr<DetMaterial> MatDBInfo::findDetMaterial( const std::string& matName ) const
{
std::shared_ptr<DetMaterial> theMat;
std::map< std::string*, std::shared_ptr<DetMaterial>, PtrLess >::const_iterator pos;
if ((pos = _matList.find((std::string*)&matName)) != _matList.end()) {
std::map< std::string, std::shared_ptr<DetMaterial> >::const_iterator pos;
if ((pos = _matList.find(matName)) != _matList.end()) {
theMat = pos->second;
} else {
// first, look for aliases
Expand Down Expand Up @@ -80,7 +72,7 @@ namespace MatEnv {
if(genMtrProp != 0){
theMat = std::make_shared<DetMaterial> ( detMatName.c_str(), genMtrProp ) ;
theMat->setEnergyLossMode(_elossmode);
that()->_matList[new std::string( detMatName )] = theMat;
that()->_matList[ detMatName ] = theMat;
return theMat;
} else {
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion MatEnv/MatDBInfo.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<DetMaterial>, PtrLess > _matList;
std::map< std::string, std::shared_ptr<DetMaterial> > _matList;
// Map for reco- and DB material names
std::map< std::string, std::string > _matNameMap;
// function to cast-off const
Expand Down

0 comments on commit b8e16c5

Please # to comment.