Back to home page

EIC code displayed by LXR

 
 

    


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