Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:34

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 #ifndef PAR04DETECTORCONSTRUCTION_H
0027 #define PAR04DETECTORCONSTRUCTION_H
0028 
0029 #include "G4Material.hh"  // for G4Material
0030 #include "G4SystemOfUnits.hh"  // for cm, mm, rad
0031 #include "G4ThreeVector.hh"  // for G4ThreeVector
0032 #include "G4VUserDetectorConstruction.hh"  // for G4VUserDetectorConstruction
0033 
0034 #include <CLHEP/Units/SystemOfUnits.h>  // for cm, mm, pi, rad
0035 #include <G4String.hh>  // for G4String
0036 #include <G4Types.hh>  // for G4double, G4bool, G4int
0037 #include <array>  // for array
0038 #include <cstddef>  // for size_t
0039 #include <vector>  // for vector
0040 class G4LogicalVolume;
0041 class G4VPhysicalVolume;
0042 class Par04DetectorMessenger;
0043 
0044 /**
0045  * @brief Detector construction.
0046  *
0047  * Creates a cylindrical detector, with cylinder axis along Z-axis. It is placed
0048  * in the  centre of the world volume.
0049  * Dimensions of the detector (inner radius and its length) as well as composition (number of
0050  * radial layers, number of absorbers, its thicknesses and materials) can be set using the UI
0051  * commands. There may be up to two absorbers used to build the layers.
0052  *
0053  * TODO Extend to allow use of more than two different absorbers.
0054  *
0055  * Each absorber may have differnt thickness (along radial direction), material, and may be
0056  * either sensitive to particle passage (will register deposited energy) or not (passive).
0057  * Readout geometry of the detector is dynamic, and its size can be set by UI commands.
0058  * Cells are created along z-axis, azimuthal angle, and radius (cylindrical
0059  * segmentation). The z axis is parallel to the direction of the particle entering the
0060  * detector volume. The mesh also starts at the entrance to the detector volume.
0061  * In order to define this enrance position and direction, a fast simulation model is used.
0062  * For the detector volume, if particle has entered, sets the particle direction and position
0063  * in the event information. Those vectors define the readout mesh for the event.
0064  *
0065  * TODO In order to speed up the simulation, fast simulation that checks for the entrance
0066  * properites should be defined in a very thin region instead of a whole region of the detector.
0067  *
0068  * Sensitive detector Par04SensitiveDetector is attached to the detector volume
0069  * Region for the detector is created as an envelope of the fast simulation.
0070  *
0071  */
0072 
0073 class Par04DetectorConstruction : public G4VUserDetectorConstruction
0074 {
0075   public:
0076     Par04DetectorConstruction();
0077     virtual ~Par04DetectorConstruction();
0078 
0079     virtual G4VPhysicalVolume* Construct() final;
0080     virtual void ConstructSDandField() final;
0081 
0082     ///  Set inner radius of the cylindrical detector
0083     void SetInnerRadius(G4double aInnerRadius);
0084     /// Get inner radius of the cylindrical detector
0085     inline G4double GetInnerRadius() const { return fDetectorInnerRadius; };
0086     ///  Set length radius of the cylindrical detector
0087     void SetLength(G4double aLength);
0088     /// Get length of the cylindrical detector (along z-axis)
0089     inline G4double GetLength() const { return fDetectorLength; };
0090     ///  Set number of layers
0091     inline void SetNbOfLayers(G4int aNumber) { fNbOfLayers = aNumber; };
0092     ///  Get number of layers
0093     inline G4int GetNbOfLayers() const { return fNbOfLayers; };
0094 
0095     ///  Set material of the layer (from NIST materials)
0096     void SetAbsorberMaterial(const std::size_t aLayer, const G4String& aMaterial);
0097     ///  Get name of the material of the layer
0098     inline G4String GetAbsorberMaterial(const std::size_t aLayer) const
0099     {
0100       return fAbsorberMaterial[aLayer]->GetName();
0101     };
0102     ///  Set thickness of the layer
0103     void SetAbsorberThickness(const std::size_t aLayer, const G4double aThickness);
0104     ///  Get thickness of the layer
0105     inline G4double GetAbsorberThickness(const std::size_t aLayer) const
0106     {
0107       return fAbsorberThickness[aLayer];
0108     };
0109     ///  Set sensitivity of the layer
0110     void SetAbsorberSensitivity(const std::size_t aLayer, const G4bool aSensitivity);
0111     ///  Get sensitivity of the layer
0112     inline G4bool GetAbsorberSensitivity(const std::size_t aLayer) const
0113     {
0114       return fAbsorberSensitivity[aLayer];
0115     };
0116 
0117     /// Set number of Mesh cells in cylindrical coordinates (r, phi, z)
0118     inline void SetMeshNbOfCells(G4ThreeVector aNb) { fMeshNbOfCells = aNb; };
0119     /// Set number of Mesh cells in cylindrical coordinates along one of the axis
0120     /// @param[in] aIndex index of cylindrical axis (0,1,2) = (r, phi, z)
0121     inline void SetMeshNbOfCells(std::size_t aIndex, G4double aNb)
0122     {
0123       fMeshNbOfCells[aIndex] = aNb;
0124     };
0125     /// Get number of Mesh cells in cylindrical coordinates (r, phi, z)
0126     inline G4ThreeVector GetMeshNbOfCells() const { return fMeshNbOfCells; };
0127     /// Set size of Mesh cells in cylindrical coordinates (r, phi, z)
0128     inline void SetMeshSizeOfCells(G4ThreeVector aNb) { fMeshSizeOfCells = aNb; };
0129     /// Set size of Mesh cells in cylindrical coordinates along one of the axis
0130     /// @param[in] aIndex index of cylindrical axis (0,1,2) = (r, phi, z)
0131     inline void SetMeshSizeOfCells(std::size_t aIndex, G4double aNb)
0132     {
0133       fMeshSizeOfCells[aIndex] = aNb;
0134     };
0135     /// Get size of Mesh cells in cylindrical coordinates (r, phi, z)
0136     inline G4ThreeVector GetMeshSizeOfCells() const { return fMeshSizeOfCells; };
0137 
0138     /// Print detector information
0139     void Print() const;
0140 
0141   private:
0142     ///  Messenger that allows to modify geometry
0143     Par04DetectorMessenger* fDetectorMessenger = nullptr;
0144     ///  Inner radius of the cylindrical detector
0145     G4double fDetectorInnerRadius = 80 * cm;
0146     ///  Length of the cylindrical detector (along z axis)
0147     G4double fDetectorLength = 24 * cm;
0148     ///  Logical volume(s) of the sensitive absorbers
0149     std::vector<G4LogicalVolume*> fLayerLogical;
0150     ///  Material(s) of the layers
0151     std::array<G4Material*, 2> fAbsorberMaterial = {nullptr, nullptr};
0152     ///  Thickness(es) of the layers
0153     std::array<G4double, 2> fAbsorberThickness = {1 * cm, 0};
0154     ///  Sensitivity of the layers
0155     std::array<G4bool, 2> fAbsorberSensitivity = {true, 0};
0156     ///  Number of layers = slices along z axis
0157     G4int fNbOfLayers = 24;
0158     ///  Mesh number of cells (Nr, Nphi, Nz)
0159     G4ThreeVector fMeshNbOfCells = {40, 50, 48};
0160     ///  Mesh size of cells (dr, dphi, dz).
0161     G4ThreeVector fMeshSizeOfCells = {5 * mm, 2 * CLHEP::pi / 50 * CLHEP::rad, 5 * mm};
0162 };
0163 
0164 #endif /* PAR04DETECTORCONSTRUCTION_H */