]>
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> | |
14 | ||
15 | AliRunMessenger::AliRunMessenger() | |
16 | { | |
17 | // | |
18 | fRunDirectory = new G4UIdirectory("/aliRun/"); | |
19 | fRunDirectory->SetGuidance("AliRun control commands."); | |
20 | ||
21 | fInitializeCmd = new G4UIcmdWithoutParameter("/aliRun/initialize", this); | |
22 | fInitializeCmd->SetGuidance("Initialize AliRun"); | |
23 | fInitializeCmd->AvailableForStates(PreInit); | |
24 | ||
25 | fBeamOnCmd = new G4UIcmdWithAnInteger("/aliRun/beamOn", this); | |
26 | fBeamOnCmd->SetGuidance("Run the specified number of events"); | |
27 | fBeamOnCmd->SetParameterName("NofEvents", true); | |
28 | fBeamOnCmd->SetDefaultValue(1); | |
29 | fBeamOnCmd->SetRange("NofEvents >= 0"); | |
30 | fBeamOnCmd->AvailableForStates(Idle); | |
31 | ||
32 | fLegoCmd = new G4UIcmdWithoutParameter("/aliRun/lego", this); | |
33 | fLegoCmd->SetGuidance("Lego run"); | |
34 | fLegoCmd->AvailableForStates(Idle); | |
35 | } | |
36 | ||
37 | AliRunMessenger::AliRunMessenger(const AliRunMessenger& right) { | |
38 | // | |
39 | AliGlobals::Exception("AliRunMessenger is protected from copying."); | |
40 | } | |
41 | ||
42 | AliRunMessenger::~AliRunMessenger() { | |
43 | // | |
44 | delete fRunDirectory; | |
45 | delete fInitializeCmd; | |
46 | delete fBeamOnCmd; | |
47 | delete fLegoCmd; | |
48 | } | |
49 | ||
50 | // operators | |
51 | ||
52 | AliRunMessenger& AliRunMessenger::operator=(const AliRunMessenger &right) | |
53 | { | |
54 | // check assignement to self | |
55 | if (this == &right) return *this; | |
56 | ||
57 | AliGlobals::Exception("AliRunMessenger is protected from assigning."); | |
58 | ||
59 | return *this; | |
60 | } | |
61 | ||
62 | // public methods | |
63 | ||
64 | void AliRunMessenger::SetNewValue(G4UIcommand* command, | |
65 | G4String newValue) | |
66 | { | |
67 | // Applies command to the associated object. | |
68 | // --- | |
69 | ||
70 | // test gAlice | |
71 | if (!gAlice) { | |
72 | AliGlobals::Exception( | |
73 | "AliRunMessenger: gAlice has not been instantiated yet."); | |
74 | } | |
75 | ||
76 | if(command == fInitializeCmd) { | |
77 | gAlice->Init(AliFiles::Config()); | |
78 | } | |
79 | else if(command == fBeamOnCmd) { | |
80 | gAlice->Run(fBeamOnCmd->GetNewIntValue(newValue)); | |
81 | } | |
82 | else if(command == fLegoCmd) { | |
83 | gAlice->RunLego(); | |
84 | } | |
85 | } |