]>
Commit | Line | Data |
---|---|---|
676fb573 | 1 | // $Id$ |
2 | // Category: geometry | |
3 | // | |
7005154f | 4 | // Author: I. Hrivnacova |
5 | // | |
6 | // Class AliModulesCompositionMessenger | |
7 | // ------------------------------------ | |
676fb573 | 8 | // See the class description in the header file. |
9 | ||
10 | #include "AliModulesCompositionMessenger.h" | |
11 | #include "AliModulesComposition.h" | |
12 | #include "AliGlobals.h" | |
13 | ||
14 | #include <G4UIdirectory.hh> | |
15 | #include <G4UIcmdWithAString.hh> | |
16 | #include <G4UIcmdWithoutParameter.hh> | |
17 | #include <G4UIcmdWithABool.hh> | |
18 | #include <G4UIcmdWithADoubleAndUnit.hh> | |
19 | ||
3cf9eae1 | 20 | //_____________________________________________________________________________ |
676fb573 | 21 | AliModulesCompositionMessenger::AliModulesCompositionMessenger( |
22 | AliModulesComposition* modulesComposition) | |
23 | : fModulesComposition(modulesComposition) | |
24 | { | |
25 | // | |
26 | fDirectory = new G4UIdirectory("/aliDet/"); | |
27 | fDirectory->SetGuidance("Detector construction control commands."); | |
28 | ||
29 | fSwitchOnCmd = new G4UIcmdWithAString("/aliDet/switchOn", this); | |
30 | fSwitchOnCmd->SetGuidance("Define the module to be built."); | |
31 | fSwitchOnCmd->SetGuidance("Available modules:"); | |
e4540b15 | 32 | G4String listAvailableDets = "NONE, ALL, PPR, "; |
676fb573 | 33 | listAvailableDets |
34 | = listAvailableDets + modulesComposition->GetAvailableDetsListWithCommas(); | |
35 | fSwitchOnCmd->SetGuidance(listAvailableDets); | |
36 | fSwitchOnCmd->SetParameterName("module", false); | |
37 | fSwitchOnCmd->AvailableForStates(PreInit);; | |
38 | ||
39 | fSwitchOffCmd = new G4UIcmdWithAString("/aliDet/switchOff", this); | |
40 | fSwitchOffCmd->SetGuidance("Define the module not to be built."); | |
41 | fSwitchOffCmd->SetGuidance("Available modules:"); | |
42 | G4String listDetsNames = "ALL, "; | |
43 | listDetsNames | |
44 | = listDetsNames + modulesComposition->GetDetNamesListWithCommas(); | |
45 | fSwitchOffCmd->SetGuidance(listDetsNames); | |
46 | fSwitchOffCmd->SetParameterName("module", false); | |
47 | fSwitchOffCmd->AvailableForStates(PreInit);; | |
48 | ||
49 | fListCmd | |
50 | = new G4UIcmdWithoutParameter("/aliDet/list", this); | |
51 | fListCmd->SetGuidance("List the currently switched modules."); | |
52 | fListCmd | |
53 | ->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc); | |
54 | ||
55 | fListAvailableCmd | |
56 | = new G4UIcmdWithoutParameter("/aliDet/listAvailable", this); | |
57 | fListAvailableCmd->SetGuidance("List all available modules."); | |
58 | fListAvailableCmd | |
59 | ->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc); | |
60 | ||
61 | fFieldValueCmd = new G4UIcmdWithADoubleAndUnit("/aliDet/fieldValue", this); | |
62 | fFieldValueCmd->SetGuidance("Define magnetic field in Z direction."); | |
63 | fFieldValueCmd->SetParameterName("fieldValue", false, false); | |
64 | fFieldValueCmd->SetDefaultUnit("tesla"); | |
65 | fFieldValueCmd->SetUnitCategory("Magnetic flux density"); | |
66 | fFieldValueCmd->AvailableForStates(PreInit,Idle); | |
67 | ||
676fb573 | 68 | fSetReadGeometryCmd |
69 | = new G4UIcmdWithABool("/aliDet/readGeometry", this); | |
70 | fSetReadGeometryCmd->SetGuidance("Read geometry from g3calls.dat files"); | |
71 | fSetReadGeometryCmd->SetParameterName("readGeometry", false); | |
72 | fSetReadGeometryCmd->AvailableForStates(PreInit); | |
73 | ||
74 | fSetWriteGeometryCmd | |
75 | = new G4UIcmdWithABool("/aliDet/writeGeometry", this); | |
76 | fSetWriteGeometryCmd->SetGuidance("Write geometry to g3calls.dat file"); | |
77 | fSetWriteGeometryCmd->SetParameterName("writeGeometry", false); | |
78 | fSetWriteGeometryCmd->AvailableForStates(PreInit); | |
79 | ||
9225847a | 80 | fPrintMaterialsCmd |
81 | = new G4UIcmdWithoutParameter("/aliDet/printMaterials", this); | |
82 | fPrintMaterialsCmd->SetGuidance("Prints all materials."); | |
83 | fPrintMaterialsCmd->AvailableForStates(PreInit, Init, Idle); | |
84 | ||
85 | fGenerateXMLCmd | |
86 | = new G4UIcmdWithoutParameter("/aliDet/generateXML", this); | |
87 | fGenerateXMLCmd->SetGuidance("Generate geometry XML file."); | |
88 | fGenerateXMLCmd->AvailableForStates(Idle); | |
89 | ||
90 | ||
676fb573 | 91 | // set candidates list |
92 | SetCandidates(); | |
93 | ||
94 | // set default values to a detector | |
95 | fModulesComposition->SwitchDetOn("NONE"); | |
676fb573 | 96 | } |
97 | ||
3cf9eae1 | 98 | //_____________________________________________________________________________ |
676fb573 | 99 | AliModulesCompositionMessenger::AliModulesCompositionMessenger() { |
100 | // | |
101 | } | |
102 | ||
3cf9eae1 | 103 | //_____________________________________________________________________________ |
676fb573 | 104 | AliModulesCompositionMessenger::AliModulesCompositionMessenger( |
105 | const AliModulesCompositionMessenger& right) | |
106 | { | |
107 | // | |
108 | AliGlobals::Exception( | |
109 | "AliModulesCompositionMessenger is protected from copying."); | |
110 | } | |
111 | ||
3cf9eae1 | 112 | //_____________________________________________________________________________ |
676fb573 | 113 | AliModulesCompositionMessenger::~AliModulesCompositionMessenger() { |
114 | // | |
115 | delete fDirectory; | |
116 | delete fSwitchOnCmd; | |
117 | delete fSwitchOffCmd; | |
118 | delete fListCmd; | |
119 | delete fListAvailableCmd; | |
120 | delete fFieldValueCmd; | |
676fb573 | 121 | delete fSetReadGeometryCmd; |
122 | delete fSetWriteGeometryCmd; | |
9225847a | 123 | delete fPrintMaterialsCmd; |
124 | delete fGenerateXMLCmd; | |
676fb573 | 125 | } |
126 | ||
127 | // operators | |
128 | ||
3cf9eae1 | 129 | //_____________________________________________________________________________ |
676fb573 | 130 | AliModulesCompositionMessenger& |
131 | AliModulesCompositionMessenger::operator=( | |
132 | const AliModulesCompositionMessenger& right) | |
133 | { | |
134 | // check assignement to self | |
135 | if (this == &right) return *this; | |
136 | ||
137 | AliGlobals::Exception( | |
138 | "AliModulesCompositionMessenger is protected from assigning."); | |
139 | ||
140 | return *this; | |
141 | } | |
142 | ||
143 | // public methods | |
144 | ||
3cf9eae1 | 145 | //_____________________________________________________________________________ |
676fb573 | 146 | void AliModulesCompositionMessenger::SetNewValue(G4UIcommand* command, G4String newValues) |
147 | { | |
148 | // Applies command to the associated object. | |
149 | // --- | |
150 | ||
151 | if (command == fSwitchOnCmd) { | |
152 | fModulesComposition->SwitchDetOn(newValues); | |
153 | } | |
154 | else if (command == fSwitchOffCmd) { | |
155 | fModulesComposition->SwitchDetOff(newValues); | |
156 | } | |
157 | else if (command == fListCmd) { | |
158 | fModulesComposition->PrintSwitchedDets(); | |
159 | } | |
160 | else if (command == fListAvailableCmd) { | |
161 | fModulesComposition->PrintAvailableDets(); | |
162 | } | |
163 | else if (command == fFieldValueCmd) { | |
164 | fModulesComposition | |
165 | ->SetMagField(fFieldValueCmd->GetNewDoubleValue(newValues)); | |
166 | } | |
676fb573 | 167 | else if (command == fSetReadGeometryCmd) { |
168 | fModulesComposition->SetReadGeometry( | |
169 | fSetReadGeometryCmd->GetNewBoolValue(newValues)); | |
170 | } | |
171 | else if (command == fSetWriteGeometryCmd) { | |
172 | fModulesComposition->SetWriteGeometry( | |
173 | fSetWriteGeometryCmd->GetNewBoolValue(newValues)); | |
174 | } | |
9225847a | 175 | else if (command == fPrintMaterialsCmd) { |
176 | fModulesComposition->PrintMaterials(); | |
177 | } | |
178 | else if (command == fGenerateXMLCmd) { | |
179 | fModulesComposition->GenerateXMLGeometry(); | |
180 | } | |
676fb573 | 181 | } |
182 | ||
3cf9eae1 | 183 | //_____________________________________________________________________________ |
676fb573 | 184 | void AliModulesCompositionMessenger::SetCandidates() |
185 | { | |
186 | // Builds candidates list. | |
187 | // --- | |
188 | ||
e4540b15 | 189 | G4String candidatesList = "NONE ALL PPR "; |
676fb573 | 190 | candidatesList += fModulesComposition->GetDetNamesList();; |
191 | candidatesList += fModulesComposition->GetAvailableDetsList(); | |
192 | fSwitchOnCmd->SetCandidates(candidatesList); | |
193 | ||
194 | candidatesList = "ALL "; | |
195 | candidatesList += fModulesComposition->GetDetNamesList();; | |
196 | fSwitchOffCmd->SetCandidates(candidatesList); | |
197 | } |