Message: How to determine the volume from position? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question How to determine the volume from position? 

Forum: Event and Track Management
Date: 02 Jul, 2008
From: Nikola Jovancevic <Nikola Jovancevic>

Dear all,

I would like to generate my particles in given (complex) volume. In the function PrimaryGeneratorAction::GeneratePrimaries I randomly pick the coordinates, but I need to find the method to check whether that position is inside my volume (it is very complicated to do with if-then combinations). I would like to do this before I generate the primary vertex. I tried this:

                  G4int X = G4UniformRand();
                  G4int Y = G4UniformRand();
                  G4int Z = G4UniformRand();
                  G4StepPoint mypoint;
                  mypoint.SetPosition(G4ThreeVector(X,Y,Z));
                  G4VPhysicalVolume* myvolume = mypoint.GetPhysicalVolume();

But the program crashes when I try to read out some information about the volume:

                  G4cout << myvolume->GetName() << G4endl;

Does anyone has some ideas?

Thank you in advance, Nikola

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

1 Feedback: Re: How to determine the volume from position?   (Gumplinger Peter - 02 Jul, 2008)
(_ Ok: Re: How to determine the volume from position?   (Nikola Jovancevic - 07 Jul, 2008)
 Add Message Add Message
to: "How to determine the volume from position?"

 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 ]