Message: Problem with G4UnionSolid::DistanceToOut Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Warning Problem with G4UnionSolid::DistanceToOut 

Keywords: Geometry, UnionSolid, DistanceToOut
Forum: Geometry
Date: 20 Oct, 2005
From: Dmitry A. Shtol <Dmitry A. Shtol>

There is a problem with G4UnionSolid::DistanceToOut: for some start points and some directions is returnes too big, impossible distances like 9e+99. Here is a special test program to demonstrate the problem:

#include "globals.hh"
#include "G4Para.hh"
#include "G4Tubs.hh"
#include "G4UnionSolid.hh"
#include "G4ThreeVector.hh"
#include "G4Transform3D.hh"

int main () {
   const G4double dx=15.3125;
   const G4double dy=100;
   const G4double dz=3.75;
   const G4double theta=0.283794;

   const G4double radius=2;
   const G4double length=200; // cm

   // Building solid
   G4Para* para=new G4Para("Para",dx*cm,dy*cm,dz*cm,0,theta,0);
   G4Tubs* tube = new G4Tubs("Tube",0.0,radius*cm*0.99, length*cm/2.0, 0.0, 2*M_PI);

   G4ThreeVector transv(-164.062,0,-17.5); // mm
   G4Transform3D trans1=G4Translate3D(transv*mm)*G4RotateX3D(M_PI/2);

   G4VSolid* solid=new G4UnionSolid("solid",para,tube,trans1);

   // Checking points
   G4ThreeVector point1(-142.188*mm,0,-0.5*mm); // mm
   G4ThreeVector point2(-142.188*mm,0,-1*mm); // mm
   G4ThreeVector direction(-1,0,0);

   if (solid->Inside(point1)==kInside) {
      G4cout<<"Test point "<<point1<<" is inside. That's right!"<<G4endl;
   }
   else {
      G4cout<<"Test point "<<point1<<" is not inside. That's wrong!"<<G4endl;
   }

   G4double dist=solid->DistanceToOut(point1,direction);

   G4cout<<"Distance is "<<dist<<G4endl;

   if (solid->Inside(point2)==kInside) {
      G4cout<<"Test point "<<point2<<" is inside. That's right!"<<G4endl;
   }
   else {
      G4cout<<"Test point "<<point2<<" is not inside. That's wrong!"<<G4endl;
   }

   dist=solid->DistanceToOut(point2,direction);

   G4cout<<"Distance is "<<dist<<G4endl;

return 0; }

The output of this program is:

Test point (-142.188,0,-0.5) is inside. That's right! Distance is 9e+99 Test point (-142.188,0,-1) is inside. That's right! Distance is 32.8189

Distance between points is 0.5 mm, and the result is very different. Why?

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: Problem with G4UnionSolid::DistanceToOut   (Vladimir Grichine - 22 Oct, 2005)
3 None: Re: Problem with G4UnionSolid::DistanceToOut   (Vladimir Grichine - 23 Oct, 2005)
 Add Message Add Message
to: "Problem with G4UnionSolid::DistanceToOut"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]