[1316] | 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: replicaCal.cc,v 1.8 2006/06/29 18:15:44 gunter Exp $ |
---|
[1347] | 28 | // GEANT4 tag $Name: geant4-09-04-ref-00 $ |
---|
[1316] | 29 | // |
---|
| 30 | // |
---|
| 31 | // |
---|
| 32 | // Replicated geometry performance test - ~calorimeter with end caps. Main |
---|
| 33 | // calorimeter block is replicated (divided) in r & z. |
---|
| 34 | // Toggle optimisation with 0/1 on command line. Default - optimisation ON |
---|
| 35 | |
---|
| 36 | #include "G4ios.hh" |
---|
| 37 | #include <stdlib.h> |
---|
| 38 | #include <cmath> |
---|
| 39 | |
---|
| 40 | #include "G4GeometryManager.hh" |
---|
| 41 | #include "Shoot.hh" |
---|
| 42 | #include "G4Timer.hh" |
---|
| 43 | |
---|
| 44 | #include "G4PVPlacement.hh" |
---|
| 45 | #include "G4PVReplica.hh" |
---|
| 46 | #include "G4LogicalVolume.hh" |
---|
| 47 | #include "G4Tubs.hh" |
---|
| 48 | |
---|
| 49 | const G4int numShoot = 10000; |
---|
| 50 | const G4bool optimise= true; |
---|
| 51 | const G4double x0=1.12343*cm; |
---|
| 52 | |
---|
| 53 | G4VPhysicalVolume* BuildReplicaCal(G4Material* Air) |
---|
| 54 | { |
---|
| 55 | G4double xr=x0/4; |
---|
| 56 | G4int nr=20; |
---|
| 57 | G4int nl=20; |
---|
| 58 | |
---|
| 59 | G4double r1=20*xr,r2=21*xr,z1=10*x0,z2=11*x0; |
---|
| 60 | // Container |
---|
| 61 | G4Tubs *ecalTube=new G4Tubs("ECAL",0,r2,z2,0,360*deg); |
---|
| 62 | // End cap |
---|
| 63 | G4Tubs *leakTube=new G4Tubs("LEAK",0,r2,0.5*x0,0,360*deg); |
---|
| 64 | // Wrapper |
---|
| 65 | G4Tubs *latrTube=new G4Tubs("LATR",r1,r2,z1,0,360*deg); |
---|
| 66 | // Main calorimeter block |
---|
| 67 | G4Tubs *blocTube=new G4Tubs("BLOC",0,r1,z1,0,360*deg); |
---|
| 68 | G4Tubs *blocTubeR=new G4Tubs("BLOCR",0,r1/nr,z1,0,360*deg); |
---|
| 69 | G4Tubs *blocTubeRZ=new G4Tubs("BLOCRZ",0,r1/nr,z1/nl,0,360*deg); |
---|
| 70 | |
---|
| 71 | G4double zc=0.5*(z1+z2); |
---|
| 72 | |
---|
| 73 | G4LogicalVolume *ecalLog=new G4LogicalVolume(ecalTube,Air, |
---|
| 74 | "ecalLog",0,0,0); |
---|
| 75 | G4LogicalVolume *leakLog=new G4LogicalVolume(leakTube,Air, |
---|
| 76 | "leakLog",0,0,0); |
---|
| 77 | G4LogicalVolume *latrLog=new G4LogicalVolume(latrTube,Air, |
---|
| 78 | "latrLog",0,0,0); |
---|
| 79 | G4LogicalVolume *blocLog=new G4LogicalVolume(blocTube,Air, |
---|
| 80 | "blocLog",0,0,0); |
---|
| 81 | G4LogicalVolume *blocRLog=new G4LogicalVolume(blocTubeR,Air, |
---|
| 82 | "blocRLog",0,0,0); |
---|
| 83 | G4LogicalVolume *blocRZLog=new G4LogicalVolume(blocTubeRZ,Air, |
---|
| 84 | "blocRZLog",0,0,0); |
---|
| 85 | |
---|
| 86 | |
---|
| 87 | G4PVPlacement *ecalPhys=new G4PVPlacement(0,G4ThreeVector(), |
---|
| 88 | "ecalPhys", |
---|
| 89 | ecalLog, |
---|
| 90 | 0,false,0); |
---|
| 91 | // Position end caps, wrapper and calorimeter bloc within ecal |
---|
| 92 | // G4PVPlacement *leakPhys= |
---|
| 93 | new G4PVPlacement(0,G4ThreeVector(0,0,-zc), |
---|
| 94 | "leakPhys", |
---|
| 95 | leakLog, |
---|
| 96 | ecalPhys,false,0); |
---|
| 97 | // G4PVPlacement *leakPhys2= |
---|
| 98 | new G4PVPlacement(0,G4ThreeVector(0,0,zc), |
---|
| 99 | "leakPhys", |
---|
| 100 | leakLog, |
---|
| 101 | ecalPhys,false,1); |
---|
| 102 | // G4PVPlacement *latrPhys= |
---|
| 103 | new G4PVPlacement(0,G4ThreeVector(), |
---|
| 104 | "latrPhys", |
---|
| 105 | latrLog, |
---|
| 106 | ecalPhys,false,0); |
---|
| 107 | G4PVPlacement *blocPhys=new G4PVPlacement(0,G4ThreeVector(), |
---|
| 108 | "blocPhys", |
---|
| 109 | blocLog, |
---|
| 110 | ecalPhys,false,0); |
---|
| 111 | |
---|
| 112 | // Create replicas |
---|
| 113 | G4PVReplica *blocPhysR=new G4PVReplica("blocRepR", |
---|
| 114 | blocRLog,blocPhys, |
---|
| 115 | kRho,nr,r1/nr,0); |
---|
| 116 | // G4PVReplica *blocPhysRZ= |
---|
| 117 | new G4PVReplica("blocRepRZ", |
---|
| 118 | blocRZLog,blocPhysR, |
---|
| 119 | kZAxis,nl,2*z1/nl); |
---|
| 120 | |
---|
| 121 | return ecalPhys; |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | int main() |
---|
| 125 | { |
---|
| 126 | G4ThreeVector pos(0,0,-10*x0+0.01*cm); |
---|
| 127 | G4double phi=pi*0.5,theta=15*deg; |
---|
| 128 | G4ThreeVector dir(std::cos(phi)*std::sin(theta),std::sin(phi)*std::sin(theta),std::cos(theta)); |
---|
| 129 | G4VPhysicalVolume *myTopNode; |
---|
| 130 | G4Timer timer; |
---|
| 131 | |
---|
| 132 | G4cout << "*** Replication Performance Test - P.Kent 26.09.96 ***" << G4endl << G4endl; |
---|
| 133 | |
---|
| 134 | myTopNode=BuildReplicaCal(0); // Build the geometry |
---|
| 135 | timer.Start(); |
---|
| 136 | G4GeometryManager::GetInstance()->CloseGeometry(optimise); |
---|
| 137 | timer.Stop(); |
---|
| 138 | |
---|
| 139 | if (optimise) |
---|
| 140 | { |
---|
| 141 | G4cout << "Optimisation ON" << G4endl; |
---|
| 142 | } |
---|
| 143 | else |
---|
| 144 | { |
---|
| 145 | G4cout << "Optimisation OFF" << G4endl; |
---|
| 146 | } |
---|
| 147 | G4cout << "Closing geometry took: " << timer << G4endl; |
---|
| 148 | |
---|
| 149 | G4cout << G4endl << "Shooting from " << pos << " along " << dir << G4endl; |
---|
| 150 | ShootVerbose(myTopNode,pos,dir); |
---|
| 151 | Shoot(numShoot,myTopNode,pos,dir); |
---|
| 152 | |
---|
| 153 | G4GeometryManager::GetInstance()->OpenGeometry(); |
---|
| 154 | return EXIT_SUCCESS; |
---|
| 155 | } |
---|
| 156 | |
---|