Creating a material map using G4Navigator

Dear all,

I am trying to create an overview material map like radiation length in the various projections (xy/xz/yz) of a setup by stepping into the respective volumes. My current approach is based on the G4Navigator as the example below shows. In addition, I also use it to calculate the radiation length along a certain path.

G4Navigator* g4Navigator = new G4Navigator();
g4Navigator->SetWorldVolume(world);

// Get volume at position
G4VPhysicalVolume* volume = g4Navigator->LocateGlobalPointAndSetup(position);
const double radLen = volume->GetLogicalVolume()->GetMaterial()->GetRadlen();

// Stepping length in volume
double stepLength = this->_g4Navigator->ComputeStep(position, direction, proposedPhysicsStep, newSafety);
if( stepLength > proposedPhysicsStep  ) {
    stepLength = proposedPhysicsStep;
}

// Cross boundary
stepLength += boundaryStep;

It is working as expected, but unfortunately it is kind of slow scanning for instance the material in a 500x500 bin histogram.

Therefore I am wondering whether there is a better way to do this? (or even a correct way if I am totally on the wrong path here).

Thanky you very much in advance,
Christian

really no expert on this field (just linked your post in another question), but from what I have read, I think the navigator benefits from “propagating” through the geometry. So if you query “random” points, it has to redo all the initial caching, finding which volume/daughter volume it is in, etc… I could imagine to rasterize the 500x500 bins in colums – where you get from one point to the next by applying g4Navigator ->ComputeStep() – would give you a speed-up.

In short: ComputeStep(position, direction) instead of
LocateGlobalPointAndSetup(position+direction) for the next position.

(but keep in mind that boundary crossings could require some extra handling, if the navigator stops the step there and needs to do the remaining step to reach the next query position for your histogram).

edit: after reading your post more carefully: you already do that for the radiation length along a certain direction. maybe you could use two navigators, one that propagates from the position to obtain the rad length, the other propagates to obtain the new origins for the second, and you copy the navigator instead of LocateGlobalPointAndSetup for the second?

1 Like