// // ******************************************************************** // * 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.7 2010/06/11 17:01:26 vnivanch Exp $ // GEANT4 tag $Name: geant4-09-04-beta-01 $ // ///////////////////////////////////////////////////////////////////////// // // DetectorConstruction // // Created: 31.01.2003 V.Ivanchenko // // Modified: // 04.06.2006 Adoptation of hadr01 (V.Ivanchenko) // //////////////////////////////////////////////////////////////////////// // #include "DetectorConstruction.hh" #include "DetectorMessenger.hh" #include "G4Tubs.hh" #include "G4LogicalVolume.hh" #include "G4PVPlacement.hh" #include "G4RunManager.hh" #include "G4GeometryManager.hh" #include "G4PhysicalVolumeStore.hh" #include "G4LogicalVolumeStore.hh" #include "G4SolidStore.hh" #include "G4VisAttributes.hh" #include "G4Colour.hh" #include "G4UnitsTable.hh" #include "G4ios.hh" #include "TargetSD.hh" #include "CheckVolumeSD.hh" #include "G4SDManager.hh" #include "HistoManager.hh" #include "G4NistManager.hh" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction::DetectorConstruction() { logicTarget = 0; logicCheck = 0; logicWorld = 0; detectorMessenger = new DetectorMessenger(this); radius = 10.*cm; targetMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al"); worldMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic"); // Prepare sensitive detectors checkSD = new CheckVolumeSD("checkSD"); (G4SDManager::GetSDMpointer())->AddNewDetector( checkSD ); targetSD = new TargetSD("targetSD"); (G4SDManager::GetSDMpointer())->AddNewDetector( targetSD ); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction::~DetectorConstruction() { delete detectorMessenger; } G4VPhysicalVolume* DetectorConstruction::Construct() { // Cleanup old geometry G4GeometryManager::GetInstance()->OpenGeometry(); G4PhysicalVolumeStore::GetInstance()->Clean(); G4LogicalVolumeStore::GetInstance()->Clean(); G4SolidStore::GetInstance()->Clean(); // Sizes G4double checkR = radius + mm; G4double worldR = radius + cm; G4double targetZ = HistoManager::GetPointer()->Length()*0.5; G4double checkZ = targetZ + mm; G4double worldZ = targetZ + cm; G4int nSlices = HistoManager::GetPointer()->NumberOfSlices(); G4double sliceZ = targetZ/G4double(nSlices); // // World // G4Tubs* solidW = new G4Tubs("World",0.,worldR,worldZ,0.,twopi); logicWorld = new G4LogicalVolume( solidW,worldMaterial,"World"); G4VPhysicalVolume* world = new G4PVPlacement(0,G4ThreeVector(), logicWorld,"World",0,false,0); // // Check volume // G4Tubs* solidC = new G4Tubs("Check",0.,checkR,checkZ,0.,twopi); logicCheck = new G4LogicalVolume( solidC,worldMaterial,"World"); // G4VPhysicalVolume* physC = new G4PVPlacement(0,G4ThreeVector(),logicCheck,"World",logicWorld,false,0); logicCheck->SetSensitiveDetector(checkSD); // // Target volume // G4Tubs* solidA = new G4Tubs("Target",0.,radius,sliceZ,0.,twopi); logicTarget = new G4LogicalVolume( solidA,targetMaterial,"Target"); logicTarget->SetSensitiveDetector(targetSD); G4double z = sliceZ - targetZ; for(G4int i=0; iGetName() << " disks with R(mm)= " << radius/mm << " Width(mm)= " << 2.0*sliceZ/mm << " Total Length(mm)= " << 2.0*targetZ/mm << " ###" << G4endl; // colors G4VisAttributes zero = G4VisAttributes::Invisible; logicWorld->SetVisAttributes(&zero); G4VisAttributes regWcolor(G4Colour(0.3, 0.3, 0.3)); logicCheck->SetVisAttributes(®Wcolor); G4VisAttributes regCcolor(G4Colour(0., 0.3, 0.7)); logicTarget->SetVisAttributes(®Ccolor); G4cout << *(G4Material::GetMaterialTable()) << G4endl; return world; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetTargetMaterial(const G4String& mat) { // search the material by its name G4Material* material = G4NistManager::Instance()->FindOrBuildMaterial(mat); if (material && material != targetMaterial) { HistoManager::GetPointer()->SetTargetMaterial(material); targetMaterial = material; if(logicTarget) logicTarget->SetMaterial(targetMaterial); G4RunManager::GetRunManager()->PhysicsHasBeenModified(); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetWorldMaterial(const G4String& mat) { // search the material by its name G4Material* material = G4NistManager::Instance()->FindOrBuildMaterial(mat); if (material && material != worldMaterial) { worldMaterial = material; if(logicWorld) logicWorld->SetMaterial(worldMaterial); G4RunManager::GetRunManager()->PhysicsHasBeenModified(); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::UpdateGeometry() { G4RunManager::GetRunManager()->DefineWorldVolume(Construct()); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetTargetRadius(G4double val) { if(val > 0.0) { radius = val; G4RunManager::GetRunManager()->GeometryHasBeenModified(); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......