Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:52

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 // G4AdjointPosOnPhysVolGenerator
0027 //
0028 // Class description:
0029 //
0030 // This class is responsible for the generation of primary adjoint particles
0031 // on the external surface of a user selected volume.
0032 // The particles are generated uniformly on the surface with the angular
0033 // distribution set to a cosine law relative to normal of the surface.
0034 // It is equivalent to the flux going in from the surface if an isotropic flux
0035 // is considered outside. 
0036 // It uses ray tracking technique and can be applied to all kind of convex
0037 // volumes. Using the ray tracking technique the area of the external surface
0038 // is also computed. The area is needed to fix the weight of the primary
0039 // adjoint particle.  
0040 // At the time of the development of this class, generation of points on
0041 // volume surface and computation of surface was limited in Geant4, therefore
0042 // the general ray tracking technique was adopted. The direct method in
0043 // G4VSolid could be now (2009) used instead.
0044 
0045 // Author: L. Desorgher, SpaceIT GmbH - 01.06.2006
0046 // Contract: ESA contract 21435/08/NL/AT
0047 // Customer: ESA/ESTEC
0048 // --------------------------------------------------------------------
0049 #ifndef G4AdjointPosOnPhysVolGenerator_hh
0050 #define G4AdjointPosOnPhysVolGenerator_hh 1
0051 
0052 #include "G4VPhysicalVolume.hh"
0053 #include "G4AffineTransform.hh"
0054 #include "G4ThreeVector.hh"
0055 
0056 class G4VSolid;
0057 
0058 class G4AdjointPosOnPhysVolGenerator 
0059 {
0060 //---------   
0061   public:
0062 //---------   
0063 
0064     static  G4AdjointPosOnPhysVolGenerator* GetInstance();
0065    
0066     G4VPhysicalVolume* DefinePhysicalVolume(const G4String& aName);
0067     void DefinePhysicalVolume1(const G4String& aName);
0068     G4double ComputeAreaOfExtSurface();
0069     G4double ComputeAreaOfExtSurface(G4int NStat);
0070     G4double ComputeAreaOfExtSurface(G4double epsilon);
0071     G4double ComputeAreaOfExtSurface(G4VSolid* aSolid);
0072     G4double ComputeAreaOfExtSurface(G4VSolid* aSolid,G4int NStat);
0073     G4double ComputeAreaOfExtSurface(G4VSolid* aSolid,G4double epsilon);
0074  
0075     void GenerateAPositionOnTheExtSurfaceOfASolid(G4VSolid* aSolid,
0076                                                   G4ThreeVector& p,
0077                                                   G4ThreeVector& direction);
0078     void GenerateAPositionOnTheExtSurfaceOfTheSolid(G4ThreeVector& p,
0079                                                     G4ThreeVector& direction);
0080     void GenerateAPositionOnTheExtSurfaceOfThePhysicalVolume(G4ThreeVector& p,
0081                                                     G4ThreeVector& direction);
0082     void GenerateAPositionOnTheExtSurfaceOfThePhysicalVolume(G4ThreeVector& p,
0083                                                     G4ThreeVector& direction,
0084                                                     G4double& costh_to_normal);
0085 
0086     inline void SetSolid(G4VSolid* aSolid)
0087       { theSolid=aSolid; }
0088     inline G4double GetAreaOfExtSurfaceOfThePhysicalVolume()
0089       { return AreaOfExtSurfaceOfThePhysicalVolume; }
0090     inline G4double GetCosThDirComparedToNormal()
0091       { return CosThDirComparedToNormal; }
0092   
0093 //---------   
0094   private:   // private methods
0095 //---------  
0096     G4AdjointPosOnPhysVolGenerator() = default;
0097    ~G4AdjointPosOnPhysVolGenerator() = default;
0098     G4double ComputeAreaOfExtSurfaceStartingFromSphere(G4VSolid* aSolid,
0099                                                        G4int NStat);
0100     G4double ComputeAreaOfExtSurfaceStartingFromBox(G4VSolid* aSolid,
0101                                                     G4int NStat);
0102     void GenerateAPositionOnASolidBoundary(G4VSolid* aSolid,
0103                                            G4ThreeVector& p,
0104                                            G4ThreeVector& direction);
0105     G4double GenerateAPositionOnASphereBoundary(G4VSolid* aSolid,
0106                                                 G4ThreeVector& p,
0107                                                 G4ThreeVector& direction);
0108     G4double GenerateAPositionOnABoxBoundary(G4VSolid* aSolid,
0109                                              G4ThreeVector& p,
0110                                              G4ThreeVector& direction);
0111     void ComputeTransformationFromPhysVolToWorld();
0112 
0113 //---------   
0114   private:   // attributes
0115 //---------   
0116 
0117    static G4ThreadLocal G4AdjointPosOnPhysVolGenerator* theInstance;
0118    G4VSolid* theSolid = nullptr;
0119    G4VPhysicalVolume* thePhysicalVolume = nullptr;
0120 
0121    G4bool UseSphere{true};
0122    G4String ModelOfSurfaceSource{"OnSolid"};
0123    G4AffineTransform theTransformationFromPhysVolToWorld;
0124    G4double AreaOfExtSurfaceOfThePhysicalVolume{0.};
0125    G4double CosThDirComparedToNormal{0.};
0126 };
0127 
0128 #endif