source: trunk/source/geometry/benchmarks/shooter.cc @ 1341

Last change on this file since 1341 was 1316, checked in by garnier, 14 years ago

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

File size: 8.5 KB
Line 
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: shooter.cc,v 1.7 2006/06/29 18:15:46 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
29//
30// shooter - perform test shots.
31//
32
33/*
34  gmake CXXFLAGS="-g -pg -a -lc_p " CPPVERBOSE=1 for the library
35
36  gmake CXXFLAGS="-g -pg -a -lc_p -static " CPPVERBOSE=1 G4TARGET=shooter
37  shooter
38  (line by line profiling in detail)
39  gprof -i -p -q -x -A -l `which shooter` > profile.shooter
40  (normal profiling)
41  gprof -p `which shooter` > profile.shooter
42*/
43
44#include "G4ios.hh"
45#include <stdlib.h>
46#include <string.h>
47#include <cmath>
48
49#include "G4GeometryManager.hh"
50#include "BuildBoxWorld.hh"
51#include "BuildCalorimeter.hh"
52#include "Shoot.hh"
53
54#include "G4GeometryManager.hh"
55#include "Shoot.hh"
56#include "G4Timer.hh"
57
58#include "G4PVPlacement.hh"
59#include "G4PVReplica.hh"
60#include "G4LogicalVolume.hh"
61#include "G4Tubs.hh"
62
63
64G4int numShoot ; //1000000;
65 
66
67const G4bool optimise= true;
68const G4double x0=1.12343*cm;
69
70G4VPhysicalVolume* BuildReplicaCal(G4Material* Air)
71{
72  G4double xr=x0/4;
73  G4int nr=20;
74  G4int nl=20;
75
76  G4double r1=20*xr,r2=21*xr,z1=10*x0,z2=11*x0;
77  // Container
78  G4Tubs *ecalTube=new G4Tubs("ECAL",0,r2,z2,0,360*deg);
79  // End cap
80  G4Tubs *leakTube=new G4Tubs("LEAK",0,r2,0.5*x0,0,360*deg);
81  // Wrapper
82  G4Tubs *latrTube=new G4Tubs("LATR",r1,r2,z1,0,360*deg);
83  // Main calorimeter block
84  G4Tubs *blocTube=new G4Tubs("BLOC",0,r1,z1,0,360*deg);
85  G4Tubs *blocTubeR=new G4Tubs("BLOCR",0,r1/nr,z1,0,360*deg);
86  G4Tubs *blocTubeRZ=new G4Tubs("BLOCRZ",0,r1/nr,z1/nl,0,360*deg);
87
88  G4double zc=0.5*(z1+z2);
89
90  G4LogicalVolume *ecalLog=new G4LogicalVolume(ecalTube,Air,
91                                               "ecalLog",0,0,0);
92  G4LogicalVolume *leakLog=new G4LogicalVolume(leakTube,Air,
93                                               "leakLog",0,0,0);
94  G4LogicalVolume *latrLog=new G4LogicalVolume(latrTube,Air,
95                                               "latrLog",0,0,0);
96  G4LogicalVolume *blocLog=new G4LogicalVolume(blocTube,Air,
97                                               "blocLog",0,0,0);
98  G4LogicalVolume *blocRLog=new G4LogicalVolume(blocTubeR,Air,
99                                               "blocRLog",0,0,0);
100  G4LogicalVolume *blocRZLog=new G4LogicalVolume(blocTubeRZ,Air,
101                                                 "blocRZLog",0,0,0);
102
103
104  G4PVPlacement *ecalPhys=new G4PVPlacement(0,G4ThreeVector(),
105                                            "ecalPhys",
106                                            ecalLog,
107                                            0,false,0);
108  // Position end caps, wrapper and calorimeter bloc within ecal
109  // G4PVPlacement *leakPhys=
110  new G4PVPlacement(0,G4ThreeVector(0,0,-zc),
111                    "leakPhys",
112                    leakLog,
113                    ecalPhys,false,0);
114  // G4PVPlacement *leakPhys2=
115  new G4PVPlacement(0,G4ThreeVector(0,0,zc),
116                    "leakPhys",
117                    leakLog,
118                    ecalPhys,false,1);
119  // G4PVPlacement *latrPhys=
120  new G4PVPlacement(0,G4ThreeVector(),
121                    "latrPhys",
122                    latrLog,
123                    ecalPhys,false,0);
124  G4PVPlacement *blocPhys=new G4PVPlacement(0,G4ThreeVector(),
125                                            "blocPhys",
126                                            blocLog,
127                                            ecalPhys,false,0);
128
129  // Create replicas
130  G4PVReplica *blocPhysR=new G4PVReplica("blocRepR",
131                                         blocRLog,blocPhys,
132                                         kRho,nr,r1/nr,0);
133  // G4PVReplica *blocPhysRZ=
134  new G4PVReplica("blocRepRZ",
135                  blocRZLog,blocPhysR,
136                  kZAxis,nl,2*z1/nl);
137
138  return ecalPhys;
139}
140
141
142/*
143   to change accuracy :
144        fieldMgr->GetChordFinder()->SetDeltaChord( G4double newValue);
145*/
146
147int main(int argc,char *argv[])
148{
149  G4ThreeVector origin(0,0,0),pMX(-500,0,0);
150  G4ThreeVector vx(1,0,0);
151  G4ThreeVector vy(0,1,0);
152  G4VPhysicalVolume *myTopNode=0;
153
154  G4double Field = 0.*tesla;
155
156  enum GeomType { BOX, CALOLOOP, CALOREP} GeomType;
157  G4int i;
158  G4bool useField = false;
159
160  /* Default Value */
161 
162  GeomType = BOX ;
163  numShoot = 1000000 ;
164 
165  /* Command line parsing */
166 
167  for (i=1;i<argc;i++) {
168    if ((i < (argc-1)) && (strcmp(argv[i],"-event") == 0)) {
169      sscanf(argv[i+1],"%d",&numShoot);     
170    }
171    if ((i < (argc-1)) && (strcmp(argv[i],"-geom") == 0)) {
172      if (strcmp(argv[i+1],"box") == 0) {
173        GeomType = BOX;
174      } else   
175      if (strcmp(argv[i+1],"caloloop") == 0) {
176        GeomType = CALOLOOP;
177      } else     
178      if (strcmp(argv[i+1],"calorep") == 0) {
179        GeomType = CALOREP;
180      } else {
181        G4cerr << argv[i+1] << " is not a known geometry (box,caloloop,calorep)" << G4endl ;
182        exit (0);
183       
184      }
185    }
186    if ((i < (argc-1)) && (strcmp(argv[i],"-magn") == 0)) {
187      sscanf(argv[i+1],"%lf",&Field);
188      G4cout << " Mag Field = " << Field << G4endl ;
189     
190      Field = Field * tesla ;
191      useField = true;
192    }
193  }
194 
195 
196  G4cout << "***  Navigation Performance Tester - E.Medernach 30.10.00  ***" << G4endl
197         << ">>>  Based on original benchmark test by P.Kent" << G4endl << G4endl;
198
199  G4cout << "Options (as arguments):" << G4endl
200         << "-event <number_of_events>" << G4endl
201         << "      number of events for the test. Default is 1000000" << G4endl
202         << "-geom <geometry_type>" << G4endl
203         << "      where <geometry_type> can be:" << G4endl
204         << "      box      - simple box (default)" << G4endl
205         << "      caloloop - calorimeter made by a loop of placements" << G4endl
206         << "      calorep  - calorimeter made of replicas" << G4endl
207         << "-magn <magnetic_field_value>" << G4endl
208         << "      activates magnetic field (value in tesla units). Default is OFF" << G4endl << G4endl;
209
210  // Build the geometry
211
212  G4cout << "Geometry type:"; 
213  switch (GeomType) {
214
215  case BOX:
216    G4cout << " Box only." << G4endl ;
217    myTopNode=BuildBoxWorld();
218    break;
219
220  case CALOLOOP:
221    G4cout << " Calorimeter made of placements." << G4endl ;
222    myTopNode=BuildCalorimeter();
223    break;
224
225  case CALOREP:
226    G4cout << "  Calorimeter made of replicas." << G4endl ;
227    myTopNode=BuildReplicaCal(0);
228    break;
229   
230  }
231 
232  G4GeometryManager::GetInstance()->CloseGeometry(true);
233
234  if (!useField)
235  {
236    G4cout << "--> Magnetic Field is disabled !" << G4endl ;
237   
238    G4cout << G4endl << "Shooting from " << origin << " along " << vx << G4endl;
239    ShootVerbose(myTopNode,origin,vx);
240    Shoot(numShoot,myTopNode,origin,vx);
241
242    G4cout << G4endl << "Shooting from " << origin << " along " << vy << G4endl;
243    ShootVerbose(myTopNode,origin,vy);
244    Shoot(numShoot,myTopNode,origin,vy);
245
246    G4cout << G4endl << "Shooting from " << pMX << " along " << vx << G4endl;
247    ShootVerbose(myTopNode,pMX,vx);
248    Shoot(numShoot,myTopNode,pMX,vx);
249  }
250  else
251  {
252    //    Field = 0.1 * tesla ;
253    G4double DeltaChord = 1.0e-2 * mm ;
254   
255    G4cout << "--> Magnetic Field test with " << Field/tesla << " Tesla" << G4endl ;
256
257    G4cout << G4endl << "Shooting from " << origin << " along " << vx << G4endl;
258    ShootVerbose(myTopNode,origin,vx);
259    MagneticShoot(numShoot,myTopNode,origin,vx,Field,DeltaChord);
260
261    G4cout << G4endl << "Shooting from " << origin << " along " << vy << G4endl;
262    ShootVerbose(myTopNode,origin,vy);
263    MagneticShoot(numShoot,myTopNode,origin,vy,Field,DeltaChord);
264
265    G4cout << G4endl << "Shooting from " << pMX << " along " << vx << G4endl;
266    ShootVerbose(myTopNode,pMX,vx);
267    MagneticShoot(numShoot,myTopNode,pMX,vx,Field,DeltaChord);
268  }
269
270  G4GeometryManager::GetInstance()->OpenGeometry();
271  return EXIT_SUCCESS;
272}
273
Note: See TracBrowser for help on using the repository browser.