Message: Problem in range checking with G4UIcmdWithADoubleAndUnit Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Problem in range checking with G4UIcmdWithADoubleAndUnit 

Forum: (Graphical) User Interfaces
Date: 29 Jun, 2012
From: Robert Penny <Robert Penny>

I'm trying to input an angular range for a cone beam using G4UIcmdWithADoubleAndUnit. It appears that range checking is applied to the raw value input, not to the value after the unit has been applied. Is there a way that I need to specify my range check string that includes the unit?


I set up the command in my messenger class constructor as:

  // Cone angle command
    = new G4UIcmdWithADoubleAndUnit("/gun/custom/SetConeHalfAngle",this);

  SetConeHalfAngleCmd->SetGuidance( "Set half angle of particle cone");  
  SetConeHalfAngleCmd->SetRange("angle >= 0. && angle <= 3.14159265358" );

Then when invoked, I process the data as:

           G4UIcommand* command,G4String newValue)

 else if( command == SetConeHalfAngleCmd )
	<< "SetConeHalfAngleCommand called with value : "
	<< newValue << std::endl;

         coneHalfAngle = SetConeHalfAngleCmd->GetNewDoubleValue( newValue );
	<< "Converted value is " << coneHalfAngle
	<< std::endl;
      primGenAction->SetConeHalfAngle( coneHalfAngle );

All good so far.

If I then use the command when running the application I can specify the angle either with a unit of "deg" or "radian"

If I input:

/gun/custom/SetConeHalfAngle 1 rad

SetConeHalfAngleCommand called with value : 1 rad Converted value is 1

If I input:

/gun/custom/SetConeHalfAngle 3 deg

SetConeHalfAngleCommand called with value : 3 deg Converted value is 0.0523599

But if I input:

/gun/custom/SetConeHalfAngle 4 deg

I get a range check error. It appears the range checking is happening before the unit multiplier is applied. Is this the intended operation or a bug in the G4UIcommand class?



 Add Message Add Message
to: "Problem in range checking with G4UIcmdWithADoubleAndUnit"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews

[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]