diff --git a/include/MedtechDetectorConstruction.hh b/include/MedtechDetectorConstruction.hh index 97fceab..97efeaa 100644 --- a/include/MedtechDetectorConstruction.hh +++ b/include/MedtechDetectorConstruction.hh @@ -24,6 +24,8 @@ #include "G4UnionSolid.hh" #include "G4Cons.hh" #include "G4Tubs.hh" +#include "G4VPVParameterisation.hh" +#include "G4RotationMatrix.hh" class MedtechDetectorConstruction : public G4VUserDetectorConstruction { diff --git a/src/MedtechDetectorConstruction.cc b/src/MedtechDetectorConstruction.cc index 6cee296..1860837 100644 --- a/src/MedtechDetectorConstruction.cc +++ b/src/MedtechDetectorConstruction.cc @@ -26,7 +26,8 @@ G4VPhysicalVolume* MedtechDetectorConstruction::Construct() G4Material *air = manager -> FindOrBuildMaterial("G4_AIR"); G4Material *targetMaterial = manager -> FindOrBuildMaterial("G4_Pb"); G4Material *boxMaterial = manager -> FindOrBuildMaterial("G4_W"); - G4Material *tetMaterial = manager -> FindOrBuildMaterial("G4_Fe"); + G4Material *coneMaterial = manager -> FindOrBuildMaterial("G4_Fe"); + G4Material *waterMaterial = manager -> FindOrBuildMaterial("G4_WATER"); //End of Material Section //Physical world @@ -59,18 +60,20 @@ G4VPhysicalVolume* MedtechDetectorConstruction::Construct() //End of Target box //Water after screen - /*G4Box *solidWater = new G4Box("Water", 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 + G4Box *solidWater = new G4Box("Water", 1*m, 1*m, 1*cm); + G4LogicalVolume *logicWater = new G4LogicalVolume(solidWater, waterMaterial, "Water", 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); + */ //End of water after screen //Collimator @@ -90,25 +93,62 @@ G4VPhysicalVolume* MedtechDetectorConstruction::Construct() //End of Collimator //Cone - //G4Tet *solidTet = new G4Tet("solidTet", G4ThreeVector(0, 0, parameter -> GetTetSize()*cm), G4ThreeVector(-2.5*cm, -2.5*cm, 0), G4ThreeVector(2.5*cm, -2.5*cm, 0), G4ThreeVector(0, 2.5*cm, 0)); - //G4Box *solidTetBox = new G4Box("solidTetBox", 1*cm, 1*cm, 1*cm); - //G4UnionSolid *unionTet = new G4UnionSolid("Cone+box", solidTet, solidTetBox); - - //G4Paraboloid *solidCone = new G4Paraboloid("Cone", 2.5*cm, 0*cm, 2.5*cm); G4double radius = parameter -> GetRadius(); G4double tube_size = parameter -> GetTubeSize(); G4double cone_size = parameter -> GetConeSize(); + G4double move_z = 0; //place the first solid to the right place + G4double cone_placement = 0; //move cone to V(1,0,0) - G4Cons *solidCone = new G4Cons("cone", 0, radius*cm, 0, 0, cone_size*cm, 0, 2*CLHEP::pi); //name, inside R -Z, outside, R -Z, inside R Z, outside R Z, half length in z, vmi, vmi - G4Tubs *solidTube = new G4Tubs("tube", 0, radius*cm, tube_size*cm, 0, 2*CLHEP::pi); //name, inner R, outter R, Half length in Z, starting angle, angle of the segment in rad + G4Cons *solidCone = 0; + G4Tubs *solidTube = 0; + G4UnionSolid *unionCone = 0; + G4LogicalVolume *logicCone = 0; - G4double move_z = tube_size + cone_size; + if(cone_size > 0 && tube_size != 0) + { + move_z = tube_size + cone_size; + cone_placement = 2*tube_size + cone_size+ 1; + + solidCone = new G4Cons("cone", 0, radius*cm, 0, 0, cone_size*cm, 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, tube_size*cm, 0, 2*CLHEP::pi); //name, inner R, outter R, Half length in Z, starting angle, angle of the segment in rad + unionCone = new G4UnionSolid("cone", solidCone, solidTube, 0, G4ThreeVector(0, 0, -move_z*cm)); + logicCone = new G4LogicalVolume(unionCone, coneMaterial, "Cone", 0, 0, 0); + } - G4UnionSolid *unionCone = new G4UnionSolid("cone", solidCone, solidTube, 0, G4ThreeVector(0, 0, -move_z*cm)); + else if(cone_size == 0 && tube_size != 0) + { + cone_placement = tube_size + 1; + solidTube = new G4Tubs("tube", 0, radius*cm, tube_size*cm, 0, 2*CLHEP::pi); //name, inner R, outter R, Half length in Z, starting angle, angle of the segment in rad + logicCone = new G4LogicalVolume(solidTube, coneMaterial, "Cone", 0, 0, 0); + } - G4double cone_placement = 2*tube_size + cone_size+ 1; + else if(cone_size < 0 && tube_size != 0) + { + if(cone_size > tube_size) + { + return 0; + } + else + { + G4RotationMatrix *rot = new G4RotationMatrix(); + rot -> rotateX(180 * deg); + + move_z = tube_size+cone_size; + cone_placement = tube_size + 1; + + solidCone = new G4Cons("cone", 0, radius*cm, 0, 0, -cone_size*cm, 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, tube_size*cm, 0, 2*CLHEP::pi); //name, inner R, outter R, Half length in Z, starting angle, angle of the segment in rad + G4SubtractionSolid *subCone = new G4SubtractionSolid("Cone", solidTube, solidCone, rot, G4ThreeVector(0, 0, move_z*cm)); + logicCone = new G4LogicalVolume(subCone, coneMaterial, "Cone", 0, 0, 0); + } + } + if(tube_size == 0) + { + cone_placement = cone_size + 1; + solidCone = new G4Cons("cone", 0, radius*cm, 0, 0, cone_size*cm, 0, 2*CLHEP::pi); //name, inside R -Z, outside, R -Z, inside R Z, outside R Z, half length in z, vmi, vmi + logicCone = new G4LogicalVolume(solidCone, coneMaterial, "Cone", 0, 0, 0); + } - G4LogicalVolume *logicCone = new G4LogicalVolume(unionCone, tetMaterial, "Cone", 0, 0, 0); G4PVPlacement *physicalCone = new G4PVPlacement(0, G4ThreeVector(0, 0, cone_placement*cm), logicCone,