00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00030
00032
00033
00034
00035
00036
00037
00038
00039
00041
00042 #include "G4ios.hh"
00043 #include "globals.hh"
00044 #include "G4OpticalSurface.hh"
00045
00047
00049
00051
00053
00054 G4OpticalSurface& G4OpticalSurface::operator=(const G4OpticalSurface& right)
00055 {
00056 if (this != &right)
00057 {
00058 theName = right.theName;
00059 theType = right.theType;
00060 theModel = right.theModel;
00061 theFinish = right.theFinish;
00062 sigma_alpha = right.sigma_alpha;
00063 polish = right.polish;
00064 theMaterialPropertiesTable = right.theMaterialPropertiesTable;
00065 AngularDistribution = right.AngularDistribution;
00066 readFileHandle = right.readFileHandle;
00067 }
00068 return *this;
00069 }
00070
00072
00074
00075 G4OpticalSurface::G4OpticalSurface(const G4String& name,
00076 G4OpticalSurfaceModel model,
00077 G4OpticalSurfaceFinish finish,
00078 G4SurfaceType type,
00079 G4double value)
00080 : G4SurfaceProperty(name,type),
00081 theModel(model),
00082 theFinish(finish),
00083 theMaterialPropertiesTable(0)
00084 {
00085 if (model == glisur ){
00086 polish = value;
00087 sigma_alpha = 0.0;
00088 }
00089 else if ( model == unified ) {
00090 sigma_alpha = value;
00091 polish = 0.0;
00092 }
00093 else if ( model == LUT ) {
00094 sigma_alpha = value;
00095 polish = 0.0;
00096 }
00097 else {
00098 G4Exception("G4OpticalSurface::G4OpticalSurface()", "mat309",
00099 FatalException,
00100 "Constructor called with INVALID model.");
00101 }
00102
00103 AngularDistribution = NULL;
00104
00105 if (type == dielectric_LUT) {
00106 AngularDistribution =
00107 new G4float[incidentIndexMax*thetaIndexMax*phiIndexMax];
00108 ReadFile();
00109 }
00110 }
00111
00112 G4OpticalSurface::~G4OpticalSurface()
00113 {
00114 if (AngularDistribution) delete AngularDistribution;
00115 }
00116
00117 G4OpticalSurface::G4OpticalSurface(const G4OpticalSurface &right)
00118 : G4SurfaceProperty(right.theName,right.theType)
00119 {
00120 *this = right;
00121 this->theMaterialPropertiesTable = right.theMaterialPropertiesTable;
00122 this->AngularDistribution = right.AngularDistribution;
00123 this->readFileHandle = right.readFileHandle;
00124 }
00125
00126 G4int G4OpticalSurface::operator==(const G4OpticalSurface &right) const
00127 {
00128 return (this == (G4OpticalSurface *) &right);
00129 }
00130
00131 G4int G4OpticalSurface::operator!=(const G4OpticalSurface &right) const
00132 {
00133 return (this != (G4OpticalSurface *) &right);
00134 }
00136
00138
00139 void G4OpticalSurface::DumpInfo() const
00140 {
00141
00142
00143
00144 G4cout <<
00145 " Surface type = " << G4int(theType) << G4endl <<
00146 " Surface finish = " << G4int(theFinish) << G4endl <<
00147 " Surface model = " << G4int(theModel) << G4endl;
00148
00149 G4cout << G4endl;
00150
00151 G4cout << " Surface parameter " << G4endl;
00152 G4cout << " ----------------- " << G4endl;
00153 if (theModel == glisur ){
00154 G4cout << polish << G4endl;
00155 }
00156 else if (theModel == LUT ){
00157 G4cout << sigma_alpha << G4endl;
00158 }
00159 else {
00160 G4cout << sigma_alpha << G4endl;
00161 }
00162 G4cout << G4endl;
00163 }
00164
00165 void G4OpticalSurface::SetType(const G4SurfaceType& type)
00166 {
00167 theType = type;
00168 if (type == dielectric_LUT) {
00169 if (!AngularDistribution) AngularDistribution =
00170 new G4float[incidentIndexMax*thetaIndexMax*phiIndexMax];
00171 ReadFile();
00172 }
00173 }
00174
00175 void G4OpticalSurface::SetFinish(const G4OpticalSurfaceFinish finish)
00176 {
00177 theFinish = finish;
00178 if (theType == dielectric_LUT) {
00179 if (!AngularDistribution) AngularDistribution =
00180 new G4float[incidentIndexMax*thetaIndexMax*phiIndexMax];
00181 ReadFile();
00182 }
00183 }
00184
00185 void G4OpticalSurface::ReadFile()
00186 {
00187 G4String readFileName = " ";
00188
00189 if (theFinish == polishedlumirrorglue) {
00190 readFileName = "PolishedLumirrorGlue.dat";
00191 }
00192 else if (theFinish == polishedlumirrorair) {
00193 readFileName = "PolishedLumirror.dat";
00194 }
00195 else if (theFinish == polishedteflonair) {
00196 readFileName = "PolishedTeflon.dat";
00197 }
00198 else if (theFinish == polishedtioair) {
00199 readFileName = "PolishedTiO.dat";
00200 }
00201 else if (theFinish == polishedtyvekair) {
00202 readFileName = "PolishedTyvek.dat";
00203 }
00204 else if (theFinish == polishedvm2000glue) {
00205 readFileName = "PolishedVM2000Glue.dat";
00206 }
00207 else if (theFinish == polishedvm2000air) {
00208 readFileName = "PolishedVM2000.dat";
00209 }
00210 else if (theFinish == etchedlumirrorglue) {
00211 readFileName = "EtchedLumirrorGlue.dat";
00212 }
00213 else if (theFinish == etchedlumirrorair) {
00214 readFileName = "EtchedLumirror.dat";
00215 }
00216 else if (theFinish == etchedteflonair) {
00217 readFileName = "EtchedTeflon.dat";
00218 }
00219 else if (theFinish == etchedtioair) {
00220 readFileName = "EtchedTiO.dat";
00221 }
00222 else if (theFinish == etchedtyvekair) {
00223 readFileName = "EtchedTyvek.dat";
00224 }
00225 else if (theFinish == etchedvm2000glue) {
00226 readFileName = "EtchedVM2000Glue.dat";
00227 }
00228 else if (theFinish == etchedvm2000air) {
00229 readFileName = "EtchedVM2000.dat";
00230 }
00231 else if (theFinish == groundlumirrorglue) {
00232 readFileName = "GroundLumirrorGlue.dat";
00233 }
00234 else if (theFinish == groundlumirrorair) {
00235 readFileName = "GroundLumirror.dat";
00236 }
00237 else if (theFinish == groundteflonair) {
00238 readFileName = "GroundTeflon.dat";
00239 }
00240 else if (theFinish == groundtioair) {
00241 readFileName = "GroundTiO.dat";
00242 }
00243 else if (theFinish == groundtyvekair) {
00244 readFileName = "GroundTyvek.dat";
00245 }
00246 else if (theFinish == groundvm2000glue) {
00247 readFileName = "GroundVM2000Glue.dat";
00248 }
00249 else if (theFinish == groundvm2000air) {
00250 readFileName = "GroundVM2000.dat";
00251 }
00252
00253 if (readFileName == " ") return;
00254
00255 char* path = getenv("G4REALSURFACEDATA");
00256 if (!path) {
00257 G4String excep =
00258 "G4OpBoundaryProcess - G4REALSURFACEDATA environment variable not set";
00259 G4Exception("G4OpticalSurface::ReadFile()", "mat310",
00260 FatalException, excep);
00261 return;
00262 }
00263 G4String pathString(path);
00264
00265 readFileName = pathString + "/" + readFileName;
00266
00267 readFileHandle = fopen(readFileName,"r");
00268
00269 if (readFileHandle) {
00270 G4int ncols;
00271 G4int idxmax = incidentIndexMax*thetaIndexMax*phiIndexMax;
00272 for (G4int i = 0; i<idxmax; i++) {
00273 ncols = fscanf(readFileHandle,"%6f", &AngularDistribution[i]);
00274 if (ncols < 0) break;
00275 }
00276 if (ncols >= 0) {
00277 G4cout << "LUT - data file: " << readFileName << " read in! " << G4endl;
00278 }
00279 else {
00280 G4String excep = "LUT - data file: "+ readFileName +" not read propery";
00281 G4Exception("G4OpticalSurface::ReadFile()", "mat312",
00282 FatalException, excep);
00283 return;
00284 }
00285 }
00286 else {
00287 G4String excep = "LUT - data file: " + readFileName + " not found";
00288 G4Exception("G4OpticalSurface::ReadFile()", "mat311",
00289 FatalException, excep);
00290 return;
00291 }
00292 fclose(readFileHandle);
00293 }