Re: [ROOT] Question about Tree

From: Jiangyoung Jia (jjia@skipper.physics.sunysb.edu)
Date: Tue Mar 05 2002 - 05:18:37 MET


Dear Rene,
Thanks for answering my question. I got my anwer to the second question.
for the first question,
The reason is that in PHENIX DST, there are about 20 TClonesArray, each
contains it's own subsystem class. In physics analysis code, one
would need to access some of these classes. Of cause if I can remember all
the classes name, I can set the branch address for each of the class. But
since Root provide nice MakeClass feature, which create nice a skeleton
class for me. The only problem with it is now I can't get the pointer to
the classes but instead I got pointer to data member(name is too long,
and also things like poiner to TObject.fBits also been generated which I
don't want) just because the DST have been stored with split level 2!


Thanks ,
Jiangyong



Of couse the easies

On Tue, 5 Mar 2002, Rene Brun wrote:

> Jiangyong,
>
> Why do you want to use TTree::MakeClass if you have access to your
> original class ?
> If the original Tree was produced with something like:
>    MyClass *obj = new MyClass();
>    tree->Branch("top","MyClass",&obj);
>
> in your program reading the Tree, simply do:
>   MyClass *obj = 0;
>   TTree *tree = (TTree*)myfile->Get("tree");
>   tree->SetBranchAddress("top,&obj);
>
> About your second question:
> Create a TChain with the list of all Tree files you want to merge, open a
> new file and use TTree::CopyTree
>
> TChain chain("T");  //assuming "T" is the name of your Tree
> chain.Add("file1.root");
> chain.Add("file2.root");
> TFile *f = new TFile("merge.root","recreate");
> TTree *newT = chain.CopyTree("some selection");
> newT->Write();
>
> Rene Brun
>
>
> On Mon, 4 Mar 2002, Jiangyoung Jia wrote:
>
> > Hello root expert,
> >
> > I have two problems that you might help.
> >
> > Let's say I have a class as following:
> > class myclass:public TObject{
> > float x,y,z;
> > }
> > if I store the class object via TClonesArray in a tree at split level 2,
> > when I use MakeClass functions, individual variables x,y,z will appear in
> > the code. But I really want to have only the pointer to the class in the
> > code. I know this can be done if I save the object at split level <0, but
> > since in PHENIX a lot of DSTs have been produced with split level 2. My
> > question is : Is it possible to convert a Tree produced at split level >0
> > to a tree with split level<0, so the source code produced by MakeClass
> > will only contains pointers to the TObject instead of pointers to the
> > individual varibles of the class?? This will be a very nice feature of
> > Tree!
> >
> > My second question is that Is it possible to merge severl Ntuples together
> > with some cut applied? I search through root digest and can't find any
> > solution. This will be very nice because it can shink Ntuple size by huge
> > factor.
> >
> >
> > Thanks,
> > Jiangyong
> >
>



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:44 MET