// // ******************************************************************** // * 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. * // ******************************************************************** // // /// \file B3/B3a/src/DetectorConstruction.cc /// \brief Implementation of the B3::DetectorConstruction class #include "DetectorConstruction.hh" #include "G4NistManager.hh" #include "G4Box.hh" #include "G4Tubs.hh" #include "G4LogicalVolume.hh" #include "G4PVPlacement.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" #include "G4SDManager.hh" #include "G4MultiFunctionalDetector.hh" #include "G4VPrimitiveScorer.hh" #include "G4PSEnergyDeposit.hh" #include "G4PSDoseDeposit.hh" #include "G4VisAttributes.hh" #include "G4PhysicalConstants.hh" #include "G4SystemOfUnits.hh" namespace B3 { //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction::DetectorConstruction() { DefineMaterials(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::DefineMaterials() { G4NistManager* man = G4NistManager::Instance(); //Collimator material //auto CollMaterial = new G4Material("Lead", 11.35 * g / cm3, 1); //CollMaterial->AddElement(Pb, 100* perCent); /* auto LSO = new G4Material("Lu2SiO5", 7.4 * g / cm3, 3); LSO->AddElement(Lu, 2); LSO->AddElement(Si, 1); LSO->AddElement(O , 5); */ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4VPhysicalVolume* DetectorConstruction::Construct() { // Gamma detector Parameters // G4double Detec_InnerR = 0., Detec_OuterR = 7.0*cm, Detec_HalfL_inZ = 7.0*cm; G4int Starting_phi_angle = 0; G4int Delta_phi_angle = 90; // Source position G4double Source_InnerR = 0., Source_OuterR = 1.0*cm, Source_HalfL_inZ = 1.0*cm; //Shield for detector position G4double Shield_InnerR = 7.9*cm, Shield_OuterR = 9.9*cm, Shield_HalfL_inZ = 7.5*cm; //BackShield for detector position G4double BackShield_InnerR = 0., BackShield_OuterR = 9.9*cm, BackShield_HalfL_inZ = 1.0*cm; /* G4double cryst_dX = 6*cm, cryst_dY = 6*cm, cryst_dZ = 3*cm; G4int nb_cryst = 32; G4int nb_rings = 9; // G4double dPhi = twopi/nb_cryst, half_dPhi = 0.5*dPhi; G4double cosdPhi = std::cos(half_dPhi); G4double tandPhi = std::tan(half_dPhi); // G4double ring_R1 = 0.5*cryst_dY/tandPhi; G4double ring_R2 = (ring_R1+cryst_dZ)/cosdPhi; // G4double detector_dZ = nb_rings*cryst_dX; // */ G4NistManager* nist = G4NistManager::Instance(); G4bool isotopes = false; G4Material* default_mat = nist->FindOrBuildMaterial("G4_AIR"); // G4Material* cryst_mat = nist->FindOrBuildMaterial("Lu2SiO5"); G4Material* CollMaterial = nist->FindOrBuildMaterial("G4_Pb"); // G4NistManager* man = G4NistManager::Instance(); G4Element* Na = man->FindOrBuildElement("Na" , isotopes); G4Element* I = man->FindOrBuildElement("I" , isotopes); //Detector (NAI) material G4Material* NaI = new G4Material("NaI", 3.67 * g / cm3, 2); NaI->AddElement(Na, 50*perCent); NaI->AddElement(I, 50*perCent); G4Element* O = man->FindOrBuildElement("O" , isotopes); // G4Element* Si = man->FindOrBuildElement("Si", isotopes); // G4Element* Lu = man->FindOrBuildElement("Lu", isotopes); G4Element* H = man->FindOrBuildElement("H" , isotopes); G4Element* C = man->FindOrBuildElement("C" , isotopes); G4Element* Bi = man->FindOrBuildElement("Bi" , isotopes); //G4Element* Pb = man->FindOrBuildElement("Pb" , isotopes); // Bismuth Oxide Material auto Bi2O3 = new G4Material("Bi2O3", 8.9 * g / cm3, 2); Bi2O3->AddElement(Bi, 2); Bi2O3->AddElement(O , 3); // Polystyrene Material auto PS = new G4Material("PS", 1.2 * g / cm3, 2); PS->AddElement(H, 8); PS->AddElement(C, 8); // Polymer Material auto poly1 = new G4Material("poly1", 1.15 * g / cm3, 2); poly1->AddMaterial(Bi2O3, 0*perCent); poly1->AddMaterial(PS, 100*perCent); auto poly2 = new G4Material("poly2", 1.19 * g / cm3, 2); poly2->AddMaterial(Bi2O3, 5*perCent); poly2->AddMaterial(PS, 95*perCent); auto poly3 = new G4Material("poly3", 1.24 * g / cm3, 2); poly3->AddMaterial(Bi2O3, 10*perCent); poly3->AddMaterial(PS, 90*perCent); G4double fworld_x = 30.0 * cm; G4double fworld_y = 30.0 * cm; G4double fworld_z = 50.0 * cm; //fTank_x = fTank_y = fTank_z = 5.0 * m; G4double fshield_x = 10*cm; G4double fshield_y = 10*cm; G4double fshield_z = 1 * cm; G4double fshield_InnerR = 0.; // The experimental Hall (world volume) // G4Box* solidWorld = new G4Box("World", fworld_x, fworld_y, fworld_z); G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, default_mat, "World", 0, 0, 0); G4VPhysicalVolume* physWorld = new G4PVPlacement(0, G4ThreeVector(), logicWorld, "World", 0, false, 0); // The Air Bubble/ shielding volume // // G4Box* bubbleAir_box = new G4Box("Bubble", fBubble_x, fBubble_y, fBubble_z); G4Tubs* shield_box = new G4Tubs("shielding", fshield_InnerR,fshield_x, fshield_z,Starting_phi_angle,Delta_phi_angle); G4LogicalVolume* shield_log = new G4LogicalVolume(shield_box, poly2, "shieldingLV", 0, 0, 0); new G4PVPlacement(0, G4ThreeVector(0, 0, 15*cm), shield_log, "shielding", logicWorld, false, 0); // new G4PVPlacement(0, G4ThreeVector(0, 0, 25.5*cm), bubbleAir_log, "Bubble", // expHall_log, false, 0); // Detector i.e sodium iodide detector G4Tubs* Soliddetector = new G4Tubs("Detector",Detec_InnerR,Detec_OuterR,Detec_HalfL_inZ,Starting_phi_angle,Delta_phi_angle); G4LogicalVolume* Detector_log = new G4LogicalVolume(Soliddetector,NaI,"DetectorLV",0,0,0); G4VPhysicalVolume* Detector_phys = new G4PVPlacement(0, G4ThreeVector(0,0,40*cm),Detector_log,"Detector", logicWorld,false,0); // Source volume G4Tubs* Solidsource = new G4Tubs("Source",Source_InnerR,Source_OuterR,Source_HalfL_inZ,Starting_phi_angle,Delta_phi_angle); G4LogicalVolume* Source_log = new G4LogicalVolume(Solidsource,default_mat,"SourceLV",0,0,0); G4VPhysicalVolume* Source_phys = new G4PVPlacement(0, G4ThreeVector(0,0,0),Source_log,"Source", logicWorld,false,0); // Shield volume for the detector G4Tubs* Solidshield = new G4Tubs("Shield",Shield_InnerR,Shield_OuterR,Shield_HalfL_inZ,Starting_phi_angle,Delta_phi_angle); G4LogicalVolume* Shield_log = new G4LogicalVolume(Solidshield,CollMaterial,"ShieldLV",0,0,0); G4VPhysicalVolume* Shield_phys = new G4PVPlacement(0, G4ThreeVector(0,0,40*cm),Shield_log,"Shield", logicWorld,false,0); // Shieldback (back shielding of the detector NaI) G4Tubs* Solidshieldback = new G4Tubs("Shieldback",BackShield_InnerR,BackShield_OuterR,BackShield_HalfL_inZ,Starting_phi_angle,Delta_phi_angle); G4LogicalVolume* Shieldback_log = new G4LogicalVolume(Solidshieldback,CollMaterial,"ShieldbackLV",0,0,0); G4VPhysicalVolume* Shieldback_phys = new G4PVPlacement(0, G4ThreeVector(0,0,48.5*cm),Shieldback_log,"Shieldback", logicWorld,false,0); /* // World // G4double world_sizeXY = 2.4*ring_R2; G4double world_sizeZ = 1.2*detector_dZ; auto solidWorld = new G4Box("World", // its name 0.5 * world_sizeXY, 0.5 * world_sizeXY, 0.5 * world_sizeZ); // its size auto logicWorld = new G4LogicalVolume(solidWorld, // its solid default_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 fCheckOverlaps); // checking overlaps // // ring // auto solidRing = new G4Tubs("Ring", ring_R1, ring_R2, 0.5 * cryst_dX, 0., twopi); auto logicRing = new G4LogicalVolume(solidRing, // its solid default_mat, // its material "Ring"); // its name // // define crystal // G4double gap = 0.5*mm; //a gap for wrapping G4double dX = cryst_dX - gap, dY = cryst_dY - gap; auto solidCryst = new G4Box("crystal", dX / 2, dY / 2, cryst_dZ / 2); auto logicCryst = new G4LogicalVolume(solidCryst, // its solid cryst_mat, // its material "CrystalLV"); // its name // place crystals within a ring // for (G4int icrys = 0; icrys < nb_cryst ; icrys++) { G4double phi = icrys*dPhi; G4RotationMatrix rotm = G4RotationMatrix(); rotm.rotateY(90*deg); rotm.rotateZ(phi); G4ThreeVector uz = G4ThreeVector(std::cos(phi), std::sin(phi),0.); G4ThreeVector position = (ring_R1+0.5*cryst_dZ)*uz; G4Transform3D transform = G4Transform3D(rotm,position); new G4PVPlacement(transform, //rotation,position logicCryst, //its logical volume "crystal", //its name logicRing, //its mother volume false, //no boolean operation icrys, //copy number fCheckOverlaps); // checking overlaps } // // full detector // auto solidDetector = new G4Tubs("Detector", ring_R1, ring_R2, 0.5 * detector_dZ, 0., twopi); auto logicDetector = new G4LogicalVolume(solidDetector, // its solid default_mat, // its material "Detector"); // its name // // place rings within detector // G4double OG = -0.5*(detector_dZ + cryst_dX); for (G4int iring = 0; iring < nb_rings ; iring++) { OG += cryst_dX; new G4PVPlacement(nullptr, // no rotation G4ThreeVector(0, 0, OG), // position logicRing, // its logical volume "ring", // its name logicDetector, // its mother volume false, // no boolean operation iring, // copy number fCheckOverlaps); // checking overlaps } // // place detector in world // new G4PVPlacement(nullptr, // no rotation G4ThreeVector(), // at (0,0,0) logicDetector, // its logical volume "Detector", // its name logicWorld, // its mother volume false, // no boolean operation 0, // copy number fCheckOverlaps); // checking overlaps // // patient // G4double patient_radius = 8*cm; G4double patient_dZ = 10*cm; G4Material* patient_mat = nist->FindOrBuildMaterial("G4_BRAIN_ICRP"); auto solidPatient = new G4Tubs("Patient", 0., patient_radius, 0.5 * patient_dZ, 0., twopi); auto logicPatient = new G4LogicalVolume(solidPatient, // its solid patient_mat, // its material "PatientLV"); // its name // // place patient in world // new G4PVPlacement(nullptr, // no rotation G4ThreeVector(), // at (0,0,0) logicPatient, // its logical volume "Patient", // its name logicWorld, // its mother volume false, // no boolean operation 0, // copy number fCheckOverlaps); // checking overlaps */ // Visualization attributes // // logicRing->SetVisAttributes (G4VisAttributes::GetInvisible()); Detector_log->SetVisAttributes (G4VisAttributes::GetInvisible()); // Print materials G4cout << *(G4Material::GetMaterialTable()) << G4endl; //always return the physical World // return physWorld; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::ConstructSDandField() { G4SDManager::GetSDMpointer()->SetVerboseLevel(1); // declare Detector as a MultiFunctionalDetector scorer // auto cryst = new G4MultiFunctionalDetector("Detector"); G4SDManager::GetSDMpointer()->AddNewDetector(cryst); G4VPrimitiveScorer* primitiv1 = new G4PSEnergyDeposit("edep"); cryst->RegisterPrimitive(primitiv1); SetSensitiveDetector("DetectorLV",cryst); // declare patient as a MultiFunctionalDetector scorer // /* auto patient = new G4MultiFunctionalDetector("patient"); G4SDManager::GetSDMpointer()->AddNewDetector(patient); G4VPrimitiveScorer* primitiv2 = new G4PSDoseDeposit("dose"); patient->RegisterPrimitive(primitiv2); SetSensitiveDetector("PatientLV",patient); */ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... }