Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ScoringMessenger Class Reference

#include <G4ScoringMessenger.hh>

+ Inheritance diagram for G4ScoringMessenger:

Public Member Functions

 G4ScoringMessenger (G4ScoringManager *SManager)
 
 ~G4ScoringMessenger () override
 
void SetNewValue (G4UIcommand *command, G4String newValues) override
 
G4String GetCurrentValue (G4UIcommand *command) override
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
G4bool CommandsShouldBeInMaster () const
 

Protected Member Functions

void FillTokenVec (G4String newValues, G4TokenVec &token)
 
void MeshBinCommand (G4VScoringMesh *mesh, G4TokenVec &token)
 
void Fill1D (G4UIcommand *cmd, G4String newValues)
 
- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String LtoS (G4long l)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const G4String &s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 

Additional Inherited Members

- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Detailed Description

Definition at line 61 of file G4ScoringMessenger.hh.

Constructor & Destructor Documentation

◆ G4ScoringMessenger()

G4ScoringMessenger::G4ScoringMessenger ( G4ScoringManager * SManager)

Definition at line 50 of file G4ScoringMessenger.cc.

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 =
78 new G4UIcmdWithAString("/score/create/cylinderMesh", this);
79 meshCylinderCreateCmd->SetGuidance("Create scoring mesh.");
80 meshCylinderCreateCmd->SetParameterName("MeshName", false);
81
82 meshRWLogVolCreateCmd =
83 new G4UIcommand("/score/create/realWorldLogVol", this);
84 meshRWLogVolCreateCmd->SetGuidance(
85 "Define scorers to a logical volume defined in the real world.");
86 meshRWLogVolCreateCmd->SetGuidance(
87 " - Name of the specified logical volume is used as the mesh name.");
88 meshRWLogVolCreateCmd->SetGuidance(
89 " - /score/mesh commands do not affect for this mesh.");
90 meshRWLogVolCreateCmd->SetGuidance(
91 " - If copyNumberLevel is set, the copy number of that-level higher");
92 meshRWLogVolCreateCmd->SetGuidance(
93 " in the geometrical hierarchy is used as the index.");
94 param = new G4UIparameter("logVol", 's', false);
95 meshRWLogVolCreateCmd->SetParameter(param);
96 param = new G4UIparameter("copyNumberLevel", 'i', true);
97 param->SetParameterRange("copyNumberLevel>=0");
98 param->SetDefaultValue(0);
99 meshRWLogVolCreateCmd->SetParameter(param);
100 //
101 probeCreateCmd = new G4UIcommand("/score/create/probe", this);
102 probeCreateCmd->SetGuidance("Define scoring probe.");
103 probeCreateCmd->SetGuidance(
104 " halfSize defines the half-width of the probing cube.");
105 param = new G4UIparameter("pname", 's', false);
106 probeCreateCmd->SetParameter(param);
107 param = new G4UIparameter("halfSize", 'd', false);
108 probeCreateCmd->SetParameter(param);
109 param = new G4UIparameter("unit", 's', true);
110 param->SetDefaultUnit("mm");
111 probeCreateCmd->SetParameter(param);
112 param = new G4UIparameter("checkOverlap", 'b', true);
113 param->SetDefaultValue(0);
114 probeCreateCmd->SetParameter(param);
115 //
116 meshOpnCmd = new G4UIcmdWithAString("/score/open", this);
117 meshOpnCmd->SetGuidance("Open scoring mesh.");
118 meshOpnCmd->SetParameterName("MeshName", false);
119 //
120 meshClsCmd = new G4UIcmdWithoutParameter("/score/close", this);
121 meshClsCmd->SetGuidance("Close scoring mesh.");
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 mCylinderRMinCmd =
147 new G4UIcmdWithADoubleAndUnit("/score/mesh/cylinderRMin", this);
148 mCylinderRMinCmd->SetGuidance("Define the inner radius of the tube mesh.");
149 mCylinderRMinCmd->SetGuidance("This command is not needed for cylinder mesh");
150 mCylinderRMinCmd->SetParameterName("RMin", false, false);
151 mCylinderRMinCmd->SetRange("RMin>=0.");
152 mCylinderRMinCmd->SetDefaultUnit("mm");
153 //
154 mCylinderAngleCmd = new G4UIcommand("/score/mesh/cylinderAngles", this);
155 mCylinderAngleCmd->SetGuidance(
156 "Define starting angle and span for tube segment mesh.");
157 mCylinderAngleCmd->SetGuidance(
158 "This command is not needed for cylinder mesh");
159 param = new G4UIparameter("startPhi", 'd', false);
160 mCylinderAngleCmd->SetParameter(param);
161 param = new G4UIparameter("deltaPhi", 'd', false);
162 param->SetParameterRange("deltaPhi>0.");
163 mCylinderAngleCmd->SetParameter(param);
164 param = new G4UIparameter("unit", 's', true);
165 param->SetDefaultUnit("deg");
166 mCylinderAngleCmd->SetParameter(param);
167 //
168 // Division command
169 mBinCmd = new G4UIcommand("/score/mesh/nBin", this);
170 mBinCmd->SetGuidance("Define segments of the scoring mesh.");
171 mBinCmd->SetGuidance("[usage] /score/mesh/nBin");
172 mBinCmd->SetGuidance(" In case of boxMesh, parameters are given in");
173 mBinCmd->SetGuidance(" Ni :(int) Number of bins i (in x-axis) ");
174 mBinCmd->SetGuidance(" Nj :(int) Number of bins j (in y-axis) ");
175 mBinCmd->SetGuidance(" Nk :(int) Number of bins k (in z-axis) ");
176 mBinCmd->SetGuidance(" In case of cylinderMesh, parameters are given in");
177 mBinCmd->SetGuidance(" Nr :(int) Number of bins in radial axis ");
178 mBinCmd->SetGuidance(" Nz :(int) Number of bins in z axis ");
179 mBinCmd->SetGuidance(" Nphi:(int) Number of bins in phi axis ");
180
181 param = new G4UIparameter("Ni", 'i', false);
182 param->SetDefaultValue("1");
183 param->SetParameterRange("Ni>0");
184 mBinCmd->SetParameter(param);
185 param = new G4UIparameter("Nj", 'i', false);
186 param->SetDefaultValue("1");
187 param->SetParameterRange("Nj>0");
188 mBinCmd->SetParameter(param);
189 param = new G4UIparameter("Nk", 'i', false);
190 param->SetDefaultValue("1");
191 mBinCmd->SetParameter(param);
192 param->SetParameterRange("Nk>0");
193
194 // Placement command
195 mTransDir = new G4UIdirectory("/score/mesh/translate/");
196 mTransDir->SetGuidance("Mesh translation commands.");
197 //
198 mTResetCmd = new G4UIcmdWithoutParameter("/score/mesh/translate/reset", this);
199 mTResetCmd->SetGuidance("Reset translated position of the scoring mesh.");
200 //
201 mTXyzCmd = new G4UIcmdWith3VectorAndUnit("/score/mesh/translate/xyz", this);
202 mTXyzCmd->SetGuidance("Translate the scoring mesh.");
203 mTXyzCmd->SetParameterName("X", "Y", "Z", false, false);
204 mTXyzCmd->SetDefaultUnit("mm");
205 //
206 mRotDir = new G4UIdirectory("/score/mesh/rotate/");
207 mRotDir->SetGuidance("Mesh rotation commands.");
208
209 mRotXCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateX", this);
210 mRotXCmd->SetGuidance("Rotate the scoring mesh in X axis.");
211 mRotXCmd->SetParameterName("Rx", false);
212 mRotXCmd->SetDefaultUnit("deg");
213 //
214 mRotYCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateY", this);
215 mRotYCmd->SetGuidance("Rotate the scoring mesh in Y axis.");
216 mRotYCmd->SetParameterName("Ry", false);
217 mRotYCmd->SetDefaultUnit("deg");
218 //
219 mRotZCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateZ", this);
220 mRotZCmd->SetGuidance("Rotate the scoring mesh in Z axis.");
221 mRotZCmd->SetParameterName("Rz", false);
222 mRotZCmd->SetDefaultUnit("deg");
223 //
224 probeDir = new G4UIdirectory("/score/probe/");
225 probeDir->SetGuidance("Probe commands");
226
227 probeMatCmd = new G4UIcmdWithAString("/score/probe/material", this);
228 probeMatCmd->SetGuidance("Specify a material to the probe cube.");
229 probeMatCmd->SetGuidance("Material name has to be taken from G4NistManager.");
230 probeMatCmd->SetGuidance("Once this command is used, the specified material "
231 "overlays the material in the mass geometry");
232 probeMatCmd->SetGuidance("with \"Layered Mass Geometry\" mechanism so that "
233 "physics quantities such as energy deposition");
234 probeMatCmd->SetGuidance("or dose will be calculated with this material.");
235 probeMatCmd->SetGuidance("To switch-off this overlaying, use \"none\".");
236 probeMatCmd->SetParameterName("matName", true);
237 probeMatCmd->SetDefaultValue("none");
238
239 probeLocateCmd = new G4UIcmdWith3VectorAndUnit("/score/probe/locate", this);
240 probeLocateCmd->SetGuidance(
241 "Locate a probe in the global coordinate system.");
242 probeLocateCmd->SetParameterName("x", "y", "z", false);
243 probeLocateCmd->SetDefaultUnit("mm");
244
245 // Draw Scoring result
246 drawCmd = new G4UIcommand("/score/drawProjection", this);
247 drawCmd->SetGuidance("Draw projection(s) of scored quantities.");
248 drawCmd->SetGuidance(
249 "Parameter <proj> specified which projection(s) to be drawn.");
250 drawCmd->SetGuidance(
251 " 100 : xy-plane, 010 : yz-plane, 001 : zx-plane -- default 111");
252 drawCmd->SetGuidance(
253 " 100 : N/A, 010 : z_phi-plane, 001 : r_phi-plane -- default 111");
254 param = new G4UIparameter("meshName", 's', false);
255 drawCmd->SetParameter(param);
256 param = new G4UIparameter("psName", 's', false);
257 drawCmd->SetParameter(param);
258 param = new G4UIparameter("colorMapName", 's', true);
259 param->SetDefaultValue("defaultLinearColorMap");
260 drawCmd->SetParameter(param);
261 param = new G4UIparameter("proj", 'i', true);
262 param->SetDefaultValue(111);
263 drawCmd->SetParameter(param);
264 drawCmd->SetToBeBroadcasted(false);
265
266 // Draw column
267 drawColumnCmd = new G4UIcommand("/score/drawColumn", this);
268 drawColumnCmd->SetGuidance("Draw a cell column.");
269 drawColumnCmd->SetGuidance(" plane = 0 : x-y, 1: y-z, 2: z-x for box mesh");
270 drawColumnCmd->SetGuidance(
271 " 0 : z-phi, 1: r-phi, 2: r-z for cylinder mesh");
272 param = new G4UIparameter("meshName", 's', false);
273 drawColumnCmd->SetParameter(param);
274 param = new G4UIparameter("psName", 's', false);
275 drawColumnCmd->SetParameter(param);
276 param = new G4UIparameter("plane", 'i', false);
277 param->SetParameterRange("plane>=0 && plane<=2");
278 drawColumnCmd->SetParameter(param);
279 param = new G4UIparameter("column", 'i', false);
280 drawColumnCmd->SetParameter(param);
281 param = new G4UIparameter("colorMapName", 's', true);
282 param->SetDefaultValue("defaultLinearColorMap");
283 drawColumnCmd->SetParameter(param);
284 drawColumnCmd->SetToBeBroadcasted(false);
285
286 colorMapDir = new G4UIdirectory("/score/colorMap/");
287 colorMapDir->SetGuidance("Color map commands.");
288
289 listColorMapCmd =
290 new G4UIcmdWithoutParameter("/score/colorMap/listScoreColorMaps", this);
291 listColorMapCmd->SetGuidance("List registered score color maps.");
292 listColorMapCmd->SetToBeBroadcasted(false);
293
294 floatMinMaxCmd = new G4UIcmdWithAString("/score/colorMap/floatMinMax", this);
295 floatMinMaxCmd->SetGuidance(
296 "Min/Max of the color map is calculated according to the actual scores.");
297 floatMinMaxCmd->SetParameterName("colorMapName", true, false);
298 floatMinMaxCmd->SetDefaultValue("defaultLinearColorMap");
299 floatMinMaxCmd->SetToBeBroadcasted(false);
300
301 colorMapMinMaxCmd = new G4UIcommand("/score/colorMap/setMinMax", this);
302 colorMapMinMaxCmd->SetGuidance("Define min/max value of the color map.");
303 param = new G4UIparameter("colorMapMame", 's', true);
304 param->SetDefaultValue("defaultLinearColorMap");
305 colorMapMinMaxCmd->SetParameter(param);
306 param = new G4UIparameter("minValue", 'd', false);
307 colorMapMinMaxCmd->SetParameter(param);
308 param = new G4UIparameter("maxValue", 'd', false);
309 colorMapMinMaxCmd->SetParameter(param);
310 colorMapMinMaxCmd->SetToBeBroadcasted(false);
311
312 // Dump a scored quantity
313 dumpQtyToFileCmd = new G4UIcommand("/score/dumpQuantityToFile", this);
314 dumpQtyToFileCmd->SetGuidance("Dump one scored quantity to file.");
315 param = new G4UIparameter("meshName", 's', false);
316 dumpQtyToFileCmd->SetParameter(param);
317 param = new G4UIparameter("psName", 's', false);
318 dumpQtyToFileCmd->SetParameter(param);
319 param = new G4UIparameter("fileName", 's', false);
320 dumpQtyToFileCmd->SetParameter(param);
321 param = new G4UIparameter("option", 's', true);
322 dumpQtyToFileCmd->SetParameter(param);
323 dumpQtyToFileCmd->SetToBeBroadcasted(false);
324
325 dumpQtyWithFactorCmd = new G4UIcommand("/score/dumpQuantityWithFactor", this);
326 dumpQtyWithFactorCmd->SetGuidance("Dump one scored quantity to file.");
327 dumpQtyWithFactorCmd->SetGuidance(
328 "Each value is multiplied by the specified factor.");
329 param = new G4UIparameter("meshName", 's', false);
330 dumpQtyWithFactorCmd->SetParameter(param);
331 param = new G4UIparameter("psName", 's', false);
332 dumpQtyWithFactorCmd->SetParameter(param);
333 param = new G4UIparameter("fileName", 's', false);
334 dumpQtyWithFactorCmd->SetParameter(param);
335 param = new G4UIparameter("factor", 'd', false);
336 param->SetParameterRange("factor>0.");
337 dumpQtyWithFactorCmd->SetParameter(param);
338 param = new G4UIparameter("option", 's', true);
339 dumpQtyWithFactorCmd->SetParameter(param);
340 dumpQtyWithFactorCmd->SetToBeBroadcasted(false);
341
342 // Dump all scored quantities
343 dumpAllQtsToFileCmd = new G4UIcommand("/score/dumpAllQuantitiesToFile", this);
344 dumpAllQtsToFileCmd->SetGuidance("Dump all quantities of the mesh to file.");
345 param = new G4UIparameter("meshName", 's', false);
346 dumpAllQtsToFileCmd->SetParameter(param);
347 param = new G4UIparameter("fileName", 's', false);
348 dumpAllQtsToFileCmd->SetParameter(param);
349 param = new G4UIparameter("option", 's', true);
350 dumpAllQtsToFileCmd->SetParameter(param);
351 dumpAllQtsToFileCmd->SetToBeBroadcasted(false);
352
353 dumpAllQtsWithFactorCmd =
354 new G4UIcommand("/score/dumpAllQuantitiesWithFactor", this);
355 dumpAllQtsWithFactorCmd->SetGuidance(
356 "Dump all quantities of the mesh to file.");
357 dumpAllQtsWithFactorCmd->SetGuidance(
358 "Each value is multiplied by the specified factor.");
359 param = new G4UIparameter("meshName", 's', false);
360 dumpAllQtsWithFactorCmd->SetParameter(param);
361 param = new G4UIparameter("fileName", 's', false);
362 dumpAllQtsWithFactorCmd->SetParameter(param);
363 param = new G4UIparameter("factor", 'd', false);
364 param->SetParameterRange("factor>0.");
365 dumpAllQtsWithFactorCmd->SetParameter(param);
366 param = new G4UIparameter("option", 's', true);
367 dumpAllQtsWithFactorCmd->SetParameter(param);
368 dumpAllQtsWithFactorCmd->SetToBeBroadcasted(false);
369
370 fill1DCmd = new G4UIcommand("/score/fill1D", this);
371 fill1DCmd->SetGuidance("Let a primitive scorer fill 1-D histogram");
372 fill1DCmd->SetGuidance("Before using this command, primitive scorer must be "
373 "defined and assigned.");
374 fill1DCmd->SetGuidance("Also before using this command, a histogram has to "
375 "be defined by /analysis/h1/create command.");
376 fill1DCmd->SetGuidance(
377 "This command is available only for real-world volume or probe.");
378 fill1DCmd->SetGuidance("Please note that this command has to be applied to "
379 "each copy number of the scoring volume.");
380 fill1DCmd->SetGuidance("If same histogram ID is used more than once, more "
381 "than one scorers fill that histogram.");
382 param = new G4UIparameter("histID", 'i', false);
383 fill1DCmd->SetParameter(param);
384 param = new G4UIparameter("meshName", 's', false);
385 fill1DCmd->SetParameter(param);
386 param = new G4UIparameter("scorerName", 's', false);
387 fill1DCmd->SetParameter(param);
388 param = new G4UIparameter("copyNo", 'i', true);
389 param->SetDefaultValue(0);
390 fill1DCmd->SetParameter(param);
391}
void SetDefaultUnit(const char *defUnit)
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultUnit(const char *defUnit)
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)
void SetToBeBroadcasted(G4bool val)
void SetParameter(G4UIparameter *const newParameter)
void SetGuidance(const char *aGuidance)
void SetRange(const char *rs)
void SetDefaultValue(const char *theDefaultValue)
void SetParameterRange(const char *theRange)
void SetDefaultUnit(const char *theDefaultUnit)

◆ ~G4ScoringMessenger()

G4ScoringMessenger::~G4ScoringMessenger ( )
override

Definition at line 393 of file G4ScoringMessenger.cc.

394{
395 delete listCmd;
396 delete verboseCmd;
397 //
398 delete meshBoxCreateCmd;
399 delete meshCylinderCreateCmd;
400 delete meshRWLogVolCreateCmd;
401 delete probeCreateCmd;
402 delete meshCreateDir;
403 //
404 delete meshOpnCmd;
405 //
406 delete meshClsCmd;
407 delete meshDir;
408 //
409 delete mBoxSizeCmd;
410 delete mCylinderSizeCmd;
411 delete mCylinderRMinCmd;
412 delete mCylinderAngleCmd;
413 //
414 delete mBinCmd;
415 //
416 delete mTResetCmd;
417 delete mTXyzCmd;
418 delete mTransDir;
419 delete mRotXCmd;
420 delete mRotYCmd;
421 delete mRotZCmd;
422 delete mRotDir;
423 //
424 delete probeLocateCmd;
425 delete probeMatCmd;
426 delete probeDir;
427 //
428 delete dumpCmd;
429 delete drawCmd;
430 delete drawColumnCmd;
431 delete listColorMapCmd;
432 delete floatMinMaxCmd;
433 delete colorMapMinMaxCmd;
434 delete colorMapDir;
435 delete dumpQtyToFileCmd;
436 delete dumpQtyWithFactorCmd;
437 delete dumpAllQtsToFileCmd;
438 delete dumpAllQtsWithFactorCmd;
439 delete fill1DCmd;
440 //
441 delete scoreDir;
442}

Member Function Documentation

◆ Fill1D()

void G4ScoringMessenger::Fill1D ( G4UIcommand * cmd,
G4String newValues )
protected

Definition at line 976 of file G4ScoringMessenger.cc.

977{
978 using MeshShape = G4VScoringMesh::MeshShape;
979
980 G4Tokenizer next(newVal);
981 G4int histID = StoI(next());
982 G4String meshName = next();
983 G4String primName = next();
984 G4int copyNo = StoI(next());
985
986 auto filler = G4VScoreHistFiller::Instance();
987 if(filler == nullptr)
988 {
990 ed << "G4TScoreHistFiller is not instantiated in this application.";
991 cmd->CommandFailed(ed);
992 return;
993 }
994 //
995 // To do : check the validity of histID
996 //
997
999 auto mesh = sm->FindMesh(meshName);
1000 if(mesh == nullptr)
1001 {
1003 ed << "Mesh name <" << meshName << "> is not found.";
1004 cmd->CommandFailed(ed);
1005 return;
1006 }
1007 auto shape = mesh->GetShape();
1008 if(shape != MeshShape::realWorldLogVol && shape != MeshShape::probe)
1009 {
1011 ed << "Mesh <" << meshName
1012 << "> is not real-world logical volume or probe.";
1013 cmd->CommandFailed(ed);
1014 return;
1015 }
1016
1017 auto prim = mesh->GetPrimitiveScorer(primName);
1018 if(prim == nullptr)
1019 {
1021 ed << "Primitive scorer name <" << primName << "> is not found.";
1022 cmd->CommandFailed(ed);
1023 return;
1024 }
1025 auto pp = dynamic_cast<G4VPrimitivePlotter*>(prim);
1026 if(pp == nullptr)
1027 {
1029 ed << "Primitive scorer <" << primName
1030 << "> does not support direct histogram filling.";
1031 cmd->CommandFailed(ed);
1032 return;
1033 }
1034
1035 pp->Plot(copyNo, histID);
1036}
std::ostringstream G4ExceptionDescription
int G4int
Definition G4Types.hh:85
static G4ScoringManager * GetScoringManagerIfExist()
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
G4int StoI(const G4String &s)
static G4VScoreHistFiller * Instance()

Referenced by SetNewValue().

◆ FillTokenVec()

void G4ScoringMessenger::FillTokenVec ( G4String newValues,
G4TokenVec & token )
protected

Definition at line 930 of file G4ScoringMessenger.cc.

931{
932 G4Tokenizer next(newValues);
933 G4String val;
934 while(!(val = next()).empty())
935 { // Loop checking 12.18.2015 M.Asai
936 token.push_back(val);
937 }
938}

Referenced by SetNewValue().

◆ GetCurrentValue()

G4String G4ScoringMessenger::GetCurrentValue ( G4UIcommand * command)
overridevirtual

Reimplemented from G4UImessenger.

Definition at line 919 of file G4ScoringMessenger.cc.

920{
921 G4String val;
922 if(command == verboseCmd)
923 {
924 val = verboseCmd->ConvertToString(fSMan->GetVerboseLevel());
925 }
926
927 return val;
928}
G4int GetVerboseLevel() const
static G4String ConvertToString(G4bool boolVal)

◆ MeshBinCommand()

void G4ScoringMessenger::MeshBinCommand ( G4VScoringMesh * mesh,
G4TokenVec & token )
protected

Definition at line 940 of file G4ScoringMessenger.cc.

941{
942 G4int Ni = StoI(token[0]);
943 G4int Nj = StoI(token[1]);
944 G4int Nk = StoI(token[2]);
945 G4int nSegment[3];
946
947 if(dynamic_cast<G4ScoringBox*>(mesh) != nullptr)
948 {
949 G4cout << ".... G4ScoringMessenger::MeshBinCommand - G4ScoringBox"
950 << G4endl;
951 nSegment[0] = Ni;
952 nSegment[1] = Nj;
953 nSegment[2] = Nk;
954 }
955 else if(dynamic_cast<G4ScoringCylinder*>(mesh) != nullptr)
956 {
957 G4cout << ".... G4ScoringMessenger::MeshBinCommand - G4ScoringCylinder"
958 << G4endl;
959 nSegment[0] = Nj;
960 nSegment[1] = Nk;
961 nSegment[2] = Ni;
962 }
963 else
964 {
965 G4Exception("G4ScoringMessenger::MeshBinCommand()", "001", FatalException,
966 "invalid mesh type");
967 return;
968 }
969 //
970 mesh->SetNumberOfSegments(nSegment);
971}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
void SetNumberOfSegments(G4int nSegment[3])

Referenced by SetNewValue().

◆ SetNewValue()

void G4ScoringMessenger::SetNewValue ( G4UIcommand * command,
G4String newValues )
overridevirtual

Reimplemented from G4UImessenger.

Definition at line 444 of file G4ScoringMessenger.cc.

445{
446 using MeshShape = G4VScoringMesh::MeshShape;
447
448 if(command == listCmd)
449 {
450 fSMan->List();
451 }
452 else if(command == dumpCmd)
453 {
454 fSMan->Dump();
455 }
456 else if(command == drawCmd)
457 {
458 G4Tokenizer next(newVal);
459 G4String meshName = next();
460 G4String psName = next();
461 G4String colorMapName = next();
462 G4int axflg = StoI(next());
463 fSMan->DrawMesh(meshName, psName, colorMapName, axflg);
464 }
465 else if(command == drawColumnCmd)
466 {
467 G4Tokenizer next(newVal);
468 G4String meshName = next();
469 G4String psName = next();
470 G4int iPlane = StoI(next());
471 G4int iColumn = StoI(next());
472 G4String colorMapName = next();
473 fSMan->DrawMesh(meshName, psName, iPlane, iColumn, colorMapName);
474 }
475 else if(command == dumpQtyToFileCmd)
476 {
477 G4Tokenizer next(newVal);
478 G4String meshName = next();
479 G4String psName = next();
480 G4String fileName = next();
481 G4String option = next("\n");
482 auto mesh = fSMan->FindMesh(meshName);
483 if(mesh == nullptr)
484 {
486 ed << "Mesh name <" << meshName << "> is not found. Command ignored.";
487 command->CommandFailed(ed);
488 return;
489 }
490 fSMan->DumpQuantityToFile(meshName, psName, fileName, option);
491 }
492 else if(command == dumpQtyWithFactorCmd)
493 {
494 G4Tokenizer next(newVal);
495 G4String meshName = next();
496 G4String psName = next();
497 G4String fileName = next();
498 G4double fac = StoD(next());
499 G4String option = next("\n");
500 auto mesh = fSMan->FindMesh(meshName);
501 if(mesh == nullptr)
502 {
504 ed << "Mesh name <" << meshName << "> is not found. Command ignored.";
505 command->CommandFailed(ed);
506 return;
507 }
508 fSMan->SetFactor(fac);
509 fSMan->DumpQuantityToFile(meshName, psName, fileName, option);
510 fSMan->SetFactor(1.0);
511 }
512 else if(command == dumpAllQtsToFileCmd)
513 {
514 G4Tokenizer next(newVal);
515 G4String meshName = next();
516 G4String fileName = next();
517 G4String option = next("\n");
518 auto mesh = fSMan->FindMesh(meshName);
519 if(mesh == nullptr)
520 {
522 ed << "Mesh name <" << meshName << "> is not found. Command ignored.";
523 command->CommandFailed(ed);
524 return;
525 }
526 fSMan->DumpAllQuantitiesToFile(meshName, fileName, option);
527 }
528 else if(command == dumpAllQtsWithFactorCmd)
529 {
530 G4Tokenizer next(newVal);
531 G4String meshName = next();
532 G4String fileName = next();
533 G4double fac = StoD(next());
534 G4String option = next("\n");
535 auto mesh = fSMan->FindMesh(meshName);
536 if(mesh == nullptr)
537 {
539 ed << "Mesh name <" << meshName << "> is not found. Command ignored.";
540 command->CommandFailed(ed);
541 return;
542 }
543 fSMan->SetFactor(fac);
544 fSMan->DumpAllQuantitiesToFile(meshName, fileName, option);
545 fSMan->SetFactor(1.0);
546 }
547 else if(command == fill1DCmd)
548 {
549 Fill1D(command, newVal);
550 }
551 else if(command == verboseCmd)
552 {
553 fSMan->SetVerboseLevel(verboseCmd->GetNewIntValue(newVal));
554 }
555 else if(command == meshBoxCreateCmd)
556 {
557 G4VScoringMesh* currentmesh = fSMan->GetCurrentMesh();
558 if(currentmesh != nullptr)
559 {
561 ed << "ERROR[" << meshBoxCreateCmd->GetCommandPath() << "] : Mesh <"
562 << currentmesh->GetWorldName()
563 << "> is still open. Close it first. Command ignored.";
564 command->CommandFailed(ed);
565 }
566 else
567 {
568 G4VScoringMesh* mesh = fSMan->FindMesh(newVal);
569 if(mesh == nullptr)
570 {
571 mesh = new G4ScoringBox(newVal);
572 fSMan->RegisterScoringMesh(mesh);
573 }
574 else
575 {
577 ed << "ERROR[" << meshBoxCreateCmd->GetCommandPath()
578 << "] : Scoring mesh <" << newVal
579 << "> already exists. Command ignored.";
580 command->CommandFailed(ed);
581 }
582 }
583 }
584 else if(command == meshCylinderCreateCmd)
585 {
586 G4VScoringMesh* currentmesh = fSMan->GetCurrentMesh();
587 if(currentmesh != nullptr)
588 {
590 ed << "ERROR[" << meshCylinderCreateCmd->GetCommandPath() << "] : Mesh <"
591 << currentmesh->GetWorldName()
592 << "> is still open. Close it first. Command ignored.";
593 command->CommandFailed(ed);
594 }
595 else
596 {
597 G4VScoringMesh* mesh = fSMan->FindMesh(newVal);
598 if(mesh == nullptr)
599 {
600 mesh = new G4ScoringCylinder(newVal);
601 fSMan->RegisterScoringMesh(mesh);
602 }
603 else
604 {
606 ed << "ERROR[" << meshCylinderCreateCmd->GetCommandPath()
607 << "] : Scoring mesh <" << newVal
608 << "> already exists. Command ignored.";
609 command->CommandFailed(ed);
610 }
611 }
612 }
613 else if(command == meshRWLogVolCreateCmd)
614 {
615 auto mesh = fSMan->GetCurrentMesh();
616 if(mesh != nullptr)
617 {
619 ed << "ERROR[" << meshRWLogVolCreateCmd->GetCommandPath() << "] : Mesh <"
620 << mesh->GetWorldName()
621 << "> is still open. Close it first. Command ignored.";
622 command->CommandFailed(ed);
623 }
624 else
625 {
626 G4Tokenizer next(newVal);
627 G4String meshName = next();
628 G4int idx = StoI(next());
629 mesh = fSMan->FindMesh(meshName);
630 if(mesh == nullptr)
631 {
632 mesh = new G4ScoringRealWorld(meshName);
633 mesh->SetCopyNumberLevel(idx);
634 fSMan->RegisterScoringMesh(mesh);
635 }
636 else
637 {
639 ed << "ERROR[" << meshRWLogVolCreateCmd->GetCommandPath()
640 << "] : Scoring mesh <" << meshName
641 << "> already exists. Command ignored.";
642 command->CommandFailed(ed);
643 }
644 }
645 }
646 else if(command == probeCreateCmd)
647 {
648 auto mesh = fSMan->GetCurrentMesh();
649 if(mesh != nullptr)
650 {
652 ed << "ERROR[" << meshRWLogVolCreateCmd->GetCommandPath() << "] : Mesh <"
653 << mesh->GetWorldName()
654 << "> is still open. Close it first. Command ignored.";
655 command->CommandFailed(ed);
656 }
657 else
658 {
659 G4Tokenizer next(newVal);
660 G4String qname = next();
661 G4double halfSize = StoD(next());
662 halfSize *= G4UIcommand::ValueOf(next());
663 G4bool checkOverlap = StoB(next());
664 mesh = fSMan->FindMesh(qname);
665 if(mesh == nullptr)
666 {
667 mesh = new G4ScoringProbe(qname, halfSize, checkOverlap);
668 fSMan->RegisterScoringMesh(mesh);
669 }
670 else
671 {
673 ed << "ERROR[" << probeCreateCmd->GetCommandPath() << "] : Mesh name <"
674 << qname << "> already exists. Use another name.";
675 command->CommandFailed(ed);
676 }
677 }
678 }
679 else if(command == probeMatCmd || command == probeLocateCmd)
680 {
681 auto mesh = fSMan->GetCurrentMesh();
682 if(mesh == nullptr)
683 {
685 ed << "ERROR : No mesh is currently open. Open/create a mesh first. "
686 "Command ignored.";
687 command->CommandFailed(ed);
688 return;
689 }
690 if(mesh->GetShape() != MeshShape::probe)
691 {
693 ed << "ERROR : Inconsistent mesh type. Close current mesh and open "
694 "Scoring Probe.";
695 command->CommandFailed(ed);
696 return;
697 }
698
699 if(command == probeMatCmd)
700 {
701 G4bool succ = static_cast<G4ScoringProbe*>(mesh)->SetMaterial(newVal);
702 if(!succ)
703 {
705 ed << "Material <" << newVal
706 << "> is not defind in G4NistManager. Command is ignored.\n"
707 << "Use /material/nist/listMaterials command to see the available "
708 "materials.";
709 command->CommandFailed(ed);
710 return;
711 }
712 }
713 else if(command == probeLocateCmd)
714 {
715 G4ThreeVector loc = probeLocateCmd->GetNew3VectorValue(newVal);
716 static_cast<G4ScoringProbe*>(mesh)->LocateProbe(loc);
717 }
718 }
719 else if(command == listColorMapCmd)
720 {
721 fSMan->ListScoreColorMaps();
722 }
723 else if(command == floatMinMaxCmd)
724 {
725 G4VScoreColorMap* colorMap = fSMan->GetScoreColorMap(newVal);
726 if(colorMap != nullptr)
727 {
728 colorMap->SetFloatingMinMax(true);
729 }
730 else
731 {
733 ed << "ERROR[" << floatMinMaxCmd->GetCommandPath() << "] : color map <"
734 << newVal << "> is not defined. Command ignored.";
735 command->CommandFailed(ed);
736 }
737 }
738 else if(command == colorMapMinMaxCmd)
739 {
740 G4Tokenizer next(newVal);
741 G4String mapName = next();
742 G4double minVal = StoD(next());
743 G4double maxVal = StoD(next());
744 G4VScoreColorMap* colorMap = fSMan->GetScoreColorMap(mapName);
745 if(colorMap != nullptr)
746 {
747 colorMap->SetFloatingMinMax(false);
748 colorMap->SetMinMax(minVal, maxVal);
749 }
750 else
751 {
753 ed << "ERROR[" << colorMapMinMaxCmd->GetCommandPath() << "] : color map <"
754 << newVal << "> is not defined. Command ignored." << G4endl;
755 command->CommandFailed(ed);
756 }
757 }
758 else if(command == meshOpnCmd)
759 {
760 G4VScoringMesh* currentmesh = fSMan->GetCurrentMesh();
761 if(currentmesh != nullptr)
762 {
764 ed << "ERROR[" << meshOpnCmd->GetCommandPath() << "] : Mesh <"
765 << currentmesh->GetWorldName()
766 << "> is still open. Close it first. Command ignored.";
767 command->CommandFailed(ed);
768 }
769 else
770 {
771 G4VScoringMesh* mesh = fSMan->FindMesh(newVal);
772 if(mesh == nullptr)
773 {
775 ed << "ERROR[" << meshOpnCmd->GetCommandPath() << "] : Scoring mesh <"
776 << newVal << "> does not exist. Command ignored.";
777 command->CommandFailed(ed);
778 }
779 else
780 {
781 fSMan->SetCurrentMesh(mesh);
782 }
783 }
784 }
785 else if(command == meshClsCmd)
786 {
787 fSMan->CloseCurrentMesh();
788 }
789 else
790 {
791 //
792 // Get Current Mesh
793 //
794 G4VScoringMesh* mesh = fSMan->GetCurrentMesh();
795 //
796 // Commands for Current Mesh
797 if(mesh != nullptr)
798 {
799 MeshShape shape = mesh->GetShape();
800 if(shape == MeshShape::realWorldLogVol)
801 {
803 ed << "ERROR[" << mBinCmd->GetCommandPath()
804 << "] : Number of mesh command cannot be set for this type of mesh. "
805 "Command ignored.";
806 command->CommandFailed(ed);
807 }
808 else
809 {
810 // Tokens
811 G4TokenVec token;
812 FillTokenVec(newVal, token);
813 //
814 // Mesh Geometry
815 if(command == mBoxSizeCmd)
816 {
817 if(shape == MeshShape::box)
818 {
819 G4ThreeVector size = mBoxSizeCmd->GetNew3VectorValue(newVal);
820 G4double vsize[3];
821 vsize[0] = size.x();
822 vsize[1] = size.y();
823 vsize[2] = size.z();
824 mesh->SetSize(vsize);
825 }
826 else
827 {
829 ed << "ERROR[" << mBoxSizeCmd->GetCommandPath()
830 << "] : This mesh is not Box. Command ignored.";
831 command->CommandFailed(ed);
832 }
833 }
834 else if(command == mCylinderSizeCmd || command == mCylinderRMinCmd ||
835 command == mCylinderAngleCmd)
836 {
837 if(shape != MeshShape::cylinder)
838 {
840 ed << "ERROR[" << command->GetCommandPath()
841 << "] : This mesh is not Cylinder. Command ignored.";
842 command->CommandFailed(ed);
843 }
844 else
845 {
846 if(command == mCylinderSizeCmd)
847 {
848 G4double vsize[3];
849 vsize[0] = (mesh->GetSize()).x();
850 vsize[1] = StoD(token[0]);
851 vsize[2] = StoD(token[1]);
852 G4double unt = mCylinderSizeCmd->ValueOf(token[2]);
853 vsize[1] *= unt;
854 vsize[2] *= unt;
855 mesh->SetSize(vsize);
856 }
857 else if(command == mCylinderRMinCmd)
858 {
859 G4double vsize[3];
860 vsize[0] = mCylinderRMinCmd->GetNewDoubleValue(newVal);
861 vsize[1] = (mesh->GetSize()).y();
862 vsize[2] = (mesh->GetSize()).z();
863 mesh->SetSize(vsize);
864 }
865 else if(command == mCylinderAngleCmd)
866 {
867 G4double stphi = StoD(token[0]);
868 G4double spphi = StoD(token[1]);
869 G4double unt = mCylinderAngleCmd->ValueOf(token[2]);
870 mesh->SetAngles(stphi * unt, spphi * unt);
871 }
872 }
873 }
874 else if(command == mBinCmd)
875 {
876 MeshBinCommand(mesh, token);
877 }
878 else if(command == mTResetCmd)
879 {
880 G4double centerPosition[3] = { 0., 0., 0. };
881 mesh->SetCenterPosition(centerPosition);
882 }
883 else if(command == mTXyzCmd)
884 {
885 G4ThreeVector xyz = mTXyzCmd->GetNew3VectorValue(newVal);
886 G4double centerPosition[3];
887 centerPosition[0] = xyz.x();
888 centerPosition[1] = xyz.y();
889 centerPosition[2] = xyz.z();
890 mesh->SetCenterPosition(centerPosition);
891 }
892 else if(command == mRotXCmd)
893 {
894 G4double value = mRotXCmd->GetNewDoubleValue(newVal);
895 mesh->RotateX(value);
896 }
897 else if(command == mRotYCmd)
898 {
899 G4double value = mRotYCmd->GetNewDoubleValue(newVal);
900 mesh->RotateY(value);
901 }
902 else if(command == mRotZCmd)
903 {
904 G4double value = mRotZCmd->GetNewDoubleValue(newVal);
905 mesh->RotateZ(value);
906 }
907 }
908 }
909 else
910 {
912 ed << "ERROR: No mesh is currently open. Open/create a mesh first. "
913 "Command ignored.";
914 command->CommandFailed(ed);
915 }
916 }
917}
std::vector< G4String > G4TokenVec
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
double z() const
double x() const
double y() const
void RegisterScoringMesh(G4VScoringMesh *scm)
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
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)
void Fill1D(G4UIcommand *cmd, G4String newValues)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
static G4double GetNewDoubleValue(const char *paramString)
static G4int GetNewIntValue(const char *paramString)
static G4double ValueOf(const char *unitName)
const G4String & GetCommandPath() const
G4double StoD(const G4String &s)
G4bool StoB(G4String s)
void SetMinMax(G4double minVal, G4double maxVal)
void SetFloatingMinMax(G4bool vl=true)
G4ThreeVector GetSize() const
MeshShape GetShape() const
void RotateY(G4double delta)
void SetAngles(G4double, G4double)
const G4String & GetWorldName() const
void SetCenterPosition(G4double centerPosition[3])
void SetCopyNumberLevel(G4int val)
void RotateX(G4double delta)
void SetSize(G4double size[3])
void RotateZ(G4double delta)

The documentation for this class was generated from the following files: