1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // ------------------------------------------------------------- |
---|
27 | // |
---|
28 | // |
---|
29 | // ------------------------------------------------------------- |
---|
30 | // GEANT4 hTest |
---|
31 | // |
---|
32 | // History: based on object model of |
---|
33 | // 2nd December 1995, G.Cosmo |
---|
34 | // ---------- hTestDetectorMessenger ------- |
---|
35 | // |
---|
36 | // Modified: 05.04.01 Vladimir Ivanchenko new design of hTest |
---|
37 | // |
---|
38 | // ------------------------------------------------------------- |
---|
39 | |
---|
40 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
41 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
42 | |
---|
43 | #include "hTestDetectorMessenger.hh" |
---|
44 | #include "hTestDetectorConstruction.hh" |
---|
45 | #include "hTestHisto.hh" |
---|
46 | #include "G4UIdirectory.hh" |
---|
47 | #include "G4UIcmdWithAString.hh" |
---|
48 | #include "G4UIcmdWithAnInteger.hh" |
---|
49 | #include "G4UIcmdWithABool.hh" |
---|
50 | #include "G4UIcmdWithADoubleAndUnit.hh" |
---|
51 | #include "G4UIcmdWithoutParameter.hh" |
---|
52 | |
---|
53 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
54 | |
---|
55 | hTestDetectorMessenger::hTestDetectorMessenger(hTestDetectorConstruction* h): |
---|
56 | hDet(h) |
---|
57 | { |
---|
58 | hTestdetDir = new G4UIdirectory("/hTest/"); |
---|
59 | hTestdetDir->SetGuidance("General hTest commands"); |
---|
60 | hTestdetDir1= new G4UIdirectory("/hTest/physics/"); |
---|
61 | hTestdetDir1->SetGuidance("hTest commands to define physics"); |
---|
62 | hTestdetDir2= new G4UIdirectory("/hTest/gun/"); |
---|
63 | hTestdetDir2->SetGuidance("hTest commands to define gun"); |
---|
64 | if(hDet->GetVerbose() > 0) { |
---|
65 | G4cout << "hTestDetectorMessenger: Is constructed" << G4endl; |
---|
66 | } |
---|
67 | |
---|
68 | AbsMaterCmd = new G4UIcmdWithAString("/hTest/AbsorberMaterial",this); |
---|
69 | AbsMaterCmd->SetGuidance("Select Material of the Absorber."); |
---|
70 | AbsMaterCmd->SetParameterName("AbsoberMaterial",false); |
---|
71 | AbsMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
72 | |
---|
73 | WorldMaterCmd = new G4UIcmdWithAString("/hTest/WorldMaterial",this); |
---|
74 | WorldMaterCmd->SetGuidance("Select Material of the World."); |
---|
75 | WorldMaterCmd->SetParameterName("WorldMaterial",false); |
---|
76 | WorldMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
77 | |
---|
78 | NumOfAbsCmd = new G4UIcmdWithAnInteger("/hTest/NumberOfAbsorbers",this); |
---|
79 | NumOfAbsCmd->SetGuidance("Set number of absorbers"); |
---|
80 | NumOfAbsCmd->SetParameterName("Nabs",false); |
---|
81 | NumOfAbsCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
82 | |
---|
83 | AbsThickCmd = new G4UIcmdWithADoubleAndUnit("/hTest/AbsorberThick",this); |
---|
84 | AbsThickCmd->SetGuidance("Set Thickness of the Absorber"); |
---|
85 | AbsThickCmd->SetParameterName("SizeZ",false); |
---|
86 | AbsThickCmd->SetRange("SizeZ>0."); |
---|
87 | AbsThickCmd->SetUnitCategory("Length"); |
---|
88 | AbsThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
89 | |
---|
90 | AbsGapCmd = new G4UIcmdWithADoubleAndUnit("/hTest/AbsorberGap",this); |
---|
91 | AbsGapCmd->SetGuidance("Set gap between absorbers"); |
---|
92 | AbsGapCmd->SetParameterName("SizeZ",false); |
---|
93 | AbsGapCmd->SetRange("SizeZ>0."); |
---|
94 | AbsGapCmd->SetUnitCategory("Length"); |
---|
95 | AbsGapCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
96 | |
---|
97 | AbsSizYZCmd = new G4UIcmdWithADoubleAndUnit("/hTest/AbsorberXY",this); |
---|
98 | AbsSizYZCmd->SetGuidance("Set sizeXY of the Absorber"); |
---|
99 | AbsSizYZCmd->SetParameterName("SizeYZ",false); |
---|
100 | AbsSizYZCmd->SetRange("SizeYZ>0."); |
---|
101 | AbsSizYZCmd->SetUnitCategory("Length"); |
---|
102 | AbsSizYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
103 | |
---|
104 | WorldXCmd = new G4UIcmdWithADoubleAndUnit("/hTest/WorldZ",this); |
---|
105 | WorldXCmd->SetGuidance("Set Z size of the World"); |
---|
106 | WorldXCmd->SetParameterName("WSizeX",false); |
---|
107 | WorldXCmd->SetRange("WSizeX>0."); |
---|
108 | WorldXCmd->SetUnitCategory("Length"); |
---|
109 | WorldXCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
110 | |
---|
111 | UpdateCmd = new G4UIcmdWithoutParameter("/hTest/update",this); |
---|
112 | UpdateCmd->SetGuidance("Update calorimeter geometry."); |
---|
113 | UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" "); |
---|
114 | UpdateCmd->SetGuidance("if you changed geometrical value(s)."); |
---|
115 | UpdateCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
116 | |
---|
117 | XMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/hTest/FieldX",this); |
---|
118 | XMagFieldCmd->SetGuidance("Define magnetic field along X"); |
---|
119 | XMagFieldCmd->SetGuidance("Magnetic field will be in X direction."); |
---|
120 | XMagFieldCmd->SetParameterName("Bx",false); |
---|
121 | XMagFieldCmd->SetUnitCategory("Magnetic flux density"); |
---|
122 | XMagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
123 | |
---|
124 | YMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/hTest/FieldY",this); |
---|
125 | YMagFieldCmd->SetGuidance("Define magnetic field along Y"); |
---|
126 | YMagFieldCmd->SetGuidance("Magnetic field will be in Y direction."); |
---|
127 | YMagFieldCmd->SetParameterName("By",false); |
---|
128 | YMagFieldCmd->SetUnitCategory("Magnetic flux density"); |
---|
129 | YMagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
130 | |
---|
131 | ZMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/hTest/FieldZ",this); |
---|
132 | ZMagFieldCmd->SetGuidance("Define magnetic field along Z"); |
---|
133 | ZMagFieldCmd->SetGuidance("Magnetic field will be in Z direction."); |
---|
134 | ZMagFieldCmd->SetParameterName("Bz",false); |
---|
135 | ZMagFieldCmd->SetUnitCategory("Magnetic flux density"); |
---|
136 | ZMagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
137 | |
---|
138 | HistoCmd = new G4UIcmdWithAString("/hTest/HistoName",this); |
---|
139 | HistoCmd->SetGuidance("Set the name of the histo file"); |
---|
140 | HistoCmd->SetParameterName("histo",false); |
---|
141 | HistoCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
142 | |
---|
143 | NumOfEvt = new G4UIcmdWithAnInteger("/hTest/NumberOfEvents",this); |
---|
144 | NumOfEvt->SetGuidance("Set number of event to be simulated"); |
---|
145 | NumOfEvt->SetParameterName("Nevt",false); |
---|
146 | NumOfEvt->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
147 | |
---|
148 | verbCmd = new G4UIcmdWithAnInteger("/hTest/verbose",this); |
---|
149 | verbCmd->SetGuidance("Set verbose for hTest"); |
---|
150 | verbCmd->SetParameterName("verb",false); |
---|
151 | verbCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
152 | |
---|
153 | intCmd = new G4UIcmdWithAnInteger("/hTest/numberAbsToSave",this); |
---|
154 | intCmd->SetGuidance("Set number of absorbers for which "); |
---|
155 | intCmd->SetGuidance("the energy is saved to tuple"); |
---|
156 | intCmd->SetParameterName("numberAbsToSave",false); |
---|
157 | intCmd->AvailableForStates(G4State_PreInit); |
---|
158 | |
---|
159 | nhistCmd = new G4UIcmdWithAnInteger("/hTest/HistoNumber",this); |
---|
160 | nhistCmd->SetGuidance("Set number of histograms to fill"); |
---|
161 | nhistCmd->SetParameterName("HistoNumber",false); |
---|
162 | nhistCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
163 | |
---|
164 | ntupCmd = new G4UIcmdWithABool("/hTest/ntuple",this); |
---|
165 | ntupCmd->SetGuidance("Set number ntuple to fill"); |
---|
166 | ntupCmd->SetParameterName("ntuple",false); |
---|
167 | ntupCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
168 | |
---|
169 | nDebugSCmd = new G4UIcmdWithAnInteger("/hTest/nFirstEventToDebug",this); |
---|
170 | nDebugSCmd->SetGuidance("Set number of the first event to debug"); |
---|
171 | nDebugSCmd->SetParameterName("nFirstEventToDebug",false); |
---|
172 | nDebugSCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
173 | |
---|
174 | nDebugECmd = new G4UIcmdWithAnInteger("/hTest/nLastEventToDebug",this); |
---|
175 | nDebugECmd->SetGuidance("Set number of the last event to debug"); |
---|
176 | nDebugECmd->SetParameterName("nLastEventToDebug",false); |
---|
177 | nDebugECmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
178 | |
---|
179 | DeltaECmd = new G4UIcmdWithADoubleAndUnit("/hTest/maxDeltaEnergy",this); |
---|
180 | DeltaECmd->SetGuidance("Define scale of delta-Energy histogram"); |
---|
181 | DeltaECmd->SetParameterName("DeltaE",false); |
---|
182 | DeltaECmd->SetUnitCategory("Energy"); |
---|
183 | DeltaECmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
184 | |
---|
185 | } |
---|
186 | |
---|
187 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
188 | |
---|
189 | hTestDetectorMessenger::~hTestDetectorMessenger() |
---|
190 | { |
---|
191 | delete NumOfAbsCmd; |
---|
192 | delete AbsMaterCmd; |
---|
193 | delete AbsThickCmd; |
---|
194 | delete AbsGapCmd; |
---|
195 | delete AbsSizYZCmd; |
---|
196 | delete WorldMaterCmd; |
---|
197 | delete WorldXCmd; |
---|
198 | delete UpdateCmd; |
---|
199 | delete XMagFieldCmd; |
---|
200 | delete YMagFieldCmd; |
---|
201 | delete ZMagFieldCmd; |
---|
202 | delete HistoCmd; |
---|
203 | delete NumOfEvt; |
---|
204 | delete verbCmd; |
---|
205 | delete intCmd; |
---|
206 | delete nhistCmd; |
---|
207 | delete nDebugSCmd; |
---|
208 | delete nDebugECmd; |
---|
209 | delete hTestdetDir; |
---|
210 | delete hTestdetDir1; |
---|
211 | delete hTestdetDir2; |
---|
212 | delete DeltaECmd; |
---|
213 | delete ntupCmd; |
---|
214 | } |
---|
215 | |
---|
216 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
217 | |
---|
218 | void hTestDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) |
---|
219 | { |
---|
220 | if(hDet->GetVerbose() > 1) { |
---|
221 | G4cout << "hTestDetectorMessenger: new value = " << newValue << G4endl; |
---|
222 | } |
---|
223 | |
---|
224 | if( command == NumOfAbsCmd ) |
---|
225 | { hDet->SetNumberOfAbsorbers(NumOfAbsCmd->GetNewIntValue(newValue)); |
---|
226 | (hTestHisto::GetPointer())->SetNumberOfAbsorbers(NumOfAbsCmd->GetNewIntValue(newValue)); |
---|
227 | } |
---|
228 | |
---|
229 | if( command == AbsMaterCmd ) |
---|
230 | { hDet->SetAbsorberMaterial(newValue);} |
---|
231 | |
---|
232 | if( command == AbsThickCmd ) |
---|
233 | { hDet->SetAbsorberThickness(AbsThickCmd->GetNewDoubleValue(newValue)); |
---|
234 | (hTestHisto::GetPointer())->SetAbsorberThickness(AbsThickCmd->GetNewDoubleValue(newValue)); |
---|
235 | } |
---|
236 | |
---|
237 | if( command == AbsGapCmd ) |
---|
238 | { hDet->SetGap(AbsGapCmd->GetNewDoubleValue(newValue)); |
---|
239 | (hTestHisto::GetPointer())->SetGap(AbsGapCmd->GetNewDoubleValue(newValue)); |
---|
240 | } |
---|
241 | |
---|
242 | if( command == WorldMaterCmd ) |
---|
243 | { hDet->SetWorldMaterial(newValue);} |
---|
244 | |
---|
245 | if( command == AbsSizYZCmd ) |
---|
246 | { hDet->SetAbsorberSizeXY(AbsSizYZCmd->GetNewDoubleValue(newValue));} |
---|
247 | |
---|
248 | if( command == WorldXCmd ) |
---|
249 | { hDet->SetWorldSizeZ(WorldXCmd->GetNewDoubleValue(newValue));} |
---|
250 | |
---|
251 | if( command == UpdateCmd ) |
---|
252 | { hDet->UpdateGeometry(); } |
---|
253 | |
---|
254 | if( command == XMagFieldCmd ) |
---|
255 | { hDet->SetMagField(XMagFieldCmd->GetNewDoubleValue(newValue),1);} |
---|
256 | |
---|
257 | if( command == YMagFieldCmd ) |
---|
258 | { hDet->SetMagField(YMagFieldCmd->GetNewDoubleValue(newValue),2);} |
---|
259 | |
---|
260 | if( command == ZMagFieldCmd ) |
---|
261 | { hDet->SetMagField(ZMagFieldCmd->GetNewDoubleValue(newValue),3);} |
---|
262 | |
---|
263 | if( command == HistoCmd ) |
---|
264 | { (hTestHisto::GetPointer())->SetHistoName(newValue);} |
---|
265 | |
---|
266 | if( command == ntupCmd ) |
---|
267 | { (hTestHisto::GetPointer())->SetNtuple(ntupCmd->GetNewBoolValue(newValue));} |
---|
268 | |
---|
269 | if( command == NumOfEvt ) |
---|
270 | { hDet->SetNumberOfEvents(NumOfAbsCmd->GetNewIntValue(newValue));} |
---|
271 | |
---|
272 | if( command == verbCmd ){ |
---|
273 | G4int ver = verbCmd->GetNewIntValue(newValue); |
---|
274 | hDet->SetVerbose(ver); |
---|
275 | (hTestHisto::GetPointer())->SetVerbose(ver); |
---|
276 | } |
---|
277 | |
---|
278 | if( command == intCmd ) |
---|
279 | { hDet->SetNumAbsorbersSaved(intCmd->GetNewIntValue(newValue));} |
---|
280 | |
---|
281 | if( command == nhistCmd ) |
---|
282 | { (hTestHisto::GetPointer())->SetHistoNumber(nhistCmd->GetNewIntValue(newValue));} |
---|
283 | |
---|
284 | if( command == nDebugSCmd ) |
---|
285 | { hDet->SetFirstEventToDebug(nDebugSCmd->GetNewIntValue(newValue));} |
---|
286 | |
---|
287 | if( command == nDebugECmd ) |
---|
288 | { hDet->SetLastEventToDebug(nDebugECmd->GetNewIntValue(newValue));} |
---|
289 | |
---|
290 | if( command == DeltaECmd ) |
---|
291 | { (hTestHisto::GetPointer()) |
---|
292 | ->SetMaxEnergy(DeltaECmd->GetNewDoubleValue(newValue));} |
---|
293 | } |
---|
294 | |
---|
295 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|