GParticle: Some use cases

Find the gamma conversions in the shower (we want e+e-)

    position = Point(far_away);
    4momentum = 0;
    Loop over the particles {
        if (this particle is a gamma) { 
            if (this particle has a child) { 
                // this was a gamma conversion
                // let's check to make sure it went to e+e- 
                // (might not care, depending on implementation)
                if ((child is an electron or a positron) && has a sibling) {
                    if ((sibling is a positron or electron) && (has no sibling) {
                        //This is a gamma->e+e- conversion
                        position = gamma._r;  // decay point of the gamma
                        4momentum = child.4momentum + sibling.4momentum; // momenta of the children
                    }
                }
            }
        }
    }

Starting with an electron, follow the path of the highest-energy electron in the shower (not clear why you would do this, but it exercises conversions and brems)

    this_particle = initial_electron;
    energy = this_particle.energy;
    done = false;
    while ((this_particle has a child) && (not done)) {
        // Bremsstrahlung: will be an electron or a photon
        // (ignoring nuclear interactions for now)
        if (child is an electron) {
           electron1 = child;
           photon = sibling of child;
        } else {
           photon = child;
           electron1 = sibling of child;
        }
        // electron is the highest energy electron in the chain
        e1 = electron1.energy
        if (photon has no child) {
            energy = e1;
            done = true;
        } else {
            // Conversion: pick the electron
            electron2 = ...  // child or sibling of child
            e2 = electron2.energy;
            if (e2>e1) {
                energy = e2;
                this_particle = electron2;
            }
        }
    }