28#include "DetectorConstruction.hh"
34#include "G4AutoDelete.hh"
37#include "G4GlobalMagFieldMessenger.hh"
38#include "G4LogicalVolume.hh"
39#include "G4Material.hh"
40#include "G4NistManager.hh"
41#include "G4PVPlacement.hh"
42#include "G4PVReplica.hh"
43#include "G4PhysicalConstants.hh"
44#include "G4SDManager.hh"
45#include "G4SystemOfUnits.hh"
46#include "G4VisAttributes.hh"
54G4ThreadLocal G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger =
nullptr;
63 return DefineVolumes();
68void DetectorConstruction::DefineMaterials() {
70 auto nistManager = G4NistManager::Instance();
71 nistManager->FindOrBuildMaterial(
"G4_Pb");
77 new G4Material(
"liquidArgon", z = 18., a = 39.95 * g / mole, density = 1.390 * g / cm3);
81 new G4Material(
"Galactic", z = 1., a = 1.01 * g / mole, density = universe_mean_density,
82 kStateGas, 2.73 * kelvin, 3.e-18 * pascal);
85 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
90G4VPhysicalVolume* DetectorConstruction::DefineVolumes() {
93 G4double absoThickness = 10. * mm;
94 G4double gapThickness = 5. * mm;
95 G4double calorSizeXY = 10. * cm;
97 auto layerThickness = absoThickness + gapThickness;
98 auto calorThickness = fNofLayers * layerThickness;
99 auto worldSizeXY = 1.2 * calorSizeXY;
100 auto worldSizeZ = 1.2 * calorThickness;
103 auto defaultMaterial = G4Material::GetMaterial(
"Galactic");
104 auto absorberMaterial = G4Material::GetMaterial(
"G4_Pb");
105 auto gapMaterial = G4Material::GetMaterial(
"liquidArgon");
107 if (!defaultMaterial || !absorberMaterial || !gapMaterial) {
108 G4ExceptionDescription msg;
109 msg <<
"Cannot retrieve materials already defined.";
110 G4Exception(
"DetectorConstruction::DefineVolumes()",
"MyCode0001", FatalException, msg);
116 auto worldS =
new G4Box(
"World",
117 worldSizeXY / 2, worldSizeXY / 2, worldSizeZ / 2);
119 auto worldLV =
new G4LogicalVolume(worldS,
123 auto worldPV =
new G4PVPlacement(
nullptr,
135 auto calorimeterS =
new G4Box(
"Calorimeter",
136 calorSizeXY / 2, calorSizeXY / 2, calorThickness / 2);
138 auto calorLV =
new G4LogicalVolume(calorimeterS,
142 new G4PVPlacement(
nullptr,
154 auto layerS =
new G4Box(
"Layer",
155 calorSizeXY / 2, calorSizeXY / 2, layerThickness / 2);
157 auto layerLV =
new G4LogicalVolume(layerS,
161 new G4PVReplica(
"Layer",
174 const std::string stepDir = G4OCCT_B4C_STEP_DIR;
177 auto absorberLV =
new G4LogicalVolume(absorberS,
181 new G4PVPlacement(
nullptr,
182 G4ThreeVector(0., 0., -gapThickness / 2),
198 auto gapLV =
new G4LogicalVolume(gapS,
202 new G4PVPlacement(
nullptr,
203 G4ThreeVector(0., 0., absoThickness / 2),
214 G4cout << G4endl <<
"------------------------------------------------------------" << G4endl
215 <<
"---> The calorimeter is " << fNofLayers <<
" layers of: [ " << absoThickness / mm
216 <<
"mm of " << absorberMaterial->GetName() <<
" + " << gapThickness / mm <<
"mm of "
217 << gapMaterial->GetName() <<
" ] " << G4endl
218 <<
"------------------------------------------------------------" << G4endl;
223 worldLV->SetVisAttributes(G4VisAttributes::GetInvisible());
224 calorLV->SetVisAttributes(G4VisAttributes(G4Colour::White()));
240 auto absoSD =
new CalorimeterSD(
"AbsorberSD",
"AbsorberHitsCollection", fNofLayers);
241 G4SDManager::GetSDMpointer()->AddNewDetector(absoSD);
242 SetSensitiveDetector(
"AbsoLV", absoSD);
244 auto gapSD =
new CalorimeterSD(
"GapSD",
"GapHitsCollection", fNofLayers);
245 G4SDManager::GetSDMpointer()->AddNewDetector(gapSD);
246 SetSensitiveDetector(
"GapLV", gapSD);
254 G4ThreeVector fieldValue;
255 fMagFieldMessenger =
new G4GlobalMagFieldMessenger(fieldValue);
256 fMagFieldMessenger->SetVerboseLevel(1);
259 G4AutoDelete::Register(fMagFieldMessenger);
Definition of the B4c::CalorimeterSD class.
Declaration of G4OCCTSolid.
G4VPhysicalVolume * Construct() override
void ConstructSDandField() override
static G4OCCTSolid * FromSTEP(const G4String &name, const std::string &path)