Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4GMocrenMessenger.cc
Go to the documentation of this file.
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// Created: Mar. 31, 2009 Akinori Kimura
30//
31#include "G4GMocrenMessenger.hh"
32
33#include "G4UIdirectory.hh"
34#include "G4UIcmdWithABool.hh"
35#include "G4UIcmdWithAString.hh"
37#include "G4UIcommand.hh"
38#include "G4Tokenizer.hh"
39
41 : suffix (""), geometry(true), pointAttributes(false), solids(true), invisibles(true),
42 kgMocrenVolumeName("gMocrenVolume"),
43 kgMocrenScoringMeshName("gMocrenScoringMesh"),
44 kDrawVolumeGrid(false) {
45
46 kgMocrenDirectory = new G4UIdirectory("/vis/gMocren/");
47 kgMocrenDirectory->SetGuidance("gMocren commands.");
48
49 setEventNumberSuffixCommand = new G4UIcmdWithAString("/vis/gMocren/setEventNumberSuffix", this);
50 setEventNumberSuffixCommand->SetGuidance("Write separate event files, appended with given suffix.");
51 setEventNumberSuffixCommand->SetGuidance("Define the suffix with a pattern such as '-0000'.");
52 setEventNumberSuffixCommand->SetParameterName("suffix",false);
53 setEventNumberSuffixCommand->SetDefaultValue("");
54 setEventNumberSuffixCommand->AvailableForStates(G4State_Idle);
55
56 appendGeometryCommand = new G4UIcmdWithABool("/vis/gMocren/appendGeometry", this);
57 appendGeometryCommand->SetGuidance("Appends copy of geometry to every event.");
58 appendGeometryCommand->SetParameterName("flag",false);
59 appendGeometryCommand->SetDefaultValue(true);
60 appendGeometryCommand->AvailableForStates(G4State_Idle);
61
62 addPointAttributesCommand = new G4UIcmdWithABool("/vis/gMocren/addPointAttributes", this);
63 addPointAttributesCommand->SetGuidance("Adds point attributes to the points of trajectories.");
64 addPointAttributesCommand->SetParameterName("flag",false);
65 addPointAttributesCommand->SetDefaultValue(false);
66 addPointAttributesCommand->AvailableForStates(G4State_Idle);
67
68 useSolidsCommand = new G4UIcmdWithABool("/vis/gMocren/useSolids", this);
69 useSolidsCommand->SetGuidance("Use GMocren Solids, rather than Geant4 Primitives.");
70 useSolidsCommand->SetParameterName("flag",false);
71 useSolidsCommand->SetDefaultValue(true);
72 useSolidsCommand->AvailableForStates(G4State_Idle);
73
74 /* Not Enabled Yet
75 writeInvisiblesCommand = new G4UIcmdWithABool("/vis/gMocren/writeInvisibles", this);
76 writeInvisiblesCommand->SetGuidance("Write invisible objects.");
77 writeInvisiblesCommand->SetParameterName("flag",false);
78 writeInvisiblesCommand->SetDefaultValue(true);
79 writeInvisiblesCommand->AvailableForStates(G4State_Idle);
80 */
81
82 kSetgMocrenVolumeNameCommand = new G4UIcmdWithAString("/vis/gMocren/setVolumeName", this);
83 kSetgMocrenVolumeNameCommand->SetGuidance("detector name for a volume data in gMocren data.");
84 kSetgMocrenVolumeNameCommand->SetParameterName("kgMocrenVolumeName",false);
85 kSetgMocrenVolumeNameCommand->SetDefaultValue("gMocrenVolume");
86 kSetgMocrenVolumeNameCommand->AvailableForStates(G4State_Idle);
87
88 kAddgMocrenHitNameCommand = new G4UIcmdWithAString("/vis/gMocren/addHitName", this);
89 kAddgMocrenHitNameCommand->SetGuidance("hit name for a dose distribution in gMocren data.");
90 kAddgMocrenHitNameCommand->SetParameterName("kgMocrenHitName",false);
91 kAddgMocrenHitNameCommand->AvailableForStates(G4State_Idle);
92
93 kResetgMocrenHitNameCommand = new G4UIcmdWithoutParameter("/vis/gMocren/resetHitNames", this);
94 kResetgMocrenHitNameCommand->SetGuidance("reset all hit names.");
95 kResetgMocrenHitNameCommand->AvailableForStates(G4State_Idle);
96
97 kSetgMocrenScoringMeshNameCommand = new G4UIcmdWithAString("/vis/gMocren/setScoringMeshName", this);
98 kSetgMocrenScoringMeshNameCommand->SetGuidance("scoring mesh name for a dose distribution in gMocren data.");
99 kSetgMocrenScoringMeshNameCommand->SetParameterName("kgMocrenScoringMeshName",false);
100 kSetgMocrenScoringMeshNameCommand->SetDefaultValue("gMocrenScoringMesh");
101 kSetgMocrenScoringMeshNameCommand->AvailableForStates(G4State_Idle);
102
103 kAddgMocrenHitScorerNameCommand = new G4UIcmdWithAString("/vis/gMocren/addHitScorerName", this);
104 kAddgMocrenHitScorerNameCommand->SetGuidance("hit scorer name for a dose distribution in gMocren data.");
105 kAddgMocrenHitScorerNameCommand->SetParameterName("kgMocrenHitScorerNames",false);
106 kAddgMocrenHitScorerNameCommand->AvailableForStates(G4State_Idle);
107
108 kResetgMocrenHitScorerNameCommand = new G4UIcmdWithoutParameter("/vis/gMocren/resetHitScorerName", this);
109 kResetgMocrenHitScorerNameCommand->SetGuidance("reset all hit scorer names.");
110 kResetgMocrenHitScorerNameCommand->AvailableForStates(G4State_Idle);
111
112 kSetgMocrenNoVoxelsCommand = new G4UIcommand("/vis/gMocren/setNumberOfVoxels", this);
113 kSetgMocrenNoVoxelsCommand->SetGuidance("set number of voxels.");
114 kSetgMocrenNoVoxelsCommand->AvailableForStates(G4State_Idle);
115 G4UIparameter * param = new G4UIparameter("nX", 'i', false);
116 param->SetDefaultValue("1");
117 param->SetParameterRange("nX>0");
118 kSetgMocrenNoVoxelsCommand->SetParameter(param);
119 param = new G4UIparameter("nY", 'i', false);
120 param->SetDefaultValue("1");
121 param->SetParameterRange("nY>0");
122 kSetgMocrenNoVoxelsCommand->SetParameter(param);
123 param = new G4UIparameter("nZ", 'i', false);
124 param->SetDefaultValue("1");
125 param->SetParameterRange("nZ>0");
126 kSetgMocrenNoVoxelsCommand->SetParameter(param);
127
128 kListgMocrenCommand = new G4UIcmdWithoutParameter("/vis/gMocren/list", this);
129 kListgMocrenCommand->SetGuidance("list gMocren command parameters.");
130 kListgMocrenCommand->AvailableForStates(G4State_Idle);
131
132 kDrawVolumeGridCommand = new G4UIcmdWithABool("/vis/gMocren/drawVolumeGrid", this);
133 kDrawVolumeGridCommand->SetGuidance("Add grid of the volume.");
134 kDrawVolumeGridCommand->SetParameterName("kDrawVolumeGrid",false);
135 kDrawVolumeGridCommand->SetDefaultValue(false);
136 kDrawVolumeGridCommand->AvailableForStates(G4State_Idle);
137
138}
139
141 delete setEventNumberSuffixCommand;
142 delete appendGeometryCommand;
143 delete addPointAttributesCommand;
144 delete useSolidsCommand;
145 // delete writeInvisiblesCommand;
146 delete kSetgMocrenVolumeNameCommand;
147 delete kAddgMocrenHitNameCommand;
148 delete kResetgMocrenHitNameCommand;
149 //
150 delete kSetgMocrenScoringMeshNameCommand;
151 delete kAddgMocrenHitScorerNameCommand;
152 delete kResetgMocrenHitScorerNameCommand;
153 //
154 delete kSetgMocrenNoVoxelsCommand;
155 //
156 delete kgMocrenDirectory;
157 //
158 delete kDrawVolumeGridCommand;
159}
160
162 if (command==setEventNumberSuffixCommand) {
163 return suffix;
164 } else if (command==appendGeometryCommand) {
165 return appendGeometryCommand->ConvertToString(geometry);
166 } else if (command==addPointAttributesCommand) {
167 return addPointAttributesCommand->ConvertToString(pointAttributes);
168 } else if (command==useSolidsCommand) {
169 return useSolidsCommand->ConvertToString(solids);
170 // } else if (command==writeInvisiblesCommand) {
171 // return writeInvisiblesCommand->ConvertToString(invisibles);
172 } else if (command == kSetgMocrenVolumeNameCommand) {
173 return kgMocrenVolumeName;
174 } else if (command == kAddgMocrenHitNameCommand) {
175 G4String strval;
176 std::vector<G4String>::iterator itr = kgMocrenHitNames.begin();
177 for(; itr != kgMocrenHitNames.end(); itr++) {
178 strval += *itr;
179 strval += " ";
180 }
181 return strval;
182 } else if (command == kSetgMocrenScoringMeshNameCommand) {
183 return kgMocrenScoringMeshName;
184 } else if (command == kAddgMocrenHitScorerNameCommand) {
185 G4String strval;
186 std::vector<G4String>::iterator itr = kgMocrenHitScorerNames.begin();
187 for(; itr != kgMocrenHitScorerNames.end(); itr++) {
188 strval += *itr;
189 strval += " ";
190 }
191 return strval;
192 } else if (command==kDrawVolumeGridCommand) {
193 return kDrawVolumeGridCommand->ConvertToString(kDrawVolumeGrid);
194 } else {
195 return "";
196 }
197}
198
200 if (command==setEventNumberSuffixCommand) {
201 suffix = newValue;
202 } else if (command==appendGeometryCommand) {
203 geometry = appendGeometryCommand->GetNewBoolValue(newValue);
204 } else if (command==addPointAttributesCommand) {
205 pointAttributes = addPointAttributesCommand->GetNewBoolValue(newValue);
206 } else if (command==useSolidsCommand) {
207 solids = useSolidsCommand->GetNewBoolValue(newValue);
208 // } else if (command==writeInvisiblesCommand) {
209 // invisibles = writeInvisiblesCommand->GetNewBoolValue(newValue);
210 } else if (command == kSetgMocrenVolumeNameCommand) {
211 kgMocrenVolumeName = newValue;
212 } else if (command == kAddgMocrenHitNameCommand) {
213 kgMocrenHitNames.push_back(newValue);
214 } else if (command == kResetgMocrenHitNameCommand) {
215 kgMocrenHitNames.clear();
216 } else if (command == kSetgMocrenScoringMeshNameCommand) {
217 kgMocrenScoringMeshName = newValue;
218 } else if (command == kAddgMocrenHitScorerNameCommand) {
219 kgMocrenHitScorerNames.push_back(newValue);
220 } else if (command == kResetgMocrenHitScorerNameCommand) {
221 kgMocrenHitScorerNames.clear();
222 } else if (command == kListgMocrenCommand) {
223 list();
224 } else if (command == kSetgMocrenNoVoxelsCommand) {
225 G4Tokenizer next(newValue);
226 for(int i = 0; i < 3; i++) {
227 kgMocrenNoVoxels[i] = StoI(next());
228 }
229 } else if (command==kDrawVolumeGridCommand) {
230 kDrawVolumeGrid = kDrawVolumeGridCommand->GetNewBoolValue(newValue);
231 }
232}
233
237
239 return geometry;
240}
241
243 return pointAttributes;
244}
245
247 return solids;
248}
249
251 return invisibles;
252}
253
255 return kgMocrenVolumeName;
256}
257
258std::vector<G4String> G4GMocrenMessenger::getHitNames() {
259 return kgMocrenHitNames;
260}
261
263 return kgMocrenScoringMeshName;
264}
265
267 return kgMocrenHitScorerNames;
268}
269
271 G4cout << " Current valuess of gMocren command parameters:" << G4endl;
272 //
273 G4cout << " volume name: " << kgMocrenVolumeName << G4endl;
274 //
275 G4cout << " hit names: ";
276 if(kgMocrenHitNames.size() > 0) {
277 std::vector<G4String>::iterator itr = kgMocrenHitNames.begin();
278 for(; itr != kgMocrenHitNames.end(); itr++)
279 G4cout << *itr << " " << G4endl;
280 } else {
281 G4cout << G4endl;
282 }
283 //
284 G4cout << " scoring mesh name: " << kgMocrenScoringMeshName << G4endl;
285 //
286 G4cout << " scorer names: ";
287 if(kgMocrenHitScorerNames.size() > 0) {
288 std::vector<G4String>::iterator itr = kgMocrenHitScorerNames.begin();
289 for(; itr != kgMocrenHitScorerNames.end(); itr++)
290 G4cout << *itr << " " << G4endl;
291 } else {
292 G4cout << G4endl;
293 }
294 G4cout << G4endl;
295}
296
297void G4GMocrenMessenger::getNoVoxels(G4int & nx, G4int & ny, G4int & nz) const {
298 nx = kgMocrenNoVoxels[0];
299 ny = kgMocrenNoVoxels[1];
300 nz = kgMocrenNoVoxels[2];
301}
@ G4State_Idle
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
virtual G4bool useSolids()
virtual std::vector< G4String > getHitNames()
virtual std::vector< G4String > getHitScorerNames()
virtual void getNoVoxels(G4int &nx, G4int &ny, G4int &nz) const
virtual G4bool appendGeometry()
virtual G4String GetCurrentValue(G4UIcommand *command)
virtual G4bool writeInvisibles()
virtual G4String getVolumeName()
virtual G4bool addPointAttributes()
virtual G4String getScoringMeshName()
virtual G4String getEventNumberSuffix()
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
static G4bool GetNewBoolValue(const char *paramString)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4bool defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(const char *defVal)
static G4String ConvertToString(G4bool boolVal)
void SetParameter(G4UIparameter *const newParameter)
void SetGuidance(const char *aGuidance)
void AvailableForStates(G4ApplicationState s1)
G4int StoI(const G4String &s)
void SetDefaultValue(const char *theDefaultValue)
void SetParameterRange(const char *theRange)