TFoam error?

Dear experts,

I am generating toys using TFoam inside a multiprocessing setup (running many toys in parallel). The job finishes and the output ROOT files are created correctly, but during the run TFoam prints many errors such as:

Error in <TFoam::Carver>: Something wrong with kBest - kBest = -1 dim = 5
STOP in TFoam::PeekMax: not found iCell = -1
Error in <TFoam::Grow>: Wrong iCell

These messages appear repeatedly, even though the final toy ROOT file looks properly formed.

When I run the exact same code in single-process mode, I do not see any TFoam errors. The problem only shows up when using multiprocessing.

So I would like to ask:

Is TFoam thread-safe or multiprocessing-safe?

Does each worker need its own fully independent TFoam instance and RNG?

Can these “kBest = -1” messages be ignored if the output file is okay, or do they indicate a deeper consistency issue?

Is there a recommended way to use TFoam safely in parallel toy production?

I guess @jonas can help you.