// #include "B3DetectorConstruction.hh" #include "PhantomConstruction.hh" // #include "G4RunManager.hh" #include "G4NistManager.hh" #include "G4Box.hh" #include "G4Tubs.hh" #include "G4VSolid.hh" #include "G4LogicalVolume.hh" #include "G4VPhysicalVolume.hh" #include "G4PVPlacement.hh" #include "G4PVParameterised.hh" #include "G4PVReplica.hh" #include "G4UserLimits.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" #include "G4SDManager.hh" #include "G4MultiFunctionalDetector.hh" #include "G4VPrimitiveScorer.hh" #include "G4PSEnergyDeposit.hh" #include "G4PSDoseDeposit.hh" #include "G4PhysicalConstants.hh" #include "G4SystemOfUnits.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" #include "G4GenericMessenger.hh" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... B3DetectorConstruction::B3DetectorConstruction() : G4VUserDetectorConstruction(), fCheckOverlaps(false), fMessenger(nullptr), rotmAngle() { DefineMaterials(); DefineCommands(); } B3DetectorConstruction::~B3DetectorConstruction() { delete fMessenger; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void B3DetectorConstruction::DefineMaterials() { G4NistManager* man = G4NistManager::Instance(); G4bool isotopes = false; G4Element* O = man->FindOrBuildElement("O" , isotopes); G4Element* Si = man->FindOrBuildElement("Si", isotopes); G4Element* Lu = man->FindOrBuildElement("Lu", isotopes); G4Material* 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* B3DetectorConstruction::Construct() { // Parameters G4NistManager* nist = G4NistManager::Instance(); G4Material* air = nist->FindOrBuildMaterial("G4_AIR"); G4Material* lso = nist->FindOrBuildMaterial("Lu2SiO5"); G4Material* NaI = nist->FindOrBuildMaterial("G4_SODIUM_IODIDE"); // World G4Box* solidWorld = new G4Box("World",0.5*20*cm, 0.5*40*cm, 0.5*210*cm); G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld,air,"World"); 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 fCheckOverlaps); //overlaps checking ////////////////////////////////////////////////////////////////////////////////////////////// // det G4Box* solid_det0 = new G4Box("dets0", 0.5*10*mm, 0.5*100*mm, 0.5*5*mm); G4Box* solid_det1 = new G4Box("dets1", 0.5*10*mm, 0.5*100*mm, 0.5*5*mm); G4LogicalVolume* logic_det1 = new G4LogicalVolume(solid_det0,air,"det1"); G4LogicalVolume* logic_det2 = new G4LogicalVolume(solid_det1,air,"det2"); G4LogicalVolume* logic_det3 = new G4LogicalVolume(solid_det1,air,"det3"); // pix G4Box* solid_pix1 = new G4Box("pixs1",0.5*0.5*mm, 0.5*0.5*mm, 0.5*5*mm); G4Box* solid_pix2 = new G4Box("pixs2",0.5*1*mm, 0.5*1*mm, 0.5*5*mm); G4LogicalVolume* logic_pix1 = new G4LogicalVolume(solid_pix1,lso,"pix1"); G4LogicalVolume* logic_pix2 = new G4LogicalVolume(solid_pix2,NaI,"pix2"); G4LogicalVolume* logic_pix3 = new G4LogicalVolume(solid_pix2,NaI,"pix3"); ////////////////////////////////////////////////////////////////////////////////////////////// for(G4int i = 0; i<20; i++){ for(G4int j = 0; j<200; j++){ G4ThreeVector pos = G4ThreeVector((i-9.5)/2*mm, (j-99.5)/2*mm, 0); G4int pix_index = i*200+j; new G4PVPlacement(0,pos,logic_pix1,"phys_pix1",logic_det1,false,pix_index,fCheckOverlaps); } } for(G4int i = 0; i<10; i++){ for(G4int j = 0; j<100; j++){ G4ThreeVector pos = G4ThreeVector((i-4.5)*mm, (j-49.5)*mm, 0); G4int pix_index = i*100+j; new G4PVPlacement(0,pos,logic_pix2,"phys_pix2",logic_det2,false,pix_index,fCheckOverlaps); new G4PVPlacement(0,pos,logic_pix3,"phys_pix3",logic_det3,false,pix_index,fCheckOverlaps); } } ////////////////////////////////////////////////////////////////////////////////////////////// // arrange det new G4PVPlacement(0,G4ThreeVector(0,0, -50*cm),logic_det1,"phys_det1",logicWorld,false,0,fCheckOverlaps); new G4PVPlacement(0,G4ThreeVector(0, -10*cm, -50*cm),logic_det2,"phys_det2",logicWorld,false,0,fCheckOverlaps); new G4PVPlacement(0,G4ThreeVector(0, 10*cm, -50*cm),logic_det3,"phys_det3",logicWorld,false,0,fCheckOverlaps); //Phantom G4Box* solid_env = new G4Box("solid_env", 0.5*20*cm, 0.5*20*cm, 0.5*20*cm); G4LogicalVolume* logic_env = new G4LogicalVolume(solid_env,air,"logic_env"); PhantomConstruction* Phantom = new PhantomConstruction(logic_env, rotmAngle); G4cout << "### angle " << rotmAngle << " start." << G4endl; new G4PVPlacement(0,G4ThreeVector(),logic_env,"phys_env",logicWorld,false,0,fCheckOverlaps); //always return the physical World return physWorld; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void B3DetectorConstruction::ConstructSDandField() { // G4SDManager::GetSDMpointer()->SetVerboseLevel(1); // // declare crystal as a MultiFunctionalDetector scorer // // // G4MultiFunctionalDetector* p1 = new G4MultiFunctionalDetector("phys_pix1"); // G4SDManager::GetSDMpointer()->AddNewDetector(p1); // G4VPrimitiveScorer* primitiv1 = new G4PSEnergyDeposit("edep"); // p1->RegisterPrimitive(primitiv1); // SetSensitiveDetector("pix1",p1); // // // G4MultiFunctionalDetector* p2 = new G4MultiFunctionalDetector("phys_pix2"); // G4SDManager::GetSDMpointer()->AddNewDetector(p2); // G4VPrimitiveScorer* primitiv2 = new G4PSEnergyDeposit("edep"); // p2->RegisterPrimitive(primitiv2); // SetSensitiveDetector("pix2",p2); // // // G4MultiFunctionalDetector* p3 = new G4MultiFunctionalDetector("phys_pix3"); // G4SDManager::GetSDMpointer()->AddNewDetector(p3); // G4VPrimitiveScorer* primitiv3 = new G4PSEnergyDeposit("edep"); // p3->RegisterPrimitive(primitiv3); // SetSensitiveDetector("pix3",p3); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void B3DetectorConstruction::DefineCommands() { // Define /B5/detector command directory using generic messenger class fMessenger = new G4GenericMessenger(this, "/rotPhantom/", "Phantom control"); // armAngle command auto& fangleCmd = fMessenger->DeclareMethodWithUnit("angleDeg","deg", &B3DetectorConstruction::SetAngle, "Set rotation angle."); fangleCmd.SetParameterName("angle", true); fangleCmd.SetDefaultValue("45."); } void B3DetectorConstruction::SetAngle(G4double val) { rotmAngle = val; // tell G4RunManager that we change the geometry G4RunManager::GetRunManager()->GeometryHasBeenModified(); }