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 // G4tgrLineProcessor 26 // G4tgrLineProcessor 27 // 27 // 28 // Author: P.Arce, CIEMAT (November 2007) 28 // Author: P.Arce, CIEMAT (November 2007) 29 // ------------------------------------------- 29 // -------------------------------------------------------------------- 30 30 31 #include "G4tgrLineProcessor.hh" 31 #include "G4tgrLineProcessor.hh" 32 32 33 #include "G4SystemOfUnits.hh" 33 #include "G4SystemOfUnits.hh" 34 #include "G4tgrParameterMgr.hh" 34 #include "G4tgrParameterMgr.hh" 35 #include "G4tgrFileIn.hh" 35 #include "G4tgrFileIn.hh" 36 #include "G4tgrElementSimple.hh" 36 #include "G4tgrElementSimple.hh" 37 #include "G4tgrElementFromIsotopes.hh" 37 #include "G4tgrElementFromIsotopes.hh" 38 #include "G4tgrVolume.hh" 38 #include "G4tgrVolume.hh" 39 #include "G4tgrVolumeDivision.hh" 39 #include "G4tgrVolumeDivision.hh" 40 #include "G4tgrVolumeAssembly.hh" 40 #include "G4tgrVolumeAssembly.hh" 41 #include "G4tgrPlaceDivRep.hh" 41 #include "G4tgrPlaceDivRep.hh" 42 #include "G4tgrPlaceParameterisation.hh" 42 #include "G4tgrPlaceParameterisation.hh" 43 #include "G4tgrVolumeMgr.hh" 43 #include "G4tgrVolumeMgr.hh" 44 #include "G4tgrUtils.hh" 44 #include "G4tgrUtils.hh" 45 #include "G4tgrMaterialFactory.hh" 45 #include "G4tgrMaterialFactory.hh" 46 #include "G4tgrRotationMatrixFactory.hh" 46 #include "G4tgrRotationMatrixFactory.hh" 47 #include "G4tgrMessenger.hh" 47 #include "G4tgrMessenger.hh" 48 48 49 // ------------------------------------------- 49 // -------------------------------------------------------------------- 50 G4tgrLineProcessor::G4tgrLineProcessor() 50 G4tgrLineProcessor::G4tgrLineProcessor() 51 { 51 { 52 volmgr = G4tgrVolumeMgr::GetInstance(); 52 volmgr = G4tgrVolumeMgr::GetInstance(); 53 } 53 } 54 54 55 // ------------------------------------------- 55 // -------------------------------------------------------------------- 56 G4tgrLineProcessor::~G4tgrLineProcessor() 56 G4tgrLineProcessor::~G4tgrLineProcessor() 57 { 57 { 58 } 58 } 59 59 60 // ------------------------------------------- 60 // -------------------------------------------------------------------- 61 G4bool G4tgrLineProcessor::ProcessLine(const s 61 G4bool G4tgrLineProcessor::ProcessLine(const std::vector<G4String>& wl) 62 { 62 { 63 #ifdef G4VERBOSE 63 #ifdef G4VERBOSE 64 if(G4tgrMessenger::GetVerboseLevel() >= 1) 64 if(G4tgrMessenger::GetVerboseLevel() >= 1) 65 { 65 { 66 G4tgrUtils::DumpVS(wl, "@@@ Processing inp 66 G4tgrUtils::DumpVS(wl, "@@@ Processing input line"); 67 } 67 } 68 #endif 68 #endif 69 69 70 G4String wl0 = wl[0]; 70 G4String wl0 = wl[0]; 71 for(G4int ii = 0; ii < (G4int)wl0.length(); << 71 for(std::size_t ii = 0; ii < wl0.length(); ++ii) 72 { 72 { 73 wl0[ii] = (char)std::toupper(wl0[ii]); << 73 wl0[ii] = toupper(wl0[ii]); 74 } 74 } 75 75 76 //------------------------------- parameter 76 //------------------------------- parameter number 77 if(wl0 == ":P") 77 if(wl0 == ":P") 78 { 78 { 79 G4tgrParameterMgr::GetInstance()->AddParam 79 G4tgrParameterMgr::GetInstance()->AddParameterNumber(wl); 80 80 81 //------------------------------- paramete 81 //------------------------------- parameter string 82 } 82 } 83 else if(wl0 == ":PS") 83 else if(wl0 == ":PS") 84 { 84 { 85 G4tgrParameterMgr::GetInstance()->AddParam 85 G4tgrParameterMgr::GetInstance()->AddParameterString(wl); 86 86 87 //------------------------------- isotope 87 //------------------------------- isotope 88 } 88 } 89 else if(wl0 == ":ISOT") 89 else if(wl0 == ":ISOT") 90 { 90 { 91 G4tgrIsotope* isot = G4tgrMaterialFactory: 91 G4tgrIsotope* isot = G4tgrMaterialFactory::GetInstance()->AddIsotope(wl); 92 volmgr->RegisterMe(isot); 92 volmgr->RegisterMe(isot); 93 93 94 //------------------------------- element 94 //------------------------------- element 95 } 95 } 96 else if(wl0 == ":ELEM") 96 else if(wl0 == ":ELEM") 97 { 97 { 98 G4tgrElementSimple* elem = 98 G4tgrElementSimple* elem = 99 G4tgrMaterialFactory::GetInstance()->Add 99 G4tgrMaterialFactory::GetInstance()->AddElementSimple(wl); 100 volmgr->RegisterMe(elem); 100 volmgr->RegisterMe(elem); 101 101 102 //------------------------------- element 102 //------------------------------- element from isotopes 103 } 103 } 104 else if(wl0 == ":ELEM_FROM_ISOT") 104 else if(wl0 == ":ELEM_FROM_ISOT") 105 { 105 { 106 //:ELEM_FROM_ISOT NAME SYMBOL N_ISOT (ISOT 106 //:ELEM_FROM_ISOT NAME SYMBOL N_ISOT (ISOT_NAME ISOT_ABUNDANCE) 107 G4tgrElementFromIsotopes* elem = 107 G4tgrElementFromIsotopes* elem = 108 G4tgrMaterialFactory::GetInstance()->Add 108 G4tgrMaterialFactory::GetInstance()->AddElementFromIsotopes(wl); 109 volmgr->RegisterMe(elem); 109 volmgr->RegisterMe(elem); 110 110 111 //------------------------------- material 111 //------------------------------- material 112 } 112 } 113 else if(wl0 == ":MATE") 113 else if(wl0 == ":MATE") 114 { 114 { 115 G4tgrMaterialSimple* mate = 115 G4tgrMaterialSimple* mate = 116 G4tgrMaterialFactory::GetInstance()->Add 116 G4tgrMaterialFactory::GetInstance()->AddMaterialSimple(wl); 117 volmgr->RegisterMe(mate); 117 volmgr->RegisterMe(mate); 118 118 119 //------------------------------- material 119 //------------------------------- material mixtures & by weight 120 } 120 } 121 else if((wl0 == ":MIXT") || (wl0 == ":MIXT_B 121 else if((wl0 == ":MIXT") || (wl0 == ":MIXT_BY_WEIGHT")) 122 { 122 { 123 G4tgrMaterialMixture* mate = 123 G4tgrMaterialMixture* mate = 124 G4tgrMaterialFactory::GetInstance()->Add 124 G4tgrMaterialFactory::GetInstance()->AddMaterialMixture( 125 wl, "MaterialMixtureByWeight"); 125 wl, "MaterialMixtureByWeight"); 126 volmgr->RegisterMe(mate); 126 volmgr->RegisterMe(mate); 127 127 128 //------------------------------- material 128 //------------------------------- material mixture by number of atoms 129 } 129 } 130 else if(wl0 == ":MIXT_BY_NATOMS") 130 else if(wl0 == ":MIXT_BY_NATOMS") 131 { 131 { 132 G4tgrMaterialMixture* mate = 132 G4tgrMaterialMixture* mate = 133 G4tgrMaterialFactory::GetInstance()->Add 133 G4tgrMaterialFactory::GetInstance()->AddMaterialMixture( 134 wl, "MaterialMixtureByNoAtoms"); 134 wl, "MaterialMixtureByNoAtoms"); 135 volmgr->RegisterMe(mate); 135 volmgr->RegisterMe(mate); 136 136 137 //------------------------------- material 137 //------------------------------- material mixture by volume 138 } 138 } 139 else if(wl0 == ":MIXT_BY_VOLUME") 139 else if(wl0 == ":MIXT_BY_VOLUME") 140 { 140 { 141 G4tgrMaterialMixture* mate = 141 G4tgrMaterialMixture* mate = 142 G4tgrMaterialFactory::GetInstance()->Add 142 G4tgrMaterialFactory::GetInstance()->AddMaterialMixture( 143 wl, "MaterialMixtureByVolume"); 143 wl, "MaterialMixtureByVolume"); 144 volmgr->RegisterMe(mate); 144 volmgr->RegisterMe(mate); 145 145 146 //------------------------------- material 146 //------------------------------- material Mean Excitation Energy of 147 // Ionisati 147 // Ionisation Potential 148 } 148 } 149 else if(wl0 == ":MATE_MEE") 149 else if(wl0 == ":MATE_MEE") 150 { 150 { 151 G4tgrMaterial* mate = G4tgrMaterialFactory 151 G4tgrMaterial* mate = G4tgrMaterialFactory::GetInstance()->FindMaterial( 152 G4tgrUtils::GetString(wl[1])); 152 G4tgrUtils::GetString(wl[1])); 153 if(mate == 0) 153 if(mate == 0) 154 { 154 { 155 G4Exception("G4tgrLineProcessor::Process 155 G4Exception("G4tgrLineProcessor::ProcessLine()", "Material not found", 156 FatalException, G4tgrUtils:: 156 FatalException, G4tgrUtils::GetString(wl[1])); 157 return false; 157 return false; 158 } 158 } 159 mate->SetIonisationMeanExcitationEnergy(G4 159 mate->SetIonisationMeanExcitationEnergy(G4tgrUtils::GetDouble(wl[2])); 160 160 161 //------------------------------- material 161 //------------------------------- material 162 } 162 } 163 else if(wl0 == ":MATE_STATE") 163 else if(wl0 == ":MATE_STATE") 164 { 164 { 165 G4tgrMaterial* mate = G4tgrMaterialFactory 165 G4tgrMaterial* mate = G4tgrMaterialFactory::GetInstance()->FindMaterial( 166 G4tgrUtils::GetString(wl[1])); 166 G4tgrUtils::GetString(wl[1])); 167 if(mate == 0) 167 if(mate == 0) 168 { 168 { 169 G4Exception("G4tgrLineProcessor::Process 169 G4Exception("G4tgrLineProcessor::ProcessLine()", "Material not found", 170 FatalException, wl[1]); 170 FatalException, wl[1]); 171 } 171 } 172 mate->SetState(wl[2]); 172 mate->SetState(wl[2]); 173 173 174 //------------------------------- material 174 //------------------------------- material 175 } 175 } 176 else if(wl0 == ":MATE_TEMPERATURE") 176 else if(wl0 == ":MATE_TEMPERATURE") 177 { 177 { 178 G4tgrMaterial* mate = G4tgrMaterialFactory 178 G4tgrMaterial* mate = G4tgrMaterialFactory::GetInstance()->FindMaterial( 179 G4tgrUtils::GetString(wl[1])); 179 G4tgrUtils::GetString(wl[1])); 180 if(mate == 0) 180 if(mate == 0) 181 { 181 { 182 G4Exception("G4tgrLineProcessor::Process 182 G4Exception("G4tgrLineProcessor::ProcessLine()", "Material not found", 183 FatalException, wl[1]); 183 FatalException, wl[1]); 184 } 184 } 185 mate->SetTemperature(G4tgrUtils::GetDouble 185 mate->SetTemperature(G4tgrUtils::GetDouble(wl[2], kelvin)); 186 186 187 //------------------------------- material 187 //------------------------------- material 188 } 188 } 189 else if(wl0 == ":MATE_PRESSURE") 189 else if(wl0 == ":MATE_PRESSURE") 190 { 190 { 191 G4tgrMaterial* mate = G4tgrMaterialFactory 191 G4tgrMaterial* mate = G4tgrMaterialFactory::GetInstance()->FindMaterial( 192 G4tgrUtils::GetString(wl[1])); 192 G4tgrUtils::GetString(wl[1])); 193 if(mate == 0) 193 if(mate == 0) 194 { 194 { 195 G4Exception("G4tgrLineProcessor::Process 195 G4Exception("G4tgrLineProcessor::ProcessLine()", "Material not found", 196 FatalException, wl[1]); 196 FatalException, wl[1]); 197 } 197 } 198 mate->SetPressure(G4tgrUtils::GetDouble(wl 198 mate->SetPressure(G4tgrUtils::GetDouble(wl[2], atmosphere)); 199 199 200 //------------------------------- solid 200 //------------------------------- solid 201 } 201 } 202 else if(wl0 == ":SOLID") 202 else if(wl0 == ":SOLID") 203 { // called from here or from G4tgrVolume:: 203 { // called from here or from G4tgrVolume::G4tgrVolume 204 volmgr->CreateSolid(wl, 0); 204 volmgr->CreateSolid(wl, 0); 205 205 206 //------------------------------- volume 206 //------------------------------- volume 207 } 207 } 208 else if(wl0 == ":VOLU") 208 else if(wl0 == ":VOLU") 209 { 209 { 210 G4tgrVolume* vol = new G4tgrVolume(wl); 210 G4tgrVolume* vol = new G4tgrVolume(wl); 211 volmgr->RegisterMe(vol); 211 volmgr->RegisterMe(vol); 212 212 213 //--------------------------------- single 213 //--------------------------------- single placement 214 } 214 } 215 else if(wl0 == ":PLACE") 215 else if(wl0 == ":PLACE") 216 { 216 { 217 G4tgrVolume* vol = FindVolume(G4tgrUtils:: 217 G4tgrVolume* vol = FindVolume(G4tgrUtils::GetString(wl[1])); 218 G4tgrPlace* vpl = vol->AddPlace(wl); 218 G4tgrPlace* vpl = vol->AddPlace(wl); 219 volmgr->RegisterMe(vpl); 219 volmgr->RegisterMe(vpl); 220 220 221 //--------------------------------- parame 221 //--------------------------------- parameterisation 222 } 222 } 223 else if(wl0 == ":PLACE_PARAM") 223 else if(wl0 == ":PLACE_PARAM") 224 { 224 { 225 G4tgrVolume* vol = FindVolu 225 G4tgrVolume* vol = FindVolume(G4tgrUtils::GetString(wl[1])); 226 G4tgrPlaceParameterisation* vpl = vol->Add 226 G4tgrPlaceParameterisation* vpl = vol->AddPlaceParam(wl); 227 volmgr->RegisterMe(vpl); 227 volmgr->RegisterMe(vpl); 228 228 229 //--------------------------------- divisi 229 //--------------------------------- division 230 } 230 } 231 else if((wl0 == ":DIV_NDIV") || (wl0 == ":DI 231 else if((wl0 == ":DIV_NDIV") || (wl0 == ":DIV_WIDTH") || 232 (wl0 == ":DIV_NDIV_WIDTH")) 232 (wl0 == ":DIV_NDIV_WIDTH")) 233 { 233 { 234 //---------- Create G4tgrVolumeDivision an 234 //---------- Create G4tgrVolumeDivision and fill the volume params 235 G4tgrVolumeDivision* vol = new G4tgrVolume 235 G4tgrVolumeDivision* vol = new G4tgrVolumeDivision(wl); 236 volmgr->RegisterMe(vol); 236 volmgr->RegisterMe(vol); 237 237 238 //--------------------------------- replic 238 //--------------------------------- replica 239 } 239 } 240 else if(wl0 == ":REPL") 240 else if(wl0 == ":REPL") 241 { 241 { 242 G4tgrVolume* vol = FindVolume(G4tgrUt 242 G4tgrVolume* vol = FindVolume(G4tgrUtils::GetString(wl[1])); 243 G4tgrPlaceDivRep* vpl = vol->AddPlaceRepli 243 G4tgrPlaceDivRep* vpl = vol->AddPlaceReplica(wl); 244 volmgr->RegisterMe(vpl); 244 volmgr->RegisterMe(vpl); 245 245 246 //----------------------------- assembly v 246 //----------------------------- assembly volume: definition of components 247 } 247 } 248 else if(wl0 == ":VOLU_ASSEMBLY") 248 else if(wl0 == ":VOLU_ASSEMBLY") 249 { 249 { 250 G4tgrVolumeAssembly* vol = new G4tgrVolume 250 G4tgrVolumeAssembly* vol = new G4tgrVolumeAssembly(wl); 251 volmgr->RegisterMe(vol); 251 volmgr->RegisterMe(vol); 252 252 253 //----------------------------- assembly v 253 //----------------------------- assembly volume: definition of components 254 } 254 } 255 else if(wl0 == ":PLACE_ASSEMBLY") 255 else if(wl0 == ":PLACE_ASSEMBLY") 256 { 256 { 257 G4tgrVolume* vol = FindVolume(G4tgrUtils:: 257 G4tgrVolume* vol = FindVolume(G4tgrUtils::GetString(wl[1])); 258 G4tgrPlace* vpl = vol->AddPlace(wl); 258 G4tgrPlace* vpl = vol->AddPlace(wl); 259 volmgr->RegisterMe(vpl); 259 volmgr->RegisterMe(vpl); 260 260 261 //--------------------------------- rotat 261 //--------------------------------- rotation matrix 262 } 262 } 263 else if(wl0 == ":ROTM") 263 else if(wl0 == ":ROTM") 264 { 264 { 265 //---------- When second word is ':NEXT/:M 265 //---------- When second word is ':NEXT/:MNXT' it is used for defining a 266 // rotation matrix that will be 266 // rotation matrix that will be used for the next placement/s 267 G4tgrRotationMatrix* rm = 267 G4tgrRotationMatrix* rm = 268 G4tgrRotationMatrixFactory::GetInstance( 268 G4tgrRotationMatrixFactory::GetInstance()->AddRotMatrix(wl); 269 volmgr->RegisterMe(rm); 269 volmgr->RegisterMe(rm); 270 270 271 //------------------------------- visualis 271 //------------------------------- visualisation 272 } 272 } 273 else if(wl0 == ":VIS") 273 else if(wl0 == ":VIS") 274 { 274 { 275 std::vector<G4tgrVolume*> vols = 275 std::vector<G4tgrVolume*> vols = 276 volmgr->FindVolumes(G4tgrUtils::GetStrin 276 volmgr->FindVolumes(G4tgrUtils::GetString(wl[1]), 1); 277 for(std::size_t ii = 0; ii < vols.size(); 277 for(std::size_t ii = 0; ii < vols.size(); ++ii) 278 { 278 { 279 vols[ii]->AddVisibility(wl); 279 vols[ii]->AddVisibility(wl); 280 } 280 } 281 281 282 //--------------------------------- colour 282 //--------------------------------- colour 283 } 283 } 284 else if((wl0 == ":COLOUR") || (wl0 == ":COLO 284 else if((wl0 == ":COLOUR") || (wl0 == ":COLOR")) 285 { 285 { 286 std::vector<G4tgrVolume*> vols = 286 std::vector<G4tgrVolume*> vols = 287 volmgr->FindVolumes(G4tgrUtils::GetStrin 287 volmgr->FindVolumes(G4tgrUtils::GetString(wl[1]), 1); 288 for(std::size_t ii = 0; ii < vols.size(); 288 for(std::size_t ii = 0; ii < vols.size(); ++ii) 289 { 289 { 290 vols[ii]->AddRGBColour(wl); 290 vols[ii]->AddRGBColour(wl); 291 } 291 } 292 292 293 //--------------------------------- check 293 //--------------------------------- check overlaps 294 } 294 } 295 else if(wl0 == ":CHECK_OVERLAPS") 295 else if(wl0 == ":CHECK_OVERLAPS") 296 { 296 { 297 std::vector<G4tgrVolume*> vols = 297 std::vector<G4tgrVolume*> vols = 298 volmgr->FindVolumes(G4tgrUtils::GetStrin 298 volmgr->FindVolumes(G4tgrUtils::GetString(wl[1]), 1); 299 for(std::size_t ii = 0; ii < vols.size(); 299 for(std::size_t ii = 0; ii < vols.size(); ++ii) 300 { 300 { 301 vols[ii]->AddCheckOverlaps(wl); 301 vols[ii]->AddCheckOverlaps(wl); 302 } 302 } 303 //--------------------------------- ERROR 303 //--------------------------------- ERROR 304 } 304 } 305 else 305 else 306 { 306 { 307 return false; 307 return false; 308 } 308 } 309 309 310 return true; 310 return true; 311 } 311 } 312 312 313 // ------------------------------------------- 313 // -------------------------------------------------------------------- 314 G4tgrVolume* G4tgrLineProcessor::FindVolume(co 314 G4tgrVolume* G4tgrLineProcessor::FindVolume(const G4String& volname) 315 { 315 { 316 G4tgrVolume* vol = volmgr->FindVolume(volnam 316 G4tgrVolume* vol = volmgr->FindVolume(volname, 1); 317 317 318 if(vol->GetType() == "VOLDivision") 318 if(vol->GetType() == "VOLDivision") 319 { 319 { 320 G4Exception("G4tgrLineProcessor::FindVolum 320 G4Exception("G4tgrLineProcessor::FindVolume()", "InvalidSetup", 321 FatalException, 321 FatalException, 322 "Using 'PLACE' for a volume cr 322 "Using 'PLACE' for a volume created by a division !"); 323 } 323 } 324 324 325 return vol; 325 return vol; 326 } 326 } 327 327