Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ScoringMessenger.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#include "G4ScoringMessenger.hh"
30#include "G4ScoringManager.hh"
31#include "G4VScoringMesh.hh"
32#include "G4ScoringBox.hh"
33#include "G4ScoringCylinder.hh"
34#include "G4ScoringRealWorld.hh"
35#include "G4ScoringProbe.hh"
36
37#include "G4UIdirectory.hh"
40#include "G4UIcmdWithAString.hh"
41#include "G4UIcmdWithABool.hh"
44#include "G4UIcommand.hh"
45#include "G4UIparameter.hh"
46#include "G4Tokenizer.hh"
47#include "G4UnitsTable.hh"
48#include "G4VScoreColorMap.hh"
49
51:fSMan(SManager)
52{
53 G4UIparameter* param = nullptr;
54
55 scoreDir = new G4UIdirectory("/score/");
56 scoreDir->SetGuidance("Interactive scoring commands.");
57
58 listCmd = new G4UIcmdWithoutParameter("/score/list",this);
59 listCmd->SetGuidance("List scoring worlds.");
60
61 dumpCmd = new G4UIcmdWithoutParameter("/score/dump",this);
62 dumpCmd->SetGuidance("Dump results of scorers.");
63
64 verboseCmd = new G4UIcmdWithAnInteger("/score/verbose",this);
65 verboseCmd->SetGuidance("Verbosity.");
66 verboseCmd->SetGuidance(" 0) errors or warnings,");
67 verboseCmd->SetGuidance(" 1) information with 0)");
68
69 meshCreateDir = new G4UIdirectory("/score/create/");
70 meshCreateDir->SetGuidance(" Mesh creation commands.");
71 //
72 // Mesh commands
73 meshBoxCreateCmd = new G4UIcmdWithAString("/score/create/boxMesh",this);
74 meshBoxCreateCmd->SetGuidance("Create scoring box mesh.");
75 meshBoxCreateCmd->SetParameterName("MeshName",false);
76 //
77 meshCylinderCreateCmd = new G4UIcmdWithAString("/score/create/cylinderMesh",this);
78 meshCylinderCreateCmd->SetGuidance("Create scoring mesh.");
79 meshCylinderCreateCmd->SetParameterName("MeshName",false);
80 //
81// meshSphereCreateCmd = new G4UIcmdWithAString("/score/create/sphereMesh",this);
82// meshSphereCreateCmd->SetGuidance("Create scoring mesh.");
83// meshSphereCreateCmd->SetParameterName("MeshName",false);
84 //
85 meshRWLogVolCreateCmd = new G4UIcommand("/score/create/realWorldLogVol",this);
86 meshRWLogVolCreateCmd->SetGuidance("Define scorers to a logical volume defined in the real world.");
87 meshRWLogVolCreateCmd->SetGuidance(" - Name of the specified logical volume is used as the mesh name.");
88 meshRWLogVolCreateCmd->SetGuidance(" - /score/mesh commands do not affect for this mesh.");
89 meshRWLogVolCreateCmd->SetGuidance(" - If copyNumberLevel is set, the copy number of that-level higher");
90 meshRWLogVolCreateCmd->SetGuidance(" in the geometrical hierarchy is used as the index.");
91 param = new G4UIparameter("logVol",'s',false);
92 meshRWLogVolCreateCmd->SetParameter(param);
93 param = new G4UIparameter("copyNumberLevel",'i',true);
94 param->SetParameterRange("copyNumberLevel>=0");
95 param->SetDefaultValue(0);
96 meshRWLogVolCreateCmd->SetParameter(param);
97 //
98 probeCreateCmd = new G4UIcommand("/score/create/probe",this);
99 probeCreateCmd->SetGuidance("Define scoring probe.");
100 probeCreateCmd->SetGuidance(" halfSize defines the half-width of the probing cube.");
101 param = new G4UIparameter("pname",'s',false);
102 probeCreateCmd->SetParameter(param);
103 param = new G4UIparameter("halfSize",'d',false);
104 probeCreateCmd->SetParameter(param);
105 param = new G4UIparameter("unit",'s',true);
106 param->SetDefaultUnit("mm");
107 probeCreateCmd->SetParameter(param);
108 param = new G4UIparameter("checkOverlap",'b',true);
109 param->SetDefaultValue(false);
110 probeCreateCmd->SetParameter(param);
111 //
112 meshOpnCmd = new G4UIcmdWithAString("/score/open",this);
113 meshOpnCmd->SetGuidance("Open scoring mesh.");
114 meshOpnCmd->SetParameterName("MeshName",false);
115 //
116 meshClsCmd = new G4UIcmdWithoutParameter("/score/close",this);
117 meshClsCmd->SetGuidance("Close scoring mesh.");
118 //
119// meshActCmd = new G4UIcmdWithABool("/score/mesh/activate",this);
120// meshActCmd->SetGuidance("Activate scoring mesh.");
121// meshActCmd->SetParameterName("MeshName",false);
122 //
123 meshDir = new G4UIdirectory("/score/mesh/");
124 meshDir->SetGuidance(" Mesh processing commands.");
125 //
126 mBoxSizeCmd = new G4UIcmdWith3VectorAndUnit("/score/mesh/boxSize",this);
127 mBoxSizeCmd->SetGuidance("Define size of the scoring mesh.");
128 mBoxSizeCmd->SetGuidance("Dx Dy Dz unit");
129 mBoxSizeCmd->SetParameterName("Di","Dj","Dk",false,false);
130 mBoxSizeCmd->SetRange("Di>0. && Dj>0. && Dk>0.");
131 mBoxSizeCmd->SetDefaultUnit("mm");
132 //
133 mCylinderSizeCmd = new G4UIcommand("/score/mesh/cylinderSize",this);
134 mCylinderSizeCmd->SetGuidance("Define size of the scoring mesh.");
135 mCylinderSizeCmd->SetGuidance("R Dz unit");
136 param = new G4UIparameter("R",'d',false);
137 param->SetParameterRange("R>0");
138 mCylinderSizeCmd->SetParameter(param);
139 param = new G4UIparameter("Dz",'d',false);
140 param->SetParameterRange("Dz>0");
141 mCylinderSizeCmd->SetParameter(param);
142 param = new G4UIparameter("unit",'s',true);
143 param->SetDefaultUnit("mm");
144 mCylinderSizeCmd->SetParameter(param);
145 //
146 // Division command
147 mBinCmd = new G4UIcommand("/score/mesh/nBin",this);
148 mBinCmd->SetGuidance("Define segments of the scoring mesh.");
149 mBinCmd->SetGuidance("[usage] /score/mesh/nBin");
150 mBinCmd->SetGuidance(" In case of boxMesh, parameters are given in");
151 mBinCmd->SetGuidance(" Ni :(int) Number of bins i (in x-axis) ");
152 mBinCmd->SetGuidance(" Nj :(int) Number of bins j (in y-axis) ");
153 mBinCmd->SetGuidance(" Nk :(int) Number of bins k (in z-axis) ");
154 mBinCmd->SetGuidance(" In case of cylinderMesh, parameters are given in");
155 mBinCmd->SetGuidance(" Nr :(int) Number of bins in radial axis ");
156 mBinCmd->SetGuidance(" Nz :(int) Number of bins in z axis ");
157 mBinCmd->SetGuidance(" Nphi:(int) Number of bins in phi axis ");
158 //mBinCmd->SetGuidance(" Axis:(int) Axis of division ");
159// mBinCmd->SetGuidance(" P1..Pn-1 :(double) \"paramter from P1 to Pn-1 for division.\"");
160 param = new G4UIparameter("Ni",'i',false);
161 param->SetDefaultValue("1");
162 param->SetParameterRange("Ni>0");
163 mBinCmd->SetParameter(param);
164 param = new G4UIparameter("Nj",'i',false);
165 param->SetDefaultValue("1");
166 param->SetParameterRange("Nj>0");
167 mBinCmd->SetParameter(param);
168 param = new G4UIparameter("Nk",'i',false);
169 param->SetDefaultValue("1");
170 mBinCmd->SetParameter(param);
171 param->SetParameterRange("Nk>0");
172 //param = new G4UIparameter("Axis",'i',true);
173 //param->SetDefaultValue("3");
174 //mBinCmd->SetParameter(param);
175 //
176 // Placement command
177 mTransDir = new G4UIdirectory("/score/mesh/translate/");
178 mTransDir->SetGuidance("Mesh translation commands.");
179 //
180 mTResetCmd = new G4UIcmdWithoutParameter("/score/mesh/translate/reset",this);
181 mTResetCmd->SetGuidance("Reset translated position of the scoring mesh.");
182 //
183 mTXyzCmd = new G4UIcmdWith3VectorAndUnit("/score/mesh/translate/xyz",this);
184 mTXyzCmd->SetGuidance("Translate the scoring mesh.");
185 mTXyzCmd->SetParameterName("X","Y","Z",false,false);
186 mTXyzCmd->SetDefaultUnit("mm");
187 //
188 mRotDir = new G4UIdirectory("/score/mesh/rotate/");
189 mRotDir->SetGuidance("Mesh rotation commands.");
190 //
191 //mRResetCmd = new G4UIcmdWithoutParameter("/score/mesh/rotate/reset",this);
192 //mRResetCmd->SetGuidance("Reset rotation angles of the scoring mesh.");
193 //
194 mRotXCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateX",this);
195 mRotXCmd->SetGuidance("Rotate the scoring mesh in X axis.");
196 mRotXCmd->SetParameterName("Rx",false);
197 mRotXCmd->SetDefaultUnit("deg");
198 //
199 mRotYCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateY",this);
200 mRotYCmd->SetGuidance("Rotate the scoring mesh in Y axis.");
201 mRotYCmd->SetParameterName("Ry",false);
202 mRotYCmd->SetDefaultUnit("deg");
203 //
204 mRotZCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateZ",this);
205 mRotZCmd->SetGuidance("Rotate the scoring mesh in Z axis.");
206 mRotZCmd->SetParameterName("Rz",false);
207 mRotZCmd->SetDefaultUnit("deg");
208 //
209 probeDir = new G4UIdirectory("/score/probe/");
210 probeDir->SetGuidance("Probe commands");
211
212 probeMatCmd = new G4UIcmdWithAString("/score/probe/material",this);
213 probeMatCmd->SetGuidance("Specify a material to the probe cube.");
214 probeMatCmd->SetGuidance("Material name has to be taken from G4NistManager.");
215 probeMatCmd->SetGuidance("Once this command is used, the specified material overlays the material in the mass geometry");
216 probeMatCmd->SetGuidance("with \"Layered Mass Geometry\" mechanism so that physics quantities such as energy deposition");
217 probeMatCmd->SetGuidance("or dose will be calculated with this material.");
218 probeMatCmd->SetGuidance("To switch-off this overlaying, use \"none\".");
219 probeMatCmd->SetParameterName("matName",true);
220 probeMatCmd->SetDefaultValue("none");
221
222 probeLocateCmd = new G4UIcmdWith3VectorAndUnit("/score/probe/locate",this);
223 probeLocateCmd->SetGuidance("Locate a probe in the global coordinate system.");
224 probeLocateCmd->SetParameterName("x","y","z",false);
225 probeLocateCmd->SetDefaultUnit("mm");
226
227 // Draw Scoring result
228 drawCmd = new G4UIcommand("/score/drawProjection",this);
229 drawCmd->SetGuidance("Draw projection(s) of scored quantities.");
230 drawCmd->SetGuidance("Parameter <proj> specified which projection(s) to be drawn.");
231 drawCmd->SetGuidance(" 100 : xy-plane, 010 : yz-plane, 001 : zx-plane -- default 111");
232 drawCmd->SetGuidance(" 100 : N/A, 010 : z_phi-plane, 001 : r_phi-plane -- default 111");
233 param = new G4UIparameter("meshName",'s',false);
234 drawCmd->SetParameter(param);
235 param = new G4UIparameter("psName",'s',false);
236 drawCmd->SetParameter(param);
237 param = new G4UIparameter("colorMapName",'s',true);
238 param->SetDefaultValue("defaultLinearColorMap");
239 drawCmd->SetParameter(param);
240 param = new G4UIparameter("proj",'i',true);
241 param->SetDefaultValue(111);
242 drawCmd->SetParameter(param);
243 drawCmd->SetToBeBroadcasted(false);
244
245 // Draw column
246 drawColumnCmd = new G4UIcommand("/score/drawColumn",this);
247 drawColumnCmd->SetGuidance("Draw a cell column.");
248 drawColumnCmd->SetGuidance(" plane = 0 : x-y, 1: y-z, 2: z-x for box mesh");
249 drawColumnCmd->SetGuidance(" 0 : z-phi, 1: r-phi, 2: r-z for cylinder mesh");
250 param = new G4UIparameter("meshName",'s',false);
251 drawColumnCmd->SetParameter(param);
252 param = new G4UIparameter("psName",'s',false);
253 drawColumnCmd->SetParameter(param);
254 param = new G4UIparameter("plane",'i',false);
255 param->SetParameterRange("plane>=0 && plane<=2");
256 drawColumnCmd->SetParameter(param);
257 param = new G4UIparameter("column",'i',false);
258 drawColumnCmd->SetParameter(param);
259 param = new G4UIparameter("colorMapName",'s',true);
260 param->SetDefaultValue("defaultLinearColorMap");
261 drawColumnCmd->SetParameter(param);
262 drawColumnCmd->SetToBeBroadcasted(false);
263
264 colorMapDir = new G4UIdirectory("/score/colorMap/");
265 colorMapDir->SetGuidance("Color map commands.");
266
267 listColorMapCmd = new G4UIcmdWithoutParameter("/score/colorMap/listScoreColorMaps",this);
268 listColorMapCmd->SetGuidance("List registered score color maps.");
269 listColorMapCmd->SetToBeBroadcasted(false);
270
271 floatMinMaxCmd = new G4UIcmdWithAString("/score/colorMap/floatMinMax",this);
272 floatMinMaxCmd->SetGuidance("Min/Max of the color map is calculated according to the actual scores.");
273 floatMinMaxCmd->SetParameterName("colorMapName",true,false);
274 floatMinMaxCmd->SetDefaultValue("defaultLinearColorMap");
275 floatMinMaxCmd->SetToBeBroadcasted(false);
276
277 colorMapMinMaxCmd = new G4UIcommand("/score/colorMap/setMinMax",this);
278 colorMapMinMaxCmd->SetGuidance("Define min/max value of the color map.");
279 param = new G4UIparameter("colorMapMame",'s',true);
280 param->SetDefaultValue("defaultLinearColorMap");
281 colorMapMinMaxCmd->SetParameter(param);
282 param = new G4UIparameter("minValue",'d',false);
283 colorMapMinMaxCmd->SetParameter(param);
284 param = new G4UIparameter("maxValue",'d',false);
285 colorMapMinMaxCmd->SetParameter(param);
286 colorMapMinMaxCmd->SetToBeBroadcasted(false);
287
288 /*
289 chartCmd = new G4UIcommand("/score/drawChart",this);
290 chartCmd->SetGuidance("Draw color chart on the screen.");
291 chartCmd->SetGuidance("[usage] /score/drawChart");
292 chartCmd->SetGuidance(" mesh :(String) Mesh name.");
293 chartCmd->SetGuidance(" psname :(String) PS name.");
294 chartCmd->SetGuidance(" On/Off :(boolean) On or Off the color chart.");
295 chartCmd->SetGuidance(" scale :(String) default=linear, or log ");
296 param = new G4UIparameter("meshName",'s',false);
297 chartCmd->SetParameter(param);
298 param = new G4UIparameter("psName",'s',false);
299 chartCmd->SetParameter(param);
300 param = new G4UIparameter("On",'s',true);
301 param->SetDefaultValue("true");
302 chartCmd->SetParameter(param);
303 param = new G4UIparameter("scale",'s',true);
304 param->SetDefaultValue("linear");
305 chartCmd->SetParameter(param);
306 */
307
308 // Dump a scored quantity
309 dumpQtyToFileCmd = new G4UIcommand("/score/dumpQuantityToFile", this);
310 dumpQtyToFileCmd->SetGuidance("Dump one scored quantity to file.");
311 param = new G4UIparameter("meshName", 's', false);
312 dumpQtyToFileCmd->SetParameter(param);
313 param = new G4UIparameter("psName", 's', false);
314 dumpQtyToFileCmd->SetParameter(param);
315 param = new G4UIparameter("fileName", 's', false);
316 dumpQtyToFileCmd->SetParameter(param);
317 param = new G4UIparameter("option", 's', true);
318 dumpQtyToFileCmd->SetParameter(param);
319 dumpQtyToFileCmd->SetToBeBroadcasted(false);
320
321 dumpQtyWithFactorCmd = new G4UIcommand("/score/dumpQuantityWithFactor", this);
322 dumpQtyWithFactorCmd->SetGuidance("Dump one scored quantity to file.");
323 dumpQtyWithFactorCmd->SetGuidance("Each value is multiplied by the specified factor.");
324 param = new G4UIparameter("meshName", 's', false);
325 dumpQtyWithFactorCmd->SetParameter(param);
326 param = new G4UIparameter("psName", 's', false);
327 dumpQtyWithFactorCmd->SetParameter(param);
328 param = new G4UIparameter("fileName", 's', false);
329 dumpQtyWithFactorCmd->SetParameter(param);
330 param = new G4UIparameter("factor", 'd', false);
331 param->SetParameterRange("factor>0.");
332 dumpQtyWithFactorCmd->SetParameter(param);
333 param = new G4UIparameter("option", 's', true);
334 dumpQtyWithFactorCmd->SetParameter(param);
335 dumpQtyWithFactorCmd->SetToBeBroadcasted(false);
336
337 // Dump all scored quantities
338 dumpAllQtsToFileCmd = new G4UIcommand("/score/dumpAllQuantitiesToFile", this);
339 dumpAllQtsToFileCmd->SetGuidance("Dump all quantities of the mesh to file.");
340 param = new G4UIparameter("meshName", 's', false);
341 dumpAllQtsToFileCmd->SetParameter(param);
342 param = new G4UIparameter("fileName", 's', false);
343 dumpAllQtsToFileCmd->SetParameter(param);
344 param = new G4UIparameter("option", 's', true);
345 dumpAllQtsToFileCmd->SetParameter(param);
346 dumpAllQtsToFileCmd->SetToBeBroadcasted(false);
347
348 dumpAllQtsWithFactorCmd = new G4UIcommand("/score/dumpAllQuantitiesWithFactor", this);
349 dumpAllQtsWithFactorCmd->SetGuidance("Dump all quantities of the mesh to file.");
350 dumpAllQtsWithFactorCmd->SetGuidance("Each value is multiplied by the specified factor.");
351 param = new G4UIparameter("meshName", 's', false);
352 dumpAllQtsWithFactorCmd->SetParameter(param);
353 param = new G4UIparameter("fileName", 's', false);
354 dumpAllQtsWithFactorCmd->SetParameter(param);
355 param = new G4UIparameter("factor", 'd', false);
356 param->SetParameterRange("factor>0.");
357 dumpAllQtsWithFactorCmd->SetParameter(param);
358 param = new G4UIparameter("option", 's', true);
359 dumpAllQtsWithFactorCmd->SetParameter(param);
360 dumpAllQtsWithFactorCmd->SetToBeBroadcasted(false);
361
362 fill1DCmd = new G4UIcommand("/score/fill1D", this);
363 fill1DCmd->SetGuidance("Let a primitive scorer fill 1-D histogram");
364 fill1DCmd->SetGuidance("Before using this command, primitive scorer must be defined and assigned.");
365 fill1DCmd->SetGuidance("Also before using this command, a histogram has to be defined by /analysis/h1/create command.");
366 fill1DCmd->SetGuidance("This command is available only for real-world volume or probe.");
367 fill1DCmd->SetGuidance("Please note that this command has to be applied to each copy number of the scoring volume.");
368 fill1DCmd->SetGuidance("If same histogram ID is used more than once, more than one scorers fill that histogram.");
369 param = new G4UIparameter("histID", 'i', false);
370 fill1DCmd->SetParameter(param);
371 param = new G4UIparameter("meshName", 's', false);
372 fill1DCmd->SetParameter(param);
373 param = new G4UIparameter("scorerName", 's', false);
374 fill1DCmd->SetParameter(param);
375 param = new G4UIparameter("copyNo", 'i', true);
376 param->SetDefaultValue(0);
377 fill1DCmd->SetParameter(param);
378
379}
380
382{
383 delete listCmd;
384 delete verboseCmd;
385 //
386 delete meshBoxCreateCmd;
387 delete meshCylinderCreateCmd;
388 delete meshRWLogVolCreateCmd;
389 delete probeCreateCmd;
390 delete meshCreateDir;
391// delete meshSphereCreateCmd;
392 //
393 delete meshOpnCmd;
394 //
395 delete meshClsCmd;
396// delete meshActCmd;
397 delete meshDir;
398 //
399 delete mBoxSizeCmd;
400 delete mCylinderSizeCmd;
401// delete mSphereSizeCmd;
402 //
403 delete mBinCmd;
404 //
405 delete mTResetCmd;
406 delete mTXyzCmd;
407 delete mTransDir;
408// delete mRResetCmd;
409 delete mRotXCmd;
410 delete mRotYCmd;
411 delete mRotZCmd;
412 delete mRotDir;
413 //
414 delete probeLocateCmd;
415 delete probeMatCmd;
416 delete probeDir;
417 //
418 //delete chartCmd;
419 delete dumpCmd;
420 delete drawCmd;
421 delete drawColumnCmd;
422 delete listColorMapCmd;
423 delete floatMinMaxCmd;
424 delete colorMapMinMaxCmd;
425 delete colorMapDir;
426 delete dumpQtyToFileCmd;
427 delete dumpQtyWithFactorCmd;
428 delete dumpAllQtsToFileCmd;
429 delete dumpAllQtsWithFactorCmd;
430 delete fill1DCmd;
431 //
432 delete scoreDir;
433}
434
436{
437 using MeshShape = G4VScoringMesh::MeshShape;
438
439 if(command==listCmd) {
440 fSMan->List();
441 } else if(command==dumpCmd) {
442 fSMan->Dump();
443 } else if(command==drawCmd) {
444 G4Tokenizer next(newVal);
445 G4String meshName = next();
446 G4String psName = next();
447 G4String colorMapName = next();
448 G4int axflg = StoI(next());
449 fSMan->DrawMesh(meshName,psName,colorMapName,axflg);
450 } else if(command==drawColumnCmd) {
451 G4Tokenizer next(newVal);
452 G4String meshName = next();
453 G4String psName = next();
454 G4int iPlane = StoI(next());
455 G4int iColumn = StoI(next());
456 G4String colorMapName = next();
457 fSMan->DrawMesh(meshName,psName,iPlane,iColumn,colorMapName);
458// } else if(command==chartCmd ){
459// G4Tokenizer next(newVal);
460// G4String meshName = next();
461// G4String psName = next();
462// //G4bool onFlag = StoB(next());
463// G4String scaleOption = next();
464// fSMan->DrawChart(meshName,psName,onFlag,scaleOption);
465
466 } else if(command==dumpQtyToFileCmd) {
467 G4Tokenizer next(newVal);
468 G4String meshName = next();
469 G4String psName = next();
470 G4String fileName = next();
471 G4String option = next("\n");
472 auto mesh = fSMan->FindMesh(meshName);
473 if(!mesh)
474 {
476 ed << "Mesh name <" << meshName << "> is not found. Command ignored.";
477 command->CommandFailed(ed);
478 return;
479 }
480 fSMan->DumpQuantityToFile(meshName, psName, fileName, option);
481 } else if(command==dumpQtyWithFactorCmd) {
482 G4Tokenizer next(newVal);
483 G4String meshName = next();
484 G4String psName = next();
485 G4String fileName = next();
486 G4double fac = StoD(next());
487 G4String option = next("\n");
488 auto mesh = fSMan->FindMesh(meshName);
489 if(!mesh)
490 {
492 ed << "Mesh name <" << meshName << "> is not found. Command ignored.";
493 command->CommandFailed(ed);
494 return;
495 }
496 fSMan->SetFactor(fac);
497 fSMan->DumpQuantityToFile(meshName, psName, fileName, option);
498 fSMan->SetFactor(1.0);
499 } else if(command==dumpAllQtsToFileCmd) {
500 G4Tokenizer next(newVal);
501 G4String meshName = next();
502 G4String fileName = next();
503 G4String option = next("\n");
504 auto mesh = fSMan->FindMesh(meshName);
505 if(!mesh)
506 {
508 ed << "Mesh name <" << meshName << "> is not found. Command ignored.";
509 command->CommandFailed(ed);
510 return;
511 }
512 fSMan->DumpAllQuantitiesToFile(meshName, fileName, option);
513 } else if(command==dumpAllQtsWithFactorCmd) {
514 G4Tokenizer next(newVal);
515 G4String meshName = next();
516 G4String fileName = next();
517 G4double fac = StoD(next());
518 G4String option = next("\n");
519 auto mesh = fSMan->FindMesh(meshName);
520 if(!mesh)
521 {
523 ed << "Mesh name <" << meshName << "> is not found. Command ignored.";
524 command->CommandFailed(ed);
525 return;
526 }
527 fSMan->SetFactor(fac);
528 fSMan->DumpAllQuantitiesToFile(meshName, fileName, option);
529 fSMan->SetFactor(1.0);
530 } else if(command==fill1DCmd) {
531 Fill1D(command,newVal);
532 } else if(command==verboseCmd) {
533 fSMan->SetVerboseLevel(verboseCmd->GetNewIntValue(newVal));
534 } else if(command==meshBoxCreateCmd) {
535 G4VScoringMesh* currentmesh = fSMan->GetCurrentMesh();
536 if ( currentmesh ){
538 ed << "ERROR[" << meshBoxCreateCmd->GetCommandPath()
539 << "] : Mesh <" << currentmesh->GetWorldName()
540 << "> is still open. Close it first. Command ignored.";
541 command->CommandFailed(ed);
542 } else {
543
544 G4VScoringMesh* mesh = fSMan->FindMesh(newVal);
545 if ( !mesh ){
546 mesh = new G4ScoringBox(newVal);
547 fSMan->RegisterScoringMesh(mesh);
548 }else{
550 ed << "ERROR[" << meshBoxCreateCmd->GetCommandPath()
551 << "] : Scoring mesh <" << newVal
552 << "> already exists. Command ignored.";
553 command->CommandFailed(ed);
554 }
555 }
556 } else if(command==meshCylinderCreateCmd) {
557 G4VScoringMesh* currentmesh = fSMan->GetCurrentMesh();
558 if ( currentmesh ){
560 ed << "ERROR[" << meshCylinderCreateCmd->GetCommandPath()
561 << "] : Mesh <" << currentmesh->GetWorldName()
562 << "> is still open. Close it first. Command ignored.";
563 command->CommandFailed(ed);
564 } else {
565
566 G4VScoringMesh* mesh = fSMan->FindMesh(newVal);
567 if ( !mesh ){
568 mesh = new G4ScoringCylinder(newVal);
569 fSMan->RegisterScoringMesh(mesh);
570 }else{
572 ed << "ERROR[" << meshCylinderCreateCmd->GetCommandPath()
573 << "] : Scoring mesh <" << newVal
574 << "> already exists. Command ignored.";
575 command->CommandFailed(ed);
576 }
577 }
578 } else if(command==meshRWLogVolCreateCmd) {
579 auto mesh = fSMan->GetCurrentMesh();
580 if ( mesh ){
582 ed << "ERROR[" << meshRWLogVolCreateCmd->GetCommandPath()
583 << "] : Mesh <" << mesh->GetWorldName()
584 << "> is still open. Close it first. Command ignored.";
585 command->CommandFailed(ed);
586 }
587 else
588 {
589 G4Tokenizer next(newVal);
590 G4String meshName = next();
591 G4int idx = StoI(next());
592 mesh = fSMan->FindMesh(meshName);
593 if ( !mesh ){
594 mesh = new G4ScoringRealWorld(meshName);
595 mesh->SetCopyNumberLevel(idx);
596 fSMan->RegisterScoringMesh(mesh);
597 }else{
599 ed << "ERROR[" << meshRWLogVolCreateCmd->GetCommandPath()
600 << "] : Scoring mesh <" << meshName << "> already exists. Command ignored.";
601 command->CommandFailed(ed);
602 }
603 }
604 } else if(command==probeCreateCmd) {
605 auto mesh = fSMan->GetCurrentMesh();
606 if ( mesh ){
608 ed << "ERROR[" << meshRWLogVolCreateCmd->GetCommandPath()
609 << "] : Mesh <" << mesh->GetWorldName()
610 << "> is still open. Close it first. Command ignored.";
611 command->CommandFailed(ed);
612 }
613 else
614 {
615 G4Tokenizer next(newVal);
616 G4String qname = next();
617 G4double halfSize = StoD(next());
618 halfSize *= G4UIcommand::ValueOf(next());
619 G4bool checkOverlap = StoB(next());
620 mesh = fSMan->FindMesh(qname);
621 if(!mesh)
622 {
623 mesh = new G4ScoringProbe(qname,halfSize,checkOverlap);
624 fSMan->RegisterScoringMesh(mesh);
625 }
626 else
627 {
629 ed << "ERROR[" << probeCreateCmd->GetCommandPath()
630 << "] : Mesh name <" << qname << "> already exists. Use another name.";
631 command->CommandFailed(ed);
632 }
633 }
634 } else if(command==probeMatCmd || command==probeLocateCmd) {
635 auto mesh = fSMan->GetCurrentMesh();
636 if(!mesh)
637 {
639 ed << "ERROR : No mesh is currently open. Open/create a mesh first. Command ignored.";
640 command->CommandFailed(ed);
641 return;
642 }
643 if(mesh->GetShape() != MeshShape::probe)
644 {
646 ed << "ERROR : Inconsistent mesh type. Close current mesh and open Scoring Probe.";
647 command->CommandFailed(ed);
648 return;
649 }
650
651 if(command==probeMatCmd)
652 {
653 G4bool succ = static_cast<G4ScoringProbe*>(mesh)->SetMaterial(newVal);
654 if(!succ)
655 {
657 ed << "Material <" << newVal << "> is not defind in G4NistManager. Command is ignored.\n"
658 << "Use /material/nist/listMaterials command to see the available materials.";
659 command->CommandFailed(ed);
660 return;
661 }
662 }
663 else if(command==probeLocateCmd)
664 {
665 G4ThreeVector loc = probeLocateCmd->GetNew3VectorValue(newVal);
666 static_cast<G4ScoringProbe*>(mesh)->LocateProbe(loc);
667 }
668 } else if(command==listColorMapCmd) {
669 fSMan->ListScoreColorMaps();
670 } else if(command==floatMinMaxCmd) {
671 G4VScoreColorMap* colorMap = fSMan->GetScoreColorMap(newVal);
672 if(colorMap)
673 { colorMap->SetFloatingMinMax(true); }
674 else
675 {
677 ed << "ERROR[" << floatMinMaxCmd->GetCommandPath()
678 << "] : color map <" << newVal << "> is not defined. Command ignored." ;
679 command->CommandFailed(ed);
680 }
681 } else if(command==colorMapMinMaxCmd) {
682 G4Tokenizer next(newVal);
683 G4String mapName = next();
684 G4double minVal = StoD(next());
685 G4double maxVal = StoD(next());
686 G4VScoreColorMap* colorMap = fSMan->GetScoreColorMap(mapName);
687 if(colorMap)
688 { colorMap->SetFloatingMinMax(false);
689 colorMap->SetMinMax(minVal,maxVal); }
690 else
691 {
693 ed << "ERROR[" << colorMapMinMaxCmd->GetCommandPath()
694 << "] : color map <" << newVal << "> is not defined. Command ignored."
695 << G4endl;
696 command->CommandFailed(ed);
697 }
698 } else if(command==meshOpnCmd) {
699 G4VScoringMesh* currentmesh = fSMan->GetCurrentMesh();
700 if ( currentmesh ){
702 ed << "ERROR[" << meshOpnCmd->GetCommandPath()
703 << "] : Mesh <" << currentmesh->GetWorldName()
704 << "> is still open. Close it first. Command ignored.";
705 command->CommandFailed(ed);
706 } else {
707 G4VScoringMesh* mesh = fSMan->FindMesh(newVal);
708 if ( !mesh ){
710 ed << "ERROR[" << meshOpnCmd->GetCommandPath()
711 << "] : Scoring mesh <" << newVal << "> does not exist. Command ignored.";
712 command->CommandFailed(ed);
713 } else {
714 fSMan->SetCurrentMesh(mesh);
715 }
716 }
717 } else if(command==meshClsCmd) {
718 fSMan->CloseCurrentMesh();
719 } else {
720 //
721 // Get Current Mesh
722 //
723 G4VScoringMesh* mesh = fSMan->GetCurrentMesh();
724 //
725 // Commands for Current Mesh
726 if ( mesh ){
727 MeshShape shape = mesh->GetShape();
728 if ( shape == MeshShape::realWorldLogVol ) {
730 ed << "ERROR[" << mBinCmd->GetCommandPath()
731 << "] : Number of mesh command cannot be set for this type of mesh. Command ignored.";
732 command->CommandFailed(ed);
733 } else {
734
735 // Tokens
736 G4TokenVec token;
737 FillTokenVec(newVal,token);
738 //
739 // Mesh Geometry
740 //
741// if(command==meshActCmd) {
742// mesh->Activate(meshActCmd->GetNewBoolValue(newVal));
743// } else
744 if(command==mBoxSizeCmd) {
745 if ( shape == MeshShape::box){
746 G4ThreeVector size = mBoxSizeCmd->GetNew3VectorValue(newVal);
747 G4double vsize[3];
748 vsize[0] = size.x();
749 vsize[1] = size.y();
750 vsize[2] = size.z();
751 mesh->SetSize(vsize);
752 } else {
754 ed << "ERROR[" << mBoxSizeCmd->GetCommandPath()
755 << "] : This mesh is not Box. Command ignored.";
756 command->CommandFailed(ed);
757 }
758 }else if(command==mCylinderSizeCmd) {
759 if ( shape == MeshShape::cylinder ){
760 G4double vsize[3];
761 vsize[0] = StoD(token[0]);
762 vsize[1] = StoD(token[1]);
763 G4double unt = mCylinderSizeCmd->ValueOf(token[2]);
764 vsize[0] *= unt;
765 vsize[1] *= unt;
766 vsize[2] = 0.0;
767 mesh->SetSize(vsize);
768 } else {
770 ed << "ERROR[" << mBoxSizeCmd->GetCommandPath()
771 << "] : This mesh is not Box. Command ignored.";
772 command->CommandFailed(ed);
773 }
774 } else if(command==mBinCmd) {
775 MeshBinCommand(mesh,token);
776 } else if(command==mTResetCmd) {
777 G4double centerPosition[3] ={ 0., 0., 0.};
778 mesh->SetCenterPosition(centerPosition);
779 } else if(command==mTXyzCmd) {
780 G4ThreeVector xyz = mTXyzCmd->GetNew3VectorValue(newVal);
781 G4double centerPosition[3];
782 centerPosition[0] = xyz.x();
783 centerPosition[1] = xyz.y();
784 centerPosition[2] = xyz.z();
785 mesh->SetCenterPosition(centerPosition);
786// } else if(command==mRResetCmd) {
787 } else if(command==mRotXCmd) {
788 G4double value = mRotXCmd->GetNewDoubleValue(newVal);
789 mesh->RotateX(value);
790 } else if(command==mRotYCmd) {
791 G4double value = mRotYCmd->GetNewDoubleValue(newVal);
792 mesh->RotateY(value);
793 } else if(command==mRotZCmd) {
794 G4double value = mRotZCmd->GetNewDoubleValue(newVal);
795 mesh->RotateZ(value);
796 }
797 }
798 }else{
800 ed << "ERROR: No mesh is currently open. Open/create a mesh first. Command ignored.";
801 command->CommandFailed(ed);
802 }
803 }
804}
805
807{
808 G4String val;
809 if(command==verboseCmd)
810 { val = verboseCmd->ConvertToString(fSMan->GetVerboseLevel()); }
811
812 return val;
813}
814
816
817 G4Tokenizer next(newValues);
818 G4String val;
819 while ( !(val = next()).isNull() ) { // Loop checking 12.18.2015 M.Asai
820 token.push_back(val);
821 }
822}
823
824
826 G4int Ni = StoI(token[0]);
827 G4int Nj = StoI(token[1]);
828 G4int Nk = StoI(token[2]);
829 G4int nSegment[3];
830
831 if(dynamic_cast<G4ScoringBox*>(mesh)) {
832 G4cout << ".... G4ScoringMessenger::MeshBinCommand - G4ScoringBox" << G4endl;
833 nSegment[0] = Ni;
834 nSegment[1] = Nj;
835 nSegment[2] = Nk;
836 } else if(dynamic_cast<G4ScoringCylinder*>(mesh)) {
837 G4cout << ".... G4ScoringMessenger::MeshBinCommand - G4ScoringCylinder" << G4endl;
838 nSegment[0] = Nj;
839 nSegment[1] = Nk;
840 nSegment[2] = Ni;
841 } else {
842 G4Exception("G4ScoringMessenger::MeshBinCommand()", "001", FatalException, "invalid mesh type");
843 return;
844 }
845 //
846 mesh->SetNumberOfSegments(nSegment);
847}
848
849#include "G4VPrimitivePlotter.hh"
850#include "G4VScoreHistFiller.hh"
851
853{
854 using MeshShape = G4VScoringMesh::MeshShape;
855
856 G4Tokenizer next(newVal);
857 G4int histID = StoI(next());
858 G4String meshName = next();
859 G4String primName = next();
860 G4int copyNo = StoI(next());
861
862 auto filler = G4VScoreHistFiller::Instance();
863 if(!filler)
864 {
866 ed << "G4TScoreHistFiller is not instantiated in this application.";
867 cmd->CommandFailed(ed);
868 return;
869 }
870 //
871 // To do : check the validity of histID
872 //
873
875 auto mesh = sm->FindMesh(meshName);
876 if(mesh==nullptr)
877 {
879 ed << "Mesh name <" << meshName << "> is not found.";
880 cmd->CommandFailed(ed);
881 return;
882 }
883 auto shape = mesh->GetShape();
884 if(shape!=MeshShape::realWorldLogVol && shape!=MeshShape::probe)
885 {
887 ed << "Mesh <" << meshName << "> is not real-world logical volume or probe.";
888 cmd->CommandFailed(ed);
889 return;
890 }
891
892 auto prim = mesh->GetPrimitiveScorer(primName);
893 if(prim==nullptr)
894 {
896 ed << "Primitive scorer name <" << primName << "> is not found.";
897 cmd->CommandFailed(ed);
898 return;
899 }
900 auto pp = dynamic_cast<G4VPrimitivePlotter*>(prim);
901 if(pp==nullptr)
902 {
904 ed << "Primitive scorer <" << primName << "> does not support direct histogram filling.";
905 cmd->CommandFailed(ed);
906 return;
907 }
908
909 pp->Plot(copyNo,histID);
910}
911
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
std::vector< G4String > G4TokenVec
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
double z() const
double x() const
double y() const
void RegisterScoringMesh(G4VScoringMesh *scm)
G4int GetVerboseLevel() const
void SetVerboseLevel(G4int vl)
G4VScoreColorMap * GetScoreColorMap(const G4String &mapName)
void DumpAllQuantitiesToFile(const G4String &meshName, const G4String &fileName, const G4String &option="")
G4VScoringMesh * FindMesh(G4VHitsCollection *map)
void SetCurrentMesh(G4VScoringMesh *scm)
void DrawMesh(const G4String &meshName, const G4String &psName, const G4String &colorMapName, G4int axflg=111)
void SetFactor(G4double val=1.0)
G4VScoringMesh * GetCurrentMesh() const
static G4ScoringManager * GetScoringManagerIfExist()
void DumpQuantityToFile(const G4String &meshName, const G4String &psName, const G4String &fileName, const G4String &option="")
void FillTokenVec(G4String newValues, G4TokenVec &token)
void MeshBinCommand(G4VScoringMesh *mesh, G4TokenVec &token)
G4ScoringMessenger(G4ScoringManager *SManager)
void Fill1D(G4UIcommand *cmd, G4String newValues)
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValues)
void SetDefaultUnit(const char *defUnit)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultUnit(const char *defUnit)
static G4double GetNewDoubleValue(const char *paramString)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(const char *defVal)
static G4int GetNewIntValue(const char *paramString)
void SetToBeBroadcasted(G4bool val)
Definition: G4UIcommand.hh:172
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:348
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:430
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:136
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:146
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
Definition: G4UIcommand.hh:179
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
G4int StoI(G4String s)
G4double StoD(G4String s)
G4bool StoB(G4String s)
void SetDefaultValue(const char *theDefaultValue)
void SetParameterRange(const char *theRange)
void SetDefaultUnit(const char *theDefaultUnit)
void SetMinMax(G4double minVal, G4double maxVal)
void SetFloatingMinMax(G4bool vl=true)
static G4VScoreHistFiller * Instance()
MeshShape GetShape() const
void RotateY(G4double delta)
const G4String & GetWorldName() const
void SetNumberOfSegments(G4int nSegment[3])
void SetCenterPosition(G4double centerPosition[3])
void RotateX(G4double delta)
void SetSize(G4double size[3])
void RotateZ(G4double delta)