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: benchmark.cc,v 1.5 2006/06/29 19:10:32 gunter Exp $ |
---|
28 | // GEANT4 tag $Name: $ |
---|
29 | // |
---|
30 | // |
---|
31 | // --------------------------------------------------------------------- |
---|
32 | // |
---|
33 | // Test routine for combining "events+tracks", "tracking","geometry" |
---|
34 | // and "particle+matter" |
---|
35 | // |
---|
36 | // Calorimeter geometry |
---|
37 | // |
---|
38 | // Arranged by R.Kiuchi 09. Oct. 1995 |
---|
39 | // |
---|
40 | // Original source written by Makoto Asai 5/Sep/95 |
---|
41 | // revised for New G4ParticleDefinition by H.Kurashige 21/Apr/96 |
---|
42 | // revised for New G4ParticleGun by H.Kurashige 3/May/96 |
---|
43 | // revised for interactive version by M.Asai 11/Jun/96 |
---|
44 | // revised for tag 0.5 by G.Cosmo 12/Feb/97 |
---|
45 | // revised for alpha01-tag by G.Cosmo 8/Apr/97 |
---|
46 | // |
---|
47 | |
---|
48 | #include "G4ios.hh" |
---|
49 | #include <stdlib.h> |
---|
50 | |
---|
51 | #include "G4ThreeVector.hh" |
---|
52 | |
---|
53 | #include "G4ParticleGun.hh" |
---|
54 | #include "G4Event.hh" |
---|
55 | #include "G4EventManager.hh" |
---|
56 | |
---|
57 | #include "G4GeometryManager.hh" |
---|
58 | #include "G4TransportationManager.hh" |
---|
59 | |
---|
60 | #include "G4PVPlacement.hh" |
---|
61 | #include "G4LogicalVolume.hh" |
---|
62 | #include "G4Box.hh" |
---|
63 | #include "G4Tubs.hh" |
---|
64 | |
---|
65 | #include "G4ParticleTable.hh" |
---|
66 | #include "G4Material.hh" |
---|
67 | #include "G4ProcessManager.hh" |
---|
68 | #include "G4MuDeltaRay.hh" |
---|
69 | #include "G4MuPairProduction.hh" |
---|
70 | #include "G4MuBremsstrahlung.hh" |
---|
71 | #include "G4MuEnergyLoss.hh" |
---|
72 | #include "G4Transportation.hh" |
---|
73 | #include "G4Geantino.hh" |
---|
74 | #include "G4Electron.hh" |
---|
75 | #include "G4MuonPlus.hh" |
---|
76 | #include "G4Gamma.hh" |
---|
77 | #include "G4Positron.hh" |
---|
78 | |
---|
79 | #include "G4UImanager.hh" |
---|
80 | #include "G4UIterminal.hh" |
---|
81 | |
---|
82 | G4VPhysicalVolume* BuildCalorimeter(G4Material* Air, |
---|
83 | G4Material* Lead, |
---|
84 | G4Material* Alluminium) |
---|
85 | { |
---|
86 | G4double offset=22.5*cm, xTlate, yTlate; |
---|
87 | G4int i,j,copyNo; |
---|
88 | |
---|
89 | G4Box *myWorldBox= new G4Box ("WBox",10000*cm, 10000*cm, 10000*cm); |
---|
90 | G4Box *myCalBox = new G4Box ("CBox",1500*cm, 1500*cm, 1000*cm); |
---|
91 | G4Tubs *myTargetTube = new G4Tubs ("TTube",0*cm, 22.5*cm, 1000*cm, 0.*deg, 360.*deg); |
---|
92 | |
---|
93 | G4LogicalVolume *myWorldLog=new G4LogicalVolume(myWorldBox,Air, |
---|
94 | "WLog", 0, 0, 0); |
---|
95 | G4LogicalVolume *myCalLog=new G4LogicalVolume(myCalBox,Alluminium, |
---|
96 | "CLog", 0, 0, 0); |
---|
97 | G4LogicalVolume *myTargetLog=new G4LogicalVolume(myTargetTube,Lead, |
---|
98 | "TLog", 0, 0, 0); |
---|
99 | |
---|
100 | G4PVPlacement *myWorldPhys=new G4PVPlacement(0,G4ThreeVector(), |
---|
101 | "WPhys", |
---|
102 | myWorldLog, |
---|
103 | 0,false,0); |
---|
104 | G4PVPlacement *myCalPhys=new G4PVPlacement(0,G4ThreeVector(), |
---|
105 | "CalPhys", |
---|
106 | myCalLog, |
---|
107 | myWorldPhys,false,0); |
---|
108 | |
---|
109 | G4String tName1("TPhys1"); // Allow all target physicals to share |
---|
110 | // same name (delayed copy) |
---|
111 | copyNo=0; |
---|
112 | for (j=1;j<=25;j++) |
---|
113 | { |
---|
114 | yTlate = -1000.0*cm - 40.0*cm + j*80.0*cm; |
---|
115 | |
---|
116 | for (i=1;i<=50;i++) |
---|
117 | { |
---|
118 | copyNo++; |
---|
119 | xTlate = -1000.0*cm - 20.0*cm + i*45.0*cm - offset; |
---|
120 | G4PVPlacement *myTargetPhys=new G4PVPlacement(0,G4ThreeVector(xTlate,yTlate,0*cm), |
---|
121 | tName1, |
---|
122 | myTargetLog, |
---|
123 | myCalPhys, |
---|
124 | false, |
---|
125 | copyNo); |
---|
126 | } |
---|
127 | } |
---|
128 | |
---|
129 | G4String tName2("TPhys2"); // Allow all target physicals to share |
---|
130 | // same name (delayed copy) |
---|
131 | copyNo=0; |
---|
132 | for (j=1;j<=26;j++) |
---|
133 | { |
---|
134 | yTlate = -1000.0*cm - 80.0*cm + j*80.0*cm; |
---|
135 | for (i=1;i<=50;i++) |
---|
136 | { |
---|
137 | copyNo++; |
---|
138 | xTlate = -1000.0*cm - 20.0*cm + i*45.0*cm; |
---|
139 | G4PVPlacement *myTargetPhys=new G4PVPlacement(0,G4ThreeVector(xTlate,yTlate,0*cm), |
---|
140 | tName2, |
---|
141 | myTargetLog, |
---|
142 | myCalPhys, |
---|
143 | false, |
---|
144 | copyNo); |
---|
145 | } |
---|
146 | } |
---|
147 | |
---|
148 | return myWorldPhys; |
---|
149 | } |
---|
150 | |
---|
151 | int main() |
---|
152 | { |
---|
153 | //-------- set output format------- |
---|
154 | G4cout.setf( std::ios:: scientific, std::ios :: floatfield ); |
---|
155 | |
---|
156 | //--------- Material definition --------- |
---|
157 | |
---|
158 | G4double a, iz, z, density; |
---|
159 | G4String name, symbol; |
---|
160 | G4int nel; |
---|
161 | |
---|
162 | a = 14.01*g/mole; |
---|
163 | G4Element* elN = new G4Element(name="Nitrogen", symbol="N", iz=7., a); |
---|
164 | a = 16.00*g/mole; |
---|
165 | G4Element* elO = new G4Element(name="Oxigen", symbol="O", iz=8., a); |
---|
166 | |
---|
167 | a = 26.98*g/mole; |
---|
168 | density = 2.7*g/cm3; |
---|
169 | G4Material* Al = new G4Material(name="Aluminium", z=13., a, density); |
---|
170 | a = 55.85*g/mole; |
---|
171 | density = 7.87*g/cm3; |
---|
172 | G4Material* Fe = new G4Material(name="Iron", z=26., a, density); |
---|
173 | a = 207.19*g/mole; |
---|
174 | density = 11.35*g/cm3; |
---|
175 | G4Material* Pb = new G4Material(name="Lead", z=82., a, density); |
---|
176 | density = 1.29e-03*g/cm3; |
---|
177 | G4Material* Air = new G4Material(name="Air", density, nel=2); |
---|
178 | Air->AddElement(elN, .7); |
---|
179 | Air->AddElement(elO, .3); |
---|
180 | |
---|
181 | // Geometry definitions |
---|
182 | |
---|
183 | G4VPhysicalVolume *myTopNode; |
---|
184 | |
---|
185 | G4cout << "Calorimeter volume Performance Test" << G4endl; |
---|
186 | myTopNode=BuildCalorimeter(Air,Pb,Al); // Build the geometry |
---|
187 | G4GeometryManager::GetInstance()->CloseGeometry(); |
---|
188 | |
---|
189 | G4TransportationManager::GetTransportationManager() |
---|
190 | ->GetNavigatorForTracking()->SetWorldVolume( myTopNode ); |
---|
191 | |
---|
192 | // Particle and Process definitions |
---|
193 | |
---|
194 | // Particle definitions |
---|
195 | |
---|
196 | G4ParticleDefinition* Gamma = G4Gamma::Gamma(); |
---|
197 | G4ParticleDefinition* Geantino = G4Geantino::Geantino(); |
---|
198 | G4ParticleDefinition* MuonPlus = G4MuonPlus::MuonPlus(); |
---|
199 | G4ParticleDefinition* Electron = G4Electron::Electron(); |
---|
200 | G4ParticleDefinition* Positron = G4Positron::Positron(); |
---|
201 | G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable(); |
---|
202 | |
---|
203 | // Process definitions |
---|
204 | |
---|
205 | G4ProcessManager* pmanager; |
---|
206 | G4Transportation* theTransportationProcess= new G4Transportation(); |
---|
207 | |
---|
208 | G4ParticleTable::G4PTblDicIterator *piter = theParticleTable->GetIterator(); |
---|
209 | piter -> reset(); |
---|
210 | while( (*piter)() ){ |
---|
211 | pmanager = piter->value()->GetProcessManager(); |
---|
212 | // add Transportation |
---|
213 | pmanager -> AddContinuousProcess(theTransportationProcess, 1); |
---|
214 | } |
---|
215 | |
---|
216 | /* !!!!!!!!!!!!!!!!!!! Muons temporary commented out !!!!!!!!!!!!!!!!! |
---|
217 | G4MuDeltaRay theDeltaRayProcess; |
---|
218 | G4MuPairProduction thePairProductionProcess; |
---|
219 | G4MuBremsstrahlung theBremsstrahlungProcess; |
---|
220 | |
---|
221 | G4MuEnergyLoss theEnergyLossProcess; |
---|
222 | |
---|
223 | G4ProcessManager* muonProcessManager= MuonPlus->GetProcessManager(); |
---|
224 | G4ProcessManager* geantinoProcessManager= Geantino->GetProcessManager(); |
---|
225 | G4ProcessManager* electronProcessManager= Electron->GetProcessManager(); |
---|
226 | |
---|
227 | muonProcessManager->AddDiscreteProcess(&theDeltaRayProcess); |
---|
228 | muonProcessManager->AddDiscreteProcess(&thePairProductionProcess); |
---|
229 | muonProcessManager->AddDiscreteProcess(&theBremsstrahlungProcess); |
---|
230 | |
---|
231 | muonProcessManager->AddContinuousProcess(&theEnergyLossProcess); |
---|
232 | |
---|
233 | // Set the cut and Build cross-sections table for physics processes |
---|
234 | |
---|
235 | Gamma->SetCuts(1.*cm); |
---|
236 | Positron->SetCuts(1.*cm); |
---|
237 | Electron->SetCuts(1.*cm); |
---|
238 | MuonPlus->SetCuts(1.*cm); |
---|
239 | !!!!!!!!!!!!!!!!!!! Muons temporary commented out !!!!!!!!!!!!!!!!! */ |
---|
240 | |
---|
241 | // Event manager |
---|
242 | |
---|
243 | G4EventManager * eventManager = new G4EventManager; |
---|
244 | |
---|
245 | // Event generator |
---|
246 | |
---|
247 | G4int numPrimaries =1; //1 particle per event |
---|
248 | G4ParticleGun * particleGun = new G4ParticleGun(numPrimaries); |
---|
249 | |
---|
250 | // Set navigator from transportation manager |
---|
251 | |
---|
252 | eventManager-> |
---|
253 | set_Navigator(G4TransportationManager::GetTransportationManager()-> |
---|
254 | GetNavigatorForTracking() ); |
---|
255 | |
---|
256 | // Prepare UI session |
---|
257 | |
---|
258 | G4UImanager * UI = G4UImanager::GetUIpointer(); |
---|
259 | G4UIterminal * terminal = new G4UIterminal; |
---|
260 | UI->SetSession( terminal ); |
---|
261 | |
---|
262 | // OK. Let's start benchmarks............ |
---|
263 | |
---|
264 | UI->Interact("G4> "); |
---|
265 | |
---|
266 | // End of run business |
---|
267 | |
---|
268 | G4GeometryManager::GetInstance()->OpenGeometry(); |
---|
269 | |
---|
270 | delete Air; delete Pb; delete Fe; delete Al; |
---|
271 | delete elO; delete elN; |
---|
272 | delete theTransportationProcess; |
---|
273 | delete eventManager; |
---|
274 | delete particleGun; |
---|
275 | |
---|
276 | return EXIT_SUCCESS; |
---|
277 | } |
---|