Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:51

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // This example is provided by the Geant4-DNA collaboration
0027 // Any report or published results obtained using the Geant4-DNA software
0028 // shall cite the following Geant4-DNA collaboration publication:
0029 // Med. Phys. 37 (2010) 4692-4708
0030 // The Geant4-DNA web site is available at http://geant4-dna.org
0031 //
0032 //
0033 /// \file DetectorConstruction.cc
0034 /// \brief Implementation of the DetectorConstruction class
0035 
0036 #include "DetectorConstruction.hh"
0037 
0038 #include "G4Box.hh"
0039 #include "G4NistManager.hh"
0040 #include "G4PVPlacement.hh"
0041 #include "G4RunManager.hh"
0042 #include "G4SystemOfUnits.hh"
0043 #include "G4VPhysicalVolume.hh"
0044 #include "G4VisAttributes.hh"
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 
0048 DetectorConstruction::DetectorConstruction() : fpDefaultMaterial(0), fpWaterMaterial(0) {}
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 
0052 DetectorConstruction::~DetectorConstruction() {}
0053 
0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0055 
0056 G4VPhysicalVolume* DetectorConstruction::Construct()
0057 {
0058   DefineMaterials();
0059   return ConstructVolumes();
0060 }
0061 
0062 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0063 
0064 void DetectorConstruction::DefineMaterials()
0065 {
0066   G4NistManager* nistManager = G4NistManager::Instance();
0067 
0068   nistManager->FindOrBuildMaterial("G4_WATER", false);
0069   fpWaterMaterial = G4Material::GetMaterial("G4_WATER");
0070 
0071   nistManager->FindOrBuildMaterial("G4_AIR", false);
0072   fpDefaultMaterial = G4Material::GetMaterial("G4_AIR");
0073 }
0074 
0075 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0076 
0077 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
0078 {
0079   // World
0080   G4double worldSize = 2 * micrometer;
0081 
0082   G4Box* solidWorld = new G4Box("World", worldSize / 2., worldSize / 2., worldSize / 2.);
0083   G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, fpDefaultMaterial, "World");
0084   G4VPhysicalVolume* physiWorld =
0085     new G4PVPlacement(0, G4ThreeVector(), "World", logicWorld, 0, false, 0);
0086   // Target Box
0087   // from Francis et al. Comput. Meth. Programs. Biomed. 2011 101(3)
0088   G4double targetSizeXY = 1 * micrometer;
0089   G4double targetSizeZ = 0.5 * micrometer;
0090 
0091   G4Box* solidTarget = new G4Box("Target", targetSizeXY / 2., targetSizeXY / 2., targetSizeZ / 2.);
0092   G4LogicalVolume* logicTarget = new G4LogicalVolume(solidTarget, fpWaterMaterial, "Target");
0093   new G4PVPlacement(0, G4ThreeVector(), "Target", logicTarget, physiWorld, false, 0);
0094 
0095   // Visualization attributes
0096   G4VisAttributes* worldVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0097   worldVisAtt->SetVisibility(true);
0098   logicWorld->SetVisAttributes(worldVisAtt);
0099 
0100   G4VisAttributes* targetVisAtt = new G4VisAttributes(G4Colour(0.0, 1.0, 0.0));
0101   targetVisAtt->SetVisibility(true);
0102   targetVisAtt->SetForceAuxEdgeVisible(true);
0103   logicTarget->SetVisAttributes(targetVisAtt);
0104 
0105   // always return the world volume
0106   return physiWorld;
0107 }