Problem 2574

Summary: Usage of final keyword in G4HadronElasticPhysicsHP.hh prevents customisation
Product: Geant4 Reporter: Thomas Kittelmann <thomas.kittelmann>
Component: processes/hadronic/models/neutron_hpAssignee: Vladimir.Ivantchenko
Status: RESOLVED FIXED    
Severity: minor CC: Alberto.Ribon
Priority: P4    
Version: 11.1   
Hardware: All   
OS: All   

Description Thomas Kittelmann 2023-11-06 12:36:49 CET
Hi there.

I would like to extend the physics from the G4HadronElasticPhysicsHP class in the same manner it itself extends the physics from G4HadronElasticPhysics. However, in the G4HadronElasticPhysicsHP class declaration, the ConstructProcess() method is marked as "final", thus preventing this usage. The workaround is for now the hack of copying the entire class over and performing the small one word change, but this is clearly unmaintainable going forward.

Could the ConstructProcess() in the G4HadronElasticPhysicsHP class please be marked as "override" rather than "final"? It should have no ABI impact, since such decorators do not affect name mangling.

Cheers,
Thomas
Comment 1 Vladimir.Ivantchenko 2023-11-07 11:42:52 CET
Hello,

the keyword already changed and the change will be available with the new public release 11.2 (December, 2023). The modification for the patch to 11.1 may be potentially considered but we prefer keeping headers unchanged in the patch and we do not yet know the date of the next patch.

A custom solution may be to create custom G4HadronElasticPhysicsMY and substitute the default inside modular physics list using the method:

G4VModularPhysicsList::ReplacePhysics(new G4HadronElasticPhysicsMY());

This constructor should implement all required modifications and may be done starting from G4HadronElasticPhysicsHP. 

VI
Comment 2 Thomas Kittelmann 2023-11-07 13:53:20 CET
Great, thanks a lot for the info!

I already have a workaround (hack) for now, but based on your info I will go ahead and modify my code so it will not use it if the Geant4 version is 11.2 or greater.

Cheers,
Thomas