Message: Re: Intersection between a straight line and a volume Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Intersection between a straight line and a volume 

Forum: Geometry
Re: None Intersection between a straight line and a volume (Alain Ferragut)
Date: 09 Jun, 2011
From: John Apostolakis <John Apostolakis>

Dear Alain,

The simplest way is to
- use a geantino as a particle (which does not interact)
- set the initial point and direction using the particle gun,
- set the verbosity of tracking using
/tracking/verbose 1
and track a particle.  The verbosity should report if you have crossed 
that volume.

But you you want to do this systematically, please find below a quick 
sketch of how to move through a geometry which you have described to 
Geant4 -- and which you have closed (e.g. by running one track through 
it with beamOn).

You will need to navigate from the current point until you have exited 
the world in order to see whether you

0) Make sure that you are not doing this during tracking - else it will 
confuse the Geant4 tracking

1) Get the Navigator
    G4Navigator  pNavigator=

2) Locate at your current point (G4ThreeVector point;)
    G4VPhysicalVolume volHere=
      pNavigator->LocateGlobalPointAndSetup( point );

    if (volHere == 0)
    // you are done - it is outside the world
    else if ( ..
    Check  volHere->GetName()  against the volume you are trying to 

3) Ask it to move to the next boundary:
    G4double stepSize=
     pNavigator->ComputeStep( point, direction );

4) Find the location of the next boundary:
    G4ThreeVector newPoint= point + stepSize * direction;

5) Check whether you have managed to move
        (newPoint - point).mag2() > 0
    and restart at Step 2) above with point=newPoint.

Please excuse any typos - you can find the signatures of key methods in
eg by look in Geant4 LXR or your source code.

Hope this helps,

On 6/7/11 4:23 PM, Alain Ferragut wrote:
> *** Discussion title: Geometry
> Hello, Is it possible to do the following : knowing the current location
> and the velocity (vector) of a particle, I would like to test if a
> specific volume in my geometry will be intersected by the straight line
> passing at my particle location and oriented by the current particle
> velocity vector ?
> Thanks,
> Alain
> -------------------------------------------------------------
> Visit this GEANT4 at message (to reply or unsubscribe) at:

John Apostolakis
Tel: Office +41-22-767-7239
      Mobile +41-76-242-0801

 Add Message Add Message
to: "Re: Intersection between a straight line and a volume"

 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 ]