Re: Memory resident tree

From: Chiara Zampolli <Chiara.Zampolli_at_bo.infn.it>
Date: Fri, 28 Sep 2007 10:49:01 +0200


Thanks Rene, now it works. I tried with:

TH1::SetDirectory(0);

(I thought ingenuously it would have been ok also for trees... :-) ) but it didn't work... Now with your suggestion, it works! BTW, the error was:

...
> > > E-TTree::Fill: Failed filling branch:TOFCalib.TOFentries, nbytes=-1
> > > This error is symptomatic of a Tree created as a memory-resident Tree
> > > Instead of doing:
> > > TTree *T = new TTree(...)
> > > TFile *f = new TFile(...)
> > > you should do:
> > > TFile *f = new TFile(...)
> > > TTree *T = new TTree(...)
> > > This error is symptomatic of a Tree created as a memory-resident Tree
> > > Instead of doing:
> > > TTree *T = new TTree(...)
> > > TFile *f = new TFile(...)
> > > you should do:
> > > TFile *f = new TFile(...)
> > > TTree *T = new TTree(...)
> > > <message repeated 1 time>
> > > ...
> > >
> > >

but I guess you know it...
Thanks a lot,
cheers,
Chiara

Rene Brun wrote:
> Chiara,
>
> >How should I avoid this error?
> Which error ?
>
> To force a memory-resident Tree, do
> fTree = new TTree("TOFCalib","Tree for TOF Calibration");
> fTree->SetDirectory(0);
>
> Rene Brun
>
>
> Chiara Zampolli wrote:
>> Dear rooters,
>>
>> I have a problem with a method of a class where I have to build a
>> tree starting from some other trees saved in files (the final tree is
>> created with CopyEntries inside a loop). In particular, the problem
>> lies on the fact that I first create the final tree, and the open the
>> files where the others are in read mode. Here you can find the code:
>>
>> void AliTOFcalib::CreateTreeFromGrid(Int_t minrun, Int_t maxrun){
>>
>> // creating the chain with the trees for calibration
>> // collecting them from reference data
>> // from minrun to maxrun
>>
>> Float_t p[CHENTRIESSMALL];
>> Int_t nentries;
>> fTree = new TTree("TOFCalib","Tree for TOF Calibration");
>> fTree->Branch("nentries",&nentries,"nentries/I");
>> fTree->Branch("TOFentries",p,"TOFentries[nentries]/F");
>> AliInfo("connected to alien");
>> TGrid::Connect("alien://");
>>
>> Char_t filename[100];
>> for (Int_t irun = minrun;irun<=maxrun;irun++){
>>
>> sprintf(filename,"alien:///alice/cern.ch/user/c/czampolli/TOFCalibReference_%i.root",irun);
>>
>> TFile *filegrid = TFile::Open(filename,"READ");
>> TTree *tree = (TTree*)filegrid->Get("T");
>> tree->SetBranchAddress("nentries",&nentries);
>> tree->SetBranchAddress("TOFentries",p);
>> fTree->CopyEntries(tree);
>> delete tree;
>> fNruns++; }
>>
>> The fTree, as you can see, is a private member of the class.
>> Moreover, I don't need to write fTree on a file, for this reason I
>> create it without opening any file.
>> How should I avoid this error?
>> Thank you a lot in advance.
>> Best Regards,
>> Chiara
>> AliInfo(Form("Number of runs being analyzed %i",fNruns));
>> }
>>
>
Received on Fri Sep 28 2007 - 10:47:20 CEST

This archive was generated by hypermail 2.2.0 : Sun Sep 30 2007 - 17:50:02 CEST