]>
Commit | Line | Data |
---|---|---|
676fb573 | 1 | // $Id$ |
2 | // Category: run | |
3 | // | |
4 | // See the class description in the header file. | |
5 | ||
6 | #include "AliRunMessenger.h" | |
7 | #include "AliFiles.h" | |
8 | #include "AliGlobals.h" | |
9 | #include "AliRun.h" | |
10 | ||
11 | #include <G4UIdirectory.hh> | |
12 | #include <G4UIcmdWithAnInteger.hh> | |
13 | #include <G4UIcmdWithoutParameter.hh> | |
e67066b2 | 14 | #include <G4UIcmdWithAString.hh> |
15 | ||
78ca1e9c | 16 | //_____________________________________________________________________________ |
676fb573 | 17 | AliRunMessenger::AliRunMessenger() |
18 | { | |
19 | // | |
20 | fRunDirectory = new G4UIdirectory("/aliRun/"); | |
21 | fRunDirectory->SetGuidance("AliRun control commands."); | |
22 | ||
e67066b2 | 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); | |
28 | ||
676fb573 | 29 | fInitializeCmd = new G4UIcmdWithoutParameter("/aliRun/initialize", this); |
30 | fInitializeCmd->SetGuidance("Initialize AliRun"); | |
31 | fInitializeCmd->AvailableForStates(PreInit); | |
32 | ||
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); | |
39 | ||
40 | fLegoCmd = new G4UIcmdWithoutParameter("/aliRun/lego", this); | |
41 | fLegoCmd->SetGuidance("Lego run"); | |
42 | fLegoCmd->AvailableForStates(Idle); | |
43 | } | |
44 | ||
78ca1e9c | 45 | //_____________________________________________________________________________ |
676fb573 | 46 | AliRunMessenger::AliRunMessenger(const AliRunMessenger& right) { |
47 | // | |
48 | AliGlobals::Exception("AliRunMessenger is protected from copying."); | |
49 | } | |
50 | ||
78ca1e9c | 51 | //_____________________________________________________________________________ |
676fb573 | 52 | AliRunMessenger::~AliRunMessenger() { |
53 | // | |
54 | delete fRunDirectory; | |
e67066b2 | 55 | delete fConfigCmd; |
676fb573 | 56 | delete fInitializeCmd; |
57 | delete fBeamOnCmd; | |
58 | delete fLegoCmd; | |
59 | } | |
60 | ||
61 | // operators | |
62 | ||
78ca1e9c | 63 | //_____________________________________________________________________________ |
676fb573 | 64 | AliRunMessenger& AliRunMessenger::operator=(const AliRunMessenger &right) |
65 | { | |
66 | // check assignement to self | |
67 | if (this == &right) return *this; | |
68 | ||
69 | AliGlobals::Exception("AliRunMessenger is protected from assigning."); | |
70 | ||
71 | return *this; | |
72 | } | |
73 | ||
74 | // public methods | |
75 | ||
78ca1e9c | 76 | //_____________________________________________________________________________ |
676fb573 | 77 | void AliRunMessenger::SetNewValue(G4UIcommand* command, |
78 | G4String newValue) | |
79 | { | |
80 | // Applies command to the associated object. | |
81 | // --- | |
82 | ||
83 | // test gAlice | |
84 | if (!gAlice) { | |
85 | AliGlobals::Exception( | |
86 | "AliRunMessenger: gAlice has not been instantiated yet."); | |
87 | } | |
88 | ||
e67066b2 | 89 | if(command == fConfigCmd) { |
90 | AliFiles::Instance()->SetMacroName(newValue); | |
91 | } | |
92 | else if(command == fInitializeCmd) { | |
93 | gAlice->Init(AliFiles::Instance()->GetRootMacroPath()); | |
676fb573 | 94 | } |
95 | else if(command == fBeamOnCmd) { | |
96 | gAlice->Run(fBeamOnCmd->GetNewIntValue(newValue)); | |
97 | } | |
98 | else if(command == fLegoCmd) { | |
99 | gAlice->RunLego(); | |
100 | } | |
101 | } |