]>
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:"); | |
e4540b15 | 27 | G4String listAvailableDets = "NONE, ALL, PPR, "; |
676fb573 | 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."); | |
14e97519 | 75 | fSetAllSensitiveCmd |
76 | ->SetGuidance("It has lower priority than individual module setting"); | |
676fb573 | 77 | fSetAllSensitiveCmd->SetParameterName("sensitivity", false); |
78 | fSetAllSensitiveCmd->AvailableForStates(PreInit); | |
79 | ||
14e97519 | 80 | fForceAllSensitiveCmd |
81 | = new G4UIcmdWithABool("/aliDet/forceAllSensitive", this); | |
82 | fForceAllSensitiveCmd | |
83 | ->SetGuidance("If true: force to set all logical volumes sensitive."); | |
84 | fForceAllSensitiveCmd | |
85 | ->SetGuidance(" (Each logical is volume associated with a sensitive"); | |
86 | fForceAllSensitiveCmd | |
87 | ->SetGuidance(" detector.)"); | |
88 | fForceAllSensitiveCmd | |
89 | ->SetGuidance("It has higher priority than individual module setting"); | |
90 | fForceAllSensitiveCmd->SetParameterName("forceSensitivity", false); | |
91 | fForceAllSensitiveCmd->AvailableForStates(PreInit); | |
92 | ||
676fb573 | 93 | fSetReadGeometryCmd |
94 | = new G4UIcmdWithABool("/aliDet/readGeometry", this); | |
95 | fSetReadGeometryCmd->SetGuidance("Read geometry from g3calls.dat files"); | |
96 | fSetReadGeometryCmd->SetParameterName("readGeometry", false); | |
97 | fSetReadGeometryCmd->AvailableForStates(PreInit); | |
98 | ||
99 | fSetWriteGeometryCmd | |
100 | = new G4UIcmdWithABool("/aliDet/writeGeometry", this); | |
101 | fSetWriteGeometryCmd->SetGuidance("Write geometry to g3calls.dat file"); | |
102 | fSetWriteGeometryCmd->SetParameterName("writeGeometry", false); | |
103 | fSetWriteGeometryCmd->AvailableForStates(PreInit); | |
104 | ||
9225847a | 105 | fPrintMaterialsCmd |
106 | = new G4UIcmdWithoutParameter("/aliDet/printMaterials", this); | |
107 | fPrintMaterialsCmd->SetGuidance("Prints all materials."); | |
108 | fPrintMaterialsCmd->AvailableForStates(PreInit, Init, Idle); | |
109 | ||
110 | fGenerateXMLCmd | |
111 | = new G4UIcmdWithoutParameter("/aliDet/generateXML", this); | |
112 | fGenerateXMLCmd->SetGuidance("Generate geometry XML file."); | |
113 | fGenerateXMLCmd->AvailableForStates(Idle); | |
114 | ||
115 | ||
676fb573 | 116 | // set candidates list |
117 | SetCandidates(); | |
118 | ||
119 | // set default values to a detector | |
120 | fModulesComposition->SwitchDetOn("NONE"); | |
676fb573 | 121 | } |
122 | ||
123 | AliModulesCompositionMessenger::AliModulesCompositionMessenger() { | |
124 | // | |
125 | } | |
126 | ||
127 | AliModulesCompositionMessenger::AliModulesCompositionMessenger( | |
128 | const AliModulesCompositionMessenger& right) | |
129 | { | |
130 | // | |
131 | AliGlobals::Exception( | |
132 | "AliModulesCompositionMessenger is protected from copying."); | |
133 | } | |
134 | ||
135 | AliModulesCompositionMessenger::~AliModulesCompositionMessenger() { | |
136 | // | |
137 | delete fDirectory; | |
138 | delete fSwitchOnCmd; | |
139 | delete fSwitchOffCmd; | |
140 | delete fListCmd; | |
141 | delete fListAvailableCmd; | |
142 | delete fFieldValueCmd; | |
143 | delete fSetAllSensitiveCmd; | |
14e97519 | 144 | delete fForceAllSensitiveCmd; |
676fb573 | 145 | delete fSetReadGeometryCmd; |
146 | delete fSetWriteGeometryCmd; | |
9225847a | 147 | delete fPrintMaterialsCmd; |
148 | delete fGenerateXMLCmd; | |
676fb573 | 149 | } |
150 | ||
151 | // operators | |
152 | ||
153 | AliModulesCompositionMessenger& | |
154 | AliModulesCompositionMessenger::operator=( | |
155 | const AliModulesCompositionMessenger& right) | |
156 | { | |
157 | // check assignement to self | |
158 | if (this == &right) return *this; | |
159 | ||
160 | AliGlobals::Exception( | |
161 | "AliModulesCompositionMessenger is protected from assigning."); | |
162 | ||
163 | return *this; | |
164 | } | |
165 | ||
166 | // public methods | |
167 | ||
168 | void AliModulesCompositionMessenger::SetNewValue(G4UIcommand* command, G4String newValues) | |
169 | { | |
170 | // Applies command to the associated object. | |
171 | // --- | |
172 | ||
173 | if (command == fSwitchOnCmd) { | |
174 | fModulesComposition->SwitchDetOn(newValues); | |
175 | } | |
176 | else if (command == fSwitchOffCmd) { | |
177 | fModulesComposition->SwitchDetOff(newValues); | |
178 | } | |
179 | else if (command == fListCmd) { | |
180 | fModulesComposition->PrintSwitchedDets(); | |
181 | } | |
182 | else if (command == fListAvailableCmd) { | |
183 | fModulesComposition->PrintAvailableDets(); | |
184 | } | |
185 | else if (command == fFieldValueCmd) { | |
186 | fModulesComposition | |
187 | ->SetMagField(fFieldValueCmd->GetNewDoubleValue(newValues)); | |
188 | } | |
189 | else if (command == fSetAllSensitiveCmd) { | |
190 | fModulesComposition->SetAllLVSensitive( | |
191 | fSetAllSensitiveCmd->GetNewBoolValue(newValues)); | |
14e97519 | 192 | } |
193 | else if (command == fForceAllSensitiveCmd) { | |
194 | fModulesComposition->SetForceAllLVSensitive( | |
195 | fForceAllSensitiveCmd->GetNewBoolValue(newValues)); | |
676fb573 | 196 | } |
197 | else if (command == fSetReadGeometryCmd) { | |
198 | fModulesComposition->SetReadGeometry( | |
199 | fSetReadGeometryCmd->GetNewBoolValue(newValues)); | |
200 | } | |
201 | else if (command == fSetWriteGeometryCmd) { | |
202 | fModulesComposition->SetWriteGeometry( | |
203 | fSetWriteGeometryCmd->GetNewBoolValue(newValues)); | |
204 | } | |
9225847a | 205 | else if (command == fPrintMaterialsCmd) { |
206 | fModulesComposition->PrintMaterials(); | |
207 | } | |
208 | else if (command == fGenerateXMLCmd) { | |
209 | fModulesComposition->GenerateXMLGeometry(); | |
210 | } | |
676fb573 | 211 | } |
212 | ||
213 | void AliModulesCompositionMessenger::SetCandidates() | |
214 | { | |
215 | // Builds candidates list. | |
216 | // --- | |
217 | ||
e4540b15 | 218 | G4String candidatesList = "NONE ALL PPR "; |
676fb573 | 219 | candidatesList += fModulesComposition->GetDetNamesList();; |
220 | candidatesList += fModulesComposition->GetAvailableDetsList(); | |
221 | fSwitchOnCmd->SetCandidates(candidatesList); | |
222 | ||
223 | candidatesList = "ALL "; | |
224 | candidatesList += fModulesComposition->GetDetNamesList();; | |
225 | fSwitchOffCmd->SetCandidates(candidatesList); | |
226 | } |