Generate root file in multi-thread mode

Dear all,
I want to generate a tree to record each step’s coordinates of each event based on example B4a. I use vector to do that. A vector means a event, and it would contain all the steps’ coordinates. Of course, I can’t use G4AnalysisManager because it only can fill “double”, “int”, and “float”. I write another file such as “B4aAnalysisManager” to do that. And it can be run in single thread successfully. But when multi-thread, it mentioned me
“Break Segmentation violation”. I tried use G4AutoLock to lock the file, but it seems not work. Is there any reference? Or any suggestions?
Thanks

The B4aAnalysisManager is just like follows, and I added them into B4RunAction, B4aEventAction and B4aSteppingAction.

class B4aAnalysisManager{
public:
        virtual ~B4aAnalysisManager();

        static B4aAnalysisManager* Instance();

        void FillTree();
        void Book();
        void CloseFile();
        void Back(G4double b, G4double c, G4double d, G4double e);
        void ClearV();

private:
        B4aAnalysisManager();
        static B4aAnalysisManager* instance;

        TFile* fFile;
        TTree* fTree;

};

Hello,

This is a ROOT problem, so you should ask help at the ROOT forum.

I would just like to point that G4AnalysisManager allows to create ntuples with vector columns, see:

https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/Analysis/managers.html#ntuples

Best regards,