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