28#include <G4Exception.hh>
29#include <G4ExceptionSeverity.hh>
30#include <G4SystemOfUnits.hh>
31#include <G4ThreeVector.hh>
32#include <G4VUserDetectorConstruction.hh>
39#include "G4LogicalVolume.hh"
40#include "G4Material.hh"
41#include "G4NistManager.hh"
42#include "G4PVPlacement.hh"
44#include "G4RegionStore.hh"
45#include "G4RunManager.hh"
46#include "G4SDManager.hh"
48#include "G4UnitsTable.hh"
49#include "G4VisAttributes.hh"
78 G4Material* air = nistManager->FindOrBuildMaterial(
"G4_AIR");
81 G4double full2Pi = 2. * CLHEP::pi * rad;
82 G4double layerThickness =
85 G4double worldSizeXY = detectorOuterRadius * 4.;
88 G4int nbOfMaterials = 0;
91 if(material !=
nullptr)
96 auto fSolidWorld =
new G4Box(
"World",
111 fLogicWorld->SetVisAttributes(G4VisAttributes::GetInvisible());
114 auto fSolidDetector =
new G4Tubs(
"Detector",
124 G4ThreeVector(0, 0, 0),
133 auto detectorRegion =
new G4Region(
"DetectorRegion");
134 detectorRegion->AddRootLogicalVolume(fLogicDetector);
137 std::array<G4VisAttributes, 2> attribs;
138 attribs[0].SetColour(
G4Colour(0, 0, 1, 0.1));
139 attribs[0].SetForceSolid(
true);
140 attribs[1].SetColour(
G4Colour(1, 0, 0, 0.1));
141 attribs[1].SetForceSolid(
true);
144 for(G4int iLayer = 0; iLayer <
fNbOfLayers; iLayer++)
146 for(G4int iMaterial = 0; iMaterial < nbOfMaterials; iMaterial++)
148 auto fSolidLayer =
new G4Tubs(
"Layer",
163 iLayer * nbOfMaterials + iMaterial,
165 logical->SetVisAttributes(attribs[iMaterial]);
184 G4SDManager::GetSDMpointer()->AddNewDetector(caloSD);
187 SetSensitiveDetector(logical, caloSD);
190 auto detectorRegion = G4RegionStore::GetInstance()->GetRegion(
"DetectorRegion");
202 G4cout <<
"\n------------------------------------------------------"
205 <<
"\n--- Number of layers:\t" <<
fNbOfLayers << G4endl <<
"\n--- 1st layer: \t"
213 G4cout <<
"-----------------------------------------------------" << G4endl;
221 G4Material* material = G4NistManager::Instance()->FindOrBuildMaterial(aName);
225 G4Exception(
"Par04DetectorConstruction::SetAbsorberMaterial()",
"InvalidSetup", FatalException,
226 (
"Unknown material name: " + aName).c_str());
227 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
233 const G4double aThickness)
238 G4Exception(
"Par04DetectorConstruction::SetAbsorberThickness()",
"InvalidSetup", FatalException,
239 (
"Requested layer " + std::to_string(aLayer) +
240 " is larger than number of available layers (" +
243 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
249 const G4bool aSensitivity)
255 "Par04DetectorConstruction::SetAbsorberSensitivity()",
"InvalidSetup", FatalException,
256 (
"Requested layer " + std::to_string(aLayer) +
" is larger than number of available layers ("+
259 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
Defince mesh for energy scoring.
void SetAbsorberSensitivity(const std::size_t aLayer, const G4bool aSensitivity)
Set sensitivity of the layer.
void SetLength(G4double aLength)
Set length radius of the cylindrical detector.
Par04DetectorMessenger * fDetectorMessenger
Messenger that allows to modify geometry.
virtual G4VPhysicalVolume * Construct() final
Par04DetectorConstruction()
G4double fDetectorInnerRadius
Inner radius of the cylindrical detector.
virtual ~Par04DetectorConstruction()
virtual void ConstructSDandField() final
G4ThreeVector fMeshSizeOfCells
Mesh size of cells (dr, dphi, dz).
std::array< G4bool, 2 > fAbsorberSensitivity
Sensitivity of the layers.
std::vector< G4LogicalVolume * > fLayerLogical
Logical volume(s) of the sensitive absorbers.
void SetAbsorberMaterial(const std::size_t aLayer, const G4String &aMaterial)
Set material of the layer (from NIST materials)
std::array< G4double, 2 > fAbsorberThickness
Thickness(es) of the layers.
void Print() const
Print detector information.
std::array< G4Material *, 2 > fAbsorberMaterial
Material(s) of the layers.
void SetInnerRadius(G4double aInnerRadius)
Set inner radius of the cylindrical detector.
G4int fNbOfLayers
Number of layers = slices along z axis.
G4ThreeVector fMeshNbOfCells
Mesh number of cells (Nr, Nphi, Nz)
G4double fDetectorLength
Length of the cylindrical detector (along z axis)
void SetAbsorberThickness(const std::size_t aLayer, const G4double aThickness)
Set thickness of the layer.