Message: Save vectors in Ntuples and multithreading runs Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Save vectors in Ntuples and multithreading runs 

Forum: Analysis
Date: Mar 26, 07:51
From: Matteo Alfonsi <Matteo Alfonsi>

I actually use the G4AnalysisManager to save simple columns to a ROOT TTree in multithread runs, as from B4x examples. In particular currently I define the ntuple in the RunAction constructor:

   auto analysisManager = G4AnalysisManager::Instance();

   analysisManager->CreateNtuple("Task1", "Edep details");
   nID_ELXe = analysisManager->CreateNtupleDColumn("ELXe");

and this works correctly. Now I want to add vector branches with

 nID_single_edeps = // [1]
   CreateNtupleDColumn(ntId, "Edeps", std::vector<float>& vec_single_edeps);

but it is not clear how to proceed to preserve thread safety.

Since the RunAction is replicated for each thread, it looks promising to use a member variable for vec_single_edeps. I think that

However, is the above mentioned call [1] thread-safe within the RunAction constructor? Which nID_single_edeps would be returned in each thread?

In this other post, the declaration of the ntuple is moved within the BeginOfRunAction method ... why? What is supposed to check:

  if (run->GetRunID() == 0) {

taking into account that I do not implement any custom G4Run

Is there any example that fully focus on this?

Thanks in advance, Matteo

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: Save vectors in Ntuples and multithreading runs   (Ivana Hrivnacova - Mar 28, 07:33)
 Add Message Add Message
to: "Save vectors in Ntuples and multithreading runs"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews

[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]