4 // Author: I. Hrivnacova
6 // Class AliDetSwitchVectorMessenger
7 // ------------------------------------
8 // See the class description in the header file.
10 #include "AliDetSwitchVectorMessenger.h"
11 #include "AliDetSwitchVector.h"
12 #include "AliGlobals.h"
14 #include <G4UIdirectory.hh>
15 #include <G4UIcmdWithAString.hh>
16 #include <G4UIcmdWithoutParameter.hh>
18 //_____________________________________________________________________________
19 AliDetSwitchVectorMessenger::AliDetSwitchVectorMessenger(
20 AliDetSwitchVector* switchVector)
21 : fDetSwitchVector(switchVector)
24 fSwitchOnCmd = new G4UIcmdWithAString("/aliDet/switchOn", this);
25 fSwitchOnCmd->SetGuidance("Define the module to be built.");
26 fSwitchOnCmd->SetGuidance("Available modules:");
27 G4String listAvailableDets = "NONE, ALL, ";
29 = listAvailableDets + fDetSwitchVector->GetAvailableDetsListWithCommas();
30 fSwitchOnCmd->SetGuidance(listAvailableDets);
31 fSwitchOnCmd->SetParameterName("module", false);
32 fSwitchOnCmd->AvailableForStates(PreInit);;
34 fSwitchOffCmd = new G4UIcmdWithAString("/aliDet/switchOff", this);
35 fSwitchOffCmd->SetGuidance("Define the module not to be built.");
36 fSwitchOffCmd->SetGuidance("Available modules:");
37 G4String listDetsNames = "ALL, ";
39 = listDetsNames + fDetSwitchVector->GetDetNamesListWithCommas();
40 fSwitchOffCmd->SetGuidance(listDetsNames);
41 fSwitchOffCmd->SetParameterName("module", false);
42 fSwitchOffCmd->AvailableForStates(PreInit);;
45 = new G4UIcmdWithoutParameter("/aliDet/list", this);
46 fListCmd->SetGuidance("List the currently switched modules.");
48 ->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc);
51 = new G4UIcmdWithoutParameter("/aliDet/listAvailable", this);
52 fListAvailableCmd->SetGuidance("List all available modules.");
54 ->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc);
56 // set candidates list
59 // set default values to a detector
60 fDetSwitchVector->SwitchDetOn("NONE");
63 //_____________________________________________________________________________
64 AliDetSwitchVectorMessenger::AliDetSwitchVectorMessenger() {
68 //_____________________________________________________________________________
69 AliDetSwitchVectorMessenger::AliDetSwitchVectorMessenger(
70 const AliDetSwitchVectorMessenger& right)
73 AliGlobals::Exception(
74 "AliDetSwitchVectorMessenger is protected from copying.");
77 //_____________________________________________________________________________
78 AliDetSwitchVectorMessenger::~AliDetSwitchVectorMessenger() {
83 delete fListAvailableCmd;
88 //_____________________________________________________________________________
89 AliDetSwitchVectorMessenger&
90 AliDetSwitchVectorMessenger::operator=(const AliDetSwitchVectorMessenger& right)
92 // check assignement to self
93 if (this == &right) return *this;
95 AliGlobals::Exception(
96 "AliDetSwitchVectorMessenger is protected from assigning.");
103 //_____________________________________________________________________________
104 void AliDetSwitchVectorMessenger::SetNewValue(G4UIcommand* command,
107 // Applies command to the associated object.
110 if (command == fSwitchOnCmd) {
111 fDetSwitchVector->SwitchDetOn(newValues);
113 else if (command == fSwitchOffCmd) {
114 fDetSwitchVector->SwitchDetOff(newValues);
116 else if (command == fListCmd) {
117 fDetSwitchVector->PrintSwitchedDets();
119 else if (command == fListAvailableCmd) {
120 fDetSwitchVector->PrintAvailableDets();
124 //_____________________________________________________________________________
125 void AliDetSwitchVectorMessenger::SetCandidates()
127 // Builds candidates list.
130 G4String candidatesList = "NONE ALL ";
131 candidatesList += fDetSwitchVector->GetDetNamesList();;
132 candidatesList += fDetSwitchVector->GetAvailableDetsList();
133 fSwitchOnCmd->SetCandidates(candidatesList);
135 candidatesList = "ALL ";
136 candidatesList += fDetSwitchVector->GetDetNamesList();;
137 fSwitchOffCmd->SetCandidates(candidatesList);