Hi,
I want to simply add more data to a Rtuple, respecting the Tree
structure already in it.
Say that every day I want to add 24*60 more pairs, one per minute,
(timestamp, temperature) to a monitoring Rtuple.
This seems to be a really basic thing to do, but I haven’t been able
to find a working example yet. Until now I’ve been RECREATING
the Rtuple afresh every time, and running a bit longer,
but it really seems a silly thing to do. Thanks for any idea!
[code] TFile *file = TFile::Open(“myfile.root”,“update”);
TTree T = (TTree)file->Get(“name of my ntuple”);
//set branch addrees for the Tree
T->SetBranchAddress(“branch1”,address of variable1 or pointer to object1)
T->SetBranchAddress(“branch2”,address of variable2 or pointer to object2)
…
//continue to fill
T->Fill();
//save the header again
T->Write();
delete file;
[/code]
Hi, and thanks for the prompt reply!
I did what you suggested, along these lines:
…
Bool_t startFresh = kFALSE;
TFile* f = 0;
TTree monitor = 0;
if ( startFresh ) {
f = new TFile(“rootOut/monitor.root”,“recreate”);
monitor = new TTree(“monitor”,“monitor TTree”);
monitor->Branch(“timeStamp”,&timeStamp,“timeStamp/i”);
monitor->Branch(“monData”,monData,“monData[15]/F”);
} else {
f = new TFile(“rootOut/monitor.root”,“update”);
monitor = (TTree)f->Get(“monitor”);
monitor->SetBranchAddress(“timeStamp”,&timeStamp);
monitor->SetBranchAddress(“monData”,monData);
}
…
and run the program twice with startFresh = kTRUE, then kFALSE.
Now the problem is, in the output file I have 2 directories,
one for each run, and they both contain the sum of all data.
This is shown in the TBrowser window, and also doing this: