Message: Root file with NTuples treated as empty again Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Root file with NTuples treated as empty again 

Forum: Analysis
Date: 27 Apr, 2015
From: Eduard Friske <Eduard Friske>

Hello,

since I switched my Geant4 installation to geant4-10-01-patch-01 from geant4-10-00-patch2, the Root analysis manager removes my Root files with NTuples as empty.

I already ran across this issue with geant4-10-00-patch1, and the upgrade to patch2 solved it. Or so I thought ...

The code creating the NTuple and writing the data looks as follows:



void B1RunAction::EndOfRunAction(const G4Run* run)
{
	//G4cout << "EndOfRunAction reached, No of neutron events: " << neutrons->size() << G4endl;
	if (IsMaster())
	{
		//G4cout << "EndOfRunAction of master thread reached" << G4endl;
		G4cout << "EndOfRunAction reached, No of neutron events: " << neutrons->size() << G4endl;
		G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
		analysisManager->SetVerboseLevel(4);
		G4cout << "Using " << analysisManager->GetType() << " analysis manager" << G4endl;
		
		G4String fileName = "DetectedNeutrons";
		analysisManager->OpenFile(fileName);
		if (!fileName)
		{
			G4cout << "output file was not opened!" << G4endl;
		}
//		analysisManager->SetFirstHistoId(1);
		
		analysisManager = G4AnalysisManager::Instance();
		
		analysisManager->CreateNtuple("Detector", "Detected Neutrons");
		analysisManager->CreateNtupleDColumn(0, "EKin");
		analysisManager->CreateNtupleDColumn(0, "PosX");
		analysisManager->CreateNtupleDColumn(0, "PosY");
		analysisManager->CreateNtupleDColumn(0, "PosZ");
		analysisManager->CreateNtupleDColumn(0, "MomX");
		analysisManager->CreateNtupleDColumn(0, "MomY");
		analysisManager->CreateNtupleDColumn(0, "MomZ");
		analysisManager->FinishNtuple(0);
		
		for (vector<NeutronData>::iterator iter = neutrons->begin(); iter != neutrons->end(); iter++)
		{
		
		analysisManager->FillNtupleDColumn(0, 0, iter->GetEnergy());
		analysisManager->FillNtupleDColumn(0, 1, iter->GetX());
		analysisManager->FillNtupleDColumn(0, 2, iter->GetY());
		analysisManager->FillNtupleDColumn(0, 3, iter->GetZ());
		analysisManager->FillNtupleDColumn(0, 4, iter->GetPx());
		analysisManager->FillNtupleDColumn(0, 5, iter->GetPy());
		analysisManager->FillNtupleDColumn(0, 6, iter->GetPz());
		analysisManager->AddNtupleRow(0);
		}
		
		G4cout << "NTuple should be filled by now." << G4endl;
		
		analysisManager->Write();
		analysisManager->CloseFile();

		// complete cleanup
		//delete G4AnalysisManager::Instance();
		delete neutrons;
		delete outputMutex;
	}
}

(I know this might not be the best solution, but I want to create a single output file from a multithreaded simulation, and the solutions I found in the manual, examples and elsewhere on the net I could not get to work for my case.
As the actual number of entries in the output file is around 10^4, memory usage is not an issue.)


All checks turn out positive, output shows the entries are there and written to the file, still the file is being deleted afterwards:
(command line output excerpt)

(some more ntuple entries)
... going to add Root ntuple row :  ntupleId 0 
... going to add Root ntuple row :  ntupleId 0 
... going to fill Root ntuple D column :  ntupleId 0 columnId 0 value 2.0253 
... going to fill Root ntuple D column :  ntupleId 0 columnId 1 value -0.00921876 
... going to fill Root ntuple D column :  ntupleId 0 columnId 2 value -0.0109968 
... going to fill Root ntuple D column :  ntupleId 0 columnId 3 value -0.0366492 
... going to fill Root ntuple D column :  ntupleId 0 columnId 4 value -3.81915e-20 
... going to fill Root ntuple D column :  ntupleId 0 columnId 5 value -1.08674e-19 
... going to fill Root ntuple D column :  ntupleId 0 columnId 6 value -1.1136e-19 
... going to add Root ntuple row :  ntupleId 0 
... going to add Root ntuple row :  ntupleId 0 
NTuple should be filled by now.
... going to write Root file : DetectedNeutrons.root 
... write Root file : DetectedNeutrons.root - done
... going to close Root file : DetectedNeutrons.root 
... delete Root empty file : DetectedNeutrons.root - done



Interestingly, when I compile my code with the former (still present) Geant4 installation from which I know that it worked, it now also shows the same erroneous behaviour and deletes the Root file as empty. That's the really weird part I don't understand at all.
As far as I know I did a new, clean install of the new version into a different subdirectory to prevent interference and have a backup system which has failed me big time.

I have run out of options what to do or to check.

If you need additional information or code I'll be glad to present it, and maybe one of you can give me a hint as to what is happening.

Best regards
Eduard

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

1 None: Re: Root file with NTuples treated as empty again   (Ivana Hrivnacova - 28 Apr, 2015)
(_ Ok: Re: Root file with NTuples treated as empty again   (Eduard Friske - 28 Apr, 2015)
 Add Message Add Message
to: "Root file with NTuples treated as empty again"

 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 ]