[822] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
[1196] | 27 | // $Id: G4OpticalSurface.cc,v 1.15 2009/11/20 00:57:51 gum Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
[822] | 29 | // |
---|
| 30 | // |
---|
| 31 | //////////////////////////////////////////////////////////////////////// |
---|
| 32 | // Optical Surface Class Implementation |
---|
| 33 | //////////////////////////////////////////////////////////////////////// |
---|
| 34 | // |
---|
| 35 | // File: G4OpticalSurface.cc |
---|
| 36 | // Description: An optical surface class for use in G4OpBoundaryProcess |
---|
| 37 | // Version: 2.0 |
---|
| 38 | // Created: 1997-06-26 |
---|
| 39 | // Author: Peter Gumplinger |
---|
| 40 | // mail: gum@triumf.ca |
---|
| 41 | // |
---|
| 42 | //////////////////////////////////////////////////////////////////////// |
---|
| 43 | |
---|
| 44 | #include "G4ios.hh" |
---|
| 45 | #include "globals.hh" |
---|
| 46 | #include "G4OpticalSurface.hh" |
---|
| 47 | |
---|
| 48 | ///////////////////////// |
---|
| 49 | // Class Implementation |
---|
| 50 | ///////////////////////// |
---|
| 51 | |
---|
| 52 | ////////////// |
---|
| 53 | // Operators |
---|
| 54 | ////////////// |
---|
| 55 | |
---|
| 56 | const G4OpticalSurface& |
---|
| 57 | G4OpticalSurface::operator=(const G4OpticalSurface& right) |
---|
| 58 | { |
---|
| 59 | if (this != &right) |
---|
| 60 | { |
---|
| 61 | theName = right.GetName(); |
---|
| 62 | theModel = right.theModel; |
---|
| 63 | theFinish = right.theFinish; |
---|
| 64 | theType = right.GetType(); |
---|
| 65 | sigma_alpha = right.sigma_alpha; |
---|
| 66 | polish = right.polish; |
---|
| 67 | theMaterialPropertiesTable = right.theMaterialPropertiesTable; |
---|
[1196] | 68 | AngularDistribution = right.AngularDistribution; |
---|
[822] | 69 | } |
---|
| 70 | return *this; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | ///////////////// |
---|
| 74 | // Constructors |
---|
| 75 | ///////////////// |
---|
| 76 | |
---|
| 77 | G4OpticalSurface::G4OpticalSurface(const G4String& name, |
---|
| 78 | G4OpticalSurfaceModel model, |
---|
| 79 | G4OpticalSurfaceFinish finish, |
---|
| 80 | G4SurfaceType type, |
---|
| 81 | G4double value) |
---|
| 82 | : G4SurfaceProperty(name,type), |
---|
| 83 | theModel(model), |
---|
| 84 | theFinish(finish), |
---|
| 85 | theMaterialPropertiesTable(0) |
---|
| 86 | { |
---|
| 87 | if (model == glisur ){ |
---|
| 88 | polish = value; |
---|
| 89 | sigma_alpha = 0.0; |
---|
| 90 | } |
---|
| 91 | else if ( model == unified ) { |
---|
| 92 | sigma_alpha = value; |
---|
| 93 | polish = 0.0; |
---|
| 94 | } |
---|
[1196] | 95 | else if ( model == LUT ) { |
---|
| 96 | sigma_alpha = value; |
---|
| 97 | polish = 0.0; |
---|
| 98 | } |
---|
[822] | 99 | else { |
---|
| 100 | G4Exception("G4OpticalSurface::G4OpticalSurface ==> " |
---|
| 101 | "Constructor called with INVALID model."); |
---|
| 102 | } |
---|
| 103 | |
---|
[1196] | 104 | AngularDistribution = NULL; |
---|
| 105 | |
---|
| 106 | if (type == dielectric_LUT) { |
---|
| 107 | AngularDistribution = |
---|
| 108 | new float[incidentIndexMax*thetaIndexMax*phiIndexMax]; |
---|
| 109 | ReadFile(); |
---|
| 110 | } |
---|
[822] | 111 | } |
---|
| 112 | |
---|
[850] | 113 | G4OpticalSurface::~G4OpticalSurface() |
---|
| 114 | { |
---|
[1196] | 115 | if (AngularDistribution) delete AngularDistribution; |
---|
[850] | 116 | } |
---|
[822] | 117 | |
---|
[986] | 118 | G4OpticalSurface::G4OpticalSurface(const G4OpticalSurface &right) |
---|
| 119 | : G4SurfaceProperty(right.GetName()) |
---|
| 120 | { |
---|
| 121 | *this = right; |
---|
| 122 | } |
---|
| 123 | |
---|
[822] | 124 | G4int G4OpticalSurface::operator==(const G4OpticalSurface &right) const |
---|
| 125 | { |
---|
| 126 | return (this == (G4OpticalSurface *) &right); |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | G4int G4OpticalSurface::operator!=(const G4OpticalSurface &right) const |
---|
| 130 | { |
---|
| 131 | return (this != (G4OpticalSurface *) &right); |
---|
| 132 | } |
---|
| 133 | //////////// |
---|
| 134 | // Methods |
---|
| 135 | //////////// |
---|
| 136 | |
---|
| 137 | void G4OpticalSurface::DumpInfo() const |
---|
| 138 | { |
---|
| 139 | |
---|
| 140 | // Dump info for surface |
---|
| 141 | |
---|
| 142 | G4cout << |
---|
| 143 | " Surface type = " << G4int(theType) << G4endl << |
---|
| 144 | " Surface finish = " << G4int(theFinish) << G4endl << |
---|
| 145 | " Surface model = " << G4int(theModel) << G4endl; |
---|
| 146 | |
---|
| 147 | G4cout << G4endl; |
---|
| 148 | |
---|
| 149 | G4cout << " Surface parameter " << G4endl; |
---|
| 150 | G4cout << " ----------------- " << G4endl; |
---|
| 151 | if (theModel == glisur ){ |
---|
| 152 | G4cout << polish << G4endl; |
---|
| 153 | } |
---|
[1196] | 154 | else if (theModel == LUT ){ |
---|
| 155 | G4cout << sigma_alpha << G4endl; |
---|
| 156 | } |
---|
[822] | 157 | else { |
---|
| 158 | G4cout << sigma_alpha << G4endl; |
---|
| 159 | } |
---|
| 160 | G4cout << G4endl; |
---|
| 161 | } |
---|
[1196] | 162 | |
---|
| 163 | void G4OpticalSurface::SetType(const G4SurfaceType& type) |
---|
| 164 | { |
---|
| 165 | theType = type; |
---|
| 166 | if (type == dielectric_LUT) { |
---|
| 167 | if (!AngularDistribution) AngularDistribution = |
---|
| 168 | new float[incidentIndexMax*thetaIndexMax*phiIndexMax]; |
---|
| 169 | ReadFile(); |
---|
| 170 | } |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | void G4OpticalSurface::SetFinish(const G4OpticalSurfaceFinish finish) |
---|
| 174 | { |
---|
| 175 | theFinish = finish; |
---|
| 176 | if (theType == dielectric_LUT) { |
---|
| 177 | if (!AngularDistribution) AngularDistribution = |
---|
| 178 | new float[incidentIndexMax*thetaIndexMax*phiIndexMax]; |
---|
| 179 | ReadFile(); |
---|
| 180 | } |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | void G4OpticalSurface::ReadFile() |
---|
| 184 | { |
---|
| 185 | G4String readFileName = " "; |
---|
| 186 | |
---|
| 187 | if (theFinish == polishedlumirrorglue) { |
---|
| 188 | readFileName = "PolishedLumirrorGlue.dat"; |
---|
| 189 | } |
---|
| 190 | else if (theFinish == polishedlumirrorair) { |
---|
| 191 | readFileName = "PolishedLumirror.dat"; |
---|
| 192 | } |
---|
| 193 | else if (theFinish == polishedteflonair) { |
---|
| 194 | readFileName = "PolishedTeflon.dat"; |
---|
| 195 | } |
---|
| 196 | else if (theFinish == polishedtioair) { |
---|
| 197 | readFileName = "PolishedTiO.dat"; |
---|
| 198 | } |
---|
| 199 | else if (theFinish == polishedtyvekair) { |
---|
| 200 | readFileName = "PolishedTyvek.dat"; |
---|
| 201 | } |
---|
| 202 | else if (theFinish == polishedvm2000glue) { |
---|
| 203 | readFileName = "PolishedVM2000Glue.dat"; |
---|
| 204 | } |
---|
| 205 | else if (theFinish == polishedvm2000air) { |
---|
| 206 | readFileName = "PolishedVM2000.dat"; |
---|
| 207 | } |
---|
| 208 | else if (theFinish == etchedlumirrorglue) { |
---|
| 209 | readFileName = "EtchedLumirrorGlue.dat"; |
---|
| 210 | } |
---|
| 211 | else if (theFinish == etchedlumirrorair) { |
---|
| 212 | readFileName = "EtchedLumirror.dat"; |
---|
| 213 | } |
---|
| 214 | else if (theFinish == etchedteflonair) { |
---|
| 215 | readFileName = "EtchedTeflon.dat"; |
---|
| 216 | } |
---|
| 217 | else if (theFinish == etchedtioair) { |
---|
| 218 | readFileName = "EtchedTiO.dat"; |
---|
| 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"; |
---|
| 249 | } |
---|
| 250 | |
---|
| 251 | if (readFileName == " ") return; |
---|
| 252 | |
---|
| 253 | char* path = getenv("G4REALSURFACEDATA"); |
---|
| 254 | if (!path) { |
---|
| 255 | G4String excep = |
---|
| 256 | "G4OpBoundaryProcess - G4REALSURFACEDATA environment variable not set"; |
---|
| 257 | G4Exception(excep); |
---|
| 258 | } |
---|
| 259 | G4String pathString(path); |
---|
| 260 | |
---|
| 261 | readFileName = pathString + "/" + readFileName; |
---|
| 262 | |
---|
| 263 | // Open LUT with Material and Integer Angle |
---|
| 264 | FILE* readFileHandle; |
---|
| 265 | |
---|
| 266 | readFileHandle = fopen(readFileName,"r"); |
---|
| 267 | |
---|
| 268 | if (readFileHandle!=NULL) { |
---|
| 269 | for (int i=0;i<incidentIndexMax*thetaIndexMax*phiIndexMax;i++) { |
---|
| 270 | fscanf(readFileHandle,"%6f", &AngularDistribution[i]); |
---|
| 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); |
---|
| 277 | } |
---|
| 278 | fclose(readFileHandle); |
---|
| 279 | } |
---|