Hi Deborah,
In your first program creating the red Tree, you should
-create the output file z
-create the Tree red
-loop on entries of the input Tree
-red->Fill(); as you do now
-red->Write();
Rene Brun
On Wed, 14 May
2003, Deborah Joanne Bard wrote:
>
> Hello Root,
> I'm using Red Hat Linux 7.3 and Root version 3.03/09 (the best that's
> available at babar!).
> I've got a problem reading a Tree after it's been put into a TChain. I
> have one program that takes existing .root files, loops over them to make
> a selection cut, then writes the outcome as more .root files. I can look
> at these files all I want with TBrowser, all the data is there. My problem
> comes when I try to use it as part of another program to fit the results.
> In this second program I chain together the files, but when I try to read
> what's in the chain I get errors in TFile::ReadBuffer. This doesn't happen
> when I run the fitting program over the original uncut files. Is there
> some 'special' way of writing the file I should have thought of? I've
> checked the file permissions, tried on 3 different machines and I'm
> running out of ideas.............
> First program:
>
> Int_t nentries = Int_t(fChain->GetEntries());
> for (Int_t i1=0; i1<nentries;i1++)
> {
> fChain->GetEntry(i1);
> if( iType==trueiType && fabs(mKstar-trueMassHad)<.05)
> {red->Fill();}
> }
> TFile *z= new
> TFile("/afs/slac.stanford.edu/g/babar/work/d/djbard/level2/cnc.root",
> "RECREATE", "output from BestCand");
> z.cd();
> red->Write("red");
>
>
>
> Second program:
>
> TChain* signalCH = new TChain("red");
>
> signalCH.Add("/afs/slac.stanford.edu/g/babar/work/d/djbard/level2/cnc.root",
> 0);
>
> signalCH.Add("/afs/slac.stanford.edu/g/babar/work/d/djbard/level2/ncc.root",
> 0);
>
> TTree *signalCHTree = signalCH;
> char *massbin[] = new char;
> *massbin[]= "mKstar>=1.0 && mKstar<1.1";
> TTree *signalCHTree = signalCH;
> signalCHTree = signalCH->CopyTree(massbin[]);
>
> this results in:
>
> Error in <TFile::ReadBuffer>: error reading all requested bytes from file
> /afs/slac.stanford.edu/g/babar/work/d/djbard/level2/cnc.root, got 0 of
> 20629
> Error in <TFile::ReadBuffer>: error reading all requested bytes from file
> /afs/slac.stanford.edu/g/babar/work/d/djbard/level2/cnc.root, got 0 of
> 20629
> Error in <TFile::ReadBuffer>: error reading all requested bytes from file
> /afs/slac.stanford.edu/g/babar/work/d/djbard/level2/cnc.root, got 0 of
> 20629
> etc etc
>
> There was a similar question in RooTalk a while ago that suggested using:
> signalCH->GetEntry(0);
> TTree *signalCHTree = (TTree*)signalCH->GetTree()->CloneTree(0);
> but that gives exactly the same error.
>
> Any ideas?
> Thanking you in advance,
> Debbie
>
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET