Output file is empty if HDF5 type

I’m developing a simulation package based on G4AnalysisManager to provide hit info persistency. The code can be found on GitHub. The output looks good for every supported file format, except for HDF5. If I set ::OpenFile("output.hdf5"), this is the output:

... going to create ntuple booking : det000 
... create ntuple booking : det000 ntupleId 0 - done
... going to create ntuple T column :  ntupleId 0 
... create ntuple T column : evtid ntupleId 0 - done
... going to create ntuple T column :  ntupleId 0 
... create ntuple T column : wavelength ntupleId 0 - done
... going to create ntuple T column :  ntupleId 0 
... create ntuple T column : time ntupleId 0 - done
... going to create ntuple booking : det001 
... create ntuple booking : det001 ntupleId 1 - done
... going to create ntuple T column :  ntupleId 1 
... create ntuple T column : evtid ntupleId 1 - done
... going to create ntuple T column :  ntupleId 1 
... create ntuple T column : wavelength ntupleId 1 - done
... going to create ntuple T column :  ntupleId 1 
... create ntuple T column : time ntupleId 1 - done
[...]
... going to open file : output.hdf5 
... going to create ntuple file manager : hdf5 
... going to create file manager : hdf5 
... done create file manager : hdf5
... done create ntuple file manager : hdf5 
... going to open analysis file : output.hdf5 
... going to create fileInformation : output.hdf5 
... going to create file : output.hdf5 
... going to create directory for histograms : default_histograms 
... create directory for histograms : default_histograms - done
... going to create directory for ntuples : default_ntuples 
... create directory for ntuples : default_ntuples - done
... create file : output.hdf5 - done
... open analysis file : output.hdf5 - done
... going to create from booking ntuple : det000 
... done create from booking ntuple : det000 
... going to create from booking ntuple : det001 
... done create from booking ntuple : det001 
... done open file : output.hdf5 
[...]
... going to write files 
... going to open analysis files 
... done open analysis files 
... going to write analysis files 
... going to write hdf5 : files 
... going to write file : output.hdf5 
... write file : output.hdf5 - done
... done write analysis files 
... done write files 
... going to close files 
... going to close analysis files 
... going to close hdf5 : files 
... going to close file : output.hdf5 
... close file : output.hdf5 - done
... done close analysis files 
... going to delete empty files 
... going to delete hdf5 : empty files 
... going to delete empty file : output.hdf5 
... delete empty file : output.hdf5 - done
... done delete empty files 
... going to reset  
... done reset  
... done close files

i.e. no output file is saved. If opening instead output.root (or any other supported format), the program behaves as axpected (see below). I don’t really understand what in the application could be triggering this behavior. Some pointers to the relevant parts in the code:

  • Here and (e.g.) here is where the analysis manager is configured
  • Here is where the output file is opened
  • Here is where the ntuples are filled
  • Here is where files are closed

With ROOT output enabled:

... going to create ntuple booking : det000 
... create ntuple booking : det000 ntupleId 0 - done
... going to create ntuple T column :  ntupleId 0 
... create ntuple T column : evtid ntupleId 0 - done
... going to create ntuple T column :  ntupleId 0 
... create ntuple T column : wavelength ntupleId 0 - done
... going to create ntuple T column :  ntupleId 0 
... create ntuple T column : time ntupleId 0 - done
... going to create ntuple booking : det001 
... create ntuple booking : det001 ntupleId 1 - done
... going to create ntuple T column :  ntupleId 1 
... create ntuple T column : evtid ntupleId 1 - done
... going to create ntuple T column :  ntupleId 1 
... create ntuple T column : wavelength ntupleId 1 - done
... going to create ntuple T column :  ntupleId 1 
... create ntuple T column : time ntupleId 1 - done
[...]
... going to open file : output.root 
... going to create ntuple file manager : root 
... going to create file manager : root 
... done create file manager : root 
... going to set ntuple merging mode 
... set ntuple merging mode : G4NtupleMergeMode::kNone - done
... going to set ntuple merging mode 
... set ntuple merging mode : G4NtupleMergeMode::kNone - done
... set ntuple merging row mode : row-wise - done
... done create ntuple file manager : root 
... going to create ntuple manager 
... done create ntuple manager 
... going to open analysis file : output.root 
... going to create fileInformation : output.root 
... going to create file : output.root 
... create file : output.root - done
... open analysis file : output.root - done
... going to open analysis file : output.root 
... going to create from booking ntuple : det000 
... done create from booking ntuple : det000 
... going to create from booking ntuple : det001 
... done create from booking ntuple : det001 
... open analysis file : output.root - done
... done open file : output.root 
[...]
... going to write files 
... going to open analysis files 
... done open analysis files 
... going to write analysis files 
... going to write root : files 
... going to write file : output.root 
... write file : output.root - done
... done write analysis files 
... done write files 
... going to close files 
... going to notify not empty file : output.root 
... done notify not empty file : output.root 
... going to notify not empty file : output.root 
... going to close analysis files 
... going to close root : files 
... going to close file : output.root 
... close file : output.root - done
... done close analysis files 
... going to delete empty files 
... going to delete root : empty files 
... done delete empty files 
... going to reset  
... done reset  
... done close files 

Can you, please, let me know your version of Geant4?

Yes, sorry, it’s 11.0.2.

Thank you. There is a bug, which was not yet spotted because it affects only HDF5 output. The outut files are remived by mistake in these cases:

  • in sequential mode: if you have only ntuples and no histograms (what seems to be your use case)
  • in MT mode: all ntuple files (produced on workers) are deleted

This problem is already fixed in the Geant4 development version, which is going to be released in December; I will make a fix for the next patch to 11.0.

Thanks a lot Ivana. I think I will also save a dummy histogram as a workaround, while waiting for the next release.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.