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