Dear all
I’m working on a monte carlo simulation in native C++ that is intended to be run multiple times, writing the final state of the system to a ROOT TFile, then upon the next run resuming from this saved state. I have succeeded in getting this to work. Each saved state is saved in a new TNtupleD with different name.
In addition to the raw state of the system, I have some summary statistics and information I would like calculated at the end of each time the program is run, saved into a TTree.
Currently, I am running
each time the program is executed. While this does work, each time the simulation is run, it creates a new TTree in the TFile with an incremented cycle number. This causes problems when I want to analyse the output or use hadd to merge files.
I want to use something along the lines of
to open the Tree, then append to the end, but the first time it is run, this fails.
Can’t seem to find much information on what I would think is a quite common thing to want to do. I’m very new when it comes to ROOT and not that exprerienced in C++ so it’s quite possible I’m just thinking in the wrong way.
I have also tried to do something along the lines of
TTree* ResultsTree;
if (runtimeslice == 0 ){
ResultsTree = new TTree("starucn_summary","Summary of STARucn output");
}
else{
ResultsTree = (TTree*)(fCore->RootFile)->Get("starucn_summary");
}
[some more stuff]
ResultsTree->Branch("RunID",runidcstr,"RunID/C");
ResultsTree->Branch("Runsection",&runsection,"Runsection/I");
[and so on...]
ResultsTree->Fill();
ResultsTree->Write("", TObject::kOverwrite)
but when this is run with runtimeslice != 0, it just writes a row of zeroes to the file.
If anyone can show me a better way to do this, or show me where I am going wrong I would be very grateful.
Thanks in Advance,
Nick