Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
examples/extended/parallel/MPI/examples/exMPI02/src/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 // ********************************************************************
25 //
26 // $Id: DetectorConstruction.cc 78126 2013-12-03 17:43:56Z gcosmo $
27 //
28 /// @file DetectorConstruction.hh
29 /// @brief Define geometry
30 
31 #include "G4Box.hh"
32 #include "G4LogicalVolume.hh"
33 #include "G4NistManager.hh"
34 #include "G4PVParameterised.hh"
35 #include "G4PVPlacement.hh"
36 #include "G4SystemOfUnits.hh"
37 #include "G4VisAttributes.hh"
38 #include "DetectorConstruction.hh"
39 #include "VoxelParam.hh"
40 #include "VoxelSD.hh"
41 
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48  : flv_voxel(NULL)
49 {
50 }
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 {
55 }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 {
60  G4NistManager* nistManager = G4NistManager::Instance();
61  G4VisAttributes* va;
62 
63  // world volume
64  const G4double DXYZ_WORLD = 200.*cm;
65  G4Box* sld_world = new G4Box("world",
66  DXYZ_WORLD/2., DXYZ_WORLD/2., DXYZ_WORLD/2.);
67 
68  G4Material* vacuum = nistManager-> FindOrBuildMaterial("G4_Galactic");
69  G4LV* lv_world = new G4LogicalVolume(sld_world, vacuum, "world");
70  G4PVP* world = new G4PVPlacement(0, G4ThreeVector(), "AREA",
71  lv_world, 0, false, 0);
72  // vis. attributes
73  va = new G4VA(G4Color(1.,1.,1.));
74  va-> SetVisibility(false);
75  lv_world-> SetVisAttributes(va);
76 
77  // water phantom
78  const G4double DXY_PHANTOM = 20.*cm;
79  const G4double DZ_PHANTOM = 50.*cm;
80 
81  G4Box* sld_phantom = new G4Box("phantom",
82  DXY_PHANTOM/2., DXY_PHANTOM/2., DZ_PHANTOM/2.);
83 
84  G4Material* water = nistManager-> FindOrBuildMaterial("G4_WATER");
85  G4LV* lv_phantom = new G4LogicalVolume(sld_phantom,
86  water, "phantom");
87 
88  va = new G4VA(G4Color(0.,1.,1.));
89  lv_phantom-> SetVisAttributes(va);
90 
91  new G4PVP(0, G4ThreeVector(), lv_phantom, "phantom", lv_world, false, 0);
92 
93  // voxel planes
94  const G4double DXY_VXP = 20.*cm;
95  const G4double DZ_VXP = 1.*mm;
96 
97  G4Box* sld_vxp = new G4Box("vxplane", DXY_VXP/2., DXY_VXP/2., DZ_VXP/2.);
98  G4LV* lv_vxp = new G4LV(sld_vxp, water, "vxplane");
99 
100  va = new G4VA(G4Color(1.,0.,0.));
101  va-> SetVisibility(false);
102  lv_vxp-> SetVisAttributes(va);
103 
104  for (G4int iz =0; iz < 500; iz++) {
105  G4double z0 = -DZ_PHANTOM/2. + (iz+0.5)*DZ_VXP;
106  new G4PVP(0, G4ThreeVector(0.,0.,z0),
107  lv_vxp, "vxplane", lv_phantom, false, 1000+iz);
108  }
109 
110  // voxel parameterized
111  G4Box* sld_voxel = new G4Box("voxel",1.,1.,1.); // dummy
112  flv_voxel = new G4LV(sld_voxel, water, "voxel");
113 
114  va = new G4VA(G4Color(0.,1.,1.));
115  va-> SetVisibility(false);
116  flv_voxel-> SetVisAttributes(va);
117 
118  const G4int nvoxels = 100*100;
119  new G4PVParameterised("voxle", flv_voxel, lv_vxp, kUndefined, nvoxels,
120  new VoxelParam());
121 
122  return world;
123 }
124 
125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
127 {
128  flv_voxel-> SetSensitiveDetector(new VoxelSD("voxel"));
129 }
CLHEP::Hep3Vector G4ThreeVector
Definition: G4Box.hh:63
Define voxel parameterization.
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
Define detector sensitivity on voxels.
G4double iz
Definition: TRTMaterials.hh:39
G4Colour G4Color
Definition: G4Color.hh:42
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
double G4double
Definition: G4Types.hh:76