Getting Primary particle info from a ROOT file

I am trying to produce gamma rays as primary particles. But the position and energy of the gamma rays are stored in a root file in branches of a TTree, such as x, y, z, and E for the position and energy.
How can I read the root file and get the values from the branches to feed into my
particleGun->SetParticlePosition() and particleGun->SetParticleEnergy().


you can have a look in the analysis reader classes, where it explains how to read a tuple from a root file.

Thanks @psaxioti . I looked into the document. It is very helpful. I am facing another problem. My Root file has tree and then branches. In the analysisReader->GetNtuple() I have to put the branch (if I am understanding it correctly) as that has n entries. But after setting the file name (analysisReader->SetFileName()) and before the getting NTuple, how can I specify which branch I want?

Dear Victoria,
you misunderstand the document.
The GetNtuple function “finds” the tuple by name in the root file, since you could have more than one.
Afterwards you have to “assign” the branch(es) that interest you to a variable(s) with the appropriate type with the SetNtupleXColumn function, where X can be I (for int), F (for float), D (for double) or S (for string).
Then you read the tuple row by row, so after each call of the GetNtupleRow the assigned variable has the value that interests you.

Hope this clarifies the procedure.

I see. Thank you @psaxioti . Appreciate your help.