]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AliGeant4/AliDetSwitchVectorMessenger.cxx
Moved from AliTransbit to AliL3Transbit.
[u/mrichter/AliRoot.git] / AliGeant4 / AliDetSwitchVectorMessenger.cxx
1 // $Id$
2 // Category: geometry
3 //
4 // Author: I. Hrivnacova
5 //
6 // Class AliDetSwitchVectorMessenger
7 // ------------------------------------
8 // See the class description in the header file.
9
10 #include "AliDetSwitchVectorMessenger.h"
11 #include "AliDetSwitchVector.h"
12 #include "AliGlobals.h"
13
14 #include <G4UIdirectory.hh>
15 #include <G4UIcmdWithAString.hh>
16 #include <G4UIcmdWithoutParameter.hh>
17
18 //_____________________________________________________________________________
19 AliDetSwitchVectorMessenger::AliDetSwitchVectorMessenger(
20                                          AliDetSwitchVector* switchVector)
21   : fDetSwitchVector(switchVector)
22 {
23 //
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";  
28   fSwitchOnCmd->SetGuidance(listAvailableDets);
29   fSwitchOnCmd->SetParameterName("module", false);
30   fSwitchOnCmd->AvailableForStates(PreInit);;
31
32   fSwitchOffCmd = new G4UIcmdWithAString("/aliDet/switchOff", this);
33   fSwitchOffCmd->SetGuidance("Define the module not to be built.");
34   fSwitchOffCmd->SetGuidance("Available modules:");
35   G4String listDetsNames = "ALL"; 
36   fSwitchOffCmd->SetGuidance(listDetsNames);
37   fSwitchOffCmd->SetParameterName("module", false);
38   fSwitchOffCmd->AvailableForStates(PreInit);;
39
40   fListCmd 
41     = new G4UIcmdWithoutParameter("/aliDet/list", this);
42   fListCmd->SetGuidance("List the currently switched modules.");
43   fListCmd
44     ->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc);
45
46   fListAvailableCmd 
47     = new G4UIcmdWithoutParameter("/aliDet/listAvailable", this);
48   fListAvailableCmd->SetGuidance("List all available modules.");
49   fListAvailableCmd
50     ->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc);
51 }
52
53 //_____________________________________________________________________________
54 AliDetSwitchVectorMessenger::AliDetSwitchVectorMessenger() {
55 //
56 }
57
58 //_____________________________________________________________________________
59 AliDetSwitchVectorMessenger::AliDetSwitchVectorMessenger(
60                                    const AliDetSwitchVectorMessenger& right)
61 {
62 //
63   AliGlobals::Exception(
64     "AliDetSwitchVectorMessenger is protected from copying.");
65 }
66
67 //_____________________________________________________________________________
68 AliDetSwitchVectorMessenger::~AliDetSwitchVectorMessenger() {
69 //
70   delete fSwitchOnCmd;
71   delete fSwitchOffCmd;
72   delete fListCmd;
73   delete fListAvailableCmd;
74 }
75
76 // operators
77
78 //_____________________________________________________________________________
79 AliDetSwitchVectorMessenger& 
80 AliDetSwitchVectorMessenger::operator=(const AliDetSwitchVectorMessenger& right)
81 {
82   // check assignement to self
83   if (this == &right) return *this;
84
85   AliGlobals::Exception(
86      "AliDetSwitchVectorMessenger is protected from assigning.");
87     
88   return *this;  
89 }    
90           
91 // private methods
92
93 //_____________________________________________________________________________
94 void AliDetSwitchVectorMessenger::SetGuidance() 
95 {
96 // Updates guidance, candidates list.
97 // ---
98
99   G4String listAvailableDets = "NONE, ALL, ";  
100   listAvailableDets 
101     = listAvailableDets + fDetSwitchVector->GetAvailableDetsListWithCommas();
102   fSwitchOnCmd->SetGuidance(listAvailableDets);
103
104   G4String listDetsNames = "ALL, "; 
105   listDetsNames
106     = listDetsNames + fDetSwitchVector->GetDetNamesListWithCommas();
107   fSwitchOffCmd->SetGuidance(listDetsNames);
108 }
109
110 //_____________________________________________________________________________
111 void AliDetSwitchVectorMessenger::SetCandidates() 
112 {
113 // Builds candidates list.
114 // ---
115
116   G4String candidatesList = "NONE ALL ";
117   candidatesList += fDetSwitchVector->GetDetNamesList();;
118   candidatesList += fDetSwitchVector->GetAvailableDetsList();
119   fSwitchOnCmd->SetCandidates(candidatesList);
120
121   candidatesList = "ALL ";
122   candidatesList += fDetSwitchVector->GetDetNamesList();;
123   fSwitchOffCmd->SetCandidates(candidatesList);
124 }
125
126 // public methods
127   
128 //_____________________________________________________________________________
129 void AliDetSwitchVectorMessenger::SetNewValue(G4UIcommand* command, 
130                                               G4String newValues)
131 {
132 // Applies command to the associated object.
133 // ---
134
135   if (command == fSwitchOnCmd) {  
136     fDetSwitchVector->SwitchDetOn(newValues); 
137   }
138   else if (command == fSwitchOffCmd) {  
139     fDetSwitchVector->SwitchDetOff(newValues); 
140   }
141   else if (command == fListCmd) {  
142     fDetSwitchVector->PrintSwitchedDets(); 
143   }
144   else if (command == fListAvailableCmd) {  
145     fDetSwitchVector->PrintAvailableDets(); 
146   }
147 }
148
149 //_____________________________________________________________________________
150 void AliDetSwitchVectorMessenger::Update() 
151 {
152 // Updates guidance, candidates list.
153 // ---
154
155   SetGuidance();
156   SetCandidates();
157
158   // set default values to a detector
159   fDetSwitchVector->SwitchDetOn("NONE");
160 }