Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectorConstruction.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
27 
28 #include "DetectorConstruction.hh"
29 #include "VoxelParam.hh"
30 #include "G4NistManager.hh"
31 #include "G4Box.hh"
32 #include "G4LogicalVolume.hh"
33 #include "G4PVPlacement.hh"
34 #include "G4PVParameterised.hh"
35 #include "VoxelSD.hh"
36 #include "G4VisAttributes.hh"
37 #include "G4SystemOfUnits.hh"
38 
42 
43 // --------------------------------------------------------------------------
45 {
46 }
47 
48 // --------------------------------------------------------------------------
50 {
51 }
52 
53 // --------------------------------------------------------------------------
55 {
56  G4NistManager* nistManager = G4NistManager::Instance();
57  G4VisAttributes* va;
58 
59  // world volume
60  const G4double DXYZ_WORLD = 200.*cm;
61  G4Box* sld_world = new G4Box("world",
62  DXYZ_WORLD/2., DXYZ_WORLD/2., DXYZ_WORLD/2.);
63 
64  G4Material* vacuum = nistManager-> FindOrBuildMaterial("G4_Galactic");
65  G4LV* lv_world = new G4LogicalVolume(sld_world, vacuum, "world");
66  G4PVP* world = new G4PVPlacement(0, G4ThreeVector(), "AREA",
67  lv_world, 0, false, 0);
68  // vis. attributes
69  va = new G4VA(G4Color(1.,1.,1.));
70  va-> SetVisibility(false);
71  lv_world-> SetVisAttributes(va);
72 
73  // water phantom
74  const G4double DXY_PHANTOM = 20.*cm;
75  const G4double DZ_PHANTOM = 50.*cm;
76 
77  G4Box* sld_phantom = new G4Box("phantom",
78  DXY_PHANTOM/2., DXY_PHANTOM/2., DZ_PHANTOM/2.);
79 
80  G4Material* water = nistManager-> FindOrBuildMaterial("G4_WATER");
81  G4LV* lv_phantom = new G4LogicalVolume(sld_phantom,
82  water, "phantom");
83 
84  va = new G4VA(G4Color(0.,1.,1.));
85  lv_phantom-> SetVisAttributes(va);
86 
87  new G4PVP(0, G4ThreeVector(), lv_phantom, "phantom", lv_world, false, 0);
88 
89  // voxel planes
90  const G4double DXY_VXP = 20.*cm;
91  const G4double DZ_VXP = 1.*mm;
92 
93  G4Box* sld_vxp = new G4Box("vxplane", DXY_VXP/2., DXY_VXP/2., DZ_VXP/2.);
94  G4LV* lv_vxp = new G4LV(sld_vxp, water, "vxplane");
95 
96  va = new G4VA(G4Color(1.,0.,0.));
97  va-> SetVisibility(false);
98  lv_vxp-> SetVisAttributes(va);
99 
100  for (G4int iz =0; iz < 500; iz++) {
101  G4double z0 = -DZ_PHANTOM/2. + (iz+0.5)*DZ_VXP;
102  new G4PVP(0, G4ThreeVector(0.,0.,z0),
103  lv_vxp, "vxplane", lv_phantom,
104  false, 1000+iz);
105  }
106 
107  // voxel parameterized
108  G4Box* sld_voxel = new G4Box("voxel",1.,1.,1.); // dummy
109  G4LV* lv_voxel = new G4LV(sld_voxel, water, "voxel");
110  lv_voxel-> SetSensitiveDetector(new VoxelSD("voxel"));
111 
112  va = new G4VA(G4Color(0.,1.,1.));
113  va-> SetVisibility(false);
114  lv_voxel-> SetVisAttributes(va);
115 
116  const G4int nvoxels = 100*100;
117  new G4PVParameterised("voxle", lv_voxel, lv_vxp,
118  kUndefined, nvoxels, new VoxelParam());
119 
120  return world;
121 }