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 | // |
---|
27 | // $Id: Test2GeometryConstruction.cc,v 1.1 2010/11/03 08:48:57 taso Exp $ |
---|
28 | // GEANT4 tag $Name: $ |
---|
29 | // |
---|
30 | // |
---|
31 | |
---|
32 | #include "Test2GeometryConstruction.hh" |
---|
33 | |
---|
34 | #include "G4Material.hh" |
---|
35 | #include "G4Box.hh" |
---|
36 | #include "G4LogicalVolume.hh" |
---|
37 | #include "G4PVPlacement.hh" |
---|
38 | #include "G4PVReplica.hh" |
---|
39 | #include "G4PVDivision.hh" |
---|
40 | #include "G4VisAttributes.hh" |
---|
41 | #include "G4Colour.hh" |
---|
42 | #include "G4ios.hh" |
---|
43 | |
---|
44 | Test2GeometryConstruction::Test2GeometryConstruction(G4double boxsize[3], |
---|
45 | G4Material* material, |
---|
46 | G4int segment[3]) |
---|
47 | :fMaterial(material) |
---|
48 | { |
---|
49 | phantomSize[0]=boxsize[0]; |
---|
50 | phantomSize[1]=boxsize[1]; |
---|
51 | phantomSize[2]=boxsize[2]; |
---|
52 | |
---|
53 | nSegment[0]=segment[0]; |
---|
54 | nSegment[1]=segment[1]; |
---|
55 | nSegment[2]=segment[2]; |
---|
56 | } |
---|
57 | |
---|
58 | Test2GeometryConstruction::~Test2GeometryConstruction() |
---|
59 | {;} |
---|
60 | |
---|
61 | G4VPhysicalVolume* |
---|
62 | Test2GeometryConstruction::ConstructGeometry(G4VPhysicalVolume* worldPhys) |
---|
63 | { |
---|
64 | G4LogicalVolume* worldLogical = worldPhys->GetLogicalVolume(); |
---|
65 | |
---|
66 | // phantom box |
---|
67 | G4VSolid* phantomSolid = new G4Box("PhantomBox", phantomSize[0], phantomSize[1], phantomSize[2]); |
---|
68 | G4LogicalVolume* phantomLogical = new G4LogicalVolume(phantomSolid, fMaterial, "Phantom"); |
---|
69 | G4cout << "logical" <<G4endl; |
---|
70 | new G4PVPlacement(0,G4ThreeVector(), phantomLogical, "Phantom", |
---|
71 | worldLogical, false, 0); |
---|
72 | |
---|
73 | G4cout << phantomSize[0]/mm <<","<<phantomSize[1]/mm<<"," <<phantomSize[2]/mm <<G4endl; |
---|
74 | G4cout << nSegment[0]<<","<<nSegment[1] <<","<<nSegment[2] <<G4endl; |
---|
75 | |
---|
76 | G4String layerName[3] = {"layerX", "layerY", "layerZ"}; |
---|
77 | G4VSolid * layerSolid[3]; |
---|
78 | |
---|
79 | |
---|
80 | // replication along X |
---|
81 | layerSolid[0] = new G4Box(layerName[0], |
---|
82 | phantomSize[0]/nSegment[0], |
---|
83 | phantomSize[1], |
---|
84 | phantomSize[2]); |
---|
85 | fLayerLogical[0] = new G4LogicalVolume(layerSolid[0], fMaterial, layerName[0]); |
---|
86 | new G4PVReplica(layerName[0], fLayerLogical[0], phantomLogical, kXAxis, |
---|
87 | nSegment[0], phantomSize[0]/nSegment[0]*2.); |
---|
88 | |
---|
89 | // replication along Y |
---|
90 | layerSolid[1] = new G4Box(layerName[1], |
---|
91 | phantomSize[0]/nSegment[0], |
---|
92 | phantomSize[1]/nSegment[1], |
---|
93 | phantomSize[2]); |
---|
94 | fLayerLogical[1] = new G4LogicalVolume(layerSolid[1], fMaterial, layerName[1]); |
---|
95 | new G4PVReplica(layerName[1], fLayerLogical[1], fLayerLogical[0], kYAxis, |
---|
96 | nSegment[1], phantomSize[1]/nSegment[1]*2.); |
---|
97 | |
---|
98 | // replication along Z |
---|
99 | layerSolid[2] = new G4Box(layerName[2], |
---|
100 | phantomSize[0]/nSegment[0], |
---|
101 | phantomSize[1]/nSegment[1], |
---|
102 | phantomSize[2]/nSegment[2]); |
---|
103 | fLayerLogical[2] = new G4LogicalVolume(layerSolid[2], fMaterial, layerName[2]); |
---|
104 | fPhantomPhys = new G4PVReplica(layerName[2], fLayerLogical[2], fLayerLogical[1], kZAxis, |
---|
105 | nSegment[2], phantomSize[2]/nSegment[2]*2.); |
---|
106 | //fPhantomPhys = new G4PVDivision(layerName[2], fLayerLogical[2], fLayerLogical[1], kZAxis, |
---|
107 | // nSegment[2], 0.); |
---|
108 | |
---|
109 | // |
---|
110 | // Visualization attributes |
---|
111 | // |
---|
112 | // worldLogical->SetVisAttributes(G4VisAttributes::Invisible); |
---|
113 | G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0)); |
---|
114 | simpleBoxVisAtt->SetVisibility(true); |
---|
115 | phantomLogical->SetVisAttributes(simpleBoxVisAtt); |
---|
116 | |
---|
117 | G4VisAttributes * invisatt = new G4VisAttributes(G4Colour(.0,.0,.0)); |
---|
118 | invisatt->SetVisibility(false); |
---|
119 | fLayerLogical[0]->SetVisAttributes(invisatt); |
---|
120 | fLayerLogical[1]->SetVisAttributes(invisatt); |
---|
121 | G4VisAttributes * visatt = new G4VisAttributes(G4Colour(.8,.8,.8)); |
---|
122 | visatt->SetVisibility(true); |
---|
123 | fLayerLogical[2]->SetVisAttributes(visatt); |
---|
124 | |
---|
125 | return worldPhys; |
---|
126 | |
---|
127 | } |
---|
128 | |
---|
129 | |
---|