Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/navigation/src/G4GeometryMessenger.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/navigation/src/G4GeometryMessenger.cc (Version 11.3.0) and /geometry/navigation/src/G4GeometryMessenger.cc (Version 9.2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // class G4GeometryMessenger implementation    << 
 27 //                                                 26 //
 28 // Author: G.Cosmo, CERN                       <<  27 // $Id: G4GeometryMessenger.cc,v 1.5 2006/06/29 18:36:57 gunter Exp $
                                                   >>  28 // GEANT4 tag $Name: geant4-09-02 $
                                                   >>  29 //
                                                   >>  30 // --------------------------------------------------------------------
                                                   >>  31 // GEANT 4 class source file
                                                   >>  32 //
                                                   >>  33 // G4GeometryMessenger
                                                   >>  34 //
                                                   >>  35 // Author: G.Cosmo, CERN.
                                                   >>  36 //
 29 // -------------------------------------------     37 // --------------------------------------------------------------------
 30                                                    38 
 31 #include <iomanip>                                 39 #include <iomanip>
 32                                                << 
 33 #include "G4GeometryMessenger.hh"                  40 #include "G4GeometryMessenger.hh"
 34                                                    41 
 35 #include "G4TransportationManager.hh"              42 #include "G4TransportationManager.hh"
 36 #include "G4GeometryManager.hh"                    43 #include "G4GeometryManager.hh"
 37 #include "G4VPhysicalVolume.hh"                    44 #include "G4VPhysicalVolume.hh"
 38 #include "G4Navigator.hh"                          45 #include "G4Navigator.hh"
 39 #include "G4PropagatorInField.hh"              << 
 40                                                    46 
 41 #include "G4UIdirectory.hh"                        47 #include "G4UIdirectory.hh"
 42 #include "G4UIcommand.hh"                          48 #include "G4UIcommand.hh"
                                                   >>  49 #include "G4UIcmdWith3VectorAndUnit.hh"
                                                   >>  50 #include "G4UIcmdWith3Vector.hh"
 43 #include "G4UIcmdWithoutParameter.hh"              51 #include "G4UIcmdWithoutParameter.hh"
 44 #include "G4UIcmdWithABool.hh"                     52 #include "G4UIcmdWithABool.hh"
 45 #include "G4UIcmdWithAnInteger.hh"                 53 #include "G4UIcmdWithAnInteger.hh"
                                                   >>  54 #include "G4UIcmdWithADouble.hh"
 46 #include "G4UIcmdWithADoubleAndUnit.hh"            55 #include "G4UIcmdWithADoubleAndUnit.hh"
 47                                                    56 
                                                   >>  57 #include "G4GeomTestStreamLogger.hh"
 48 #include "G4GeomTestVolume.hh"                     58 #include "G4GeomTestVolume.hh"
 49                                                    59 
 50 //                                                 60 //
 51 // Constructor                                     61 // Constructor
 52 //                                                 62 //
 53 G4GeometryMessenger::G4GeometryMessenger(G4Tra     63 G4GeometryMessenger::G4GeometryMessenger(G4TransportationManager* tman)
 54   : tmanager(tman)                             <<  64   : x(0,0,0), p(0,0,1), grdRes(100,100,100), cylRes(90,50,50),
                                                   >>  65     cylfZ(0.8), cylfR(0.8), newtol(false), tol(1E-4*mm),
                                                   >>  66     recLevel(0), recDepth(-1), tmanager(tman), tlogger(0), tvolume(0)
 55 {                                                  67 {
 56   geodir = new G4UIdirectory( "/geometry/" );      68   geodir = new G4UIdirectory( "/geometry/" );
 57   geodir->SetGuidance( "Geometry control comma     69   geodir->SetGuidance( "Geometry control commands." );
 58                                                    70 
 59   //                                               71   //
 60   // Geometry navigator commands                   72   // Geometry navigator commands
 61   //                                               73   //
 62   navdir = new G4UIdirectory( "/geometry/navig     74   navdir = new G4UIdirectory( "/geometry/navigator/" );
 63   navdir->SetGuidance( "Geometry navigator con     75   navdir->SetGuidance( "Geometry navigator control setup." );
 64                                                    76 
 65   resCmd = new G4UIcmdWithoutParameter( "/geom     77   resCmd = new G4UIcmdWithoutParameter( "/geometry/navigator/reset", this );
 66   resCmd->SetGuidance( "Reset navigator and na     78   resCmd->SetGuidance( "Reset navigator and navigation history." );
 67   resCmd->SetGuidance( "NOTE: must be called o     79   resCmd->SetGuidance( "NOTE: must be called only after kernel has been" );
 68   resCmd->SetGuidance( "      initialized once     80   resCmd->SetGuidance( "      initialized once through the run manager!" );
 69   resCmd->AvailableForStates(G4State_Idle);        81   resCmd->AvailableForStates(G4State_Idle);
 70                                                    82 
 71   verbCmd = new G4UIcmdWithAnInteger( "/geomet     83   verbCmd = new G4UIcmdWithAnInteger( "/geometry/navigator/verbose", this );
 72   verbCmd->SetGuidance( "Set run-time verbosit     84   verbCmd->SetGuidance( "Set run-time verbosity for the navigator." );
 73   verbCmd->SetGuidance(" 0 : Silent (default)"     85   verbCmd->SetGuidance(" 0 : Silent (default)");
 74   verbCmd->SetGuidance(" 1 : Display volume po     86   verbCmd->SetGuidance(" 1 : Display volume positioning and step lengths");
 75   verbCmd->SetGuidance(" 2 : Display step/safe     87   verbCmd->SetGuidance(" 2 : Display step/safety info on point location");
 76   verbCmd->SetGuidance(" 3 : Display minimal s     88   verbCmd->SetGuidance(" 3 : Display minimal state at -every- step");
 77   verbCmd->SetGuidance(" 4 : Maximum verbosity     89   verbCmd->SetGuidance(" 4 : Maximum verbosity (very detailed!)");
 78   verbCmd->SetGuidance( "NOTE: this command ha     90   verbCmd->SetGuidance( "NOTE: this command has effect -only- if Geant4 has" );
 79   verbCmd->SetGuidance( "      been installed      91   verbCmd->SetGuidance( "      been installed with the G4VERBOSE flag set!" );
 80   verbCmd->SetParameterName("level",true);         92   verbCmd->SetParameterName("level",true);
 81   verbCmd->SetDefaultValue(0);                     93   verbCmd->SetDefaultValue(0);
 82   verbCmd->SetRange("level >=0 && level <=4");     94   verbCmd->SetRange("level >=0 && level <=4");
 83                                                    95 
 84   chkCmd = new G4UIcmdWithABool( "/geometry/na     96   chkCmd = new G4UIcmdWithABool( "/geometry/navigator/check_mode", this );
 85   chkCmd->SetGuidance( "Set navigator in -chec     97   chkCmd->SetGuidance( "Set navigator in -check_mode- state." );
 86   chkCmd->SetGuidance( "This will cause extra      98   chkCmd->SetGuidance( "This will cause extra checks to be applied during" );
 87   chkCmd->SetGuidance( "navigation. More stric     99   chkCmd->SetGuidance( "navigation. More strict and less tolerant conditions" );
 88   chkCmd->SetGuidance( "are applied. A run-tim    100   chkCmd->SetGuidance( "are applied. A run-time performance penalty may be" );
 89   chkCmd->SetGuidance( "observed when the -che    101   chkCmd->SetGuidance( "observed when the -check_mode- state is activated." );
 90   chkCmd->SetGuidance( "NOTE: this command has    102   chkCmd->SetGuidance( "NOTE: this command has effect -only- if Geant4 has" );
 91   chkCmd->SetGuidance( "      been installed w    103   chkCmd->SetGuidance( "      been installed with the G4VERBOSE flag set!" );
 92   chkCmd->SetParameterName("checkFlag",true);     104   chkCmd->SetParameterName("checkFlag",true);
 93   chkCmd->SetDefaultValue(false);                 105   chkCmd->SetDefaultValue(false);
 94   chkCmd->AvailableForStates(G4State_Idle);       106   chkCmd->AvailableForStates(G4State_Idle);
 95                                                   107 
 96   pchkCmd = new G4UIcmdWithABool( "/geometry/n << 
 97   pchkCmd->SetGuidance( "Set navigator verbosi << 
 98   pchkCmd->SetGuidance( "This allows one to di << 
 99   pchkCmd->SetGuidance( "navigation, when trac << 
100   pchkCmd->SetGuidance( "one artificial push a << 
101   pchkCmd->SetGuidance( "navigator. Notificati << 
102   pchkCmd->SetGuidance( "NOTE: this command ha << 
103   pchkCmd->SetGuidance( "      been installed  << 
104   pchkCmd->SetParameterName("pushFlag",true);  << 
105   pchkCmd->SetDefaultValue(true);              << 
106   pchkCmd->AvailableForStates(G4State_Idle);   << 
107                                                << 
108   //                                              108   //
109   // Geometry verification test commands          109   // Geometry verification test commands
110   //                                              110   //
111   testdir = new G4UIdirectory( "/geometry/test    111   testdir = new G4UIdirectory( "/geometry/test/" );
112   testdir->SetGuidance( "Geometry verification    112   testdir->SetGuidance( "Geometry verification control setup." );
113   testdir->SetGuidance( "Helps in detecting po    113   testdir->SetGuidance( "Helps in detecting possible overlapping regions." );
114                                                   114 
115   tolCmd = new G4UIcmdWithADoubleAndUnit( "/ge    115   tolCmd = new G4UIcmdWithADoubleAndUnit( "/geometry/test/tolerance",this );
116   tolCmd->SetGuidance( "Define tolerance (in m << 116   tolCmd->SetGuidance( "Set error tolerance value." );
117   tolCmd->SetGuidance( "should be reported. By << 117   tolCmd->SetGuidance( "Initial default value: 1E-4*mm." );
118   tolCmd->SetGuidance( "reported, i.e. toleran << 
119   tolCmd->SetParameterName( "Tolerance", true,    118   tolCmd->SetParameterName( "Tolerance", true, true );
120   tolCmd->SetDefaultValue( 0 );                << 119   tolCmd->SetDefaultValue( 1E-4 );
121   tolCmd->SetDefaultUnit( "mm" );                 120   tolCmd->SetDefaultUnit( "mm" );
122   tolCmd->SetUnitCategory( "Length" );            121   tolCmd->SetUnitCategory( "Length" );
123                                                   122 
124   verCmd = new G4UIcmdWithABool( "/geometry/te << 123   posCmd = new G4UIcmdWith3VectorAndUnit( "/geometry/test/position", this );
125   verCmd->SetGuidance( "Specify if running in  << 124   posCmd->SetGuidance( "Set starting position for the line_test." );
126   verCmd->SetGuidance( "By default verbosity i << 125   posCmd->SetParameterName( "X", "Y", "Z", true, true );
127   verCmd->SetParameterName("verbosity",true);  << 126   posCmd->SetDefaultUnit( "cm" );
128   verCmd->SetDefaultValue(true);               << 127 
129   verCmd->AvailableForStates(G4State_Idle);    << 128   dirCmd = new G4UIcmdWith3VectorAndUnit( "/geometry/test/direction", this );
130                                                << 129   dirCmd->SetGuidance( "Set momentum direction for the line_test." );
131   rslCmd = new G4UIcmdWithAnInteger( "/geometr << 130   dirCmd->SetGuidance( "Direction needs not to be a unit vector." );
132   rslCmd->SetGuidance( "Set the number of poin << 131   dirCmd->SetParameterName( "Px", "Py", "Pz", true, true );
133   rslCmd->SetGuidance( "checking overlaps." ); << 132   dirCmd->SetRange( "Px != 0 || Py != 0 || Pz != 0" );
134   rslCmd->SetParameterName("resolution",true); << 133 
135   rslCmd->SetDefaultValue(10000);              << 134   linCmd = new G4UIcmdWithABool( "/geometry/test/line_test", this );
                                                   >> 135   linCmd->SetGuidance( "Performs test along a single specified direction/position." );
                                                   >> 136   linCmd->SetGuidance( "Use position and direction commands to change default." );
                                                   >> 137   linCmd->SetGuidance( "Initial default: position(0,0,0), direction(0,0,1)." );
                                                   >> 138   linCmd->SetGuidance( "If recursion flag is set to TRUE, the intersection checks" );
                                                   >> 139   linCmd->SetGuidance( "will be performed recursively in the geometry tree." );
                                                   >> 140   linCmd->SetParameterName("recursionFlag",true);
                                                   >> 141   linCmd->SetDefaultValue(false);
                                                   >> 142   linCmd->AvailableForStates(G4State_Idle);
                                                   >> 143 
                                                   >> 144   grzCmd = new G4UIcmdWith3Vector( "/geometry/test/grid_cells", this );
                                                   >> 145   grzCmd->SetGuidance( "Define resolution of grid geometry as number of cells," );
                                                   >> 146   grzCmd->SetGuidance( "specifying them for each dimension, X, Y and Z." );
                                                   >> 147   grzCmd->SetGuidance( "Will be applied to grid_test and recursive_test commands." );
                                                   >> 148   grzCmd->SetGuidance( "Initial default values: X=100, Y=100, Z=100." );
                                                   >> 149   grzCmd->SetParameterName( "X", "Y", "Z", true, true );
                                                   >> 150   grzCmd->SetDefaultValue( G4ThreeVector(100, 100, 100) );
                                                   >> 151 
                                                   >> 152   grdCmd = new G4UIcmdWithABool( "/geometry/test/grid_test", this );
                                                   >> 153   grdCmd->SetGuidance( "Start running the default grid test." );
                                                   >> 154   grdCmd->SetGuidance( "A grid of lines parallel to a cartesian axis is used;" );
                                                   >> 155   grdCmd->SetGuidance( "By default, only direct daughters of the mother volumes are checked." );
                                                   >> 156   grdCmd->SetGuidance( "If recursion flag is set to TRUE, the intersection checks" );
                                                   >> 157   grdCmd->SetGuidance( "will be performed recursively in the geometry tree." );
                                                   >> 158   grdCmd->SetGuidance( "NOTE: the recursion may take a very long time," );
                                                   >> 159   grdCmd->SetGuidance( "      depending on the geometry complexity !");
                                                   >> 160   grdCmd->SetParameterName("recursionFlag",true);
                                                   >> 161   grdCmd->SetDefaultValue(false);
                                                   >> 162   grdCmd->AvailableForStates(G4State_Idle);
                                                   >> 163 
                                                   >> 164   cyzCmd = new G4UIcmdWith3Vector( "/geometry/test/cylinder_geometry", this );
                                                   >> 165   cyzCmd->SetGuidance( "Define details of the cylinder geometry, specifying:" );
                                                   >> 166   cyzCmd->SetGuidance( "  nPhi - number of lines per Phi" );
                                                   >> 167   cyzCmd->SetGuidance( "  nZ   - number of Z points" );
                                                   >> 168   cyzCmd->SetGuidance( "  nRho - number of Rho points" );
                                                   >> 169   cyzCmd->SetGuidance( "Will be applied to the cylinder_test command." );
                                                   >> 170   cyzCmd->SetGuidance( "Initial default values: nPhi=90, nZ=50, nRho=50." );
                                                   >> 171   cyzCmd->SetParameterName( "nPhi", "nZ", "nRho", true, true );
                                                   >> 172   cyzCmd->SetDefaultValue( G4ThreeVector(90, 50, 50) );
                                                   >> 173 
                                                   >> 174   cfzCmd = new G4UIcmdWithADouble( "/geometry/test/cylinder_scaleZ", this );
                                                   >> 175   cfzCmd->SetGuidance( "Define the resolution of the cylinder geometry, specifying" );
                                                   >> 176   cfzCmd->SetGuidance( "the fraction scale for points along Z." );
                                                   >> 177   cfzCmd->SetGuidance( "Initial default values: fracZ=0.8" );
                                                   >> 178   cfzCmd->SetParameterName("fracZ",true);
                                                   >> 179   cfzCmd->SetDefaultValue(0.8);
                                                   >> 180 
                                                   >> 181   cfrCmd = new G4UIcmdWithADouble( "/geometry/test/cylinder_scaleRho", this );
                                                   >> 182   cfrCmd->SetGuidance( "Define the resolution of the cylinder geometry, specifying" );
                                                   >> 183   cfrCmd->SetGuidance( "the fraction scale for points along Rho." );
                                                   >> 184   cfrCmd->SetGuidance( "Initial default values: fracRho=0.8" );
                                                   >> 185   cfrCmd->SetParameterName("fracRho",true);
                                                   >> 186   cfrCmd->SetDefaultValue(0.8);
                                                   >> 187 
                                                   >> 188   cylCmd = new G4UIcmdWithABool( "/geometry/test/cylinder_test", this );
                                                   >> 189   cylCmd->SetGuidance( "Start running the cylinder test." );
                                                   >> 190   cylCmd->SetGuidance( "A set of lines in a cylindrical pattern of gradually" );
                                                   >> 191   cylCmd->SetGuidance( "increasing mesh size." );
                                                   >> 192   cylCmd->SetGuidance( "By default, only direct daughters of the mother volumes are checked." );
                                                   >> 193   cylCmd->SetGuidance( "If recursion flag is set to TRUE, the intersection checks" );
                                                   >> 194   cylCmd->SetGuidance( "will be performed recursively in the geometry tree." );
                                                   >> 195   cylCmd->SetGuidance( "NOTE: the recursion may take a very long time," );
                                                   >> 196   cylCmd->SetGuidance( "      depending on the geometry complexity !");
                                                   >> 197   cylCmd->SetParameterName("recursionFlag",true);
                                                   >> 198   cylCmd->SetDefaultValue(false);
                                                   >> 199   cylCmd->AvailableForStates(G4State_Idle);
136                                                   200 
137   rcsCmd = new G4UIcmdWithAnInteger( "/geometr    201   rcsCmd = new G4UIcmdWithAnInteger( "/geometry/test/recursion_start", this );
138   rcsCmd->SetGuidance( "Set the initial level     202   rcsCmd->SetGuidance( "Set the initial level in the geometry tree for recursion." );
139   rcsCmd->SetGuidance( "recursive_test will th    203   rcsCmd->SetGuidance( "recursive_test will then start from the specified level." );
140   rcsCmd->SetParameterName("initial_level",tru    204   rcsCmd->SetParameterName("initial_level",true);
141   rcsCmd->SetDefaultValue(0);                     205   rcsCmd->SetDefaultValue(0);
142                                                   206 
143   rcdCmd = new G4UIcmdWithAnInteger( "/geometr    207   rcdCmd = new G4UIcmdWithAnInteger( "/geometry/test/recursion_depth", this );
144   rcdCmd->SetGuidance( "Set the depth in the g    208   rcdCmd->SetGuidance( "Set the depth in the geometry tree for recursion." );
145   rcdCmd->SetGuidance( "recursive_test will th    209   rcdCmd->SetGuidance( "recursive_test will then stop after reached the specified depth." );
146   rcdCmd->SetGuidance( "By default, recursion     210   rcdCmd->SetGuidance( "By default, recursion will proceed for the whole depth." );
147   rcdCmd->SetParameterName("recursion_depth",t    211   rcdCmd->SetParameterName("recursion_depth",true);
148   rcdCmd->SetDefaultValue(-1);                    212   rcdCmd->SetDefaultValue(-1);
149                                                   213 
150   errCmd = new G4UIcmdWithAnInteger( "/geometr << 214   // Obsolete verification commands ...
151   errCmd->SetGuidance( "Set the maximum number << 215 
152   errCmd->SetGuidance( "for each single volume << 216   runCmd = new G4UIcmdWithABool( "/geometry/test/run", this );
153   errCmd->SetGuidance( "Once reached the maxim << 217   runCmd->SetGuidance( "Start running the default grid test." );
154   errCmd->SetGuidance( "affecting that volume  << 218   runCmd->SetGuidance( "Same as the grid_test command." );
155   errCmd->SetParameterName("maximum_errors",tr << 219   runCmd->SetGuidance( "If recursion flag is set to TRUE, the intersection checks" );
156   errCmd->SetDefaultValue(1);                  << 220   runCmd->SetGuidance( "will be performed recursively in the geometry tree." );
157                                                << 221   runCmd->SetGuidance( "NOTE: the recursion may take a very long time," );
158   parCmd = new G4UIcmdWithABool( "/geometry/te << 222   runCmd->SetGuidance( "      depending on the geometry complexity !");
159   parCmd->SetGuidance( "Check for overlaps in  << 223   runCmd->SetParameterName("recursionFlag",true);
160   parCmd->SetGuidance( "By default, overlaps a << 224   runCmd->SetDefaultValue(false);
161   parCmd->SetParameterName("check_parallel",tr << 225   runCmd->AvailableForStates(G4State_Idle);
162   parCmd->SetDefaultValue(true);               << 226 
163                                                << 227   recCmd = new G4UIcmdWithoutParameter( "/geometry/test/recursive_test", this );
164   recCmd = new G4UIcmdWithoutParameter( "/geom << 228   recCmd->SetGuidance( "Start running the recursive grid test." );
165   recCmd->SetGuidance( "Start running the recu << 229   recCmd->SetGuidance( "A grid of lines along a cartesian axis is recursively" );
166   recCmd->SetGuidance( "Volumes are recursivel << 230   recCmd->SetGuidance( "to all daughters and daughters of daughters, etc." );
167   recCmd->SetGuidance( "for points generated o << 
168   recCmd->SetGuidance( "respective mother volu << 
169   recCmd->SetGuidance( "level, performing for  << 
170   recCmd->SetGuidance( "daughters, etc." );    << 
171   recCmd->SetGuidance( "NOTE: it may take a ve    231   recCmd->SetGuidance( "NOTE: it may take a very long time," );
172   recCmd->SetGuidance( "      depending on the    232   recCmd->SetGuidance( "      depending on the geometry complexity !");
173   recCmd->AvailableForStates(G4State_Idle);       233   recCmd->AvailableForStates(G4State_Idle);
174 }                                                 234 }
175                                                   235 
176 //                                                236 //
177 // Destructor                                     237 // Destructor
178 //                                                238 //
179 G4GeometryMessenger::~G4GeometryMessenger()       239 G4GeometryMessenger::~G4GeometryMessenger()
180 {                                                 240 {
181   delete verCmd; delete recCmd; delete rslCmd; << 241   delete linCmd; delete posCmd; delete dirCmd;
182   delete resCmd; delete rcsCmd; delete rcdCmd; << 242   delete grzCmd; delete grdCmd; delete recCmd; delete runCmd;
183   delete errCmd; delete parCmd; delete tolCmd; << 243   delete rcsCmd; delete rcdCmd;
184   delete verbCmd; delete pchkCmd; delete chkCm << 244   delete cyzCmd; delete cfzCmd; delete cfrCmd; delete cylCmd;
                                                   >> 245   delete tolCmd;
                                                   >> 246   delete resCmd; delete verbCmd; delete chkCmd;
185   delete geodir; delete navdir; delete testdir    247   delete geodir; delete navdir; delete testdir;
186   for(auto* tvolume: tvolumes) {               << 248   delete tvolume; delete tlogger;
187       delete tvolume;                          << 
188   }                                            << 
189 }                                                 249 }
190                                                   250 
191 //                                                251 //
192 // Init                                           252 // Init
193 //                                                253 //
194 void                                              254 void
195 G4GeometryMessenger::Init()                       255 G4GeometryMessenger::Init()
196 {                                                 256 {
197   // Create checker...                         << 257   // Clean old allocated loggers...
198   //                                              258   //
199   if (tvolumes.empty())                        << 259   if (tlogger) delete tlogger;
200   {                                            << 260   if (tvolume) delete tvolume;
201     // Get all world volumes                   << 261 
202     //                                         << 262   // Create a logger to send errors/output to cout
203     const auto noWorlds = tmanager->GetNoWorld << 263   //
204     const auto fWorld = tmanager->GetWorldsIte << 264   tlogger = new G4GeomTestStreamLogger(std::cout);
205     for(size_t i=0;i<noWorlds;++i)             << 265 
206     {                                          << 266   // Get the world volume
207         // Test the actual detector...         << 267   //
208         //                                     << 268   G4VPhysicalVolume* world =
209         tvolumes.push_back(new G4GeomTestVolum << 269     tmanager->GetNavigatorForTracking()->GetWorldVolume();
210     }                                          << 270 
211   }                                            << 271   // Test the actual detector...
                                                   >> 272   //
                                                   >> 273   tvolume = new G4GeomTestVolume(world, tlogger);
212 }                                                 274 }
213                                                   275 
214 //                                                276 //
215 // SetNewValue                                    277 // SetNewValue
216 //                                                278 //
217 void                                              279 void
218 G4GeometryMessenger::SetNewValue( G4UIcommand*    280 G4GeometryMessenger::SetNewValue( G4UIcommand* command, G4String newValues )
219 {                                                 281 {
220   if (command == resCmd) {                        282   if (command == resCmd) {
221     ResetNavigator();                             283     ResetNavigator();
222   }                                               284   }
223   else if (command == verbCmd) {                  285   else if (command == verbCmd) {
224     SetVerbosity( newValues );                    286     SetVerbosity( newValues );
225   }                                               287   }
226   else if (command == chkCmd) {                   288   else if (command == chkCmd) {
227     SetCheckMode( newValues );                    289     SetCheckMode( newValues );
228   }                                               290   }
229   else if (command == pchkCmd) {               << 291   else if (command == posCmd) {
230     SetPushFlag( newValues );                  << 292     x = posCmd->GetNew3VectorValue( newValues );
231   }                                               293   }
232   else if (command == tolCmd) {                << 294   else if (command == dirCmd) {
233     Init();                                    << 295     p = dirCmd->GetNew3VectorValue( newValues );
234     tol = tolCmd->GetNewDoubleValue( newValues << 296     if (p.mag() < DBL_MIN) {
235         * tolCmd->GetNewUnitValue( newValues ) << 297       G4cerr << "Please specify non-zero momentum!" << G4endl;
236     for(auto* tvolume: tvolumes)               << 298       p = G4ThreeVector(0,0,1);
237     {                                          << 
238       tvolume->SetTolerance(tol);              << 
239     }                                             299     }
240   }                                               300   }
241   else if (command == verCmd) {                << 301   else if (command == tolCmd) {
                                                   >> 302     tol = tolCmd->GetNewDoubleValue( newValues );
                                                   >> 303     newtol = true;
                                                   >> 304   }
                                                   >> 305   else if (command == linCmd) {
242     Init();                                       306     Init();
243     for(auto* tvolume: tvolumes)               << 307     if (linCmd->GetNewBoolValue( newValues ))
244     {                                          << 308       RecursiveLineTest();
245       tvolume->SetVerbosity(verCmd->GetNewBool << 309     else
246     }                                          << 310       LineTest();
247   }                                               311   }
248   else if (command == rslCmd) {                << 312   else if ((command == grdCmd) || (command == runCmd)){
249     Init();                                       313     Init();
250     for(auto* tvolume: tvolumes)               << 314     if (grdCmd->GetNewBoolValue( newValues ) || runCmd->GetNewBoolValue( newValues ))
251     {                                          << 315       RecursiveGridTest();
252       tvolume->SetResolution(rslCmd->GetNewInt << 316     else
                                                   >> 317       GridTest();
                                                   >> 318   }
                                                   >> 319   else if (command == grzCmd) {
                                                   >> 320     grdRes = grzCmd->GetNew3VectorValue( newValues );
                                                   >> 321     if (grdRes.mag() < DBL_MIN) {
                                                   >> 322       G4cerr << "Please specify non-zero resolution!" << G4endl;
                                                   >> 323       grdRes = G4ThreeVector(100,100,100);
253     }                                             324     }
254   }                                               325   }
                                                   >> 326   else if (command == cyzCmd) {
                                                   >> 327     cylRes = cyzCmd->GetNew3VectorValue( newValues );
                                                   >> 328   }
                                                   >> 329   else if (command == cfzCmd) {
                                                   >> 330     cylfZ = cfzCmd->GetNewDoubleValue( newValues );
                                                   >> 331   }
                                                   >> 332   else if (command == cfrCmd) {
                                                   >> 333     cylfR = cfrCmd->GetNewDoubleValue( newValues );
                                                   >> 334   }
255   else if (command == rcsCmd) {                   335   else if (command == rcsCmd) {
256     recLevel = rcsCmd->GetNewIntValue( newValu    336     recLevel = rcsCmd->GetNewIntValue( newValues );
257   }                                               337   }
258   else if (command == rcdCmd) {                   338   else if (command == rcdCmd) {
259     recDepth = rcdCmd->GetNewIntValue( newValu    339     recDepth = rcdCmd->GetNewIntValue( newValues );
260   }                                               340   }
261   else if (command == parCmd) {                << 341   else if (command == recCmd) {
262     checkParallelWorlds = parCmd->GetNewBoolVa << 
263   }                                            << 
264   else if (command == errCmd) {                << 
265     Init();                                       342     Init();
266     for(auto* tvolume: tvolumes)               << 343     RecursiveGridTest();
267     {                                          << 
268       tvolume->SetErrorsThreshold(errCmd->GetN << 
269     }                                          << 
270   }                                               344   }
271   else if (command == recCmd) {                << 345   else if (command == cylCmd) {
272     Init();                                       346     Init();
273     G4cout << "Running geometry overlaps check << 347     if (cylCmd->GetNewBoolValue( newValues ))
274     RecursiveOverlapTest();                    << 348       RecursiveCylinderTest();
275     G4cout << "Geometry overlaps check complet << 349     else
                                                   >> 350       CylinderTest();
276   }                                               351   }
277 }                                                 352 }
278                                                   353 
279 //                                                354 //
280 // GetCurrentValue                                355 // GetCurrentValue
281 //                                                356 //
282 G4String                                          357 G4String
283 G4GeometryMessenger::GetCurrentValue( G4UIcomm << 358 G4GeometryMessenger::GetCurrentValue(G4UIcommand* command )
284 {                                                 359 {
285   G4String cv = "";                               360   G4String cv = "";
286   if (command == tolCmd)                       << 361   if (command == posCmd) {
287   {                                            << 362     cv = posCmd->ConvertToString( x, "cm" );
                                                   >> 363   }
                                                   >> 364   else if (command == tolCmd) {
288     cv = tolCmd->ConvertToString( tol, "mm" );    365     cv = tolCmd->ConvertToString( tol, "mm" );
289   }                                               366   }
                                                   >> 367   else if (command == dirCmd) {
                                                   >> 368     cv = dirCmd->ConvertToString( p, "GeV" );
                                                   >> 369   }
290   return cv;                                      370   return cv;
291 }                                                 371 }
292                                                   372 
293 //                                                373 //
294 // CheckGeometry                                  374 // CheckGeometry
295 //                                                375 //
296 void                                              376 void
297 G4GeometryMessenger::CheckGeometry()              377 G4GeometryMessenger::CheckGeometry()
298 {                                                 378 {
299   // Verify that the geometry is closed           379   // Verify that the geometry is closed
300   //                                              380   //
301   G4GeometryManager* geomManager = G4GeometryM    381   G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
302   if (!geomManager->IsGeometryClosed())        << 382   if (!geomManager->IsGeometryClosed()) {
303   {                                            << 
304     geomManager->OpenGeometry();                  383     geomManager->OpenGeometry();
305     geomManager->CloseGeometry(true);             384     geomManager->CloseGeometry(true);
306   }                                               385   } 
307 }                                                 386 }
308                                                   387 
309 //                                                388 //
310 // ResetNavigator                                 389 // ResetNavigator
311 //                                                390 //
312 void                                              391 void
313 G4GeometryMessenger::ResetNavigator()             392 G4GeometryMessenger::ResetNavigator()
314 {                                                 393 {
315   // Close geometry and reset optimisation if     394   // Close geometry and reset optimisation if necessary
316   //                                              395   //
317   CheckGeometry();                                396   CheckGeometry();
318                                                   397 
319   // Reset navigator's state                      398   // Reset navigator's state
320   //                                              399   //
321   G4ThreeVector pt(0,0,0);                        400   G4ThreeVector pt(0,0,0);
322   G4Navigator* navigator = tmanager->GetNaviga    401   G4Navigator* navigator = tmanager->GetNavigatorForTracking();
323   navigator->LocateGlobalPointAndSetup(pt,null << 402   navigator->LocateGlobalPointAndSetup(pt,0,false);
324 }                                                 403 }
325                                                   404 
326 //                                                405 //
327 // Set navigator verbosity                        406 // Set navigator verbosity
328 //                                                407 //
329 void                                              408 void
330 G4GeometryMessenger::SetVerbosity(const G4Stri << 409 G4GeometryMessenger::SetVerbosity(G4String input)
331 {                                                 410 {
332   G4int level = verbCmd->GetNewIntValue(input)    411   G4int level = verbCmd->GetNewIntValue(input);
333   G4Navigator* navigator = tmanager->GetNaviga    412   G4Navigator* navigator = tmanager->GetNavigatorForTracking();
334   navigator->SetVerboseLevel(level);              413   navigator->SetVerboseLevel(level);
335 }                                                 414 }
336                                                   415 
337 //                                                416 //
338 // Set navigator mode                             417 // Set navigator mode
339 //                                                418 //
340 void                                              419 void
341 G4GeometryMessenger::SetCheckMode(const G4Stri << 420 G4GeometryMessenger::SetCheckMode(G4String input)
342 {                                                 421 {
343   G4bool mode = chkCmd->GetNewBoolValue(input)    422   G4bool mode = chkCmd->GetNewBoolValue(input);
344   G4Navigator* navigator = tmanager->GetNaviga    423   G4Navigator* navigator = tmanager->GetNavigatorForTracking();
345   navigator->CheckMode(mode);                     424   navigator->CheckMode(mode);
346   G4PropagatorInField* pField = tmanager->GetP << 
347   if (pField != nullptr)  { pField->CheckMode( << 
348 }                                                 425 }
349                                                   426 
350 //                                                427 //
351 // Set navigator verbosity for push notificati << 428 // LineTest
352 //                                                429 //
353 void                                              430 void
354 G4GeometryMessenger::SetPushFlag(const G4Strin << 431 G4GeometryMessenger::LineTest()
355 {                                                 432 {
356   G4bool mode = pchkCmd->GetNewBoolValue(input << 433   // Close geometry if necessary
357   G4Navigator* navigator = tmanager->GetNaviga << 434   //
358   navigator->SetPushVerbosity(mode);           << 435   CheckGeometry();
                                                   >> 436 
                                                   >> 437   // Verify if error tolerance has changed
                                                   >> 438   //
                                                   >> 439   if (newtol) tvolume->SetTolerance(tol);
                                                   >> 440 
                                                   >> 441   // Make test on single line supplied by user
                                                   >> 442   //
                                                   >> 443   tvolume->TestOneLine( x, p );
                                                   >> 444 
                                                   >> 445   // Print out any errors, if found
                                                   >> 446   //
                                                   >> 447   tvolume->ReportErrors();
359 }                                                 448 }
360                                                   449 
361 //                                                450 //
362 // Recursive Overlap Test                      << 451 // RecursiveLineTest
363 //                                                452 //
364 void                                              453 void
365 G4GeometryMessenger::RecursiveOverlapTest()    << 454 G4GeometryMessenger::RecursiveLineTest()
366 {                                                 455 {
367   // Close geometry if necessary                  456   // Close geometry if necessary
368   //                                              457   //
369   CheckGeometry();                                458   CheckGeometry();
370                                                   459 
                                                   >> 460   // Verify if error tolerance has changed
                                                   >> 461   //
                                                   >> 462   if (newtol) tvolume->SetTolerance(tol);
                                                   >> 463 
371   // Make test on single line supplied by user    464   // Make test on single line supplied by user recursively
372   //                                              465   //
373   if (checkParallelWorlds)                     << 466   tvolume->TestRecursiveLine( x, p, recLevel, recDepth );
374   {                                            << 467 
375     for(auto* tvolume: tvolumes)               << 468   // Print out any errors, if found
376     {                                          << 469   //
377       tvolume->TestRecursiveOverlap( recLevel, << 470   tvolume->ReportErrors();
378     }                                          << 471 }
379   }                                            << 472 
380   else                                         << 473 //
381   {                                            << 474 // GridTest
382     tvolumes.front()->TestRecursiveOverlap( re << 475 //
383   }                                            << 476 void
                                                   >> 477 G4GeometryMessenger::GridTest()
                                                   >> 478 {
                                                   >> 479   // Close geometry if necessary
                                                   >> 480   //
                                                   >> 481   CheckGeometry();
                                                   >> 482 
                                                   >> 483   // Verify if error tolerance has changed
                                                   >> 484   //
                                                   >> 485   if (newtol) tvolume->SetTolerance(tol);
                                                   >> 486 
                                                   >> 487   // Apply set of trajectories in a 3D grid pattern
                                                   >> 488   //
                                                   >> 489   tvolume->TestCartGridXYZ( G4int(grdRes.x()),
                                                   >> 490                             G4int(grdRes.y()),
                                                   >> 491                             G4int(grdRes.z()) );
                                                   >> 492   
                                                   >> 493   // Print out any errors, if found
                                                   >> 494   //
                                                   >> 495   tvolume->ReportErrors();
                                                   >> 496 }
                                                   >> 497 
                                                   >> 498 //
                                                   >> 499 // RecursiveGridTest
                                                   >> 500 //
                                                   >> 501 void
                                                   >> 502 G4GeometryMessenger::RecursiveGridTest()
                                                   >> 503 {
                                                   >> 504   // Close geometry if necessary
                                                   >> 505   //
                                                   >> 506   CheckGeometry();
                                                   >> 507 
                                                   >> 508   // Verify if error tolerance has changed
                                                   >> 509   //
                                                   >> 510   if (newtol) tvolume->SetTolerance(tol);
                                                   >> 511 
                                                   >> 512   // Apply set of trajectories in a 3D grid pattern recursively
                                                   >> 513   //
                                                   >> 514   tvolume->TestRecursiveCartGrid( G4int(grdRes.x()),
                                                   >> 515                                   G4int(grdRes.y()),
                                                   >> 516                                   G4int(grdRes.z()),
                                                   >> 517                                   recLevel, recDepth );
                                                   >> 518   
                                                   >> 519   // Print out any errors, if found
                                                   >> 520   //
                                                   >> 521   tvolume->ReportErrors();
                                                   >> 522 }
                                                   >> 523 
                                                   >> 524 //
                                                   >> 525 // CylinderTest
                                                   >> 526 //
                                                   >> 527 void
                                                   >> 528 G4GeometryMessenger::CylinderTest()
                                                   >> 529 {
                                                   >> 530   // Close geometry if necessary
                                                   >> 531   //
                                                   >> 532   CheckGeometry();
                                                   >> 533 
                                                   >> 534   // Verify if error tolerance has changed
                                                   >> 535   //
                                                   >> 536   if (newtol) tvolume->SetTolerance(tol);
                                                   >> 537 
                                                   >> 538   // Apply default set of lines in a cylindrical pattern of gradually
                                                   >> 539   // increasing mesh size of trajectories in a 3D grid pattern
                                                   >> 540   //
                                                   >> 541   tvolume->TestCylinder(G4int(cylRes.x()),
                                                   >> 542                         G4int(cylRes.y()),
                                                   >> 543                         G4int(cylRes.z()),
                                                   >> 544                         cylfZ, cylfR, true);
                                                   >> 545   
                                                   >> 546   // Print out any errors, if found
                                                   >> 547   //
                                                   >> 548   tvolume->ReportErrors();
                                                   >> 549 }
                                                   >> 550 
                                                   >> 551 //
                                                   >> 552 // RecursiveCylinderTest
                                                   >> 553 //
                                                   >> 554 void
                                                   >> 555 G4GeometryMessenger::RecursiveCylinderTest()
                                                   >> 556 {
                                                   >> 557   // Close geometry if necessary
                                                   >> 558   //
                                                   >> 559   CheckGeometry();
                                                   >> 560 
                                                   >> 561   // Verify if error tolerance has changed
                                                   >> 562   //
                                                   >> 563   if (newtol) tvolume->SetTolerance(tol);
                                                   >> 564 
                                                   >> 565   // Apply default set of lines in a cylindrical pattern of gradually
                                                   >> 566   // increasing mesh size of trajectories in a 3D grid pattern recursively
                                                   >> 567   //
                                                   >> 568   tvolume->TestRecursiveCylinder(G4int(cylRes.x()),
                                                   >> 569                                  G4int(cylRes.y()),
                                                   >> 570                                  G4int(cylRes.z()),
                                                   >> 571                                  cylfZ, cylfR, true,
                                                   >> 572                                  recLevel, recDepth );
                                                   >> 573   
                                                   >> 574   // Print out any errors, if found
                                                   >> 575   //
                                                   >> 576   tvolume->ReportErrors();
384 }                                                 577 }
385                                                   578