Problem 2420

Summary: G4GenericMessenger: buggy SetRange on DeclareMethod commands (numeric types)
Product: Geant4 Reporter: Luigi Pertoldi <gipert>
Component: intercomsAssignee: asai
Status: RESOLVED FIXED    
Severity: normal    
Priority: P4    
Version: 10.7   
Hardware: All   
OS: All   

Description Luigi Pertoldi 2021-09-09 16:13:40 CEST
G4GenericMessenger::SetRange does not work as expected on a Command created with G4GenericMessenger::DeclareMethod with a function that accepts a numeric type. This happens because DeclareMethod seems to always assign type "string" to the function argument.

The bug can be reproduced by modifying example basic/B5:

1) In B5DetectorConstruction::DefineCommands, create armAngleCmd by invoking DeclareMethod instead of DeclareMethodWithUnit (remove the "deg" unit specification).

2) Substitute "/B5/detector/armAngle 30. deg" with "/B5/detector/armAngle 30." in provided macro run1.mac.

3) Compile the example and run the program. Output:

parameter out of range: angle>=0. && angle<180.
***** Illegal parameter (99) </B5/detector/armAngle 0. deg> *****

***** Batch is interrupted!! *****

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : UIMAN0123
      issued by : G4UImanager::ApplyCommand
Command aborted (399)
Error code : 399
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------
Comment 1 asai 2021-12-14 22:34:03 CET
Thank you for reporting this. The fix will be included in the next patch release.