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: BuildParametrised.cc,v 1.7 2006/06/29 21:34:18 gunter Exp $ |
---|
28 | // GEANT4 tag $Name: $ |
---|
29 | // |
---|
30 | // |
---|
31 | // Based on test code from Hans-Peter Wellisch |
---|
32 | |
---|
33 | #include "BuildParametrised.hh" |
---|
34 | |
---|
35 | #include "G4PVPlacement.hh" |
---|
36 | #include "G4LogicalVolume.hh" |
---|
37 | #include "G4Box.hh" |
---|
38 | #include "G4Tubs.hh" |
---|
39 | #include "G4Material.hh" |
---|
40 | #include "G4VisAttributes.hh" |
---|
41 | |
---|
42 | #include "G4PVParameterised.hh" |
---|
43 | #include "ParametrisedBox.hh" |
---|
44 | |
---|
45 | G4VPhysicalVolume* BuildParametrised () |
---|
46 | { |
---|
47 | G4Material* theAir=new G4Material("N2-air", 14.0, 28.0 * g / mole, |
---|
48 | 0.0001 *g/cm3); |
---|
49 | G4Material * theCopper = |
---|
50 | new G4Material("Quaterhard-Cu",25.0, 63.0 * g / mole, |
---|
51 | 6.8*g/cm3); |
---|
52 | |
---|
53 | G4RotationMatrix* theNull = new G4RotationMatrix (); |
---|
54 | G4ThreeVector* theCenter = new G4ThreeVector(0,0,0); |
---|
55 | |
---|
56 | // The Pit. |
---|
57 | G4Box* aBox = new G4Box("aBox",10*m, 10*m, 10*m); |
---|
58 | G4LogicalVolume* theLogicalPit = |
---|
59 | new G4LogicalVolume(aBox, theAir, |
---|
60 | "thePit", 0, 0, 0); |
---|
61 | theLogicalPit->SetVisAttributes (G4VisAttributes::Invisible); |
---|
62 | G4PVPlacement* thePit = |
---|
63 | new G4PVPlacement( theNull, |
---|
64 | *theCenter, |
---|
65 | "thePit", |
---|
66 | theLogicalPit, |
---|
67 | 0, 0, 0); |
---|
68 | |
---|
69 | // The Mother of Parametrised. |
---|
70 | G4VSolid * anotherBox = new G4Box("aBox",5*m, 5*m, 5*m); |
---|
71 | G4LogicalVolume* theLogicalMother1 = |
---|
72 | new G4LogicalVolume(anotherBox, theAir, |
---|
73 | "aTest1", 0, 0, |
---|
74 | 0); |
---|
75 | G4PVPlacement* theMother1 = |
---|
76 | new G4PVPlacement( 0, G4ThreeVector (-4 * m, 0 , 0), |
---|
77 | "theMother1", |
---|
78 | theLogicalMother1, |
---|
79 | thePit, 0, 0); |
---|
80 | |
---|
81 | // Parametrized volume. |
---|
82 | G4Box * theBox = new G4Box("aBox",1,1,1); |
---|
83 | G4LogicalVolume* theLogicalBox1 = |
---|
84 | new G4LogicalVolume(theBox, theCopper, |
---|
85 | "aTest1", 0, 0, |
---|
86 | 0); |
---|
87 | G4VisAttributes * logicalPAttributes1; |
---|
88 | logicalPAttributes1 = new G4VisAttributes(G4Colour(1.,0.,0.)); |
---|
89 | theLogicalBox1->SetVisAttributes(logicalPAttributes1); |
---|
90 | ParametrisedBox* thePar1 = new ParametrisedBox(theCopper,theAir); |
---|
91 | new G4PVParameterised("theParametrizedtest1", |
---|
92 | theLogicalBox1, |
---|
93 | theMother1, |
---|
94 | kYAxis, |
---|
95 | 2, |
---|
96 | thePar1); |
---|
97 | // A second parameterised volume for test purposes... |
---|
98 | G4LogicalVolume* theLogicalMother2 = |
---|
99 | new G4LogicalVolume(anotherBox, theAir, |
---|
100 | "aTest2", 0, 0, |
---|
101 | 0); |
---|
102 | G4PVPlacement* theMother2 = |
---|
103 | new G4PVPlacement( 0, G4ThreeVector (0, -4 * m, 0), |
---|
104 | "theMother2", |
---|
105 | theLogicalMother2, |
---|
106 | thePit, 0, 0); |
---|
107 | G4LogicalVolume* theLogicalBox2 = |
---|
108 | new G4LogicalVolume(theBox, theCopper, |
---|
109 | "aTest2", 0, 0, |
---|
110 | 0); |
---|
111 | G4VisAttributes * logicalPAttributes2; |
---|
112 | logicalPAttributes2 = new G4VisAttributes(G4Colour(0.,1.,0.)); |
---|
113 | theLogicalBox2->SetVisAttributes(logicalPAttributes2); |
---|
114 | ParametrisedBox* thePar2 = new ParametrisedBox(theAir,theCopper); |
---|
115 | new G4PVParameterised("theParametrizedtest2", |
---|
116 | theLogicalBox2, |
---|
117 | theMother2, |
---|
118 | kYAxis, |
---|
119 | 5, |
---|
120 | thePar2); |
---|
121 | |
---|
122 | // The Mother of Replica. |
---|
123 | G4VSolid * box3 = new G4Box("aBox", 1 * m, 2 * m, 3 * m); |
---|
124 | G4LogicalVolume* theLogicalRMother = |
---|
125 | new G4LogicalVolume(box3, theAir, |
---|
126 | "aTest", 0, 0, |
---|
127 | 0); |
---|
128 | G4PVPlacement* theRMother = |
---|
129 | new G4PVPlacement( 0, G4ThreeVector (4 * m, 0, 0), |
---|
130 | "theRMother", |
---|
131 | theLogicalRMother, |
---|
132 | thePit, 0, 0); |
---|
133 | |
---|
134 | // Replicated volume. |
---|
135 | G4VSolid * RBox = new G4Box("aBox", 0.2 * m, 2 * m, 3 * m); |
---|
136 | G4LogicalVolume* theLogicalRBox = |
---|
137 | new G4LogicalVolume(RBox, theCopper, |
---|
138 | "aTest", 0, 0, |
---|
139 | 0); |
---|
140 | G4VisAttributes * logicalRAttributes; |
---|
141 | logicalRAttributes = new G4VisAttributes(G4Colour(0.,1.,0.)); |
---|
142 | theLogicalRBox->SetVisAttributes(logicalRAttributes); |
---|
143 | new G4PVReplica("theReplicatest", |
---|
144 | theLogicalRBox, |
---|
145 | theRMother, |
---|
146 | kXAxis, |
---|
147 | 5, 0.4 * m, 0); |
---|
148 | |
---|
149 | // The Mother of Tubs Replica. |
---|
150 | G4VSolid * tubs = new G4Tubs ("aTubsBox", 0.5 * m, 1 * m, 2 * m, |
---|
151 | 90. * deg, 180. * deg); |
---|
152 | G4LogicalVolume* theLogicalTMother = |
---|
153 | new G4LogicalVolume(tubs, theAir, |
---|
154 | "aTest", 0, 0, |
---|
155 | 0); |
---|
156 | G4PVPlacement* theTMother = |
---|
157 | new G4PVPlacement( 0, G4ThreeVector (4 * m, 4 * m, 0), |
---|
158 | "theTMother", |
---|
159 | theLogicalTMother, |
---|
160 | thePit, 0, 0); |
---|
161 | |
---|
162 | // Replicated volume. |
---|
163 | G4VSolid * tubsPart = new G4Tubs ("aTubsPart", 0.5 * m, 1 * m, 2 * m, |
---|
164 | 0., 36. * deg); |
---|
165 | G4LogicalVolume* theLogicalTubsPart = |
---|
166 | new G4LogicalVolume(tubsPart, theCopper, |
---|
167 | "aTest", 0, 0, |
---|
168 | 0); |
---|
169 | G4VisAttributes * logicalTAttributes; |
---|
170 | logicalTAttributes = new G4VisAttributes(G4Colour(0.,0.,1.)); |
---|
171 | theLogicalTubsPart->SetVisAttributes(logicalTAttributes); |
---|
172 | new G4PVReplica("theTReplicatest", |
---|
173 | theLogicalTubsPart, |
---|
174 | theTMother, |
---|
175 | kPhi, |
---|
176 | 5, 36. * deg, 90. * deg); |
---|
177 | |
---|
178 | /*************** Bloggs's box to workaround bug in G4SmartVoxelHeader. |
---|
179 | |
---|
180 | G4Box * thebloggsBox = new G4Box("aBox",5*m, 4*m, 2*m); |
---|
181 | G4LogicalVolume* theLogicalbloggs = |
---|
182 | new G4LogicalVolume(thebloggsBox, theCopper, |
---|
183 | "aTest", 0, 0, |
---|
184 | 0); |
---|
185 | G4VisAttributes * bloggsAttributes = |
---|
186 | new G4VisAttributes(G4Colour(0.,1.,0.)); |
---|
187 | theLogicalbloggs->SetVisAttributes(bloggsAttributes); |
---|
188 | G4PVPlacement* bloggs = |
---|
189 | new G4PVPlacement( theNull, |
---|
190 | G4ThreeVector (10*m, -30*m, -40*m), |
---|
191 | "bloggs", |
---|
192 | theLogicalbloggs, |
---|
193 | thePitPosition, |
---|
194 | 0, 0); |
---|
195 | ***************/ |
---|
196 | |
---|
197 | return thePit; |
---|
198 | } |
---|