Hello all,
I hope you’re fine.
I’m having some questions about the GetTouchable()
function.
- Get the
G4PhantomParameterisation
I saw in some code that we can get the G4PhantomParameterisation
associated with the current G4Track*
doing something like:
auto vol = track->GetTouchable()->GetVolume();
if(!vol) return;
auto phantomParam = dynamic_cast<G4PhantomParameterisation*>(vol->GetParameterisation());
Is that true? I would have thought that it is not the G4VPhysicalVolume
in the phantom sense that would be returned, but a voxel ; but again, maybe a “voxel” isn’t a G4VPhysicalVolume
?
GetCopyNumber()
Also, when a G4Track track
is inside a G4PhantomParameterisation
, I can use…
G4int copyNo = track.GetTouchable()->GetCopyNumber();
… to get the copy number of the current voxel where the G4Track
is located?
- Convert global direction to local direction
I have also written a function that convert global direction to local direction in the case of a G4Track& track
inside of a G4PhantomParameterisation
:
G4ThreeVector ConvertToLocalDirection(const G4Track& track, const G4ThreeVector& globalDir) const
{
G4TouchableHistory* hist = dynamic_cast<G4TouchableHistory*>(track.GetTouchable());
G4ThreeVector localDir = hist->GetTransform(hist->GetDepth()).TransformAxis(globalDir);
return localDir;
}
Is it correct? Are there other ways to do this in a more optimized way?
Is always the GetTouchable
of a G4Track
a G4TouchableHistory
?
For information :
Geant4 Version: 11.2.2
Operating System: Windows and Linux
Thanks a lot,