]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AliGeant4/AliRunMessenger.cxx
Updated class description: added class title, author;
[u/mrichter/AliRoot.git] / AliGeant4 / AliRunMessenger.cxx
1 // $Id$
2 // Category: run
3 //
4 // Author: I. Hrivnacova
5 //
6 // Class AliRunMessenger
7 // ---------------------
8 // See the class description in the header file.
9
10 #include "AliRunMessenger.h"
11 #include "AliFiles.h"
12 #include "AliGlobals.h"
13 #include "AliRun.h"
14
15 #include <G4UIdirectory.hh>
16 #include <G4UIcmdWithAnInteger.hh>
17 #include <G4UIcmdWithoutParameter.hh>
18 #include <G4UIcmdWithAString.hh>
19
20 //_____________________________________________________________________________
21 AliRunMessenger::AliRunMessenger()
22 {
23 // 
24   fRunDirectory = new G4UIdirectory("/aliRun/");
25   fRunDirectory->SetGuidance("AliRun control commands.");
26
27   fConfigCmd = new G4UIcmdWithAString("/aliRun/setConfig", this);
28   fConfigCmd->SetGuidance("Set configuration macro name");
29   fConfigCmd->SetParameterName("ConfigName", true);
30   fConfigCmd->SetDefaultValue("Config");
31   fConfigCmd->AvailableForStates(PreInit);
32
33   fInitializeCmd = new G4UIcmdWithoutParameter("/aliRun/initialize", this);
34   fInitializeCmd->SetGuidance("Initialize AliRun");
35   fInitializeCmd->AvailableForStates(PreInit);
36
37   fBeamOnCmd = new G4UIcmdWithAnInteger("/aliRun/beamOn", this);
38   fBeamOnCmd->SetGuidance("Run the specified number of events");
39   fBeamOnCmd->SetParameterName("NofEvents", true);
40   fBeamOnCmd->SetDefaultValue(1);
41   fBeamOnCmd->SetRange("NofEvents >= 0");
42   fBeamOnCmd->AvailableForStates(Idle);
43
44   fLegoCmd = new G4UIcmdWithoutParameter("/aliRun/lego", this);
45   fLegoCmd->SetGuidance("Lego run");
46   fLegoCmd->AvailableForStates(Idle);
47 }
48
49 //_____________________________________________________________________________
50 AliRunMessenger::AliRunMessenger(const AliRunMessenger& right) {
51 //
52   AliGlobals::Exception("AliRunMessenger is protected from copying.");
53 }
54
55 //_____________________________________________________________________________
56 AliRunMessenger::~AliRunMessenger() {
57 //
58   delete fRunDirectory;
59   delete fConfigCmd;
60   delete fInitializeCmd;
61   delete fBeamOnCmd;
62   delete fLegoCmd;
63 }
64
65 // operators
66
67 //_____________________________________________________________________________
68 AliRunMessenger& AliRunMessenger::operator=(const AliRunMessenger &right)
69 {
70   // check assignement to self
71   if (this == &right) return *this;
72   
73   AliGlobals::Exception("AliRunMessenger is protected from assigning.");
74
75   return *this;
76 }
77
78 // public methods
79
80 //_____________________________________________________________________________
81 void AliRunMessenger::SetNewValue(G4UIcommand* command, 
82        G4String newValue)
83
84 // Applies command to the associated object.
85 // ---
86
87   // test gAlice
88   if (!gAlice) {
89     AliGlobals::Exception(
90       "AliRunMessenger: gAlice has not been instantiated yet.");
91   }      
92
93   if(command == fConfigCmd) { 
94     AliFiles::Instance()->SetMacroName(newValue); 
95   }   
96   else if(command == fInitializeCmd) { 
97     gAlice->Init(AliFiles::Instance()->GetRootMacroPath()); 
98   }   
99   else if(command == fBeamOnCmd) { 
100     gAlice->Run(fBeamOnCmd->GetNewIntValue(newValue)); 
101   }   
102   else if(command == fLegoCmd) { 
103     //gAlice->SetDebug(1); 
104     gAlice->RunLego(); 
105   }   
106 }