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