| 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 | // Test File for tracking functions on a solid surface
|
|---|
| 28 | //
|
|---|
| 29 | // o Basic asserts on each function +
|
|---|
| 30 | // awkward cases for tracking / geom algorithms
|
|---|
| 31 | //
|
|---|
| 32 | // o Add tests on dicovering bugs in G4Sphere.cc...
|
|---|
| 33 | //
|
|---|
| 34 | // History:
|
|---|
| 35 | //
|
|---|
| 36 | // 14.07.04 V.Grichine creation for box, orb and sphere
|
|---|
| 37 | // 15.02.05 V.Grichine changes for boolean solids
|
|---|
| 38 |
|
|---|
| 39 | #include "G4ios.hh"
|
|---|
| 40 | #include <assert.h>
|
|---|
| 41 | #include <cmath>
|
|---|
| 42 | #include "globals.hh"
|
|---|
| 43 | #include "geomdefs.hh"
|
|---|
| 44 | #include "Randomize.hh"
|
|---|
| 45 |
|
|---|
| 46 | #include "ApproxEqual.hh"
|
|---|
| 47 |
|
|---|
| 48 | #include "G4ThreeVector.hh"
|
|---|
| 49 | #include "G4RotationMatrix.hh"
|
|---|
| 50 | #include "G4AffineTransform.hh"
|
|---|
| 51 | #include "G4VoxelLimits.hh"
|
|---|
| 52 | #include "G4GeometryTolerance.hh"
|
|---|
| 53 |
|
|---|
| 54 | #include "G4Box.hh"
|
|---|
| 55 | #include "G4Orb.hh"
|
|---|
| 56 | #include "G4Tubs.hh"
|
|---|
| 57 | #include "G4Sphere.hh"
|
|---|
| 58 | #include "G4Cons.hh"
|
|---|
| 59 | // #include "G4Hype.hh"
|
|---|
| 60 | #include "G4Para.hh"
|
|---|
| 61 | #include "G4Torus.hh"
|
|---|
| 62 | #include "G4Trd.hh"
|
|---|
| 63 |
|
|---|
| 64 | #include "G4IntersectionSolid.hh"
|
|---|
| 65 | #include "G4UnionSolid.hh"
|
|---|
| 66 | #include "G4SubtractionSolid.hh"
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 | ///////////////////////////////////////////////////////////////////////////
|
|---|
| 70 | //
|
|---|
| 71 | //
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 | //const G4double kApproxEqualTolerance = kCarTolerance;
|
|---|
| 75 |
|
|---|
| 76 | // Return true if the double check is approximately equal to target
|
|---|
| 77 | //
|
|---|
| 78 | // Process:
|
|---|
| 79 | //
|
|---|
| 80 | // Return true is difference < kApproxEqualTolerance
|
|---|
| 81 |
|
|---|
| 82 | //G4bool ApproxEqual(const G4double check,const G4double target)
|
|---|
| 83 | //{
|
|---|
| 84 | // return (std::fabs(check-target)<kApproxEqualTolerance) ? true : false ;
|
|---|
| 85 | //}
|
|---|
| 86 |
|
|---|
| 87 | // Return true if the 3vector check is approximately equal to target
|
|---|
| 88 | //G4bool ApproxEqual(const G4ThreeVector& check, const G4ThreeVector& target)
|
|---|
| 89 | //{
|
|---|
| 90 | // return (ApproxEqual(check.x(),target.x())&&
|
|---|
| 91 | // ApproxEqual(check.y(),target.y())&&
|
|---|
| 92 | // ApproxEqual(check.z(),target.z()))? true : false;
|
|---|
| 93 | //}
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 | ///////////////////////////////////////////////////////////////////
|
|---|
| 99 | //
|
|---|
| 100 | // Dave's auxiliary function
|
|---|
| 101 |
|
|---|
| 102 | const G4String OutputInside(const EInside a)
|
|---|
| 103 | {
|
|---|
| 104 | switch(a)
|
|---|
| 105 | {
|
|---|
| 106 | case kInside: return "Inside";
|
|---|
| 107 | case kOutside: return "Outside";
|
|---|
| 108 | case kSurface: return "Surface";
|
|---|
| 109 | }
|
|---|
| 110 | return "????";
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 115 | //
|
|---|
| 116 | // Random unit direction vector
|
|---|
| 117 |
|
|---|
| 118 | G4ThreeVector GetRandomUnitVector()
|
|---|
| 119 | {
|
|---|
| 120 | G4double cosTheta, sinTheta, phi, vx, vy, vz;
|
|---|
| 121 |
|
|---|
| 122 | cosTheta = -1. + 2.*G4UniformRand();
|
|---|
| 123 | if( cosTheta > 1.) cosTheta = 1.;
|
|---|
| 124 | if( cosTheta < -1.) cosTheta = -1.;
|
|---|
| 125 | sinTheta = std::sqrt( 1. - cosTheta*cosTheta );
|
|---|
| 126 |
|
|---|
| 127 | phi = 2*pi*G4UniformRand();
|
|---|
| 128 |
|
|---|
| 129 | vx = sinTheta*std::cos(phi);
|
|---|
| 130 | vy = sinTheta*std::sin(phi);
|
|---|
| 131 | vz = cosTheta;
|
|---|
| 132 |
|
|---|
| 133 | return G4ThreeVector(vx,vy,vz);
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 137 | //
|
|---|
| 138 | // Random vector on box surface
|
|---|
| 139 |
|
|---|
| 140 | G4ThreeVector GetVectorOnBox( G4Box& box )
|
|---|
| 141 | {
|
|---|
| 142 | G4double rand, a, b, c, px, py, pz;
|
|---|
| 143 | G4double part = 1./6.;
|
|---|
| 144 |
|
|---|
| 145 | a = box.GetXHalfLength();
|
|---|
| 146 | b = box.GetYHalfLength();
|
|---|
| 147 | c = box.GetZHalfLength();
|
|---|
| 148 |
|
|---|
| 149 | rand = G4UniformRand();
|
|---|
| 150 | G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
|---|
| 151 |
|
|---|
| 152 | if ( rand < part )
|
|---|
| 153 | {
|
|---|
| 154 | px = -a - 0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 155 | py = -b - 0.5*kCarTolerance + (2.*b + kCarTolerance)*G4UniformRand();
|
|---|
| 156 | pz = -c - 0.5*kCarTolerance + (2.*c + kCarTolerance)*G4UniformRand();
|
|---|
| 157 | }
|
|---|
| 158 | else if ( rand < 2*part )
|
|---|
| 159 | {
|
|---|
| 160 | px = a - 0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 161 | py = -b - 0.5*kCarTolerance + (2.*b + kCarTolerance)*G4UniformRand();
|
|---|
| 162 | pz = -c - 0.5*kCarTolerance + (2.*c + kCarTolerance)*G4UniformRand();
|
|---|
| 163 | }
|
|---|
| 164 | else if ( rand < 3*part )
|
|---|
| 165 | {
|
|---|
| 166 | px = -a - 0.5*kCarTolerance + (2.*a + kCarTolerance)*G4UniformRand();
|
|---|
| 167 | py = -b - 0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 168 | pz = -c - 0.5*kCarTolerance + (2.*c + kCarTolerance)*G4UniformRand();
|
|---|
| 169 | }
|
|---|
| 170 | else if ( rand < 4*part )
|
|---|
| 171 | {
|
|---|
| 172 | px = -a - 0.5*kCarTolerance + (2.*a + kCarTolerance)*G4UniformRand();
|
|---|
| 173 | py = b - 0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 174 | pz = -c - 0.5*kCarTolerance + (2.*c + kCarTolerance)*G4UniformRand();
|
|---|
| 175 | }
|
|---|
| 176 | else if ( rand < 5*part )
|
|---|
| 177 | {
|
|---|
| 178 | px = -a - 0.5*kCarTolerance + (2.*a + kCarTolerance)*G4UniformRand();
|
|---|
| 179 | py = -b - 0.5*kCarTolerance + (2.*b + kCarTolerance)*G4UniformRand();
|
|---|
| 180 | pz = -c - 0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 181 | }
|
|---|
| 182 | else
|
|---|
| 183 | {
|
|---|
| 184 | px = -a - 0.5*kCarTolerance + (2.*a + kCarTolerance)*G4UniformRand();
|
|---|
| 185 | py = -b - 0.5*kCarTolerance + (2.*b + kCarTolerance)*G4UniformRand();
|
|---|
| 186 | pz = c - 0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 | return G4ThreeVector(px,py,pz);
|
|---|
| 190 | }
|
|---|
| 191 |
|
|---|
| 192 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 193 | //
|
|---|
| 194 | // Random vector on orb surface
|
|---|
| 195 |
|
|---|
| 196 | G4ThreeVector GetVectorOnOrb(G4Orb& orb)
|
|---|
| 197 | {
|
|---|
| 198 | G4double cosTheta, sinTheta, phi, radius, px, py, pz;
|
|---|
| 199 | G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
|---|
| 200 |
|
|---|
| 201 | radius = orb.GetRadius();
|
|---|
| 202 | radius += -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 203 |
|
|---|
| 204 | cosTheta = -1. + 2.*G4UniformRand();
|
|---|
| 205 | if( cosTheta > 1.) cosTheta = 1.;
|
|---|
| 206 | if( cosTheta < -1.) cosTheta = -1.;
|
|---|
| 207 | sinTheta = std::sqrt( 1. - cosTheta*cosTheta );
|
|---|
| 208 |
|
|---|
| 209 | phi = 2*pi*G4UniformRand();
|
|---|
| 210 |
|
|---|
| 211 | px = radius*sinTheta*std::cos(phi);
|
|---|
| 212 | py = radius*sinTheta*std::sin(phi);
|
|---|
| 213 | pz = radius*cosTheta;
|
|---|
| 214 |
|
|---|
| 215 | return G4ThreeVector(px,py,pz);
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 219 | //
|
|---|
| 220 | // Random vector on sphere surface
|
|---|
| 221 |
|
|---|
| 222 | G4ThreeVector GetVectorOnSphere(G4Sphere& sphere)
|
|---|
| 223 | {
|
|---|
| 224 | G4double cosTheta, sinTheta, phi, radius, px, py, pz;
|
|---|
| 225 | G4double part = 1./6.;
|
|---|
| 226 | G4double rand = G4UniformRand();
|
|---|
| 227 |
|
|---|
| 228 | G4double pRmin = sphere.GetInsideRadius();
|
|---|
| 229 | G4double pRmax = sphere.GetOuterRadius();
|
|---|
| 230 | G4double phi1 = sphere.GetStartPhiAngle();
|
|---|
| 231 | G4double phi2 = phi1 + sphere.GetDeltaPhiAngle();
|
|---|
| 232 | G4double theta1 = sphere.GetStartThetaAngle();
|
|---|
| 233 | G4double theta2 = theta1 + sphere.GetDeltaThetaAngle();
|
|---|
| 234 | G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
|---|
| 235 | G4double kAngTolerance = G4GeometryTolerance::GetInstance()->GetAngularTolerance();
|
|---|
| 236 |
|
|---|
| 237 | if ( rand < part ) // Rmax
|
|---|
| 238 | {
|
|---|
| 239 | radius = pRmax -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 240 |
|
|---|
| 241 | cosTheta = std::cos(theta2+0.5*kAngTolerance) +
|
|---|
| 242 | (std::cos(theta1-0.5*kAngTolerance)-std::cos(theta2+0.5*kAngTolerance))*G4UniformRand();
|
|---|
| 243 | if( cosTheta > 1.) cosTheta = 1.;
|
|---|
| 244 | if( cosTheta < -1.) cosTheta = -1.;
|
|---|
| 245 | sinTheta = std::sqrt( 1. - cosTheta*cosTheta );
|
|---|
| 246 |
|
|---|
| 247 | phi = phi1 - 0.5*kAngTolerance + (phi2 - phi1 + kAngTolerance)*G4UniformRand();
|
|---|
| 248 | }
|
|---|
| 249 | else if ( rand < 2*part ) // Rmin
|
|---|
| 250 | {
|
|---|
| 251 | radius = pRmin -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 252 |
|
|---|
| 253 | cosTheta = std::cos(theta2+0.5*kAngTolerance) +
|
|---|
| 254 | (std::cos(theta1-0.5*kAngTolerance)-std::cos(theta2+0.5*kAngTolerance))*G4UniformRand();
|
|---|
| 255 | if( cosTheta > 1.) cosTheta = 1.;
|
|---|
| 256 | if( cosTheta < -1.) cosTheta = -1.;
|
|---|
| 257 | sinTheta = std::sqrt( 1. - cosTheta*cosTheta );
|
|---|
| 258 |
|
|---|
| 259 | phi = phi1 - 0.5*kAngTolerance + (phi2 - phi1 + kAngTolerance)*G4UniformRand();
|
|---|
| 260 | }
|
|---|
| 261 | else if ( rand < 3*part ) // phi1
|
|---|
| 262 | {
|
|---|
| 263 | radius = pRmin - 0.5*kCarTolerance + (pRmax-pRmin+kCarTolerance)*G4UniformRand();
|
|---|
| 264 |
|
|---|
| 265 | cosTheta = std::cos(theta2+0.5*kAngTolerance) +
|
|---|
| 266 | (std::cos(theta1-0.5*kAngTolerance)-std::cos(theta2+0.5*kAngTolerance))*G4UniformRand();
|
|---|
| 267 | if( cosTheta > 1.) cosTheta = 1.;
|
|---|
| 268 | if( cosTheta < -1.) cosTheta = -1.;
|
|---|
| 269 | sinTheta = std::sqrt( 1. - cosTheta*cosTheta );
|
|---|
| 270 |
|
|---|
| 271 | phi = phi1 -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 272 | }
|
|---|
| 273 | else if ( rand < 4*part ) // phi2
|
|---|
| 274 | {
|
|---|
| 275 | radius = pRmin - 0.5*kCarTolerance + (pRmax-pRmin+kCarTolerance)*G4UniformRand();
|
|---|
| 276 |
|
|---|
| 277 | cosTheta = std::cos(theta2+0.5*kAngTolerance) +
|
|---|
| 278 | (std::cos(theta1-0.5*kAngTolerance)-std::cos(theta2+0.5*kAngTolerance))*G4UniformRand();
|
|---|
| 279 | if( cosTheta > 1.) cosTheta = 1.;
|
|---|
| 280 | if( cosTheta < -1.) cosTheta = -1.;
|
|---|
| 281 | sinTheta = std::sqrt( 1. - cosTheta*cosTheta );
|
|---|
| 282 |
|
|---|
| 283 | phi = phi2 -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 284 | }
|
|---|
| 285 | else if ( rand < 5*part ) // theta1
|
|---|
| 286 | {
|
|---|
| 287 | radius = pRmin - 0.5*kCarTolerance + (pRmax-pRmin+kCarTolerance)*G4UniformRand();
|
|---|
| 288 |
|
|---|
| 289 | cosTheta = std::cos(theta1+0.5*kAngTolerance) +
|
|---|
| 290 | (std::cos(theta1-0.5*kAngTolerance)-std::cos(theta1+0.5*kAngTolerance))*G4UniformRand();
|
|---|
| 291 | if( cosTheta > 1.) cosTheta = 1.;
|
|---|
| 292 | if( cosTheta < -1.) cosTheta = -1.;
|
|---|
| 293 | sinTheta = std::sqrt( 1. - cosTheta*cosTheta );
|
|---|
| 294 |
|
|---|
| 295 | phi = phi1 - 0.5*kAngTolerance + (phi2 - phi1 + kAngTolerance)*G4UniformRand();
|
|---|
| 296 | }
|
|---|
| 297 | else // theta2
|
|---|
| 298 | {
|
|---|
| 299 | radius = pRmin - 0.5*kCarTolerance + (pRmax-pRmin+kCarTolerance)*G4UniformRand();
|
|---|
| 300 |
|
|---|
| 301 | cosTheta = std::cos(theta2+0.5*kAngTolerance) +
|
|---|
| 302 | (std::cos(theta2-0.5*kAngTolerance)-std::cos(theta2+0.5*kAngTolerance))*G4UniformRand();
|
|---|
| 303 | if( cosTheta > 1.) cosTheta = 1.;
|
|---|
| 304 | if( cosTheta < -1.) cosTheta = -1.;
|
|---|
| 305 | sinTheta = std::sqrt( 1. - cosTheta*cosTheta );
|
|---|
| 306 |
|
|---|
| 307 | phi = phi1 - 0.5*kAngTolerance + (phi2 - phi1 + kAngTolerance)*G4UniformRand();
|
|---|
| 308 | }
|
|---|
| 309 |
|
|---|
| 310 | px = radius*sinTheta*std::cos(phi);
|
|---|
| 311 | py = radius*sinTheta*std::sin(phi);
|
|---|
| 312 | pz = radius*cosTheta;
|
|---|
| 313 |
|
|---|
| 314 | return G4ThreeVector(px,py,pz);
|
|---|
| 315 | }
|
|---|
| 316 |
|
|---|
| 317 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 318 | //
|
|---|
| 319 | // Random vector on tubs surface
|
|---|
| 320 |
|
|---|
| 321 | G4ThreeVector GetVectorOnTubs(G4Tubs& tubs)
|
|---|
| 322 | {
|
|---|
| 323 | G4double phi, radius, px, py, pz;
|
|---|
| 324 | G4double part = 1./6.;
|
|---|
| 325 | G4double rand = G4UniformRand();
|
|---|
| 326 |
|
|---|
| 327 | G4double pRmin = tubs.GetInnerRadius ();
|
|---|
| 328 | G4double pRmax = tubs.GetOuterRadius ();
|
|---|
| 329 | G4double tubsZ = tubs.GetZHalfLength ();
|
|---|
| 330 | G4double phi1 = tubs.GetStartPhiAngle ();
|
|---|
| 331 | G4double phi2 = phi1 + tubs.GetDeltaPhiAngle ();
|
|---|
| 332 | G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
|---|
| 333 | G4double kAngTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
|---|
| 334 |
|
|---|
| 335 | if ( rand < part ) // Rmax
|
|---|
| 336 | {
|
|---|
| 337 | radius = pRmax -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 338 | pz = -tubsZ - 0.5*kCarTolerance + (2*tubsZ + kCarTolerance)*G4UniformRand();
|
|---|
| 339 | phi = phi1 - 0.5*kAngTolerance + (phi2 - phi1 + kAngTolerance)*G4UniformRand();
|
|---|
| 340 | }
|
|---|
| 341 | else if ( rand < 2*part ) // Rmin
|
|---|
| 342 | {
|
|---|
| 343 | radius = pRmin -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 344 | pz = -tubsZ - 0.5*kCarTolerance + (2*tubsZ + kCarTolerance)*G4UniformRand();
|
|---|
| 345 | phi = phi1 - 0.5*kAngTolerance + (phi2 - phi1 + kAngTolerance)*G4UniformRand();
|
|---|
| 346 | }
|
|---|
| 347 | else if ( rand < 3*part ) // phi1
|
|---|
| 348 | {
|
|---|
| 349 | radius = pRmin - 0.5*kCarTolerance + (pRmax-pRmin+kCarTolerance)*G4UniformRand();
|
|---|
| 350 | pz = -tubsZ - 0.5*kCarTolerance + (2*tubsZ + kCarTolerance)*G4UniformRand();
|
|---|
| 351 | phi = phi1 -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 352 | }
|
|---|
| 353 | else if ( rand < 4*part ) // phi2
|
|---|
| 354 | {
|
|---|
| 355 | radius = pRmin - 0.5*kCarTolerance + (pRmax-pRmin+kCarTolerance)*G4UniformRand();
|
|---|
| 356 | pz = -tubsZ - 0.5*kCarTolerance + (2*tubsZ + kCarTolerance)*G4UniformRand();
|
|---|
| 357 | phi = phi2 -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 358 | }
|
|---|
| 359 | else if ( rand < 5*part ) // -fZ
|
|---|
| 360 | {
|
|---|
| 361 | radius = pRmin - 0.5*kCarTolerance + (pRmax-pRmin+kCarTolerance)*G4UniformRand();
|
|---|
| 362 |
|
|---|
| 363 | pz = -tubsZ - 0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 364 |
|
|---|
| 365 | phi = phi1 - 0.5*kAngTolerance + (phi2 - phi1 + kAngTolerance)*G4UniformRand();
|
|---|
| 366 | }
|
|---|
| 367 | else // fZ
|
|---|
| 368 | {
|
|---|
| 369 | radius = pRmin - 0.5*kCarTolerance + (pRmax-pRmin+kCarTolerance)*G4UniformRand();
|
|---|
| 370 | pz = tubsZ - 0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 371 | phi = phi1 - 0.5*kAngTolerance + (phi2 - phi1 + kAngTolerance)*G4UniformRand();
|
|---|
| 372 | }
|
|---|
| 373 |
|
|---|
| 374 | px = radius*std::cos(phi);
|
|---|
| 375 | py = radius*std::sin(phi);
|
|---|
| 376 |
|
|---|
| 377 | return G4ThreeVector(px,py,pz);
|
|---|
| 378 | }
|
|---|
| 379 |
|
|---|
| 380 |
|
|---|
| 381 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 382 | //
|
|---|
| 383 | // Random vector out of tubs surface
|
|---|
| 384 |
|
|---|
| 385 | G4ThreeVector GetVectorOutOfTubs(G4Tubs& tubs)
|
|---|
| 386 | {
|
|---|
| 387 | G4double phi, radius, px, py, pz;
|
|---|
| 388 | G4double part = 1./5.;
|
|---|
| 389 | G4double rand = G4UniformRand();
|
|---|
| 390 |
|
|---|
| 391 | G4double pRmin = tubs.GetInnerRadius ();
|
|---|
| 392 | G4double pRmax = tubs.GetOuterRadius ();
|
|---|
| 393 | G4double tubsZ = tubs.GetZHalfLength ();
|
|---|
| 394 | G4double phi1 = tubs.GetStartPhiAngle ();
|
|---|
| 395 | G4double deltaPhi = tubs.GetDeltaPhiAngle ();
|
|---|
| 396 | G4double phi2 = phi1 + deltaPhi;
|
|---|
| 397 | G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
|---|
| 398 |
|
|---|
| 399 | if ( rand < part ) // Rmax
|
|---|
| 400 | {
|
|---|
| 401 | radius = pRmax +0.5*kCarTolerance + pRmax*G4UniformRand();
|
|---|
| 402 | pz = -2*tubsZ + (4*tubsZ)*G4UniformRand();
|
|---|
| 403 | phi = (2*pi)*G4UniformRand();
|
|---|
| 404 | }
|
|---|
| 405 | else if ( rand < 2*part ) // Rmin
|
|---|
| 406 | {
|
|---|
| 407 | radius = (pRmin -0.5*kCarTolerance)*G4UniformRand();
|
|---|
| 408 | pz = -2*tubsZ + (4*tubsZ)*G4UniformRand();
|
|---|
| 409 | phi = (2*pi)*G4UniformRand();
|
|---|
| 410 | }
|
|---|
| 411 | else if ( rand < 3*part ) // out of deltaPhi
|
|---|
| 412 | {
|
|---|
| 413 | radius = (2*pRmax)*G4UniformRand();
|
|---|
| 414 | pz = -2*tubsZ - 0.5*kCarTolerance + (4*tubsZ + kCarTolerance)*G4UniformRand();
|
|---|
| 415 | phi = phi2 + 0.5*kCarTolerance + (2*pi - deltaPhi - kCarTolerance)*G4UniformRand();
|
|---|
| 416 | }
|
|---|
| 417 | else if ( rand < 4*part ) // -fZ
|
|---|
| 418 | {
|
|---|
| 419 | radius = (2*pRmax)*G4UniformRand();
|
|---|
| 420 | pz = -tubsZ - 0.5*kCarTolerance - (tubsZ)*G4UniformRand();
|
|---|
| 421 | phi = (2*pi)*G4UniformRand();
|
|---|
| 422 | }
|
|---|
| 423 | else // fZ
|
|---|
| 424 | {
|
|---|
| 425 | radius = (2*pRmax)*G4UniformRand();
|
|---|
| 426 | pz = tubsZ + 0.5*kCarTolerance + (tubsZ)*G4UniformRand();
|
|---|
| 427 | phi = (2*pi)*G4UniformRand();
|
|---|
| 428 | }
|
|---|
| 429 |
|
|---|
| 430 | px = radius*std::cos(phi);
|
|---|
| 431 | py = radius*std::sin(phi);
|
|---|
| 432 |
|
|---|
| 433 | return G4ThreeVector(px,py,pz);
|
|---|
| 434 | }
|
|---|
| 435 |
|
|---|
| 436 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 437 | //
|
|---|
| 438 | // Random vector on cons surface
|
|---|
| 439 |
|
|---|
| 440 | G4ThreeVector GetVectorOnCons(G4Cons& cons)
|
|---|
| 441 | {
|
|---|
| 442 | G4double phi, pRmin, pRmax, radius, px, py, pz;
|
|---|
| 443 | G4double part = 1./6.;
|
|---|
| 444 | G4double rand = G4UniformRand();
|
|---|
| 445 |
|
|---|
| 446 | G4double pRmin1 = cons.GetInnerRadiusMinusZ ();
|
|---|
| 447 | G4double pRmax1 = cons.GetOuterRadiusMinusZ ();
|
|---|
| 448 | G4double pRmin2 = cons.GetInnerRadiusPlusZ ();
|
|---|
| 449 | G4double pRmax2 = cons.GetOuterRadiusPlusZ ();
|
|---|
| 450 | G4double consZ = cons.GetZHalfLength ();
|
|---|
| 451 | G4double phi1 = cons.GetStartPhiAngle ();
|
|---|
| 452 | G4double phi2 = phi1 + cons.GetDeltaPhiAngle ();
|
|---|
| 453 | G4double tgMin = (pRmin2 - pRmin1)/(2.*consZ);
|
|---|
| 454 | G4double tgMax = (pRmax2 - pRmax1)/(2.*consZ);
|
|---|
| 455 | G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
|---|
| 456 | G4double kAngTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
|---|
| 457 |
|
|---|
| 458 | if ( rand < part ) // Rmax
|
|---|
| 459 | {
|
|---|
| 460 | pz = -consZ - 0.5*kCarTolerance + (2*consZ + kCarTolerance)*G4UniformRand();
|
|---|
| 461 | pRmax = pRmax1 + tgMax*(pz+consZ);
|
|---|
| 462 | radius = pRmax -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 463 | phi = phi1 - 0.5*kAngTolerance + (phi2 - phi1 + kAngTolerance)*G4UniformRand();
|
|---|
| 464 | }
|
|---|
| 465 | else if ( rand < 2*part ) // Rmin
|
|---|
| 466 | {
|
|---|
| 467 | pz = -consZ - 0.5*kCarTolerance + (2*consZ + kCarTolerance)*G4UniformRand();
|
|---|
| 468 | pRmin = pRmin1 + tgMin*(pz+consZ);
|
|---|
| 469 | radius = pRmin -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 470 | phi = phi1 - 0.5*kAngTolerance + (phi2 - phi1 + kAngTolerance)*G4UniformRand();
|
|---|
| 471 | }
|
|---|
| 472 | else if ( rand < 3*part ) // phi1
|
|---|
| 473 | {
|
|---|
| 474 | pz = -consZ - 0.5*kCarTolerance + (2*consZ + kCarTolerance)*G4UniformRand();
|
|---|
| 475 | pRmax = pRmax1 + tgMax*(pz+consZ);
|
|---|
| 476 | pRmin = pRmin1 + tgMin*(pz+consZ);
|
|---|
| 477 | radius = pRmin - 0.5*kCarTolerance + (pRmax-pRmin+kCarTolerance)*G4UniformRand();
|
|---|
| 478 | phi = phi1 -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 479 | }
|
|---|
| 480 | else if ( rand < 4*part ) // phi2
|
|---|
| 481 | {
|
|---|
| 482 | pz = -consZ - 0.5*kCarTolerance + (2*consZ + kCarTolerance)*G4UniformRand();
|
|---|
| 483 | pRmax = pRmax1 + tgMax*(pz+consZ);
|
|---|
| 484 | pRmin = pRmin1 + tgMin*(pz+consZ);
|
|---|
| 485 | radius = pRmin - 0.5*kCarTolerance + (pRmax-pRmin+kCarTolerance)*G4UniformRand();
|
|---|
| 486 | phi = phi2 -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 487 | }
|
|---|
| 488 | else if ( rand < 5*part ) // -fZ
|
|---|
| 489 | {
|
|---|
| 490 | pz = -consZ - 0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 491 | radius = pRmin1 - 0.5*kCarTolerance + (pRmax1-pRmin1+kCarTolerance)*G4UniformRand();
|
|---|
| 492 | phi = phi1 - 0.5*kAngTolerance + (phi2 - phi1 + kAngTolerance)*G4UniformRand();
|
|---|
| 493 | }
|
|---|
| 494 | else // fZ
|
|---|
| 495 | {
|
|---|
| 496 | pz = consZ - 0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 497 | radius = pRmin2 - 0.5*kCarTolerance + (pRmax2-pRmin2+kCarTolerance)*G4UniformRand();
|
|---|
| 498 | phi = phi1 - 0.5*kAngTolerance + (phi2 - phi1 + kAngTolerance)*G4UniformRand();
|
|---|
| 499 | }
|
|---|
| 500 |
|
|---|
| 501 | px = radius*std::cos(phi);
|
|---|
| 502 | py = radius*std::sin(phi);
|
|---|
| 503 |
|
|---|
| 504 | return G4ThreeVector(px,py,pz);
|
|---|
| 505 | }
|
|---|
| 506 |
|
|---|
| 507 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 508 | //
|
|---|
| 509 | // Random vector on torus surface
|
|---|
| 510 |
|
|---|
| 511 | G4ThreeVector GetVectorOnTorus(G4Torus& torus)
|
|---|
| 512 | {
|
|---|
| 513 | G4double phi, radius, px, py, pz;
|
|---|
| 514 | G4double part = 1./4.;
|
|---|
| 515 | G4double rand = G4UniformRand();
|
|---|
| 516 |
|
|---|
| 517 | G4double pRmin = torus.GetRmin();
|
|---|
| 518 | G4double pRmax = torus.GetRmax();
|
|---|
| 519 | G4double pRtor = torus.GetRtor();
|
|---|
| 520 | G4double phi1 = torus.GetSPhi();
|
|---|
| 521 | G4double phi2 = phi1 + torus.GetDPhi ();
|
|---|
| 522 | G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
|---|
| 523 | G4double kAngTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
|---|
| 524 |
|
|---|
| 525 | if ( rand < part ) // Rmax
|
|---|
| 526 | {
|
|---|
| 527 | radius = pRmax -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 528 | pz = -pRtor - 0.5*kCarTolerance + (2*pRtor + kCarTolerance)*G4UniformRand();
|
|---|
| 529 | phi = phi1 - 0.5*kAngTolerance + (phi2 - phi1 + kAngTolerance)*G4UniformRand();
|
|---|
| 530 | }
|
|---|
| 531 | else if ( rand < 2*part ) // Rmin
|
|---|
| 532 | {
|
|---|
| 533 | radius = pRmin -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 534 | pz = -pRtor - 0.5*kCarTolerance + (2*pRtor + kCarTolerance)*G4UniformRand();
|
|---|
| 535 | phi = phi1 - 0.5*kAngTolerance + (phi2 - phi1 + kAngTolerance)*G4UniformRand();
|
|---|
| 536 | }
|
|---|
| 537 | else if ( rand < 3*part ) // phi1
|
|---|
| 538 | {
|
|---|
| 539 | radius = pRmin - 0.5*kCarTolerance + (pRmax-pRmin+kCarTolerance)*G4UniformRand();
|
|---|
| 540 | pz = -pRtor - 0.5*kCarTolerance + (2*pRtor + kCarTolerance)*G4UniformRand();
|
|---|
| 541 | phi = phi1 -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 542 | }
|
|---|
| 543 | else if ( rand < 4*part ) // phi2
|
|---|
| 544 | {
|
|---|
| 545 | radius = pRmin - 0.5*kCarTolerance + (pRmax-pRmin+kCarTolerance)*G4UniformRand();
|
|---|
| 546 | pz = -pRtor - 0.5*kCarTolerance + (2*pRtor + kCarTolerance)*G4UniformRand();
|
|---|
| 547 | phi = phi2 -0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 548 | }
|
|---|
| 549 | else if ( rand < 5*part ) // -fZ
|
|---|
| 550 | {
|
|---|
| 551 | radius = pRmin - 0.5*kCarTolerance + (pRmax-pRmin+kCarTolerance)*G4UniformRand();
|
|---|
| 552 |
|
|---|
| 553 | pz = -pRtor - 0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 554 |
|
|---|
| 555 | phi = phi1 - 0.5*kAngTolerance + (phi2 - phi1 + kAngTolerance)*G4UniformRand();
|
|---|
| 556 | }
|
|---|
| 557 | else // fZ
|
|---|
| 558 | {
|
|---|
| 559 | radius = pRmin - 0.5*kCarTolerance + (pRmax-pRmin+kCarTolerance)*G4UniformRand();
|
|---|
| 560 | pz = pRtor - 0.5*kCarTolerance + (kCarTolerance)*G4UniformRand();
|
|---|
| 561 | phi = phi1 - 0.5*kAngTolerance + (phi2 - phi1 + kAngTolerance)*G4UniformRand();
|
|---|
| 562 | }
|
|---|
| 563 |
|
|---|
| 564 | px = radius*std::cos(phi);
|
|---|
| 565 | py = radius*std::sin(phi);
|
|---|
| 566 |
|
|---|
| 567 | return G4ThreeVector(px,py,pz);
|
|---|
| 568 | }
|
|---|
| 569 |
|
|---|
| 570 |
|
|---|
| 571 | //////////////////////////////////////////////////////////////////////
|
|---|
| 572 | //
|
|---|
| 573 | // Main executable function
|
|---|
| 574 |
|
|---|
| 575 | int main(void)
|
|---|
| 576 | {
|
|---|
| 577 | G4int i, j, iMax=1000, jMax=1000;
|
|---|
| 578 | G4int iCheck = iMax/10;
|
|---|
| 579 | G4double distIn, distIn1, distIn2, distOut;
|
|---|
| 580 | EInside surfaceP, surfaceP1, surfaceP2;
|
|---|
| 581 | G4ThreeVector norm, *pNorm;
|
|---|
| 582 | G4bool *pgoodNorm, goodNorm, calcNorm=true;
|
|---|
| 583 | G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
|---|
| 584 |
|
|---|
| 585 | enum Esolid {kInter, kBox, kOrb, kSphere, kCons, kTubs, kTorus, kPara, kTrapezoid, kTrd};
|
|---|
| 586 |
|
|---|
| 587 | Esolid useCase = kInter;
|
|---|
| 588 |
|
|---|
| 589 | pNorm=&norm;
|
|---|
| 590 | pgoodNorm=&goodNorm;
|
|---|
| 591 |
|
|---|
| 592 | G4cout.precision(20);
|
|---|
| 593 |
|
|---|
| 594 | // Boxes for test
|
|---|
| 595 |
|
|---|
| 596 | G4Box b1("Test Box #1",20,30,40);
|
|---|
| 597 | G4Box b2("Test Box #2",10,10,10);
|
|---|
| 598 | G4Box box3("BABAR Box",0.14999999999999999,
|
|---|
| 599 | 24.707000000000001,
|
|---|
| 600 | 22.699999999999999) ;
|
|---|
| 601 |
|
|---|
| 602 | // orbs for test
|
|---|
| 603 |
|
|---|
| 604 | G4Orb o1("Solid G4Orb",50);
|
|---|
| 605 | G4Orb o10("s10",0.018*mm);
|
|---|
| 606 | // G4Orb* solidO1= new G4Orb("O1", 2.7*cm);
|
|---|
| 607 |
|
|---|
| 608 |
|
|---|
| 609 | // spheres for test
|
|---|
| 610 |
|
|---|
| 611 | // G4Sphere s5("Patch (phi/theta seg)",45,50,-pi/4,halfpi,pi/4,halfpi);
|
|---|
| 612 | // G4Sphere s5("Patch (phi/theta seg)",45,50,-pi/4.,pi/4.,pi/4,pi/4.);
|
|---|
| 613 | G4Sphere s5("Patch (phi/theta seg)",45,50,-pi/4.,pi/4.,pi/2,pi/4.);
|
|---|
| 614 |
|
|---|
| 615 | G4Sphere s6("John example",300,500,0,5.76,0,pi) ;
|
|---|
| 616 | G4Sphere s7("sphere7",1400.,1550.,0.022321428571428572,0.014642857142857141,
|
|---|
| 617 | 1.5631177553663251,0.014642857142857141 );
|
|---|
| 618 | G4Sphere s8("sphere",278.746*mm, 280.0*mm, 0.0*degree, 360.0*degree,
|
|---|
| 619 | 0.0*degree, 90.0*degree);
|
|---|
| 620 |
|
|---|
| 621 | G4Sphere b216("b216", 1400.0, 1550.0,
|
|---|
| 622 | 0.022321428571428572,
|
|---|
| 623 | 0.014642857142857141,
|
|---|
| 624 | 1.578117755366325,
|
|---|
| 625 | 0.014642857142867141);
|
|---|
| 626 |
|
|---|
| 627 | G4Sphere s9("s9",0*mm,410*mm,0*degree,360*degree,90*degree,90*degree);
|
|---|
| 628 |
|
|---|
| 629 | G4Sphere b402("b402", 475*mm, 480*mm,
|
|---|
| 630 | 0*degree,360*degree,17.8*degree,144.4*degree);
|
|---|
| 631 |
|
|---|
| 632 |
|
|---|
| 633 | G4Sphere s10("s10",0*mm,0.018*mm,0*degree,360*degree,0*degree,180*degree);
|
|---|
| 634 |
|
|---|
| 635 |
|
|---|
| 636 | G4Sphere s11("s11",5000000.*mm,
|
|---|
| 637 | 3700000000.*mm,
|
|---|
| 638 | 0*degree,360*degree,0*degree,180*degree);
|
|---|
| 639 |
|
|---|
| 640 |
|
|---|
| 641 | G4Sphere sAlex("sAlex",500.*mm,
|
|---|
| 642 | 501.*mm,
|
|---|
| 643 | 0*degree,360*degree,0*degree,180*degree);
|
|---|
| 644 |
|
|---|
| 645 | G4Sphere sLHCB("sLHCB",8600*mm, 8606*mm,
|
|---|
| 646 | -1.699135525184141*degree,
|
|---|
| 647 | 3.398271050368263*degree,88.52855940538514*degree,2.942881189229715*degree );
|
|---|
| 648 |
|
|---|
| 649 | G4Sphere spAroundX("SpAroundX", 10.*mm, 1000.*mm, -1.0*degree,
|
|---|
| 650 | 2.0*degree,
|
|---|
| 651 | 0.*degree, 180.0*degree );
|
|---|
| 652 |
|
|---|
| 653 |
|
|---|
| 654 | // G4Tubs t4("Hole Sector #4",45*mm,50*mm,50*mm,halfpi,halfpi);
|
|---|
| 655 | G4Tubs t4("Hole Sector #4",45*mm,50*mm,50*mm,-halfpi,halfpi);
|
|---|
| 656 |
|
|---|
| 657 | G4Cons c4("Hollow Cut Cone",50,100,50,200,50,-pi/6,pi/3);
|
|---|
| 658 | G4Cons c5("Hollow Cut Cone",25,50,75,150,50,0,3*halfpi);
|
|---|
| 659 |
|
|---|
| 660 | G4Torus torus1("torus1",10.,15.,20.,0.,3*halfpi);
|
|---|
| 661 |
|
|---|
| 662 |
|
|---|
| 663 |
|
|---|
| 664 | G4Tubs* detTub1 = new G4Tubs("Tubs4", 0.*cm, 5.*cm, 5.*cm, 0., 359*deg);
|
|---|
| 665 | G4Tubs* detTub12 = new G4Tubs("Tubs12", 1.*cm, 5.*cm, 5.*cm, 0., 359*deg);
|
|---|
| 666 | G4Tubs* detTub2 = new G4Tubs("Tubs5", 1.*cm, 5.1*cm, 5.1*cm, 0., 359*deg);
|
|---|
| 667 |
|
|---|
| 668 | G4IntersectionSolid* detInt1 = new G4IntersectionSolid("inter1",
|
|---|
| 669 | detTub1, detTub2, 0, G4ThreeVector() );
|
|---|
| 670 | G4IntersectionSolid* detInt2 = new G4IntersectionSolid("inter2",
|
|---|
| 671 | detTub2, detTub1, 0, G4ThreeVector() );
|
|---|
| 672 |
|
|---|
| 673 | // Check of some use cases shown zero-zero problems
|
|---|
| 674 |
|
|---|
| 675 | G4ThreeVector pCheck, vCheck;
|
|---|
| 676 |
|
|---|
| 677 | // pCheck = G4ThreeVector( 41.418613476008794, -16.893662525384702, 4.9094423552800466 );
|
|---|
| 678 | // vCheck = G4ThreeVector( 0.34553222148699703, 0.91172822040596313, 0.22216916084289551 );
|
|---|
| 679 | // distIn = s5.DistanceToIn(pCheck,vCheck);
|
|---|
| 680 | // distOut = s5.DistanceToOut(pCheck,vCheck,calcNorm,pgoodNorm,pNorm);
|
|---|
| 681 |
|
|---|
| 682 | // pCheck = G4ThreeVector( 43.169180219772784, -11.564259048580507, 5.2621090605480623 );
|
|---|
| 683 | // surfaceP = s5.Inside(pCheck);
|
|---|
| 684 |
|
|---|
| 685 | pCheck = G4ThreeVector( -51.189087930597751, -17.382942686173514, -45.939946175080983 );
|
|---|
| 686 | vCheck = G4ThreeVector( 0.44410267104120671, -0.88563345532911941, -0.13574314117431641 );
|
|---|
| 687 | distIn = c5.DistanceToIn(pCheck,vCheck);
|
|---|
| 688 | distOut = c5.DistanceToOut(pCheck,vCheck,calcNorm,pgoodNorm,pNorm);
|
|---|
| 689 |
|
|---|
| 690 | pCheck = G4ThreeVector(-41.407491890396564, -31.155805955816909, -48.18046093035241 );
|
|---|
| 691 | vCheck = G4ThreeVector(0.79040557001853884, -0.52472467107317944, -0.31610608100891113 );
|
|---|
| 692 | distIn = c5.DistanceToIn(pCheck,vCheck);
|
|---|
| 693 | distOut = c5.DistanceToOut(pCheck,vCheck,calcNorm,pgoodNorm,pNorm);
|
|---|
| 694 |
|
|---|
| 695 | pCheck = G4ThreeVector(-66.68328490196707, -47.460245099793099, -18.151754141035401 );
|
|---|
| 696 | vCheck = G4ThreeVector(-0.066679791594195931, 0.88577693677046576, -0.45929622650146484 );
|
|---|
| 697 | distIn = c5.DistanceToIn(pCheck,vCheck);
|
|---|
| 698 | distOut = c5.DistanceToOut(pCheck,vCheck,calcNorm,pgoodNorm,pNorm);
|
|---|
| 699 |
|
|---|
| 700 | pCheck = G4ThreeVector( -17.140591059524617, -23.320101452294466, -49.999999999668375 );
|
|---|
| 701 | vCheck = G4ThreeVector ( -0.69080640316788089, -0.58982688856527554, 0.41819941997528076 );
|
|---|
| 702 | distIn = detTub12->DistanceToIn(pCheck,vCheck);
|
|---|
| 703 | distIn1 = detTub1->DistanceToIn(pCheck,vCheck);
|
|---|
| 704 | distIn2 = detTub2->DistanceToIn(pCheck,vCheck);
|
|---|
| 705 | G4cout<<"dTub12 = "<<distIn<<"; dTub1 = "<<distIn1<<"; dTub2 = "<<distIn2<<G4endl;
|
|---|
| 706 | surfaceP = detTub12->Inside(pCheck);
|
|---|
| 707 | surfaceP1 = detTub1->Inside(pCheck);
|
|---|
| 708 | surfaceP2 = detTub2->Inside(pCheck);
|
|---|
| 709 | G4cout<<"insideTub12 = "<<OutputInside(surfaceP)<<"; insideTub1 = "<<OutputInside(surfaceP1)
|
|---|
| 710 | <<"; insideTub2 = "<<OutputInside(surfaceP2)<<G4endl;
|
|---|
| 711 | distIn1 = detInt1->DistanceToIn(pCheck,vCheck);
|
|---|
| 712 | distIn2 = detInt2->DistanceToIn(pCheck,vCheck);
|
|---|
| 713 | G4cout<<"Int1 = "<<distIn1<<"; Int2 = "<<distIn2<<G4endl;
|
|---|
| 714 | surfaceP1 = detInt1->Inside(pCheck);
|
|---|
| 715 | surfaceP2 = detInt2->Inside(pCheck);
|
|---|
| 716 | G4cout<<"insideInt1 = "<<OutputInside(surfaceP1)
|
|---|
| 717 | <<"; insideInt2 = "<<OutputInside(surfaceP2)<<G4endl;
|
|---|
| 718 |
|
|---|
| 719 |
|
|---|
| 720 | #ifdef NDEBUG
|
|---|
| 721 | G4Exception("FAIL: *** Assertions must be compiled in! ***");
|
|---|
| 722 | #endif
|
|---|
| 723 |
|
|---|
| 724 | G4ThreeVector p1, p2;
|
|---|
| 725 |
|
|---|
| 726 | // Check box tracking function
|
|---|
| 727 |
|
|---|
| 728 | switch (useCase)
|
|---|
| 729 | {
|
|---|
| 730 | case kInter:
|
|---|
| 731 | G4cout<<"Testing of all cutted G4Tubs intersection:"<<G4endl<<G4endl;
|
|---|
| 732 | for( i = 0; i < iMax; i++ )
|
|---|
| 733 | {
|
|---|
| 734 | if(i%iCheck == 0) G4cout<<"i = "<<i<<G4endl;
|
|---|
| 735 |
|
|---|
| 736 | // G4ThreeVector p1 = GetVectorOnTubs(*detTub1);
|
|---|
| 737 | G4ThreeVector p1 = GetVectorOutOfTubs(*detTub12);
|
|---|
| 738 | G4ThreeVector p2 = GetVectorOnTubs(*detTub2);
|
|---|
| 739 |
|
|---|
| 740 | surfaceP = detInt1->Inside(p1);
|
|---|
| 741 |
|
|---|
| 742 | if(
|
|---|
| 743 | // surfaceP != kSurface
|
|---|
| 744 | surfaceP != kOutside
|
|---|
| 745 | )
|
|---|
| 746 | {
|
|---|
| 747 | // G4cout<<"p is out of surface: "<<G4endl;
|
|---|
| 748 | // G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 749 |
|
|---|
| 750 | }
|
|---|
| 751 | else
|
|---|
| 752 | {
|
|---|
| 753 | for( j = 0; j < jMax; j++ )
|
|---|
| 754 | {
|
|---|
| 755 | G4ThreeVector v = GetRandomUnitVector();
|
|---|
| 756 |
|
|---|
| 757 | distIn1 = detInt1->DistanceToIn(p1,v);
|
|---|
| 758 | distIn2 = detInt2->DistanceToIn(p1,v);
|
|---|
| 759 | // distOut = detInt1->DistanceToOut(p1,v,calcNorm,pgoodNorm,pNorm);
|
|---|
| 760 | // distOut = t4.DistanceToOut(p,v,calcNorm,pgoodNorm,pNorm);
|
|---|
| 761 |
|
|---|
| 762 | // if( distIn < kCarTolerance && distOut < kCarTolerance )
|
|---|
| 763 | if(
|
|---|
| 764 | // distIn1 != distIn2
|
|---|
| 765 | std::abs( distIn1 - distIn2 ) > 100*kCarTolerance
|
|---|
| 766 | // distIn1 == distOut
|
|---|
| 767 | )
|
|---|
| 768 | {
|
|---|
| 769 | G4cout<<" distIn1 != distIn2: "<<G4endl;
|
|---|
| 770 | // G4cout<<" distIn1 == distOut: "<<G4endl;
|
|---|
| 771 | G4cout<<"distIn1 = "<<distIn1
|
|---|
| 772 | <<"; distIn2 = "<<distIn2<<G4endl;
|
|---|
| 773 | // <<"; distOut = "<<distOut<<G4endl;
|
|---|
| 774 | G4cout<<"location p1: "<<G4endl;
|
|---|
| 775 | G4cout<<"( "<<p1.x()<<", "<<p1.y()<<", "<<p1.z()<<" ); "<<G4endl;
|
|---|
| 776 | G4cout<<" direction v: "<<G4endl;
|
|---|
| 777 | G4cout<<"( "<<v.x()<<", "<<v.y()<<", "<<v.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 778 | }
|
|---|
| 779 | else if(distIn > 100000*kCarTolerance && distOut > 100*kCarTolerance)
|
|---|
| 780 | {
|
|---|
| 781 | /*
|
|---|
| 782 | G4cout<<" distIn > 100000*kCarTolerance && distOut > 100*kCarTolerance"<<G4endl;
|
|---|
| 783 | G4cout<<"distIn = "<<distIn<<"; distOut = "<<distOut<<G4endl;
|
|---|
| 784 | G4cout<<"location p: "<<G4endl;
|
|---|
| 785 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl;
|
|---|
| 786 | G4cout<<" direction v: "<<G4endl;
|
|---|
| 787 | G4cout<<"( "<<v.x()<<", "<<v.y()<<", "<<v.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 788 | */
|
|---|
| 789 | }
|
|---|
| 790 | }
|
|---|
| 791 | }
|
|---|
| 792 | }
|
|---|
| 793 | break;
|
|---|
| 794 |
|
|---|
| 795 | case kBox:
|
|---|
| 796 | G4cout<<"Testing G4Box:"<<G4endl<<G4endl;
|
|---|
| 797 | for(i=0;i<iMax;i++)
|
|---|
| 798 | {
|
|---|
| 799 | G4ThreeVector p = GetVectorOnBox(b1);
|
|---|
| 800 |
|
|---|
| 801 | surfaceP = b1.Inside(p);
|
|---|
| 802 | if(surfaceP != kSurface)
|
|---|
| 803 | {
|
|---|
| 804 | G4cout<<"p is out of surface: "<<G4endl;
|
|---|
| 805 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 806 |
|
|---|
| 807 | }
|
|---|
| 808 | else
|
|---|
| 809 | {
|
|---|
| 810 | for(j=0;j<jMax;j++)
|
|---|
| 811 | {
|
|---|
| 812 | G4ThreeVector v = GetRandomUnitVector();
|
|---|
| 813 |
|
|---|
| 814 | distIn = b1.DistanceToIn(p,v);
|
|---|
| 815 | distOut = b1.DistanceToOut(p,v,calcNorm,pgoodNorm,pNorm);
|
|---|
| 816 |
|
|---|
| 817 | if( distIn < kCarTolerance && distOut < kCarTolerance )
|
|---|
| 818 | {
|
|---|
| 819 | G4cout<<" distIn < kCarTolerance && distOut < kCarTolerance"<<G4endl;
|
|---|
| 820 | G4cout<<"distIn = "<<distIn<<"; distOut = "<<distOut<<G4endl;
|
|---|
| 821 | G4cout<<"location p: "<<G4endl;
|
|---|
| 822 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl;
|
|---|
| 823 | G4cout<<" direction v: "<<G4endl;
|
|---|
| 824 | G4cout<<"( "<<v.x()<<", "<<v.y()<<", "<<v.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 825 | }
|
|---|
| 826 | else if(distIn > 100000*kCarTolerance && distOut > 100*kCarTolerance)
|
|---|
| 827 | {
|
|---|
| 828 | G4cout<<" distIn > 100000*kCarTolerance && distOut > 100*kCarTolerance"<<G4endl;
|
|---|
| 829 | G4cout<<"distIn = "<<distIn<<"; distOut = "<<distOut<<G4endl;
|
|---|
| 830 | G4cout<<"location p: "<<G4endl;
|
|---|
| 831 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl;
|
|---|
| 832 | G4cout<<" direction v: "<<G4endl;
|
|---|
| 833 | G4cout<<"( "<<v.x()<<", "<<v.y()<<", "<<v.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 834 | }
|
|---|
| 835 | }
|
|---|
| 836 | }
|
|---|
| 837 | }
|
|---|
| 838 | break;
|
|---|
| 839 |
|
|---|
| 840 | case kOrb:
|
|---|
| 841 | G4cout<<"Testing G4Orb:"<<G4endl<<G4endl;
|
|---|
| 842 | for(i=0;i<iMax;i++)
|
|---|
| 843 | {
|
|---|
| 844 | G4ThreeVector p = GetVectorOnOrb(o1);
|
|---|
| 845 |
|
|---|
| 846 | surfaceP = o1.Inside(p);
|
|---|
| 847 | if(surfaceP != kSurface)
|
|---|
| 848 | {
|
|---|
| 849 | G4cout<<"p is out of surface: "<<G4endl;
|
|---|
| 850 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 851 |
|
|---|
| 852 | }
|
|---|
| 853 | else
|
|---|
| 854 | {
|
|---|
| 855 | for(j=0;j<jMax;j++)
|
|---|
| 856 | {
|
|---|
| 857 | G4ThreeVector v = GetRandomUnitVector();
|
|---|
| 858 |
|
|---|
| 859 | distIn = o1.DistanceToIn(p,v);
|
|---|
| 860 | distOut = o1.DistanceToOut(p,v,calcNorm,pgoodNorm,pNorm);
|
|---|
| 861 |
|
|---|
| 862 | if( distIn < kCarTolerance && distOut < kCarTolerance )
|
|---|
| 863 | {
|
|---|
| 864 | G4cout<<" distIn < kCarTolerance && distOut < kCarTolerance"<<G4endl;
|
|---|
| 865 | G4cout<<"distIn = "<<distIn<<"; distOut = "<<distOut<<G4endl;
|
|---|
| 866 | G4cout<<"location p: "<<G4endl;
|
|---|
| 867 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl;
|
|---|
| 868 | G4cout<<" direction v: "<<G4endl;
|
|---|
| 869 | G4cout<<"( "<<v.x()<<", "<<v.y()<<", "<<v.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 870 | }
|
|---|
| 871 | else if(distIn > 100000*kCarTolerance && distOut > 100*kCarTolerance)
|
|---|
| 872 | {
|
|---|
| 873 | G4cout<<" distIn > 100000*kCarTolerance && distOut > 100*kCarTolerance"<<G4endl;
|
|---|
| 874 | G4cout<<"distIn = "<<distIn<<"; distOut = "<<distOut<<G4endl;
|
|---|
| 875 | G4cout<<"location p: "<<G4endl;
|
|---|
| 876 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl;
|
|---|
| 877 | G4cout<<" direction v: "<<G4endl;
|
|---|
| 878 | G4cout<<"( "<<v.x()<<", "<<v.y()<<", "<<v.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 879 | }
|
|---|
| 880 | }
|
|---|
| 881 | }
|
|---|
| 882 | }
|
|---|
| 883 | break;
|
|---|
| 884 |
|
|---|
| 885 | case kSphere:
|
|---|
| 886 | G4cout<<"Testing all cutted G4Sphere:"<<G4endl<<G4endl;
|
|---|
| 887 | for(i=0;i<iMax;i++)
|
|---|
| 888 | {
|
|---|
| 889 | if(i%iCheck == 0) G4cout<<"i = "<<i<<G4endl;
|
|---|
| 890 | G4ThreeVector p = GetVectorOnSphere(s5);
|
|---|
| 891 | surfaceP = s5.Inside(p);
|
|---|
| 892 | if(surfaceP != kSurface)
|
|---|
| 893 | {
|
|---|
| 894 | G4cout<<"p is out of surface: "<<G4endl;
|
|---|
| 895 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 896 |
|
|---|
| 897 | }
|
|---|
| 898 | else
|
|---|
| 899 | {
|
|---|
| 900 | for(j=0;j<jMax;j++)
|
|---|
| 901 | {
|
|---|
| 902 | G4ThreeVector v = GetRandomUnitVector();
|
|---|
| 903 |
|
|---|
| 904 | distIn = s5.DistanceToIn(p,v);
|
|---|
| 905 | distOut = s5.DistanceToOut(p,v,calcNorm,pgoodNorm,pNorm);
|
|---|
| 906 |
|
|---|
| 907 | // if( distIn < kCarTolerance && distOut < kCarTolerance )
|
|---|
| 908 | if( distIn == 0. && distOut == 0. )
|
|---|
| 909 | {
|
|---|
| 910 | G4cout<<" distIn < kCarTolerance && distOut < kCarTolerance"<<G4endl;
|
|---|
| 911 | G4cout<<"distIn = "<<distIn<<"; distOut = "<<distOut<<G4endl;
|
|---|
| 912 | G4cout<<"location p: "<<G4endl;
|
|---|
| 913 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl;
|
|---|
| 914 | G4cout<<" direction v: "<<G4endl;
|
|---|
| 915 | G4cout<<"( "<<v.x()<<", "<<v.y()<<", "<<v.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 916 | }
|
|---|
| 917 | else if(distIn > 100000*kCarTolerance && distOut > 100*kCarTolerance)
|
|---|
| 918 | {
|
|---|
| 919 | /*
|
|---|
| 920 | G4cout<<" distIn > 100000*kCarTolerance && distOut > 100*kCarTolerance"<<G4endl;
|
|---|
| 921 | G4cout<<"distIn = "<<distIn<<"; distOut = "<<distOut<<G4endl;
|
|---|
| 922 | G4cout<<"location p: "<<G4endl;
|
|---|
| 923 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl;
|
|---|
| 924 | G4cout<<" direction v: "<<G4endl;
|
|---|
| 925 | G4cout<<"( "<<v.x()<<", "<<v.y()<<", "<<v.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 926 | */
|
|---|
| 927 | }
|
|---|
| 928 | }
|
|---|
| 929 | }
|
|---|
| 930 | }
|
|---|
| 931 | break;
|
|---|
| 932 |
|
|---|
| 933 | case kTubs:
|
|---|
| 934 | G4cout<<"Testing all cutted G4Tubs:"<<G4endl<<G4endl;
|
|---|
| 935 | for(i=0;i<iMax;i++)
|
|---|
| 936 | {
|
|---|
| 937 | if(i%iCheck == 0) G4cout<<"i = "<<i<<G4endl;
|
|---|
| 938 | G4ThreeVector p = GetVectorOnTubs(t4);
|
|---|
| 939 | surfaceP = t4.Inside(p);
|
|---|
| 940 | if(surfaceP != kSurface)
|
|---|
| 941 | {
|
|---|
| 942 | G4cout<<"p is out of surface: "<<G4endl;
|
|---|
| 943 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 944 |
|
|---|
| 945 | }
|
|---|
| 946 | else
|
|---|
| 947 | {
|
|---|
| 948 | for(j=0;j<jMax;j++)
|
|---|
| 949 | {
|
|---|
| 950 | G4ThreeVector v = GetRandomUnitVector();
|
|---|
| 951 |
|
|---|
| 952 | distIn = t4.DistanceToIn(p,v);
|
|---|
| 953 | distOut = t4.DistanceToOut(p,v,calcNorm,pgoodNorm,pNorm);
|
|---|
| 954 |
|
|---|
| 955 | // if( distIn < kCarTolerance && distOut < kCarTolerance )
|
|---|
| 956 | if( distIn == 0. && distOut == 0. )
|
|---|
| 957 | {
|
|---|
| 958 | G4cout<<" distIn < kCarTolerance && distOut < kCarTolerance"<<G4endl;
|
|---|
| 959 | G4cout<<"distIn = "<<distIn<<"; distOut = "<<distOut<<G4endl;
|
|---|
| 960 | G4cout<<"location p: "<<G4endl;
|
|---|
| 961 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl;
|
|---|
| 962 | G4cout<<" direction v: "<<G4endl;
|
|---|
| 963 | G4cout<<"( "<<v.x()<<", "<<v.y()<<", "<<v.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 964 | }
|
|---|
| 965 | else if(distIn > 100000*kCarTolerance && distOut > 100*kCarTolerance)
|
|---|
| 966 | {
|
|---|
| 967 | /*
|
|---|
| 968 | G4cout<<" distIn > 100000*kCarTolerance && distOut > 100*kCarTolerance"<<G4endl;
|
|---|
| 969 | G4cout<<"distIn = "<<distIn<<"; distOut = "<<distOut<<G4endl;
|
|---|
| 970 | G4cout<<"location p: "<<G4endl;
|
|---|
| 971 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl;
|
|---|
| 972 | G4cout<<" direction v: "<<G4endl;
|
|---|
| 973 | G4cout<<"( "<<v.x()<<", "<<v.y()<<", "<<v.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 974 | */
|
|---|
| 975 | }
|
|---|
| 976 | }
|
|---|
| 977 | }
|
|---|
| 978 | }
|
|---|
| 979 | break;
|
|---|
| 980 |
|
|---|
| 981 | case kCons:
|
|---|
| 982 | G4cout<<"Testing all cutted G4Cons:"<<G4endl<<G4endl;
|
|---|
| 983 | for(i=0;i<iMax;i++)
|
|---|
| 984 | {
|
|---|
| 985 | if(i%iCheck == 0) G4cout<<"i = "<<i<<G4endl;
|
|---|
| 986 | G4ThreeVector p = GetVectorOnCons(c5);
|
|---|
| 987 | surfaceP = c5.Inside(p);
|
|---|
| 988 | if(surfaceP != kSurface)
|
|---|
| 989 | {
|
|---|
| 990 | G4cout<<"p is out of surface: "<<G4endl;
|
|---|
| 991 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 992 |
|
|---|
| 993 | }
|
|---|
| 994 | else
|
|---|
| 995 | {
|
|---|
| 996 | for(j=0;j<jMax;j++)
|
|---|
| 997 | {
|
|---|
| 998 | G4ThreeVector v = GetRandomUnitVector();
|
|---|
| 999 |
|
|---|
| 1000 | distIn = c5.DistanceToIn(p,v);
|
|---|
| 1001 | distOut = c5.DistanceToOut(p,v,calcNorm,pgoodNorm,pNorm);
|
|---|
| 1002 |
|
|---|
| 1003 | // if( distIn < kCarTolerance && distOut < kCarTolerance )
|
|---|
| 1004 | if( distIn == 0. && distOut == 0. )
|
|---|
| 1005 | {
|
|---|
| 1006 | G4cout<<" distIn < kCarTolerance && distOut < kCarTolerance"<<G4endl;
|
|---|
| 1007 | G4cout<<"distIn = "<<distIn<<"; distOut = "<<distOut<<G4endl;
|
|---|
| 1008 | G4cout<<"location p: "<<G4endl;
|
|---|
| 1009 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl;
|
|---|
| 1010 | G4cout<<" direction v: "<<G4endl;
|
|---|
| 1011 | G4cout<<"( "<<v.x()<<", "<<v.y()<<", "<<v.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 1012 | }
|
|---|
| 1013 | else if(distIn > 100000*kCarTolerance && distOut > 100*kCarTolerance)
|
|---|
| 1014 | {
|
|---|
| 1015 | /*
|
|---|
| 1016 | G4cout<<" distIn > 100000*kCarTolerance && distOut > 100*kCarTolerance"<<G4endl;
|
|---|
| 1017 | G4cout<<"distIn = "<<distIn<<"; distOut = "<<distOut<<G4endl;
|
|---|
| 1018 | G4cout<<"location p: "<<G4endl;
|
|---|
| 1019 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl;
|
|---|
| 1020 | G4cout<<" direction v: "<<G4endl;
|
|---|
| 1021 | G4cout<<"( "<<v.x()<<", "<<v.y()<<", "<<v.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 1022 | */
|
|---|
| 1023 | }
|
|---|
| 1024 | }
|
|---|
| 1025 | }
|
|---|
| 1026 | }
|
|---|
| 1027 | break;
|
|---|
| 1028 | case kTorus:
|
|---|
| 1029 | G4cout<<"Testing all cutted G4Torus:"<<G4endl<<G4endl;
|
|---|
| 1030 | for(i=0;i<iMax;i++)
|
|---|
| 1031 | {
|
|---|
| 1032 | if(i%iCheck == 0) G4cout<<"i = "<<i<<G4endl;
|
|---|
| 1033 | G4ThreeVector p = GetVectorOnTorus(torus1);
|
|---|
| 1034 | surfaceP = torus1.Inside(p);
|
|---|
| 1035 | if(surfaceP != kSurface)
|
|---|
| 1036 | {
|
|---|
| 1037 | G4cout<<"p is out of surface: "<<G4endl;
|
|---|
| 1038 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 1039 |
|
|---|
| 1040 | }
|
|---|
| 1041 | else
|
|---|
| 1042 | {
|
|---|
| 1043 | for(j=0;j<jMax;j++)
|
|---|
| 1044 | {
|
|---|
| 1045 | G4ThreeVector v = GetRandomUnitVector();
|
|---|
| 1046 |
|
|---|
| 1047 | distIn = torus1.DistanceToIn(p,v);
|
|---|
| 1048 | distOut = torus1.DistanceToOut(p,v,calcNorm,pgoodNorm,pNorm);
|
|---|
| 1049 |
|
|---|
| 1050 | // if( distIn < kCarTolerance && distOut < kCarTolerance )
|
|---|
| 1051 | if( distIn == 0. && distOut == 0. )
|
|---|
| 1052 | {
|
|---|
| 1053 | G4cout<<" distIn < kCarTolerance && distOut < kCarTolerance"<<G4endl;
|
|---|
| 1054 | G4cout<<"distIn = "<<distIn<<"; distOut = "<<distOut<<G4endl;
|
|---|
| 1055 | G4cout<<"location p: "<<G4endl;
|
|---|
| 1056 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl;
|
|---|
| 1057 | G4cout<<" direction v: "<<G4endl;
|
|---|
| 1058 | G4cout<<"( "<<v.x()<<", "<<v.y()<<", "<<v.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 1059 | }
|
|---|
| 1060 | else if(distIn > 100000*kCarTolerance && distOut > 100*kCarTolerance)
|
|---|
| 1061 | {
|
|---|
| 1062 | /*
|
|---|
| 1063 | G4cout<<" distIn > 100000*kCarTolerance && distOut > 100*kCarTolerance"<<G4endl;
|
|---|
| 1064 | G4cout<<"distIn = "<<distIn<<"; distOut = "<<distOut<<G4endl;
|
|---|
| 1065 | G4cout<<"location p: "<<G4endl;
|
|---|
| 1066 | G4cout<<"( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "<<G4endl;
|
|---|
| 1067 | G4cout<<" direction v: "<<G4endl;
|
|---|
| 1068 | G4cout<<"( "<<v.x()<<", "<<v.y()<<", "<<v.z()<<" ); "<<G4endl<<G4endl;
|
|---|
| 1069 | */
|
|---|
| 1070 | }
|
|---|
| 1071 | }
|
|---|
| 1072 | }
|
|---|
| 1073 | }
|
|---|
| 1074 | break;
|
|---|
| 1075 |
|
|---|
| 1076 | default:
|
|---|
| 1077 | break;
|
|---|
| 1078 | }
|
|---|
| 1079 | return 0;
|
|---|
| 1080 | }
|
|---|
| 1081 |
|
|---|