Declaring UI messenger command without unit

I want to set the fraction mass of material via detector messenger. fraction mass is mostly specified in perCent which is not available in units table so it gives me error at run time. So I want to declare this UI command without any unit and I want use that value in my detector construction file. How can I?

// create ui directory
  nbDir = new G4UIdirectory("/nb/");
  nbDir->SetGuidance("UI commands for this detector");
  
  detDir = new G4UIdirectory("/nb/det/");
  detDir->SetGuidance("detector control");
  
  detDir = new G4UIdirectory("/nb/det/H/");
  detDir->SetGuidance("H control");
  
  
  // set H fractionmass for pH
  HSetterCmdForH = new G4UIcmdWithADoubleAndUnit("/nb/det/H/setH",this);  
  HSetterCmdForH->SetGuidance("define H fractionmass for H");
  HSetterCmdForH->SetParameterName("H",false);    
  // HSetterCmdForH->SetDefaultUnit("perCent"); gives error
  HSetterCmdForH->AvailableForStates(G4State_PreInit,G4State_Idle);

G4UIcmdWithADouble( )
See examples/extended/electromagnetic/TestEm1 : PrimaryGeneratorMessenger

Thanks, I have managed to do it. But now another problem is arised.

In my macro I am using something like this:

/run/beamOn 1000

# then I change material and again I run 

/nb/det/H/setH 5

/run/beamOn 1000

I want to change materials in my geometry at run time and save all those results in my ntuple.
this is giving me ntuple merging error. since I am changing materials at run time. G4AnalysisManager is giving me error. Any help on this please? @mkelsey @maire

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