Geant4.10
 All Data Structures 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 71488 2013-06-17 08:20:50Z gcosmo $
27 //
28 //
29 ////////////////////////////////////////////////////////////////////////
30 // Optical Surface Class Implementation
31 ////////////////////////////////////////////////////////////////////////
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 //
40 ////////////////////////////////////////////////////////////////////////
41 
42 #include "G4ios.hh"
43 #include "globals.hh"
44 #include "G4OpticalSurface.hh"
45 
46 /////////////////////////
47 // Class Implementation
48 /////////////////////////
49 
50  //////////////
51  // Operators
52  //////////////
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  readLUTFileHandle = right.readLUTFileHandle;
67  DichroicVector = right.DichroicVector;
68 
70  }
71  return *this;
72 }
73 
74  /////////////////
75  // Constructors
76  /////////////////
77 
81  G4SurfaceType type,
83  : G4SurfaceProperty(name,type),
84  theModel(model),
85  theFinish(finish),
86  theMaterialPropertiesTable(0)
87 {
88  if (model == glisur ){
89  polish = value;
90  sigma_alpha = 0.0;
91  }
92  else if ( model == unified ) {
93  sigma_alpha = value;
94  polish = 0.0;
95  }
96  else if ( model == LUT ) {
97  sigma_alpha = value;
98  polish = 0.0;
99  }
100  else if ( model == dichroic ) {
101  sigma_alpha = value;
102  polish = 0.0;
103  }
104  else {
105  G4Exception("G4OpticalSurface::G4OpticalSurface()", "mat309",
107  "Constructor called with INVALID model.");
108  }
109 
110  AngularDistribution = NULL;
111  DichroicVector = NULL;
112 
113  readLUTFileHandle = NULL;
114 
115  if (type == dielectric_LUT) {
116  AngularDistribution =
117  new G4float[incidentIndexMax*thetaIndexMax*phiIndexMax];
118  ReadLUTFile();
119  }
120 
121  if (type == dielectric_dichroic) {
122  DichroicVector = new G4Physics2DVector();
124  }
125 }
126 
128 {
129  if (AngularDistribution) delete AngularDistribution;
130  if (DichroicVector) delete DichroicVector;
131 
132  if (readLUTFileHandle) delete readLUTFileHandle;
133 }
134 
136  : G4SurfaceProperty(right.theName,right.theType)
137 {
138  *this = right;
139  this->theName = right.theName;
140  this->theType = right.theType;
141  this->theModel = right.theModel;
142  this->theFinish = right.theFinish;
143  this->sigma_alpha = right.sigma_alpha;
144  this->polish = right.polish;
145  this->theMaterialPropertiesTable = right.theMaterialPropertiesTable;
146  this->AngularDistribution = right.AngularDistribution;
147  this->readLUTFileHandle = right.readLUTFileHandle;
148  this->DichroicVector = right.DichroicVector;
149 }
150 
152 {
153  return (this == (G4OpticalSurface *) &right);
154 }
155 
157 {
158  return (this != (G4OpticalSurface *) &right);
159 }
160  ////////////
161  // Methods
162  ////////////
163 
165 {
166 
167  // Dump info for surface
168 
169  G4cout <<
170  " Surface type = " << G4int(theType) << G4endl <<
171  " Surface finish = " << G4int(theFinish) << G4endl <<
172  " Surface model = " << G4int(theModel) << G4endl;
173 
174  G4cout << G4endl;
175 
176  G4cout << " Surface parameter " << G4endl;
177  G4cout << " ----------------- " << G4endl;
178  if (theModel == glisur ){
179  G4cout << polish << G4endl;
180  }
181  else if (theModel == LUT ){
182  G4cout << sigma_alpha << G4endl;
183  }
184  else {
185  G4cout << sigma_alpha << G4endl;
186  }
187  G4cout << G4endl;
188 }
189 
191 {
192  theType = type;
193  if (type == dielectric_LUT) {
194  if (!AngularDistribution) AngularDistribution =
195  new G4float[incidentIndexMax*thetaIndexMax*phiIndexMax];
196  ReadLUTFile();
197  }
198  if (type == dielectric_dichroic) {
199  if (!DichroicVector) DichroicVector = new G4Physics2DVector();
201  }
202 }
203 
205 {
206  theFinish = finish;
207  if (theType == dielectric_LUT) {
208  if (!AngularDistribution) AngularDistribution =
209  new G4float[incidentIndexMax*thetaIndexMax*phiIndexMax];
210  ReadLUTFile();
211  }
212  if (theType == dielectric_dichroic) {
213  if (!DichroicVector) DichroicVector = new G4Physics2DVector();
215  }
216 }
217 
219 {
220  G4String readLUTFileName = " ";
221 
222  if (theFinish == polishedlumirrorglue) {
223  readLUTFileName = "PolishedLumirrorGlue.dat";
224  }
225  else if (theFinish == polishedlumirrorair) {
226  readLUTFileName = "PolishedLumirror.dat";
227  }
228  else if (theFinish == polishedteflonair) {
229  readLUTFileName = "PolishedTeflon.dat";
230  }
231  else if (theFinish == polishedtioair) {
232  readLUTFileName = "PolishedTiO.dat";
233  }
234  else if (theFinish == polishedtyvekair) {
235  readLUTFileName = "PolishedTyvek.dat";
236  }
237  else if (theFinish == polishedvm2000glue) {
238  readLUTFileName = "PolishedVM2000Glue.dat";
239  }
240  else if (theFinish == polishedvm2000air) {
241  readLUTFileName = "PolishedVM2000.dat";
242  }
243  else if (theFinish == etchedlumirrorglue) {
244  readLUTFileName = "EtchedLumirrorGlue.dat";
245  }
246  else if (theFinish == etchedlumirrorair) {
247  readLUTFileName = "EtchedLumirror.dat";
248  }
249  else if (theFinish == etchedteflonair) {
250  readLUTFileName = "EtchedTeflon.dat";
251  }
252  else if (theFinish == etchedtioair) {
253  readLUTFileName = "EtchedTiO.dat";
254  }
255  else if (theFinish == etchedtyvekair) {
256  readLUTFileName = "EtchedTyvek.dat";
257  }
258  else if (theFinish == etchedvm2000glue) {
259  readLUTFileName = "EtchedVM2000Glue.dat";
260  }
261  else if (theFinish == etchedvm2000air) {
262  readLUTFileName = "EtchedVM2000.dat";
263  }
264  else if (theFinish == groundlumirrorglue) {
265  readLUTFileName = "GroundLumirrorGlue.dat";
266  }
267  else if (theFinish == groundlumirrorair) {
268  readLUTFileName = "GroundLumirror.dat";
269  }
270  else if (theFinish == groundteflonair) {
271  readLUTFileName = "GroundTeflon.dat";
272  }
273  else if (theFinish == groundtioair) {
274  readLUTFileName = "GroundTiO.dat";
275  }
276  else if (theFinish == groundtyvekair) {
277  readLUTFileName = "GroundTyvek.dat";
278  }
279  else if (theFinish == groundvm2000glue) {
280  readLUTFileName = "GroundVM2000Glue.dat";
281  }
282  else if (theFinish == groundvm2000air) {
283  readLUTFileName = "GroundVM2000.dat";
284  }
285 
286  if (readLUTFileName == " ") return;
287 
288  char* path = getenv("G4REALSURFACEDATA");
289  if (!path) {
290  G4String excep =
291  "G4OpBoundaryProcess - G4REALSURFACEDATA environment variable not set";
292  G4Exception("G4OpticalSurface::ReadLUTFile()", "mat310",
293  FatalException, excep);
294  return;
295  }
296  G4String pathString(path);
297 
298  readLUTFileName = pathString + "/" + readLUTFileName;
299 
300  readLUTFileHandle = fopen(readLUTFileName,"r");
301 
302  if (readLUTFileHandle) {
303  G4int ncols;
304  G4int idxmax = incidentIndexMax*thetaIndexMax*phiIndexMax;
305  for (G4int i = 0; i<idxmax; i++) {
306  ncols = fscanf(readLUTFileHandle,"%6f", &AngularDistribution[i]);
307  if (ncols < 0) break;
308  }
309  if (ncols >= 0) {
310  G4cout << "LUT - data file: " << readLUTFileName << " read in! " << G4endl;
311  }
312  else {
313  G4String excep = "LUT - data file: "+ readLUTFileName +" not read propery";
314  G4Exception("G4OpticalSurface::ReadLUTFile()", "mat312",
315  FatalException, excep);
316  return;
317  }
318  }
319  else {
320  G4String excep = "LUT - data file: " + readLUTFileName + " not found";
321  G4Exception("G4OpticalSurface::ReadLUTFile()", "mat311",
322  FatalException, excep);
323  return;
324  }
325  fclose(readLUTFileHandle);
326 }
327 
329 {
330  const char* datadir = getenv("G4DICHROICDATA");
331 
332  if(!datadir) {
333  G4Exception("G4OpticalSurface::ReadDichroicFile()","mat313",
334  FatalException,"Environment variable G4DICHROICDATA not defined");
335  return;
336  }
337 
338  std::ostringstream ost;
339  ost << datadir;
340  std::ifstream fin(ost.str().c_str());
341  if( !fin.is_open()) {
343  ed << "Dichroic surface data file <" << ost.str().c_str()
344  << "> is not opened!" << G4endl;
345  G4Exception("G4OpticalSurface::ReadDichroicFile()","mat314",
346  FatalException,ed," ");
347  return;
348  }
349 
350  if( !(DichroicVector->Retrieve(fin)) ) {
352  ed << "Dichroic surface data file <" << ost.str().c_str()
353  << "> is not opened!" << G4endl;
354  G4Exception("G4OpticalSurface::ReadDichroicFile()","mat315",
355  FatalException,ed," ");
356  return;
357  }
358 
359 // DichroicVector->SetBicubicInterpolation(true);
360 
361  G4cout << " *** Dichroic surface data file *** " << G4endl;
362 
363  size_t numberOfXNodes = DichroicVector->GetLengthX();
364  size_t numberOfYNodes = DichroicVector->GetLengthY();
365 
366  G4cout << "numberOfXNodes: " << numberOfXNodes << G4endl;
367  G4cout << "numberOfYNodes: " << numberOfYNodes << G4endl;
368 
369  G4PV2DDataVector xVector;
370  G4PV2DDataVector yVector;
371 
372  xVector.resize(numberOfXNodes,0.);
373  yVector.resize(numberOfYNodes,0.);
374 
375  for(size_t i = 0; i<numberOfXNodes; ++i) {
376  G4cout << "i: " << DichroicVector->GetX(i) << G4endl;
377  xVector[i] = DichroicVector->GetX(i);
378  }
379  for(size_t j = 0; j<numberOfYNodes; ++j) {
380  G4cout << "j: " << DichroicVector->GetY(j) << G4endl;
381  yVector[j] = DichroicVector->GetY(j);
382  }
383 
384  for(size_t j = 0; j<numberOfYNodes; ++j) {
385  for(size_t i = 0; i<numberOfXNodes; ++i) {
386  G4cout << " i: " << i << " j: " << j << " "
387  << DichroicVector->GetValue(i,j) << G4endl;
388  }
389  }
390 
391 // size_t idx, idy;
392 
393 // for(size_t j = 0; j<numberOfYNodes-1; ++j) {
394 // G4double y = (yVector[j] + yVector[j+1])/2.;
395 // for(size_t i = 0; i<numberOfXNodes-1; ++i) {
396 // G4double x = (xVector[i] + xVector[i+1])/2.;
397 // G4cout << " x: " << x << " y: " << y << " "
398 // << DichroicVector->Value(x,y,idx,idy) << G4endl;
399 // }
400 // }
401 
402 }
void SetFinish(const G4OpticalSurfaceFinish)
std::vector< G4double > G4PV2DDataVector
G4double GetValue(size_t idx, size_t idy) const
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4int operator==(const G4OpticalSurface &right) const
float G4float
Definition: G4Types.hh:77
void DumpInfo() const
size_t GetLengthY() const
G4OpticalSurface(const G4OpticalSurface &right)
const XML_Char * name
G4SurfaceType
int G4int
Definition: G4Types.hh:78
virtual ~G4OpticalSurface()
G4GLOB_DLL std::ostream G4cout
G4OpticalSurface & operator=(const G4OpticalSurface &right)
G4int operator!=(const G4OpticalSurface &right) const
const XML_Char XML_Content * model
size_t GetLengthX() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4bool Retrieve(std::ifstream &fIn)
G4OpticalSurfaceFinish
G4double GetY(size_t index) const
const XML_Char int const XML_Char * value
G4OpticalSurfaceModel
#define G4endl
Definition: G4ios.hh:61
static G4SurfacePropertyTable theSurfacePropertyTable
double G4double
Definition: G4Types.hh:76
void ReadDichroicFile(void)
G4double GetX(size_t index) const
void SetType(const G4SurfaceType &type)