I am trying to run an adjusted version of the pythia8.C macro (from the root tutorials) in which I want to select all pions of which the mother particle is a lambda c baryon. I have been trying to use the ‘GetFirstMother’ command, but then I realized I don’t know what kind of information this command delivers. In the description of the command it says it returns the ‘mother particle indices’, but I don’t know what that means. Is there anyone out here who can explain to me how I can select particles based on of which particles they are the decay products?
GetFirstMother() gives you the index of the mother in the particle stack.
TParticle* part = (TParticle*) particles->At(indexMother);
to retrieve the corresponding TParticle.
(above, ptPionH and ptPionlH are histograms I have defined in the code)
Now it seems that the code does what I want it to do. It returns the transverse momentum distribution of all pions and it returns the momentum distribution of pions originating from lambda_c baryons. The only problem is that it gives me the following error for a huge amount of particles:
Error in TClonesArray::At: index -1 out of bounds (size: 4000, this: 0x555e943a50c0)
Could you tell me how it is possible that a particle has index -1 and maybe how to prevent this error?