# No data filled to H3 when using MT mode

**URL:** <https://geant4-forum.web.cern.ch/t/no-data-filled-to-h3-when-using-mt-mode/14020>\
**Category:** Recording, Visualizing and Persisting Data\
**Created:** [April 23, 2025, 9:07am UTC](https://geant4-forum.web.cern.ch/t/no-data-filled-to-h3-when-using-mt-mode/14020 "2025-04-23T09:07:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sai\_Ma](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/sai_ma/32/9900_2.png) [@Sai\_Ma](https://geant4-forum.web.cern.ch/u/Sai_Ma)\
**Post date:** [April 23, 2025, 9:07am UTC](https://geant4-forum.web.cern.ch/t/no-data-filled-to-h3-when-using-mt-mode/14020/1 "2025-04-23T09:07:34Z")

</div>

I am currently working on scoring energy deposition in 3D histograms. When I use `G4RunManager` in non-multithreading (sequential) mode, the results appear correctly. However, after switching to multi-threading mode,`G4MTRunManager`, the scoring results always show zero.

Could you please advise what might be causing this issue, or suggest any points I should check when implementing scorers in MT mode?

Thanks!  
Masai

 ![image](https://geant4-forum.web.cern.ch/uploads/default/original/2X/2/2bc33fad0cf9ddea4ba8818fc1e2a5b359f3240d.png)

```auto
//this is my runaction.cc
void RunAction::BeginOfRunAction(const G4Run* run)
{
    G4AccumulableManager* accumMgr = G4AccumulableManager::Instance();
    accumMgr->Reset();

    auto analysisManager = G4AnalysisManager::Instance();
    analysisManager->SetNtupleMerging(true);    
		analysisManager->Reset();  
       // if (IsMaster()) {
            analysisManager->OpenFile("SWG_Target_Edep3D");
     // }
        // 0
        analysisManager->CreateH3("Edep3D_MeV", "Energy Deposition (MeV)",
            fBinX, -fMeshX, fMeshX,
            fBinY, -fMeshY, fMeshY,
            fBinZ, -fMeshZ * 2, 0.0,
            "mm", "mm", "mm");
        //1
        analysisManager->CreateH3("Edep3D_joule", "Energy Deposition (joule)",
            fBinX, -fMeshX, fMeshX,
            fBinY, -fMeshY, fMeshY,
            fBinZ, -fMeshZ * 2, 0.0,
            "mm", "mm", "mm");
  // }
}

void RunAction::EndOfRunAction(const G4Run* run)
{
    G4AccumulableManager::Instance()->Merge();
        auto analysisManager = G4AnalysisManager::Instance();
        analysisManager->Write();
        analysisManager->CloseFile(false);
    }
}

```

```auto
void SteppingAction::UserSteppingAction(const G4Step* step)
{
    G4double nonIonEdep = step->GetNonIonizingEnergyDeposit();
    G4double totalEdep = step->GetTotalEnergyDeposit();

    G4StepPoint* preStep = step->GetPreStepPoint();
    G4ThreeVector pos = preStep->GetPosition();

    if (totalEdep <= 0.) return;

    G4VPhysicalVolume* volume =
        step->GetPreStepPoint()->GetTouchableHandle()->GetVolume();

    G4String volumeName = volume->GetName();
        if (volumeName == "Target") {

            auto analysis = G4AnalysisManager::Instance();
			G4int Edep3D_MeV_id = analysis->GetH3Id("Edep3D_MeV");

            //G4cout
            // << "User messager: [Thread " << G4Threading::G4GetThreadId()
            // << "] Filling at " << pos
            // << " edep(MeV)=" << totalEdep / MeV
            // << G4endl;

            analysis->FillH3(0, pos.x(), pos.y(), pos.z(), totalEdep / joule);
            analysis->FillH3(Edep3D_MeV_id, pos.x(), pos.y(), pos.z(), totalEdep / MeV);
        }
}

```

\_Geant4 Version:\_11.3  
\_Operating System:\_Ubuntu 24.04.01 LTS  
\_Compiler/Version:\_13.3.0  
\_CMake Version:\_3.28.3

* * *

---

<div class="post-metadata">

**Author:** ![ivana](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/ivana/32/186_2.png) [@ivana](https://geant4-forum.web.cern.ch/u/ivana)\
**Post date:** [April 30, 2025, 1:42pm UTC](https://geant4-forum.web.cern.ch/t/no-data-filled-to-h3-when-using-mt-mode/14020/2 "2025-04-30T13:42:00Z")

</div>

Hello,

Can you confirm that you create your `RunAction` both on master and workers ? (It should be done in both `ActionInialization::Build()` and `ActionInialization::BuildForMaster()` functions.)

Also, histograms should be created only once per program execution, so it is better to move the code, where you create them, from `BeginOfRunAction` to the `RunAction()` (constructor).

Best regards,
