I am trying to UPDATE root files produced by Geant4 runs. From a Ntuple of this root file I produce many histograms of interest and then would like to write them in the file. I thus create folder in the root file to put them. The idea is also to loop over all the files but I am currently stuck at not corrupting the files.
My main issue is when using the TFile(filename, “UPDATE”), my Ntuple is corrupted after the run of my macro. If I try running the macro again I get
Error in TBranch::GetBasket: File: config300_alpha_6MeV_nucl (copy).root at byte:0, branch:row_wise_branch, entry:0, badread=0, nerrors=1, basketnumber=0
Trying to access a pointer that points to an invalid memory address…
Execution of your code was aborted.
In file included from input_line_8:1:
/home/f069g735/Desktop/essai/Write_histos2.C:92:5: warning: invalid memory pointer passed to a callee: hParticle[hpart]->Fill(step,edep);
If I open the Ntuple file through TBrowser I get the same GetBasket error but still can perform the automatic draw.
Here are the file opened in the macro (not corrupted) and my code:
Write_histos2.C (3.9 KB)
Could you help me understand what I am doing wrong?
Thank you in advance!