#include "BirminghamBeamlineMessenger.hh" #include "BirminghamBeamline.hh" #include "G4UIdirectory.hh" #include "G4UIcmdWithAnInteger.hh" #include "G4UIcmdWithADoubleAndUnit.hh" #include "G4UIcmdWithAString.hh" #include "G4UIcmdWithoutParameter.hh" #include "G4UIcmdWith3VectorAndUnit.hh" ///////////////////////////////////////////////////////////////////////////// BirminghamBeamlineMessenger::BirminghamBeamlineMessenger(BirminghamBeamline* Det) :pBirminghamBeamline(Det) { beamlineDir = new G4UIdirectory("/Beamline/"); beamlineDir->SetGuidance("Beamline construction commands"); absorberDepthCmd = new G4UIcmdWithADoubleAndUnit("/Beamline/Birmingham/setAbsorberDepth", this); absorberDepthCmd->SetGuidance("Set depth of absorber after air chamber"); absorberDepthCmd->SetParameterName("AbsorberDepth", false); absorberDepthCmd->SetUnitCategory("Length"); absorberDepthCmd->SetRange("AbsorberDepth>=0.0"); absorberDepthCmd->AvailableForStates(G4State_PreInit,G4State_Idle); absorberMaterialCmd = new G4UIcmdWithAString("/Beamline/Birmingham/setAbsorberMaterial", this); absorberMaterialCmd->SetGuidance("Set the material of absorber after air chamber"); absorberMaterialCmd->SetDefaultValue("Perspex"); absorberMaterialCmd->SetParameterName("AbsorberMaterial", false); absorberMaterialCmd->AvailableForStates(G4State_PreInit,G4State_Idle); colInnerRadiusCmd = new G4UIcmdWithADoubleAndUnit("/Beamline/Birmingham/setCollimatorInnerRadius", this); colInnerRadiusCmd->SetGuidance("Set the inner radius of the collimator at the end of the beampipe"); colInnerRadiusCmd->SetParameterName("ColInnerRadius", false); colInnerRadiusCmd->SetUnitCategory("Length"); colInnerRadiusCmd->SetRange("ColInnerRadius>=0.0"); colInnerRadiusCmd->AvailableForStates(G4State_PreInit,G4State_Idle); scattererPositionCmd = new G4UIcmdWith3VectorAndUnit("/Beamline/Birmingham/setScattererPosition", this); scattererPositionCmd->SetGuidance("Set the position of the first scatterer"); scattererPositionCmd->SetParameterName("ScatterPosX", "ScatterPosY", "ScatterPosZ", false); scattererPositionCmd->AvailableForStates(G4State_PreInit,G4State_Idle); scattererSizeCmd = new G4UIcmdWith3VectorAndUnit("/Beamline/Birmingham/setScattererSize", this); scattererSizeCmd->SetGuidance("Set the size of the first scatterer"); scattererSizeCmd->SetParameterName("ScatterSizeX", "ScatterSizeY", "ScatterSizeZ", false); scattererSizeCmd->AvailableForStates(G4State_PreInit,G4State_Idle); scattererMaterialCmd = new G4UIcmdWithAString("/Beamline/Birmingham/setScattererMaterial", this); scattererMaterialCmd->SetGuidance("Set the material of the scatterer system"); scattererMaterialCmd->SetParameterName("ScattererMaterial", false); scattererMaterialCmd->AvailableForStates(G4State_PreInit,G4State_Idle); scattererConstructCmd = new G4UIcmdWithABool("/Beamline/Birmingham/constructScatterer", this); scattererConstructCmd->SetGuidance("Set whether to build scatterer or not"); scattererConstructCmd->SetParameterName("ScattererConstruct", false); scattererConstructCmd->AvailableForStates(G4State_PreInit,G4State_Idle); // constructCmd = new G4UIcmdWithoutParameter("/Beamline/Birmingham/construct",this); // constructCmd->SetGuidance("This command constructs the Birmingham Beamline Model"); // constructCmd->AvailableForStates(G4State_PreInit,G4State_Idle); UpdateCmd = new G4UIcmdWithoutParameter("/Beamline/Birmingham/update",this); UpdateCmd->SetGuidance("Update calorimeter geometry."); UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" "); UpdateCmd->SetGuidance("if you changed geometrical value(s)."); UpdateCmd->AvailableForStates(G4State_PreInit,G4State_Idle); } ///////////////////////////////////////////////////////////////////////////// BirminghamBeamlineMessenger::~BirminghamBeamlineMessenger() { delete beamlineDir; delete absorberDepthCmd; delete absorberMaterialCmd; delete colInnerRadiusCmd; delete UpdateCmd; } ///////////////////////////////////////////////////////////////////////////// void BirminghamBeamlineMessenger::SetNewValue(G4UIcommand* command, G4String newValue) { if( command == absorberDepthCmd ) pBirminghamBeamline->SetAbsorberDepth(absorberDepthCmd->GetNewDoubleValue(newValue)); else if( command == absorberMaterialCmd ) pBirminghamBeamline->SetAbsorberMaterial(newValue); else if( command == colInnerRadiusCmd ) pBirminghamBeamline->SetCollimatorInnerRadius(colInnerRadiusCmd->GetNewDoubleValue(newValue)); else if( command == scattererPositionCmd ) pBirminghamBeamline->SetScattererPosition(scattererPositionCmd->GetNew3VectorValue(newValue)); else if( command == scattererSizeCmd ) pBirminghamBeamline->SetScattererSize(scattererSizeCmd->GetNew3VectorValue(newValue)); else if( command == scattererMaterialCmd ) pBirminghamBeamline->SetScattererMaterial(newValue); else if( command == scattererConstructCmd ) pBirminghamBeamline->SetConstructScatterer(scattererConstructCmd->GetNewBoolValue(newValue)); // else if( command == constructCmd ) // pBirminghamBeamline->ConstructBeamline(); // else if( command == UpdateCmd ) // pBirminghamBeamline->UpdateGeometry(); }