| Summary: | G4AnalysisManager creates ROOT files that are not updateable | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | seligman |
| Component: | analysis | Assignee: | Ivana Hrivnacova <ivana> |
| Status: | ASSIGNED --- | ||
| Severity: | normal | ||
| Priority: | P4 | ||
| Version: | 11.1 | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: |
A file output from a Geant4 simulation using G4AnalysisManager
A file after the described "open with update", followed by an immediate close Tar file with a fix |
||
|
Description
seligman
2023-10-24 00:28:24 CEST
Created attachment 830 [details]
A file after the described "open with update", followed by an immediate close
Hit the wrong button... I've attached copies of the file from the same run of the Geant4 simulation that used G4AnalysisManager. The "works" file is before the example ROOT lines were executed, the "broken" file is after. To compare the files, load them in ROOT and examine the result of scanning the LArHits ntuple: # root gramsg4-works.root root [0] LArHits->Scan() root [1] .q # root gramsg4-broken.root root [0] LArHits->Scan() root [1] .q Hello, Thank you for reporting this problem. We have found that it was already reported in ROOT forum two years ago (https://root-forum.cern.ch/t/opening-a-file-in-update-mode-causes-error-in-tbasket-streamer-the-value-of-fnbytes-is-incorrect/43340), however we were not notify about it at that time. There is also suggested the following work-around that can be used until the problem is fixed in Geant4: "The geant4 reimplementation has a flaw that makes the file not update-able. Instead you need to first copy the file with ROOT (hadd -f output_updatable.root output_good.root) then update the copy." Best regards, Hi, That work-around was discussed in the ROOT page I referenced in my original report: https://root-forum.cern.ch/t/appending-to-file-opened-in-update-mode-corrupts-file/56801 I implemented it within a C++ routine within my Geant4 simulation: https://github.com/wgseligman/GramsSim/blob/develop/GramsG4/g4util/src/FixAnalysis.cc However, this does not solve the problem within Geant4. It also wastes disk space. Is there any timescale for a G4 fix? Or will it be left to the future GeantV + ROOT7 integration? Hi, You wrote: "According to problem ID 1534, this was problem was fixed in Geant4.9.6. However, it still exists in Geant4.11." Where was this problem reported ? The problem with this ID in Geant4 bugzilla is not related to analysis. The 'g4tools' developer is working on the fix, which will be integrated in Geant4 as soon as possible, we hope it will be still in the coming release, 11.2. Best regards, Created attachment 835 [details]
Tar file with a fix
Hello, The problem is now fixed in Geant4 development version; I attach a tar file that can be unpacked in the geant4 top directory; it contains only one file: source/externals/g4tools/include/tools/wroot/file It fixes the problem with updating a Root file in our tests (with the Root file produced with example B4); but it would be useful if you can check that it works also in your application. With best regards, |