Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-02 07:42:52

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 /// \file DetectorConstruction.cc
0027 /// \brief Implementation of the DetectorConstruction class
0028 
0029 // This example is provided by the Geant4-DNA collaboration
0030 // Any report or published results obtained using the Geant4-DNA software
0031 // shall cite the following Geant4-DNA collaboration publication:
0032 // Med. Phys. 37 (2010) 4692-4708
0033 // The Geant4-DNA web site is available at http://geant4-dna.org
0034 //
0035 //
0036 
0037 #include "DetectorConstruction.hh"
0038 
0039 #include "G4Box.hh"
0040 #include "G4NistManager.hh"
0041 #include "G4PVPlacement.hh"
0042 #include "G4RunManager.hh"
0043 #include "G4SystemOfUnits.hh"
0044 #include "G4VPhysicalVolume.hh"
0045 #include "G4VisAttributes.hh"
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 DetectorConstruction::DetectorConstruction() : fpDefaultMaterial(0), fpWaterMaterial(0) {}
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0052 
0053 DetectorConstruction::~DetectorConstruction() {}
0054 
0055 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0056 
0057 G4VPhysicalVolume* DetectorConstruction::Construct()
0058 {
0059   DefineMaterials();
0060   return ConstructVolumes();
0061 }
0062 
0063 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0064 
0065 void DetectorConstruction::DefineMaterials()
0066 {
0067   G4NistManager* nistManager = G4NistManager::Instance();
0068 
0069   nistManager->FindOrBuildMaterial("G4_WATER", false);
0070   fpWaterMaterial = G4Material::GetMaterial("G4_WATER");
0071 
0072   nistManager->FindOrBuildMaterial("G4_AIR", false);
0073   fpDefaultMaterial = G4Material::GetMaterial("G4_AIR");
0074 }
0075 
0076 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0077 
0078 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
0079 {
0080   // World
0081   G4double worldSize = 2 * micrometer;
0082 
0083   G4Box* solidWorld = new G4Box("World", worldSize / 2., worldSize / 2., worldSize / 2.);
0084   G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, fpDefaultMaterial, "World");
0085   G4VPhysicalVolume* physiWorld =
0086     new G4PVPlacement(0, G4ThreeVector(), "World", logicWorld, 0, false, 0);
0087   // Target Box
0088   // from Francis et al. Comput. Meth. Programs. Biomed. 2011 101(3)
0089   G4double targetSizeXY = 1 * micrometer;
0090   G4double targetSizeZ = 0.5 * micrometer;
0091 
0092   G4Box* solidTarget = new G4Box("Target", targetSizeXY / 2., targetSizeXY / 2., targetSizeZ / 2.);
0093   G4LogicalVolume* logicTarget = new G4LogicalVolume(solidTarget, fpWaterMaterial, "Target");
0094   new G4PVPlacement(0, G4ThreeVector(), "Target", logicTarget, physiWorld, false, 0);
0095 
0096   // Visualization attributes
0097   G4VisAttributes* worldVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0098   worldVisAtt->SetVisibility(true);
0099   logicWorld->SetVisAttributes(worldVisAtt);
0100 
0101   G4VisAttributes* targetVisAtt = new G4VisAttributes(G4Colour(0.0, 1.0, 0.0));
0102   targetVisAtt->SetVisibility(true);
0103   targetVisAtt->SetForceAuxEdgeVisible(true);
0104   logicTarget->SetVisAttributes(targetVisAtt);
0105 
0106   // always return the world volume
0107   return physiWorld;
0108 }