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 | #include "TstDrawVox01DetectorConstruction.hh" |
---|
28 | |
---|
29 | #include "TstDrawVox01DetectorMessenger.hh" |
---|
30 | |
---|
31 | #include "G4Material.hh" |
---|
32 | #include "G4MaterialTable.hh" |
---|
33 | #include "G4Element.hh" |
---|
34 | #include "G4ElementTable.hh" |
---|
35 | #include "G4Box.hh" |
---|
36 | #include "G4Tubs.hh" |
---|
37 | #include "G4LogicalVolume.hh" |
---|
38 | #include "G4ThreeVector.hh" |
---|
39 | #include "G4PVPlacement.hh" |
---|
40 | #include "G4SDManager.hh" |
---|
41 | #include "G4VisAttributes.hh" |
---|
42 | #include "G4Colour.hh" |
---|
43 | #include "G4TransportationManager.hh" |
---|
44 | #include "G4GeometryManager.hh" |
---|
45 | #include "G4StateManager.hh" |
---|
46 | #include "G4UImanager.hh" |
---|
47 | #include "G4ios.hh" |
---|
48 | #include "G4TransportationManager.hh" |
---|
49 | |
---|
50 | |
---|
51 | TstDrawVox01DetectorConstruction::TstDrawVox01DetectorConstruction() |
---|
52 | :simpleBoxLog(0),simpleBoxDetector(0),honeycombDetector(0), |
---|
53 | Air(0),Al(0),Pb(0),selectedMaterial(0),detectorChoice(0) |
---|
54 | { |
---|
55 | detectorMessenger = new TstDrawVox01DetectorMessenger(this); |
---|
56 | materialChoice = "Pb"; |
---|
57 | } |
---|
58 | |
---|
59 | TstDrawVox01DetectorConstruction::~TstDrawVox01DetectorConstruction() |
---|
60 | { |
---|
61 | delete detectorMessenger; |
---|
62 | } |
---|
63 | |
---|
64 | G4VPhysicalVolume* TstDrawVox01DetectorConstruction::Construct() |
---|
65 | { |
---|
66 | if((!simpleBoxDetector)&&(!honeycombDetector)) |
---|
67 | { ConstructDetectors(); } |
---|
68 | |
---|
69 | G4VPhysicalVolume* worldVol = 0; |
---|
70 | switch(detectorChoice) |
---|
71 | { |
---|
72 | case 1: |
---|
73 | worldVol = honeycombDetector; |
---|
74 | break; |
---|
75 | default: |
---|
76 | worldVol = simpleBoxDetector; |
---|
77 | } |
---|
78 | return worldVol; |
---|
79 | } |
---|
80 | |
---|
81 | void TstDrawVox01DetectorConstruction::SwitchDetector() |
---|
82 | { |
---|
83 | if((!simpleBoxDetector)&&(!honeycombDetector)) |
---|
84 | ConstructDetectors(); |
---|
85 | |
---|
86 | switch(detectorChoice) |
---|
87 | { |
---|
88 | case 1: |
---|
89 | G4TransportationManager::GetTransportationManager()-> |
---|
90 | GetNavigatorForTracking()->SetWorldVolume(honeycombDetector); |
---|
91 | break; |
---|
92 | default: |
---|
93 | G4TransportationManager::GetTransportationManager()-> |
---|
94 | GetNavigatorForTracking()->SetWorldVolume(simpleBoxDetector); |
---|
95 | } |
---|
96 | } |
---|
97 | |
---|
98 | void TstDrawVox01DetectorConstruction::SelectDetector(G4String val) |
---|
99 | { |
---|
100 | if(val=="Honeycomb") |
---|
101 | { detectorChoice = 1; } |
---|
102 | else |
---|
103 | { detectorChoice = 0; } |
---|
104 | G4cout << "Now Detector is " << val << G4endl; |
---|
105 | } |
---|
106 | |
---|
107 | void TstDrawVox01DetectorConstruction::SelectMaterial(G4String val) |
---|
108 | { |
---|
109 | materialChoice = val; |
---|
110 | SelectMaterialPointer(); |
---|
111 | G4cout << "SimpleBox is now made of " << materialChoice << G4endl; |
---|
112 | } |
---|
113 | |
---|
114 | void TstDrawVox01DetectorConstruction::SelectMaterialPointer() |
---|
115 | { |
---|
116 | //--------- Material definition --------- |
---|
117 | |
---|
118 | G4double a, iz, z, density; |
---|
119 | G4String name, symbol; |
---|
120 | G4int nel; |
---|
121 | |
---|
122 | if(!Air) |
---|
123 | { |
---|
124 | a = 14.01*g/mole; |
---|
125 | G4Element* elN = new G4Element(name="Nitrogen", symbol="N", iz=7., a); |
---|
126 | a = 16.00*g/mole; |
---|
127 | G4Element* elO = new G4Element(name="Oxigen", symbol="O", iz=8., a); |
---|
128 | density = 1.29e-03*g/cm3; |
---|
129 | Air = new G4Material(name="Air", density, nel=2); |
---|
130 | Air->AddElement(elN, .7); |
---|
131 | Air->AddElement(elO, .3); |
---|
132 | } |
---|
133 | |
---|
134 | if(!Al) |
---|
135 | { |
---|
136 | a = 26.98*g/mole; |
---|
137 | density = 2.7*g/cm3; |
---|
138 | Al = new G4Material(name="Aluminium", z=13., a, density); |
---|
139 | } |
---|
140 | |
---|
141 | if(!Pb) |
---|
142 | { |
---|
143 | a = 207.19*g/mole; |
---|
144 | density = 11.35*g/cm3; |
---|
145 | Pb = new G4Material(name="Lead", z=82., a, density); |
---|
146 | } |
---|
147 | |
---|
148 | if(materialChoice=="Air") |
---|
149 | { selectedMaterial = Air; } |
---|
150 | else if(materialChoice=="Al") |
---|
151 | { selectedMaterial = Al; } |
---|
152 | else |
---|
153 | { selectedMaterial = Pb; } |
---|
154 | |
---|
155 | if(simpleBoxLog) |
---|
156 | { simpleBoxLog->SetMaterial(selectedMaterial); } |
---|
157 | } |
---|
158 | |
---|
159 | void TstDrawVox01DetectorConstruction::ConstructDetectors() |
---|
160 | { |
---|
161 | SelectMaterialPointer(); |
---|
162 | |
---|
163 | //--------- G4VSolid, G4LogicalVolume, G4VPhysicalVolume --------- |
---|
164 | |
---|
165 | //--------- simpleBoxDetector ------------------------------------- |
---|
166 | |
---|
167 | G4Box * mySimpleBox = new G4Box("SBox",2000*cm, 2000*cm, 2000*cm); |
---|
168 | simpleBoxLog = new G4LogicalVolume( mySimpleBox, |
---|
169 | selectedMaterial,"SLog",0,0,0); |
---|
170 | simpleBoxDetector = new G4PVPlacement(0,G4ThreeVector(), |
---|
171 | "SPhys",simpleBoxLog,0,false,0); |
---|
172 | |
---|
173 | //--------- honeycombDetector ------------------------------------- |
---|
174 | |
---|
175 | G4double offset=22.5*cm, xTlate, yTlate; |
---|
176 | G4int i,j,copyNo; |
---|
177 | |
---|
178 | G4Box *myWorldBox= new G4Box("WBox",2000*cm, 2000*cm, 2000*cm); |
---|
179 | G4Box *myCalBox = new G4Box("CBox",1500*cm, 1500*cm, 1000*cm); |
---|
180 | G4Tubs *myTargetTube |
---|
181 | = new G4Tubs("TTube",0*cm, 22.5*cm, 1000*cm, 0.*deg, 360.*deg); |
---|
182 | |
---|
183 | G4LogicalVolume *myWorldLog=new G4LogicalVolume(myWorldBox,Air, |
---|
184 | "WLog", 0, 0, 0); |
---|
185 | G4LogicalVolume *myCalLog=new G4LogicalVolume(myCalBox,Al, |
---|
186 | "CLog", 0, 0, 0); |
---|
187 | G4LogicalVolume *myTargetLog=new G4LogicalVolume(myTargetTube,Pb, |
---|
188 | "TLog", 0, 0, 0); |
---|
189 | |
---|
190 | honeycombDetector = new G4PVPlacement(0,G4ThreeVector(), |
---|
191 | "WPhys", |
---|
192 | myWorldLog, |
---|
193 | 0,false,0); |
---|
194 | G4PVPlacement *myCalPhys=new G4PVPlacement(0,G4ThreeVector(), |
---|
195 | "CalPhys", |
---|
196 | myCalLog, |
---|
197 | honeycombDetector, |
---|
198 | false,0); |
---|
199 | |
---|
200 | G4String tName1("TPhys1"); // Allow all target physicals to share |
---|
201 | // same name (delayed copy) |
---|
202 | copyNo=0; |
---|
203 | for (j=1;j<=3;j++) |
---|
204 | { |
---|
205 | yTlate = -1000.0*cm - 40.0*cm + j*320.0*cm; |
---|
206 | for (i=1;i<= 4;i++) |
---|
207 | { |
---|
208 | xTlate = -1000.0*cm - 20.0*cm + i*160.0*cm - offset; |
---|
209 | // G4PVPlacement *myTargetPhys= |
---|
210 | new G4PVPlacement(0,G4ThreeVector(xTlate,yTlate,0*cm), |
---|
211 | tName1,myTargetLog,myCalPhys,false,copyNo++); |
---|
212 | } |
---|
213 | } |
---|
214 | for (j=1;j<=3;j++) |
---|
215 | { |
---|
216 | yTlate = -1000.0*cm - 80.0*cm + j*320.0*cm; |
---|
217 | for (i=1;i<= 4;i++) |
---|
218 | { |
---|
219 | xTlate = -1000.0*cm - 20.0*cm + i*160.0*cm; |
---|
220 | // G4PVPlacement *myTargetPhys= |
---|
221 | new G4PVPlacement(0,G4ThreeVector(xTlate,yTlate,0*cm), |
---|
222 | tName1,myTargetLog,myCalPhys,false,copyNo++); |
---|
223 | } |
---|
224 | } |
---|
225 | |
---|
226 | //--------- Visualization attributes ------------------------------- |
---|
227 | |
---|
228 | G4VisAttributes * simpleBoxVisAtt |
---|
229 | = new G4VisAttributes(G4Colour(.0,0.7,.0)); |
---|
230 | simpleBoxVisAtt->SetVisibility(true); |
---|
231 | simpleBoxLog->SetVisAttributes(simpleBoxVisAtt); |
---|
232 | |
---|
233 | G4VisAttributes * experimentalHallVisAtt |
---|
234 | = new G4VisAttributes(G4Colour(0.3,0.,.0)); |
---|
235 | experimentalHallVisAtt->SetVisibility(true); |
---|
236 | myWorldLog->SetVisAttributes(experimentalHallVisAtt); |
---|
237 | |
---|
238 | G4VisAttributes * calorimeterBoxVisAtt |
---|
239 | = new G4VisAttributes(G4Colour(0.0,0.0,1.0)); |
---|
240 | calorimeterBoxVisAtt->SetForceWireframe(true); |
---|
241 | calorimeterBoxVisAtt->SetVisibility(true); |
---|
242 | myCalLog->SetVisAttributes(calorimeterBoxVisAtt); |
---|
243 | |
---|
244 | G4VisAttributes * calorimeterTubeVisAtt |
---|
245 | = new G4VisAttributes(G4Colour(0.0,0.5,0.5)); |
---|
246 | calorimeterTubeVisAtt->SetForceWireframe(true); |
---|
247 | calorimeterTubeVisAtt->SetVisibility(true); |
---|
248 | myTargetLog->SetVisAttributes(calorimeterTubeVisAtt); |
---|
249 | |
---|
250 | //------------------------------------------------------------------ |
---|
251 | |
---|
252 | } |
---|
253 | |
---|