Import Geant4 11.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2024-06-28 13:08:51 +02:00
parent f7b23877ed
commit e58e650b32
5232 changed files with 239416 additions and 244360 deletions
@@ -29,21 +29,20 @@
#include "DetectorConstruction.hh"
#include "G4NistManager.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4RotationMatrix.hh"
#include "G4Transform3D.hh"
#include "G4SDManager.hh"
#include "G4MultiFunctionalDetector.hh"
#include "G4VPrimitiveScorer.hh"
#include "G4PSEnergyDeposit.hh"
#include "G4NistManager.hh"
#include "G4PSDoseDeposit.hh"
#include "G4VisAttributes.hh"
#include "G4PSEnergyDeposit.hh"
#include "G4PVPlacement.hh"
#include "G4PhysicalConstants.hh"
#include "G4RotationMatrix.hh"
#include "G4SDManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4Transform3D.hh"
#include "G4Tubs.hh"
#include "G4VisAttributes.hh"
namespace B3
{
@@ -63,14 +62,14 @@ void DetectorConstruction::DefineMaterials()
G4bool isotopes = false;
G4Element* O = man->FindOrBuildElement("O" , isotopes);
G4Element* O = man->FindOrBuildElement("O", isotopes);
G4Element* Si = man->FindOrBuildElement("Si", isotopes);
G4Element* Lu = man->FindOrBuildElement("Lu", isotopes);
auto LSO = new G4Material("Lu2SiO5", 7.4 * g / cm3, 3);
LSO->AddElement(Lu, 2);
LSO->AddElement(Si, 1);
LSO->AddElement(O , 5);
LSO->AddElement(O, 5);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -79,44 +78,45 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
{
// Gamma detector Parameters
//
G4double cryst_dX = 6*cm, cryst_dY = 6*cm, cryst_dZ = 3*cm;
G4double cryst_dX = 6 * cm, cryst_dY = 6 * cm, cryst_dZ = 3 * cm;
G4int nb_cryst = 32;
G4int nb_rings = 9;
//
G4double dPhi = twopi/nb_cryst, half_dPhi = 0.5*dPhi;
G4double dPhi = twopi / nb_cryst, half_dPhi = 0.5 * dPhi;
G4double cosdPhi = std::cos(half_dPhi);
G4double tandPhi = std::tan(half_dPhi);
//
G4double ring_R1 = 0.5*cryst_dY/tandPhi;
G4double ring_R2 = (ring_R1+cryst_dZ)/cosdPhi;
G4double ring_R1 = 0.5 * cryst_dY / tandPhi;
G4double ring_R2 = (ring_R1 + cryst_dZ) / cosdPhi;
//
G4double detector_dZ = nb_rings*cryst_dX;
G4double detector_dZ = nb_rings * cryst_dX;
//
G4NistManager* nist = G4NistManager::Instance();
G4Material* default_mat = nist->FindOrBuildMaterial("G4_AIR");
G4Material* cryst_mat = nist->FindOrBuildMaterial("Lu2SiO5");
G4Material* cryst_mat = nist->FindOrBuildMaterial("Lu2SiO5");
//
// World
//
G4double world_sizeXY = 2.4*ring_R2;
G4double world_sizeZ = 1.2*detector_dZ;
G4double world_sizeXY = 2.4 * ring_R2;
G4double world_sizeZ = 1.2 * detector_dZ;
auto solidWorld = new G4Box("World", // its name
0.5 * world_sizeXY, 0.5 * world_sizeXY, 0.5 * world_sizeZ); // its size
auto solidWorld =
new G4Box("World", // its name
0.5 * world_sizeXY, 0.5 * world_sizeXY, 0.5 * world_sizeZ); // its size
auto logicWorld = new G4LogicalVolume(solidWorld, // its solid
default_mat, // its material
"World"); // its name
default_mat, // its material
"World"); // its name
auto physWorld = new G4PVPlacement(nullptr, // no rotation
G4ThreeVector(), // at (0,0,0)
logicWorld, // its logical volume
"World", // its name
nullptr, // its mother volume
false, // no boolean operation
0, // copy number
fCheckOverlaps); // checking overlaps
G4ThreeVector(), // at (0,0,0)
logicWorld, // its logical volume
"World", // its name
nullptr, // its mother volume
false, // no boolean operation
0, // copy number
fCheckOverlaps); // checking overlaps
//
// ring
@@ -124,38 +124,38 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
auto solidRing = new G4Tubs("Ring", ring_R1, ring_R2, 0.5 * cryst_dX, 0., twopi);
auto logicRing = new G4LogicalVolume(solidRing, // its solid
default_mat, // its material
"Ring"); // its name
default_mat, // its material
"Ring"); // its name
//
// define crystal
//
G4double gap = 0.5*mm; //a gap for wrapping
G4double gap = 0.5 * mm; // a gap for wrapping
G4double dX = cryst_dX - gap, dY = cryst_dY - gap;
auto solidCryst = new G4Box("crystal", dX / 2, dY / 2, cryst_dZ / 2);
auto logicCryst = new G4LogicalVolume(solidCryst, // its solid
cryst_mat, // its material
"CrystalLV"); // its name
cryst_mat, // its material
"CrystalLV"); // its name
// place crystals within a ring
//
for (G4int icrys = 0; icrys < nb_cryst ; icrys++) {
G4double phi = icrys*dPhi;
G4RotationMatrix rotm = G4RotationMatrix();
rotm.rotateY(90*deg);
for (G4int icrys = 0; icrys < nb_cryst; icrys++) {
G4double phi = icrys * dPhi;
G4RotationMatrix rotm = G4RotationMatrix();
rotm.rotateY(90 * deg);
rotm.rotateZ(phi);
G4ThreeVector uz = G4ThreeVector(std::cos(phi), std::sin(phi),0.);
G4ThreeVector position = (ring_R1+0.5*cryst_dZ)*uz;
G4Transform3D transform = G4Transform3D(rotm,position);
G4ThreeVector uz = G4ThreeVector(std::cos(phi), std::sin(phi), 0.);
G4ThreeVector position = (ring_R1 + 0.5 * cryst_dZ) * uz;
G4Transform3D transform = G4Transform3D(rotm, position);
new G4PVPlacement(transform, //rotation,position
logicCryst, //its logical volume
"crystal", //its name
logicRing, //its mother volume
false, //no boolean operation
icrys, //copy number
fCheckOverlaps); // checking overlaps
new G4PVPlacement(transform, // rotation,position
logicCryst, // its logical volume
"crystal", // its name
logicRing, // its mother volume
false, // no boolean operation
icrys, // copy number
fCheckOverlaps); // checking overlaps
}
//
@@ -164,71 +164,71 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
auto solidDetector = new G4Tubs("Detector", ring_R1, ring_R2, 0.5 * detector_dZ, 0., twopi);
auto logicDetector = new G4LogicalVolume(solidDetector, // its solid
default_mat, // its material
"Detector"); // its name
default_mat, // its material
"Detector"); // its name
//
// place rings within detector
//
G4double OG = -0.5*(detector_dZ + cryst_dX);
for (G4int iring = 0; iring < nb_rings ; iring++) {
G4double OG = -0.5 * (detector_dZ + cryst_dX);
for (G4int iring = 0; iring < nb_rings; iring++) {
OG += cryst_dX;
new G4PVPlacement(nullptr, // no rotation
G4ThreeVector(0, 0, OG), // position
logicRing, // its logical volume
"ring", // its name
logicDetector, // its mother volume
false, // no boolean operation
iring, // copy number
fCheckOverlaps); // checking overlaps
G4ThreeVector(0, 0, OG), // position
logicRing, // its logical volume
"ring", // its name
logicDetector, // its mother volume
false, // no boolean operation
iring, // copy number
fCheckOverlaps); // checking overlaps
}
//
// place detector in world
//
new G4PVPlacement(nullptr, // no rotation
G4ThreeVector(), // at (0,0,0)
logicDetector, // its logical volume
"Detector", // its name
logicWorld, // its mother volume
false, // no boolean operation
0, // copy number
fCheckOverlaps); // checking overlaps
G4ThreeVector(), // at (0,0,0)
logicDetector, // its logical volume
"Detector", // its name
logicWorld, // its mother volume
false, // no boolean operation
0, // copy number
fCheckOverlaps); // checking overlaps
//
// patient
//
G4double patient_radius = 8*cm;
G4double patient_dZ = 10*cm;
G4double patient_radius = 8 * cm;
G4double patient_dZ = 10 * cm;
G4Material* patient_mat = nist->FindOrBuildMaterial("G4_BRAIN_ICRP");
auto solidPatient = new G4Tubs("Patient", 0., patient_radius, 0.5 * patient_dZ, 0., twopi);
auto logicPatient = new G4LogicalVolume(solidPatient, // its solid
patient_mat, // its material
"PatientLV"); // its name
patient_mat, // its material
"PatientLV"); // its name
//
// place patient in world
//
new G4PVPlacement(nullptr, // no rotation
G4ThreeVector(), // at (0,0,0)
logicPatient, // its logical volume
"Patient", // its name
logicWorld, // its mother volume
false, // no boolean operation
0, // copy number
fCheckOverlaps); // checking overlaps
G4ThreeVector(), // at (0,0,0)
logicPatient, // its logical volume
"Patient", // its name
logicWorld, // its mother volume
false, // no boolean operation
0, // copy number
fCheckOverlaps); // checking overlaps
// Visualization attributes
//
logicRing->SetVisAttributes (G4VisAttributes::GetInvisible());
logicDetector->SetVisAttributes (G4VisAttributes::GetInvisible());
logicRing->SetVisAttributes(G4VisAttributes::GetInvisible());
logicDetector->SetVisAttributes(G4VisAttributes::GetInvisible());
// Print materials
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
//always return the physical World
// always return the physical World
//
return physWorld;
}
@@ -245,7 +245,7 @@ void DetectorConstruction::ConstructSDandField()
G4SDManager::GetSDMpointer()->AddNewDetector(cryst);
G4VPrimitiveScorer* primitiv1 = new G4PSEnergyDeposit("edep");
cryst->RegisterPrimitive(primitiv1);
SetSensitiveDetector("CrystalLV",cryst);
SetSensitiveDetector("CrystalLV", cryst);
// declare patient as a MultiFunctionalDetector scorer
//
@@ -253,10 +253,9 @@ void DetectorConstruction::ConstructSDandField()
G4SDManager::GetSDMpointer()->AddNewDetector(patient);
G4VPrimitiveScorer* primitiv2 = new G4PSDoseDeposit("dose");
patient->RegisterPrimitive(primitiv2);
SetSensitiveDetector("PatientLV",patient);
SetSensitiveDetector("PatientLV", patient);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B3