Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/materials/src/G4OpticalSurface.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /materials/src/G4OpticalSurface.cc (Version 11.3.0) and /materials/src/G4OpticalSurface.cc (Version 11.1.3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25                                                <<  25 //
                                                   >>  26 //
                                                   >>  27 //
 26 //////////////////////////////////////////////     28 ////////////////////////////////////////////////////////////////////////
 27 // Optical Surface Class Implementation            29 // Optical Surface Class Implementation
 28 //////////////////////////////////////////////     30 ////////////////////////////////////////////////////////////////////////
 29 //                                                 31 //
 30 // File:        G4OpticalSurface.cc                32 // File:        G4OpticalSurface.cc
 31 // Description: An optical surface class for u     33 // Description: An optical surface class for use in G4OpBoundaryProcess
 32 // Version:     2.0                                34 // Version:     2.0
 33 // Created:     1997-06-26                         35 // Created:     1997-06-26
 34 // Author:      Peter Gumplinger                   36 // Author:      Peter Gumplinger
 35 // updated:     2017-02-24 Mariele Stockhoff a     37 // updated:     2017-02-24 Mariele Stockhoff add DAVIS model
 36 //////////////////////////////////////////////     38 ////////////////////////////////////////////////////////////////////////
 37                                                    39 
 38 #include "G4OpticalSurface.hh"                 <<  40 #include <iostream>
 39                                                <<  41 #include <fstream>
 40 #include "globals.hh"                          << 
 41                                                << 
 42 #include <zlib.h>                                  42 #include <zlib.h>
 43                                                    43 
 44 #include <fstream>                             <<  44 #include "globals.hh"
 45 #include <iostream>                            <<  45 #include "G4OpticalSurface.hh"
 46                                                    46 
 47 G4OpticalSurface& G4OpticalSurface::operator=(     47 G4OpticalSurface& G4OpticalSurface::operator=(const G4OpticalSurface& right)
 48 {                                                  48 {
 49   if (this != &right) {                        <<  49   if(this != &right)
 50     theName = right.theName;                   <<  50   {
 51     theType = right.theType;                   <<  51     theName                    = right.theName;
 52     theModel = right.theModel;                 <<  52     theType                    = right.theType;
 53     theFinish = right.theFinish;               <<  53     theModel                   = right.theModel;
 54     sigma_alpha = right.sigma_alpha;           <<  54     theFinish                  = right.theFinish;
 55     polish = right.polish;                     <<  55     sigma_alpha                = right.sigma_alpha;
                                                   >>  56     polish                     = right.polish;
 56     theMaterialPropertiesTable = right.theMate     57     theMaterialPropertiesTable = right.theMaterialPropertiesTable;
 57                                                    58 
 58     delete[] AngularDistribution;                  59     delete[] AngularDistribution;
 59     AngularDistribution = new G4float[incident <<  60     AngularDistribution =
                                                   >>  61       new G4float[incidentIndexMax * thetaIndexMax * phiIndexMax];
 60     *(AngularDistribution) = *(right.AngularDi     62     *(AngularDistribution) = *(right.AngularDistribution);
 61                                                    63 
 62     delete[] AngularDistributionLUT;               64     delete[] AngularDistributionLUT;
 63     AngularDistributionLUT = new G4float[index <<  65     AngularDistributionLUT    = new G4float[indexmax];
 64     *(AngularDistributionLUT) = *(right.Angula     66     *(AngularDistributionLUT) = *(right.AngularDistributionLUT);
 65                                                    67 
 66     delete[] Reflectivity;                         68     delete[] Reflectivity;
 67     Reflectivity = new G4float[RefMax];        <<  69     Reflectivity    = new G4float[RefMax];
 68     *(Reflectivity) = *(right.Reflectivity);       70     *(Reflectivity) = *(right.Reflectivity);
 69                                                    71 
 70     delete DichroicVector;                         72     delete DichroicVector;
 71     DichroicVector = new G4Physics2DVector();  <<  73     DichroicVector  = new G4Physics2DVector();
 72     *DichroicVector = *(right.DichroicVector);     74     *DichroicVector = *(right.DichroicVector);
 73   }                                                75   }
 74   return *this;                                    76   return *this;
 75 }                                                  77 }
 76                                                    78 
 77 G4OpticalSurface::G4OpticalSurface(const G4Str <<  79 G4OpticalSurface::G4OpticalSurface(const G4String& name,
 78   G4OpticalSurfaceFinish finish, G4SurfaceType <<  80                                    G4OpticalSurfaceModel model,
 79   : G4SurfaceProperty(name, type), theModel(mo <<  81                                    G4OpticalSurfaceFinish finish,
                                                   >>  82                                    G4SurfaceType type, G4double value)
                                                   >>  83   : G4SurfaceProperty(name, type)
                                                   >>  84   , theModel(model)
                                                   >>  85   , theFinish(finish)
                                                   >>  86   , theMaterialPropertiesTable(nullptr)
 80 {                                                  87 {
 81   AngularDistribution = nullptr;                   88   AngularDistribution = nullptr;
 82                                                    89 
 83   AngularDistributionLUT = nullptr;                90   AngularDistributionLUT = nullptr;
 84   Reflectivity = nullptr;                      <<  91   Reflectivity           = nullptr;
 85                                                    92 
 86   DichroicVector = nullptr;                        93   DichroicVector = nullptr;
 87                                                    94 
 88   switch (theModel) {                          <<  95   switch(theModel)
                                                   >>  96   {
 89     case glisur:                                   97     case glisur:
 90       polish = value;                          <<  98       polish      = value;
 91       sigma_alpha = 0.0;                           99       sigma_alpha = 0.0;
 92       break;                                      100       break;
 93     case LUT:                                     101     case LUT:
 94     case dichroic:                                102     case dichroic:
 95     case DAVIS:                                   103     case DAVIS:
 96       ReadDataFile();                             104       ReadDataFile();
 97       // fall through                             105       // fall through
 98     case unified:                                 106     case unified:
 99       sigma_alpha = value;                        107       sigma_alpha = value;
100       polish = 0.0;                            << 108       polish      = 0.0;
101       break;                                      109       break;
102     default:                                      110     default:
103       G4Exception("G4OpticalSurface::G4Optical << 111       G4Exception("G4OpticalSurface::G4OpticalSurface()", "mat309",
104         "Constructor called with INVALID model << 112                   FatalException, "Constructor called with INVALID model.");
105   }                                               113   }
106 }                                                 114 }
107                                                   115 
108 G4OpticalSurface::~G4OpticalSurface()             116 G4OpticalSurface::~G4OpticalSurface()
109 {                                                 117 {
110   delete[] AngularDistribution;                << 118     delete[] AngularDistribution;
111                                                   119 
112   delete[] AngularDistributionLUT;             << 120     delete[] AngularDistributionLUT;
113                                                   121 
114   delete[] Reflectivity;                       << 122     delete[] Reflectivity;
115                                                   123 
116   delete DichroicVector;                       << 124     delete DichroicVector;
117 }                                                 125 }
118                                                   126 
119 G4OpticalSurface::G4OpticalSurface(const G4Opt    127 G4OpticalSurface::G4OpticalSurface(const G4OpticalSurface& right)
120   : G4SurfaceProperty(right.theName, right.the    128   : G4SurfaceProperty(right.theName, right.theType)
121 {                                                 129 {
122   *this = right;                               << 130   *this                            = right;
123   this->theName = right.theName;               << 131   this->theName                    = right.theName;
124   this->theType = right.theType;               << 132   this->theType                    = right.theType;
125   this->theModel = right.theModel;             << 133   this->theModel                   = right.theModel;
126   this->theFinish = right.theFinish;           << 134   this->theFinish                  = right.theFinish;
127   this->sigma_alpha = right.sigma_alpha;       << 135   this->sigma_alpha                = right.sigma_alpha;
128   this->polish = right.polish;                 << 136   this->polish                     = right.polish;
129   this->theMaterialPropertiesTable = right.the    137   this->theMaterialPropertiesTable = right.theMaterialPropertiesTable;
130                                                   138 
131   delete[] AngularDistribution;                << 139     delete[] AngularDistribution;
132   this->AngularDistribution = new G4float[inci << 140   this->AngularDistribution =
                                                   >> 141     new G4float[incidentIndexMax * thetaIndexMax * phiIndexMax];
133   *(this->AngularDistribution) = *(right.Angul    142   *(this->AngularDistribution) = *(right.AngularDistribution);
134                                                   143 
135   delete[] AngularDistributionLUT;             << 144     delete[] AngularDistributionLUT;
136   this->AngularDistributionLUT = new G4float[i << 145   this->AngularDistributionLUT    = new G4float[indexmax];
137   *(this->AngularDistributionLUT) = *(right.An    146   *(this->AngularDistributionLUT) = *(right.AngularDistributionLUT);
138                                                   147 
139   delete[] Reflectivity;                       << 148     delete[] Reflectivity;
140   this->Reflectivity = new G4float[RefMax];    << 149   this->Reflectivity    = new G4float[RefMax];
141   *(this->Reflectivity) = *(right.Reflectivity    150   *(this->Reflectivity) = *(right.Reflectivity);
142                                                   151 
143   delete DichroicVector;                       << 152     delete DichroicVector;
144   this->DichroicVector = new G4Physics2DVector << 153   this->DichroicVector    = new G4Physics2DVector();
145   *(this->DichroicVector) = *(right.DichroicVe    154   *(this->DichroicVector) = *(right.DichroicVector);
146 }                                                 155 }
147                                                   156 
148 G4bool G4OpticalSurface::operator==(const G4Op    157 G4bool G4OpticalSurface::operator==(const G4OpticalSurface& right) const
149 {                                                 158 {
150   return (this == (G4OpticalSurface*)&right);  << 159   return (this == (G4OpticalSurface*) &right);
151 }                                                 160 }
152                                                   161 
153 G4bool G4OpticalSurface::operator!=(const G4Op    162 G4bool G4OpticalSurface::operator!=(const G4OpticalSurface& right) const
154 {                                                 163 {
155   return (this != (G4OpticalSurface*)&right);  << 164   return (this != (G4OpticalSurface*) &right);
156 }                                                 165 }
157                                                   166 
158 G4int G4OpticalSurface::GetInmax() const { ret    167 G4int G4OpticalSurface::GetInmax() const { return indexmax; }
159                                                   168 
160 G4int G4OpticalSurface::GetLUTbins() const { r    169 G4int G4OpticalSurface::GetLUTbins() const { return LUTbins; }
161                                                   170 
162 G4int G4OpticalSurface::GetRefMax() const { re    171 G4int G4OpticalSurface::GetRefMax() const { return RefMax; }
163                                                   172 
164 G4int G4OpticalSurface::GetThetaIndexMax() con    173 G4int G4OpticalSurface::GetThetaIndexMax() const { return thetaIndexMax; }
165                                                   174 
166 G4int G4OpticalSurface::GetPhiIndexMax() const    175 G4int G4OpticalSurface::GetPhiIndexMax() const { return phiIndexMax; }
167                                                   176 
168 void G4OpticalSurface::DumpInfo() const           177 void G4OpticalSurface::DumpInfo() const
169 {                                                 178 {
170   // Dump info for surface                        179   // Dump info for surface
171                                                   180 
172   G4cout << "  Surface type   = " << G4int(the    181   G4cout << "  Surface type   = " << G4int(theType) << G4endl
173          << "  Surface finish = " << G4int(the    182          << "  Surface finish = " << G4int(theFinish) << G4endl
174          << "  Surface model  = " << G4int(the << 183          << "  Surface model  = " << G4int(theModel) << G4endl << G4endl
175          << G4endl << "  ----------------- " < << 184          << "  Surface parameter " << G4endl << "  ----------------- "
                                                   >> 185          << G4endl;
176                                                   186 
177   if (theModel == glisur) {                    << 187   if(theModel == glisur)
                                                   >> 188   {
178     G4cout << " polish: " << polish << G4endl;    189     G4cout << " polish: " << polish << G4endl;
179   }                                               190   }
180   else {                                       << 191   else
                                                   >> 192   {
181     G4cout << " sigma_alpha: " << sigma_alpha     193     G4cout << " sigma_alpha: " << sigma_alpha << G4endl;
182   }                                               194   }
183   G4cout << G4endl;                               195   G4cout << G4endl;
184 }                                                 196 }
185                                                   197 
186 void G4OpticalSurface::SetType(const G4Surface    198 void G4OpticalSurface::SetType(const G4SurfaceType& type)
187 {                                                 199 {
188   theType = type;                                 200   theType = type;
189   ReadDataFile();                                 201   ReadDataFile();
190 }                                                 202 }
191                                                   203 
192 void G4OpticalSurface::SetFinish(const G4Optic    204 void G4OpticalSurface::SetFinish(const G4OpticalSurfaceFinish finish)
193 {                                                 205 {
194   theFinish = finish;                             206   theFinish = finish;
195   ReadDataFile();                                 207   ReadDataFile();
196 }                                                 208 }
197                                                   209 
198 void G4OpticalSurface::ReadDataFile()             210 void G4OpticalSurface::ReadDataFile()
199 {                                                 211 {
200   // type and finish can be set in either orde    212   // type and finish can be set in either order. Thus, we can't check
201   // for consistency. Need to read file on set    213   // for consistency. Need to read file on setting either type or finish.
202   switch (theType) {                           << 214   switch(theType)
                                                   >> 215   {
203     case dielectric_LUT:                          216     case dielectric_LUT:
204       if (AngularDistribution == nullptr) {    << 217       if(AngularDistribution == nullptr)
205         AngularDistribution = new G4float[inci << 218       {
                                                   >> 219         AngularDistribution =
                                                   >> 220           new G4float[incidentIndexMax * thetaIndexMax * phiIndexMax];
206       }                                           221       }
207       ReadLUTFile();                              222       ReadLUTFile();
208       break;                                      223       break;
209     case dielectric_LUTDAVIS:                     224     case dielectric_LUTDAVIS:
210       if (AngularDistributionLUT == nullptr) { << 225       if(AngularDistributionLUT == nullptr)
                                                   >> 226       {
211         AngularDistributionLUT = new G4float[i    227         AngularDistributionLUT = new G4float[indexmax];
212       }                                           228       }
213       ReadLUTDAVISFile();                         229       ReadLUTDAVISFile();
214                                                   230 
215       if (Reflectivity == nullptr) {           << 231       if(Reflectivity == nullptr)
                                                   >> 232       {
216         Reflectivity = new G4float[RefMax];       233         Reflectivity = new G4float[RefMax];
217       }                                           234       }
218       ReadReflectivityLUTFile();                  235       ReadReflectivityLUTFile();
219       break;                                      236       break;
220     case dielectric_dichroic:                     237     case dielectric_dichroic:
221       if (DichroicVector == nullptr) {         << 238       if(DichroicVector == nullptr)
                                                   >> 239       {
222         DichroicVector = new G4Physics2DVector    240         DichroicVector = new G4Physics2DVector();
223       }                                           241       }
224       ReadDichroicFile();                         242       ReadDichroicFile();
225       break;                                      243       break;
226     default:                                      244     default:
227       break;                                      245       break;
228   }                                               246   }
229 }                                                 247 }
230                                                   248 
231 void G4OpticalSurface::ReadLUTFile()              249 void G4OpticalSurface::ReadLUTFile()
232 {                                                 250 {
233   G4String readLUTFileName;                       251   G4String readLUTFileName;
234                                                   252 
235   switch (theFinish) {                         << 253   switch(theFinish)
                                                   >> 254   {
236     case polishedlumirrorglue:                    255     case polishedlumirrorglue:
237       readLUTFileName = "PolishedLumirrorGlue.    256       readLUTFileName = "PolishedLumirrorGlue.z";
238       break;                                      257       break;
239     case polishedlumirrorair:                     258     case polishedlumirrorair:
240       readLUTFileName = "PolishedLumirror.z";     259       readLUTFileName = "PolishedLumirror.z";
241       break;                                      260       break;
242     case polishedteflonair:                       261     case polishedteflonair:
243       readLUTFileName = "PolishedTeflon.z";       262       readLUTFileName = "PolishedTeflon.z";
244       break;                                      263       break;
245     case polishedtioair:                          264     case polishedtioair:
246       readLUTFileName = "PolishedTiO.z";          265       readLUTFileName = "PolishedTiO.z";
247       break;                                      266       break;
248     case polishedtyvekair:                        267     case polishedtyvekair:
249       readLUTFileName = "PolishedTyvek.z";        268       readLUTFileName = "PolishedTyvek.z";
250       break;                                      269       break;
251     case polishedvm2000glue:                      270     case polishedvm2000glue:
252       readLUTFileName = "PolishedVM2000Glue.z"    271       readLUTFileName = "PolishedVM2000Glue.z";
253       break;                                      272       break;
254     case polishedvm2000air:                       273     case polishedvm2000air:
255       readLUTFileName = "PolishedVM2000.z";       274       readLUTFileName = "PolishedVM2000.z";
256       break;                                      275       break;
257     case etchedlumirrorglue:                      276     case etchedlumirrorglue:
258       readLUTFileName = "EtchedLumirrorGlue.z"    277       readLUTFileName = "EtchedLumirrorGlue.z";
259       break;                                      278       break;
260     case etchedlumirrorair:                       279     case etchedlumirrorair:
261       readLUTFileName = "EtchedLumirror.z";       280       readLUTFileName = "EtchedLumirror.z";
262       break;                                      281       break;
263     case etchedteflonair:                         282     case etchedteflonair:
264       readLUTFileName = "EtchedTeflon.z";         283       readLUTFileName = "EtchedTeflon.z";
265       break;                                      284       break;
266     case etchedtioair:                            285     case etchedtioair:
267       readLUTFileName = "EtchedTiO.z";            286       readLUTFileName = "EtchedTiO.z";
268       break;                                      287       break;
269     case etchedtyvekair:                          288     case etchedtyvekair:
270       readLUTFileName = "EtchedTyvek.z";          289       readLUTFileName = "EtchedTyvek.z";
271       break;                                      290       break;
272     case etchedvm2000glue:                        291     case etchedvm2000glue:
273       readLUTFileName = "EtchedVM2000Glue.z";     292       readLUTFileName = "EtchedVM2000Glue.z";
274       break;                                      293       break;
275     case etchedvm2000air:                         294     case etchedvm2000air:
276       readLUTFileName = "EtchedVM2000.z";         295       readLUTFileName = "EtchedVM2000.z";
277       break;                                      296       break;
278     case groundlumirrorglue:                      297     case groundlumirrorglue:
279       readLUTFileName = "GroundLumirrorGlue.z"    298       readLUTFileName = "GroundLumirrorGlue.z";
280       break;                                      299       break;
281     case groundlumirrorair:                       300     case groundlumirrorair:
282       readLUTFileName = "GroundLumirror.z";       301       readLUTFileName = "GroundLumirror.z";
283       break;                                      302       break;
284     case groundteflonair:                         303     case groundteflonair:
285       readLUTFileName = "GroundTeflon.z";         304       readLUTFileName = "GroundTeflon.z";
286       break;                                      305       break;
287     case groundtioair:                            306     case groundtioair:
288       readLUTFileName = "GroundTiO.z";            307       readLUTFileName = "GroundTiO.z";
289       break;                                      308       break;
290     case groundtyvekair:                          309     case groundtyvekair:
291       readLUTFileName = "GroundTyvek.z";          310       readLUTFileName = "GroundTyvek.z";
292       break;                                      311       break;
293     case groundvm2000glue:                        312     case groundvm2000glue:
294       readLUTFileName = "GroundVM2000Glue.z";     313       readLUTFileName = "GroundVM2000Glue.z";
295       break;                                      314       break;
296     case groundvm2000air:                         315     case groundvm2000air:
297       readLUTFileName = "GroundVM2000.z";         316       readLUTFileName = "GroundVM2000.z";
298       break;                                      317       break;
299     default:                                      318     default:
300       return;                                     319       return;
301   }                                               320   }
302                                                   321 
303   std::istringstream iss;                         322   std::istringstream iss;
304   ReadCompressedFile(readLUTFileName, iss);       323   ReadCompressedFile(readLUTFileName, iss);
305                                                   324 
306   size_t idxmax = incidentIndexMax * thetaInde    325   size_t idxmax = incidentIndexMax * thetaIndexMax * phiIndexMax;
307   for (size_t i = 0; i < idxmax; ++i) {        << 326   for(size_t i = 0; i < idxmax; ++i)
                                                   >> 327   {
308     iss >> AngularDistribution[i];                328     iss >> AngularDistribution[i];
309   }                                               329   }
310   G4cout << "LUT - data file: " << readLUTFile    330   G4cout << "LUT - data file: " << readLUTFileName << " read in! " << G4endl;
311 }                                                 331 }
312                                                   332 
313 void G4OpticalSurface::ReadLUTDAVISFile()         333 void G4OpticalSurface::ReadLUTDAVISFile()
314 {                                                 334 {
315   G4String readLUTDAVISFileName;                  335   G4String readLUTDAVISFileName;
316                                                   336 
317   switch (theFinish) {                         << 337   switch(theFinish)
                                                   >> 338   {
318     case Rough_LUT:                               339     case Rough_LUT:
319       readLUTDAVISFileName = "Rough_LUT.z";       340       readLUTDAVISFileName = "Rough_LUT.z";
320       break;                                      341       break;
321     case RoughTeflon_LUT:                         342     case RoughTeflon_LUT:
322       readLUTDAVISFileName = "RoughTeflon_LUT.    343       readLUTDAVISFileName = "RoughTeflon_LUT.z";
323       break;                                      344       break;
324     case RoughESR_LUT:                            345     case RoughESR_LUT:
325       readLUTDAVISFileName = "RoughESR_LUT.z";    346       readLUTDAVISFileName = "RoughESR_LUT.z";
326       break;                                      347       break;
327     case RoughESRGrease_LUT:                      348     case RoughESRGrease_LUT:
328       readLUTDAVISFileName = "RoughESRGrease_L    349       readLUTDAVISFileName = "RoughESRGrease_LUT.z";
329       break;                                      350       break;
330     case Polished_LUT:                            351     case Polished_LUT:
331       readLUTDAVISFileName = "Polished_LUT.z";    352       readLUTDAVISFileName = "Polished_LUT.z";
332       break;                                      353       break;
333     case PolishedTeflon_LUT:                      354     case PolishedTeflon_LUT:
334       readLUTDAVISFileName = "PolishedTeflon_L    355       readLUTDAVISFileName = "PolishedTeflon_LUT.z";
335       break;                                      356       break;
336     case PolishedESR_LUT:                         357     case PolishedESR_LUT:
337       readLUTDAVISFileName = "PolishedESR_LUT.    358       readLUTDAVISFileName = "PolishedESR_LUT.z";
338       break;                                      359       break;
339     case PolishedESRGrease_LUT:                   360     case PolishedESRGrease_LUT:
340       readLUTDAVISFileName = "PolishedESRGreas    361       readLUTDAVISFileName = "PolishedESRGrease_LUT.z";
341       break;                                      362       break;
342     case Detector_LUT:                            363     case Detector_LUT:
343       readLUTDAVISFileName = "Detector_LUT.z";    364       readLUTDAVISFileName = "Detector_LUT.z";
344       break;                                      365       break;
345     default:                                      366     default:
346       return;                                     367       return;
347   }                                               368   }
348                                                   369 
349   std::istringstream iss;                         370   std::istringstream iss;
350   ReadCompressedFile(readLUTDAVISFileName, iss    371   ReadCompressedFile(readLUTDAVISFileName, iss);
351                                                   372 
352   for (size_t i = 0; i < indexmax; ++i) {      << 373   for(size_t i = 0; i < indexmax; ++i)
                                                   >> 374   {
353     iss >> AngularDistributionLUT[i];             375     iss >> AngularDistributionLUT[i];
354   }                                               376   }
355   G4cout << "LUT DAVIS - data file: " << readL << 377   G4cout << "LUT DAVIS - data file: " << readLUTDAVISFileName << " read in! "
                                                   >> 378          << G4endl;
356 }                                                 379 }
357                                                   380 
358 void G4OpticalSurface::ReadReflectivityLUTFile    381 void G4OpticalSurface::ReadReflectivityLUTFile()
359 {                                                 382 {
360   G4String readReflectivityLUTFileName;           383   G4String readReflectivityLUTFileName;
361                                                   384 
362   switch (theFinish) {                         << 385   switch(theFinish)
                                                   >> 386   {
363     case Rough_LUT:                               387     case Rough_LUT:
364       readReflectivityLUTFileName = "Rough_LUT    388       readReflectivityLUTFileName = "Rough_LUTR.z";
365       break;                                      389       break;
366     case RoughTeflon_LUT:                         390     case RoughTeflon_LUT:
367       readReflectivityLUTFileName = "RoughTefl    391       readReflectivityLUTFileName = "RoughTeflon_LUTR.z";
368       break;                                      392       break;
369     case RoughESR_LUT:                            393     case RoughESR_LUT:
370       readReflectivityLUTFileName = "RoughESR_    394       readReflectivityLUTFileName = "RoughESR_LUTR.z";
371       break;                                      395       break;
372     case RoughESRGrease_LUT:                      396     case RoughESRGrease_LUT:
373       readReflectivityLUTFileName = "RoughESRG    397       readReflectivityLUTFileName = "RoughESRGrease_LUTR.z";
374       break;                                      398       break;
375     case Polished_LUT:                            399     case Polished_LUT:
376       readReflectivityLUTFileName = "Polished_    400       readReflectivityLUTFileName = "Polished_LUTR.z";
377       break;                                      401       break;
378     case PolishedTeflon_LUT:                      402     case PolishedTeflon_LUT:
379       readReflectivityLUTFileName = "PolishedT    403       readReflectivityLUTFileName = "PolishedTeflon_LUTR.z";
380       break;                                      404       break;
381     case PolishedESR_LUT:                         405     case PolishedESR_LUT:
382       readReflectivityLUTFileName = "PolishedE    406       readReflectivityLUTFileName = "PolishedESR_LUTR.z";
383       break;                                      407       break;
384     case PolishedESRGrease_LUT:                   408     case PolishedESRGrease_LUT:
385       readReflectivityLUTFileName = "PolishedE    409       readReflectivityLUTFileName = "PolishedESRGrease_LUTR.z";
386       break;                                      410       break;
387     case Detector_LUT:                            411     case Detector_LUT:
388       readReflectivityLUTFileName = "Detector_    412       readReflectivityLUTFileName = "Detector_LUTR.z";
389       break;                                      413       break;
390     default:                                      414     default:
391       return;                                     415       return;
392   }                                               416   }
393                                                   417 
394   std::istringstream iss;                         418   std::istringstream iss;
395   ReadCompressedFile(readReflectivityLUTFileNa    419   ReadCompressedFile(readReflectivityLUTFileName, iss);
396                                                   420 
397   for (size_t i = 0; i < RefMax; ++i) {        << 421   for(size_t i = 0; i < RefMax; ++i)
                                                   >> 422   {
398     iss >> Reflectivity[i];                       423     iss >> Reflectivity[i];
399   }                                               424   }
400   G4cout << "LUT DAVIS - reflectivity data fil << 425   G4cout << "LUT DAVIS - reflectivity data file: "
401          << G4endl;                            << 426          << readReflectivityLUTFileName << " read in! " << G4endl;
402 }                                                 427 }
403                                                   428 
404 // uncompress one data file into the input str    429 // uncompress one data file into the input string stream
405 void G4OpticalSurface::ReadCompressedFile(cons << 430 void G4OpticalSurface::ReadCompressedFile(const G4String& filename,
                                                   >> 431                                           std::istringstream& iss)
406 {                                                 432 {
407   G4String* dataString = nullptr;              << 433   G4String* dataString  = nullptr;
408   G4String path = G4FindDataDir("G4REALSURFACE << 434   G4String path         = G4FindDataDir("G4REALSURFACEDATA");
409   G4String compfilename = path + "/" + filenam    435   G4String compfilename = path + "/" + filename;
410   // create input stream with binary mode oper    436   // create input stream with binary mode operation and position at end of file
411   std::ifstream in(compfilename, std::ios::bin    437   std::ifstream in(compfilename, std::ios::binary | std::ios::ate);
412   if (in.good()) {                             << 438   if(in.good())
                                                   >> 439   {
413     // get current position in the stream (was    440     // get current position in the stream (was set to the end)
414     G4int fileSize = (G4int)in.tellg();           441     G4int fileSize = (G4int)in.tellg();
415     // set current position being the beginnin    442     // set current position being the beginning of the stream
416     in.seekg(0, std::ios::beg);                   443     in.seekg(0, std::ios::beg);
417     // create (zlib) byte buffer for the data     444     // create (zlib) byte buffer for the data
418     auto compdata = new Bytef[fileSize];       << 445     Bytef* compdata = new Bytef[fileSize];
419     while (in) {                               << 446     while(in)
420       in.read((char*)compdata, fileSize);      << 447     {
                                                   >> 448       in.read((char*) compdata, fileSize);
421     }                                             449     }
422     // create (zlib) byte buffer for the uncom    450     // create (zlib) byte buffer for the uncompressed data
423     auto complen = (uLongf)(fileSize * 4);     << 451     uLongf complen    = (uLongf)(fileSize * 4);
424     auto uncompdata = new Bytef[complen];      << 452     Bytef* uncompdata = new Bytef[complen];
425     while (Z_OK != uncompress(uncompdata, &com << 453     while(Z_OK != uncompress(uncompdata, &complen, compdata, fileSize))
                                                   >> 454     {
426       // increase uncompressed byte buffer        455       // increase uncompressed byte buffer
427       delete[] uncompdata;                        456       delete[] uncompdata;
428       complen *= 2;                               457       complen *= 2;
429       uncompdata = new Bytef[complen];            458       uncompdata = new Bytef[complen];
430     }                                             459     }
431     // delete the compressed data buffer          460     // delete the compressed data buffer
432     delete[] compdata;                            461     delete[] compdata;
433     // create a string from uncompressed data     462     // create a string from uncompressed data (will be deallocated by caller)
434     dataString = new G4String((char*)uncompdat << 463     dataString = new G4String((char*) uncompdata, (long) complen);
435     // delete the uncompressed data buffer        464     // delete the uncompressed data buffer
436     delete[] uncompdata;                          465     delete[] uncompdata;
437   }                                               466   }
438   else {                                       << 467   else
                                                   >> 468   {
439     G4ExceptionDescription ed;                    469     G4ExceptionDescription ed;
440     ed << "Problem while trying to read " + co    470     ed << "Problem while trying to read " + compfilename + " data file.\n";
441     G4Exception("G4OpticalSurface::ReadCompres << 471     G4Exception("G4OpticalSurface::ReadCompressedFile", "mat316",
                                                   >> 472                 FatalException, ed);
442     return;                                       473     return;
443   }                                               474   }
444   // create the input string stream from the d    475   // create the input string stream from the data string
445   if (dataString != nullptr) {                 << 476   if(dataString != nullptr)
                                                   >> 477   {
446     iss.str(*dataString);                         478     iss.str(*dataString);
447     in.close();                                   479     in.close();
448     delete dataString;                            480     delete dataString;
449     G4cout << "G4OpticalSurface: data file " < << 481     G4cout << "G4OpticalSurface: data file " << compfilename
                                                   >> 482            << " successfully read in." << G4endl;
450   }                                               483   }
451 }                                                 484 }
452                                                   485 
453 void G4OpticalSurface::ReadDichroicFile()         486 void G4OpticalSurface::ReadDichroicFile()
454 {                                                 487 {
455   const char* datadir = G4FindDataDir("G4DICHR    488   const char* datadir = G4FindDataDir("G4DICHROICDATA");
456                                                   489 
457   if (datadir == nullptr) {                    << 490   if(datadir == nullptr)
458     G4Exception("G4OpticalSurface::ReadDichroi << 491   {
459       "Environment variable G4DICHROICDATA not << 492     G4Exception("G4OpticalSurface::ReadDichroicFile()", "mat313",
                                                   >> 493                 FatalException,
                                                   >> 494                 "Environment variable G4DICHROICDATA not defined");
460     return;                                       495     return;
461   }                                               496   }
462                                                   497 
463   std::ostringstream ost;                         498   std::ostringstream ost;
464   ost << datadir;                                 499   ost << datadir;
465   std::ifstream fin(ost.str().c_str());           500   std::ifstream fin(ost.str().c_str());
466   if (! fin.is_open()) {                       << 501   if(!fin.is_open())
                                                   >> 502   {
467     G4ExceptionDescription ed;                    503     G4ExceptionDescription ed;
468     ed << "Dichroic surface data file <" << os << 504     ed << "Dichroic surface data file <" << ost.str().c_str()
469     G4Exception("G4OpticalSurface::ReadDichroi << 505        << "> is not opened!" << G4endl;
                                                   >> 506     G4Exception("G4OpticalSurface::ReadDichroicFile()", "mat314",
                                                   >> 507                 FatalException, ed, " ");
470     return;                                       508     return;
471   }                                               509   }
472                                                   510 
473   if (! (DichroicVector->Retrieve(fin))) {     << 511   if(!(DichroicVector->Retrieve(fin)))
                                                   >> 512   {
474     G4ExceptionDescription ed;                    513     G4ExceptionDescription ed;
475     ed << "Dichroic surface data file <" << os << 514     ed << "Dichroic surface data file <" << ost.str().c_str()
476     G4Exception("G4OpticalSurface::ReadDichroi << 515        << "> is not opened!" << G4endl;
                                                   >> 516     G4Exception("G4OpticalSurface::ReadDichroicFile()", "mat315",
                                                   >> 517                 FatalException, ed, " ");
477     return;                                       518     return;
478   }                                               519   }
479                                                   520 
480   //  DichroicVector->SetBicubicInterpolation(    521   //  DichroicVector->SetBicubicInterpolation(true);
481                                                   522 
482   G4cout << " *** Dichroic surface data file *    523   G4cout << " *** Dichroic surface data file *** " << G4endl;
483                                                   524 
484   auto numberOfXNodes = (G4int)DichroicVector- << 525   G4int numberOfXNodes = (G4int)DichroicVector->GetLengthX();
485   auto numberOfYNodes = (G4int)DichroicVector- << 526   G4int numberOfYNodes = (G4int)DichroicVector->GetLengthY();
486                                                   527 
487   G4cout << "numberOfXNodes: " << numberOfXNod    528   G4cout << "numberOfXNodes: " << numberOfXNodes << G4endl;
488   G4cout << "numberOfYNodes: " << numberOfYNod    529   G4cout << "numberOfYNodes: " << numberOfYNodes << G4endl;
489                                                   530 
490   if (0 > numberOfXNodes || numberOfXNodes >=  << 531   if(0 > numberOfXNodes || numberOfXNodes >= INT_MAX)
                                                   >> 532   {
491     numberOfXNodes = 0;                           533     numberOfXNodes = 0;
492   }                                               534   }
493   if (0 > numberOfYNodes || numberOfYNodes >=  << 535   if(0 > numberOfYNodes || numberOfYNodes >= INT_MAX)
                                                   >> 536   {
494     numberOfYNodes = 0;                           537     numberOfYNodes = 0;
495   }                                               538   }
496                                                   539 
497   G4PV2DDataVector xVector;                       540   G4PV2DDataVector xVector;
498   G4PV2DDataVector yVector;                       541   G4PV2DDataVector yVector;
499                                                   542 
500   xVector.resize(numberOfXNodes, 0.);             543   xVector.resize(numberOfXNodes, 0.);
501   yVector.resize(numberOfYNodes, 0.);             544   yVector.resize(numberOfYNodes, 0.);
502                                                   545 
503   for (G4int i = 0; i < numberOfXNodes; ++i) { << 546   for(G4int i = 0; i < numberOfXNodes; ++i)
                                                   >> 547   {
504     G4cout << "i: " << DichroicVector->GetX(i)    548     G4cout << "i: " << DichroicVector->GetX(i) << G4endl;
505     xVector[i] = DichroicVector->GetX(i);         549     xVector[i] = DichroicVector->GetX(i);
506   }                                               550   }
507   for (G4int j = 0; j < numberOfYNodes; ++j) { << 551   for(G4int j = 0; j < numberOfYNodes; ++j)
                                                   >> 552   {
508     G4cout << "j: " << DichroicVector->GetY(j)    553     G4cout << "j: " << DichroicVector->GetY(j) << G4endl;
509     yVector[j] = DichroicVector->GetY(j);         554     yVector[j] = DichroicVector->GetY(j);
510   }                                               555   }
511                                                   556 
512   for (G4int j = 0; j < numberOfYNodes; ++j) { << 557   for(G4int j = 0; j < numberOfYNodes; ++j)
513     for (G4int i = 0; i < numberOfXNodes; ++i) << 558   {
514       G4cout << " i: " << i << " j: " << j <<  << 559     for(G4int i = 0; i < numberOfXNodes; ++i)
                                                   >> 560     {
                                                   >> 561       G4cout << " i: " << i << " j: " << j << " "
                                                   >> 562              << DichroicVector->GetValue(i, j) << G4endl;
515     }                                             563     }
516   }                                               564   }
517 }                                                 565 }
518                                                   566