Also this is for my detectorconstruction.cc
```
namespace myfirst
{
G4VPhysicalVolume* DetectorConstruction::Construct()
{
// Get nist material manager
G4NistManager* nist = G4NistManager::Instance();
//initial variables to be used throughout
G4bool checkOverlaps = true;
// Building my World
//
G4double world_sizeX = 1.0 * m;
G4double world_sizeY = 1.5 * m;
G4double world_sizeZ = 0.8 * m;
G4Material* world_mat = nist->FindOrBuildMaterial("G4_AIR");
auto solidWorld =
new G4Box("World", // its name
0.5 * world_sizeX, 0.5 * world_sizeY, 0.5 * world_sizeZ); // its size
auto logicWorld = new G4LogicalVolume(solidWorld, // its solid
world_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
checkOverlaps); // overlaps checking
// Constructing my /working area
G4double env_sizeX = 0.7 * m;
G4double env_sizeY = 0.6 * m;
G4double env_sizeZ = 0.5 * m;
auto solidOuter = new G4Box("OuterWall", // its name
0.5 * env_sizeX, 0.5 * env_sizeY, 0.5 * env_sizeZ); // its size
G4double wall = 10 * cm;
//G4double clearance = 0.1 * mm;
//dimensions of the inner wall
G4double in_sizeX = 0.7 * m - wall;
G4double in_sizeY = 0.6 * m - wall;
G4double in_sizeZ = 0.5 * m - wall;
auto solidInner = new G4Box("Cabinet", // its name
0.5 * in_sizeX, 0.5 * in_sizeY, 0.5 * in_sizeZ); // its size
// for the actual working area
auto solidWall = new G4SubtractionSolid(
"Wall",
solidOuter,
solidInner);
// creating the logic volumes for both the wall (Outer) and the inner working area (Cabinet)
// first creating stainless steel
auto Fe = nist->FindOrBuildElement("Fe");
auto Cr = nist->FindOrBuildElement("Cr");
auto Ni = nist->FindOrBuildElement("Ni");
G4double density = 8.0 * g / cm3;
auto stainlessSteel =
new G4Material("StainlessSteel",
density,
3);
stainlessSteel->AddElement(Fe, 70. * perCent);
stainlessSteel->AddElement(Cr, 18. * perCent);
stainlessSteel->AddElement(Ni, 12. * perCent);
auto logicOuter = new G4LogicalVolume(solidWall, // its solid
stainlessSteel, // its material
"Wall"); // its name
new G4PVPlacement(nullptr, // no rotation
G4ThreeVector(), // at (0,0,0)
logicOuter, // its logical volume
"Wall", // its name
logicWorld, // its mother volume
false, // no boolean operation
0, // copy number
checkOverlaps); // overlaps checking
//
// now for the working area
G4Material* cabinet_air = nist->FindOrBuildMaterial("G4_AIR");
auto logicCabinet = new G4LogicalVolume(solidInner, // its solid
cabinet_air, // its material
"Cabinet"); // its name
new G4PVPlacement(nullptr, // no rotation
G4ThreeVector(), // at (0,0,0)
logicCabinet, // its logical volume
"Cabinet", // its name
logicOuter, // its mother volume
false, // no boolean operation
0, // copy number
checkOverlaps); // overlaps checking
//
// Shape 1 (calibrator)
//
G4Material* calib_mat = nist->FindOrBuildMaterial("G4_AIR");
G4ThreeVector pos1 = G4ThreeVector(-0.1 *m , 0*m, 0 *m);
// Outer dimensions of the calibrator section shape
G4double pRMin_1 = 0. * cm, pRMax_1 = 8.6 * cm;
G4double pDz_1 = 0.5 * 43.8 * cm;
G4double pSPhi_1 = 0. * deg;
G4double pDPhi_1 = 360. * deg;
auto solidCalibOuter = new G4Tubs("Calib_Outer", pRMin_1, pRMax_1, pDz_1, pSPhi_1, pDPhi_1);
// Inner dimensions of the calibrator
G4double pRMin_2 = 0. * cm, pRMax_2 = 3.05 * cm;
G4double pDz_2 = 0.5 * 25.3 * cm;
G4double pSPhi_2 = 0. * deg;
G4double pDPhi_2 = 360. * deg;
auto solidCalibInner = new G4Tubs("Calib_Inner", pRMin_2, pRMax_2, pDz_2, pSPhi_1, pDPhi_1);
auto solidCalib = new G4SubtractionSolid(
"Calibrator",
solidCalibOuter,
solidCalibInner);
auto logicCalib = new G4LogicalVolume(solidCalib, // its solid
calib_mat, // its material
"Calibrator"); // its name
// nullptr,
//G4ThreeVector(0,0, 9.25*cm)); // offset(halflength of outer -halflength of inner +/- depending on where the hole should start
auto rotX = new G4RotationMatrix();
rotX->rotateX(-90. * deg);
new G4PVPlacement(rotX, // no rotation
pos1, // at position
logicCalib, // its logical volume
"Calibrator", // its name
logicCabinet, // its mother volume
false, // no boolean operation
0, // copy number
checkOverlaps); // overlaps checking
// Shape 2
G4Material* shape2_mat = nist->FindOrBuildMaterial("G4_SKIN_ICRP");
G4ThreeVector pos2 = G4ThreeVector(0.2 *m, 0 * m, 0* m);
// boxshape for scoring volume
G4double shape2_dxa = 10 * cm;
G4double shape2_dya = 10 * cm;
G4double shape2_dza = 10 * cm;
auto solidShape2 =
new G4Box("Shape2", // its name
0.5 * shape2_dxa, 0.5 * shape2_dya, 0.5 * shape2_dza); // its size
auto logicShape2 = new G4LogicalVolume(solidShape2, // its solid
shape2_mat, // its material
"Shape2"); // its name
new G4PVPlacement(nullptr, // no rotation
pos2, // at position
logicShape2, // its logical volume
"Shape2", // its name
logicCabinet, // its mother volume
false, // no boolean operation
0, // copy number
checkOverlaps); // overlaps checking
// now setting visibility
//for wall
auto wallVis = new G4VisAttributes(G4Colour(0.7, 0.7, 0.7,0.05));
wallVis->SetVisibility(true);
wallVis->SetForceSolid(true);
logicOuter->SetVisAttributes(wallVis);
//for working area or cabinet
//logicCabinet->SetVisAttributes(G4VisAttributes::GetInvisible());
auto cabVis = new G4VisAttributes(G4Colour(0.0, 0.5, 0.5, 0.5));
cabVis->SetVisibility(true);
cabVis->SetForceSolid(true);
logicCabinet->SetVisAttributes(cabVis);
// for calibrator
auto calibVis = new G4VisAttributes(G4Colour::Blue());
calibVis->SetVisibility(true);
calibVis->SetForceSolid(true);
logicCalib->SetVisAttributes(calibVis);
// for scoring volume or shape 2
auto shape2Vis = new G4VisAttributes(G4Colour::Red());
shape2Vis->SetVisibility(true);
shape2Vis->SetForceSolid(true);
logicShape2->SetVisAttributes(shape2Vis);
// Set scoring volume
//
fScoringVolume = logicShape2;
//
// always return the physical World
//
return physWorld;
}
} ```