Hi Antonio,
In your original form, TTree::Branch has no way to find the address
of cpat[0] because it does not know the maximum value for nc
Rene Brun
On Wed, 29 May 2002, Antonio Sidoti tel. +39+0461 88 1525 wrote:
> Hi,
> I've solved the problem by doing :
>
> tree->Branch("nc",&nc,"nc/I");
> tree->Branch("vars",patn.vars,"var[20][nc]/F");
> tree->Branch("cpat",patn.pat,"pat[nc]/F");
> tree->Branch("epat",&patn.evt,"evt/F");
> (as reported in the manual:-))
>
> However I am interested to know why the original guess gives wrong
> results...
>
> tree->Branch("nc",&nc,"nc/I");
> tree->Branch("Comb",&patn,"var[20][nc]/F:cpat[nc]/F:evt/F");
> (and tried some other combinations)
>
> Any suggestions?
> Thanks
> Cheers,
> Antonio
>
>
>
> ---------- Forwarded message ----------
> Date: Wed, 29 May 2002 17:33:04 +0200 (MET DST)
> From: Antonio Sidoti tel. +39+0461 88 1525 <sidoti@science.unitn.it>
> To: roottalk@pcroot.cern.ch
> Subject: Problems creating a TTree....
>
> Dear Rooters,
> I really do not understand what's going on while I create and write a
> TTree.
>
> Cf the snipped pippo.C and pippo.h below. The problem is that
> whhen I open the root file I've created, the branches do not contain what
> it was supposed to be inserted (To check that I fill
> some histos with the BB_* variables and draw them)
>
> Thanks alot,
> Cheers,
> Antonio
> P.S. Using 3.02/07
>
> Here are the pippo.C and pippo.h (the usual stuff
> generated by MakeClass):
>
> // pippo.h
> typedef struct {
> Float_t vars[20][3000];
> Float_t pat[3000];
> Float_t evt;
> } PAT;
> class Myanal {
> public :
> ...
> };
>
> //----------- pippo.C
> #include "pippo.h"
> #include "TH2.h"
> #include "TStyle.h"
> #include "TCanvas.h"
>
> void MyAnal::Loop()
> {
> PAT patn;
> TH1F *h_pat = new TH1F("h_pat","pat",50,0,1);
> TFile f1("pip.root","RECREATE");
>
> TTree *tree = new TTree("tree", "xxxx");
> Int_t nc;
> tree->Branch("nc",&nc,"nc/I");
> tree->Branch("Comb",&patn,"var[20][nc]/F:cpat[nc]/F:evt/F");
> (...)
> for (Int_t jentry=0; jentry<nentries;jentry++) {
> Int_t ientry = LoadTree(jentry);
> nb = fChain->GetEntry(jentry);
> if(BB_nc==0) continue;
> nc = BB_nc;
>
> for(Int_t it = 0; it<BB_nc;++it){
> patn.vars[0][it] = BB_v1[it];
> patn.vars[1][it] = BB_v2[it]; // etc...
>
> patn.cpat[it] = BB_p[it];
> }
> patn.evt = BB_a;
> h_pat->Fill(BB_a);
> tree->Fill();
> }
> tree->Write();
> }
>
>
>
> _______________________________________________________________________________
> a n t o n i o s i d o t i
>
> e-mail sidoti@science.unitn.it
> sidoti@fnal.gov
> www http://higgs.tn.infn.it/~sidoti/
> _______________________________________________________________________________
> "Il meglio e` nemico del buono"
>
>
>
>
>
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:54 MET