source: trunk/examples/extended/parallel/MPI/exMPI01/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:16:46 kmura Exp $
27// $Name: $
28//
29// ====================================================================
30// DetectorConstruction.cc
31//
32// 2007 Q
33// ====================================================================
34#include "DetectorConstruction.hh"
35#include "Materials.hh"
36#include "G4Material.hh"
37#include "G4Tubs.hh"
38#include "G4Box.hh"
39#include "G4LogicalVolume.hh"
40#include "G4PVPlacement.hh"
41#include "G4VisAttributes.hh"
42
43// ====================================================================
44//
45// class description
46//
47// ====================================================================
48
49// constants (detector parameters)
50static const G4double DXYZ_AREA= 32.*cm;
51static const G4double DW= 10.*cm;
52
53////////////////////////////////////////////
54DetectorConstruction::DetectorConstruction()
55////////////////////////////////////////////
56{
57}
58
59/////////////////////////////////////////////
60DetectorConstruction::~DetectorConstruction()
61/////////////////////////////////////////////
62{
63}
64
65///////////////////////////////////////////////////
66G4VPhysicalVolume* DetectorConstruction::Construct()
67///////////////////////////////////////////////////
68{
69 // material definition
70 Materials* materialConstruction= new Materials;
71 materialConstruction-> Construct();
72
73 G4Material* mate;
74 G4VisAttributes* va;
75
76 // ==============================================================
77 // world volume
78 // ==============================================================
79 G4Box* areaSolid= new G4Box("AREA",
80 DXYZ_AREA/2., DXYZ_AREA/2., DXYZ_AREA/2.);
81
82 G4Material* vacuum= G4Material::GetMaterial("Vacuum");
83 G4LogicalVolume* areaLV= new G4LogicalVolume(areaSolid, vacuum, "AREA_LV");
84 G4PVPlacement* area= new G4PVPlacement(0, G4ThreeVector(), "AREA_PV",
85 areaLV, 0, false, 0);
86 // vis. attributes
87 va= new G4VisAttributes(G4Color(1.,1.,1.));
88 va-> SetVisibility(false);
89 areaLV-> SetVisAttributes(va);
90
91 // ==============================================================
92 // detectors
93 // ==============================================================
94 // voxel
95 const G4double dvoxel= 10.*mm;
96 const G4double dl= 10.*cm;
97
98 G4Box* svoxel= new G4Box("voxel", dvoxel, dl, dvoxel);
99 mate= G4Material::GetMaterial("Vacuum");
100 G4LogicalVolume* lvoxel= new G4LogicalVolume(svoxel, mate, "voxel");
101 va= new G4VisAttributes(G4Color(0.,0.8,0.8));
102 va-> SetVisibility(false);
103 lvoxel-> SetVisAttributes(va);
104
105 G4int ix, iz;
106 G4int index=0;
107 for (iz=0; iz<5; iz++) {
108 for (ix=-7; ix<=7; ix++) {
109 G4double x0= (2.*ix)*cm;
110 G4double z0= (-13.+2.*iz)*cm;
111 new G4PVPlacement(0, G4ThreeVector(x0, 0., z0),
112 lvoxel, "voxel", areaLV, false, index);
113 index++;
114 }
115 }
116
117 // tube
118 //G4Tubs* stube= new G4Tubs("tube", 15./2.*mm, 19./2.*mm, dl,
119 G4Tubs* stube= new G4Tubs("tube", 0.*mm, 19./2.*mm, dl,
120 0., 360.*deg);
121 mate= G4Material::GetMaterial("Al");
122 G4LogicalVolume* ltube= new G4LogicalVolume(stube, mate, "tube");
123 va= new G4VisAttributes(G4Color(0.,0.8,0.8));
124 ltube-> SetVisAttributes(va);
125
126 G4RotationMatrix* rmtube= new G4RotationMatrix;
127 rmtube-> rotateX(-90.*deg);
128 new G4PVPlacement(rmtube, G4ThreeVector(),
129 ltube, "tube", lvoxel, false, 0);
130
131 // cal
132 const G4double dxycal= 25.*mm;
133 const G4double dzcal= 3.*cm;
134
135 G4Box* scal= new G4Box("cal", dxycal, dxycal, dzcal);
136 mate= G4Material::GetMaterial("CsI");
137 G4LogicalVolume* lcal= new G4LogicalVolume(scal, mate, "cal");
138 va= new G4VisAttributes(G4Color(0.5,0.5,0.));
139 lcal-> SetVisAttributes(va);
140
141 index= 0;
142 for (ix=-2; ix<=2; ix++) {
143 G4double x0= (5.*ix)*cm;
144 new G4PVPlacement(0, G4ThreeVector(x0, 0., 2.*cm),
145 lcal, "cal", areaLV, false, index);
146 index++;
147 }
148
149 return area;
150}
151
Note: See TracBrowser for help on using the repository browser.