// // ******************************************************************** // * 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 DetectorConstruction.cc /// \brief Implementation of the B1::DetectorConstruction class #include "DetectorConstruction.hh" #include "G4RunManager.hh" #include "G4NistManager.hh" #include "G4Material.hh" #include "G4Box.hh" #include "G4Cons.hh" #include "G4Orb.hh" #include "G4Sphere.hh" #include "G4Trd.hh" #include "G4LogicalVolume.hh" #include "G4PVPlacement.hh" #include "G4SystemOfUnits.hh" #include "G4PhysicalConstants.hh" #include "G4Tubs.hh" const double PI= 3.14159265358979323846; namespace B1 { //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction::DetectorConstruction() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction::~DetectorConstruction() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4VPhysicalVolume* DetectorConstruction::Construct() { // //从NIST物理材料数据库中获取材料管理器的实例 // Get nist material manager G4NistManager* nist = G4NistManager::Instance(); // Envelope parameters //定义了一个被称为“envelope”的立方体几何体的尺寸和材料(水) G4double env_sizeXY = 100*cm, env_sizeZ = 100*cm; G4Material* env_mat = nist->FindOrBuildMaterial("G4_WATER"); // Option to switch on/off checking of volumes overlaps //设置一个选项,以便在创建几何体时检查它们是否有重叠 G4bool checkOverlaps = true; // Air // G4Element* N = new G4Element("Nitrogen", "N", 7 , 14.01*g/mole); G4Element* Mg = new G4Element("Magnesium", "Mg", 12, 24.3*g/mole); G4Element* O = new G4Element("Oxygen" , "O", 8 , 16.00*g/mole); G4Material* air = new G4Material("Air", 1.29*mg/cm3, 2); air->AddElement(N, 70.*perCent); air->AddElement(O, 30.*perCent); G4Material* MgO_mat = new G4Material("MgO", 1*g/cm3, 2); MgO_mat->AddElement(Mg, 60.*perCent); MgO_mat->AddElement(O, 40.*perCent); // Water // G4Element* Hydro = new G4Element("Hydrogen", "H", 1 , 1.01*g/mole); G4Material* water = new G4Material("Water", 1.0*g/cm3, 2); water->AddElement(Hydro, 2); water->AddElement(O, 1); // HNO3 G4double z, a, density; G4String name, symbol; G4int ncomponents, natoms; a = 1.01*g/mole; G4Element* elH = new G4Element(name="Hydrogen",symbol="H" , z= 1., a); a = 16.00*g/mole; G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a); a = 14.0067*g/mole; G4Element* elN = new G4Element(name="Nitrogen" ,symbol="N" , z= 7., a); density = 1.4*g/cm3; G4Material* HN03 = new G4Material(name="HNO3",density,ncomponents=3); HN03->AddElement(elH, natoms=1); HN03->AddElement(elO, natoms=3); HN03->AddElement(elO, natoms=1); G4Material* HNO3_mat = nist->FindOrBuildMaterial("HNO3"); // Envelope parameters // G4Material* Air_mat = nist->FindOrBuildMaterial("G4_AIR"); G4Material* Al_mat = nist->FindOrBuildMaterial("G4_Al"); G4Material* Ar_mat = nist->FindOrBuildMaterial("G4_Ar"); G4Material* Pb_mat = nist->FindOrBuildMaterial("G4_Pb"); G4Material* W_mat = nist->FindOrBuildMaterial("G4_W"); G4Material* Fe_mat = nist->FindOrBuildMaterial("G4_Fe"); G4Material* HPGE_mat = nist->FindOrBuildMaterial("G4_Ge"); G4Material* Cu_mat = nist->FindOrBuildMaterial("G4_Cu"); G4Material* Glass_mat = nist->FindOrBuildMaterial("G4_GLASS_PLATE"); G4Material* NaI_sci_mat=nist->FindOrBuildMaterial("G4_SODIUM_IODIDE"); G4Material* TAI_mat = nist->FindOrBuildMaterial("G4_Ti"); G4Element* Zr = nist->FindOrBuildElement("Zr", false); G4Material* Zr_mat= new G4Material("mCu1",10*g/cm3, 1); Zr_mat->AddElement(Zr, 1); // // World //定义了最大的几何体“world”,代表整个模拟环境的边界。“world”材料是空气 G4double world_sizeXY = 1.2*env_sizeXY; G4double world_sizeZ = 1.2*env_sizeZ; G4Material* world_mat = nist->FindOrBuildMaterial("G4_AIR"); G4Box* solidWorld = new G4Box("World", //its name 0.5*world_sizeXY, 0.5*world_sizeXY, 0.5*world_sizeZ); //its size G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, //its solid world_mat, //its material "World"); //its name G4VPhysicalVolume* physWorld = new G4PVPlacement(0, //no rotation G4ThreeVector(), //at (0,0,0) logicWorld, //its logical volume "World", //its name 0, //its mother volume false, //no boolean operation 0, //copy number checkOverlaps); //overlaps checking // G4double FeiWuTong_r1=10; // inner radius G4double Fe_Tube_r2=14; // outer radius G4double FeiWuTong_high=50; // hight //waitong G4Tubs* Soild_Fe_cover_1= new G4Tubs("Fe_cover_1",FeiWuTong_r1*mm, Fe_Tube_r2*mm, 0.5*FeiWuTong_high*mm,0,2*PI); G4LogicalVolume* logic_Fe_cover_1= new G4LogicalVolume(Soild_Fe_cover_1, Fe_mat, "Soild_Fe_cover_1"); G4VPhysicalVolume* physi_FeiWuTong_1 = new G4PVPlacement(0, G4ThreeVector(0,0,0), logic_Fe_cover_1, "Fe_cover_1", logicWorld, false, 0, checkOverlaps); //neitong G4Tubs* Soild_FeiWuTong_0 = new G4Tubs("FeiWuTong_0",0, FeiWuTong_r1*mm, 0.5*FeiWuTong_high*mm,0,2*PI); G4LogicalVolume* logic_FeiWuTong_0= new G4LogicalVolume(Soild_FeiWuTong_0, Air_mat, "Soild_FeiWuTong_0"); G4VPhysicalVolume* physi_FeiWuTong_0 = new G4PVPlacement(0, G4ThreeVector(0,0,0), logic_FeiWuTong_0, "FeiWuTong_0", logic_Fe_cover_1, false, 0, checkOverlaps); //RJY G4Tubs* Soild_RJY = new G4Tubs("RJY",0, FeiWuTong_r1*mm, 0.25*FeiWuTong_high*mm,0,2*PI); G4LogicalVolume* logic_RJY= new G4LogicalVolume(Soild_RJY, HNO3_mat, "Soild_RJY"); G4VPhysicalVolume* physi_RJY = new G4PVPlacement(0, G4ThreeVector(0,0,-12.5*mm), logic_RJY, "RJY", logic_FeiWuTong_0, false, 0, checkOverlaps); // tanceqi-AL G4double DetAL_sizeXYZ = 20*mm; // G4double DetAR_sizeXYZ = 10*mm; G4Box* solidDeAL = new G4Box("DeAl", //its name 0.5*DetAL_sizeXYZ, 0.5*DetAL_sizeXYZ, 0.5*DetAL_sizeXYZ); //its size G4LogicalVolume* logicDeal = new G4LogicalVolume(solidDeAL, //its solid Al_mat, //its material "DeAl"); //its name G4VPhysicalVolume* physDeAL = new G4PVPlacement(0, //no rotation G4ThreeVector(0,44,0), //at (0,0,0) logicDeal, //its logical volume "DeAl", //its name logicWorld, //its mother volume false, //no boolean operation 0, //copy number checkOverlaps); //overlaps checking //tanceqi-Ar G4Box* solidDeAR = new G4Box("DeAR", //its name 0.5*DetAR_sizeXYZ, 0.5*DetAR_sizeXYZ, 0.5*DetAR_sizeXYZ); //its size G4LogicalVolume* logicDeAR = new G4LogicalVolume(solidDeAR, //its solid Ar_mat, //its material "DeAR"); //its name G4VPhysicalVolume* physDeAR = new G4PVPlacement(0, //no rotation G4ThreeVector(0,44,0), //at (0,0,0) logicDeAR, //its logical volume "DeAR", //its name logicWorld, //its mother volume false, //no boolean operation 0, //copy number checkOverlaps); //overlaps checking //Detialed_Fe_mat G4RotationMatrix* fieldRot = new G4RotationMatrix(); fieldRot->rotateX(90.*deg); G4double HPGE_R=40.15; G4double HPGE_H=31.3; G4double Coll_H=160; G4double Coll_W=200; G4double RoundShield_R=120; G4double RoundShield_H=100; G4double Distance_from_surce_to_center=100; /* G4double W_coll_W=Coll_width;//30 60 G4Box* Soild_coll_vacancy_2=new G4Box("coll_vacancy_2",0.5*W_coll_W, 0.5*W_coll_W, 0.5*Coll_H);//its size G4Box* Soild_shielding_3=new G4Box("shielding_3",0.5*Coll_W, 0.5*Coll_W, 0.5*Coll_H);//its size G4SubtractionSolid *Soild_shielding_coll_4=new G4SubtractionSolid("shielding_coll_4",Soild_shielding_3,Soild_coll_vacancy_2); G4LogicalVolume* logic_shielding_coll_4=new G4LogicalVolume(Soild_shielding_coll_4,W_mat,"shielding_coll_4_log"); new G4PVPlacement(fieldRot,G4ThreeVector(0,-0.5*Coll_H+Distance_from_surce_to_center,0),logic_shielding_coll_4, "shielding_coll_4_log", logicWorld,false,0,checkOverlaps); G4Tubs* Soild_roundshielding_5=new G4Tubs("roundshielding_5",HPGE_R, RoundShield_R, 0.5*RoundShield_H,0,360); G4LogicalVolume* logic_roundshielding_5=new G4LogicalVolume(Soild_roundshielding_5,W_mat,"Soild_W_mat"); new G4PVPlacement(fieldRot,G4ThreeVector(0,0.5*RoundShield_H+Distance_from_surce_to_center,0),logic_roundshielding_5, "roundshielding_5", logicWorld,false,0,checkOverlaps); G4Tubs* Soild_HPGE_6=new G4Tubs("HPGE_6",0, HPGE_R, 0.5*HPGE_H,0,360); G4LogicalVolume* logic_HPGE_6=new G4LogicalVolume(Soild_HPGE_6,HPGE_mat,"Soild_HPGE_6"); new G4PVPlacement(fieldRot,G4ThreeVector(0,0.5*HPGE_H+Distance_from_surce_to_center,0),logic_HPGE_6, "HPGE_6", logicWorld,false,0,checkOverlaps); // Envelope // G4Box* solidEnv = new G4Box("Envelope", //its name 0.5*env_sizeXY, 0.5*env_sizeXY, 0.5*env_sizeZ); //its size G4LogicalVolume* logicEnv = new G4LogicalVolume(solidEnv, //its solid env_mat, //its material "Envelope"); //its name new G4PVPlacement(0, //no rotation G4ThreeVector(), //at (0,0,0) logicEnv, //its logical volume "Envelope", //its name logicWorld, //its mother volume false, //no boolean operation 0, //copy number checkOverlaps); //overlaps checking // // Shape 1 // G4Material* shape1_mat = nist->FindOrBuildMaterial("G4_A-150_TISSUE"); G4ThreeVector pos1 = G4ThreeVector(0, 2*cm, -7*cm); // Conical section shape G4double shape1_rmina = 0.*cm, shape1_rmaxa = 2.*cm; G4double shape1_rminb = 0.*cm, shape1_rmaxb = 4.*cm; G4double shape1_hz = 3.*cm; G4double shape1_phimin = 0.*deg, shape1_phimax = 360.*deg; G4Cons* solidShape1 = new G4Cons("Shape1", shape1_rmina, shape1_rmaxa, shape1_rminb, shape1_rmaxb, shape1_hz, shape1_phimin, shape1_phimax); G4LogicalVolume* logicShape1 = new G4LogicalVolume(solidShape1, //its solid shape1_mat, //its material "Shape1"); //its name new G4PVPlacement(0, //no rotation pos1, //at position logicShape1, //its logical volume "Shape1", //its name logicEnv, //its mother volume false, //no boolean operation 0, //copy number checkOverlaps); //overlaps checking // // Shape 2 // G4Material* shape2_mat = nist->FindOrBuildMaterial("G4_BONE_COMPACT_ICRU"); G4ThreeVector pos2 = G4ThreeVector(0, -1*cm, 7*cm); // Trapezoid shape G4double shape2_dxa = 12*cm, shape2_dxb = 12*cm; G4double shape2_dya = 10*cm, shape2_dyb = 16*cm; G4double shape2_dz = 6*cm; G4Trd* solidShape2 = new G4Trd("Shape2", //its name 0.5*shape2_dxa, 0.5*shape2_dxb, 0.5*shape2_dya, 0.5*shape2_dyb, 0.5*shape2_dz); //its size G4LogicalVolume* logicShape2 = new G4LogicalVolume(solidShape2, //its solid shape2_mat, //its material "Shape2"); //its name new G4PVPlacement(0, //no rotation pos2, //at position logicShape2, //its logical volume "Shape2", //its name logicEnv, //its mother volume false, //no boolean operation 0, //copy number checkOverlaps); //overlaps checking // Set Shape2 as scoring volume // fScoringVolume = logicShape2; */ // //always return the physical World // return physWorld; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... }