Geant4 Cross Reference |
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 // Previous authors: G. Guerrieri, S. Guatelli << 26 // Authors: S. Guatelli and M. G. Pia, INFN Genova, Italy 27 // Authors (since 2007): S. Guatelli, Universi << 27 // >> 28 // Based on code developed by the undergraduate student G. Guerrieri >> 29 // Note: this is a preliminary beta-version of the code; an improved >> 30 // version will be distributed in the next Geant4 public release, compliant >> 31 // with the design in a forthcoming publication, and subject to a >> 32 // design and code review. 28 // 33 // 29 #include "G4HumanPhantomMessenger.hh" 34 #include "G4HumanPhantomMessenger.hh" 30 #include "G4HumanPhantomConstruction.hh" 35 #include "G4HumanPhantomConstruction.hh" 31 36 32 #include "G4UIdirectory.hh" 37 #include "G4UIdirectory.hh" 33 #include "G4UIcmdWithAString.hh" 38 #include "G4UIcmdWithAString.hh" 34 #include "G4UIcmdWithoutParameter.hh" 39 #include "G4UIcmdWithoutParameter.hh" 35 40 36 #include "globals.hh" 41 #include "globals.hh" 37 42 38 #include "G4RunManager.hh" 43 #include "G4RunManager.hh" 39 44 40 G4HumanPhantomMessenger::G4HumanPhantomMesseng 45 G4HumanPhantomMessenger::G4HumanPhantomMessenger(G4HumanPhantomConstruction* myUsrPhtm) 41 :fUserPhantom(myUsrPhtm),fBps(false) << 46 :myUserPhantom(myUsrPhtm),bps(false) 42 { 47 { 43 fPhantomDir = new G4UIdirectory("/phantom/") << 48 phantomDir = new G4UIdirectory("/phantom/"); 44 fPhantomDir->SetGuidance("Set Your Phantom." << 49 phantomDir->SetGuidance("Set Your Phantom."); 45 50 46 fDir = new G4UIdirectory("/bodypart/"); << 51 bpDir = new G4UIdirectory("/bodypart/"); 47 fDir->SetGuidance("Add Body Part to Phantom" << 52 bpDir->SetGuidance("Add Body Part to Phantom"); 48 53 49 fModelCmd = new G4UIcmdWithAString("/phantom << 54 cleanCmd = new G4UIcmdWithoutParameter("/phantom/startNewPhantom",this); 50 fModelCmd->SetGuidance("Set sex of Phantom: << 55 cleanCmd->SetGuidance("Start a New Phantom and clean previous one."); 51 fModelCmd->SetParameterName("phantomModel",t << 56 cleanCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 52 fModelCmd->SetDefaultValue("MIRD"); << 57 53 fModelCmd->SetCandidates("MIRD ORNLFemale OR << 58 modelCmd = new G4UIcmdWithAString("/phantom/setPhantomModel",this); 54 fModelCmd->AvailableForStates(G4State_PreIni << 59 modelCmd->SetGuidance("Set sex of Phantom: MIRD, ORNL or MIX."); 55 << 60 modelCmd->SetParameterName("phantomModel",true); 56 fSexCmd = new G4UIcmdWithAString("/phantom/s << 61 modelCmd->SetDefaultValue("MIRD"); 57 fSexCmd->SetGuidance("Set sex of Phantom: Ma << 62 modelCmd->SetCandidates("MIRD ORNL MIX"); 58 fSexCmd->SetParameterName("phantomSex",true) << 63 modelCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 59 fSexCmd->SetDefaultValue("Female"); << 64 60 fSexCmd->SetCandidates("Male Female"); << 65 sexCmd = new G4UIcmdWithAString("/phantom/setPhantomSex",this); 61 fSexCmd->AvailableForStates(G4State_PreInit, << 66 sexCmd->SetGuidance("Set sex of Phantom: Male or Female."); >> 67 sexCmd->SetParameterName("phantomSex",true); >> 68 sexCmd->SetDefaultValue("Female"); >> 69 sexCmd->SetCandidates("Male Female"); >> 70 sexCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 62 71 63 fBodypartCmd = new G4UIcmdWithAString("/body << 72 bodypartCmd = new G4UIcmdWithAString("/bodypart/addBodyPart",this); 64 fBodypartCmd->SetGuidance("Add a Body Part t << 73 bodypartCmd->SetGuidance("Add a Body Part to Phantom"); 65 fBodypartCmd->SetParameterName("bpName",true << 74 bodypartCmd->SetParameterName("bpName",true); 66 fBodypartCmd->AvailableForStates(G4State_Pre << 75 bodypartCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 67 76 68 fEndCmd = new G4UIcmdWithoutParameter("/phan << 77 endCmd = new G4UIcmdWithoutParameter("/phantom/buildNewPhantom",this); 69 fEndCmd->SetGuidance("Build your Phantom."); << 78 endCmd->SetGuidance("Build your Phantom."); 70 fEndCmd->AvailableForStates(G4State_PreInit, << 79 endCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 80 71 } 81 } 72 82 73 G4HumanPhantomMessenger::~G4HumanPhantomMessen 83 G4HumanPhantomMessenger::~G4HumanPhantomMessenger() 74 { 84 { 75 delete fModelCmd; << 85 delete cleanCmd; 76 delete fSexCmd; << 86 delete modelCmd; 77 delete fBodypartCmd; << 87 delete sexCmd; 78 delete fEndCmd; << 88 delete bodypartCmd; 79 delete fPhantomDir; << 89 delete endCmd; 80 delete fDir; << 90 delete phantomDir; >> 91 delete bpDir; 81 } 92 } 82 93 83 void G4HumanPhantomMessenger::SetNewValue(G4UI 94 void G4HumanPhantomMessenger::SetNewValue(G4UIcommand* command,G4String newValue){ 84 << 95 if( command == cleanCmd ) 85 if( command == fModelCmd ) << 96 { >> 97 myUserPhantom->CleanPhantom(); >> 98 } >> 99 if( command == modelCmd ) 86 { 100 { 87 fUserPhantom->SetPhantomModel(newValue); << 101 myUserPhantom->SetPhantomModel(newValue); 88 } 102 } 89 if( command == fSexCmd ) << 103 if( command == sexCmd ) 90 { 104 { 91 fUserPhantom->SetPhantomSex(newValue); << 105 myUserPhantom->SetPhantomSex(newValue); 92 } 106 } 93 if( command == fBodypartCmd ) << 107 if( command == bodypartCmd ) 94 { 108 { 95 AddBodyPart(newValue); 109 AddBodyPart(newValue); 96 } 110 } 97 if( command == fEndCmd ) << 111 if( command == endCmd ) 98 { 112 { 99 G4cout << 113 G4cout << 100 " ****************>>>> NEW PHANTOM CONSTRUCT 114 " ****************>>>> NEW PHANTOM CONSTRUCTION <<<<***************** " 101 << G4endl; 115 << G4endl; >> 116 >> 117 //myUserPhantom->UpdatePhantom(); >> 118 >> 119 //G4RunManager::GetRunManager()->Initialize(); 102 } 120 } 103 } 121 } 104 122 105 void G4HumanPhantomMessenger::AddBodyPart(G4S 123 void G4HumanPhantomMessenger::AddBodyPart(G4String newBodyPartSensitivity) 106 { 124 { >> 125 107 char* str = new char[newBodyPartSensitivity. 126 char* str = new char[newBodyPartSensitivity.length()+1]; 108 127 109 strcpy(str, newBodyPartSensitivity.c_str()); 128 strcpy(str, newBodyPartSensitivity.c_str()); 110 129 111 std::string bpart = strtok(str," "); << 130 std::string bodypart = strtok(str," "); 112 131 113 std::string sensitivity = strtok(nullptr," " << 132 std::string sensitivity = strtok(NULL," "); 114 133 115 if(sensitivity=="yes"){ 134 if(sensitivity=="yes"){ 116 fBps=true; << 135 bps=true; 117 }else{ 136 }else{ 118 fBps=false; << 137 bps=false; 119 } 138 } 120 139 121 G4cout << " >>> Body Part = " << bpart << "\ << 140 G4cout << " >>> Body Part = " << bodypart << "\n" 122 << " >>> Sensitivity = " << sensitivity << 141 << " >>> Sensitivity = " << sensitivity << G4endl; 123 142 124 fUserPhantom->SetBodyPartSensitivity(bpart,f << 143 myUserPhantom->SetBodyPartSensitivity(bodypart,bps); 125 } 144 } 126 145 127 146