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