Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MyDetectorConstruction.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 // ********************************************************************
25 //
26 // $Id: MyDetectorConstruction.cc,v 1.3 2006-06-29 15:28:11 gunter Exp $
27 // $Name: not supported by cvs2svn $
28 // ====================================================================
29 // MyDetectorConstruction.cc
30 //
31 // 2005 Q
32 // ====================================================================
34 
35 #include "G4Material.hh"
36 #include "G4Box.hh"
37 #include "G4LogicalVolume.hh"
38 #include "G4PVPlacement.hh"
39 #include "G4VisAttributes.hh"
40 #include "G4SystemOfUnits.hh"
41 
42 // ====================================================================
43 //
44 // class description
45 //
46 // ====================================================================
47 
48 
51  : scoreVoxel(0)
53 {
54 }
55 
59 {
60 }
61 
65 {
66  G4Material* mate;
67  G4VisAttributes* va;
68 
69  // ==============================================================
70  // world volume
71  // ==============================================================
72  G4Box* areaSolid= new G4Box("area", 25.*cm, 25.*cm, 1.1*m);
73  G4Material* vacuum= G4Material::GetMaterial("Vacuum");
74  G4LogicalVolume* areaLV= new G4LogicalVolume(areaSolid, vacuum, "area");
75  G4PVPlacement* area= new G4PVPlacement(0, G4ThreeVector(), "area",
76  areaLV, 0, false, 0);
77  // vis. attributes
78  va= new G4VisAttributes(G4Color(1.,1.,1.));
79  va-> SetVisibility(false);
80  areaLV-> SetVisAttributes(va);
81 
82  // ==============================================================
83  // phantom
84  // ==============================================================
85  // water phantom
86  const double dxyphantom= 40.*cm;
87  const double dzphantom= 50.*cm;
88 
89  G4Box* sphantom= new G4Box("phantom",
90  dxyphantom/2., dxyphantom/2., dzphantom/2.);
91  G4Material* water= G4Material::GetMaterial("Water");
92  G4LogicalVolume* lphantom= new G4LogicalVolume(sphantom,
93  water, "phantom");
94  G4PVPlacement* phantom= new G4PVPlacement(0,
95  G4ThreeVector(0.,0., dzphantom/2.),
96  lphantom, "phantom",
97  areaLV, false, 0);
98 
99  va= new G4VisAttributes(G4Color(0.,0.1,0.8));
100  lphantom-> SetVisAttributes(va);
101 
102  // score voxels
103  const G4double dvoxel= 2.*mm;
104  const G4double dvoxel_y= 20.*mm;
105 
106  G4Box* svoxel= new G4Box("voxel", dvoxel/2., dvoxel_y/2., dvoxel/2.);
107  scoreVoxel= new G4LogicalVolume(svoxel, water, "voxel");
108  va= new G4VisAttributes(G4Color(0.,0.8,0.8));
109  va-> SetVisibility(false);
110  scoreVoxel-> SetVisAttributes(va);
111 
112  G4int ix, iz;
113  G4int index=0;
114  for (iz=0; iz<200; iz++) {
115  for (ix=-40; ix<=40; ix++) {
116  G4double x0= ix*dvoxel;
117  G4double z0= -dzphantom/2.+(iz+0.5)*dvoxel;
118  G4PVPlacement* pvoxel= new
119  G4PVPlacement(0, G4ThreeVector(x0, 0., z0),
120  scoreVoxel, "voxel", lphantom,
121  false, index);
122  index++;
123  }
124  }
125 
126  return area;
127 }
128 
129 
133 {
134  if(scoreVoxel) {
135  scoreVoxel-> SetSensitiveDetector(asd);
136  }
137 }
138