205 lines
9.4 KiB
C++
205 lines
9.4 KiB
C++
//
|
|
// MedtechDetectorConstruction.cc
|
|
// medtech
|
|
//
|
|
// Created by Baranyai David on 2018. 04. 01..
|
|
//
|
|
|
|
#include "MedtechDetectorConstruction.hh"
|
|
|
|
MedtechDetectorConstruction::MedtechDetectorConstruction() : G4VUserDetectorConstruction()
|
|
{
|
|
|
|
}
|
|
|
|
MedtechDetectorConstruction::~MedtechDetectorConstruction()
|
|
{
|
|
|
|
}
|
|
|
|
G4VPhysicalVolume* MedtechDetectorConstruction::Construct()
|
|
{
|
|
Parameters *parameter = Parameters::getInstance();
|
|
|
|
//Material Section
|
|
G4NistManager *manager = G4NistManager::Instance();
|
|
G4Material *air = manager -> FindOrBuildMaterial("G4_Galactic");
|
|
G4Material *targetMaterial = manager -> FindOrBuildMaterial("G4_Pb");
|
|
G4Material *boxMaterial = manager -> FindOrBuildMaterial("G4_W");
|
|
G4Material *coneMaterial = manager -> FindOrBuildMaterial("G4_Fe");
|
|
G4Material *globeMaterial = manager -> FindOrBuildMaterial("G4_W");
|
|
//End of Material Section
|
|
|
|
//Physical world
|
|
G4int world_xyz = 1*m; // world is 1m x 1m x 2m for each
|
|
G4Box *solidWorld = new G4Box("World",world_xyz,world_xyz,4*m); //define a box for world
|
|
|
|
G4LogicalVolume *logicWorld = new G4LogicalVolume(solidWorld, air, "World", 0, 0, 0); //define a logical volume for world
|
|
|
|
G4PVPlacement *physicalWorld = new G4PVPlacement(0, //no rotation
|
|
G4ThreeVector(), //at (0,0,0)
|
|
logicWorld, //it's logical volume
|
|
"World", //it's name
|
|
0, //it's mother volume
|
|
false, //no boolean operations
|
|
0); //no magnetic field
|
|
//End of Physical world
|
|
|
|
//Target box == screen
|
|
G4Box *solidTarget = new G4Box("Target", 1*m, 1*m, 0.1*cm);
|
|
|
|
G4LogicalVolume *logicTarget = new G4LogicalVolume(solidTarget, targetMaterial, "Collimator", 0, 0, 0);
|
|
|
|
G4PVPlacement *physicalTarget = new G4PVPlacement(0, //no rotation
|
|
G4ThreeVector(0, 0, 1.1*m), //at (0,0,0)
|
|
logicTarget, //it's logical volume
|
|
"Target", //it's name
|
|
logicWorld, //it's mother volume
|
|
false, //no boolean operations
|
|
0); //no particular field
|
|
//End of Target box
|
|
|
|
//Water after screen
|
|
/*G4Box *solidWater = new G4Box("waterCell", 1*m, 1*m, 1*m);
|
|
|
|
G4LogicalVolume *logicWater = new G4LogicalVolume(solidWater, waterMaterial, "waterCell", 0, 0, 0);
|
|
|
|
G4PVPlacement *physicalWater = new G4PVPlacement(0, //no rotation
|
|
G4ThreeVector(0, 0, 1.2*m), //at (0,0,0)
|
|
logicWater, //it's logical volume
|
|
"Water", //it's name
|
|
logicWorld, //it's mother volume
|
|
false, //no boolean operations
|
|
0); //no particular field */
|
|
|
|
//Water after screen cells (parameterisation)
|
|
/*G4Box *solidWaterCell = new G4Box("Water", 1*m, 1*m, 1*cm);
|
|
G4VPhysicalVolume *logicWaterCell = new G4VPhysicalVolume(solidWaterCell, waterMaterial, "cellWater", 0, 0, 0);
|
|
G4VPVParameterisation waterCell = new G4VPVParameterisation("cellWater", logicWaterCell, physicalWater, logicWaterCell, false, 0, true);*/
|
|
|
|
//G4VPhysicalVolume *waterCell = new G4PVReplica("waterCell", logicWater, logicWorld, kZAxis, 100, 1*cm, 0.);
|
|
|
|
//End of water after screen
|
|
|
|
//Collimator
|
|
G4double box_size = parameter -> GetBoxSize();
|
|
G4Box *solidB1 = new G4Box("B1", 1*m, 1*m, 0.1*cm);
|
|
G4Box *solidB2 = new G4Box("B2", box_size*cm, box_size*cm, 1.5*cm);
|
|
|
|
G4SubtractionSolid *Box = new G4SubtractionSolid("Box", solidB1, solidB2);
|
|
G4LogicalVolume *logicBox = new G4LogicalVolume(Box, boxMaterial, "Box", 0, 0, 0);
|
|
G4PVPlacement *physicalBox = new G4PVPlacement(0, //no rotation
|
|
G4ThreeVector(0, 0, 10*cm),
|
|
logicBox,
|
|
"Box",
|
|
logicWorld,
|
|
false,
|
|
0);
|
|
//End of Collimator
|
|
|
|
//Cone
|
|
G4double radius = parameter -> GetRadius();
|
|
G4double tube_size = parameter -> GetTubeSize() / 2;
|
|
G4double cone_size = parameter -> GetConeSize() / 2; //we need to substract by 2 for valid size
|
|
G4double move_in_z_to_zero = 0;
|
|
G4double cone_placement = 0; //used to determine where to place the solids
|
|
|
|
G4Cons *solidCone = 0;
|
|
G4Tubs *solidTube = 0;
|
|
G4LogicalVolume *logicCone = 0;
|
|
|
|
G4PVPlacement *physicalCone = 0;
|
|
|
|
if(cone_size > 0)
|
|
{
|
|
cone_placement = abs(cone_size);
|
|
|
|
solidCone = new G4Cons("cone", 0, radius*cm, 0, 0, cone_size*mm, 0, 2*CLHEP::pi); //name, inside R -Z, outside, R -Z, inside R Z, outside R Z, half length in z, vmi, vmi
|
|
//move_in_z_to_zero = cone_size; //put the cone to zero
|
|
cone_placement = cone_size + 2*tube_size; //use tube size + threshold
|
|
logicCone = new G4LogicalVolume(solidCone, coneMaterial, "Cone", 0, 0, 0);
|
|
physicalCone = new G4PVPlacement(0,
|
|
G4ThreeVector(0, 0, cone_placement*mm),
|
|
logicCone,
|
|
"Cone",
|
|
logicWorld,
|
|
false,
|
|
0);
|
|
}
|
|
|
|
else if(cone_size < 0) //cone_size < 0
|
|
{
|
|
G4double abs_cone_size = abs(cone_size);
|
|
cone_placement = abs_cone_size + 2*tube_size;
|
|
|
|
G4RotationMatrix *rot = new G4RotationMatrix();
|
|
rot -> rotateX(180 * deg);
|
|
|
|
solidCone = new G4Cons("cone", 0, radius*cm, 0, 0, -cone_size*mm, 0, 2*CLHEP::pi); //name, inside R -Z, outside, R -Z, inside R Z, outside R Z, half length in z, vmi, vmi
|
|
solidTube = new G4Tubs("tube", 0, radius*cm, -cone_size*mm, 0, 2*CLHEP::pi); //name, inner R, outter R, Half length in Z, starting angle, angle of the segment in rad
|
|
G4SubtractionSolid *Cone = new G4SubtractionSolid("Cone", solidTube, solidCone, rot, G4ThreeVector(0, 0, move_in_z_to_zero*cm));
|
|
logicCone = new G4LogicalVolume(Cone, coneMaterial, "Cone", 0, 0, 0);
|
|
physicalCone = new G4PVPlacement(0,
|
|
G4ThreeVector(0, 0, cone_placement*mm),
|
|
logicCone,
|
|
"Cone",
|
|
logicWorld,
|
|
false,
|
|
0);
|
|
}
|
|
//End of cone
|
|
|
|
|
|
//Tube
|
|
G4PVPlacement *fixTube = 0;
|
|
cone_placement = tube_size;
|
|
|
|
if(tube_size > 0)
|
|
{
|
|
G4Tubs *fixsolidTube = new G4Tubs("tube", 0, radius*cm, tube_size*mm, 0, 2*CLHEP::pi); //name, inner R, outter R, Half length in Z, starting angle, angle of the segment in rad
|
|
G4LogicalVolume *fixlogicalTube = new G4LogicalVolume(fixsolidTube, coneMaterial, "fixTube", 0, 0, 0);
|
|
fixTube = new G4PVPlacement(0,
|
|
G4ThreeVector(0, 0, cone_placement*mm),
|
|
fixlogicalTube,
|
|
"Cone",
|
|
logicWorld,
|
|
false,
|
|
0);
|
|
}
|
|
|
|
//Globe
|
|
G4PVPlacement *Globe = 0;
|
|
G4double globe_size = parameter -> GetGlobeSize() / 2;
|
|
G4double globe_placement = globe_size + cone_placement + 100;
|
|
if(globe_size > 0)
|
|
{
|
|
G4Orb *solidGlobe = new G4Orb("Globe", globe_size*mm);
|
|
G4LogicalVolume *logicalGlobe = new G4LogicalVolume(solidGlobe, globeMaterial, "Globe", 0, 0, 0);
|
|
Globe = new G4PVPlacement(0,
|
|
G4ThreeVector(0, 0, 0.5*m),
|
|
logicalGlobe,
|
|
"Globe",
|
|
logicWorld,
|
|
false,
|
|
0);
|
|
}
|
|
//End of globe
|
|
|
|
//köpeny a másik köré
|
|
G4PVPlacement *sphere = 0;
|
|
G4double sphere_outter_size = 200 / 2;
|
|
G4double sphere_inner_size = 190 / 2;
|
|
G4Sphere *solidSphere = new G4Sphere("sphere", sphere_inner_size, sphere_outter_size, 0, 360*deg, 0, 360*deg); //name, inner R, outter R, starting phi angle, Delta phi angle, starting theta angle, delta theta angle
|
|
G4LogicalVolume * logicalSphere = new G4LogicalVolume(solidSphere, air, "sphere", 0, 0, 0);
|
|
sphere = new G4PVPlacement(0,
|
|
G4ThreeVector(0, 0, 0.5*m),
|
|
logicalSphere,
|
|
"sphere",
|
|
logicWorld,
|
|
false,
|
|
0);
|
|
|
|
|
|
return physicalWorld;
|
|
}
|