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 // >> 27 // $Id: G4OpticalSurface.cc,v 1.16 2009/12/01 08:24:51 gcosmo Exp $ >> 28 // GEANT4 tag $Name: geant4-09-03 $ >> 29 // >> 30 // 26 ////////////////////////////////////////////// 31 //////////////////////////////////////////////////////////////////////// 27 // Optical Surface Class Implementation 32 // Optical Surface Class Implementation 28 ////////////////////////////////////////////// 33 //////////////////////////////////////////////////////////////////////// 29 // 34 // 30 // File: G4OpticalSurface.cc 35 // File: G4OpticalSurface.cc 31 // Description: An optical surface class for u 36 // Description: An optical surface class for use in G4OpBoundaryProcess 32 // Version: 2.0 37 // Version: 2.0 33 // Created: 1997-06-26 38 // Created: 1997-06-26 34 // Author: Peter Gumplinger 39 // Author: Peter Gumplinger 35 // updated: 2017-02-24 Mariele Stockhoff a << 40 // mail: gum@triumf.ca >> 41 // 36 ////////////////////////////////////////////// 42 //////////////////////////////////////////////////////////////////////// 37 43 38 #include "G4OpticalSurface.hh" << 44 #include "G4ios.hh" 39 << 40 #include "globals.hh" 45 #include "globals.hh" >> 46 #include "G4OpticalSurface.hh" 41 47 42 #include <zlib.h> << 48 ///////////////////////// 43 << 49 // Class Implementation 44 #include <fstream> << 50 ///////////////////////// 45 #include <iostream> << 51 46 << 52 ////////////// 47 G4OpticalSurface& G4OpticalSurface::operator=( << 53 // Operators 48 { << 54 ////////////// 49 if (this != &right) { << 55 50 theName = right.theName; << 56 const G4OpticalSurface& 51 theType = right.theType; << 57 G4OpticalSurface::operator=(const G4OpticalSurface& right) 52 theModel = right.theModel; << 58 { 53 theFinish = right.theFinish; << 59 if (this != &right) 54 sigma_alpha = right.sigma_alpha; << 60 { 55 polish = right.polish; << 61 theName = right.GetName(); 56 theMaterialPropertiesTable = right.theMate << 62 theModel = right.theModel; 57 << 63 theFinish = right.theFinish; 58 delete[] AngularDistribution; << 64 theType = right.GetType(); 59 AngularDistribution = new G4float[incident << 65 sigma_alpha = right.sigma_alpha; 60 *(AngularDistribution) = *(right.AngularDi << 66 polish = right.polish; 61 << 67 theMaterialPropertiesTable = right.theMaterialPropertiesTable; 62 delete[] AngularDistributionLUT; << 68 AngularDistribution = right.AngularDistribution; 63 AngularDistributionLUT = new G4float[index << 69 } 64 *(AngularDistributionLUT) = *(right.Angula << 65 << 66 delete[] Reflectivity; << 67 Reflectivity = new G4float[RefMax]; << 68 *(Reflectivity) = *(right.Reflectivity); << 69 << 70 delete DichroicVector; << 71 DichroicVector = new G4Physics2DVector(); << 72 *DichroicVector = *(right.DichroicVector); << 73 } << 74 return *this; 70 return *this; 75 } 71 } 76 72 77 G4OpticalSurface::G4OpticalSurface(const G4Str << 73 ///////////////// 78 G4OpticalSurfaceFinish finish, G4SurfaceType << 74 // Constructors 79 : G4SurfaceProperty(name, type), theModel(mo << 75 ///////////////// 80 { << 76 81 AngularDistribution = nullptr; << 77 G4OpticalSurface::G4OpticalSurface(const G4String& name, 82 << 78 G4OpticalSurfaceModel model, 83 AngularDistributionLUT = nullptr; << 79 G4OpticalSurfaceFinish finish, 84 Reflectivity = nullptr; << 80 G4SurfaceType type, 85 << 81 G4double value) 86 DichroicVector = nullptr; << 82 : G4SurfaceProperty(name,type), 87 << 83 theModel(model), 88 switch (theModel) { << 84 theFinish(finish), 89 case glisur: << 85 theMaterialPropertiesTable(0) 90 polish = value; << 86 { 91 sigma_alpha = 0.0; << 87 if (model == glisur ){ 92 break; << 88 polish = value; 93 case LUT: << 89 sigma_alpha = 0.0; 94 case dichroic: << 90 } 95 case DAVIS: << 91 else if ( model == unified ) { 96 ReadDataFile(); << 92 sigma_alpha = value; 97 // fall through << 93 polish = 0.0; 98 case unified: << 94 } 99 sigma_alpha = value; << 95 else if ( model == LUT ) { 100 polish = 0.0; << 96 sigma_alpha = value; 101 break; << 97 polish = 0.0; 102 default: << 98 } 103 G4Exception("G4OpticalSurface::G4Optical << 99 else { 104 "Constructor called with INVALID model << 100 G4Exception("G4OpticalSurface::G4OpticalSurface ==> " 105 } << 101 "Constructor called with INVALID model."); >> 102 } >> 103 >> 104 AngularDistribution = NULL; >> 105 >> 106 if (type == dielectric_LUT) { >> 107 AngularDistribution = >> 108 new G4float[incidentIndexMax*thetaIndexMax*phiIndexMax]; >> 109 ReadFile(); >> 110 } 106 } 111 } 107 112 108 G4OpticalSurface::~G4OpticalSurface() 113 G4OpticalSurface::~G4OpticalSurface() 109 { 114 { 110 delete[] AngularDistribution; << 115 if (AngularDistribution) delete AngularDistribution; 111 << 112 delete[] AngularDistributionLUT; << 113 << 114 delete[] Reflectivity; << 115 << 116 delete DichroicVector; << 117 } 116 } 118 117 119 G4OpticalSurface::G4OpticalSurface(const G4Opt << 118 G4OpticalSurface::G4OpticalSurface(const G4OpticalSurface &right) 120 : G4SurfaceProperty(right.theName, right.the << 119 : G4SurfaceProperty(right.GetName()) 121 { 120 { 122 *this = right; << 121 *this = right; 123 this->theName = right.theName; << 124 this->theType = right.theType; << 125 this->theModel = right.theModel; << 126 this->theFinish = right.theFinish; << 127 this->sigma_alpha = right.sigma_alpha; << 128 this->polish = right.polish; << 129 this->theMaterialPropertiesTable = right.the << 130 << 131 delete[] AngularDistribution; << 132 this->AngularDistribution = new G4float[inci << 133 *(this->AngularDistribution) = *(right.Angul << 134 << 135 delete[] AngularDistributionLUT; << 136 this->AngularDistributionLUT = new G4float[i << 137 *(this->AngularDistributionLUT) = *(right.An << 138 << 139 delete[] Reflectivity; << 140 this->Reflectivity = new G4float[RefMax]; << 141 *(this->Reflectivity) = *(right.Reflectivity << 142 << 143 delete DichroicVector; << 144 this->DichroicVector = new G4Physics2DVector << 145 *(this->DichroicVector) = *(right.DichroicVe << 146 } 122 } 147 123 148 G4bool G4OpticalSurface::operator==(const G4Op << 124 G4int G4OpticalSurface::operator==(const G4OpticalSurface &right) const 149 { 125 { 150 return (this == (G4OpticalSurface*)&right); << 126 return (this == (G4OpticalSurface *) &right); 151 } 127 } 152 128 153 G4bool G4OpticalSurface::operator!=(const G4Op << 129 G4int G4OpticalSurface::operator!=(const G4OpticalSurface &right) const 154 { 130 { 155 return (this != (G4OpticalSurface*)&right); << 131 return (this != (G4OpticalSurface *) &right); 156 } 132 } >> 133 //////////// >> 134 // Methods >> 135 //////////// 157 136 158 G4int G4OpticalSurface::GetInmax() const { ret << 137 void G4OpticalSurface::DumpInfo() const 159 << 138 { 160 G4int G4OpticalSurface::GetLUTbins() const { r << 161 << 162 G4int G4OpticalSurface::GetRefMax() const { re << 163 139 164 G4int G4OpticalSurface::GetThetaIndexMax() con << 140 // Dump info for surface 165 141 166 G4int G4OpticalSurface::GetPhiIndexMax() const << 142 G4cout << >> 143 " Surface type = " << G4int(theType) << G4endl << >> 144 " Surface finish = " << G4int(theFinish) << G4endl << >> 145 " Surface model = " << G4int(theModel) << G4endl; 167 146 168 void G4OpticalSurface::DumpInfo() const << 147 G4cout << G4endl; 169 { << 170 // Dump info for surface << 171 148 172 G4cout << " Surface type = " << G4int(the << 149 G4cout << " Surface parameter " << G4endl; 173 << " Surface finish = " << G4int(the << 150 G4cout << " ----------------- " << G4endl; 174 << " Surface model = " << G4int(the << 151 if (theModel == glisur ){ 175 << G4endl << " ----------------- " < << 152 G4cout << polish << G4endl; 176 << 153 } 177 if (theModel == glisur) { << 154 else if (theModel == LUT ){ 178 G4cout << " polish: " << polish << G4endl; << 155 G4cout << sigma_alpha << G4endl; 179 } << 156 } 180 else { << 157 else { 181 G4cout << " sigma_alpha: " << sigma_alpha << 158 G4cout << sigma_alpha << G4endl; 182 } << 159 } 183 G4cout << G4endl; << 160 G4cout << G4endl; 184 } 161 } 185 162 186 void G4OpticalSurface::SetType(const G4Surface 163 void G4OpticalSurface::SetType(const G4SurfaceType& type) 187 { 164 { 188 theType = type; 165 theType = type; 189 ReadDataFile(); << 166 if (type == dielectric_LUT) { >> 167 if (!AngularDistribution) AngularDistribution = >> 168 new G4float[incidentIndexMax*thetaIndexMax*phiIndexMax]; >> 169 ReadFile(); >> 170 } 190 } 171 } 191 172 192 void G4OpticalSurface::SetFinish(const G4Optic 173 void G4OpticalSurface::SetFinish(const G4OpticalSurfaceFinish finish) 193 { 174 { 194 theFinish = finish; 175 theFinish = finish; 195 ReadDataFile(); << 176 if (theType == dielectric_LUT) { 196 } << 177 if (!AngularDistribution) AngularDistribution = 197 << 178 new G4float[incidentIndexMax*thetaIndexMax*phiIndexMax]; 198 void G4OpticalSurface::ReadDataFile() << 179 ReadFile(); 199 { << 200 // type and finish can be set in either orde << 201 // for consistency. Need to read file on set << 202 switch (theType) { << 203 case dielectric_LUT: << 204 if (AngularDistribution == nullptr) { << 205 AngularDistribution = new G4float[inci << 206 } << 207 ReadLUTFile(); << 208 break; << 209 case dielectric_LUTDAVIS: << 210 if (AngularDistributionLUT == nullptr) { << 211 AngularDistributionLUT = new G4float[i << 212 } << 213 ReadLUTDAVISFile(); << 214 << 215 if (Reflectivity == nullptr) { << 216 Reflectivity = new G4float[RefMax]; << 217 } << 218 ReadReflectivityLUTFile(); << 219 break; << 220 case dielectric_dichroic: << 221 if (DichroicVector == nullptr) { << 222 DichroicVector = new G4Physics2DVector << 223 } << 224 ReadDichroicFile(); << 225 break; << 226 default: << 227 break; << 228 } 180 } 229 } 181 } 230 182 231 void G4OpticalSurface::ReadLUTFile() << 183 void G4OpticalSurface::ReadFile() 232 { 184 { 233 G4String readLUTFileName; << 185 G4String readFileName = " "; 234 186 235 switch (theFinish) { << 187 if (theFinish == polishedlumirrorglue) { 236 case polishedlumirrorglue: << 188 readFileName = "PolishedLumirrorGlue.dat"; 237 readLUTFileName = "PolishedLumirrorGlue. << 238 break; << 239 case polishedlumirrorair: << 240 readLUTFileName = "PolishedLumirror.z"; << 241 break; << 242 case polishedteflonair: << 243 readLUTFileName = "PolishedTeflon.z"; << 244 break; << 245 case polishedtioair: << 246 readLUTFileName = "PolishedTiO.z"; << 247 break; << 248 case polishedtyvekair: << 249 readLUTFileName = "PolishedTyvek.z"; << 250 break; << 251 case polishedvm2000glue: << 252 readLUTFileName = "PolishedVM2000Glue.z" << 253 break; << 254 case polishedvm2000air: << 255 readLUTFileName = "PolishedVM2000.z"; << 256 break; << 257 case etchedlumirrorglue: << 258 readLUTFileName = "EtchedLumirrorGlue.z" << 259 break; << 260 case etchedlumirrorair: << 261 readLUTFileName = "EtchedLumirror.z"; << 262 break; << 263 case etchedteflonair: << 264 readLUTFileName = "EtchedTeflon.z"; << 265 break; << 266 case etchedtioair: << 267 readLUTFileName = "EtchedTiO.z"; << 268 break; << 269 case etchedtyvekair: << 270 readLUTFileName = "EtchedTyvek.z"; << 271 break; << 272 case etchedvm2000glue: << 273 readLUTFileName = "EtchedVM2000Glue.z"; << 274 break; << 275 case etchedvm2000air: << 276 readLUTFileName = "EtchedVM2000.z"; << 277 break; << 278 case groundlumirrorglue: << 279 readLUTFileName = "GroundLumirrorGlue.z" << 280 break; << 281 case groundlumirrorair: << 282 readLUTFileName = "GroundLumirror.z"; << 283 break; << 284 case groundteflonair: << 285 readLUTFileName = "GroundTeflon.z"; << 286 break; << 287 case groundtioair: << 288 readLUTFileName = "GroundTiO.z"; << 289 break; << 290 case groundtyvekair: << 291 readLUTFileName = "GroundTyvek.z"; << 292 break; << 293 case groundvm2000glue: << 294 readLUTFileName = "GroundVM2000Glue.z"; << 295 break; << 296 case groundvm2000air: << 297 readLUTFileName = "GroundVM2000.z"; << 298 break; << 299 default: << 300 return; << 301 } << 302 << 303 std::istringstream iss; << 304 ReadCompressedFile(readLUTFileName, iss); << 305 << 306 size_t idxmax = incidentIndexMax * thetaInde << 307 for (size_t i = 0; i < idxmax; ++i) { << 308 iss >> AngularDistribution[i]; << 309 } 189 } 310 G4cout << "LUT - data file: " << readLUTFile << 190 else if (theFinish == polishedlumirrorair) { 311 } << 191 readFileName = "PolishedLumirror.dat"; 312 << 313 void G4OpticalSurface::ReadLUTDAVISFile() << 314 { << 315 G4String readLUTDAVISFileName; << 316 << 317 switch (theFinish) { << 318 case Rough_LUT: << 319 readLUTDAVISFileName = "Rough_LUT.z"; << 320 break; << 321 case RoughTeflon_LUT: << 322 readLUTDAVISFileName = "RoughTeflon_LUT. << 323 break; << 324 case RoughESR_LUT: << 325 readLUTDAVISFileName = "RoughESR_LUT.z"; << 326 break; << 327 case RoughESRGrease_LUT: << 328 readLUTDAVISFileName = "RoughESRGrease_L << 329 break; << 330 case Polished_LUT: << 331 readLUTDAVISFileName = "Polished_LUT.z"; << 332 break; << 333 case PolishedTeflon_LUT: << 334 readLUTDAVISFileName = "PolishedTeflon_L << 335 break; << 336 case PolishedESR_LUT: << 337 readLUTDAVISFileName = "PolishedESR_LUT. << 338 break; << 339 case PolishedESRGrease_LUT: << 340 readLUTDAVISFileName = "PolishedESRGreas << 341 break; << 342 case Detector_LUT: << 343 readLUTDAVISFileName = "Detector_LUT.z"; << 344 break; << 345 default: << 346 return; << 347 } 192 } 348 << 193 else if (theFinish == polishedteflonair) { 349 std::istringstream iss; << 194 readFileName = "PolishedTeflon.dat"; 350 ReadCompressedFile(readLUTDAVISFileName, iss << 351 << 352 for (size_t i = 0; i < indexmax; ++i) { << 353 iss >> AngularDistributionLUT[i]; << 354 } 195 } 355 G4cout << "LUT DAVIS - data file: " << readL << 196 else if (theFinish == polishedtioair) { 356 } << 197 readFileName = "PolishedTiO.dat"; 357 << 358 void G4OpticalSurface::ReadReflectivityLUTFile << 359 { << 360 G4String readReflectivityLUTFileName; << 361 << 362 switch (theFinish) { << 363 case Rough_LUT: << 364 readReflectivityLUTFileName = "Rough_LUT << 365 break; << 366 case RoughTeflon_LUT: << 367 readReflectivityLUTFileName = "RoughTefl << 368 break; << 369 case RoughESR_LUT: << 370 readReflectivityLUTFileName = "RoughESR_ << 371 break; << 372 case RoughESRGrease_LUT: << 373 readReflectivityLUTFileName = "RoughESRG << 374 break; << 375 case Polished_LUT: << 376 readReflectivityLUTFileName = "Polished_ << 377 break; << 378 case PolishedTeflon_LUT: << 379 readReflectivityLUTFileName = "PolishedT << 380 break; << 381 case PolishedESR_LUT: << 382 readReflectivityLUTFileName = "PolishedE << 383 break; << 384 case PolishedESRGrease_LUT: << 385 readReflectivityLUTFileName = "PolishedE << 386 break; << 387 case Detector_LUT: << 388 readReflectivityLUTFileName = "Detector_ << 389 break; << 390 default: << 391 return; << 392 } 198 } 393 << 199 else if (theFinish == polishedtyvekair) { 394 std::istringstream iss; << 200 readFileName = "PolishedTyvek.dat"; 395 ReadCompressedFile(readReflectivityLUTFileNa << 396 << 397 for (size_t i = 0; i < RefMax; ++i) { << 398 iss >> Reflectivity[i]; << 399 } 201 } 400 G4cout << "LUT DAVIS - reflectivity data fil << 202 else if (theFinish == polishedvm2000glue) { 401 << G4endl; << 203 readFileName = "PolishedVM2000Glue.dat"; 402 } << 403 << 404 // uncompress one data file into the input str << 405 void G4OpticalSurface::ReadCompressedFile(cons << 406 { << 407 G4String* dataString = nullptr; << 408 G4String path = G4FindDataDir("G4REALSURFACE << 409 G4String compfilename = path + "/" + filenam << 410 // create input stream with binary mode oper << 411 std::ifstream in(compfilename, std::ios::bin << 412 if (in.good()) { << 413 // get current position in the stream (was << 414 G4int fileSize = (G4int)in.tellg(); << 415 // set current position being the beginnin << 416 in.seekg(0, std::ios::beg); << 417 // create (zlib) byte buffer for the data << 418 auto compdata = new Bytef[fileSize]; << 419 while (in) { << 420 in.read((char*)compdata, fileSize); << 421 } << 422 // create (zlib) byte buffer for the uncom << 423 auto complen = (uLongf)(fileSize * 4); << 424 auto uncompdata = new Bytef[complen]; << 425 while (Z_OK != uncompress(uncompdata, &com << 426 // increase uncompressed byte buffer << 427 delete[] uncompdata; << 428 complen *= 2; << 429 uncompdata = new Bytef[complen]; << 430 } << 431 // delete the compressed data buffer << 432 delete[] compdata; << 433 // create a string from uncompressed data << 434 dataString = new G4String((char*)uncompdat << 435 // delete the uncompressed data buffer << 436 delete[] uncompdata; << 437 } 204 } 438 else { << 205 else if (theFinish == polishedvm2000air) { 439 G4ExceptionDescription ed; << 206 readFileName = "PolishedVM2000.dat"; 440 ed << "Problem while trying to read " + co << 441 G4Exception("G4OpticalSurface::ReadCompres << 442 return; << 443 } << 444 // create the input string stream from the d << 445 if (dataString != nullptr) { << 446 iss.str(*dataString); << 447 in.close(); << 448 delete dataString; << 449 G4cout << "G4OpticalSurface: data file " < << 450 } 207 } 451 } << 208 else if (theFinish == etchedlumirrorglue) { 452 << 209 readFileName = "EtchedLumirrorGlue.dat"; 453 void G4OpticalSurface::ReadDichroicFile() << 454 { << 455 const char* datadir = G4FindDataDir("G4DICHR << 456 << 457 if (datadir == nullptr) { << 458 G4Exception("G4OpticalSurface::ReadDichroi << 459 "Environment variable G4DICHROICDATA not << 460 return; << 461 } 210 } 462 << 211 else if (theFinish == etchedlumirrorair) { 463 std::ostringstream ost; << 212 readFileName = "EtchedLumirror.dat"; 464 ost << datadir; << 465 std::ifstream fin(ost.str().c_str()); << 466 if (! fin.is_open()) { << 467 G4ExceptionDescription ed; << 468 ed << "Dichroic surface data file <" << os << 469 G4Exception("G4OpticalSurface::ReadDichroi << 470 return; << 471 } 213 } 472 << 214 else if (theFinish == etchedteflonair) { 473 if (! (DichroicVector->Retrieve(fin))) { << 215 readFileName = "EtchedTeflon.dat"; 474 G4ExceptionDescription ed; << 216 } 475 ed << "Dichroic surface data file <" << os << 217 else if (theFinish == etchedtioair) { 476 G4Exception("G4OpticalSurface::ReadDichroi << 218 readFileName = "EtchedTiO.dat"; 477 return; << 219 } >> 220 else if (theFinish == etchedtyvekair) { >> 221 readFileName = "EtchedTyvek.dat"; >> 222 } >> 223 else if (theFinish == etchedvm2000glue) { >> 224 readFileName = "EtchedVM2000Glue.dat"; >> 225 } >> 226 else if (theFinish == etchedvm2000air) { >> 227 readFileName = "EtchedVM2000.dat"; >> 228 } >> 229 else if (theFinish == groundlumirrorglue) { >> 230 readFileName = "GroundLumirrorGlue.dat"; >> 231 } >> 232 else if (theFinish == groundlumirrorair) { >> 233 readFileName = "GroundLumirror.dat"; >> 234 } >> 235 else if (theFinish == groundteflonair) { >> 236 readFileName = "GroundTeflon.dat"; >> 237 } >> 238 else if (theFinish == groundtioair) { >> 239 readFileName = "GroundTiO.dat"; >> 240 } >> 241 else if (theFinish == groundtyvekair) { >> 242 readFileName = "GroundTyvek.dat"; >> 243 } >> 244 else if (theFinish == groundvm2000glue) { >> 245 readFileName = "GroundVM2000Glue.dat"; >> 246 } >> 247 else if (theFinish == groundvm2000air) { >> 248 readFileName = "GroundVM2000.dat"; 478 } 249 } 479 250 480 // DichroicVector->SetBicubicInterpolation( << 251 if (readFileName == " ") return; 481 << 482 G4cout << " *** Dichroic surface data file * << 483 << 484 auto numberOfXNodes = (G4int)DichroicVector- << 485 auto numberOfYNodes = (G4int)DichroicVector- << 486 << 487 G4cout << "numberOfXNodes: " << numberOfXNod << 488 G4cout << "numberOfYNodes: " << numberOfYNod << 489 252 490 if (0 > numberOfXNodes || numberOfXNodes >= << 253 char* path = getenv("G4REALSURFACEDATA"); 491 numberOfXNodes = 0; << 254 if (!path) { 492 } << 255 G4String excep = 493 if (0 > numberOfYNodes || numberOfYNodes >= << 256 "G4OpBoundaryProcess - G4REALSURFACEDATA environment variable not set"; 494 numberOfYNodes = 0; << 257 G4Exception(excep); 495 } 258 } >> 259 G4String pathString(path); 496 260 497 G4PV2DDataVector xVector; << 261 readFileName = pathString + "/" + readFileName; 498 G4PV2DDataVector yVector; << 499 262 500 xVector.resize(numberOfXNodes, 0.); << 263 // Open LUT with Material and Integer Angle 501 yVector.resize(numberOfYNodes, 0.); << 264 FILE* readFileHandle; 502 265 503 for (G4int i = 0; i < numberOfXNodes; ++i) { << 266 readFileHandle = fopen(readFileName,"r"); 504 G4cout << "i: " << DichroicVector->GetX(i) << 505 xVector[i] = DichroicVector->GetX(i); << 506 } << 507 for (G4int j = 0; j < numberOfYNodes; ++j) { << 508 G4cout << "j: " << DichroicVector->GetY(j) << 509 yVector[j] = DichroicVector->GetY(j); << 510 } << 511 267 512 for (G4int j = 0; j < numberOfYNodes; ++j) { << 268 if (readFileHandle!=NULL) { 513 for (G4int i = 0; i < numberOfXNodes; ++i) << 269 for (int i=0;i<incidentIndexMax*thetaIndexMax*phiIndexMax;i++) { 514 G4cout << " i: " << i << " j: " << j << << 270 fscanf(readFileHandle,"%6f", &AngularDistribution[i]); 515 } << 271 } >> 272 G4cout << "LUT - data file: " << readFileName << " read in! " << G4endl; >> 273 } >> 274 else { >> 275 G4String excep = "LUT - data file: " + readFileName + " not found"; >> 276 G4Exception(excep); 516 } 277 } >> 278 fclose(readFileHandle); 517 } 279 } 518 280