How to get first step in a volume

Hi everyone.

I’m trying to get first step information in a volume like this.

 if(step->IsFirstStepInVolume() && step->GetTrack()->GetParentID()==1)
        G4cout << "step number = " << step->GetTrack()->GetCurrentStepNumber() << G4endl;

When a particle arrives at the volume called PMT form other volumes, it’s current step number will be printed on the screen.

* G4Track Information:   Particle = opticalphoton,   Track ID = 10351,   Parent ID = 1

Step#    X(mm)    Y(mm)    Z(mm) KinE(MeV)  dE(MeV) StepLeng TrackLeng  NextVolume ProcName
   0 9.95e-05 0.000673    -19.6   2.9e-06        0        0         0      Target initStep
   1     86.8     -125     -0.7   2.9e-06        0      153       153         PMT Transportation
   2      101     -145     2.38   2.9e-06  2.9e-06       25       178         PMT OpAbsorption
step number = 2

Like this. However, The information of step number 2 is not what I what. How do I change the judgment.

Could you please clarify your question. Is your concern that you’re actually getting the second step in the volume because the current step number which you printed is 2?

If that is your concern I think you might be misunderstanding the meaning of the value returned by “GetCurrentStepNumber()”. Your track could take say, 100 steps in some other volume before reaching the PMT volume. Then, once your track reaches PMT, when you call “GetCurrentStepNumber()” you will find that the current step number is 101. But it is still the first step in your PMT volume, which is what you are looking for.

I hope this is helpful,


Edit: When you are filling your NtupleDColumn, are you accessing the step’s preStepPoint or postStepPoint? Accessing the preStepPoint might yield the information you’re looking for.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.