#include "construction.hh" MyDetectorConstruction::MyDetectorConstruction() { DefineMaterials(); } MyDetectorConstruction::~MyDetectorConstruction() {} void MyDetectorConstruction::DefineMaterials(){ G4NistManager *nist = G4NistManager::Instance(); /*_____________________________________________________________________________________________________*/ Al = nist->FindOrBuildMaterial("G4_Al"); Fe = nist->FindOrBuildMaterial("G4_Fe"); air = nist->FindOrBuildMaterial("G4_AIR"); Na = nist->FindOrBuildElement("Na"); I = nist->FindOrBuildElement("I"); Mg = nist->FindOrBuildElement("Mg"); C = new G4Element("Carbon", "C", 6, 12.011 * g / mole); // Carbon H = new G4Element("Hydrogen", "H", 1, 1.008 * g / mole); // Hydrogen O = new G4Element("Oxygen", "O", 8, 15.999 * g / mole); // Oxygen // PMMA Material PMMA = new G4Material("PMMA",1.18 *g/cm3,3); PMMA->AddElement(H,8); PMMA->AddElement(C,5); PMMA->AddElement(O,2); // Wood Material wood = new G4Material("wood",1.300 *g/cm3,3); wood->AddElement(C, 50.0 * perCent); wood->AddElement(H, 6.0 * perCent); wood->AddElement(O, 44.0 * perCent); // Sodium Iodide NaI = new G4Material("NaI",3.67 *g/cm3,2); NaI->AddElement(Na,1); NaI->AddElement(I,1); // Define Material Properties G4double energy[1] = {661.7 * keV}; // Refractive Index of NaI G4double rindexNaI[1] = {1.786}; G4double fraction[1] = {1.0}; // Defining Material Propeties of NaI G4MaterialPropertiesTable *mptNaI = new G4MaterialPropertiesTable(); mptNaI->AddProperty("RINDEX", energy, rindexNaI, 1); mptNaI->AddProperty("FASTCOMPONENT", energy, fraction, 2, true); mptNaI->AddConstProperty("SCINTILLATIONYIELD", 38. / keV); mptNaI->AddConstProperty("RESOLUTIONSCALE", 1.0); mptNaI->AddConstProperty("FASTTIMECONSTANT", 250. * ns, true); mptNaI->AddConstProperty("YIELDRATIO", 1.0, true); NaI->SetMaterialPropertiesTable(mptNaI); // Mgo Material as reflector MgO = new G4Material("MgO",3.58* g/ cm3,2); MgO->AddElement(Mg,1); MgO->AddElement(O,1); } void MyDetectorConstruction::Phantom() { G4double angle = 360; G4double angle_rad = angle * CLHEP::pi / 180.0; G4double phantom_x = 3.0 * std::cos(angle_rad) + 21.0; G4double phantom_y = 3.0 * std::sin(angle_rad); G4double alpha_radians = std::atan((3.0 * std::sin(angle_rad)) / (3.0 * std::cos(angle_rad) + 21.0)); // Convert alpha from radians to degrees G4double alpha_degrees = alpha_radians * 180.0 / CLHEP::pi; // Geometrical Parameters G4double fba = 37.1; // Fan beam angle G4double SOD = 42; // Source to detector distance /*___________________________________________________________________________________________________________*/ // Perspex Cylinder tracker = new G4Tubs("tracker",0*cm,6*cm,2*cm, 0.*deg, 360*deg); trackerLog = new G4LogicalVolume(tracker,PMMA,"trackerLog"); phystracker = new G4PVPlacement(0,G4ThreeVector(21*cm,0,4.5*cm),"phystracker",trackerLog,physWorld,0,true); // Aluminium Cylinder cyl2 = new G4Tubs("cyl2",0,1.9*cm,2*cm, 0*deg, 360*deg); cyl2Logical = new G4LogicalVolume(cyl2, Al,"cyl2Logical"); physcyl2 = new G4PVPlacement(new G4RotationMatrix(alpha_degrees*deg,0,0*deg),G4ThreeVector(phantom_x*cm,phantom_y*cm,4.5*cm),"physcyl2",cyl2Logical,physWorld,0,true); G4VSolid* unionSolid = new G4UnionSolid("tracker+cyl2",tracker,cyl2); // Iron Cylinder cyl3 = new G4Tubs("cyl3",0,0.4*cm,2.02*cm,0*deg,360*deg); cyl3Logical = new G4LogicalVolume(cyl3,Fe,"cyl3Logical"); physcyl3 = new G4PVPlacement(new G4RotationMatrix(alpha_degrees*deg,0,0*deg),G4ThreeVector(phantom_x*cm,phantom_y*cm,4.52*cm),"physcyl3",cyl3Logical,physWorld,0,true); G4VSolid* union1 = new G4UnionSolid("unionSolid+cyl2",unionSolid,cyl3); // Wooden Table table = new G4Box("table", 0.5*m,0.4*m,2.5*cm); logictable = new G4LogicalVolume(table,wood,"logictable"); phystable = new G4PVPlacement(0,G4ThreeVector(21*cm,0,0),"phystable",logictable,physWorld,0,true); // Defining source source = new G4Tubs("source",0,1.25*cm, 2.5*mm, 0, 2*CLHEP::pi); Logic_source = new G4LogicalVolume(source,PMMA,"Logic_source"); source1 = new G4PVPlacement(new G4RotationMatrix(90*deg,90*deg,0),G4ThreeVector(-0*cm,0,4.5*cm),"source1",Logic_source,physWorld,0,true); G4VisAttributes* glassVisAttributes = new G4VisAttributes(G4Color(1.0, 1.0, 1.0, 0.3)); // White with 20% transparency glassVisAttributes->SetVisibility(true); // Make sure the material is visible glassVisAttributes->SetForceSolid(true); // Render as solid (or wireframe if you want outlines) trackerLog->SetVisAttributes(glassVisAttributes); cyl2Logical->SetVisAttributes(G4Color::Red()); cyl3Logical->SetVisAttributes(G4Color::Blue()); logictable->SetVisAttributes(G4Color::Brown()); Logic_source->SetVisAttributes(G4Color::Yellow()); } void MyDetectorConstruction::ConstructScintillator1() { NaI_Tube = new G4Tubs("NaI_Tube",0,25.4*mm,25.4*mm,0*deg,360*deg); NaI_Logical1 = new G4LogicalVolume(NaI_Tube,NaI,"NaI_Logical1"); physNaI1 = new G4PVPlacement(new G4RotationMatrix(108.55*deg,90*deg,0),G4ThreeVector(42.225*cm,14.169*cm,5.1085*cm),"physNaI1",NaI_Logical1,physWorld,0,true); fScoringVolume1 = NaI_Logical1; MgO_Tube = new G4Tubs("MgO_Tube",25.4*mm,25.585*mm,25.4*mm,0*deg,360*deg); MgO_Logical1 = new G4LogicalVolume(MgO_Tube,MgO,"MgO_Logical1"); physMgO1 = new G4PVPlacement(new G4RotationMatrix(108.55*deg,90*deg,0),G4ThreeVector(42.225*cm,14.169*cm,5.1085*cm),"physMgO1",MgO_Logical1,physWorld,0,true); Al_Tube = new G4Tubs("Al_Tube",25.585*mm,26.085*mm,25.4*mm,0*deg,360*deg); Al_Logical1 = new G4LogicalVolume(Al_Tube,Al,"Al_Logical1"); physAl1 = new G4PVPlacement(new G4RotationMatrix(108.55*deg,90*deg,0),G4ThreeVector(42.225*cm,14.169*cm,5.1085*cm),"physAl1",Al_Logical1,physWorld,0,true); EndCap = new G4Tubs( "EndCap", // Name of Solid 0, // Inner Radius 26.085 * mm, // Outer Radius 0.5 * mm, // Z Thickness 0, // Starting angle 2 * CLHEP::pi // Ending Angle ); EndCap_Logical1 = new G4LogicalVolume(EndCap,Al,"EndCap_Logical1"); physEndCap1 = new G4PVPlacement(new G4RotationMatrix(108.55*deg,90*deg,0),G4ThreeVector(39.81794*cm,13.3615*cm,5.1085*cm),"physEndCap1",EndCap_Logical1,physWorld,0,true); physEndCap2 = new G4PVPlacement(new G4RotationMatrix(108.55*deg,90*deg,0),G4ThreeVector(44.634*cm,14.977*cm,5.1085*cm),"physEndCap2",EndCap_Logical1,physWorld,1,true); NaI_Logical1->SetVisAttributes(G4Color::Blue()); Al_Logical1->SetVisAttributes(G4Color::Red()); EndCap_Logical1->SetVisAttributes(G4Color::Red()); } void MyDetectorConstruction::ConstructScintillator2() { NaI_Logical2 = new G4LogicalVolume(NaI_Tube,NaI,"NaI_Logical2"); physNaI2 = new G4PVPlacement(new G4RotationMatrix(99.275*deg,90*deg,0),G4ThreeVector(43.95769*cm,7.1786547*cm,5.1085*cm),"physNaI2",NaI_Logical2,physWorld,0,true); fScoringVolume2 = NaI_Logical2; MgO_Logical2 = new G4LogicalVolume(MgO_Tube,MgO,"MgO_Logical2"); physMgO2 = new G4PVPlacement(new G4RotationMatrix(99.275*deg,90*deg,0),G4ThreeVector(43.95769*cm,7.1786547*cm,5.1085*cm),"physMgO2",MgO_Logical2,physWorld,0,true); Al_Logical2 = new G4LogicalVolume(Al_Tube,Al,"Al_Logical2"); physAl2 = new G4PVPlacement(new G4RotationMatrix(99.275*deg,90*deg,0),G4ThreeVector(43.95769*cm,7.1786547*cm,5.1085*cm),"physAl2",Al_Logical2,physWorld,0,true); EndCap_Logical2 = new G4LogicalVolume(EndCap,Al,"EndCap_Logical2"); physEndCap3 = new G4PVPlacement(new G4RotationMatrix(99.275*deg,90*deg,0),G4ThreeVector(41.45*cm,6.77*cm,5.1085*cm),"physEndCap3",EndCap_Logical2,physWorld,0,true); physEndCap4 = new G4PVPlacement(new G4RotationMatrix(99.275*deg,90*deg,0),G4ThreeVector(46.464*cm,7.588*cm,5.1085*cm),"physEndCap4",EndCap_Logical2,physWorld,1,true); Al_Logical2->SetVisAttributes(G4Color::Yellow()); EndCap_Logical2->SetVisAttributes(G4Color::Yellow()); } void MyDetectorConstruction::ConstructScintillator3() { NaI_Logical3 = new G4LogicalVolume(NaI_Tube,NaI,"NaI_Logical3"); physNaI3 = new G4PVPlacement(new G4RotationMatrix(90*deg,90*deg,0),G4ThreeVector(44.54*cm,0,5.1085*cm),"physNaI3",NaI_Logical3,physWorld,0,true); fScoringVolume3 = NaI_Logical3; MgO_Logical3 = new G4LogicalVolume(MgO_Tube,MgO,"MgO_Logical3"); physMgO3 = new G4PVPlacement(new G4RotationMatrix(90*deg,90*deg,0),G4ThreeVector(44.54*cm,0,5.1085*cm),"physMgO3",MgO_Logical3,physWorld,0,true); Al_Logical3 = new G4LogicalVolume(Al_Tube,Al,"Al_Logical3"); physAl3 = new G4PVPlacement(new G4RotationMatrix(90*deg,90*deg,0),G4ThreeVector(44.54*cm,0,5.1085*cm),"physAl3",Al_Logical3,physWorld,0,true); EndCap_Logical3 = new G4LogicalVolume(EndCap,Al,"EndCap_Logical3"); physEndCap5 = new G4PVPlacement(new G4RotationMatrix(90*deg,90*deg,0),G4ThreeVector(42.00*cm,0,5.1085*cm),"physEndCap5",EndCap_Logical3,physWorld,0,true); physEndCap6 = new G4PVPlacement(new G4RotationMatrix(90*deg,90*deg,0),G4ThreeVector(47.08*cm,0,5.1085*cm),"physEndCap6",EndCap_Logical3,physWorld,1,true); Al_Logical3->SetVisAttributes(G4Color::Blue()); EndCap_Logical3->SetVisAttributes(G4Color::Blue()); } void MyDetectorConstruction::ConstructScintillator4() { NaI_Logical4 = new G4LogicalVolume(NaI_Tube,NaI,"NaI_Logical4"); physNaI4 = new G4PVPlacement(new G4RotationMatrix(80.725*deg,90*deg,0), G4ThreeVector(43.957*cm,-7.17865*cm,5.1085*cm),"physNaI4",NaI_Logical4,physWorld,0,true); fScoringVolume4 = NaI_Logical4; MgO_Logical4 = new G4LogicalVolume(MgO_Tube,MgO,"MgO_Logical4"); physMgO4 = new G4PVPlacement(new G4RotationMatrix(80.725*deg,90*deg,0),G4ThreeVector(43.957*cm,-7.17865*cm,5.1085*cm),"physMgO4",MgO_Logical4,physWorld,0,true); Al_Logical4 = new G4LogicalVolume(Al_Tube,Al,"Al_Logical4"); physAl4 = new G4PVPlacement(new G4RotationMatrix(80.725*deg,90*deg,0),G4ThreeVector(43.957*cm,-7.17865*cm,5.1085*cm),"physAl4",Al_Logical4,physWorld,0,true); EndCap_Logical4 = new G4LogicalVolume(EndCap,Al,"EndCap_Logical4"); physEndCap7 = new G4PVPlacement(new G4RotationMatrix(80.725*deg,90*deg,0),G4ThreeVector(41.450*cm,-6.769*cm,5.1085*cm),"physEndCap7",EndCap_Logical4,physWorld,0,true); physEndCap8 = new G4PVPlacement(new G4RotationMatrix(80.725*deg,90*deg,0),G4ThreeVector(46.464*cm,-7.5880*cm,5.1085*cm),"physEndCap8",EndCap_Logical4,physWorld,1,true); Al_Logical4->SetVisAttributes(G4Color::Green()); EndCap_Logical4->SetVisAttributes(G4Color::Green()); } void MyDetectorConstruction::ConstructScintillator5() { NaI_Logical5 = new G4LogicalVolume(NaI_Tube,NaI,"NaI_Logical5"); physNaI5 = new G4PVPlacement(new G4RotationMatrix(71.45*deg,90*deg,0), G4ThreeVector(42.225*cm,-14.169*cm,5.1085*cm),"physNaI5",NaI_Logical5,physWorld,0,true); fScoringVolume5 = NaI_Logical5; MgO_Logical5 = new G4LogicalVolume(MgO_Tube,MgO,"MgO_Logical5"); physMgO5 = new G4PVPlacement(new G4RotationMatrix(71.45*deg,90*deg,0),G4ThreeVector(42.225*cm,-14.169*cm,5.1085*cm),"physMgO5",MgO_Logical5,physWorld,0,true); Al_Logical5 = new G4LogicalVolume(Al_Tube,Al,"Al_Logical5"); physAl5 = new G4PVPlacement(new G4RotationMatrix(71.45*deg,90*deg,0),G4ThreeVector(42.225*cm,-14.169*cm,5.1085*cm),"physAl5",Al_Logical5,physWorld,0,true); EndCap_Logical5 = new G4LogicalVolume(EndCap,Al,"EndCap_Logical5"); physEndCap9 = new G4PVPlacement(new G4RotationMatrix(71.45*deg,90*deg,0),G4ThreeVector(39.81794*cm,-13.3615*cm,5.1085*cm),"physEndCap9",EndCap_Logical5,physWorld,0,true); physEndCap10 = new G4PVPlacement(new G4RotationMatrix(71.45*deg,90*deg,0),G4ThreeVector(44.634*cm,-14.977*cm,5.1085*cm),"physEndCap10",EndCap_Logical5,physWorld,1,true); Al_Logical5->SetVisAttributes(G4Color::Cyan()); EndCap_Logical5->SetVisAttributes(G4Color::Cyan()); } G4VPhysicalVolume *MyDetectorConstruction::Construct() { /*___________________________________________________________________________________________________________*/ // Defining World Volume solidWorld = new G4Box("World",2*m, 4*m, 2*m); logicalWorld = new G4LogicalVolume(solidWorld,air,"World"); physWorld = new G4PVPlacement(0, G4ThreeVector(), logicalWorld, "World", 0, false, 0, true); /*____________________________________________________________________________________________________________*/ Phantom(); ConstructScintillator1(); ConstructScintillator2(); ConstructScintillator3(); ConstructScintillator4(); ConstructScintillator5(); G4VSolid* unionSolid = new G4UnionSolid("Al_Tube+EndCap", Al_Tube, EndCap); /*___________________________________________________________________________________________________________*/ // Adding VisAttributes G4VisAttributes* visAttributes = new G4VisAttributes(G4Colour::Brown()); visAttributes->SetVisibility(false); logicalWorld->SetVisAttributes(visAttributes); /*____________________________________________________________________________________________________________*/ return physWorld; }