TVirtualMC: access to track points

Hi,
I am trying to visualize tracks in Geant4VMC example3 (macro
run_g4(“g4tgeoConfig.C”)) superimposed over the TGeo geometry (in a Canvas
or better in OpenGL).
Actually the tracks are visualized only in G4visualization mode.
I created the TGeoTrack in Ex03MCApplication::PreTrack() in this way:


Int_t theCurrentTrackId = gMC->GetStack()->GetCurrentTrackNumber();
TParticle* theCurrentParticle=gMC->GetStack()->GetCurrentTrack();
Int_t
theTGeoTrack_index=gGeoManager->AddTrack(theCurrentTrackId,theCurrentParticle->GetPdgCode(),theCurrentParticle);
TVirtualGeoTrack* theTGeoTrack=gGeoManager->GetTrack(theTGeoTrack_index);


Then I have to AddPoints to track and Draw with:


theTGeoTrack->AddPoint(Xtrack,Ytrack,Ztrack,Ttrack);
gGeoManager->DrawTracks("/*");


My question is how can I have access to all points of a track for each step, in order to fill in AddPoint? Should I use
TG4StepManager GetTrack() method, and then G4Track method GetPosition()?
Is my procedure correct?

Could you help me?

Thanks a lot in advance.

Hi Simone,

You have to create the TGeoTrack only when you get a new track index (e.g. store the current one). As well, in Ex03Application::Stepping() you have to check if the current track is the stored one, then you can add the point as you suggested to the current TGeoTrack.

You will not be able to visualize in OpenGL TGeoTrack objects.

Regards,