source: trunk/examples/extended/parallel/MPI/exMPI02/src/DetectorConstruction.cc@ 1330

Last change on this file since 1330 was 807, checked in by garnier, 17 years ago

update

File size: 5.4 KB
Line 
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// ********************************************************************
25//
26// $Id: DetectorConstruction.cc,v 1.1 2007/11/16 14:29:33 kmura Exp $
27// $Name: $
28//
29// ====================================================================
30// DetectorConstruction.cc
31//
32// 2007 Q
33// ====================================================================
34#include "DetectorConstruction.hh"
35#include "VoxelParam.hh"
36#include "G4NistManager.hh"
37#include "G4Box.hh"
38#include "G4LogicalVolume.hh"
39#include "G4PVPlacement.hh"
40#include "G4PVParameterised.hh"
41#include "VoxelSD.hh"
42#include "G4VisAttributes.hh"
43
44typedef G4LogicalVolume G4LV;
45typedef G4PVPlacement G4PVP;
46typedef G4VisAttributes G4VA;
47
48// ====================================================================
49//
50// class description
51//
52// ====================================================================
53
54////////////////////////////////////////////
55DetectorConstruction::DetectorConstruction()
56////////////////////////////////////////////
57{
58}
59
60/////////////////////////////////////////////
61DetectorConstruction::~DetectorConstruction()
62/////////////////////////////////////////////
63{
64}
65
66////////////////////////////////////////////////////
67G4VPhysicalVolume* DetectorConstruction::Construct()
68////////////////////////////////////////////////////
69{
70 G4NistManager* nistManager= G4NistManager::Instance();
71 G4VisAttributes* va;
72
73 // ==============================================================
74 // world volume
75 // ==============================================================
76 const G4double DXYZ_WORLD= 200.*cm;
77 G4Box* sld_world= new G4Box("world",
78 DXYZ_WORLD/2., DXYZ_WORLD/2., DXYZ_WORLD/2.);
79
80 G4Material* vacuum= nistManager-> FindOrBuildMaterial("G4_Galactic");
81 G4LV* lv_world= new G4LogicalVolume(sld_world, vacuum, "world");
82 G4PVP* world= new G4PVPlacement(0, G4ThreeVector(), "AREA",
83 lv_world, 0, false, 0);
84 // vis. attributes
85 va= new G4VA(G4Color(1.,1.,1.));
86 va-> SetVisibility(false);
87 lv_world-> SetVisAttributes(va);
88
89 // ==============================================================
90 // water phantom
91 // ==============================================================
92 const G4double DXY_PHANTOM= 20.*cm;
93 const G4double DZ_PHANTOM= 50.*cm;
94
95 G4Box* sld_phantom= new G4Box("phantom",
96 DXY_PHANTOM/2., DXY_PHANTOM/2., DZ_PHANTOM/2.);
97
98 G4Material* water= nistManager-> FindOrBuildMaterial("G4_WATER");
99 G4LV* lv_phantom= new G4LogicalVolume(sld_phantom,
100 water, "phantom");
101
102 va= new G4VA(G4Color(0.,1.,1.));
103 lv_phantom-> SetVisAttributes(va);
104
105 new G4PVP(0, G4ThreeVector(), lv_phantom, "phantom", lv_world, false, 0);
106
107 // --------------------------------------------------------------
108 // voxel planes
109 const G4double DXY_VXP= 20.*cm;
110 const G4double DZ_VXP= 1.*mm;
111
112 G4Box* sld_vxp= new G4Box("vxplane", DXY_VXP/2., DXY_VXP/2., DZ_VXP/2.);
113 G4LV* lv_vxp= new G4LV(sld_vxp, water, "vxplane");
114
115 va= new G4VA(G4Color(1.,0.,0.));
116 va-> SetVisibility(false);
117 lv_vxp-> SetVisAttributes(va);
118
119 for (G4int iz=0; iz<500; iz++) {
120 G4double z0= -DZ_PHANTOM/2. + (iz+0.5)*DZ_VXP;
121 new G4PVP(0, G4ThreeVector(0.,0.,z0),
122 lv_vxp, "vxplane", lv_phantom,
123 false, 1000+iz);
124 }
125
126 // --------------------------------------------------------------
127 // voxel parameterized
128
129 G4Box* sld_voxel= new G4Box("voxel",1.,1.,1.); // dummy
130 G4LV* lv_voxel= new G4LV(sld_voxel, water, "voxel");
131 lv_voxel-> SetSensitiveDetector(new VoxelSD("voxel"));
132
133 va= new G4VA(G4Color(0.,1.,1.));
134 va-> SetVisibility(false);
135 lv_voxel-> SetVisAttributes(va);
136
137 const G4int nvoxels= 100*100;
138 new G4PVParameterised("voxle", lv_voxel, lv_vxp,
139 kUndefined, nvoxels, new VoxelParam());
140
141
142 return world;
143}
144
Note: See TracBrowser for help on using the repository browser.