Problem 1633

Summary: RootAnalysisManager deletes files containing only ntuples as empty in MT mode
Product: Geant4 Reporter: Jed Leggett <ehl7>
Component: analysisAssignee: Ivana.Hrivnacova
Status: RESOLVED FIXED    
Severity: normal    
Priority: P5    
Version: 10.0   
Hardware: All   
OS: All   
Attachments: The code with fixed method G4RootAnalysisManager::CloseFileImpl()

Description Jed Leggett 2014-05-30 06:35:05 CEST
If one tries to write a Root file containing only ntuples, the analysis manager incorrectly deletes the file as empty.  This is due to the following code:

In G4RootAnalysisManager.cc lines 321-324:

  // Delete files if empty in MT mode
  if ( ( fState.GetIsMaster() && 
         fH1Manager->IsEmpty() && fH2Manager->IsEmpty() ) || 
       ( ( ! fState.GetIsMaster() ) && fNtupleManager->IsEmpty() ) ) {

The code should instead look for both empty histogram managers AND an empty ntuple manager as follows:

  // Delete files if empty in MT mode
  if ( ( fState.GetIsMaster() && 
         fH1Manager->IsEmpty() && fH2Manager->IsEmpty() ) && 
       ( ( ! fState.GetIsMaster() ) && fNtupleManager->IsEmpty() ) ) {
Comment 1 Ivana.Hrivnacova 2014-06-03 18:20:07 CEST
Created attachment 273 [details]
The code with fixed method G4RootAnalysisManager::CloseFileImpl()
Comment 2 Ivana.Hrivnacova 2014-06-03 18:22:40 CEST
The incorrect delete happens when an application is built against Geant4 MT libraries and runs in sequential mode. (If running in MT mode, the ntuples are written in files per thread and the base file remains empty.) 

The problem has been fixed in the development version and the fix will be also provided in patch02 to 10.0 release. (The code of the modified method in G4RootAnalysisManager.cc for the patch02  is also provided in the attachment.)

Best regards