If I don’t clean the variable, I get an uncorrect number of entries. (larger that simulated particles). Then, I don’t know how to save in the TTree fPos.x(), fPos.y(), fPos.z(), fkinE, fmom.theta .
Thanks
After reading your post, it’s not immediately apparent to me where are you placing the call to ClearVariables(). In principle, you should do it before the first call to FillhPrimaries(), for each entry in the TTree.
OT: Additionally, instead of calling resize(0), you can do clear(), which I find more descriptive.
Instead, fillprimary particles is called in primarygeneratoraction file.
Then following your suggestion to clear the variables before than fillprimaryparticles, I added the call to a new function in primarygeneratoraction file
Sorry for the delayed reply. Given that the problem was tied to your specific case, I don’t think it’s worth it if you share it with the rest of the community. Anyways, thanks for letting me know!
and it works.
The reason because initially I got a lower number of events was a flag that save all the events or just the detected ones! I forgot to select by the flag to store all the events…then I initially got a lower number of events because they were the detected one! switching on the storage of all simulated events, I got the right number of events!