Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:48

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 
0026 ////////////////////////////////////////////////////////////////////////
0027 // G4OpticalSurface Definition
0028 ////////////////////////////////////////////////////////////////////////
0029 //
0030 // File:        G4OpticalSurface.hh
0031 // Description: A optical surface class for use in G4OpBoundaryProcess
0032 // Version:     2.0
0033 // Created:     1997-06-26
0034 // Author:      Peter Gumplinger
0035 // Updated:     1999-10-29 add method and class descriptors
0036 //              2017-02-24 Mariele Stockhoff add DAVIS model
0037 //
0038 // Class Description:
0039 // A optical surface class for use in the G4OpBoundaryProcess class.
0040 // Contains the enumerations: G4OpticalSurfaceFinish, G4OpticalSurfaceType,
0041 // and G4OpticalSurfaceModel.
0042 ////////////////////////////////////////////////////////////////////////
0043 
0044 #ifndef G4OpticalSurface_h
0045 #define G4OpticalSurface_h 1
0046 
0047 #include "G4Physics2DVector.hh"
0048 #include "G4SurfaceProperty.hh"
0049 #include "G4Types.hh"
0050 
0051 // clang-format off
0052 enum G4OpticalSurfaceFinish
0053 {
0054   polished,              // smooth perfectly polished surface
0055   polishedfrontpainted,  // smooth top-layer (front) paint
0056   polishedbackpainted,   // same is 'polished' but with a back-paint
0057 
0058   ground,              // rough surface
0059   groundfrontpainted,  // rough top-layer (front) paint
0060   groundbackpainted,   // same as 'ground' but with a back-paint
0061 
0062   // for LBNL LUT model
0063   polishedlumirrorair,   // mechanically polished surface, with lumirror
0064   polishedlumirrorglue,  // mechanically polished surface, with lumirror &
0065                          // meltmount
0066   polishedair,           // mechanically polished surface
0067   polishedteflonair,     // mechanically polished surface, with teflon
0068   polishedtioair,        // mechanically polished surface, with tio paint
0069   polishedtyvekair,      // mechanically polished surface, with tyvek
0070   polishedvm2000air,     // mechanically polished surface, with esr film
0071   polishedvm2000glue,    // mechanically polished surface, with esr film &
0072                          // meltmount
0073 
0074   etchedlumirrorair,   // chemically etched surface, with lumirror
0075   etchedlumirrorglue,  // chemically etched surface, with lumirror & meltmount
0076   etchedair,           // chemically etched surface
0077   etchedteflonair,     // chemically etched surface, with teflon
0078   etchedtioair,        // chemically etched surface, with tio paint
0079   etchedtyvekair,      // chemically etched surface, with tyvek
0080   etchedvm2000air,     // chemically etched surface, with esr film
0081   etchedvm2000glue,    // chemically etched surface, with esr film & meltmount
0082 
0083   groundlumirrorair,   // rough-cut surface, with lumirror
0084   groundlumirrorglue,  // rough-cut surface, with lumirror & meltmount
0085   groundair,           // rough-cut surface
0086   groundteflonair,     // rough-cut surface, with teflon
0087   groundtioair,        // rough-cut surface, with tio paint
0088   groundtyvekair,      // rough-cut surface, with tyvek
0089   groundvm2000air,     // rough-cut surface, with esr film
0090   groundvm2000glue,    // rough-cut surface, with esr film & meltmount
0091 
0092   // for DAVIS model
0093   Rough_LUT,              // rough surface
0094   RoughTeflon_LUT,        // rough surface wrapped in Teflon tape
0095   RoughESR_LUT,           // rough surface wrapped with ESR
0096   RoughESRGrease_LUT,     // rough surface wrapped with ESR
0097                           // and coupled with optical grease
0098   Polished_LUT,           // polished surface
0099   PolishedTeflon_LUT,     // polished surface wrapped in Teflon tape
0100   PolishedESR_LUT,        // polished surface wrapped with ESR
0101   PolishedESRGrease_LUT,  // polished surface wrapped with ESR
0102                           // and coupled with optical grease
0103   Detector_LUT            // polished surface with optical grease
0104 };
0105 
0106 enum G4OpticalSurfaceModel
0107 {
0108   glisur,   // original GEANT3 model
0109   unified,  // UNIFIED model
0110   LUT,      // Look-Up-Table model (LBNL model)
0111   DAVIS,    // DAVIS model
0112   dichroic  // dichroic filter
0113 };
0114 
0115 // clang-format on
0116 
0117 class G4MaterialPropertiesTable;
0118 
0119 class G4OpticalSurface : public G4SurfaceProperty
0120 {
0121  public:
0122   // Constructor of an optical surface object.
0123   G4OpticalSurface(const G4String& name, G4OpticalSurfaceModel model = glisur,
0124     G4OpticalSurfaceFinish finish = polished, G4SurfaceType type = dielectric_dielectric,
0125     G4double value = 1.0);
0126 
0127   ~G4OpticalSurface() override;
0128 
0129   G4OpticalSurface(const G4OpticalSurface& right);
0130   G4OpticalSurface& operator=(const G4OpticalSurface& right);
0131 
0132   G4bool operator==(const G4OpticalSurface& right) const;
0133   G4bool operator!=(const G4OpticalSurface& right) const;
0134 
0135   void SetType(const G4SurfaceType& type) override;
0136 
0137   // Returns the optical surface finish.
0138   inline G4OpticalSurfaceFinish GetFinish() const { return theFinish; }
0139 
0140   // Sets the optical surface finish.
0141   void SetFinish(const G4OpticalSurfaceFinish);
0142 
0143   // Returns the optical surface model used.
0144   inline G4OpticalSurfaceModel GetModel() const { return theModel; }
0145 
0146   // Sets the optical surface model to be followed.
0147   inline void SetModel(const G4OpticalSurfaceModel model) { theModel = model; }
0148 
0149   // Returns an unified model surface parameter.
0150   inline G4double GetSigmaAlpha() const { return sigma_alpha; }
0151 
0152   // Sets an unified model surface parameter.
0153   inline void SetSigmaAlpha(const G4double s_a) { sigma_alpha = s_a; }
0154 
0155   // Returns the optical surface polish type.
0156   G4double GetPolish() const { return polish; }
0157 
0158   // Sets the optical surface polish type.
0159   inline void SetPolish(const G4double plsh) { polish = plsh; }
0160 
0161   // Retrieves the pointer of the G4MaterialPropertiesTable
0162   // attached to optical surface.
0163   inline G4MaterialPropertiesTable* GetMaterialPropertiesTable() const
0164   {
0165     return theMaterialPropertiesTable;
0166   }
0167 
0168   // Attaches a G4MaterialPropertiesTable to the optical surface.
0169   inline void SetMaterialPropertiesTable(G4MaterialPropertiesTable* anMPT)
0170   {
0171     theMaterialPropertiesTable = anMPT;
0172   }
0173 
0174   // Prints information about the optical surface.
0175   void DumpInfo() const;
0176 
0177   // call the correct ReadXXXFile
0178   void ReadDataFile();
0179 
0180   // read a zlib-compressed file
0181   void ReadCompressedFile(const G4String&, std::istringstream&);
0182 
0183   // Method to read the Look-Up-Table into array AngularDistribution
0184   void ReadLUTFile();
0185 
0186   // for DAVIS model
0187   inline G4double GetAngularDistributionValue(G4int, G4int, G4int);
0188 
0189   // Returns the AngularDistributionValue
0190   inline G4double GetAngularDistributionValueLUT(G4int);
0191 
0192   // Method to read the Davis Look-Up-Table into array AngularDistribution
0193   void ReadLUTDAVISFile();
0194 
0195   // Method to read the Look-Up-Table for reflectivity
0196   void ReadReflectivityLUTFile();
0197 
0198   // Returns the reflectivity value from the Davis Look-Up-Table
0199   inline G4double GetReflectivityLUTValue(G4int);
0200 
0201   // Returns the number of lines in the Davis Look-Up-Table
0202   G4int GetInmax() const;
0203 
0204   // Returns the number of probability values per incidentangle
0205   G4int GetLUTbins() const;
0206 
0207   // Returns the number of reflectivity values per angle
0208   G4int GetRefMax() const;
0209 
0210   G4int GetThetaIndexMax() const;
0211   G4int GetPhiIndexMax() const;
0212 
0213   // Method to read the dichroic surface data file into Dichroic
0214   void ReadDichroicFile();
0215 
0216   inline G4Physics2DVector* GetDichroicVector();
0217 
0218  private:
0219   G4OpticalSurfaceModel theModel;  // Surface model
0220   G4OpticalSurfaceFinish theFinish;  // Surface finish
0221 
0222   G4double sigma_alpha;  // The sigma of micro-facet polar angle
0223   G4double polish;  // Polish parameter in glisur model
0224 
0225   G4MaterialPropertiesTable* theMaterialPropertiesTable{nullptr};
0226 
0227   static const G4int incidentIndexMax = 91;
0228   static const G4int thetaIndexMax = 45;
0229   static const G4int phiIndexMax = 37;
0230 
0231   G4float* AngularDistribution;
0232   G4Physics2DVector* DichroicVector;
0233 
0234   // for DAVIS model
0235   static const G4int indexmax = 7280001;  // 3640001;
0236   static const G4int RefMax = 90;
0237   static const G4int LUTbins = 20000;
0238   G4float* AngularDistributionLUT;
0239   G4float* Reflectivity;
0240 };
0241 
0242 ////////////////////
0243 // Inline methods
0244 ////////////////////
0245 
0246 inline G4double G4OpticalSurface::GetAngularDistributionValue(
0247   G4int angleIncident, G4int thetaIndex, G4int phiIndex)
0248 {
0249   G4int product = angleIncident * thetaIndex * phiIndex;
0250   if (product < 0 || product >= incidentIndexMax * thetaIndexMax * phiIndexMax) {
0251     G4ExceptionDescription ed;
0252     ed << "Index angleIncident: " << angleIncident << " thetaIndex: " << thetaIndex
0253        << " phiIndex: " << phiIndex << " out of range!";
0254     G4Exception("G4OpticalSurface::GetAngularDistributionValue", "mat317", FatalException, ed);
0255     return 0.;
0256   }
0257   return (G4double)AngularDistribution[angleIncident + thetaIndex * incidentIndexMax +
0258                                        phiIndex * thetaIndexMax * incidentIndexMax];
0259 }
0260 
0261 inline G4double G4OpticalSurface::GetAngularDistributionValueLUT(G4int i)
0262 {
0263   if (i < 0 || i >= indexmax) {
0264     G4ExceptionDescription ed;
0265     ed << "Index " << i << " out of range!";
0266     G4Exception("G4OpticalSurface::GetAngularDistributionValueLUT", "mat318", FatalException, ed);
0267     return 0.;
0268   }
0269   return (G4double)AngularDistributionLUT[i];
0270 }
0271 
0272 inline G4double G4OpticalSurface::GetReflectivityLUTValue(G4int i)
0273 {
0274   if (i < 0 || i >= RefMax) {
0275     G4ExceptionDescription ed;
0276     ed << "Index " << i << " out of range!";
0277     G4Exception("G4OpticalSurface::GetReflectivityLUTValue", "mat319", FatalException, ed);
0278     return 0.;
0279   }
0280   return (G4double)Reflectivity[i];
0281 }
0282 
0283 inline G4Physics2DVector* G4OpticalSurface::GetDichroicVector() { return DichroicVector; }
0284 
0285 #endif /* G4OpticalSurface_h */