Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 #ifndef PAR04DETECTORCONSTRUCTION_H 27 #define PAR04DETECTORCONSTRUCTION_H 28 29 #include "G4Material.hh" // for G4Material 30 #include "G4SystemOfUnits.hh" // for cm, mm, rad 31 #include "G4ThreeVector.hh" // for G4ThreeVector 32 #include "G4VUserDetectorConstruction.hh" // for G4VUserDetectorConstruction 33 34 #include <CLHEP/Units/SystemOfUnits.h> // for cm, mm, pi, rad 35 #include <G4String.hh> // for G4String 36 #include <G4Types.hh> // for G4double, G4bool, G4int 37 #include <array> // for array 38 #include <cstddef> // for size_t 39 #include <vector> // for vector 40 class G4LogicalVolume; 41 class G4VPhysicalVolume; 42 class Par04DetectorMessenger; 43 44 /** 45 * @brief Detector construction. 46 * 47 * Creates a cylindrical detector, with cylinder axis along Z-axis. It is placed 48 * in the centre of the world volume. 49 * Dimensions of the detector (inner radius and its length) as well as composition (number of 50 * radial layers, number of absorbers, its thicknesses and materials) can be set using the UI 51 * commands. There may be up to two absorbers used to build the layers. 52 * 53 * TODO Extend to allow use of more than two different absorbers. 54 * 55 * Each absorber may have differnt thickness (along radial direction), material, and may be 56 * either sensitive to particle passage (will register deposited energy) or not (passive). 57 * Readout geometry of the detector is dynamic, and its size can be set by UI commands. 58 * Cells are created along z-axis, azimuthal angle, and radius (cylindrical 59 * segmentation). The z axis is parallel to the direction of the particle entering the 60 * detector volume. The mesh also starts at the entrance to the detector volume. 61 * In order to define this enrance position and direction, a fast simulation model is used. 62 * For the detector volume, if particle has entered, sets the particle direction and position 63 * in the event information. Those vectors define the readout mesh for the event. 64 * 65 * TODO In order to speed up the simulation, fast simulation that checks for the entrance 66 * properites should be defined in a very thin region instead of a whole region of the detector. 67 * 68 * Sensitive detector Par04SensitiveDetector is attached to the detector volume 69 * Region for the detector is created as an envelope of the fast simulation. 70 * 71 */ 72 73 class Par04DetectorConstruction : public G4VUserDetectorConstruction 74 { 75 public: 76 Par04DetectorConstruction(); 77 virtual ~Par04DetectorConstruction(); 78 79 virtual G4VPhysicalVolume* Construct() final; 80 virtual void ConstructSDandField() final; 81 82 /// Set inner radius of the cylindrical detector 83 void SetInnerRadius(G4double aInnerRadius); 84 /// Get inner radius of the cylindrical detector 85 inline G4double GetInnerRadius() const { return fDetectorInnerRadius; }; 86 /// Set length radius of the cylindrical detector 87 void SetLength(G4double aLength); 88 /// Get length of the cylindrical detector (along z-axis) 89 inline G4double GetLength() const { return fDetectorLength; }; 90 /// Set number of layers 91 inline void SetNbOfLayers(G4int aNumber) { fNbOfLayers = aNumber; }; 92 /// Get number of layers 93 inline G4int GetNbOfLayers() const { return fNbOfLayers; }; 94 95 /// Set material of the layer (from NIST materials) 96 void SetAbsorberMaterial(const std::size_t aLayer, const G4String& aMaterial); 97 /// Get name of the material of the layer 98 inline G4String GetAbsorberMaterial(const std::size_t aLayer) const 99 { 100 return fAbsorberMaterial[aLayer]->GetName(); 101 }; 102 /// Set thickness of the layer 103 void SetAbsorberThickness(const std::size_t aLayer, const G4double aThickness); 104 /// Get thickness of the layer 105 inline G4double GetAbsorberThickness(const std::size_t aLayer) const 106 { 107 return fAbsorberThickness[aLayer]; 108 }; 109 /// Set sensitivity of the layer 110 void SetAbsorberSensitivity(const std::size_t aLayer, const G4bool aSensitivity); 111 /// Get sensitivity of the layer 112 inline G4bool GetAbsorberSensitivity(const std::size_t aLayer) const 113 { 114 return fAbsorberSensitivity[aLayer]; 115 }; 116 117 /// Set number of Mesh cells in cylindrical coordinates (r, phi, z) 118 inline void SetMeshNbOfCells(G4ThreeVector aNb) { fMeshNbOfCells = aNb; }; 119 /// Set number of Mesh cells in cylindrical coordinates along one of the axis 120 /// @param[in] aIndex index of cylindrical axis (0,1,2) = (r, phi, z) 121 inline void SetMeshNbOfCells(std::size_t aIndex, G4double aNb) 122 { 123 fMeshNbOfCells[aIndex] = aNb; 124 }; 125 /// Get number of Mesh cells in cylindrical coordinates (r, phi, z) 126 inline G4ThreeVector GetMeshNbOfCells() const { return fMeshNbOfCells; }; 127 /// Set size of Mesh cells in cylindrical coordinates (r, phi, z) 128 inline void SetMeshSizeOfCells(G4ThreeVector aNb) { fMeshSizeOfCells = aNb; }; 129 /// Set size of Mesh cells in cylindrical coordinates along one of the axis 130 /// @param[in] aIndex index of cylindrical axis (0,1,2) = (r, phi, z) 131 inline void SetMeshSizeOfCells(std::size_t aIndex, G4double aNb) 132 { 133 fMeshSizeOfCells[aIndex] = aNb; 134 }; 135 /// Get size of Mesh cells in cylindrical coordinates (r, phi, z) 136 inline G4ThreeVector GetMeshSizeOfCells() const { return fMeshSizeOfCells; }; 137 138 /// Print detector information 139 void Print() const; 140 141 private: 142 /// Messenger that allows to modify geometry 143 Par04DetectorMessenger* fDetectorMessenger = nullptr; 144 /// Inner radius of the cylindrical detector 145 G4double fDetectorInnerRadius = 80 * cm; 146 /// Length of the cylindrical detector (along z axis) 147 G4double fDetectorLength = 24 * cm; 148 /// Logical volume(s) of the sensitive absorbers 149 std::vector<G4LogicalVolume*> fLayerLogical; 150 /// Material(s) of the layers 151 std::array<G4Material*, 2> fAbsorberMaterial = {nullptr, nullptr}; 152 /// Thickness(es) of the layers 153 std::array<G4double, 2> fAbsorberThickness = {1 * cm, 0}; 154 /// Sensitivity of the layers 155 std::array<G4bool, 2> fAbsorberSensitivity = {true, 0}; 156 /// Number of layers = slices along z axis 157 G4int fNbOfLayers = 24; 158 /// Mesh number of cells (Nr, Nphi, Nz) 159 G4ThreeVector fMeshNbOfCells = {40, 50, 48}; 160 /// Mesh size of cells (dr, dphi, dz). 161 G4ThreeVector fMeshSizeOfCells = {5 * mm, 2 * CLHEP::pi / 50 * CLHEP::rad, 5 * mm}; 162 }; 163 164 #endif /* PAR04DETECTORCONSTRUCTION_H */ 165