Replacement for MaterialPropertiesTable "ConstPropertyMap"?

Howdy! This is another issue I’ve run into trying to migrate our simulation framework to Geant4 v11. For our detector response simulation, we define a number of custom “const” (single value) material properties. We attach default values for these properties to the G4Material* associated with the relevant volumes, but we also support the application (via macro commands) assigning non-default values to specific SurfaceProperty instances.

In our code, we handle those overrides by looping over the properties attached to the material, and copying them over to the SurfaceProperty object as needed. For Geant4 10.7.4, this looks like:

  typedef const std::map<G4int, G4double, std::less<G4int> > MCPtype;
  MCPtype* MCPvals = filmMPT->GetConstPropertyMap();
  if (MCPnames.empty() || !MCPvals) return;     // No appropriate properties

  for (const auto& MCPentry : *MCPvals) {
    prop.AddConstProperty(MCPnames[MCPentry.first], MCPentry.second);
  }

Unfortunately, in Geant4 v11, the GetConstPropertyMap() was removed, presumably along with the std::map<> itself. I guess that this should be replaced with MaterialPropertiesIndex? If so, is there an example where I could see how to make that transition?

Geant4 Version: 10.7.4 → 11.3.2
Operating System: Ubuntu 24
Compiler/Version: GCC 13.3.0
CMake Version:

I was able to solve this by restructuring the loop above to simply not use the map at all. I get the list of known ConstProperty names (keys), loop over that vector, and for each one, call AddConstProperty(...,...,true) (because these are specifically custom properties) to move it to the new table.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.