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.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 /examples/advanced/hadrontherapy/src/HadrontherapyDetectorMessenger.cc (Version 11.3.0) and /examples/advanced/hadrontherapy/src/HadrontherapyDetectorMessenger.cc (Version 10.1.p1)


  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 // Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request 
                                                   >>  26 // the *COMPLETE* version of this program, together with its documentation;
                                                   >>  27 // Hadrontherapy (both basic and full version) are supported by the Italian INFN
                                                   >>  28 // Institute in the framework of the MC-INFN Group
 25 //                                                 29 //
 26 // Hadrontherapy advanced example for Geant4   << 
 27 // See more at: https://twiki.cern.ch/twiki/bi << 
 28                                                    30 
 29 #include "HadrontherapyDetectorMessenger.hh"       31 #include "HadrontherapyDetectorMessenger.hh"
 30 #include "HadrontherapyDetectorConstruction.hh     32 #include "HadrontherapyDetectorConstruction.hh"
 31 #include "G4UIdirectory.hh"                        33 #include "G4UIdirectory.hh"
 32 #include "G4UIcmdWith3VectorAndUnit.hh"            34 #include "G4UIcmdWith3VectorAndUnit.hh"
 33 #include "G4UIcmdWithoutParameter.hh"              35 #include "G4UIcmdWithoutParameter.hh"
 34 #include "G4UIcmdWithAString.hh"                   36 #include "G4UIcmdWithAString.hh"
 35 #include "G4SystemOfUnits.hh"                      37 #include "G4SystemOfUnits.hh"
 36 #include "G4UIcmdWithABool.hh"                 <<  38 
 37                                                    39 
 38 //////////////////////////////////////////////     40 /////////////////////////////////////////////////////////////////////////////
 39 HadrontherapyDetectorMessenger::HadrontherapyD     41 HadrontherapyDetectorMessenger::HadrontherapyDetectorMessenger(HadrontherapyDetectorConstruction* detector)
 40 :hadrontherapyDetector(detector)               <<  42   :hadrontherapyDetector(detector)
 41 {                                                  43 {
 42     // Change Phantom size                         44     // Change Phantom size
 43     changeThePhantomDir = new G4UIdirectory("/     45     changeThePhantomDir = new G4UIdirectory("/changePhantom/");
 44     changeThePhantomDir -> SetGuidance("Comman     46     changeThePhantomDir -> SetGuidance("Command to change the Phantom Size/position");
 45     changeThePhantomSizeCmd = new G4UIcmdWith3     47     changeThePhantomSizeCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/size", this);
 46     changeThePhantomSizeCmd -> SetGuidance("In     48     changeThePhantomSizeCmd -> SetGuidance("Insert sizes X Y and Z"
 47                                            "\n <<  49                                      "\n   0 or negative values mean <<Don't change it!>>");
 48     changeThePhantomSizeCmd -> SetParameterNam <<  50     changeThePhantomSizeCmd -> SetParameterName("PhantomSizeAlongX", 
 49                                                <<  51             "PhantomSizeAlongY", 
 50                                                <<  52             "PhantomSizeAlongZ", false);
 51     changeThePhantomSizeCmd -> SetDefaultUnit(     53     changeThePhantomSizeCmd -> SetDefaultUnit("mm");
 52     changeThePhantomSizeCmd -> SetUnitCandidat <<  54     changeThePhantomSizeCmd -> SetUnitCandidates("nm um mm cm"); 
 53     changeThePhantomSizeCmd -> AvailableForSta     55     changeThePhantomSizeCmd -> AvailableForStates(G4State_Idle);
 54                                                <<  56 
 55                                                <<  57 
 56     // Change Phantom material                 <<  58     // Change Phantom material 
 57     changeThePhantomMaterialCmd = new G4UIcmdW     59     changeThePhantomMaterialCmd = new G4UIcmdWithAString("/changePhantom/material", this);
 58     changeThePhantomMaterialCmd -> SetGuidance <<  60     changeThePhantomMaterialCmd -> SetGuidance("Change the Phantom and the detector material"); 
 59     changeThePhantomMaterialCmd -> SetParamete     61     changeThePhantomMaterialCmd -> SetParameterName("PhantomMaterial", false);
 60     changeThePhantomMaterialCmd -> SetDefaultV     62     changeThePhantomMaterialCmd -> SetDefaultValue("G4_WATER");
 61     changeThePhantomMaterialCmd -> AvailableFo     63     changeThePhantomMaterialCmd -> AvailableForStates(G4State_Idle);
 62                                                <<  64 
 63     // Change Phantom position                     65     // Change Phantom position
 64     changeThePhantomPositionCmd = new G4UIcmdW     66     changeThePhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/position", this);
 65     changeThePhantomPositionCmd -> SetGuidance     67     changeThePhantomPositionCmd -> SetGuidance("Insert X Y and Z dimensions for the position of the center of the Phantom"
 66                                                <<  68             " respect to that of the \"World\""); 
 67     changeThePhantomPositionCmd -> SetParamete <<  69     changeThePhantomPositionCmd -> SetParameterName("PositionAlongX", 
 68                                                <<  70                 "PositionAlongY", 
 69                                                <<  71                 "PositionAlongZ", false);
 70     changeThePhantomPositionCmd -> SetDefaultU     72     changeThePhantomPositionCmd -> SetDefaultUnit("mm");
 71     changeThePhantomPositionCmd -> SetUnitCand <<  73     changeThePhantomPositionCmd -> SetUnitCandidates("um mm cm m"); 
 72     changeThePhantomPositionCmd -> AvailableFo     74     changeThePhantomPositionCmd -> AvailableForStates(G4State_Idle);
 73                                                <<  75 
 74                                                <<  76 
 75     updateCmd = new G4UIcmdWithoutParameter("/     77     updateCmd = new G4UIcmdWithoutParameter("/changePhantom/update",this);
 76     updateCmd->SetGuidance("Update Phantom/Det     78     updateCmd->SetGuidance("Update Phantom/Detector geometry.");
 77     updateCmd->SetGuidance("This command MUST      79     updateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
 78     updateCmd->SetGuidance("if you changed geo     80     updateCmd->SetGuidance("if you changed geometrical value(s).");
 79     updateCmd->AvailableForStates(G4State_Idle     81     updateCmd->AvailableForStates(G4State_Idle);
 80                                                <<  82 
 81     //  Change detector size                       83     //  Change detector size
 82     changeTheDetectorDir = new G4UIdirectory("     84     changeTheDetectorDir = new G4UIdirectory("/changeDetector/");
 83     changeTheDetectorDir -> SetGuidance("Comma     85     changeTheDetectorDir -> SetGuidance("Command to change the Detector's Size/position/Voxels");
 84                                                    86     
 85     changeTheDetectorSizeCmd = new G4UIcmdWith     87     changeTheDetectorSizeCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/size",this);
 86     changeTheDetectorSizeCmd -> SetGuidance("I     88     changeTheDetectorSizeCmd -> SetGuidance("Insert sizes for X Y and Z dimensions of the Detector"
 87                                             "\ <<  89               "\n   0 or negative values mean <<Don't change it>>");
 88     changeTheDetectorSizeCmd -> SetParameterNa     90     changeTheDetectorSizeCmd -> SetParameterName("DetectorSizeAlongX", "DetectorSizeAlongY", "DetectorSizeAlongZ", false);
 89     changeTheDetectorSizeCmd -> SetDefaultUnit     91     changeTheDetectorSizeCmd -> SetDefaultUnit("mm");
 90     changeTheDetectorSizeCmd -> SetUnitCandida <<  92     changeTheDetectorSizeCmd -> SetUnitCandidates("nm um mm cm"); 
 91     changeTheDetectorSizeCmd -> AvailableForSt     93     changeTheDetectorSizeCmd -> AvailableForStates(G4State_Idle);
 92                                                <<  94 
 93     //  Change the detector to phantom displac     95     //  Change the detector to phantom displacement
 94     changeTheDetectorToPhantomPositionCmd = ne     96     changeTheDetectorToPhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/displacement",this);
 95     changeTheDetectorToPhantomPositionCmd -> S     97     changeTheDetectorToPhantomPositionCmd -> SetGuidance("Insert X Y and Z displacements between Detector and Phantom"
 96                                                <<  98                                                    "\nNegative values mean <<Don't change it!>>"); 
 97     changeTheDetectorToPhantomPositionCmd -> S     99     changeTheDetectorToPhantomPositionCmd -> SetParameterName("DisplacementAlongX",
 98                                                << 100                     "DisplacementAlongY", 
 99                                                << 101                     "DisplacementAlongZ", false);
100     changeTheDetectorToPhantomPositionCmd -> S    102     changeTheDetectorToPhantomPositionCmd -> SetDefaultUnit("mm");
101     changeTheDetectorToPhantomPositionCmd -> S << 103     changeTheDetectorToPhantomPositionCmd -> SetUnitCandidates("nm um mm cm"); 
102     changeTheDetectorToPhantomPositionCmd -> A    104     changeTheDetectorToPhantomPositionCmd -> AvailableForStates(G4State_Idle);
103                                                   105     
104     // Change voxels by its size                  106     // Change voxels by its size
105     changeTheDetectorVoxelCmd = new G4UIcmdWit    107     changeTheDetectorVoxelCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/voxelSize",this);
106     changeTheDetectorVoxelCmd -> SetGuidance("    108     changeTheDetectorVoxelCmd -> SetGuidance("Insert Voxel sizes for X Y and Z dimensions"
107                                              " << 109                                  "\n   0 or negative values mean <<Don't change it!>>");
108     changeTheDetectorVoxelCmd -> SetParameterN    110     changeTheDetectorVoxelCmd -> SetParameterName("VoxelSizeAlongX", "VoxelSizeAlongY", "VoxelSizeAlongZ", false);
109     changeTheDetectorVoxelCmd -> SetDefaultUni    111     changeTheDetectorVoxelCmd -> SetDefaultUnit("mm");
110     changeTheDetectorVoxelCmd -> SetUnitCandid    112     changeTheDetectorVoxelCmd -> SetUnitCandidates("nm um mm cm");
111     changeTheDetectorVoxelCmd -> AvailableForS    113     changeTheDetectorVoxelCmd -> AvailableForStates(G4State_Idle);
112                                                << 114 
113                                                << 
114     changeTheSource = new G4UIdirectory("/chan << 
115     changeTheSource -> SetGuidance("Command to << 
116                                                << 
117                                                << 
118                                                << 
119                                                << 
120     ////////////////////////////////////////// << 
121                                                << 
122     VirtualLayer = new G4UIcmdWithABool("/chan << 
123     VirtualLayer -> SetParameterName("VirtualL << 
124     VirtualLayer -> SetDefaultValue("false");  << 
125     VirtualLayer -> SetGuidance("Set if you wa << 
126                                 "\n[usage]: /c << 
127     VirtualLayer -> AvailableForStates(G4State << 
128                                                << 
129                                                << 
130     VirtualLayerPosition = new G4UIcmdWith3Vec << 
131     VirtualLayerPosition -> SetGuidance("Inser << 
132                                         " resp << 
133     VirtualLayerPosition -> SetParameterName(" << 
134                                              " << 
135                                              " << 
136                                                << 
137     VirtualLayerPosition -> SetDefaultUnit("cm << 
138     VirtualLayerPosition -> SetUnitCandidates( << 
139     VirtualLayerPosition -> AvailableForStates << 
140                                                << 
141                                                << 
142                                                << 
143 }                                                 115 }
144                                                   116 
145 //////////////////////////////////////////////    117 /////////////////////////////////////////////////////////////////////////////
146 HadrontherapyDetectorMessenger::~Hadrontherapy    118 HadrontherapyDetectorMessenger::~HadrontherapyDetectorMessenger()
147 {                                                 119 {
148     delete changeThePhantomDir;                << 120     delete changeThePhantomDir; 
149     delete changeThePhantomSizeCmd;            << 121     delete changeThePhantomSizeCmd; 
150     delete changeThePhantomPositionCmd;        << 122     delete changeThePhantomPositionCmd; 
151     delete changeThePhantomMaterialCmd;        << 123     delete changeThePhantomMaterialCmd; 
152     delete updateCmd;                             124     delete updateCmd;
153     delete changeTheDetectorDir;               << 125     delete changeTheDetectorDir; 
154     delete changeTheDetectorSizeCmd;           << 126     delete changeTheDetectorSizeCmd; 
155     delete changeTheDetectorToPhantomPositionC << 127     delete changeTheDetectorToPhantomPositionCmd; 
156     delete changeTheDetectorVoxelCmd;             128     delete changeTheDetectorVoxelCmd;
157     delete VirtualLayer;                       << 
158     delete VirtualLayerPosition;               << 
159 }                                                 129 }
160                                                   130 
161 //////////////////////////////////////////////    131 /////////////////////////////////////////////////////////////////////////////
162 void HadrontherapyDetectorMessenger::SetNewVal    132 void HadrontherapyDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
163 {                                                 133 {
164                                                << 134   
165     if( command == changeThePhantomSizeCmd)    << 135   if( command == changeThePhantomSizeCmd)
166     {                                          << 
167         G4ThreeVector size = changeThePhantomS << 
168         hadrontherapyDetector -> SetPhantomSiz << 
169     }                                          << 
170     else if (command == changeThePhantomPositi << 
171     {                                          << 
172                                                << 
173         G4ThreeVector size = changeThePhantomP << 
174         hadrontherapyDetector -> SetPhantomPos << 
175     }                                          << 
176     else if (command == changeThePhantomMateri << 
177     {                                             136     {
178         hadrontherapyDetector -> SetPhantomMat << 137   G4ThreeVector size = changeThePhantomSizeCmd -> GetNew3VectorValue(newValue);
                                                   >> 138   hadrontherapyDetector -> SetPhantomSize(size.getX(),size.getY(),size.getZ());
179     }                                             139     }
180     else if (command == changeTheDetectorSizeC << 140   else if (command == changeThePhantomPositionCmd )
181     {                                          << 141   {
182         G4ThreeVector size = changeTheDetector << 142    G4ThreeVector size = changeThePhantomPositionCmd -> GetNew3VectorValue(newValue);
                                                   >> 143          hadrontherapyDetector -> SetPhantomPosition(size);
                                                   >> 144   }
                                                   >> 145   else if (command == changeThePhantomMaterialCmd)
                                                   >> 146   {
                                                   >> 147       hadrontherapyDetector -> SetPhantomMaterial(newValue);
                                                   >> 148   }
                                                   >> 149   else if (command == changeTheDetectorSizeCmd)
                                                   >> 150   {
                                                   >> 151   G4ThreeVector size = changeTheDetectorSizeCmd  -> GetNew3VectorValue(newValue);
183         hadrontherapyDetector -> SetDetectorSi    152         hadrontherapyDetector -> SetDetectorSize(size.getX(),size.getY(),size.getZ());
184     }                                          << 153   }
185     else if (command == changeTheDetectorToPha << 154   else if (command == changeTheDetectorToPhantomPositionCmd)
186     {                                          << 155   {
187         G4ThreeVector size = changeTheDetector << 156   G4ThreeVector size = changeTheDetectorToPhantomPositionCmd-> GetNew3VectorValue(newValue);
188         hadrontherapyDetector -> SetDetectorTo    157         hadrontherapyDetector -> SetDetectorToPhantomPosition(size);
189                                                << 158   }
190     }                                          << 159   else if (command == changeTheDetectorVoxelCmd)
191     else if (command == changeTheDetectorVoxel << 160   {
192     {                                          << 161   G4ThreeVector size = changeTheDetectorVoxelCmd  -> GetNew3VectorValue(newValue);
193         G4ThreeVector size = changeTheDetector << 
194         hadrontherapyDetector -> SetVoxelSize(    162         hadrontherapyDetector -> SetVoxelSize(size.getX(),size.getY(),size.getZ());
195     }                                          << 163   }
196     else if (command == updateCmd)             << 164   else if (command == updateCmd)
197     {                                          << 165   {
198         hadrontherapyDetector -> UpdateGeometr << 166       hadrontherapyDetector -> UpdateGeometry();
199     }                                          << 167   }
200                                                << 
201     else if(command == VirtualLayer)           << 
202     {                                          << 
203         hadrontherapyDetector->VirtualLayer(Vi << 
204     }                                          << 
205     else if(command == VirtualLayerPosition)   << 
206     {                                          << 
207         G4ThreeVector size = VirtualLayerPosit << 
208                                                << 
209         hadrontherapyDetector -> SetVirtualLay << 
210     }                                          << 
211                                                << 
212 }                                                 168 }
213                                                   169