Geant4-11
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 //
78 new G4UIcmdWithAString("/score/create/cylinderMesh", this);
79 meshCylinderCreateCmd->SetGuidance("Create scoring mesh.");
80 meshCylinderCreateCmd->SetParameterName("MeshName", false);
81 //
82 // meshSphereCreateCmd = new
83 // G4UIcmdWithAString("/score/create/sphereMesh",this);
84 // meshSphereCreateCmd->SetGuidance("Create scoring mesh.");
85 // meshSphereCreateCmd->SetParameterName("MeshName",false);
86 //
88 new G4UIcommand("/score/create/realWorldLogVol", this);
90 "Define scorers to a logical volume defined in the real world.");
92 " - Name of the specified logical volume is used as the mesh name.");
94 " - /score/mesh commands do not affect for this mesh.");
96 " - If copyNumberLevel is set, the copy number of that-level higher");
98 " in the geometrical hierarchy is used as the index.");
99 param = new G4UIparameter("logVol", 's', false);
101 param = new G4UIparameter("copyNumberLevel", 'i', true);
102 param->SetParameterRange("copyNumberLevel>=0");
103 param->SetDefaultValue(0);
105 //
106 probeCreateCmd = new G4UIcommand("/score/create/probe", this);
107 probeCreateCmd->SetGuidance("Define scoring probe.");
109 " halfSize defines the half-width of the probing cube.");
110 param = new G4UIparameter("pname", 's', false);
112 param = new G4UIparameter("halfSize", 'd', false);
114 param = new G4UIparameter("unit", 's', true);
115 param->SetDefaultUnit("mm");
117 param = new G4UIparameter("checkOverlap", 'b', true);
118 param->SetDefaultValue(false);
120 //
121 meshOpnCmd = new G4UIcmdWithAString("/score/open", this);
122 meshOpnCmd->SetGuidance("Open scoring mesh.");
123 meshOpnCmd->SetParameterName("MeshName", false);
124 //
125 meshClsCmd = new G4UIcmdWithoutParameter("/score/close", this);
126 meshClsCmd->SetGuidance("Close scoring mesh.");
127 //
128 // meshActCmd = new G4UIcmdWithABool("/score/mesh/activate",this);
129 // meshActCmd->SetGuidance("Activate scoring mesh.");
130 // meshActCmd->SetParameterName("MeshName",false);
131 //
132 meshDir = new G4UIdirectory("/score/mesh/");
133 meshDir->SetGuidance(" Mesh processing commands.");
134 //
135 mBoxSizeCmd = new G4UIcmdWith3VectorAndUnit("/score/mesh/boxSize", this);
136 mBoxSizeCmd->SetGuidance("Define size of the scoring mesh.");
137 mBoxSizeCmd->SetGuidance("Dx Dy Dz unit");
138 mBoxSizeCmd->SetParameterName("Di", "Dj", "Dk", false, false);
139 mBoxSizeCmd->SetRange("Di>0. && Dj>0. && Dk>0.");
141 //
142 mCylinderSizeCmd = new G4UIcommand("/score/mesh/cylinderSize", this);
143 mCylinderSizeCmd->SetGuidance("Define size of the scoring mesh.");
144 mCylinderSizeCmd->SetGuidance("R Dz unit");
145 param = new G4UIparameter("R", 'd', false);
146 param->SetParameterRange("R>0");
148 param = new G4UIparameter("Dz", 'd', false);
149 param->SetParameterRange("Dz>0");
151 param = new G4UIparameter("unit", 's', true);
152 param->SetDefaultUnit("mm");
154 //
156 new G4UIcmdWithADoubleAndUnit("/score/mesh/cylinderRMin", this);
157 mCylinderRMinCmd->SetGuidance("Define the inner radius of the tube mesh.");
158 mCylinderRMinCmd->SetGuidance("This command is not needed for cylinder mesh");
159 mCylinderRMinCmd->SetParameterName("RMin", false, false);
160 mCylinderRMinCmd->SetRange("RMin>=0.");
162 //
163 mCylinderAngleCmd = new G4UIcommand("/score/mesh/cylinderAngles", this);
165 "Define starting angle and span for tube segment mesh.");
167 "This command is not needed for cylinder mesh");
168 param = new G4UIparameter("startPhi", 'd', false);
170 param = new G4UIparameter("deltaPhi", 'd', false);
171 param->SetParameterRange("deltaPhi>0.");
173 param = new G4UIparameter("unit", 's', true);
174 param->SetDefaultUnit("deg");
176 //
177 // Division command
178 mBinCmd = new G4UIcommand("/score/mesh/nBin", this);
179 mBinCmd->SetGuidance("Define segments of the scoring mesh.");
180 mBinCmd->SetGuidance("[usage] /score/mesh/nBin");
181 mBinCmd->SetGuidance(" In case of boxMesh, parameters are given in");
182 mBinCmd->SetGuidance(" Ni :(int) Number of bins i (in x-axis) ");
183 mBinCmd->SetGuidance(" Nj :(int) Number of bins j (in y-axis) ");
184 mBinCmd->SetGuidance(" Nk :(int) Number of bins k (in z-axis) ");
185 mBinCmd->SetGuidance(" In case of cylinderMesh, parameters are given in");
186 mBinCmd->SetGuidance(" Nr :(int) Number of bins in radial axis ");
187 mBinCmd->SetGuidance(" Nz :(int) Number of bins in z axis ");
188 mBinCmd->SetGuidance(" Nphi:(int) Number of bins in phi axis ");
189 // mBinCmd->SetGuidance(" Axis:(int) Axis of division ");
190 // mBinCmd->SetGuidance(" P1..Pn-1 :(double) \"paramter from P1 to Pn-1 for
191 // division.\"");
192 param = new G4UIparameter("Ni", 'i', false);
193 param->SetDefaultValue("1");
194 param->SetParameterRange("Ni>0");
195 mBinCmd->SetParameter(param);
196 param = new G4UIparameter("Nj", 'i', false);
197 param->SetDefaultValue("1");
198 param->SetParameterRange("Nj>0");
199 mBinCmd->SetParameter(param);
200 param = new G4UIparameter("Nk", 'i', false);
201 param->SetDefaultValue("1");
202 mBinCmd->SetParameter(param);
203 param->SetParameterRange("Nk>0");
204 // param = new G4UIparameter("Axis",'i',true);
205 // param->SetDefaultValue("3");
206 // mBinCmd->SetParameter(param);
207 //
208 // Placement command
209 mTransDir = new G4UIdirectory("/score/mesh/translate/");
210 mTransDir->SetGuidance("Mesh translation commands.");
211 //
212 mTResetCmd = new G4UIcmdWithoutParameter("/score/mesh/translate/reset", this);
213 mTResetCmd->SetGuidance("Reset translated position of the scoring mesh.");
214 //
215 mTXyzCmd = new G4UIcmdWith3VectorAndUnit("/score/mesh/translate/xyz", this);
216 mTXyzCmd->SetGuidance("Translate the scoring mesh.");
217 mTXyzCmd->SetParameterName("X", "Y", "Z", false, false);
219 //
220 mRotDir = new G4UIdirectory("/score/mesh/rotate/");
221 mRotDir->SetGuidance("Mesh rotation commands.");
222 //
223 // mRResetCmd = new G4UIcmdWithoutParameter("/score/mesh/rotate/reset",this);
224 // mRResetCmd->SetGuidance("Reset rotation angles of the scoring mesh.");
225 //
226 mRotXCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateX", this);
227 mRotXCmd->SetGuidance("Rotate the scoring mesh in X axis.");
228 mRotXCmd->SetParameterName("Rx", false);
229 mRotXCmd->SetDefaultUnit("deg");
230 //
231 mRotYCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateY", this);
232 mRotYCmd->SetGuidance("Rotate the scoring mesh in Y axis.");
233 mRotYCmd->SetParameterName("Ry", false);
234 mRotYCmd->SetDefaultUnit("deg");
235 //
236 mRotZCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateZ", this);
237 mRotZCmd->SetGuidance("Rotate the scoring mesh in Z axis.");
238 mRotZCmd->SetParameterName("Rz", false);
239 mRotZCmd->SetDefaultUnit("deg");
240 //
241 probeDir = new G4UIdirectory("/score/probe/");
242 probeDir->SetGuidance("Probe commands");
243
244 probeMatCmd = new G4UIcmdWithAString("/score/probe/material", this);
245 probeMatCmd->SetGuidance("Specify a material to the probe cube.");
246 probeMatCmd->SetGuidance("Material name has to be taken from G4NistManager.");
247 probeMatCmd->SetGuidance("Once this command is used, the specified material "
248 "overlays the material in the mass geometry");
249 probeMatCmd->SetGuidance("with \"Layered Mass Geometry\" mechanism so that "
250 "physics quantities such as energy deposition");
251 probeMatCmd->SetGuidance("or dose will be calculated with this material.");
252 probeMatCmd->SetGuidance("To switch-off this overlaying, use \"none\".");
253 probeMatCmd->SetParameterName("matName", true);
256
257 probeLocateCmd = new G4UIcmdWith3VectorAndUnit("/score/probe/locate", this);
259 "Locate a probe in the global coordinate system.");
260 probeLocateCmd->SetParameterName("x", "y", "z", false);
263
264 // Draw Scoring result
265 drawCmd = new G4UIcommand("/score/drawProjection", this);
266 drawCmd->SetGuidance("Draw projection(s) of scored quantities.");
268 "Parameter <proj> specified which projection(s) to be drawn.");
270 " 100 : xy-plane, 010 : yz-plane, 001 : zx-plane -- default 111");
272 " 100 : N/A, 010 : z_phi-plane, 001 : r_phi-plane -- default 111");
273 param = new G4UIparameter("meshName", 's', false);
274 drawCmd->SetParameter(param);
275 param = new G4UIparameter("psName", 's', false);
276 drawCmd->SetParameter(param);
277 param = new G4UIparameter("colorMapName", 's', true);
278 param->SetDefaultValue("defaultLinearColorMap");
279 drawCmd->SetParameter(param);
280 param = new G4UIparameter("proj", 'i', true);
281 param->SetDefaultValue(111);
282 drawCmd->SetParameter(param);
284
285 // Draw column
286 drawColumnCmd = new G4UIcommand("/score/drawColumn", this);
287 drawColumnCmd->SetGuidance("Draw a cell column.");
288 drawColumnCmd->SetGuidance(" plane = 0 : x-y, 1: y-z, 2: z-x for box mesh");
290 " 0 : z-phi, 1: r-phi, 2: r-z for cylinder mesh");
291 param = new G4UIparameter("meshName", 's', false);
293 param = new G4UIparameter("psName", 's', false);
295 param = new G4UIparameter("plane", 'i', false);
296 param->SetParameterRange("plane>=0 && plane<=2");
298 param = new G4UIparameter("column", 'i', false);
300 param = new G4UIparameter("colorMapName", 's', true);
301 param->SetDefaultValue("defaultLinearColorMap");
304
305 colorMapDir = new G4UIdirectory("/score/colorMap/");
306 colorMapDir->SetGuidance("Color map commands.");
307
309 new G4UIcmdWithoutParameter("/score/colorMap/listScoreColorMaps", this);
310 listColorMapCmd->SetGuidance("List registered score color maps.");
312
313 floatMinMaxCmd = new G4UIcmdWithAString("/score/colorMap/floatMinMax", this);
315 "Min/Max of the color map is calculated according to the actual scores.");
316 floatMinMaxCmd->SetParameterName("colorMapName", true, false);
317 floatMinMaxCmd->SetDefaultValue("defaultLinearColorMap");
319
320 colorMapMinMaxCmd = new G4UIcommand("/score/colorMap/setMinMax", this);
321 colorMapMinMaxCmd->SetGuidance("Define min/max value of the color map.");
322 param = new G4UIparameter("colorMapMame", 's', true);
323 param->SetDefaultValue("defaultLinearColorMap");
325 param = new G4UIparameter("minValue", 'd', false);
327 param = new G4UIparameter("maxValue", 'd', false);
330
331 /*
332 chartCmd = new G4UIcommand("/score/drawChart",this);
333 chartCmd->SetGuidance("Draw color chart on the screen.");
334 chartCmd->SetGuidance("[usage] /score/drawChart");
335 chartCmd->SetGuidance(" mesh :(String) Mesh name.");
336 chartCmd->SetGuidance(" psname :(String) PS name.");
337 chartCmd->SetGuidance(" On/Off :(boolean) On or Off the color chart.");
338 chartCmd->SetGuidance(" scale :(String) default=linear, or log ");
339 param = new G4UIparameter("meshName",'s',false);
340 chartCmd->SetParameter(param);
341 param = new G4UIparameter("psName",'s',false);
342 chartCmd->SetParameter(param);
343 param = new G4UIparameter("On",'s',true);
344 param->SetDefaultValue("true");
345 chartCmd->SetParameter(param);
346 param = new G4UIparameter("scale",'s',true);
347 param->SetDefaultValue("linear");
348 chartCmd->SetParameter(param);
349 */
350
351 // Dump a scored quantity
352 dumpQtyToFileCmd = new G4UIcommand("/score/dumpQuantityToFile", this);
353 dumpQtyToFileCmd->SetGuidance("Dump one scored quantity to file.");
354 param = new G4UIparameter("meshName", 's', false);
356 param = new G4UIparameter("psName", 's', false);
358 param = new G4UIparameter("fileName", 's', false);
360 param = new G4UIparameter("option", 's', true);
363
364 dumpQtyWithFactorCmd = new G4UIcommand("/score/dumpQuantityWithFactor", this);
365 dumpQtyWithFactorCmd->SetGuidance("Dump one scored quantity to file.");
367 "Each value is multiplied by the specified factor.");
368 param = new G4UIparameter("meshName", 's', false);
370 param = new G4UIparameter("psName", 's', false);
372 param = new G4UIparameter("fileName", 's', false);
374 param = new G4UIparameter("factor", 'd', false);
375 param->SetParameterRange("factor>0.");
377 param = new G4UIparameter("option", 's', true);
380
381 // Dump all scored quantities
382 dumpAllQtsToFileCmd = new G4UIcommand("/score/dumpAllQuantitiesToFile", this);
383 dumpAllQtsToFileCmd->SetGuidance("Dump all quantities of the mesh to file.");
384 param = new G4UIparameter("meshName", 's', false);
386 param = new G4UIparameter("fileName", 's', false);
388 param = new G4UIparameter("option", 's', true);
391
393 new G4UIcommand("/score/dumpAllQuantitiesWithFactor", this);
395 "Dump all quantities of the mesh to file.");
397 "Each value is multiplied by the specified factor.");
398 param = new G4UIparameter("meshName", 's', false);
400 param = new G4UIparameter("fileName", 's', false);
402 param = new G4UIparameter("factor", 'd', false);
403 param->SetParameterRange("factor>0.");
405 param = new G4UIparameter("option", 's', true);
408
409 fill1DCmd = new G4UIcommand("/score/fill1D", this);
410 fill1DCmd->SetGuidance("Let a primitive scorer fill 1-D histogram");
411 fill1DCmd->SetGuidance("Before using this command, primitive scorer must be "
412 "defined and assigned.");
413 fill1DCmd->SetGuidance("Also before using this command, a histogram has to "
414 "be defined by /analysis/h1/create command.");
416 "This command is available only for real-world volume or probe.");
417 fill1DCmd->SetGuidance("Please note that this command has to be applied to "
418 "each copy number of the scoring volume.");
419 fill1DCmd->SetGuidance("If same histogram ID is used more than once, more "
420 "than one scorers fill that histogram.");
421 param = new G4UIparameter("histID", 'i', false);
422 fill1DCmd->SetParameter(param);
423 param = new G4UIparameter("meshName", 's', false);
424 fill1DCmd->SetParameter(param);
425 param = new G4UIparameter("scorerName", 's', false);
426 fill1DCmd->SetParameter(param);
427 param = new G4UIparameter("copyNo", 'i', true);
428 param->SetDefaultValue(0);
429 fill1DCmd->SetParameter(param);
430}
431
433{
434 delete listCmd;
435 delete verboseCmd;
436 //
437 delete meshBoxCreateCmd;
440 delete probeCreateCmd;
441 delete meshCreateDir;
442 // delete meshSphereCreateCmd;
443 //
444 delete meshOpnCmd;
445 //
446 delete meshClsCmd;
447 // delete meshActCmd;
448 delete meshDir;
449 //
450 delete mBoxSizeCmd;
451 delete mCylinderSizeCmd;
452 delete mCylinderRMinCmd;
453 delete mCylinderAngleCmd;
454 // delete mSphereSizeCmd;
455 //
456 delete mBinCmd;
457 //
458 delete mTResetCmd;
459 delete mTXyzCmd;
460 delete mTransDir;
461 // delete mRResetCmd;
462 delete mRotXCmd;
463 delete mRotYCmd;
464 delete mRotZCmd;
465 delete mRotDir;
466 //
467 delete probeLocateCmd;
468 delete probeMatCmd;
469 delete probeDir;
470 //
471 // delete chartCmd;
472 delete dumpCmd;
473 delete drawCmd;
474 delete drawColumnCmd;
475 delete listColorMapCmd;
476 delete floatMinMaxCmd;
477 delete colorMapMinMaxCmd;
478 delete colorMapDir;
479 delete dumpQtyToFileCmd;
481 delete dumpAllQtsToFileCmd;
483 delete fill1DCmd;
484 //
485 delete scoreDir;
486}
487
489{
490 using MeshShape = G4VScoringMesh::MeshShape;
491
492 if(command == listCmd)
493 {
494 fSMan->List();
495 }
496 else if(command == dumpCmd)
497 {
498 fSMan->Dump();
499 }
500 else if(command == drawCmd)
501 {
502 G4Tokenizer next(newVal);
503 G4String meshName = next();
504 G4String psName = next();
505 G4String colorMapName = next();
506 G4int axflg = StoI(next());
507 fSMan->DrawMesh(meshName, psName, colorMapName, axflg);
508 }
509 else if(command == drawColumnCmd)
510 {
511 G4Tokenizer next(newVal);
512 G4String meshName = next();
513 G4String psName = next();
514 G4int iPlane = StoI(next());
515 G4int iColumn = StoI(next());
516 G4String colorMapName = next();
517 fSMan->DrawMesh(meshName, psName, iPlane, iColumn, colorMapName);
518 // } else if(command==chartCmd ){
519 // G4Tokenizer next(newVal);
520 // G4String meshName = next();
521 // G4String psName = next();
522 // //G4bool onFlag = StoB(next());
523 // G4String scaleOption = next();
524 // fSMan->DrawChart(meshName,psName,onFlag,scaleOption);
525 }
526 else if(command == dumpQtyToFileCmd)
527 {
528 G4Tokenizer next(newVal);
529 G4String meshName = next();
530 G4String psName = next();
531 G4String fileName = next();
532 G4String option = next("\n");
533 auto mesh = fSMan->FindMesh(meshName);
534 if(!mesh)
535 {
537 ed << "Mesh name <" << meshName << "> is not found. Command ignored.";
538 command->CommandFailed(ed);
539 return;
540 }
541 fSMan->DumpQuantityToFile(meshName, psName, fileName, option);
542 }
543 else if(command == dumpQtyWithFactorCmd)
544 {
545 G4Tokenizer next(newVal);
546 G4String meshName = next();
547 G4String psName = next();
548 G4String fileName = next();
549 G4double fac = StoD(next());
550 G4String option = next("\n");
551 auto mesh = fSMan->FindMesh(meshName);
552 if(!mesh)
553 {
555 ed << "Mesh name <" << meshName << "> is not found. Command ignored.";
556 command->CommandFailed(ed);
557 return;
558 }
560 fSMan->DumpQuantityToFile(meshName, psName, fileName, option);
561 fSMan->SetFactor(1.0);
562 }
563 else if(command == dumpAllQtsToFileCmd)
564 {
565 G4Tokenizer next(newVal);
566 G4String meshName = next();
567 G4String fileName = next();
568 G4String option = next("\n");
569 auto mesh = fSMan->FindMesh(meshName);
570 if(!mesh)
571 {
573 ed << "Mesh name <" << meshName << "> is not found. Command ignored.";
574 command->CommandFailed(ed);
575 return;
576 }
577 fSMan->DumpAllQuantitiesToFile(meshName, fileName, option);
578 }
579 else if(command == dumpAllQtsWithFactorCmd)
580 {
581 G4Tokenizer next(newVal);
582 G4String meshName = next();
583 G4String fileName = next();
584 G4double fac = StoD(next());
585 G4String option = next("\n");
586 auto mesh = fSMan->FindMesh(meshName);
587 if(!mesh)
588 {
590 ed << "Mesh name <" << meshName << "> is not found. Command ignored.";
591 command->CommandFailed(ed);
592 return;
593 }
595 fSMan->DumpAllQuantitiesToFile(meshName, fileName, option);
596 fSMan->SetFactor(1.0);
597 }
598 else if(command == fill1DCmd)
599 {
600 Fill1D(command, newVal);
601 }
602 else if(command == verboseCmd)
603 {
605 }
606 else if(command == meshBoxCreateCmd)
607 {
608 G4VScoringMesh* currentmesh = fSMan->GetCurrentMesh();
609 if(currentmesh)
610 {
612 ed << "ERROR[" << meshBoxCreateCmd->GetCommandPath() << "] : Mesh <"
613 << currentmesh->GetWorldName()
614 << "> is still open. Close it first. Command ignored.";
615 command->CommandFailed(ed);
616 }
617 else
618 {
619 G4VScoringMesh* mesh = fSMan->FindMesh(newVal);
620 if(!mesh)
621 {
622 mesh = new G4ScoringBox(newVal);
624 }
625 else
626 {
628 ed << "ERROR[" << meshBoxCreateCmd->GetCommandPath()
629 << "] : Scoring mesh <" << newVal
630 << "> already exists. Command ignored.";
631 command->CommandFailed(ed);
632 }
633 }
634 }
635 else if(command == meshCylinderCreateCmd)
636 {
637 G4VScoringMesh* currentmesh = fSMan->GetCurrentMesh();
638 if(currentmesh)
639 {
641 ed << "ERROR[" << meshCylinderCreateCmd->GetCommandPath() << "] : Mesh <"
642 << currentmesh->GetWorldName()
643 << "> is still open. Close it first. Command ignored.";
644 command->CommandFailed(ed);
645 }
646 else
647 {
648 G4VScoringMesh* mesh = fSMan->FindMesh(newVal);
649 if(!mesh)
650 {
651 mesh = new G4ScoringCylinder(newVal);
653 }
654 else
655 {
657 ed << "ERROR[" << meshCylinderCreateCmd->GetCommandPath()
658 << "] : Scoring mesh <" << newVal
659 << "> already exists. Command ignored.";
660 command->CommandFailed(ed);
661 }
662 }
663 }
664 else if(command == meshRWLogVolCreateCmd)
665 {
666 auto mesh = fSMan->GetCurrentMesh();
667 if(mesh)
668 {
670 ed << "ERROR[" << meshRWLogVolCreateCmd->GetCommandPath() << "] : Mesh <"
671 << mesh->GetWorldName()
672 << "> is still open. Close it first. Command ignored.";
673 command->CommandFailed(ed);
674 }
675 else
676 {
677 G4Tokenizer next(newVal);
678 G4String meshName = next();
679 G4int idx = StoI(next());
680 mesh = fSMan->FindMesh(meshName);
681 if(!mesh)
682 {
683 mesh = new G4ScoringRealWorld(meshName);
684 mesh->SetCopyNumberLevel(idx);
686 }
687 else
688 {
690 ed << "ERROR[" << meshRWLogVolCreateCmd->GetCommandPath()
691 << "] : Scoring mesh <" << meshName
692 << "> already exists. Command ignored.";
693 command->CommandFailed(ed);
694 }
695 }
696 }
697 else if(command == probeCreateCmd)
698 {
699 auto mesh = fSMan->GetCurrentMesh();
700 if(mesh)
701 {
703 ed << "ERROR[" << meshRWLogVolCreateCmd->GetCommandPath() << "] : Mesh <"
704 << mesh->GetWorldName()
705 << "> is still open. Close it first. Command ignored.";
706 command->CommandFailed(ed);
707 }
708 else
709 {
710 G4Tokenizer next(newVal);
711 G4String qname = next();
712 G4double halfSize = StoD(next());
713 halfSize *= G4UIcommand::ValueOf(next());
714 G4bool checkOverlap = StoB(next());
715 mesh = fSMan->FindMesh(qname);
716 if(!mesh)
717 {
718 mesh = new G4ScoringProbe(qname, halfSize, checkOverlap);
720 }
721 else
722 {
724 ed << "ERROR[" << probeCreateCmd->GetCommandPath() << "] : Mesh name <"
725 << qname << "> already exists. Use another name.";
726 command->CommandFailed(ed);
727 }
728 }
729 }
730 else if(command == probeMatCmd || command == probeLocateCmd)
731 {
732 auto mesh = fSMan->GetCurrentMesh();
733 if(!mesh)
734 {
736 ed << "ERROR : No mesh is currently open. Open/create a mesh first. "
737 "Command ignored.";
738 command->CommandFailed(ed);
739 return;
740 }
741 if(mesh->GetShape() != MeshShape::probe)
742 {
744 ed << "ERROR : Inconsistent mesh type. Close current mesh and open "
745 "Scoring Probe.";
746 command->CommandFailed(ed);
747 return;
748 }
749
750 if(command == probeMatCmd)
751 {
752 G4bool succ = static_cast<G4ScoringProbe*>(mesh)->SetMaterial(newVal);
753 if(!succ)
754 {
756 ed << "Material <" << newVal
757 << "> is not defind in G4NistManager. Command is ignored.\n"
758 << "Use /material/nist/listMaterials command to see the available "
759 "materials.";
760 command->CommandFailed(ed);
761 return;
762 }
763 }
764 else if(command == probeLocateCmd)
765 {
767 static_cast<G4ScoringProbe*>(mesh)->LocateProbe(loc);
768 }
769 }
770 else if(command == listColorMapCmd)
771 {
773 }
774 else if(command == floatMinMaxCmd)
775 {
776 G4VScoreColorMap* colorMap = fSMan->GetScoreColorMap(newVal);
777 if(colorMap)
778 {
779 colorMap->SetFloatingMinMax(true);
780 }
781 else
782 {
784 ed << "ERROR[" << floatMinMaxCmd->GetCommandPath() << "] : color map <"
785 << newVal << "> is not defined. Command ignored.";
786 command->CommandFailed(ed);
787 }
788 }
789 else if(command == colorMapMinMaxCmd)
790 {
791 G4Tokenizer next(newVal);
792 G4String mapName = next();
793 G4double minVal = StoD(next());
794 G4double maxVal = StoD(next());
795 G4VScoreColorMap* colorMap = fSMan->GetScoreColorMap(mapName);
796 if(colorMap)
797 {
798 colorMap->SetFloatingMinMax(false);
799 colorMap->SetMinMax(minVal, maxVal);
800 }
801 else
802 {
804 ed << "ERROR[" << colorMapMinMaxCmd->GetCommandPath() << "] : color map <"
805 << newVal << "> is not defined. Command ignored." << G4endl;
806 command->CommandFailed(ed);
807 }
808 }
809 else if(command == meshOpnCmd)
810 {
811 G4VScoringMesh* currentmesh = fSMan->GetCurrentMesh();
812 if(currentmesh)
813 {
815 ed << "ERROR[" << meshOpnCmd->GetCommandPath() << "] : Mesh <"
816 << currentmesh->GetWorldName()
817 << "> is still open. Close it first. Command ignored.";
818 command->CommandFailed(ed);
819 }
820 else
821 {
822 G4VScoringMesh* mesh = fSMan->FindMesh(newVal);
823 if(!mesh)
824 {
826 ed << "ERROR[" << meshOpnCmd->GetCommandPath() << "] : Scoring mesh <"
827 << newVal << "> does not exist. Command ignored.";
828 command->CommandFailed(ed);
829 }
830 else
831 {
832 fSMan->SetCurrentMesh(mesh);
833 }
834 }
835 }
836 else if(command == meshClsCmd)
837 {
839 }
840 else
841 {
842 //
843 // Get Current Mesh
844 //
846 //
847 // Commands for Current Mesh
848 if(mesh)
849 {
850 MeshShape shape = mesh->GetShape();
851 if(shape == MeshShape::realWorldLogVol)
852 {
854 ed << "ERROR[" << mBinCmd->GetCommandPath()
855 << "] : Number of mesh command cannot be set for this type of mesh. "
856 "Command ignored.";
857 command->CommandFailed(ed);
858 }
859 else
860 {
861 // Tokens
862 G4TokenVec token;
863 FillTokenVec(newVal, token);
864 //
865 // Mesh Geometry
866 //
867 // if(command==meshActCmd) {
868 // mesh->Activate(meshActCmd->GetNewBoolValue(newVal));
869 // } else
870 if(command == mBoxSizeCmd)
871 {
872 if(shape == MeshShape::box)
873 {
875 G4double vsize[3];
876 vsize[0] = size.x();
877 vsize[1] = size.y();
878 vsize[2] = size.z();
879 mesh->SetSize(vsize);
880 }
881 else
882 {
884 ed << "ERROR[" << mBoxSizeCmd->GetCommandPath()
885 << "] : This mesh is not Box. Command ignored.";
886 command->CommandFailed(ed);
887 }
888 }
889 else if(command == mCylinderSizeCmd || command == mCylinderRMinCmd ||
890 command == mCylinderAngleCmd)
891 {
892 if(shape != MeshShape::cylinder)
893 {
895 ed << "ERROR[" << command->GetCommandPath()
896 << "] : This mesh is not Cylinder. Command ignored.";
897 command->CommandFailed(ed);
898 }
899 else
900 {
901 if(command == mCylinderSizeCmd)
902 {
903 G4double vsize[3];
904 vsize[0] = (mesh->GetSize()).x();
905 vsize[1] = StoD(token[0]);
906 vsize[2] = StoD(token[1]);
907 G4double unt = mCylinderSizeCmd->ValueOf(token[2]);
908 vsize[1] *= unt;
909 vsize[2] *= unt;
910 mesh->SetSize(vsize);
911 }
912 else if(command == mCylinderRMinCmd)
913 {
914 G4double vsize[3];
915 vsize[0] = mCylinderRMinCmd->GetNewDoubleValue(newVal);
916 vsize[1] = (mesh->GetSize()).y();
917 vsize[2] = (mesh->GetSize()).z();
918 mesh->SetSize(vsize);
919 }
920 else if(command == mCylinderAngleCmd)
921 {
922 G4double stphi = StoD(token[0]);
923 G4double spphi = StoD(token[1]);
924 G4double unt = mCylinderAngleCmd->ValueOf(token[2]);
925 mesh->SetAngles(stphi * unt, spphi * unt);
926 }
927 }
928 }
929 else if(command == mBinCmd)
930 {
931 MeshBinCommand(mesh, token);
932 }
933 else if(command == mTResetCmd)
934 {
935 G4double centerPosition[3] = { 0., 0., 0. };
936 mesh->SetCenterPosition(centerPosition);
937 }
938 else if(command == mTXyzCmd)
939 {
941 G4double centerPosition[3];
942 centerPosition[0] = xyz.x();
943 centerPosition[1] = xyz.y();
944 centerPosition[2] = xyz.z();
945 mesh->SetCenterPosition(centerPosition);
946 // } else if(command==mRResetCmd) {
947 }
948 else if(command == mRotXCmd)
949 {
950 G4double value = mRotXCmd->GetNewDoubleValue(newVal);
951 mesh->RotateX(value);
952 }
953 else if(command == mRotYCmd)
954 {
955 G4double value = mRotYCmd->GetNewDoubleValue(newVal);
956 mesh->RotateY(value);
957 }
958 else if(command == mRotZCmd)
959 {
960 G4double value = mRotZCmd->GetNewDoubleValue(newVal);
961 mesh->RotateZ(value);
962 }
963 }
964 }
965 else
966 {
968 ed << "ERROR: No mesh is currently open. Open/create a mesh first. "
969 "Command ignored.";
970 command->CommandFailed(ed);
971 }
972 }
973}
974
976{
977 G4String val;
978 if(command == verboseCmd)
979 {
981 }
982
983 return val;
984}
985
987{
988 G4Tokenizer next(newValues);
989 G4String val;
990 while(!(val = next()).empty())
991 { // Loop checking 12.18.2015 M.Asai
992 token.push_back(val);
993 }
994}
995
997{
998 G4int Ni = StoI(token[0]);
999 G4int Nj = StoI(token[1]);
1000 G4int Nk = StoI(token[2]);
1001 G4int nSegment[3];
1002
1003 if(dynamic_cast<G4ScoringBox*>(mesh))
1004 {
1005 G4cout << ".... G4ScoringMessenger::MeshBinCommand - G4ScoringBox"
1006 << G4endl;
1007 nSegment[0] = Ni;
1008 nSegment[1] = Nj;
1009 nSegment[2] = Nk;
1010 }
1011 else if(dynamic_cast<G4ScoringCylinder*>(mesh))
1012 {
1013 G4cout << ".... G4ScoringMessenger::MeshBinCommand - G4ScoringCylinder"
1014 << G4endl;
1015 nSegment[0] = Nj;
1016 nSegment[1] = Nk;
1017 nSegment[2] = Ni;
1018 }
1019 else
1020 {
1021 G4Exception("G4ScoringMessenger::MeshBinCommand()", "001", FatalException,
1022 "invalid mesh type");
1023 return;
1024 }
1025 //
1026 mesh->SetNumberOfSegments(nSegment);
1027}
1028
1029#include "G4VPrimitivePlotter.hh"
1030#include "G4VScoreHistFiller.hh"
1031
1033{
1034 using MeshShape = G4VScoringMesh::MeshShape;
1035
1036 G4Tokenizer next(newVal);
1037 G4int histID = StoI(next());
1038 G4String meshName = next();
1039 G4String primName = next();
1040 G4int copyNo = StoI(next());
1041
1042 auto filler = G4VScoreHistFiller::Instance();
1043 if(!filler)
1044 {
1046 ed << "G4TScoreHistFiller is not instantiated in this application.";
1047 cmd->CommandFailed(ed);
1048 return;
1049 }
1050 //
1051 // To do : check the validity of histID
1052 //
1053
1055 auto mesh = sm->FindMesh(meshName);
1056 if(mesh == nullptr)
1057 {
1059 ed << "Mesh name <" << meshName << "> is not found.";
1060 cmd->CommandFailed(ed);
1061 return;
1062 }
1063 auto shape = mesh->GetShape();
1064 if(shape != MeshShape::realWorldLogVol && shape != MeshShape::probe)
1065 {
1067 ed << "Mesh <" << meshName
1068 << "> is not real-world logical volume or probe.";
1069 cmd->CommandFailed(ed);
1070 return;
1071 }
1072
1073 auto prim = mesh->GetPrimitiveScorer(primName);
1074 if(prim == nullptr)
1075 {
1077 ed << "Primitive scorer name <" << primName << "> is not found.";
1078 cmd->CommandFailed(ed);
1079 return;
1080 }
1081 auto pp = dynamic_cast<G4VPrimitivePlotter*>(prim);
1082 if(pp == nullptr)
1083 {
1085 ed << "Primitive scorer <" << primName
1086 << "> does not support direct histogram filling.";
1087 cmd->CommandFailed(ed);
1088 return;
1089 }
1090
1091 pp->Plot(copyNo, histID);
1092}
@ 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
static const G4double fac
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="")
G4UIcmdWith3VectorAndUnit * mBoxSizeCmd
G4UIcmdWith3VectorAndUnit * probeLocateCmd
G4UIcommand * mCylinderAngleCmd
G4UIcommand * dumpQtyToFileCmd
G4UIcmdWithoutParameter * dumpCmd
G4UIcmdWithADoubleAndUnit * mRotXCmd
G4ScoringManager * fSMan
G4UIcmdWithAString * meshBoxCreateCmd
G4UIdirectory * colorMapDir
void FillTokenVec(G4String newValues, G4TokenVec &token)
G4UIdirectory * meshDir
G4UIcmdWithoutParameter * mTResetCmd
G4UIdirectory * scoreDir
void MeshBinCommand(G4VScoringMesh *mesh, G4TokenVec &token)
G4ScoringMessenger(G4ScoringManager *SManager)
G4UIcmdWithAnInteger * verboseCmd
G4UIdirectory * mTransDir
G4UIcommand * probeCreateCmd
G4UIcommand * dumpAllQtsToFileCmd
G4UIcommand * drawColumnCmd
G4UIcmdWith3VectorAndUnit * mTXyzCmd
G4UIcmdWithADoubleAndUnit * mRotYCmd
G4UIcommand * mCylinderSizeCmd
void Fill1D(G4UIcommand *cmd, G4String newValues)
G4UIcmdWithAString * meshOpnCmd
G4UIcmdWithoutParameter * meshClsCmd
G4UIcmdWithADoubleAndUnit * mCylinderRMinCmd
G4String GetCurrentValue(G4UIcommand *command)
G4UIcommand * dumpAllQtsWithFactorCmd
G4UIcmdWithAString * probeMatCmd
G4UIdirectory * mRotDir
G4UIcommand * dumpQtyWithFactorCmd
G4UIcommand * colorMapMinMaxCmd
G4UIdirectory * probeDir
G4UIcmdWithAString * meshCylinderCreateCmd
G4UIdirectory * meshCreateDir
G4UIcmdWithoutParameter * listCmd
G4UIcmdWithADoubleAndUnit * mRotZCmd
G4UIcommand * meshRWLogVolCreateCmd
G4UIcmdWithoutParameter * listColorMapCmd
G4UIcmdWithAString * floatMinMaxCmd
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:363
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:445
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()
G4ThreeVector GetSize() const
MeshShape GetShape() const
void RotateY(G4double delta)
void SetAngles(G4double, G4double)
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)
def SetMaterial(material_name)
Definition: EmPlot.py:25