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