Hi Luigi, Setting a flag in memory does not modify the data base. Whay you can do is something like TFile f1("oldfile.root"); TTree *oldTree = (TTree*)f1.Get("treename"); MyClass *a = 0; oldTree->SetBranchAddress("branchname",&a); TFile *f2 = new TFile("newfile.root","recreate"); TTree *newTree = oldTree->CloneTree(0); Int_t nentries = oldTree->GetEntries(); for (Int_t i=0;i<nentries;i++) { oldTree->GetEntry(i); if event is not OK continue; SetFlag(...) newTree->Fill(); } newTree->Write(); f2->Close(); Rene Brun Luigi Bardelli wrote: > > Dear ROOTers, > > (Probably a beginner question...) > This is my problem: after creating an unsplit TTree made of MyEvent > objects with inside some Signal objects and rereading it from disk, > I'd like to scan all the events, make some selections, and upgrade > some flag INSIDE the Signal Object (I'd like also to upgrade the file on > disk). I have provided the following methods: > > void Signal::SetFlag(int value) > Signal* MyEvent::GetSignal() > // to retrieve a pointer to the > // Signal Object > > I've tried with TTree::MakeSelector("SetFlag"), with these modifications: > .... > => void SetFlag::ProcessFill(Int_t entry) > => { > => // function called for selected entries only > => // entry is the entry number in the current Tree > => // read branches not processed in ProcessCut and fill histograms > => // to read complete event, call fChain->GetTree()->GetEntry(entry) > => fChain->GetTree()->GetEntry(entry); > => int i,newFlag; > => Signal *s; > => s=MyBranch->GetSignal(); > => /*-- here I compute newFlag --*/ > => ... > => /*----------------------------*/ > => s->SetFlag(newFlag); > => } > > and > > => void SetFlag::Terminate() > => { > => // function called at the end of the event loop > => f->Write(); > => } > > where f (global at the moment) is the file containg the TTree. > Every event is processed in the right way, but > nor the file on disk, neither the TTree here in memory change. > > Someone can help me? > > Thank you very much > Luigi Bardelli
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:35 MET