Geant4  10.00.p02
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 //
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;
68 
70  }
71  return *this;
72 }
73 
75  // Constructors
77 
81  G4SurfaceType type,
82  G4double value)
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) {
118  ReadLUTFile();
119  }
120 
121  if (type == dielectric_dichroic) {
124  }
125 }
126 
128 {
130  if (DichroicVector) delete DichroicVector;
131 
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;
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 }
161  // Methods
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) {
196  ReadLUTFile();
197  }
198  if (type == dielectric_dichroic) {
201  }
202 }
203 
205 {
206  theFinish = finish;
207  if (theType == dielectric_LUT) {
210  ReadLUTFile();
211  }
212  if (theType == dielectric_dichroic) {
215  }
216 }
217 
219 {
220  G4String readLUTFileName = " ";
221 
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;
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
G4OpticalSurfaceModel theModel
G4int operator==(const G4OpticalSurface &right) const
G4String name
Definition: TRTMaterials.hh:40
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
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
G4bool Retrieve(std::ifstream &fIn)
G4OpticalSurfaceFinish
G4double GetY(size_t index) const
G4OpticalSurfaceModel
#define G4endl
Definition: G4ios.hh:61
static G4SurfacePropertyTable theSurfacePropertyTable
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