4 // See the class description in the header file.
6 #include "AliRunMessenger.h"
8 #include "AliGlobals.h"
11 #include <G4UIdirectory.hh>
12 #include <G4UIcmdWithAnInteger.hh>
13 #include <G4UIcmdWithoutParameter.hh>
14 #include <G4UIcmdWithAString.hh>
17 AliRunMessenger::AliRunMessenger()
20 fRunDirectory = new G4UIdirectory("/aliRun/");
21 fRunDirectory->SetGuidance("AliRun control commands.");
23 fConfigCmd = new G4UIcmdWithAString("/aliRun/setConfig", this);
24 fConfigCmd->SetGuidance("Set configuration macro name");
25 fConfigCmd->SetParameterName("ConfigName", true);
26 fConfigCmd->SetDefaultValue("Config");
27 fConfigCmd->AvailableForStates(PreInit);
29 fInitializeCmd = new G4UIcmdWithoutParameter("/aliRun/initialize", this);
30 fInitializeCmd->SetGuidance("Initialize AliRun");
31 fInitializeCmd->AvailableForStates(PreInit);
33 fBeamOnCmd = new G4UIcmdWithAnInteger("/aliRun/beamOn", this);
34 fBeamOnCmd->SetGuidance("Run the specified number of events");
35 fBeamOnCmd->SetParameterName("NofEvents", true);
36 fBeamOnCmd->SetDefaultValue(1);
37 fBeamOnCmd->SetRange("NofEvents >= 0");
38 fBeamOnCmd->AvailableForStates(Idle);
40 fLegoCmd = new G4UIcmdWithoutParameter("/aliRun/lego", this);
41 fLegoCmd->SetGuidance("Lego run");
42 fLegoCmd->AvailableForStates(Idle);
45 AliRunMessenger::AliRunMessenger(const AliRunMessenger& right) {
47 AliGlobals::Exception("AliRunMessenger is protected from copying.");
50 AliRunMessenger::~AliRunMessenger() {
54 delete fInitializeCmd;
61 AliRunMessenger& AliRunMessenger::operator=(const AliRunMessenger &right)
63 // check assignement to self
64 if (this == &right) return *this;
66 AliGlobals::Exception("AliRunMessenger is protected from assigning.");
73 void AliRunMessenger::SetNewValue(G4UIcommand* command,
76 // Applies command to the associated object.
81 AliGlobals::Exception(
82 "AliRunMessenger: gAlice has not been instantiated yet.");
85 if(command == fConfigCmd) {
86 AliFiles::Instance()->SetMacroName(newValue);
88 else if(command == fInitializeCmd) {
89 gAlice->Init(AliFiles::Instance()->GetRootMacroPath());
91 else if(command == fBeamOnCmd) {
92 gAlice->Run(fBeamOnCmd->GetNewIntValue(newValue));
94 else if(command == fLegoCmd) {