| [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: testG4SmartVoxels.cc,v 1.5 2006/06/29 18:58:52 gunter Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
|
|---|
| 29 | //
|
|---|
| 30 |
|
|---|
| 31 | // testG4SmartVoxels
|
|---|
| 32 | // Ensure asserts are compiled in
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 | #include <assert.h>
|
|---|
| 36 |
|
|---|
| 37 | #include "globals.hh"
|
|---|
| 38 | #include "voxeldefs.hh"
|
|---|
| 39 |
|
|---|
| 40 | #include "G4LogicalVolume.hh"
|
|---|
| 41 | #include "G4PVPlacement.hh"
|
|---|
| 42 | #include "G4PVReplica.hh"
|
|---|
| 43 |
|
|---|
| 44 | #include "G4Box.hh"
|
|---|
| 45 |
|
|---|
| 46 | #include "G4GeometryManager.hh"
|
|---|
| 47 | #include "G4SolidStore.hh"
|
|---|
| 48 |
|
|---|
| 49 | #include "G4SmartVoxelNode.hh"
|
|---|
| 50 | #include "G4SmartVoxelHeader.hh"
|
|---|
| 51 |
|
|---|
| 52 | #include "G4RotationMatrix.hh"
|
|---|
| 53 | #include "G4ThreeVector.hh"
|
|---|
| 54 |
|
|---|
| 55 | G4bool testG4SmartVoxelNodes()
|
|---|
| 56 | {
|
|---|
| 57 | G4SmartVoxelNode tNode(1);
|
|---|
| 58 | assert(tNode.GetNoContained()==0);
|
|---|
| 59 | assert(tNode.GetMinEquivalentSliceNo()==1);
|
|---|
| 60 | assert(tNode.GetMaxEquivalentSliceNo()==1);
|
|---|
| 61 | tNode.SetMinEquivalentSliceNo(0);
|
|---|
| 62 | tNode.SetMaxEquivalentSliceNo(2);
|
|---|
| 63 | assert(tNode.GetMinEquivalentSliceNo()==0);
|
|---|
| 64 | assert(tNode.GetMaxEquivalentSliceNo()==2);
|
|---|
| 65 | return true;
|
|---|
| 66 |
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | // Test of geometry close and hence voxel Build
|
|---|
| 70 | // 2 small cubes are positioned inside a larger cuboid
|
|---|
| 71 | //
|
|---|
| 72 | // [Navigation links [logi/phys volumes] checked by testG4Volumes]
|
|---|
| 73 | G4bool testG4SmartVoxels()
|
|---|
| 74 | {
|
|---|
| 75 |
|
|---|
| 76 | G4Box myBigBox("cuboid",25,25,20);
|
|---|
| 77 | G4Box myBox("cube",10,10,10);
|
|---|
| 78 | G4Box mySlab("slab",10,25,10);
|
|---|
| 79 |
|
|---|
| 80 | G4LogicalVolume myDetectorLog(&myBigBox,0,
|
|---|
| 81 | "World",0,0,0);
|
|---|
| 82 | // Logical with no material,field,
|
|---|
| 83 | // sensitive detector or user limits
|
|---|
| 84 |
|
|---|
| 85 | G4PVPlacement myDetectorPhys(0,G4ThreeVector(0,0,0),
|
|---|
| 86 | "World",&myDetectorLog,
|
|---|
| 87 | 0,false,0);
|
|---|
| 88 | // Note: no mother pointer set
|
|---|
| 89 |
|
|---|
| 90 | G4LogicalVolume myDaughter1Log(&myBox,0,"Crystal Box",0,0,0);
|
|---|
| 91 | G4LogicalVolume myDaughter2Log(&mySlab,0,"Crystal Slab",0,0,0);
|
|---|
| 92 | G4PVPlacement offMXYPhys(0,G4ThreeVector(-15,15,-10),
|
|---|
| 93 | "Target 1",&myDaughter1Log,
|
|---|
| 94 | &myDetectorPhys,false,0);
|
|---|
| 95 | G4PVPlacement offMXMYPhys(0,G4ThreeVector(-15,-15,-10),
|
|---|
| 96 | "Target 2",&myDaughter1Log,
|
|---|
| 97 | &myDetectorPhys,false,0);
|
|---|
| 98 |
|
|---|
| 99 | G4PVPlacement offYPhys(0,G4ThreeVector(15,0,-10),
|
|---|
| 100 | "Target 3",&myDaughter2Log,
|
|---|
| 101 | &myDetectorPhys,false,0);
|
|---|
| 102 |
|
|---|
| 103 | G4PVPlacement offYZPhys(0,G4ThreeVector(0,15,10),
|
|---|
| 104 | "Target 4",&myDaughter1Log,
|
|---|
| 105 | &myDetectorPhys,false,0);
|
|---|
| 106 | G4PVPlacement offMYZPhys(0,G4ThreeVector(0,-15,10),
|
|---|
| 107 | "Target 5",&myDaughter1Log,
|
|---|
| 108 | &myDetectorPhys,false,0);
|
|---|
| 109 |
|
|---|
| 110 | // Close geometry and check voxels constructed
|
|---|
| 111 | assert(G4GeometryManager::GetInstance()->CloseGeometry());
|
|---|
| 112 |
|
|---|
| 113 | // Check we have some voxels
|
|---|
| 114 | assert(myDetectorLog.GetVoxelHeader() != 0);
|
|---|
| 115 | if (kMinVoxelVolumesLevel1==0)
|
|---|
| 116 | {
|
|---|
| 117 | assert(myDaughter1Log.GetVoxelHeader() != 0);
|
|---|
| 118 | assert(myDaughter2Log.GetVoxelHeader() != 0);
|
|---|
| 119 | }
|
|---|
| 120 | else
|
|---|
| 121 | {
|
|---|
| 122 | assert(!myDaughter1Log.GetVoxelHeader());
|
|---|
| 123 | assert(!myDaughter2Log.GetVoxelHeader());
|
|---|
| 124 | }
|
|---|
| 125 | //
|
|---|
| 126 | //
|
|---|
| 127 | //
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 | // Open geometry freeing voxels
|
|---|
| 131 | G4GeometryManager::GetInstance()->OpenGeometry();
|
|---|
| 132 | // Check voxels destroyed
|
|---|
| 133 | assert(!myDetectorLog.GetVoxelHeader());
|
|---|
| 134 | assert(!myDaughter1Log.GetVoxelHeader());
|
|---|
| 135 | assert(!myDaughter2Log.GetVoxelHeader());
|
|---|
| 136 |
|
|---|
| 137 | return true;
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | // Test voxel Build for replicas
|
|---|
| 141 | G4bool testG4ReplicaVoxels()
|
|---|
| 142 | {
|
|---|
| 143 |
|
|---|
| 144 | G4Box myBigBox("cuboid",100,100,100);
|
|---|
| 145 | G4Box myBox("cube",100,100,50);
|
|---|
| 146 | G4Box mySlab("slab",100,100,10);
|
|---|
| 147 |
|
|---|
| 148 | G4LogicalVolume myDetectorLog(&myBigBox,0,
|
|---|
| 149 | "World",0,0,0);
|
|---|
| 150 | // Logical with no material,field,
|
|---|
| 151 | // sensitive detector or user limits
|
|---|
| 152 |
|
|---|
| 153 | G4PVPlacement myDetectorPhys(0,G4ThreeVector(0,0,0),
|
|---|
| 154 | "World",&myDetectorLog,
|
|---|
| 155 | 0,false,0);
|
|---|
| 156 | // Note: no mother pointer set
|
|---|
| 157 |
|
|---|
| 158 | G4LogicalVolume myDaughter1Log(&myBox,0,"Crate",0,0,0);
|
|---|
| 159 | G4LogicalVolume myDaughter2Log(&mySlab,0,"Slab",0,0,0);
|
|---|
| 160 | G4PVPlacement myPhys1(0,G4ThreeVector(0,0,0),
|
|---|
| 161 | "Target 1",&myDaughter1Log,
|
|---|
| 162 | &myDetectorPhys,false,0);
|
|---|
| 163 |
|
|---|
| 164 | G4PVReplica myPhysRep1("Replicated Slabs",
|
|---|
| 165 | &myDaughter2Log,
|
|---|
| 166 | &myPhys1,
|
|---|
| 167 | kZAxis,5,20);
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 | // Close geometry and check voxels constructed
|
|---|
| 171 | assert(G4GeometryManager::GetInstance()->CloseGeometry());
|
|---|
| 172 |
|
|---|
| 173 | // Check replicated voxels
|
|---|
| 174 | assert(myDaughter1Log.GetVoxelHeader() != 0);
|
|---|
| 175 | assert(!myDaughter2Log.GetVoxelHeader());
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 | G4SmartVoxelHeader *vHead=myDaughter1Log.GetVoxelHeader();
|
|---|
| 179 | G4SmartVoxelProxy *vProxy=0;
|
|---|
| 180 | G4SmartVoxelNode *vNode=0;
|
|---|
| 181 | assert(vHead->GetAxis()==kZAxis);
|
|---|
| 182 | assert(vHead->GetMinExtent()==-50);
|
|---|
| 183 | assert(vHead->GetMaxExtent()==50);
|
|---|
| 184 | assert(vHead->GetNoSlices()==5);
|
|---|
| 185 | // Check all nodes contain (correct) single volume
|
|---|
| 186 | for (G4int n=0;n<5;n++)
|
|---|
| 187 | {
|
|---|
| 188 | vProxy=vHead->GetSlice(n);
|
|---|
| 189 | assert(vProxy->IsNode());
|
|---|
| 190 | vNode=vProxy->GetNode();
|
|---|
| 191 | assert(vNode->GetNoContained()==1);
|
|---|
| 192 | assert(vNode->GetVolume(0)==n);
|
|---|
| 193 | }
|
|---|
| 194 |
|
|---|
| 195 | // Open geometry freeing voxels
|
|---|
| 196 | G4GeometryManager::GetInstance()->OpenGeometry();
|
|---|
| 197 | // Check voxels destroyed
|
|---|
| 198 | assert(!myDaughter1Log.GetVoxelHeader());
|
|---|
| 199 |
|
|---|
| 200 | return true;
|
|---|
| 201 | }
|
|---|
| 202 | int main()
|
|---|
| 203 | {
|
|---|
| 204 | #ifdef NDEBUG
|
|---|
| 205 | G4Exception("FAIL: *** Assertions must be compiled in! ***");
|
|---|
| 206 | #endif
|
|---|
| 207 | assert(testG4SmartVoxelNodes());
|
|---|
| 208 | assert(testG4SmartVoxels());
|
|---|
| 209 | assert(testG4ReplicaVoxels());
|
|---|
| 210 | return 0;
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 |
|
|---|
| 214 |
|
|---|
| 215 |
|
|---|