]>
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 | ||
90 | // set candidates list | |
91 | SetCandidates(); | |
92 | ||
93 | // set default values to a detector | |
94 | fModulesComposition->SwitchDetOn("NONE"); | |
95 | fModulesComposition->SetMagField(0.0*tesla); | |
96 | } | |
97 | ||
98 | AliModulesCompositionMessenger::AliModulesCompositionMessenger() { | |
99 | // | |
100 | } | |
101 | ||
102 | AliModulesCompositionMessenger::AliModulesCompositionMessenger( | |
103 | const AliModulesCompositionMessenger& right) | |
104 | { | |
105 | // | |
106 | AliGlobals::Exception( | |
107 | "AliModulesCompositionMessenger is protected from copying."); | |
108 | } | |
109 | ||
110 | AliModulesCompositionMessenger::~AliModulesCompositionMessenger() { | |
111 | // | |
112 | delete fDirectory; | |
113 | delete fSwitchOnCmd; | |
114 | delete fSwitchOffCmd; | |
115 | delete fListCmd; | |
116 | delete fListAvailableCmd; | |
117 | delete fFieldValueCmd; | |
118 | delete fSetAllSensitiveCmd; | |
119 | delete fSetReadGeometryCmd; | |
120 | delete fSetWriteGeometryCmd; | |
121 | } | |
122 | ||
123 | // operators | |
124 | ||
125 | AliModulesCompositionMessenger& | |
126 | AliModulesCompositionMessenger::operator=( | |
127 | const AliModulesCompositionMessenger& right) | |
128 | { | |
129 | // check assignement to self | |
130 | if (this == &right) return *this; | |
131 | ||
132 | AliGlobals::Exception( | |
133 | "AliModulesCompositionMessenger is protected from assigning."); | |
134 | ||
135 | return *this; | |
136 | } | |
137 | ||
138 | // public methods | |
139 | ||
140 | void AliModulesCompositionMessenger::SetNewValue(G4UIcommand* command, G4String newValues) | |
141 | { | |
142 | // Applies command to the associated object. | |
143 | // --- | |
144 | ||
145 | if (command == fSwitchOnCmd) { | |
146 | fModulesComposition->SwitchDetOn(newValues); | |
147 | } | |
148 | else if (command == fSwitchOffCmd) { | |
149 | fModulesComposition->SwitchDetOff(newValues); | |
150 | } | |
151 | else if (command == fListCmd) { | |
152 | fModulesComposition->PrintSwitchedDets(); | |
153 | } | |
154 | else if (command == fListAvailableCmd) { | |
155 | fModulesComposition->PrintAvailableDets(); | |
156 | } | |
157 | else if (command == fFieldValueCmd) { | |
158 | fModulesComposition | |
159 | ->SetMagField(fFieldValueCmd->GetNewDoubleValue(newValues)); | |
160 | } | |
161 | else if (command == fSetAllSensitiveCmd) { | |
162 | fModulesComposition->SetAllLVSensitive( | |
163 | fSetAllSensitiveCmd->GetNewBoolValue(newValues)); | |
164 | } | |
165 | else if (command == fSetReadGeometryCmd) { | |
166 | fModulesComposition->SetReadGeometry( | |
167 | fSetReadGeometryCmd->GetNewBoolValue(newValues)); | |
168 | } | |
169 | else if (command == fSetWriteGeometryCmd) { | |
170 | fModulesComposition->SetWriteGeometry( | |
171 | fSetWriteGeometryCmd->GetNewBoolValue(newValues)); | |
172 | } | |
173 | } | |
174 | ||
175 | void AliModulesCompositionMessenger::SetCandidates() | |
176 | { | |
177 | // Builds candidates list. | |
178 | // --- | |
179 | ||
180 | G4String candidatesList = "NONE ALL "; | |
181 | candidatesList += fModulesComposition->GetDetNamesList();; | |
182 | candidatesList += fModulesComposition->GetAvailableDetsList(); | |
183 | fSwitchOnCmd->SetCandidates(candidatesList); | |
184 | ||
185 | candidatesList = "ALL "; | |
186 | candidatesList += fModulesComposition->GetDetNamesList();; | |
187 | fSwitchOffCmd->SetCandidates(candidatesList); | |
188 | } |