Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4OpticalSurface.cc
Go to the documentation of this file.
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 // $Id: G4OpticalSurface.cc 67044 2013-01-30 08:50:06Z gcosmo $
27 //
28 //
30 // Optical Surface Class Implementation
32 //
33 // File: G4OpticalSurface.cc
34 // Description: An optical surface class for use in G4OpBoundaryProcess
35 // Version: 2.0
36 // Created: 1997-06-26
37 // Author: Peter Gumplinger
38 // mail: gum@triumf.ca
39 //
41 
42 #include "G4ios.hh"
43 #include "globals.hh"
44 #include "G4OpticalSurface.hh"
45 
47 // Class Implementation
49 
51  // Operators
53 
55 {
56  if (this != &right)
57  {
58  theName = right.theName;
59  theType = right.theType;
60  theModel = right.theModel;
61  theFinish = right.theFinish;
62  sigma_alpha = right.sigma_alpha;
63  polish = right.polish;
64  theMaterialPropertiesTable = right.theMaterialPropertiesTable;
65  AngularDistribution = right.AngularDistribution;
66  readFileHandle = right.readFileHandle;
67  }
68  return *this;
69 }
70 
72  // Constructors
74 
78  G4SurfaceType type,
80  : G4SurfaceProperty(name,type),
81  theModel(model),
82  theFinish(finish),
83  theMaterialPropertiesTable(0)
84 {
85  if (model == glisur ){
86  polish = value;
87  sigma_alpha = 0.0;
88  }
89  else if ( model == unified ) {
90  sigma_alpha = value;
91  polish = 0.0;
92  }
93  else if ( model == LUT ) {
94  sigma_alpha = value;
95  polish = 0.0;
96  }
97  else {
98  G4Exception("G4OpticalSurface::G4OpticalSurface()", "mat309",
100  "Constructor called with INVALID model.");
101  }
102 
103  AngularDistribution = NULL;
104 
105  if (type == dielectric_LUT) {
106  AngularDistribution =
107  new G4float[incidentIndexMax*thetaIndexMax*phiIndexMax];
108  ReadFile();
109  }
110 }
111 
113 {
114  if (AngularDistribution) delete AngularDistribution;
115 }
116 
118  : G4SurfaceProperty(right.theName,right.theType)
119 {
120  *this = right;
121  this->theMaterialPropertiesTable = right.theMaterialPropertiesTable;
122  this->AngularDistribution = right.AngularDistribution;
123  this->readFileHandle = right.readFileHandle;
124 }
125 
127 {
128  return (this == (G4OpticalSurface *) &right);
129 }
130 
132 {
133  return (this != (G4OpticalSurface *) &right);
134 }
136  // Methods
138 
140 {
141 
142  // Dump info for surface
143 
144  G4cout <<
145  " Surface type = " << G4int(theType) << G4endl <<
146  " Surface finish = " << G4int(theFinish) << G4endl <<
147  " Surface model = " << G4int(theModel) << G4endl;
148 
149  G4cout << G4endl;
150 
151  G4cout << " Surface parameter " << G4endl;
152  G4cout << " ----------------- " << G4endl;
153  if (theModel == glisur ){
154  G4cout << polish << G4endl;
155  }
156  else if (theModel == LUT ){
157  G4cout << sigma_alpha << G4endl;
158  }
159  else {
160  G4cout << sigma_alpha << G4endl;
161  }
162  G4cout << G4endl;
163 }
164 
166 {
167  theType = type;
168  if (type == dielectric_LUT) {
169  if (!AngularDistribution) AngularDistribution =
170  new G4float[incidentIndexMax*thetaIndexMax*phiIndexMax];
171  ReadFile();
172  }
173 }
174 
176 {
177  theFinish = finish;
178  if (theType == dielectric_LUT) {
179  if (!AngularDistribution) AngularDistribution =
180  new G4float[incidentIndexMax*thetaIndexMax*phiIndexMax];
181  ReadFile();
182  }
183 }
184 
186 {
187  G4String readFileName = " ";
188 
189  if (theFinish == polishedlumirrorglue) {
190  readFileName = "PolishedLumirrorGlue.dat";
191  }
192  else if (theFinish == polishedlumirrorair) {
193  readFileName = "PolishedLumirror.dat";
194  }
195  else if (theFinish == polishedteflonair) {
196  readFileName = "PolishedTeflon.dat";
197  }
198  else if (theFinish == polishedtioair) {
199  readFileName = "PolishedTiO.dat";
200  }
201  else if (theFinish == polishedtyvekair) {
202  readFileName = "PolishedTyvek.dat";
203  }
204  else if (theFinish == polishedvm2000glue) {
205  readFileName = "PolishedVM2000Glue.dat";
206  }
207  else if (theFinish == polishedvm2000air) {
208  readFileName = "PolishedVM2000.dat";
209  }
210  else if (theFinish == etchedlumirrorglue) {
211  readFileName = "EtchedLumirrorGlue.dat";
212  }
213  else if (theFinish == etchedlumirrorair) {
214  readFileName = "EtchedLumirror.dat";
215  }
216  else if (theFinish == etchedteflonair) {
217  readFileName = "EtchedTeflon.dat";
218  }
219  else if (theFinish == etchedtioair) {
220  readFileName = "EtchedTiO.dat";
221  }
222  else if (theFinish == etchedtyvekair) {
223  readFileName = "EtchedTyvek.dat";
224  }
225  else if (theFinish == etchedvm2000glue) {
226  readFileName = "EtchedVM2000Glue.dat";
227  }
228  else if (theFinish == etchedvm2000air) {
229  readFileName = "EtchedVM2000.dat";
230  }
231  else if (theFinish == groundlumirrorglue) {
232  readFileName = "GroundLumirrorGlue.dat";
233  }
234  else if (theFinish == groundlumirrorair) {
235  readFileName = "GroundLumirror.dat";
236  }
237  else if (theFinish == groundteflonair) {
238  readFileName = "GroundTeflon.dat";
239  }
240  else if (theFinish == groundtioair) {
241  readFileName = "GroundTiO.dat";
242  }
243  else if (theFinish == groundtyvekair) {
244  readFileName = "GroundTyvek.dat";
245  }
246  else if (theFinish == groundvm2000glue) {
247  readFileName = "GroundVM2000Glue.dat";
248  }
249  else if (theFinish == groundvm2000air) {
250  readFileName = "GroundVM2000.dat";
251  }
252 
253  if (readFileName == " ") return;
254 
255  char* path = getenv("G4REALSURFACEDATA");
256  if (!path) {
257  G4String excep =
258  "G4OpBoundaryProcess - G4REALSURFACEDATA environment variable not set";
259  G4Exception("G4OpticalSurface::ReadFile()", "mat310",
260  FatalException, excep);
261  return;
262  }
263  G4String pathString(path);
264 
265  readFileName = pathString + "/" + readFileName;
266 
267  readFileHandle = fopen(readFileName,"r");
268 
269  if (readFileHandle) {
270  G4int ncols;
271  G4int idxmax = incidentIndexMax*thetaIndexMax*phiIndexMax;
272  for (G4int i = 0; i<idxmax; i++) {
273  ncols = fscanf(readFileHandle,"%6f", &AngularDistribution[i]);
274  if (ncols < 0) break;
275  }
276  if (ncols >= 0) {
277  G4cout << "LUT - data file: " << readFileName << " read in! " << G4endl;
278  }
279  else {
280  G4String excep = "LUT - data file: "+ readFileName +" not read propery";
281  G4Exception("G4OpticalSurface::ReadFile()", "mat312",
282  FatalException, excep);
283  return;
284  }
285  }
286  else {
287  G4String excep = "LUT - data file: " + readFileName + " not found";
288  G4Exception("G4OpticalSurface::ReadFile()", "mat311",
289  FatalException, excep);
290  return;
291  }
292  fclose(readFileHandle);
293 }