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