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 /* 26 /* 27 * MoleculeGunMessenger.cc 27 * MoleculeGunMessenger.cc 28 * 28 * 29 * Created on: 30 janv. 2014 29 * Created on: 30 janv. 2014 30 * Author: kara 30 * Author: kara 31 */ 31 */ 32 32 33 #include "G4MoleculeGunMessenger.hh" 33 #include "G4MoleculeGunMessenger.hh" 34 << 35 #include "G4MoleculeGun.hh" 34 #include "G4MoleculeGun.hh" >> 35 36 #include "G4Tokenizer.hh" 36 #include "G4Tokenizer.hh" >> 37 >> 38 #include "G4UIdirectory.hh" >> 39 #include "G4UIcmdWithAString.hh" >> 40 #include "G4UIcmdWithAString.hh" 37 #include "G4UIcmdWith3VectorAndUnit.hh" 41 #include "G4UIcmdWith3VectorAndUnit.hh" 38 #include "G4UIcmdWithADoubleAndUnit.hh" 42 #include "G4UIcmdWithADoubleAndUnit.hh" 39 #include "G4UIcmdWithAString.hh" << 40 #include "G4UIcmdWithAnInteger.hh" 43 #include "G4UIcmdWithAnInteger.hh" 41 #include "G4UIdirectory.hh" 44 #include "G4UIdirectory.hh" 42 45 43 //-------------------------------------------- << 46 G4MoleculeGunMessenger::G4MoleculeGunMessenger() 44 << 45 G4MoleculeGunMessenger::G4MoleculeGunMessenger << 46 G4UImessenger("/chem/gun/", "") << 47 { 47 { 48 fpGunNewGunType = new G4UIcmdWithAString("/c << 48 fpGunDir = new G4UIdirectory("/process/em/dna/chem/gun/"); >> 49 fpGunNewGunType = new G4UIcmdWithAString("/process/em/dna/chem/gun/newType", 49 thi 50 this); 50 fpMoleculeGun = gun; << 51 } 51 } 52 52 53 //-------------------------------------------- << 54 << 55 G4MoleculeGunMessenger::~G4MoleculeGunMessenge 53 G4MoleculeGunMessenger::~G4MoleculeGunMessenger() 56 { 54 { 57 delete fpGunNewGunType; << 55 if (fpGunDir) delete fpGunDir; >> 56 if (fpGunNewGunType) delete fpGunNewGunType; 58 } 57 } 59 58 60 //-------------------------------------------- << 61 << 62 G4String G4MoleculeGunMessenger::GetCurrentVal 59 G4String G4MoleculeGunMessenger::GetCurrentValue(G4UIcommand* /*command*/) 63 { 60 { 64 return ""; 61 return ""; 65 } 62 } 66 63 67 //-------------------------------------------- << 64 G4MoleculeGunMessenger::MultipleGun* G4MoleculeGunMessenger::CreateNewType(const G4String& name) >> 65 { >> 66 MultipleGun* multiGun = new MultipleGun(name, this); >> 67 fMultipleGun.push_back(multiGun); >> 68 return multiGun; >> 69 } 68 70 69 void G4MoleculeGunMessenger::SetNewValue(G4UIc 71 void G4MoleculeGunMessenger::SetNewValue(G4UIcommand* command, 70 G4Str 72 G4String newValue) 71 { 73 { 72 if (command == fpGunNewGunType) 74 if (command == fpGunNewGunType) 73 { 75 { 74 std::istringstream iss (newValue); << 76 CreateNewType(newValue); 75 << 76 G4String shootName; << 77 iss >> shootName; << 78 << 79 G4String shootType; << 80 iss >> shootType; << 81 << 82 if(shootType.empty() || shootType.empty()) << 83 { << 84 CreateNewType<G4Track>(shootName); << 85 } << 86 else << 87 { << 88 CreateNewType<G4ContinuousMedium>(shootN << 89 } << 90 } 77 } 91 } 78 } 92 79 93 //-------------------------------------------- << 80 G4MoleculeGunMessenger::MultipleGun::MultipleGun(const G4String& name, 94 << 81 G4MoleculeGunMessenger*) 95 G4MoleculeShootMessenger::G4MoleculeShootMesse << 96 << 97 << 98 : fpShoot(std::move(shoot)) << 99 { 82 { 100 G4String dir("/chem/gun/"); << 83 G4String dir("/process/em/dna/chem/gun/"); 101 dir += name; 84 dir += name; 102 CreateDirectory(dir, ""); << 85 fpGunType = new G4UIdirectory(name); 103 86 104 G4String tmp = dir; 87 G4String tmp = dir; 105 tmp += "/species"; << 88 tmp += "/moleculeModel"; 106 fpGunSpecies = new G4UIcmdWithAString(tmp, t << 89 fpGunMoleculeModel = new G4UIcmdWithAString(tmp, this); 107 << 108 tmp = dir; 90 tmp = dir; 109 tmp += "/position"; 91 tmp += "/position"; 110 fpGunPosition = new G4UIcmdWith3VectorAndUni 92 fpGunPosition = new G4UIcmdWith3VectorAndUnit(tmp, this); 111 << 112 tmp = dir; 93 tmp = dir; 113 tmp += "/time"; 94 tmp += "/time"; 114 fpGunTime = new G4UIcmdWithADoubleAndUnit(tm 95 fpGunTime = new G4UIcmdWithADoubleAndUnit(tmp, this); 115 << 116 tmp = dir; 96 tmp = dir; 117 tmp += "/number"; 97 tmp += "/number"; 118 fpGunN = new G4UIcmdWithAnInteger(tmp, this) 98 fpGunN = new G4UIcmdWithAnInteger(tmp, this); 119 99 120 tmp = dir; << 100 fMoleculeName = ""; 121 tmp += "/rndmPosition"; << 101 fTime = 0; 122 fpGunRdnmPosition = new G4UIcmdWith3VectorAn << 102 fNumber = 0; 123 << 124 tmp = std::move(dir); << 125 tmp += "/type"; << 126 fpGunType = new G4UIcmdWithAString(tmp, this << 127 << 128 // fpShoot.reset(new TG4MoleculeShoot<G4Track << 129 } 103 } 130 104 131 //-------------------------------------------- << 105 G4MoleculeGunMessenger::MultipleGun::~MultipleGun() 132 << 133 G4MoleculeShootMessenger::~G4MoleculeShootMess << 134 { 106 { 135 delete fpGunSpecies; << 107 if (fpGunMoleculeModel) delete fpGunMoleculeModel; 136 delete fpGunPosition; << 108 if (fpGunPosition) delete fpGunPosition; 137 delete fpGunTime; << 109 if (fpGunTime) delete fpGunTime; 138 delete fpGunN; << 110 if (fpGunN) delete fpGunN; 139 } 111 } 140 112 141 //-------------------------------------------- << 113 void G4MoleculeGunMessenger::MultipleGun::SetNewValue(G4UIcommand* command, 142 << 114 G4String newValue) 143 void G4MoleculeShootMessenger::SetNewValue(G4U << 144 { 115 { 145 if (command == fpGunSpecies) << 116 >> 117 if (command == fpGunMoleculeModel) 146 { 118 { 147 fpShoot->fMoleculeName = newValue; << 119 fMoleculeName = newValue; 148 } 120 } 149 else if (command == fpGunPosition) 121 else if (command == fpGunPosition) 150 { 122 { 151 fpShoot->fPosition = fpGunPosition->GetNew << 123 fPosition = fpGunPosition->GetNew3VectorValue(newValue); 152 } << 153 else if(command == fpGunRdnmPosition) << 154 { << 155 fpShoot->fBoxSize = new G4ThreeVector(fpGu << 156 } 124 } 157 else if (command == fpGunTime) 125 else if (command == fpGunTime) 158 { 126 { 159 fpShoot->fTime = fpGunTime->GetNewDoubleVa << 127 fTime = fpGunTime->GetNewDoubleValue(newValue); 160 } 128 } 161 else if (command == fpGunN) 129 else if (command == fpGunN) 162 { 130 { 163 fpShoot->fNumber = fpGunN->GetNewIntValue( << 131 fNumber = fpGunN->GetNewIntValue(newValue); 164 } << 165 else if (command == fpGunType) << 166 { << 167 if(newValue == "CM") << 168 { << 169 // G4cout << "**** Change type" << G4endl << 170 // TG4MoleculeShoot<G4ContinuousMedium>* << 171 // fpShoot.reset(casted); << 172 fpShoot = fpShoot.get()->ChangeType<G4Co << 173 } << 174 } 132 } 175 } 133 } 176 134 177 //-------------------------------------------- << 135 G4String G4MoleculeGunMessenger::MultipleGun::GetCurrentValue(G4UIcommand* command) 178 << 179 G4String G4MoleculeShootMessenger::GetCurrentV << 180 { 136 { 181 if (command == fpGunSpecies) << 137 182 { << 138 if (command == fpGunMoleculeModel) 183 return fpShoot->fMoleculeName; << 184 } << 185 if (command == fpGunPosition) << 186 { 139 { 187 return fpGunPosition->ConvertToStringWithB << 140 return fMoleculeName; 188 } 141 } 189 if (command == fpGunRdnmPosition) << 142 else if (command == fpGunPosition) 190 { 143 { 191 if(fpShoot->fBoxSize != nullptr) << 144 return fpGunPosition->ConvertToStringWithBestUnit(fPosition); 192 { << 193 return fpGunRdnmPosition->ConvertToStrin << 194 } << 195 return fpGunRdnmPosition->ConvertToStringW << 196 } 145 } 197 if (command == fpGunTime) << 146 else if (command == fpGunTime) 198 { 147 { 199 return fpGunTime->ConvertToStringWithBestU << 148 return fpGunTime->ConvertToStringWithBestUnit(fTime); 200 } 149 } 201 if (command == fpGunN) << 150 else if (command == fpGunN) 202 { 151 { 203 return fpGunN->ConvertToString(fpShoot->fN << 152 return fpGunN->ConvertToString(fNumber); 204 } 153 } 205 return ""; 154 return ""; 206 } 155 } 207 156 208 //-------------------------------------------- << 157 void G4MoleculeGunMessenger::DefineTracks(G4MoleculeGun* gun) >> 158 { >> 159 for (size_t i = 0; i < fMultipleGun.size(); i++) >> 160 { >> 161 fMultipleGun[i]->DefineTracks(gun); >> 162 } >> 163 } 209 164 >> 165 void G4MoleculeGunMessenger::MultipleGun::DefineTracks(G4MoleculeGun* gun) >> 166 { >> 167 gun->AddNMolecules(fNumber, fMoleculeName, fPosition, fTime); >> 168 } 210 169