[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 | // First Polycone test, created by J. Apostolakis, 12 Feb 99 |
---|
| 28 | // modification of BREP PCon test, created by L. Broglia, 20 Oct 98 |
---|
| 29 | // which was derived from G4Gerep test by J. Sulkimo |
---|
| 30 | // |
---|
| 31 | // Cvs version: $ Id $ |
---|
| 32 | // Cvs tag : $ Name $ |
---|
| 33 | |
---|
| 34 | #include "G4Timer.hh" |
---|
| 35 | #include <cmath> |
---|
| 36 | #include <fstream> |
---|
| 37 | #include <stdlib.h> |
---|
| 38 | #include "G4ios.hh" |
---|
| 39 | #include "G4Polycone.hh" |
---|
| 40 | |
---|
| 41 | #include "G4Vector3D.hh" |
---|
| 42 | #include "G4Point3D.hh" |
---|
| 43 | |
---|
| 44 | int main(int, char **) |
---|
| 45 | { |
---|
| 46 | double RMINVec[8]; |
---|
| 47 | RMINVec[0] = 30; |
---|
| 48 | RMINVec[1] = 30; |
---|
| 49 | RMINVec[2] = 0; |
---|
| 50 | RMINVec[3] = 0; |
---|
| 51 | RMINVec[4] = 0; |
---|
| 52 | RMINVec[5] = 0; |
---|
| 53 | RMINVec[6] = 40; |
---|
| 54 | RMINVec[7] = 40; |
---|
| 55 | |
---|
| 56 | double RMAXVec[8]; |
---|
| 57 | RMAXVec[0] = 70; |
---|
| 58 | RMAXVec[1] = 70; |
---|
| 59 | RMAXVec[2] = 70; |
---|
| 60 | RMAXVec[3] = 40; |
---|
| 61 | RMAXVec[4] = 40; |
---|
| 62 | RMAXVec[5] = 80; |
---|
| 63 | RMAXVec[6] = 80; |
---|
| 64 | RMAXVec[7] = 60; |
---|
| 65 | |
---|
| 66 | double Z_Values[8]; |
---|
| 67 | Z_Values[0] =-20; |
---|
| 68 | Z_Values[1] =-10; |
---|
| 69 | Z_Values[2] =-10; |
---|
| 70 | Z_Values[3] = 0; |
---|
| 71 | Z_Values[4] = 10; |
---|
| 72 | Z_Values[5] = 20; |
---|
| 73 | Z_Values[6] = 30; |
---|
| 74 | Z_Values[7] = 40; |
---|
| 75 | |
---|
| 76 | double Phi_Values[1]; |
---|
| 77 | Phi_Values[0]=-10*deg; |
---|
| 78 | Phi_Values[1]=10.*deg; |
---|
| 79 | // Phi_Values[1]=2*pi; |
---|
| 80 | |
---|
| 81 | G4cout << "\n======= Polycone test ========"; |
---|
| 82 | |
---|
| 83 | G4Polycone *MyPCone = new G4Polycone ("MyPCone", |
---|
| 84 | Phi_Values[0], |
---|
| 85 | Phi_Values[1], |
---|
| 86 | 8 , |
---|
| 87 | Z_Values , |
---|
| 88 | RMINVec , |
---|
| 89 | RMAXVec ); |
---|
| 90 | |
---|
| 91 | G4cout << "\n\nPCone created ! "<<G4endl; |
---|
| 92 | // -> Check methods : |
---|
| 93 | // - Inside |
---|
| 94 | // - DistanceToIn |
---|
| 95 | // - DistanceToOut |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | EInside in; |
---|
| 99 | |
---|
| 100 | G4cout<<"\n\n=================================================="; |
---|
| 101 | G4ThreeVector pt(0, -100, 24); |
---|
| 102 | G4int y; |
---|
| 103 | for (y = -100; y<=100; y+=10) |
---|
| 104 | { |
---|
| 105 | pt.setY(y); |
---|
| 106 | in = MyPCone->Inside(pt); |
---|
| 107 | |
---|
| 108 | G4cout << "\nx=" << pt.x() << " y=" << pt.y() << " z=" << pt.z(); |
---|
| 109 | |
---|
| 110 | if( in == kInside ) |
---|
| 111 | G4cout <<" is inside"; |
---|
| 112 | else |
---|
| 113 | if( in == kOutside ) |
---|
| 114 | G4cout <<" is outside"; |
---|
| 115 | else |
---|
| 116 | G4cout <<" is on the surface"; |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | G4cout<<"\n\n=================================================="; |
---|
| 120 | G4ThreeVector start( 0, 0, -30); |
---|
| 121 | G4ThreeVector dir(1./std::sqrt(2.), 1./std::sqrt(2.), 0); |
---|
| 122 | G4double d; |
---|
| 123 | G4int z; |
---|
| 124 | |
---|
| 125 | G4cout<<"\nPdep is (0, 0, z)"; |
---|
| 126 | G4cout<<"\nDir is (1, 1, 0)\n"; |
---|
| 127 | |
---|
| 128 | for(z=-30; z<=50; z+=5) |
---|
| 129 | { |
---|
| 130 | start.setZ(z); |
---|
| 131 | |
---|
| 132 | in = MyPCone->Inside(start); |
---|
| 133 | G4cout<< "x=" << start.x() << " y=" << start.y() << " z=" << start.z(); |
---|
| 134 | |
---|
| 135 | if( in == kInside ) |
---|
| 136 | { |
---|
| 137 | G4cout <<" is inside"; |
---|
| 138 | |
---|
| 139 | d = MyPCone->DistanceToOut(start, dir); |
---|
| 140 | G4cout<<" distance to out="<<d; |
---|
| 141 | d = MyPCone->DistanceToOut(start); |
---|
| 142 | G4cout<<" closest distance to out="<<d<<G4endl; |
---|
| 143 | } |
---|
| 144 | else if( in == kOutside ) |
---|
| 145 | { |
---|
| 146 | G4cout <<" is outside"; |
---|
| 147 | |
---|
| 148 | d = MyPCone->DistanceToIn(start, dir); |
---|
| 149 | G4cout<<" distance to in="<<d; |
---|
| 150 | d = MyPCone->DistanceToIn(start); |
---|
| 151 | G4cout<<" closest distance to in="<<d<<G4endl; |
---|
| 152 | } |
---|
| 153 | else |
---|
| 154 | G4cout <<" is on the surface"<<G4endl; |
---|
| 155 | |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | G4cout<<"\n\n=================================================="; |
---|
| 159 | G4ThreeVector start2( 0, -100, -30); |
---|
| 160 | G4ThreeVector dir2(0, 1, 0); |
---|
| 161 | G4double d2; |
---|
| 162 | |
---|
| 163 | G4cout<<"\nPdep is (0, -100, z)"; |
---|
| 164 | G4cout<<"\nDir is (0, 1, 0)\n"; |
---|
| 165 | |
---|
| 166 | for(z=-30; z<=50; z+=5) |
---|
| 167 | { |
---|
| 168 | G4cout<<" z="<<z; |
---|
| 169 | start2.setZ(z); |
---|
| 170 | d2 = MyPCone->DistanceToIn(start2, dir2); |
---|
| 171 | G4cout<<" distance to in="<<d2; |
---|
| 172 | d2 = MyPCone->DistanceToIn(start2); |
---|
| 173 | G4cout<<" distance to in="<<d2<<G4endl; |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | G4cout<<"\n\n=================================================="; |
---|
| 177 | G4ThreeVector start3( 0, 0, -50); |
---|
| 178 | G4ThreeVector dir3(0, 0, 1); |
---|
| 179 | G4double d3; |
---|
| 180 | |
---|
| 181 | G4cout<<"\nPdep is (0, y, -50)"; |
---|
| 182 | G4cout<<"\nDir is (0, 0, 1)\n"; |
---|
| 183 | |
---|
| 184 | for(y=-0; y<=90; y+=5) |
---|
| 185 | { |
---|
| 186 | G4cout<<" y="<<y; |
---|
| 187 | start3.setY(y); |
---|
| 188 | d3 = MyPCone->DistanceToIn(start3, dir3); |
---|
| 189 | G4cout<<" distance to in="<<d3<<G4endl; |
---|
| 190 | } |
---|
| 191 | // |
---|
| 192 | // Add checks in Phi direction |
---|
| 193 | // Point move in Phi direction for differents Z |
---|
| 194 | // |
---|
| 195 | G4cout<<"\n\n=================================================="; |
---|
| 196 | |
---|
| 197 | for(z=-10; z<=50; z+=5) |
---|
| 198 | { |
---|
| 199 | G4cout<<"\n\n===================Z="<<z<<"=============================="; |
---|
| 200 | //G4ThreeVector start4( 0, 0, z-0.00001); |
---|
| 201 | G4ThreeVector start4( 0, 0, z); |
---|
| 202 | //G4double phi=pi/180.*rad; |
---|
| 203 | // G4double phi=0.0000000001*pi/180.*rad; |
---|
| 204 | G4double phi=-pi/180.*rad; |
---|
| 205 | G4ThreeVector dir4(std::cos(phi), std::sin(phi), 0); |
---|
| 206 | G4double d4; |
---|
| 207 | |
---|
| 208 | G4cout<<"\nPdep is (0<<R<<50, phi, z)"; |
---|
| 209 | G4cout<<"\nDir is (std::cos(phi), std::sin(phi), 0)\n"; |
---|
| 210 | G4cout<<"Ndirection is="<<dir4 <<G4endl; |
---|
| 211 | |
---|
| 212 | for(y=-0; y<=50; y+=5) |
---|
| 213 | { |
---|
| 214 | |
---|
| 215 | start4.setX(y*std::cos(phi)); |
---|
| 216 | start4.setY(y*std::sin(phi)); |
---|
| 217 | G4cout<<" R="<<y<<" with Start"<<start4; |
---|
| 218 | in = MyPCone->Inside(start4); |
---|
| 219 | if( in == kInside ) |
---|
| 220 | { |
---|
| 221 | G4cout <<" is inside"; |
---|
| 222 | d4 = MyPCone->DistanceToOut(start4, dir4); |
---|
| 223 | G4cout<<" distance to out="<<d4; |
---|
| 224 | d4 = MyPCone->DistanceToOut(start4); |
---|
| 225 | G4cout<<" closest distance to out="<<d4<<G4endl; |
---|
| 226 | } |
---|
| 227 | else |
---|
| 228 | if( in == kOutside ) |
---|
| 229 | { |
---|
| 230 | G4cout <<" is outside"; |
---|
| 231 | d4 = MyPCone->DistanceToIn(start4, dir4); |
---|
| 232 | G4cout<<" distance to in="<<d4; |
---|
| 233 | d4 = MyPCone->DistanceToIn(start4); |
---|
| 234 | G4cout<<" closest distance to in="<<d4<<G4endl; |
---|
| 235 | } |
---|
| 236 | else |
---|
| 237 | {G4cout <<" is on the surface"; |
---|
| 238 | d4 = MyPCone->DistanceToIn(start4, dir4); |
---|
| 239 | G4cout<<" distance to in="<<d4; |
---|
| 240 | d4 = MyPCone->DistanceToIn(start4); |
---|
| 241 | G4cout<<" closest distance to in="<<d4<<G4endl; |
---|
| 242 | } |
---|
| 243 | |
---|
| 244 | } |
---|
| 245 | } |
---|
| 246 | // |
---|
| 247 | // Add checks in Phi direction |
---|
| 248 | // Point move in X direction for differents Z |
---|
| 249 | // and 'schoot' on rhi edge |
---|
| 250 | G4cout<<"\n\n=================================================="; |
---|
| 251 | |
---|
| 252 | for(z=-10; z<=50; z+=5) |
---|
| 253 | { |
---|
| 254 | G4cout<<"\n\n===================Z="<<z<<"=============================="; |
---|
| 255 | // G4ThreeVector start5( 0., 0.000000000001, z); |
---|
| 256 | G4ThreeVector start5( 0., 1, z); |
---|
| 257 | G4ThreeVector dir5(0,-1, 0); |
---|
| 258 | G4double d5; |
---|
| 259 | |
---|
| 260 | G4cout<<"\nPdep is (0<<X<<50, 1, z)"; |
---|
| 261 | G4cout<<"\nDir is (0, -1, 0)\n"; |
---|
| 262 | G4cout<<"Ndirection is="<<dir5 <<G4endl; |
---|
| 263 | |
---|
| 264 | for(y=-0; y<=50; y+=5) |
---|
| 265 | { |
---|
| 266 | |
---|
| 267 | start5.setX(y); |
---|
| 268 | G4cout<<" Start"<<start5; |
---|
| 269 | in = MyPCone->Inside(start5); |
---|
| 270 | if( in == kInside ) |
---|
| 271 | { |
---|
| 272 | G4cout <<" is inside"; |
---|
| 273 | d5 = MyPCone->DistanceToOut(start5, dir5); |
---|
| 274 | G4cout<<" distance to out="<<d5; |
---|
| 275 | d5 = MyPCone->DistanceToOut(start5); |
---|
| 276 | G4cout<<" closest distance to out="<<d5<<G4endl; |
---|
| 277 | } |
---|
| 278 | else |
---|
| 279 | if( in == kOutside ) |
---|
| 280 | { |
---|
| 281 | G4cout <<" is outside"; |
---|
| 282 | d5 = MyPCone->DistanceToIn(start5, dir5); |
---|
| 283 | G4cout<<" distance to in="<<d5; |
---|
| 284 | d5 = MyPCone->DistanceToIn(start5); |
---|
| 285 | G4cout<<" closest distance to in="<<d5<<G4endl; |
---|
| 286 | } |
---|
| 287 | else |
---|
| 288 | { |
---|
| 289 | G4cout <<" is on the surface"; |
---|
| 290 | d5 = MyPCone->DistanceToIn(start5, dir5); |
---|
| 291 | G4cout<<" distance to in="<<d5; |
---|
| 292 | d5 = MyPCone->DistanceToIn(start5); |
---|
| 293 | G4cout<<" closest distance to in="<<d5<<G4endl; |
---|
| 294 | } |
---|
| 295 | |
---|
| 296 | } |
---|
| 297 | } |
---|
| 298 | |
---|
| 299 | return EXIT_SUCCESS; |
---|
| 300 | } |
---|
| 301 | |
---|