ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4GMocrenMessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4GMocrenMessenger.cc
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'.");
55 
56  appendGeometryCommand = new G4UIcmdWithABool("/vis/gMocren/appendGeometry", this);
57  appendGeometryCommand->SetGuidance("Appends copy of geometry to every event.");
61 
62  addPointAttributesCommand = new G4UIcmdWithABool("/vis/gMocren/addPointAttributes", this);
63  addPointAttributesCommand->SetGuidance("Adds point attributes to the points of trajectories.");
67 
68  useSolidsCommand = new G4UIcmdWithABool("/vis/gMocren/useSolids", this);
69  useSolidsCommand->SetGuidance("Use GMocren Solids, rather than Geant4 Primitives.");
70  useSolidsCommand->SetParameterName("flag",false);
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);
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);
92 
93  kResetgMocrenHitNameCommand = new G4UIcmdWithoutParameter("/vis/gMocren/resetHitNames", this);
94  kResetgMocrenHitNameCommand->SetGuidance("reset all hit names.");
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");
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);
107 
108  kResetgMocrenHitScorerNameCommand = new G4UIcmdWithoutParameter("/vis/gMocren/resetHitScorerName", this);
109  kResetgMocrenHitScorerNameCommand->SetGuidance("reset all hit scorer names.");
111 
112  kSetgMocrenNoVoxelsCommand = new G4UIcommand("/vis/gMocren/setNumberOfVoxels", this);
113  kSetgMocrenNoVoxelsCommand->SetGuidance("set number of voxels.");
115  G4UIparameter * param = new G4UIparameter("nX", 'i', false);
116  param->SetDefaultValue("1");
117  param->SetParameterRange("nX>0");
119  param = new G4UIparameter("nY", 'i', false);
120  param->SetDefaultValue("1");
121  param->SetParameterRange("nY>0");
123  param = new G4UIparameter("nZ", 'i', false);
124  param->SetDefaultValue("1");
125  param->SetParameterRange("nZ>0");
127 
128  kListgMocrenCommand = new G4UIcmdWithoutParameter("/vis/gMocren/list", this);
129  kListgMocrenCommand->SetGuidance("list gMocren command parameters.");
131 
132  kDrawVolumeGridCommand = new G4UIcmdWithABool("/vis/gMocren/drawVolumeGrid", this);
133  kDrawVolumeGridCommand->SetGuidance("Add grid of the volume.");
134  kDrawVolumeGridCommand->SetParameterName("kDrawVolumeGrid",false);
137 
138 }
139 
142  delete appendGeometryCommand;
144  delete useSolidsCommand;
145  // delete writeInvisiblesCommand;
149  //
153  //
155  //
156  delete kgMocrenDirectory;
157  //
158  delete kDrawVolumeGridCommand;
159 }
160 
162  if (command==setEventNumberSuffixCommand) {
163  return suffix;
164  } else if (command==appendGeometryCommand) {
166  } else if (command==addPointAttributesCommand) {
168  } else if (command==useSolidsCommand) {
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) {
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) {
194  } else {
195  return "";
196  }
197 }
198 
200  if (command==setEventNumberSuffixCommand) {
201  suffix = newValue;
202  } else if (command==appendGeometryCommand) {
204  } else if (command==addPointAttributesCommand) {
206  } else if (command==useSolidsCommand) {
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) {
231  }
232 }
233 
235  return suffix;
236 }
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 
258 std::vector<G4String> G4GMocrenMessenger::getHitNames() {
259  return kgMocrenHitNames;
260 }
261 
264 }
265 
266 std::vector<G4String> G4GMocrenMessenger::getHitScorerNames() {
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 
297 void G4GMocrenMessenger::getNoVoxels(G4int & nx, G4int & ny, G4int & nz) const {
298  nx = kgMocrenNoVoxels[0];
299  ny = kgMocrenNoVoxels[1];
300  nz = kgMocrenNoVoxels[2];
301 }