Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4OpticalSurface.cc
이 파일의 문서화 페이지로 가기
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 108421 2018-02-13 11:16:20Z 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 // updated: 2017-02-24 Mariele Stockhoff add DAVIS model
39 // mail: gum@triumf.ca
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;
68 
73 
77 
78  if (Reflectivity) delete [] Reflectivity;
80  *(Reflectivity) = *(right.Reflectivity);
81 
82  if (DichroicVector) delete DichroicVector;
84  *DichroicVector = *(right.DichroicVector);
85  }
86  return *this;
87 }
88 
90  // Constructors
92 
96  G4SurfaceType type,
98  : G4SurfaceProperty(name,type),
99  theModel(model),
100  theFinish(finish),
101  theMaterialPropertiesTable(0)
102 {
103  if ( model == glisur ){
104  polish = value;
105  sigma_alpha = 0.0;
106  }
107  else if ( model == unified ) {
108  sigma_alpha = value;
109  polish = 0.0;
110  }
111  else if ( model == LUT ) {
112  sigma_alpha = value;
113  polish = 0.0;
114  }
115  else if ( model == dichroic ) {
116  sigma_alpha = value;
117  polish = 0.0;
118  }
119  else if ( model == DAVIS ) {
120  sigma_alpha = value;
121  polish = 0.0;
122  }
123  else {
124  G4Exception("G4OpticalSurface::G4OpticalSurface()", "mat309",
126  "Constructor called with INVALID model.");
127  }
128 
129  AngularDistribution = NULL;
130 
131  AngularDistributionLUT = NULL;
132  Reflectivity = NULL;
133 
134  DichroicVector = NULL;
135 
136  if (type == dielectric_LUT) {
139  ReadLUTFile();
140  }
141 
142  if (type == dielectric_LUTDAVIS) {
145 
146  Reflectivity = new G4float[RefMax];
148  }
149 
150  if (type == dielectric_dichroic) {
153  }
154 }
155 
157 {
159 
161  if (Reflectivity) delete [] Reflectivity;
162 
163  if (DichroicVector) delete DichroicVector;
164 }
165 
167  : G4SurfaceProperty(right.theName,right.theType)
168 {
169  *this = right;
170  this->theName = right.theName;
171  this->theType = right.theType;
172  this->theModel = right.theModel;
173  this->theFinish = right.theFinish;
174  this->sigma_alpha = right.sigma_alpha;
175  this->polish = right.polish;
177 
178  if (this->AngularDistribution) delete [] AngularDistribution;
179  this->AngularDistribution =
181  *(this->AngularDistribution) = *(right.AngularDistribution);
182 
183  if (this->AngularDistributionLUT) delete [] AngularDistributionLUT;
186  if (this->Reflectivity) delete [] Reflectivity;
187  this->Reflectivity = new G4float[RefMax];
188  *(this->Reflectivity) = *(right.Reflectivity);
189 
190  if (this->DichroicVector) delete DichroicVector;
191  this->DichroicVector = new G4Physics2DVector();
192  *(this->DichroicVector) = *(right.DichroicVector);
193 }
194 
196 {
197  return (this == (G4OpticalSurface *) &right);
198 }
199 
201 {
202  return (this != (G4OpticalSurface *) &right);
203 }
205  // Methods
207 
209 {
210  return indexmax;
211 }
212 
214 {
215  return LUTbins;
216 }
217 
219 {
220  return RefMax;
221 }
222 
224 {
225  return thetaIndexMax;
226 }
227 
229 {
230  return phiIndexMax;
231 }
232 
234 {
235  // Dump info for surface
236 
237  G4cout <<
238  " Surface type = " << G4int(theType) << G4endl <<
239  " Surface finish = " << G4int(theFinish) << G4endl <<
240  " Surface model = " << G4int(theModel) << G4endl;
241 
242  G4cout << G4endl;
243 
244  G4cout << " Surface parameter " << G4endl;
245  G4cout << " ----------------- " << G4endl;
246  if (theModel == glisur ){
247  G4cout << polish << G4endl;
248  }
249  else if (theModel == LUT ){
250  G4cout << sigma_alpha << G4endl;
251  }
252  else {
253  G4cout << sigma_alpha << G4endl;
254  }
255  G4cout << G4endl;
256 }
257 
259 {
260  theType = type;
261 
262  if (type == dielectric_LUTDAVIS) {
264  new G4float[indexmax];
266  }
267 
268  if (type == dielectric_LUT) {
271 
272  ReadLUTFile();
273  }
274  if (type == dielectric_dichroic) {
277  }
278 }
279 
281 {
282  theFinish = finish;
283  if (theType == dielectric_LUT) {
286  ReadLUTFile();
287  }
288 
289  if (theType == dielectric_LUTDAVIS) {
291  new G4float[indexmax];
293 
296  }
297 
298  if (theType == dielectric_dichroic) {
301  }
302 }
303 
305 {
306  G4String readLUTFileName = " ";
307 
309  readLUTFileName = "PolishedLumirrorGlue.dat";
310  }
311  else if (theFinish == polishedlumirrorair) {
312  readLUTFileName = "PolishedLumirror.dat";
313  }
314  else if (theFinish == polishedteflonair) {
315  readLUTFileName = "PolishedTeflon.dat";
316  }
317  else if (theFinish == polishedtioair) {
318  readLUTFileName = "PolishedTiO.dat";
319  }
320  else if (theFinish == polishedtyvekair) {
321  readLUTFileName = "PolishedTyvek.dat";
322  }
323  else if (theFinish == polishedvm2000glue) {
324  readLUTFileName = "PolishedVM2000Glue.dat";
325  }
326  else if (theFinish == polishedvm2000air) {
327  readLUTFileName = "PolishedVM2000.dat";
328  }
329  else if (theFinish == etchedlumirrorglue) {
330  readLUTFileName = "EtchedLumirrorGlue.dat";
331  }
332  else if (theFinish == etchedlumirrorair) {
333  readLUTFileName = "EtchedLumirror.dat";
334  }
335  else if (theFinish == etchedteflonair) {
336  readLUTFileName = "EtchedTeflon.dat";
337  }
338  else if (theFinish == etchedtioair) {
339  readLUTFileName = "EtchedTiO.dat";
340  }
341  else if (theFinish == etchedtyvekair) {
342  readLUTFileName = "EtchedTyvek.dat";
343  }
344  else if (theFinish == etchedvm2000glue) {
345  readLUTFileName = "EtchedVM2000Glue.dat";
346  }
347  else if (theFinish == etchedvm2000air) {
348  readLUTFileName = "EtchedVM2000.dat";
349  }
350  else if (theFinish == groundlumirrorglue) {
351  readLUTFileName = "GroundLumirrorGlue.dat";
352  }
353  else if (theFinish == groundlumirrorair) {
354  readLUTFileName = "GroundLumirror.dat";
355  }
356  else if (theFinish == groundteflonair) {
357  readLUTFileName = "GroundTeflon.dat";
358  }
359  else if (theFinish == groundtioair) {
360  readLUTFileName = "GroundTiO.dat";
361  }
362  else if (theFinish == groundtyvekair) {
363  readLUTFileName = "GroundTyvek.dat";
364  }
365  else if (theFinish == groundvm2000glue) {
366  readLUTFileName = "GroundVM2000Glue.dat";
367  }
368  else if (theFinish == groundvm2000air) {
369  readLUTFileName = "GroundVM2000.dat";
370  }
371 
372  if (readLUTFileName == " ") return;
373 
374  char* path = getenv("G4REALSURFACEDATA");
375  if (!path) {
376  G4String excep =
377  "G4OpBoundaryProcess - G4REALSURFACEDATA environment variable not set";
378  G4Exception("G4OpticalSurface::ReadLUTFile()", "mat310",
379  FatalException, excep);
380  return;
381  }
382  G4String pathString(path);
383 
384  readLUTFileName = pathString + "/" + readLUTFileName;
385 
386  std::ifstream readLUTFileHandle(readLUTFileName, std::ios::in);
387 
388  if (readLUTFileHandle) {
390  for (G4int i = 0; i<idxmax; i++) {
391  if (readLUTFileHandle.eof()) break;
392  readLUTFileHandle >> AngularDistribution[i];
393  }
394  if (!readLUTFileHandle.bad()) {
395  G4cout <<"LUT - data file: "<< readLUTFileName <<" read in! "<< G4endl;
396  }
397  else {
398  G4String excep="LUT - data file: "+readLUTFileName+" not read propery";
399  G4Exception("G4OpticalSurface::ReadLUTFile()", "mat312",
400  FatalException, excep);
401  return;
402  }
403  }
404  else {
405  G4String excep ="LUT - data file: "+readLUTFileName+" not found";
406  G4Exception("G4OpticalSurface::ReadLUTFile()", "mat311",
407  FatalException, excep);
408  return;
409  }
410  readLUTFileHandle.close();
411 }
412 
414 {
415  G4String readLUTDAVISFileName = " ";
416 
417  if (theFinish == Rough_LUT) {
418  readLUTDAVISFileName = "Rough_LUT.dat";
419  }else if (theFinish == RoughTeflon_LUT) {
420  readLUTDAVISFileName = "RoughTeflon_LUT.dat";
421  }else if (theFinish == RoughESR_LUT) {
422  readLUTDAVISFileName = "RoughESR_LUT.dat";
423  }else if (theFinish == RoughESRGrease_LUT) {
424  readLUTDAVISFileName = "RoughESRGrease_LUT.dat";
425  }else if (theFinish == Polished_LUT) {
426  readLUTDAVISFileName = "Polished_LUT.dat";
427  }else if (theFinish == PolishedTeflon_LUT) {
428  readLUTDAVISFileName = "PolishedTeflon_LUT.dat";
429  }else if (theFinish == PolishedESR_LUT) {
430  readLUTDAVISFileName = "PolishedESR_LUT.dat";
431  }else if (theFinish == PolishedESRGrease_LUT) {
432  readLUTDAVISFileName = "PolishedESRGrease_LUT.dat";
433  }else if (theFinish == Detector_LUT) {
434  readLUTDAVISFileName = "Detector_LUT.dat";
435  }
436 
437  if (readLUTDAVISFileName == " ") return;
438 
439  char* path = getenv("G4REALSURFACEDATA");
440  if (!path) {
441  G4String excep =
442  "G4OpBoundaryProcess - G4REALSURFACEDATA environment variable not set";
443  G4Exception("G4OpticalSurface::ReadLUTDAVISFile()", "mat310",
444  FatalException, excep);
445  return;
446  }
447  G4String pathString(path);
448 
449  readLUTDAVISFileName = pathString + "/" + readLUTDAVISFileName;
450 
451  std::ifstream readLUTDAVISFileHandle(readLUTDAVISFileName, std::ios::in);
452 
453  if (readLUTDAVISFileHandle) {
454 
455  for (G4int i = 0; i<indexmax; i++) {
456  if (readLUTDAVISFileHandle.eof()) break;
457  readLUTDAVISFileHandle >> AngularDistributionLUT[i];
458  }
459  if (!readLUTDAVISFileHandle.bad()) {
460  G4cout <<"LUT DAVIS - data file: " <<
461  readLUTDAVISFileName << " read in! " << G4endl;
462  }
463  else {
464  G4String excep="LUT DAVIS- data file: "+readLUTDAVISFileName+" not read propery";
465  G4Exception("G4OpticalSurface::ReadLUTFile()", "mat312",
466  FatalException, excep);
467  return;
468  }
469  }
470  else {
471  G4String excep ="LUT DAVIS- data file: "+readLUTDAVISFileName+" not found";
472  G4Exception("G4OpticalSurface::ReadLUTFile()", "mat311",
473  FatalException, excep);
474  return;
475  }
476  readLUTDAVISFileHandle.close();
477 }
478 
480 {
481  G4String readReflectivityLUTFileName = " ";
482 
483  if (theFinish == Rough_LUT) {
484  readReflectivityLUTFileName = "Rough_LUTR.dat";
485  }
486  if (theFinish == RoughTeflon_LUT) {
487  readReflectivityLUTFileName = "RoughTeflon_LUTR.dat";
488  }
489  if (theFinish== RoughESR_LUT) {
490  readReflectivityLUTFileName = "RoughESR_LUTR.dat";
491  }
492  if (theFinish == RoughESRGrease_LUT) {
493  readReflectivityLUTFileName = "RoughESRGrease_LUTR.dat";
494  }
495  if (theFinish== Polished_LUT) {
496  readReflectivityLUTFileName = "Polished_LUTR.dat";
497  }
498  if (theFinish == PolishedTeflon_LUT) {
499  readReflectivityLUTFileName = "PolishedTeflon_LUTR.dat";
500  }
501  if (theFinish== PolishedESR_LUT) {
502  readReflectivityLUTFileName = "PolishedESR_LUTR.dat";
503  }
505  readReflectivityLUTFileName = "PolishedESRGrease_LUTR.dat";
506  }
507  if (theFinish== Detector_LUT) {
508  readReflectivityLUTFileName = "Detector_LUTR.dat";
509  }
510 
511  if (readReflectivityLUTFileName == " ") return;
512 
513  char* path = getenv("G4REALSURFACEDATA");
514  if (!path) {
515  G4String excep =
516  "G4OpBoundaryProcess - G4REALSURFACEDATA environment variable not set";
517  G4Exception("G4OpticalSurface::ReadReflectivityLUTFile()", "mat310",
518  FatalException, excep);
519  return;
520  }
521  G4String pathString(path);
522 
523  readReflectivityLUTFileName = pathString + "/" + readReflectivityLUTFileName;
524 
525  std::ifstream readReflectivityLUTFileHandle(readReflectivityLUTFileName,
526  std::ios::in);
527 
528  if (readReflectivityLUTFileHandle) {
529  for (G4int i = 0; i<RefMax; i++) {
530  if (readReflectivityLUTFileHandle.eof()) break;
531  readReflectivityLUTFileHandle >> Reflectivity[i];
532  }
533  if (!readReflectivityLUTFileHandle.bad()) {
534  G4cout << "Reflectivity LUT DAVIS - data file: " <<
535  readReflectivityLUTFileName << " read in! " << G4endl;
536  }
537  else {
538  G4String excep="Reflectivity LUT DAVIS- data file: "+readReflectivityLUTFileName+" not read propery";
539  G4Exception("G4OpticalSurface::ReadReflectivityLUTFile()", "mat312",
540  FatalException, excep);
541  return;
542  }
543  }
544  else {
545  G4String excep ="Reflectivity LUT DAVIS - data file: "+readReflectivityLUTFileName+" not found";
546  G4Exception("G4OpticalSurface::ReadReflectivityLUTFile()", "mat311",
547  FatalException, excep);
548  return;
549  }
550  readReflectivityLUTFileHandle.close();
551 }
552 
554 {
555  const char* datadir = getenv("G4DICHROICDATA");
556 
557  if(!datadir) {
558  G4Exception("G4OpticalSurface::ReadDichroicFile()","mat313",
559  FatalException,"Environment variable G4DICHROICDATA not defined");
560  return;
561  }
562 
563  std::ostringstream ost;
564  ost << datadir;
565  std::ifstream fin(ost.str().c_str());
566  if( !fin.is_open()) {
568  ed << "Dichroic surface data file <" << ost.str().c_str()
569  << "> is not opened!" << G4endl;
570  G4Exception("G4OpticalSurface::ReadDichroicFile()","mat314",
571  FatalException,ed," ");
572  return;
573  }
574 
575  if( !(DichroicVector->Retrieve(fin)) ) {
577  ed << "Dichroic surface data file <" << ost.str().c_str()
578  << "> is not opened!" << G4endl;
579  G4Exception("G4OpticalSurface::ReadDichroicFile()","mat315",
580  FatalException,ed," ");
581  return;
582  }
583 
584 // DichroicVector->SetBicubicInterpolation(true);
585 
586  G4cout << " *** Dichroic surface data file *** " << G4endl;
587 
588  G4int numberOfXNodes = DichroicVector->GetLengthX();
589  G4int numberOfYNodes = DichroicVector->GetLengthY();
590 
591  G4cout << "numberOfXNodes: " << numberOfXNodes << G4endl;
592  G4cout << "numberOfYNodes: " << numberOfYNodes << G4endl;
593 
594  if (0 > numberOfXNodes || numberOfXNodes >= INT_MAX) numberOfXNodes = 0;
595  if (0 > numberOfYNodes || numberOfYNodes >= INT_MAX) numberOfYNodes = 0;
596 
597  G4PV2DDataVector xVector;
598  G4PV2DDataVector yVector;
599 
600  xVector.resize(numberOfXNodes,0.);
601  yVector.resize(numberOfYNodes,0.);
602 
603  for(G4int i = 0; i<numberOfXNodes; ++i) {
604  G4cout << "i: " << DichroicVector->GetX(i) << G4endl;
605  xVector[i] = DichroicVector->GetX(i);
606  }
607  for(G4int j = 0; j<numberOfYNodes; ++j) {
608  G4cout << "j: " << DichroicVector->GetY(j) << G4endl;
609  yVector[j] = DichroicVector->GetY(j);
610  }
611 
612  for(G4int j = 0; j<numberOfYNodes; ++j) {
613  for(G4int i = 0; i<numberOfXNodes; ++i) {
614  G4cout << " i: " << i << " j: " << j << " "
615  << DichroicVector->GetValue(i,j) << G4endl;
616  }
617  }
618 
619 // G4int idx, idy;
620 
621 // for(G4int j = 0; j<numberOfYNodes-1; ++j) {
622 // G4double y = (yVector[j] + yVector[j+1])/2.;
623 // for(G4int i = 0; i<numberOfXNodes-1; ++i) {
624 // G4double x = (xVector[i] + xVector[i+1])/2.;
625 // G4cout << " x: " << x << " y: " << y << " "
626 // << DichroicVector->Value(x,y,idx,idy) << G4endl;
627 // }
628 // }
629 
630 }
const XML_Char * name
Definition: expat.h:151
static const G4int LUTbins
size_t GetLengthY() const
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:45
G4int GetPhiIndexMax(void) const
virtual ~G4OpticalSurface()
G4int GetThetaIndexMax(void) const
#define G4endl
Definition: G4ios.hh:61
float G4float
Definition: G4Types.hh:77
G4double GetY(size_t index) const
void ReadLUTDAVISFile(void)
G4bool Retrieve(std::ifstream &fIn)
G4SurfaceType
G4OpticalSurfaceFinish theFinish
void ReadReflectivityLUTFile(void)
G4MaterialPropertiesTable * theMaterialPropertiesTable
static const G4int thetaIndexMax
fin
Definition: AddMC.C:2
G4OpticalSurfaceModel theModel
double G4double
Definition: G4Types.hh:76
G4double GetX(size_t index) const
const XML_Char int const XML_Char * value
Definition: expat.h:331
void SetType(const G4SurfaceType &type)
static const G4int RefMax
void ReadDichroicFile(void)
G4Physics2DVector * DichroicVector
G4OpticalSurfaceFinish
#define INT_MAX
Definition: templates.hh:111
G4float * AngularDistributionLUT
static const G4int incidentIndexMax
G4OpticalSurface & operator=(const G4OpticalSurface &right)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
int G4int
Definition: G4Types.hh:78
ifstream in
Definition: comparison.C:7
G4int GetRefMax(void) const
G4int operator==(const G4OpticalSurface &right) const
G4float * AngularDistribution
G4int GetInmax(void) const
G4GLOB_DLL std::ostream G4cout
G4OpticalSurface(const G4OpticalSurface &right)
void DumpInfo() const
size_t GetLengthX() const
G4double GetValue(size_t idx, size_t idy) const
static const G4int phiIndexMax
G4int operator!=(const G4OpticalSurface &right) const
const XML_Char XML_Content * model
Definition: expat.h:151
G4OpticalSurfaceModel
G4int GetLUTbins(void) const
static const G4int indexmax
void SetFinish(const G4OpticalSurfaceFinish)
std::vector< G4double > G4PV2DDataVector