| [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 | // Demonstrate some issues with G4Tubs
|
|---|
| 28 | //
|
|---|
| 29 |
|
|---|
| 30 | #include <assert.h>
|
|---|
| 31 | #include <iomanip>
|
|---|
| 32 | #include <cmath>
|
|---|
| 33 |
|
|---|
| 34 | #include "globals.hh"
|
|---|
| 35 | #include "geomdefs.hh"
|
|---|
| 36 |
|
|---|
| 37 | #include "ApproxEqual.hh"
|
|---|
| 38 |
|
|---|
| 39 | #include "G4ThreeVector.hh"
|
|---|
| 40 |
|
|---|
| 41 | #include "G4Tubs.hh"
|
|---|
| 42 |
|
|---|
| 43 | // #include "G4Tubs13.hh"
|
|---|
| 44 |
|
|---|
| 45 | #include "G4Hype.hh"
|
|---|
| 46 | #include "G4VoxelLimits.hh"
|
|---|
| 47 | #include "G4AffineTransform.hh"
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 | const G4String OutputInside(const EInside a)
|
|---|
| 51 | {
|
|---|
| 52 | switch(a)
|
|---|
| 53 | {
|
|---|
| 54 | case kInside: return " Inside";
|
|---|
| 55 | case kOutside: return "Outside";
|
|---|
| 56 | case kSurface: return "Surface";
|
|---|
| 57 | }
|
|---|
| 58 | return " ????";
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 | int main()
|
|---|
| 63 | {
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | // Voxel problems
|
|---|
| 67 | //
|
|---|
| 68 | // Make a simple cylinder
|
|---|
| 69 |
|
|---|
| 70 | G4Tubs test3( "simple", 0.5*m, 1*m, 0.1*m, 0, 2*pi );
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 | // Make an equivalent hyperbolic tube
|
|---|
| 74 |
|
|---|
| 75 | G4Hype test4( "simple2", 0.5*m, 1*m, 0.0, 0.0, 0.1*m );
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 | // Build a transform that is a simple rotation
|
|---|
| 79 | // of 85 degrees around the z axis
|
|---|
| 80 |
|
|---|
| 81 | G4RotationMatrix rotate;
|
|---|
| 82 |
|
|---|
| 83 | // rotate.rotateZ(85.0*degree);
|
|---|
| 84 | // rotate.rotateZ(90.0*degree);
|
|---|
| 85 |
|
|---|
| 86 | rotate.rotateZ(270.0*degree);
|
|---|
| 87 | G4AffineTransform transform( rotate );
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 | // Here is a voxel limit that extends into the
|
|---|
| 91 | // middle of the solid
|
|---|
| 92 |
|
|---|
| 93 | G4VoxelLimits voxel1;
|
|---|
| 94 | voxel1.AddLimit( kXAxis, -0.1*m, 0.1*m );
|
|---|
| 95 | voxel1.AddLimit( kYAxis, 0.8*m, 2.0*m );
|
|---|
| 96 | voxel1.AddLimit( kZAxis, -0.001*m, 0.001*m );
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 | // Test 1 CalculateExtent. Answer should be:
|
|---|
| 100 | // Min = 0.8
|
|---|
| 101 | // Max = something just larger than 1*m
|
|---|
| 102 |
|
|---|
| 103 | G4bool answer3, answer4;
|
|---|
| 104 | G4double min3, max3, min4, max4;
|
|---|
| 105 |
|
|---|
| 106 | answer3 = test3.CalculateExtent( kYAxis, voxel1, transform, min3, max3 );
|
|---|
| 107 | answer4 = test4.CalculateExtent( kYAxis, voxel1, transform, min4, max4 );
|
|---|
| 108 |
|
|---|
| 109 | G4cout << "-----------------" << std::endl;
|
|---|
| 110 | G4cout << "Voxel test 1 " << std::endl;
|
|---|
| 111 | /*
|
|---|
| 112 | G4cout << "Should be: "
|
|---|
| 113 | << std::setw(7) << true
|
|---|
| 114 | << std::setw(10) << 800
|
|---|
| 115 | << std::setw(10) << ">1000" << std::endl;
|
|---|
| 116 |
|
|---|
| 117 | G4cout << "G4Tubs: "
|
|---|
| 118 | << std::setw(7) << answer3
|
|---|
| 119 | << std::setw(10) << min3
|
|---|
| 120 | << std::setw(10) << max3 << std::endl;
|
|---|
| 121 | G4cout << "G4Hype: "
|
|---|
| 122 | << std::setw(7) << answer4
|
|---|
| 123 | << std::setw(10) << min4
|
|---|
| 124 | << std::setw(10) << max4 << std::endl;
|
|---|
| 125 | */
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 | // Here is a voxel limit that starts and ends in the solid
|
|---|
| 129 |
|
|---|
| 130 | G4VoxelLimits voxel2;
|
|---|
| 131 | // voxel2.AddLimit( kXAxis, -0.1*m, 0.1*m );
|
|---|
| 132 | voxel2.AddLimit( kXAxis, -0.8*m, 0.8*m );
|
|---|
| 133 | voxel2.AddLimit( kYAxis, -0.8*m, 0.8*m );
|
|---|
| 134 | voxel2.AddLimit( kZAxis, -0.001*m, 0.001*m );
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 | // Test 2 CalculateExtent. Answer should be:
|
|---|
| 138 | // Min = -0.8
|
|---|
| 139 | // Max = +0.8
|
|---|
| 140 |
|
|---|
| 141 | // answer3 = test3.CalculateExtent( kXAxis, voxel2, transform, min3, max3 );
|
|---|
| 142 | // answer4 = test4.CalculateExtent( kXAxis, voxel2, transform, min4, max4 );
|
|---|
| 143 |
|
|---|
| 144 | answer3 = test3.CalculateExtent( kYAxis, voxel2, transform, min3, max3 );
|
|---|
| 145 | answer4 = test4.CalculateExtent( kYAxis, voxel2, transform, min4, max4 );
|
|---|
| 146 |
|
|---|
| 147 | G4cout << "-----------------" << std::endl;
|
|---|
| 148 | G4cout << "Voxel test 2 " << std::endl;
|
|---|
| 149 | /*
|
|---|
| 150 | G4cout << "Should be: "
|
|---|
| 151 | << std::setw(7) << true
|
|---|
| 152 | << std::setw(10) << -800
|
|---|
| 153 | << std::setw(10) << 800 << std::endl;
|
|---|
| 154 |
|
|---|
| 155 | G4cout << "G4Tubs: "
|
|---|
| 156 | << std::setw(7) << answer3
|
|---|
| 157 | << std::setw(10) << min3
|
|---|
| 158 | << std::setw(10) << max3 << std::endl;
|
|---|
| 159 | G4cout << "G4Hype: "
|
|---|
| 160 | << std::setw(7) << answer4
|
|---|
| 161 | << std::setw(10) << min4
|
|---|
| 162 | << std::setw(10) << max4 << std::endl;
|
|---|
| 163 | */
|
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 | // Here is a tiny voxel that just skims the solid.
|
|---|
| 167 |
|
|---|
| 168 | G4VoxelLimits voxel3;
|
|---|
| 169 | // voxel3.AddLimit( kXAxis, -0.001*m, 0.001*m );
|
|---|
| 170 |
|
|---|
| 171 | voxel3.AddLimit( kXAxis, 0.998*m, 1.003*m );
|
|---|
| 172 | voxel3.AddLimit( kYAxis, 0.998*m, 1.003*m );
|
|---|
| 173 | voxel3.AddLimit( kZAxis, -0.001*m, 0.001*m );
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 | // Test 3 CalculateExtent. Answer should be:
|
|---|
| 177 | // Min = 0.998
|
|---|
| 178 | // Max = Something larger than 1.0
|
|---|
| 179 | //
|
|---|
| 180 |
|
|---|
| 181 | // answer3 = test3.CalculateExtent( kXAxis, voxel3, transform, min3, max3 );
|
|---|
| 182 | // answer4 = test4.CalculateExtent( kXAxis, voxel3, transform, min4, max4 );
|
|---|
| 183 | answer3 = test3.CalculateExtent( kYAxis, voxel3, transform, min3, max3 );
|
|---|
| 184 | answer4 = test4.CalculateExtent( kYAxis, voxel3, transform, min4, max4 );
|
|---|
| 185 |
|
|---|
| 186 | G4cout << "-----------------" << std::endl;
|
|---|
| 187 | G4cout << "Voxel test 3 " << std::endl;
|
|---|
| 188 | /*
|
|---|
| 189 | G4cout << "Should be: "
|
|---|
| 190 | << std::setw(7) << true
|
|---|
| 191 | << std::setw(10) << 998
|
|---|
| 192 | << std::setw(10) << ">1000" << std::endl;
|
|---|
| 193 | G4cout << "G4Tubs: "
|
|---|
| 194 | << std::setw(7) << answer3
|
|---|
| 195 | << std::setw(10) << min3
|
|---|
| 196 | << std::setw(10) << max3 << std::endl;
|
|---|
| 197 | G4cout << "G4Hype: "
|
|---|
| 198 | << std::setw(7) << answer4
|
|---|
| 199 | << std::setw(10) << min4
|
|---|
| 200 | << std::setw(10) << max4 << std::endl;
|
|---|
| 201 | */
|
|---|
| 202 |
|
|---|
| 203 | }
|
|---|