Re: trouble with trees

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Apr 06 1999 - 18:52:32 MEST


Hi Peter,
I cannot reproduce your problem. Please specify which version/machine
you are using.
Could you run the following test (from your example)?

Rene Brun


{
   TFile *f = new TFile("peter.root","recreate");
   Int_t nPhot;
   Float_t E[500];
   Float_t Px[500];
   Float_t Py[500];
   Float_t Pz[500];
   Float_t Arm[500];
   Float_t PhotProb[500];

   TTree* nEmcPhotons = new TTree("nEmcPhotons","EMC Photons");
   nEmcPhotons->Branch("nPhot",&nPhot,"nPhot/I");
   nEmcPhotons->Branch("E",E,"E[nPhot]/F");
   nEmcPhotons->Branch("Px",Px,"Px[nPhot]/F");
   nEmcPhotons->Branch("Py",Py,"Py[nPhot]/F");
   nEmcPhotons->Branch("Pz",Pz,"Pz[nPhot]/F");
   nEmcPhotons->Branch("Arm", Arm,"Arm[nPhot]/F");
   nEmcPhotons->Branch("PhotProb", PhotProb,"PhotProb[nPhot]/F");

   for (Int_t i=0;i<1000;i++) {
      nPhot = 500*gRandom->Rndm();
      for (Int_t j=0;j<nPhot;j++) {
         E[j] = j;
         Px[j] = j+1;
         Py[j] = j+2;
         Pz[j] = j+3;
         Arm[j] = j+4;
         PhotProb[j] = j+5;
      }
      nEmcPhotons->Fill();
   }
   nEmcPhotons->Print();
   nEmcPhotons->Write();
   f->Close();
   delete f;
}







Peter Steinberg wrote:
> 
> Hello -
> 
> Now, I thought i knew how to make trees with variable length branches:
> 
>    Int_t nPhot;
>    Float_t E[500];
>    Float_t Px[500];
>    Float_t Py[500];
>    Float_t Pz[500];
>    Float_t Arm[500];
>    Float_t PhotProb[500];
> 
>    TTree* nEmcPhotons = new TTree("nEmcPhotons","EMC Photons");
>    nEmcPhotons->Branch("nPhot",&nPhot,"nPhot/I");
>    nEmcPhotons->Branch("E",E,"E[nPhot]/F");
>    nEmcPhotons->Branch("Px",Px,"Px[nPhot]/F");
>    nEmcPhotons->Branch("Py",Py,"Py[nPhot]/F");
>    nEmcPhotons->Branch("Pz",Pz,"Pz[nPhot]/F");
>    nEmcPhotons->Branch("Arm", Arm,"Arm[nPhot]/F");
>    nEmcPhotons->Branch("PhotProb", PhotProb,"PhotProb[nPhot]/F");
> 
> now when i Fill() this tree and save it to a file and then try and read it
> back
> and Draw() any of the variable-length fields, i get:
> 
> root [0] TFile f("nEmcPhotons.root")
> root [1] nEmcPhotons->Draw("Pz")
> Warning in <MakeDefCanvas>: creating a default canvas with name c1
> Warning in <TBranch::GetBasket>: Estimated keylen too small=15697
> Fatal in <operator new>: storage exhausted
> aborting
> 
> making bufsize=128000 in the Branch() calls does not help...
> 
> - Peter



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:31 MET