Import Geant4 11.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2025-12-05 08:54:02 +01:00
parent a499fb82e9
commit b4a16de652
6484 changed files with 232674 additions and 221097 deletions
@@ -61,8 +61,16 @@ FlashApplicator::~FlashApplicator() {}
void FlashApplicator::ConstructCollimator(G4VPhysicalVolume *) {
// Sets default geometry and materials
SetDefaultDimensions();
SetOuterRadius(55*mm);
SetApplicatorLength(365*mm);
// DEFAULT APPLICATOR LENGTH AND RADIUS - UNIFORM FLASH CONFIGURATION
SetOuterRadius(55*mm);
SetApplicatorLength(365*mm);
//SET THE FOLLOWING APPLICATOR RADIUS AND LENGTH FOR MINIBEAM CONFIGURATION
// SetOuterRadius(25*mm);
// SetApplicatorLength(173.5*mm);
// Construct the whole Applicator Beam Line
ConstructApplicator();
}
@@ -101,8 +109,9 @@ void FlashApplicator::SetDefaultDimensions() {
magenta->SetVisibility(true);
fInitial_pos = -113*cm; //set the same position in FlashPrimaryGeneratorAction.cc
// Geometry APPLICATOR DEFAULTS
fInitial_pos = -113*cm; //set the same position in FlashPrimaryGeneratorAction.cc for DEFAULT CONFIGURATION - 100 MM DIAMETER APPLICATOR
// fInitial_pos=-74.70005*cm; ////// Set this for MINIBEAM configuration
// Geometry APPLICATOR DEFAULTS
@@ -29,7 +29,7 @@
#include "FlashDetectorConstruction.hh"
#include "FlashMinibeamTemplate.hh"
#include "G4RunManager.hh"
#include "G4Material.hh"
@@ -77,7 +77,6 @@ fPhantomLogicalVolume(0),fPhant_phys(0),
fCheckOverlaps(true),
fActivateDet(false)
{
DefineMaterials();
fDetectorMessenger = new FlashDetectorMessenger(this);
@@ -111,22 +110,14 @@ G4bool isotopes = false;
C = nist->FindOrBuildElement("C", isotopes);
}
//
G4VPhysicalVolume *
FlashDetectorConstruction::ConstructPhantom(G4double CollPos) {
//This function creates a cubic phantom with the point Collpos on the surface of the cube.
fPhantomMaterial = nist->FindOrBuildMaterial("G4_WATER");
fPosition_coefficient = CollPos;
fPhantom_coordinateX = (fPosition_coefficient * mm + fPhantomSizeX / 2);
fPhantomPosition = G4ThreeVector(fPhantom_coordinateX, 0. * mm, 0. * mm); //phantom is constructed with the entrance surface attached to the applicator
// Definition of the solid volume of the Phantom
fPhantom = new G4Box("Phantom", fPhantomSizeX / 2, fPhantomSizeY / 2,
fPhantomSizeZ / 2);
@@ -159,22 +150,14 @@ FlashDetectorConstruction::ConstructPhantom(G4double CollPos) {
return fPhant_phys;
}
void FlashDetectorConstruction::ConstructDetector(){
//Detector
G4double fDensity_SiC=3.22*g/cm3;
SiC=new G4Material("SiC", fDensity_SiC,2);
SiC->AddElement(Si,1);
SiC->AddElement(C,1);
fDetectorMaterial=SiC;
fDet_box = new G4Box("Detector",fDet_thickness/2,fDet_width/2,fDet_width/2);
// Definition of the logical volume of the Detector
@@ -187,11 +170,9 @@ void FlashDetectorConstruction::ConstructDetector(){
// Definition of the logical volume of the Detector substrate
fDet_sub_LogicalVolume =
new G4LogicalVolume(fDet_sub, fDetectorMaterial, "Det_sub_Log", 0, 0, 0);
G4double posInit = (nDet - 1) * fDet_ctc / 2;
if (fActivateDet) {
// Placement physical volumes of the detector array
for (int i = 0; i < nDet; i++){
@@ -221,7 +202,6 @@ if (fActivateDet) {
fCheckOverlaps
));
fDet_sub_phys.push_back (new G4PVPlacement
(0,
G4ThreeVector(-fPhantomSizeX/2+fDetectorPosition+fDet_thickness/2+fDet_sub_thickness/2, 0. * mm, -posInit + fDet_ctc * i),
@@ -231,9 +211,6 @@ if (fActivateDet) {
false,
i,
fCheckOverlaps));
}
}
@@ -252,7 +229,6 @@ G4VPhysicalVolume *FlashDetectorConstruction::Construct() {
airNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
// Air
//
G4Box *treatmentRoom = new G4Box("TreatmentRoom", worldX, worldY, worldZ);
logicTreatmentRoom = new G4LogicalVolume(treatmentRoom, airNist,
"logicTreatmentRoom", 0, 0, 0);
@@ -266,21 +242,24 @@ G4VPhysicalVolume *FlashDetectorConstruction::Construct() {
// -----------------------------
// Applicator + phantom +Default dimensions
//------------------------------
Collimator = new FlashApplicator(physicalTreatmentRoom);
//// Construct minibeam collimator////
fPhantom_physical =
G4bool Template_constr = false; //Set to true to activate the minibeam configuration
if (Template_constr == true){
fTemp_= new FlashMinibeamTemplate(physicalTreatmentRoom,Collimator->fFinalApplicatorXPositionFlash +
Collimator->fHightFinalApplicatorFlash,Collimator->fOuterRadiusFirstApplicatorFlash);
fPhantom_physical =
ConstructPhantom(Collimator->fFinalApplicatorXPositionFlash +
Collimator->fHightFinalApplicatorFlash+fAirGap);
Collimator->fHightFinalApplicatorFlash +fAirGap+ 2*fTemp_->hight );}
else if (Template_constr == false){
fPhantom_physical =
ConstructPhantom(Collimator->fFinalApplicatorXPositionFlash +
Collimator->fHightFinalApplicatorFlash+fAirGap);
}
ConstructDetector();
return physicalTreatmentRoom;
}
@@ -300,8 +279,6 @@ if (fActivateDet){
}
}
/////MESSANGER ///
G4bool FlashDetectorConstruction::SetPhantomMaterial(G4String material)
@@ -332,7 +309,6 @@ G4bool FlashDetectorConstruction::SetPhantomMaterial(G4String material)
return true;
}
void FlashDetectorConstruction::SetPhantomSize(G4double sizeX, G4double sizeY, G4double sizeZ)
{
if (sizeX > 0.) fPhantomSizeX = sizeX;
@@ -374,9 +350,6 @@ G4bool FlashDetectorConstruction::SetDetectorMaterial(G4String material)
return true;
}
void FlashDetectorConstruction::SetDetectorThickness(G4double thickness)
{
@@ -0,0 +1,223 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// This is the first version of Flash, a Geant4-based application
//
//
//////////////////////////////////////////////////////////////////////////////////////////////
#include "FlashMinibeamTemplate.hh"
#include "G4Box.hh"
#include "G4Colour.hh"
#include "G4Cons.hh"
#include "G4LogicalVolume.hh"
#include "G4NistElementBuilder.hh"
#include "G4NistManager.hh"
#include "G4PVPlacement.hh"
#include "G4RotationMatrix.hh"
#include "G4RunManager.hh"
#include "G4SubtractionSolid.hh"
#include "G4SystemOfUnits.hh"
#include "G4MultiUnion.hh"
#include "G4Tubs.hh"
#include "G4VisAttributes.hh"
#include "globals.hh"
#include "G4UserLimits.hh"
#include "G4Region.hh"
#include <cmath>
FlashMinibeamTemplate::FlashMinibeamTemplate(G4VPhysicalVolume *physicalTreatmentRoom, G4double x, G4double r)
: hight(0.),motherPhys(physicalTreatmentRoom),X_center(x), y_center(0.),z_center(0.),d_between_holes(0.),hole_side(0.),radius(r),field_side(0)
{
ConstructCollimator();
}
FlashMinibeamTemplate::~FlashMinibeamTemplate() {}
void FlashMinibeamTemplate::ConstructCollimator() {
// Sets default geometry and materials
SetMaterial();
//ConstructColl_full(); //FULL
// ConstructColl_template(); //GRID
// Construct_hole(); //SINGLE HOLE
ConstructColl_template_planar(); //PLANAR
}
void FlashMinibeamTemplate::SetMaterial() {
//X_center = 0 *cm;
y_center = 0.*cm;
z_center = 0.*cm;
d_between_holes=2; //mm
hole_side = 1; //mm
maxStep = 0.1 * mm;
field_side=10; //mm
TemplateRegion = new G4Region("Template_region");
fStepLimit = new G4UserLimits(maxStep);
blue = new G4VisAttributes(G4Colour(0., 0., 1.));
red = new G4VisAttributes(G4Colour(0., 1., 0.));
blue->SetVisibility(true);
red->SetVisibility(true);
G4NistManager *man = G4NistManager::Instance();
G4bool isotopes = false;
TEFLON = man->FindOrBuildMaterial("G4_TEFLON", isotopes);
TUNGSTEN = man->FindOrBuildMaterial("G4_W", isotopes);
}
void FlashMinibeamTemplate::ConstructColl_full() {
G4double phi1 = 90. * deg;
G4RotationMatrix rm1;
rm1.rotateY(phi1);
const G4double outerRad = radius;
const G4double innRadius = 0. * mm;
hight = 5 * cm;
const G4double startAngle= 0. * deg;
const G4double spanningAngle = 360. * deg;
const G4double XPosition = X_center+hight;
G4VSolid * solid =
new G4Tubs("Solid_template", innRadius, outerRad, hight,
startAngle, spanningAngle);
G4LogicalVolume *log = new G4LogicalVolume(
solid, TUNGSTEN, "Log_template", 0, 0, 0);
new G4PVPlacement(
G4Transform3D(rm1, G4ThreeVector((XPosition), 0., 0.)), "physi_template",
log, motherPhys, false, 0);
log->SetVisAttributes(blue);
log->SetRegion(TemplateRegion);
TemplateRegion->AddRootLogicalVolume(log);
log->SetUserLimits(fStepLimit);
}
void FlashMinibeamTemplate::ConstructColl_template() { //GRID
G4double phi2 = 90. * deg;
G4RotationMatrix rm2;
rm2.rotateY(phi2);
hight = 0.25 * cm;
const G4double XPosition = X_center+hight;
G4Box *t1 = new G4Box("t1_", radius, radius, hight);
G4Box *Air_box = new G4Box("air_templ",hole_side/2,hole_side/2,hight+0.1*mm);
G4MultiUnion* munion_solid = new G4MultiUnion("Boxes_Union");
G4int n_holes = (G4int) round(field_side/(d_between_holes));
G4RotationMatrix rotm = G4RotationMatrix();
G4cout<< "NUMBER:"<<n_holes<<G4endl;
for (G4int i= 0; i<n_holes;i++){
for (G4int j=0;j<n_holes;j++){
G4double xi = (-(n_holes -1)/2+ i)*(d_between_holes) ;
G4double yi = ((n_holes -1)/2- j)*(d_between_holes) ;
G4ThreeVector position = G4ThreeVector(xi*mm,yi*mm,0.);
G4Transform3D tr = G4Transform3D(rotm,position);
munion_solid->AddNode(*Air_box,tr);
}
}
munion_solid->Voxelize();
// Associate it to a logical volume as a normal solid
//
G4RotationMatrix rotm_t2 = G4RotationMatrix();
rotm_t2.rotateX(0 * deg);
G4ThreeVector zTrans(0, 0, 0);
G4SubtractionSolid *hollowcover =
new G4SubtractionSolid("template", t1, munion_solid, 0, zTrans);
G4LogicalVolume *logic =
new G4LogicalVolume(hollowcover, TUNGSTEN, "Log_template", 0, 0, 0);
new G4PVPlacement(
G4Transform3D(rm2, G4ThreeVector((XPosition), 0., 0.)), "cover1phys",
logic, motherPhys, false, 0);
logic->SetVisAttributes(blue);
logic->SetRegion(TemplateRegion);
TemplateRegion->AddRootLogicalVolume(logic);
logic->SetUserLimits(fStepLimit);
}
void FlashMinibeamTemplate::Construct_hole(){ //Single hole
G4double phi2 = 90. * deg;
G4RotationMatrix rm2;
rm2.rotateY(phi2);
const G4double outerRad = radius;
const G4double innRadius = 0. * mm;
hight = 0.25 * cm;
const G4double startAngle= 0. * deg;
const G4double spanningAngle = 360. * deg;
const G4double XPosition = X_center+hight;
G4VSolid *t1 = new G4Tubs("t1_", innRadius, outerRad, hight,
startAngle, spanningAngle);
G4Box *Air_box = new G4Box("air_templ",0.5*cm,0.5*cm,hight+1*mm);
G4RotationMatrix rotm_t2 = G4RotationMatrix();
rotm_t2.rotateX(0 * deg);
//G4ThreeVector zTrans(lato/2, -lato/2, 0);
G4ThreeVector zTrans(0, 0, 0);
G4SubtractionSolid *hollowcover =
new G4SubtractionSolid("template", t1, Air_box, 0, zTrans);
G4LogicalVolume *logic =
new G4LogicalVolume(hollowcover, TUNGSTEN, "Log_template", 0, 0, 0);
new G4PVPlacement(
G4Transform3D(rm2, G4ThreeVector((XPosition), 0., 0.)), "cover1phys",
logic, motherPhys, false, 0);
logic->SetVisAttributes(blue);
logic->SetRegion(TemplateRegion);
TemplateRegion->AddRootLogicalVolume(logic);
logic->SetUserLimits(fStepLimit);
}
void FlashMinibeamTemplate::ConstructColl_template_planar() {
G4double phi2 = 90. * deg;
G4RotationMatrix rm2;
rm2.rotateY(phi2);
hight = 0.25 * cm;
const G4double XPosition = X_center+hight;
G4Box *t1 = new G4Box("t1_", radius, radius, hight);
G4Box *Air_box = new G4Box("air_templ",hole_side/2,field_side/2*mm,hight+0.1*mm);
G4MultiUnion* munion_solid = new G4MultiUnion("Boxes_Union");
G4int n_holes = (G4int) round(field_side/(d_between_holes))/2; //TOTAL HOLE NUMBERS=n_holes*2+1
G4RotationMatrix rotm = G4RotationMatrix();
G4ThreeVector position = G4ThreeVector(0.,0.,0.);
G4Transform3D tr = G4Transform3D(rotm,position);
munion_solid->AddNode(*Air_box,tr);
for (G4int j=1;j<n_holes;j++){
G4double xi = j*(d_between_holes) ;
//G4double yi = ((n_holes -1)/2- j)*(d_between_holes) ;
position = G4ThreeVector(xi*mm,0.,0.);
tr = G4Transform3D(rotm,position);
munion_solid->AddNode(*Air_box,tr);
position = G4ThreeVector(-xi*mm,0.,0.);
tr = G4Transform3D(rotm,position);
munion_solid->AddNode(*Air_box,tr);
}
munion_solid->Voxelize();
// Associate it to a logical volume as a normal solid
//
G4RotationMatrix rotm_t2 = G4RotationMatrix();
rotm_t2.rotateX(0 * deg);
//G4ThreeVector zTrans(lato/2, -lato/2, 0);
G4ThreeVector zTrans(0, 0, 0);
G4SubtractionSolid *hollowcover =
new G4SubtractionSolid("template", t1, munion_solid, 0, zTrans);
G4LogicalVolume *logic =
new G4LogicalVolume(hollowcover, TUNGSTEN, "Log_template", 0, 0, 0);
new G4PVPlacement(
G4Transform3D(rm2, G4ThreeVector((XPosition), 0., 0.)), "cover1phys",
logic, motherPhys, false, 0);
logic->SetVisAttributes(blue);
logic->SetRegion(TemplateRegion);
TemplateRegion->AddRootLogicalVolume(logic);
logic->SetUserLimits(fStepLimit);
}
@@ -55,8 +55,8 @@ void FlashPrimaryGeneratorAction::SetDefaultPrimaryParticle() {
particleGun->SetParticleDefinition(particle);
G4double defaultX0 = -113 * cm; //the beam propagates in the x direction from x=-100cm
G4double defaultX0 = -113 * cm; //DEFAULT CONFIGURATION- 100 MM DIAMETER APPLICATOR
// G4double defaultX0 =-74.70005*cm;// SET THIS FOR MINIBEAM CONFIGURATION
X0 = defaultX0;
G4double defaultY0 = 0.0 * mm;