// // ******************************************************************** // * 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 B1/src/DetectorConstruction.cc /// \brief Implementation of the B1::DetectorConstruction class #include "DetectorConstruction.hh" #include "G4RunManager.hh" #include "G4NistManager.hh" #include "G4Box.hh" #include "G4Orb.hh" #include "G4LogicalVolume.hh" #include "G4PVPlacement.hh" #include "G4SystemOfUnits.hh" namespace B1 { //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4VPhysicalVolume* DetectorConstruction::Construct() { G4bool checkOverlaps = true; // Get nist material manager G4NistManager* nist = G4NistManager::Instance(); G4Material* air = nist->FindOrBuildMaterial("G4_AIR"); G4Material* material = nist->FindOrBuildMaterial("G4_WATER"); // World auto solidWorld = new G4Box("World", 20*m, 20*m, 20*m); auto logicWorld = new G4LogicalVolume(solidWorld, air, "World"); auto physWorld = new G4PVPlacement(nullptr, G4ThreeVector(), logicWorld, "World", nullptr, false, 0, checkOverlaps); // Sphere G4double r; auto solidSphere = new G4Orb("Sphere", r = 10.0*m); auto logicSphere = new G4LogicalVolume(solidSphere, material, "Sphere"); new G4PVPlacement(nullptr, G4ThreeVector(), logicSphere, "Sphere", logicWorld, false, 0, checkOverlaps); // Box G4double x, y, z; auto solidBox = new G4Box("Sphere", x = 0.5*m, y = 1.0*m, z = 1.5*m); auto logicBox = new G4LogicalVolume(solidBox, material, "Box"); // Place boxes G4int nTheta = 6, nPhi = 8; G4double dTheta = 180.*deg/nTheta; G4double dPhi = 360.*deg/nPhi; G4Translate3D shiftZ(0, 0, r + z); for (G4int i = 1; i < nTheta; ++i) { G4RotateY3D rotTheta(i*dTheta); for (G4int k = 0; k < nPhi; ++k) { G4int copyNumber = 100*i + k + 1; G4RotateZ3D rotPhi(k*dPhi); auto transform = rotPhi*rotTheta*shiftZ; new G4PVPlacement(transform, logicBox, "Box", logicWorld, false, copyNumber, checkOverlaps); } } //always return the physical World fScoringVolume = logicWorld; return physWorld; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... }