Primary and secondary particles

Hi G4ers,

I have a question about primary and secondary particles in GEANT4.

In this platform I saw somewhere for secondary particles said we can use: if (step->GetTrack()->GetTrackID() == 1)…
How we can calculate energy deposition of secondary particles?

or
in another topic
auto secondary = step->GetSecondaryInCurrentStep();
size_t size_secondary = (*secondary).size();

if (size_secondary){
for (size_t i=0; i<(size_secondary);i++){…

Actually, I’m confused. So I decided on the below orders.
is it correct that if we want to get information about primary particles, we use this order
if (step->GetTrack()->GetParentID() == 0)
{

}

and for secondary particles, we use this one:
if (step->GetTrack()->GetParentID() != 0)
{

}
Please let me know if I am wrong

Thank you
mohaddeseh