ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ScoringMessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4ScoringMessenger.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 //
28 // ---------------------------------------------------------------------
29 
30 #include "G4ScoringMessenger.hh"
31 #include "G4ScoringManager.hh"
32 #include "G4VScoringMesh.hh"
33 #include "G4ScoringBox.hh"
34 #include "G4ScoringCylinder.hh"
35 #include "G4ScoringRealWorld.hh"
36 
37 #include "G4UIdirectory.hh"
39 #include "G4UIcmdWithAnInteger.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  meshDir = new G4UIdirectory("/score/mesh/");
70  meshDir->SetGuidance(" Mesh processing commands.");
71 
72  meshCreateDir = new G4UIdirectory("/score/create/");
73  meshCreateDir->SetGuidance(" Mesh creation commands.");
74  //
75  // Mesh commands
76  meshBoxCreateCmd = new G4UIcmdWithAString("/score/create/boxMesh",this);
77  meshBoxCreateCmd->SetGuidance("Create scoring box mesh.");
78  meshBoxCreateCmd->SetParameterName("MeshName",false);
79  //
80  meshCylinderCreateCmd = new G4UIcmdWithAString("/score/create/cylinderMesh",this);
81  meshCylinderCreateCmd->SetGuidance("Create scoring mesh.");
82  meshCylinderCreateCmd->SetParameterName("MeshName",false);
83  //
84 // meshSphereCreateCmd = new G4UIcmdWithAString("/score/create/sphereMesh",this);
85 // meshSphereCreateCmd->SetGuidance("Create scoring mesh.");
86 // meshSphereCreateCmd->SetParameterName("MeshName",false);
87  //
88  meshRWLogVolCreateCmd = new G4UIcommand("/score/create/realWorldLogVol",this);
89  meshRWLogVolCreateCmd->SetGuidance("Define scorers to a logical volume defined in the real world.");
90  meshRWLogVolCreateCmd->SetGuidance(" - Name of the specified logical volume is used as the mesh name.");
91  meshRWLogVolCreateCmd->SetGuidance(" - /score/mesh commands do not affect for this mesh.");
92  meshRWLogVolCreateCmd->SetGuidance(" - If copyNumberLevel is set, the copy number of that-level higher");
93  meshRWLogVolCreateCmd->SetGuidance(" in the geometrical hierarchy is used as the index.");
94  param = new G4UIparameter("logVol",'s',false);
96  param = new G4UIparameter("copyNumberLevel",'i',true);
97  param->SetParameterRange("copyNumberLevel>=0");
98  param->SetDefaultValue(0);
100  //
101  meshOpnCmd = new G4UIcmdWithAString("/score/open",this);
102  meshOpnCmd->SetGuidance("Open scoring mesh.");
103  meshOpnCmd->SetParameterName("MeshName",false);
104  //
105  meshClsCmd = new G4UIcmdWithoutParameter("/score/close",this);
106  meshClsCmd->SetGuidance("Close scoring mesh.");
107  //
108 // meshActCmd = new G4UIcmdWithABool("/score/mesh/activate",this);
109 // meshActCmd->SetGuidance("Activate scoring mesh.");
110 // meshActCmd->SetParameterName("MeshName",false);
111  //
112  mBoxSizeCmd = new G4UIcmdWith3VectorAndUnit("/score/mesh/boxSize",this);
113  mBoxSizeCmd->SetGuidance("Define size of the scoring mesh.");
114  mBoxSizeCmd->SetGuidance("Dx Dy Dz unit");
115  mBoxSizeCmd->SetParameterName("Di","Dj","Dk",false,false);
116  mBoxSizeCmd->SetRange("Di>0. && Dj>0. && Dk>0.");
118  //
119  mCylinderSizeCmd = new G4UIcommand("/score/mesh/cylinderSize",this);
120  mCylinderSizeCmd->SetGuidance("Define size of the scoring mesh.");
121  mCylinderSizeCmd->SetGuidance("R Dz unit");
122  param = new G4UIparameter("R",'d',false);
123  param->SetParameterRange("R>0");
125  param = new G4UIparameter("Dz",'d',false);
126  param->SetParameterRange("Dz>0");
128  param = new G4UIparameter("unit",'s',true);
129  param->SetDefaultUnit("mm");
131  //
132  // Division command
133  mBinCmd = new G4UIcommand("/score/mesh/nBin",this);
134  mBinCmd->SetGuidance("Define segments of the scoring mesh.");
135  mBinCmd->SetGuidance("[usage] /score/mesh/nBin");
136  mBinCmd->SetGuidance(" In case of boxMesh, parameters are given in");
137  mBinCmd->SetGuidance(" Ni :(int) Number of bins i (in x-axis) ");
138  mBinCmd->SetGuidance(" Nj :(int) Number of bins j (in y-axis) ");
139  mBinCmd->SetGuidance(" Nk :(int) Number of bins k (in z-axis) ");
140  mBinCmd->SetGuidance(" In case of cylinderMesh, parameters are given in");
141  mBinCmd->SetGuidance(" Nr :(int) Number of bins in radial axis ");
142  mBinCmd->SetGuidance(" Nz :(int) Number of bins in z axis ");
143  mBinCmd->SetGuidance(" Nphi:(int) Number of bins in phi axis ");
144  //mBinCmd->SetGuidance(" Axis:(int) Axis of division ");
145 // mBinCmd->SetGuidance(" P1..Pn-1 :(double) \"paramter from P1 to Pn-1 for division.\"");
146  param = new G4UIparameter("Ni",'i',false);
147  param->SetDefaultValue("1");
148  param->SetParameterRange("Ni>0");
149  mBinCmd->SetParameter(param);
150  param = new G4UIparameter("Nj",'i',false);
151  param->SetDefaultValue("1");
152  param->SetParameterRange("Nj>0");
153  mBinCmd->SetParameter(param);
154  param = new G4UIparameter("Nk",'i',false);
155  param->SetDefaultValue("1");
156  mBinCmd->SetParameter(param);
157  param->SetParameterRange("Nk>0");
158  //param = new G4UIparameter("Axis",'i',true);
159  //param->SetDefaultValue("3");
160  //mBinCmd->SetParameter(param);
161  //
162  // Placement command
163  mTransDir = new G4UIdirectory("/score/mesh/translate/");
164  mTransDir->SetGuidance("Mesh translation commands.");
165  //
166  mTResetCmd = new G4UIcmdWithoutParameter("/score/mesh/translate/reset",this);
167  mTResetCmd->SetGuidance("Reset translated position of the scoring mesh.");
168  //
169  mTXyzCmd = new G4UIcmdWith3VectorAndUnit("/score/mesh/translate/xyz",this);
170  mTXyzCmd->SetGuidance("Translate the scoring mesh.");
171  mTXyzCmd->SetParameterName("X","Y","Z",false,false);
172  mTXyzCmd->SetDefaultUnit("mm");
173  //
174  mRotDir = new G4UIdirectory("/score/mesh/rotate/");
175  mRotDir->SetGuidance("Mesh rotation commands.");
176  //
177  //mRResetCmd = new G4UIcmdWithoutParameter("/score/mesh/rotate/reset",this);
178  //mRResetCmd->SetGuidance("Reset rotation angles of the scoring mesh.");
179  //
180  mRotXCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateX",this);
181  mRotXCmd->SetGuidance("Rotate the scoring mesh in X axis.");
182  mRotXCmd->SetParameterName("Rx",false);
183  mRotXCmd->SetDefaultUnit("deg");
184  //
185  mRotYCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateY",this);
186  mRotYCmd->SetGuidance("Rotate the scoring mesh in Y axis.");
187  mRotYCmd->SetParameterName("Ry",false);
188  mRotYCmd->SetDefaultUnit("deg");
189  //
190  mRotZCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateZ",this);
191  mRotZCmd->SetGuidance("Rotate the scoring mesh in Z axis.");
192  mRotZCmd->SetParameterName("Rz",false);
193  mRotZCmd->SetDefaultUnit("deg");
194  //
195 
196  // Draw Scoring result
197  drawCmd = new G4UIcommand("/score/drawProjection",this);
198  drawCmd->SetGuidance("Draw projection(s) of scored quantities.");
199  drawCmd->SetGuidance("Parameter <proj> specified which projection(s) to be drawn.");
200  drawCmd->SetGuidance(" 100 : xy-plane, 010 : yz-plane, 001 : zx-plane -- default 111");
201  drawCmd->SetGuidance(" 100 : N/A, 010 : z_phi-plane, 001 : r_phi-plane -- default 111");
202  param = new G4UIparameter("meshName",'s',false);
203  drawCmd->SetParameter(param);
204  param = new G4UIparameter("psName",'s',false);
205  drawCmd->SetParameter(param);
206  param = new G4UIparameter("colorMapName",'s',true);
207  param->SetDefaultValue("defaultLinearColorMap");
208  drawCmd->SetParameter(param);
209  param = new G4UIparameter("proj",'i',true);
210  param->SetDefaultValue(111);
211  drawCmd->SetParameter(param);
212  drawCmd->SetToBeBroadcasted(false);
213 
214  // Draw column
215  drawColumnCmd = new G4UIcommand("/score/drawColumn",this);
216  drawColumnCmd->SetGuidance("Draw a cell column.");
217  drawColumnCmd->SetGuidance(" plane = 0 : x-y, 1: y-z, 2: z-x for box mesh");
218  drawColumnCmd->SetGuidance(" 0 : z-phi, 1: r-phi, 2: r-z for cylinder mesh");
219  param = new G4UIparameter("meshName",'s',false);
220  drawColumnCmd->SetParameter(param);
221  param = new G4UIparameter("psName",'s',false);
222  drawColumnCmd->SetParameter(param);
223  param = new G4UIparameter("plane",'i',false);
224  param->SetParameterRange("plane>=0 && plane<=2");
225  drawColumnCmd->SetParameter(param);
226  param = new G4UIparameter("column",'i',false);
227  drawColumnCmd->SetParameter(param);
228  param = new G4UIparameter("colorMapName",'s',true);
229  param->SetDefaultValue("defaultLinearColorMap");
230  drawColumnCmd->SetParameter(param);
232 
233  colorMapDir = new G4UIdirectory("/score/colorMap/");
234  colorMapDir->SetGuidance("Color map commands.");
235 
236  listColorMapCmd = new G4UIcmdWithoutParameter("/score/colorMap/listScoreColorMaps",this);
237  listColorMapCmd->SetGuidance("List registered score color maps.");
239 
240  floatMinMaxCmd = new G4UIcmdWithAString("/score/colorMap/floatMinMax",this);
241  floatMinMaxCmd->SetGuidance("Min/Max of the color map is calculated according to the actual scores.");
242  floatMinMaxCmd->SetParameterName("colorMapName",true,false);
243  floatMinMaxCmd->SetDefaultValue("defaultLinearColorMap");
245 
246  colorMapMinMaxCmd = new G4UIcommand("/score/colorMap/setMinMax",this);
247  colorMapMinMaxCmd->SetGuidance("Define min/max value of the color map.");
248  param = new G4UIparameter("colorMapMame",'s',true);
249  param->SetDefaultValue("defaultLinearColorMap");
251  param = new G4UIparameter("minValue",'d',false);
253  param = new G4UIparameter("maxValue",'d',false);
256 
257  /*
258  chartCmd = new G4UIcommand("/score/drawChart",this);
259  chartCmd->SetGuidance("Draw color chart on the screen.");
260  chartCmd->SetGuidance("[usage] /score/drawChart");
261  chartCmd->SetGuidance(" mesh :(String) Mesh name.");
262  chartCmd->SetGuidance(" psname :(String) PS name.");
263  chartCmd->SetGuidance(" On/Off :(boolean) On or Off the color chart.");
264  chartCmd->SetGuidance(" scale :(String) default=linear, or log ");
265  param = new G4UIparameter("meshName",'s',false);
266  chartCmd->SetParameter(param);
267  param = new G4UIparameter("psName",'s',false);
268  chartCmd->SetParameter(param);
269  param = new G4UIparameter("On",'s',true);
270  param->SetDefaultValue("true");
271  chartCmd->SetParameter(param);
272  param = new G4UIparameter("scale",'s',true);
273  param->SetDefaultValue("linear");
274  chartCmd->SetParameter(param);
275  */
276 
277  // Dump a scored quantity
278  dumpQtyToFileCmd = new G4UIcommand("/score/dumpQuantityToFile", this);
279  dumpQtyToFileCmd->SetGuidance("Dump one scored quantity to file.");
280  param = new G4UIparameter("meshName", 's', false);
282  param = new G4UIparameter("psName", 's', false);
284  param = new G4UIparameter("fileName", 's', false);
286  param = new G4UIparameter("option", 's', true);
289 
290  dumpQtyWithFactorCmd = new G4UIcommand("/score/dumpQuantityWithFactor", this);
291  dumpQtyWithFactorCmd->SetGuidance("Dump one scored quantity to file.");
292  dumpQtyWithFactorCmd->SetGuidance("Each value is multiplied by the specified factor.");
293  param = new G4UIparameter("meshName", 's', false);
295  param = new G4UIparameter("psName", 's', false);
297  param = new G4UIparameter("fileName", 's', false);
299  param = new G4UIparameter("factor", 'd', false);
300  param->SetParameterRange("factor>0.");
302  param = new G4UIparameter("option", 's', true);
305 
306  // Dump all scored quantities
307  dumpAllQtsToFileCmd = new G4UIcommand("/score/dumpAllQuantitiesToFile", this);
308  dumpAllQtsToFileCmd->SetGuidance("Dump all quantities of the mesh to file.");
309  param = new G4UIparameter("meshName", 's', false);
311  param = new G4UIparameter("fileName", 's', false);
313  param = new G4UIparameter("option", 's', true);
316 
317  dumpAllQtsWithFactorCmd = new G4UIcommand("/score/dumpAllQuantitiesWithFactor", this);
318  dumpAllQtsWithFactorCmd->SetGuidance("Dump all quantities of the mesh to file.");
319  dumpAllQtsWithFactorCmd->SetGuidance("Each value is multiplied by the specified factor.");
320  param = new G4UIparameter("meshName", 's', false);
322  param = new G4UIparameter("fileName", 's', false);
324  param = new G4UIparameter("factor", 'd', false);
325  param->SetParameterRange("factor>0.");
327  param = new G4UIparameter("option", 's', true);
330 
331 }
332 
334 {
335  delete listCmd;
336  delete verboseCmd;
337  //
338  delete meshCreateDir;
339  delete meshBoxCreateCmd;
340  delete meshCylinderCreateCmd;
341  delete meshRWLogVolCreateCmd;
342 // delete meshSphereCreateCmd;
343  //
344  delete meshOpnCmd;
345  //
346  delete meshClsCmd;
347 // delete meshActCmd;
348  delete meshDir;
349  //
350  delete mBoxSizeCmd;
351  delete mCylinderSizeCmd;
352 // delete mSphereSizeCmd;
353  //
354  delete mBinCmd;
355  //
356  delete mTResetCmd;
357  delete mTXyzCmd;
358  delete mTransDir;
359 // delete mRResetCmd;
360  delete mRotXCmd;
361  delete mRotYCmd;
362  delete mRotZCmd;
363  delete mRotDir;
364  //
365  //delete chartCmd;
366  delete dumpCmd;
367  delete drawCmd;
368  delete drawColumnCmd;
369  delete listColorMapCmd;
370  delete floatMinMaxCmd;
371  delete colorMapMinMaxCmd;
372  delete colorMapDir;
373  delete dumpQtyWithFactorCmd;
374  delete dumpQtyWithFactorCmd;
375  delete dumpAllQtsToFileCmd;
377  //
378  delete scoreDir;
379 }
380 
382 {
383  using MeshShape = G4VScoringMesh::MeshShape;
384 
385  if(command==listCmd) {
386  fSMan->List();
387  } else if(command==dumpCmd) {
388  fSMan->Dump();
389  } else if(command==drawCmd) {
390  G4Tokenizer next(newVal);
391  G4String meshName = next();
392  G4String psName = next();
393  G4String colorMapName = next();
394  G4int axflg = StoI(next());
395  fSMan->DrawMesh(meshName,psName,colorMapName,axflg);
396  } else if(command==drawColumnCmd) {
397  G4Tokenizer next(newVal);
398  G4String meshName = next();
399  G4String psName = next();
400  G4int iPlane = StoI(next());
401  G4int iColumn = StoI(next());
402  G4String colorMapName = next();
403  fSMan->DrawMesh(meshName,psName,iPlane,iColumn,colorMapName);
404 // } else if(command==chartCmd ){
405 // G4Tokenizer next(newVal);
406 // G4String meshName = next();
407 // G4String psName = next();
408 // //G4bool onFlag = StoB(next());
409 // G4String scaleOption = next();
410 // fSMan->DrawChart(meshName,psName,onFlag,scaleOption);
411 
412  } else if(command==dumpQtyToFileCmd) {
413  G4Tokenizer next(newVal);
414  G4String meshName = next();
415  G4String psName = next();
416  G4String fileName = next();
417  G4String option = next("\n");
418  auto mesh = fSMan->FindMesh(meshName);
419  if(!mesh)
420  {
422  ed << "Mesh name <" << meshName << "> is not found. Command ignored.";
423  command->CommandFailed(ed);
424  return;
425  }
426  fSMan->DumpQuantityToFile(meshName, psName, fileName, option);
427  } else if(command==dumpQtyWithFactorCmd) {
428  G4Tokenizer next(newVal);
429  G4String meshName = next();
430  G4String psName = next();
431  G4String fileName = next();
432  G4double fac = StoD(next());
433  G4String option = next("\n");
434  auto mesh = fSMan->FindMesh(meshName);
435  if(!mesh)
436  {
438  ed << "Mesh name <" << meshName << "> is not found. Command ignored.";
439  command->CommandFailed(ed);
440  return;
441  }
442  fSMan->SetFactor(fac);
443  fSMan->DumpQuantityToFile(meshName, psName, fileName, option);
444  fSMan->SetFactor(1.0);
445  } else if(command==dumpAllQtsToFileCmd) {
446  G4Tokenizer next(newVal);
447  G4String meshName = next();
448  G4String fileName = next();
449  G4String option = next("\n");
450  auto mesh = fSMan->FindMesh(meshName);
451  if(!mesh)
452  {
454  ed << "Mesh name <" << meshName << "> is not found. Command ignored.";
455  command->CommandFailed(ed);
456  return;
457  }
458  fSMan->DumpAllQuantitiesToFile(meshName, fileName, option);
459  } else if(command==dumpAllQtsWithFactorCmd) {
460  G4Tokenizer next(newVal);
461  G4String meshName = next();
462  G4String fileName = next();
463  G4double fac = StoD(next());
464  G4String option = next("\n");
465  auto mesh = fSMan->FindMesh(meshName);
466  if(!mesh)
467  {
469  ed << "Mesh name <" << meshName << "> is not found. Command ignored.";
470  command->CommandFailed(ed);
471  return;
472  }
473  fSMan->SetFactor(fac);
474  fSMan->DumpAllQuantitiesToFile(meshName, fileName, option);
475  fSMan->SetFactor(1.0);
476  } else if(command==verboseCmd) {
478  } else if(command==meshBoxCreateCmd) {
479  G4VScoringMesh* currentmesh = fSMan->GetCurrentMesh();
480  if ( currentmesh ){
482  ed << "ERROR[" << meshBoxCreateCmd->GetCommandPath()
483  << "] : Mesh <" << currentmesh->GetWorldName()
484  << "> is still open. Close it first. Command ignored.";
485  command->CommandFailed(ed);
486  } else {
487 
488  G4VScoringMesh* mesh = fSMan->FindMesh(newVal);
489  if ( !mesh ){
490  mesh = new G4ScoringBox(newVal);
491  fSMan->RegisterScoringMesh(mesh);
492  }else{
494  ed << "ERROR[" << meshBoxCreateCmd->GetCommandPath()
495  << "] : Scoring mesh <" << newVal
496  << "> already exists. Command ignored.";
497  command->CommandFailed(ed);
498  }
499  }
500  } else if(command==meshCylinderCreateCmd) {
501  G4VScoringMesh* currentmesh = fSMan->GetCurrentMesh();
502  if ( currentmesh ){
504  ed << "ERROR[" << meshCylinderCreateCmd->GetCommandPath()
505  << "] : Mesh <" << currentmesh->GetWorldName()
506  << "> is still open. Close it first. Command ignored.";
507  command->CommandFailed(ed);
508  } else {
509 
510  G4VScoringMesh* mesh = fSMan->FindMesh(newVal);
511  if ( !mesh ){
512  mesh = new G4ScoringCylinder(newVal);
513  fSMan->RegisterScoringMesh(mesh);
514  }else{
516  ed << "ERROR[" << meshCylinderCreateCmd->GetCommandPath()
517  << "] : Scoring mesh <" << newVal
518  << "> already exists. Command ignored.";
519  command->CommandFailed(ed);
520  }
521  }
522  } else if(command==meshRWLogVolCreateCmd) {
523  auto mesh = fSMan->GetCurrentMesh();
524  if ( mesh ){
526  ed << "ERROR[" << meshRWLogVolCreateCmd->GetCommandPath()
527  << "] : Mesh <" << mesh->GetWorldName()
528  << "> is still open. Close it first. Command ignored.";
529  command->CommandFailed(ed);
530  }
531  else
532  {
533  G4Tokenizer next(newVal);
534  G4String meshName = next();
535  G4int idx = StoI(next());
536  mesh = fSMan->FindMesh(meshName);
537  if ( !mesh ){
538  mesh = new G4ScoringRealWorld(meshName);
539  mesh->SetCopyNumberLevel(idx);
540  fSMan->RegisterScoringMesh(mesh);
541  }else{
543  ed << "ERROR[" << meshRWLogVolCreateCmd->GetCommandPath()
544  << "] : Scoring mesh <" << meshName << "> already exists. Command ignored.";
545  command->CommandFailed(ed);
546  }
547  }
548 
549  } else if(command==listColorMapCmd) {
551  } else if(command==floatMinMaxCmd) {
552  G4VScoreColorMap* colorMap = fSMan->GetScoreColorMap(newVal);
553  if(colorMap)
554  { colorMap->SetFloatingMinMax(true); }
555  else
556  {
558  ed << "ERROR[" << floatMinMaxCmd->GetCommandPath()
559  << "] : color map <" << newVal << "> is not defined. Command ignored." ;
560  command->CommandFailed(ed);
561  }
562  } else if(command==colorMapMinMaxCmd) {
563  G4Tokenizer next(newVal);
564  G4String mapName = next();
565  G4double minVal = StoD(next());
566  G4double maxVal = StoD(next());
567  G4VScoreColorMap* colorMap = fSMan->GetScoreColorMap(mapName);
568  if(colorMap)
569  { colorMap->SetFloatingMinMax(false);
570  colorMap->SetMinMax(minVal,maxVal); }
571  else
572  {
574  ed << "ERROR[" << colorMapMinMaxCmd->GetCommandPath()
575  << "] : color map <" << newVal << "> is not defined. Command ignored."
576  << G4endl;
577  command->CommandFailed(ed);
578  }
579  } else if(command==meshOpnCmd) {
580  G4VScoringMesh* currentmesh = fSMan->GetCurrentMesh();
581  if ( currentmesh ){
583  ed << "ERROR[" << meshOpnCmd->GetCommandPath()
584  << "] : Mesh <" << currentmesh->GetWorldName()
585  << "> is still open. Close it first. Command ignored.";
586  command->CommandFailed(ed);
587  } else {
588  G4VScoringMesh* mesh = fSMan->FindMesh(newVal);
589  if ( !mesh ){
591  ed << "ERROR[" << meshOpnCmd->GetCommandPath()
592  << "] : Scoring mesh <" << newVal << "> does not exist. Command ignored.";
593  command->CommandFailed(ed);
594  } else {
595  fSMan->SetCurrentMesh(mesh);
596  }
597  }
598  } else if(command==meshClsCmd) {
600  } else {
601  //
602  // Get Current Mesh
603  //
605  //
606  // Commands for Current Mesh
607  if ( mesh ){
608  MeshShape shape = mesh->GetShape();
609  if ( shape == MeshShape::realWorldLogVol ) {
611  ed << "ERROR[" << mBinCmd->GetCommandPath()
612  << "] : Number of mesh command cannot be set for this type of mesh. Command ignored.";
613  command->CommandFailed(ed);
614  } else {
615 
616  // Tokens
617  G4TokenVec token;
618  FillTokenVec(newVal,token);
619  //
620  // Mesh Geometry
621  //
622 // if(command==meshActCmd) {
623 // mesh->Activate(meshActCmd->GetNewBoolValue(newVal));
624 // } else
625  if(command==mBoxSizeCmd) {
626  if ( shape == MeshShape::box){
628  G4double vsize[3];
629  vsize[0] = size.x();
630  vsize[1] = size.y();
631  vsize[2] = size.z();
632  mesh->SetSize(vsize);
633  } else {
635  ed << "ERROR[" << mBoxSizeCmd->GetCommandPath()
636  << "] : This mesh is not Box. Command ignored.";
637  command->CommandFailed(ed);
638  }
639  }else if(command==mCylinderSizeCmd) {
640  if ( shape == MeshShape::cylinder ){
641  G4double vsize[3];
642  vsize[0] = StoD(token[0]);
643  vsize[1] = StoD(token[1]);
644  G4double unt = mCylinderSizeCmd->ValueOf(token[2]);
645  vsize[0] *= unt;
646  vsize[1] *= unt;
647  vsize[2] = 0.0;
648  mesh->SetSize(vsize);
649  } else {
651  ed << "ERROR[" << mBoxSizeCmd->GetCommandPath()
652  << "] : This mesh is not Box. Command ignored.";
653  command->CommandFailed(ed);
654  }
655  } else if(command==mBinCmd) {
656  MeshBinCommand(mesh,token);
657  } else if(command==mTResetCmd) {
658  G4double centerPosition[3] ={ 0., 0., 0.};
659  mesh->SetCenterPosition(centerPosition);
660  } else if(command==mTXyzCmd) {
662  G4double centerPosition[3];
663  centerPosition[0] = xyz.x();
664  centerPosition[1] = xyz.y();
665  centerPosition[2] = xyz.z();
666  mesh->SetCenterPosition(centerPosition);
667 // } else if(command==mRResetCmd) {
668  } else if(command==mRotXCmd) {
670  mesh->RotateX(value);
671  } else if(command==mRotYCmd) {
673  mesh->RotateY(value);
674  } else if(command==mRotZCmd) {
676  mesh->RotateZ(value);
677  }
678  }
679  }else{
681  ed << "ERROR: No mesh is currently open. Open/create a mesh first. Command ignored.";
682  command->CommandFailed(ed);
683  }
684  }
685 }
686 
688 {
689  G4String val;
690  if(command==verboseCmd)
692 
693  return val;
694 }
695 
697 
698  G4Tokenizer next(newValues);
699  G4String val;
700  while ( !(val = next()).isNull() ) { // Loop checking 12.18.2015 M.Asai
701  token.push_back(val);
702  }
703 }
704 
705 
707  G4int Ni = StoI(token[0]);
708  G4int Nj = StoI(token[1]);
709  G4int Nk = StoI(token[2]);
710  G4int nSegment[3];
711 
712  if(dynamic_cast<G4ScoringBox*>(mesh)) {
713  G4cout << ".... G4ScoringMessenger::MeshBinCommand - G4ScoringBox" << G4endl;
714  nSegment[0] = Ni;
715  nSegment[1] = Nj;
716  nSegment[2] = Nk;
717  } else if(dynamic_cast<G4ScoringCylinder*>(mesh)) {
718  G4cout << ".... G4ScoringMessenger::MeshBinCommand - G4ScoringCylinder" << G4endl;
719  nSegment[0] = Nj;
720  nSegment[1] = Nk;
721  nSegment[2] = Ni;
722  } else {
723  G4Exception("G4ScoringMessenger::MeshBinCommand()", "001", FatalException, "invalid mesh type");
724  return;
725  }
726  //
727  mesh->SetNumberOfSegments(nSegment);
728 }
729 
730