How to store the position when the global run end?

I set a vector in RunAction.cc as

std::vector<std::pair<G4ThreeVector, G4double>>> energyDeposits

It store the positon and energy deposit .
But when i want to get the value and print to a file in EndOfRun as

if(ismaster){
 for (const auto& pair : energyDeposits) {
        const auto& position = pair.first;
        const auto& energy = pair.second;
        outputFile << "Position: (" << position.x() << ", " << position.y() << ", " << position.z() << "), ";
        outputFile << "Energy: " << energy << std::endl;
    }
}

It print nothing.Why?
If not in the master thread,it will print in a wrong order.
Is there any method to print in master thread?Can I use?

G4Accumulable<std::vector<std::pair<G4ThreeVector, G4double>>> energyDepositsAccumulable;

?

There are no particles at end of run.

This method are involked in end of event,and than in each step like:

RunAction.hh
class RunAction : public G4UserRunAction
{
public:
    void FillVector (std::vector<std::pair<G4ThreeVector, G4double>> vec)
    {energyDeposits.insert(energyDeposits.end(),vec.begin(),vec.end());}
private:
    std::vector<std::pair<G4ThreeVector, G4double>> energyDeposits;
};
EventAction.hh:
class EventAction : public G4UserEventAction
{
public:
    void FillVector (std::vector<std::pair<G4ThreeVector, G4double>> vec)
    {energyDeposits.insert(energyDeposits.end(),vec.begin(),vec.end());}
private:
    RunAction* fRunAction = nullptr;
    std::vector<std::pair<G4ThreeVector, G4double>> energyDeposits;
};

void EventAction::EndOfEventAction(const G4Event*)
{
fRunAction->FillVector(energyDeposits);
}
SteppingAction.cc:
void SteppingAction::UserSteppingAction(const G4Step* step){

std::vector<std::pair<G4ThreeVector, G4double>> energyDeposits;
       
G4ThreeVector point = step->GetPostStepPoint()->GetPosition();
       
G4double energyDeposit = step->GetTotalEnergyDeposit();
              
energyDeposits.push_back(std::make_pair(point, energyDeposit));
     
fEventAction->FillVector(energyDeposits);
}
Did the print work in master thread?

Ah, I see. The tracks (and hence steps) only exist in the worker threads. The master thread EndOfRunAction() only gets called after all of the worker threads have finished their work and are closed.

Thanks for answering´╝ü
So, is there any way to get it in my master thread?Like get energy deposition in B1 using G4Accumulable?Because it will print in a wrong order in worker thread.