Message: RE02 : How is ComputeMaterial called ? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question RE02 : How is ComputeMaterial called ?  

Forum: Documentation and Examples
Date: 13 Jul, 2011
From: David Oxley <David Oxley>

Dear all,

I am having some trouble understanding example examples/extended/runandEvent/RE02.

Let me start at the beginning and please correct me if I am misinformed along the way:

I was looking for an example to help me voxelise a target quickly and efficiently and with the flexibility to assign a different material to different voxels. I gather this has to be done at compile time and cannot be done at run time. The NestedParameterisation class used in RE02 seemed a good place to start with this. I can adapt the ComputeMaterial function to set the materials to what I want them to be rather than to lead and water.

Now I must be missing something, but I don't see the ComputeMaterial function being called anywhere.

Q1) Where is it being called? Is it called somewhere "automatically" on NestedParameterisation construction? I did a > grep ComputeMaterial * and I only find the lines which declare it in the NestedParameterisation.hh and define the full function in the I added some cout statements right to the first line of the function, and they did not appear in my output either.

Moving on...

So I wanted to just call it myself. My guess is it needs to be called when defining the geometry in my class.

So I was thinking along the lines of : // Somewhere inside (after defining all my materials first, of course)

for (int i=0;i<MyNumberOfVoxels; i++) { // 1) get the ith voxel via its replica number // 2) set the material of this voxel to what ComputeMaterial returns }

Q2) How do I get the replica number(s) ?

The documentation I have found so far says to get them via the G4Touchables and, indeed, I had used this later on in the at run time and (of course) it works fine. But I have been accessing the G4Touchable through Step->GetPreStepPoint()->GetTouchable()->GetReplicaNumber(axis=0,1 or 2) But I dont have a step in the . So I am looking for a way to get from either G4LogicalVolume or PhysicalVolume (or from anything that I know in the construction class..e.g. position is fine too) to the replica number. I have been looking in the Geant4 Cross Reference data base, but was not able to find an appropriate chain of functions. I am grateful for any help.

Finally, one thing I tried was to create a "fake step", whose position I manually set to a point in the target. Then I thought I could go via the step back to the touchable to the replica number, but this gives me a segmentation fault.

just out of curiosity : Q3) Am i right assuming the Touchable is set somewhere each time a step is made and because I didnt actually make a step, there is no valid touchable to return?

I hope I have been clear about what I am trying to do and that the questions make sense. If not, please get back to me.

As always, any help is greatly appreciated.

Dave Oxley

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

1 Idea: Re: RE02 : How is ComputeMaterial called ?   (Ben Pietras - 14 Jul, 2011)
2 Ok: Re: RE02 : How is ComputeMaterial called ?   (David Oxley - 04 Aug, 2011)
 Add Message Add Message
to: "RE02 : How is ComputeMaterial called ? "

 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 ]