Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:50:29

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 // $Id: InstrumentedG4OpBoundaryProcess.hh 104458 2017-05-31 15:54:11Z gcosmo $
0028 //
0029 // 
0030 ////////////////////////////////////////////////////////////////////////
0031 // Optical Photon Boundary Process Class Definition
0032 ////////////////////////////////////////////////////////////////////////
0033 //
0034 // File:        InstrumentedG4OpBoundaryProcess.hh
0035 // Description: Discrete Process -- reflection/refraction at
0036 //                                  optical interfaces
0037 // Version:     1.1
0038 // Created:     1997-06-18
0039 // Modified:    2005-07-28 add G4ProcessType to constructor
0040 //              1999-10-29 add method and class descriptors
0041 //              1999-10-10 - Fill NewMomentum/NewPolarization in 
0042 //                           DoAbsorption. These members need to be
0043 //                           filled since DoIt calls 
0044 //                           aParticleChange.SetMomentumChange etc.
0045 //                           upon return (thanks to: Clark McGrew)
0046 //              2006-11-04 - add capability of calculating the reflectivity
0047 //                           off a metal surface by way of a complex index
0048 //                           of refraction - Thanks to Sehwook Lee and John
0049 //                           Hauptman (Dept. of Physics - Iowa State Univ.)
0050 //              2009-11-10 - add capability of simulating surface reflections
0051 //                           with Look-Up-Tables (LUT) containing measured
0052 //                           optical reflectance for a variety of surface
0053 //                           treatments - Thanks to Martin Janecek and
0054 //                           William Moses (Lawrence Berkeley National Lab.)
0055 //              2013-06-01 - add the capability of simulating the transmission
0056 //                           of a dichronic filter
0057 //              2017-02-24 - add capability of simulating surface reflections
0058 //                           with Look-Up-Tables (LUT) developed in DAVIS
0059 //
0060 // Author:      Peter Gumplinger
0061 //              adopted from work by Werner Keil - April 2/96
0062 // mail:        gum@triumf.ca
0063 //
0064 ////////////////////////////////////////////////////////////////////////
0065 
0066 #ifndef InstrumentedG4OpBoundaryProcess_h
0067 #define InstrumentedG4OpBoundaryProcess_h 1
0068 
0069 /////////////
0070 // Includes
0071 /////////////
0072 
0073 #include "globals.hh"
0074 #include "templates.hh"
0075 #include "geomdefs.hh"
0076 #include "Randomize.hh"
0077 
0078 #include "G4RandomTools.hh"
0079 #include "G4RandomDirection.hh"
0080 
0081 
0082 #include "U4RandomTools.hh"
0083 #include "U4RandomDirection.hh"
0084 #include "plog/Severity.h"
0085 
0086 #ifdef WITH_PMTFASTSIM
0087 #include "SOpBoundaryProcess.hh"
0088 
0089 struct IPMTAccessor ; 
0090 struct CustomART ; 
0091 #endif
0092 
0093 #include "G4Step.hh"
0094 #include "G4VDiscreteProcess.hh"
0095 #include "G4DynamicParticle.hh"
0096 #include "G4Material.hh"
0097 #include "G4LogicalBorderSurface.hh"
0098 #include "G4LogicalSkinSurface.hh"
0099 #include "G4OpticalSurface.hh"
0100 #include "G4OpticalPhoton.hh"
0101 #include "G4TransportationManager.hh"
0102 
0103 // Class Description:
0104 // Discrete Process -- reflection/refraction at optical interfaces.
0105 // Class inherits publicly from G4VDiscreteProcess.
0106 // Class Description - End:
0107 
0108 /////////////////////
0109 // Class Definition
0110 /////////////////////
0111 
0112 
0113 #include "G4OpBoundaryProcess.hh"
0114 
0115 /*
0116 // better to get these enum consts from standard boundary process 
0117 
0118 enum G4OpBoundaryProcessStatus {  Undefined,
0119                                   Transmission, FresnelRefraction,
0120                                   FresnelReflection, TotalInternalReflection,
0121                                   LambertianReflection, LobeReflection,
0122                                   SpikeReflection, BackScattering,
0123                                   Absorption, Detection, NotAtBoundary,
0124                                   SameMaterial, StepTooSmall, NoRINDEX,
0125                                   PolishedLumirrorAirReflection,
0126                                   PolishedLumirrorGlueReflection,
0127                                   PolishedAirReflection,
0128                                   PolishedTeflonAirReflection,
0129                                   PolishedTiOAirReflection,
0130                                   PolishedTyvekAirReflection,
0131                                   PolishedVM2000AirReflection,
0132                                   PolishedVM2000GlueReflection,
0133                                   EtchedLumirrorAirReflection,
0134                                   EtchedLumirrorGlueReflection,
0135                                   EtchedAirReflection,
0136                                   EtchedTeflonAirReflection,
0137                                   EtchedTiOAirReflection,
0138                                   EtchedTyvekAirReflection,
0139                                   EtchedVM2000AirReflection,
0140                                   EtchedVM2000GlueReflection,
0141                                   GroundLumirrorAirReflection,
0142                                   GroundLumirrorGlueReflection,
0143                                   GroundAirReflection,
0144                                   GroundTeflonAirReflection,
0145                                   GroundTiOAirReflection,
0146                                   GroundTyvekAirReflection,
0147                                   GroundVM2000AirReflection,
0148                                   GroundVM2000GlueReflection,
0149                                   Dichroic };
0150 
0151 */
0152 
0153 #ifdef DEBUG_TAG
0154 #include "U4Stack.h"
0155 #include "SEvt.hh"
0156 #endif
0157 
0158 
0159 
0160 #include "U4_API_EXPORT.hh"
0161 class U4_API InstrumentedG4OpBoundaryProcess 
0162     : 
0163     public G4VDiscreteProcess
0164 #ifdef WITH_PMTFASTSIM
0165     ,public SOpBoundaryProcess
0166 #endif
0167 {
0168 
0169 #if !defined(PRODUCTION) && defined(DEBUG_PIDX)
0170         static const int  PIDX ;
0171         int pidx ; 
0172         bool pidx_dump ; 
0173 #endif
0174 
0175 public:
0176         static const plog::Severity LEVEL ; 
0177         char theCustomStatus ; 
0178 
0179 #ifdef WITH_PMTFASTSIM
0180         CustomART*      m_custom_art ; 
0181 
0182         double getU0() const ; 
0183         int getU0_idx() const ; 
0184         const double* getRecoveredNormal() const ; 
0185         char getCustomStatus() const ; 
0186 
0187         static void Save(const char* dir); 
0188 #endif
0189 
0190 #ifdef DEBUG_TAG
0191         static const bool FLOAT ;  
0192         void ResetNumberOfInteractionLengthLeft();
0193 #endif
0194 
0195         ////////////////////////////////
0196         // Constructors and Destructor
0197         ////////////////////////////////
0198 
0199         InstrumentedG4OpBoundaryProcess(
0200 #ifdef WITH_PMTFASTSIM
0201                  const IPMTAccessor* accessor, 
0202 #endif
0203                  const G4String& processName = "OpBoundary",
0204                  G4ProcessType type = fOptical) ;
0205 
0206         ~InstrumentedG4OpBoundaryProcess();
0207 
0208 private:
0209 
0210         InstrumentedG4OpBoundaryProcess(const InstrumentedG4OpBoundaryProcess &right);
0211 
0212         //////////////
0213         // Operators
0214         //////////////
0215 
0216         InstrumentedG4OpBoundaryProcess& operator=(const InstrumentedG4OpBoundaryProcess &right);
0217 
0218 public:
0219 
0220     ////////////
0221         // Methods
0222         ////////////
0223 
0224         G4bool IsApplicable(const G4ParticleDefinition& aParticleType);
0225         // Returns true -> 'is applicable' only for an optical photon.
0226 
0227         G4double GetMeanFreePath(const G4Track& ,
0228                                  G4double ,
0229                                  G4ForceCondition* condition);
0230         // Returns infinity; i. e. the process does not limit the step,
0231         // but sets the 'Forced' condition for the DoIt to be invoked at
0232         // every step. However, only at a boundary will any action be
0233         // taken.
0234 
0235         G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
0236                                         const G4Step&  aStep);
0237 
0238         G4VParticleChange* PostStepDoIt_(const G4Track& aTrack,
0239                                          const G4Step&  aStep);
0240 
0241         // This is the method implementing boundary processes.
0242 
0243         G4OpBoundaryProcessStatus GetStatus() const;
0244         // Returns the current status.
0245 
0246         void SetInvokeSD(G4bool );
0247         // Set flag for call to InvokeSD method.
0248 
0249 private:
0250 
0251         G4bool G4BooleanRand(const G4double prob) const;
0252         G4bool G4BooleanRand_TransCoeff(const G4double prob) const;
0253         G4bool G4BooleanRand_theEfficiency(const G4double prob) const;
0254         G4bool G4BooleanRand_theReflectivity(const G4double prob) const;
0255 
0256         G4ThreeVector GetFacetNormal(const G4ThreeVector& Momentum,
0257                                      const G4ThreeVector&  Normal) const;
0258 
0259         void DielectricMetal();
0260         void DielectricDielectric();
0261 
0262         void DielectricLUT();
0263         void DielectricLUTDAVIS();
0264 
0265         void DielectricDichroic();
0266 
0267         void ChooseReflection();
0268         void DoAbsorption();
0269         void DoReflection();
0270 
0271         G4double GetIncidentAngle();
0272         // Returns the incident angle of optical photon
0273 
0274         G4double GetReflectivity(G4double E1_perp,
0275                                  G4double E1_parl,
0276                                  G4double incidentangle,
0277                                  G4double RealRindex,
0278                                  G4double ImaginaryRindex);
0279         // Returns the Reflectivity on a metalic surface
0280 
0281         void CalculateReflectivity(void);
0282 
0283         void BoundaryProcessVerbose(void) const;
0284 
0285         // Invoke SD for post step point if the photon is 'detected'
0286         G4bool InvokeSD(const G4Step* step);
0287 
0288 public:  
0289 
0290 #ifdef DEBUG_TAG 
0291         double m_u0 ; 
0292         int    m_u0_idx ; 
0293         int    m_u0_idx_delta ; 
0294 #endif
0295         int PostStepDoIt_count ; 
0296 
0297 private:
0298         G4double thePhotonMomentum;
0299 
0300         G4ThreeVector OldMomentum;
0301         G4ThreeVector OldPolarization;
0302 
0303         G4ThreeVector NewMomentum;
0304         G4ThreeVector NewPolarization;
0305 
0306         G4ThreeVector theGlobalPoint ;
0307         G4ThreeVector theGlobalExitNormal;   // SCB: as provided by G4Navigator 
0308         G4ThreeVector theGlobalNormal;
0309         G4ThreeVector theRecoveredNormal ;   // SCB: try to use haveEnteredDaughter status to unflip back to G4Track independent normal 
0310 
0311         G4ThreeVector theFacetNormal;
0312 
0313         G4Material* Material1;
0314         G4Material* Material2;
0315 
0316         G4OpticalSurface* OpticalSurface;
0317 
0318         G4MaterialPropertyVector* PropertyPointer;
0319         G4MaterialPropertyVector* PropertyPointer1;
0320         G4MaterialPropertyVector* PropertyPointer2;
0321 
0322         G4double Rindex1;
0323         G4double Rindex2;
0324 
0325         G4double cost1, cost2, sint1, sint2;
0326 
0327         G4OpBoundaryProcessStatus theStatus;
0328 
0329         G4OpticalSurfaceModel theModel;
0330 
0331         G4OpticalSurfaceFinish theFinish;
0332 
0333         G4double theReflectivity;
0334         G4double theEfficiency;
0335         G4double theTransmittance;
0336 
0337         G4double theSurfaceRoughness;
0338 
0339         G4double prob_sl, prob_ss, prob_bs;
0340 
0341         G4int iTE, iTM;
0342 
0343         G4double kCarTolerance;
0344 
0345         size_t idx, idy;
0346         G4Physics2DVector* DichroicVector;
0347 
0348         G4bool fInvokeSD;
0349 };
0350 
0351 
0352 
0353 #endif /* InstrumentedG4OpBoundaryProcess_h */