// // ******************************************************************** // * 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. * // ******************************************************************** // // $Id: DetectorConstruction.cc,v 1.2 2006/10/02 16:25:55 vnivanch Exp $ // GEANT4 tag $Name: geant4-09-03-cand-01 $ // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... #include "DetectorConstruction.hh" #include "DetectorMessenger.hh" #include "G4Material.hh" #include "G4Box.hh" #include "G4LogicalVolume.hh" #include "G4PVPlacement.hh" #include "G4GeometryManager.hh" #include "G4PhysicalVolumeStore.hh" #include "G4LogicalVolumeStore.hh" #include "G4SolidStore.hh" #include "G4UnitsTable.hh" #include "G4PolarizationManager.hh" #include "G4NistManager.hh" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction::DetectorConstruction() :pWorld(0), pBox(0), aMaterial(0) { boxSizeXY = 50*mm; boxSizeZ = 5*mm; worldSize = 1.*m; aMaterial = 0; wMaterial = 0; SetTargetMaterial("G4_Fe"); SetWorldMaterial("G4_Galactic"); detectorMessenger = new DetectorMessenger(this); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction::~DetectorConstruction() { delete detectorMessenger; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4VPhysicalVolume* DetectorConstruction::Construct() { // Cleanup old geometry G4GeometryManager::GetInstance()->OpenGeometry(); G4PhysicalVolumeStore::GetInstance()->Clean(); G4LogicalVolumeStore::GetInstance()->Clean(); G4SolidStore::GetInstance()->Clean(); G4PolarizationManager::GetInstance()->Clean(); // World // G4Box* sWorld = new G4Box("World", //name worldSize/2,worldSize/2,worldSize/2); //dimensions G4LogicalVolume* lWorld = new G4LogicalVolume(sWorld, //shape wMaterial, //material "World"); //name pWorld = new G4PVPlacement(0, //no rotation G4ThreeVector(), //at (0,0,0) lWorld, //logical volume "World", //name 0, //mother volume false, //no boolean operation 0); //copy number // Box // G4Box* sBox = new G4Box("Container", //its name boxSizeXY/2.,boxSizeXY/2.,boxSizeZ/2.); //its dimensions G4LogicalVolume* lBox = new G4LogicalVolume(sBox, //its shape aMaterial, //its material "theBox"); //its name pBox = new G4PVPlacement(0, //no rotation G4ThreeVector(), //at (0,0,0) lBox, //its logical volume aMaterial->GetName(), //its name lWorld, //its mother volume false, //no boolean operation 0); //copy number // register logical Volume in PolarizationManager with zero polarization G4PolarizationManager * polMgr = G4PolarizationManager::GetInstance(); polMgr->SetVolumePolarization(lBox,G4ThreeVector(0.,0.,0.)); PrintParameters(); //always return the root volume // return pWorld; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::PrintParameters() { G4cout << "\n The Box is " << G4BestUnit(boxSizeXY,"Length") << " x " << G4BestUnit(boxSizeXY,"Length") << " x " << G4BestUnit(boxSizeZ,"Length") << " of " << aMaterial->GetName() << G4endl; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetTargetMaterial(G4String materialChoice) { // search the material by its name G4Material* mat = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); if (mat != aMaterial) { if(mat) { aMaterial = mat; UpdateGeometry(); } else { G4cout << "### Warning! Target material: <" << materialChoice << "> not found" << G4endl; } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetWorldMaterial(G4String materialChoice) { // search the material by its name G4Material* mat = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); if (mat != wMaterial) { if(mat) { wMaterial = mat; UpdateGeometry(); } else { G4cout << "### Warning! World material: <" << materialChoice << "> not found" << G4endl; } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetSizeXY(G4double value) { boxSizeXY = value; if (worldSizeDefineWorldVolume(Construct()); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......