Re: [ROOT] TFolder or TDirectory?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Jan 14 2002 - 21:45:12 MET


Hi Christian,

On Mon, 14 Jan 2002, Christian Holm Christensen wrote:

> > We had several iterations on this point last fall. We want to
discourage
> > updating branches of a tree. An alternative with Tree friends
> exists.
>
> I didn't mean doing TBranch::Fill.  No, what I mean was, if you have a
> TTree like
>
>    A*      a    = 0;
>    B*      b    = 0;
>    TTree*  tree = new TTree("T", "A Tree");
>    tree->Branch("A", "A", &a);
>    tree->Branch("B", "B", &b);
> 
> and then for a given instance only want to fill a, that is, b = 0:
>    
>    // Fill number n
>    a = new A;
>    b = 0;
>    tree->Fill();
> 
> What happens when you read back that entry?  Supposing that you do
>
>    A*      a    = 0;
>    B*      b    = 0;
>    TTree*  tree = (TTree*)gDirectory->Get("T");
>    tree->SetBranchAddress("A", &a);
>    tree->SetBranchAddress("B", &b);
>   
>    ...
> 
>    tree->GetEntry(n);
> 
> Will b == 0? 

Yes

Or will it be created according to the default CTOR?

No
   
> What if objects of class A or B is put in a TClonesArray that is  
> stored on a branch, and you do TClonesArray::Clear() to limit the
> numbers of new/delete mesages?  This is what I meant!

I do not understand this point. Do you mean that the TClonesArray is empty
when you Fill the branch? This is Ok. When you will read back, you will
find that the number of entries in the array is null.


> 
> Another question: Is it possible to have a TRef member pointing to
> another object in a different entry?  Since the TRef does not work by
> address, I guess it can.

Yes, you can. However, read TRef::SetObjectCount/GetObjectCound.
See, for example, the way it is used in $ROOTSYS/test/Event::Build

>    
> > > To this end, it would be nice to have some sort of SQL search
> > > functions in TTree.  I believe it's doable.  What is needed is an
SQL
> > > parser and a translator from SQL to the regular ROOT selection
> > > mechanism.
> > >
> >
> > Not a very efficient way to make a query to a Tree. We already have
> > TTreeResult, TTreeRow, TTree::Query. Anything beyond that is likely to
be
> > application dependent and can be coded with a few lines of code.
> 
> Well, it may not be efficent, but it makes it easier to have ROOT drop
> in as the database backend.  The idea is simply that you should be
> able to have
>    
>    
>   TSQLServer* serv =
>     TSQLServer::Connect("url", "db", "user", "passwd");
>   TSQLResult* res  = serv->Query("SELECT * FROM Runs WHERE runno=1234");
> 
> The idea then that if "url" is of the form "root://host/dir/file", then
a
> connection (via rootd) to the TTree "db" in the file "dir/file" is
> setup, but it could also be "mysql://host" or what ever.  That would
> really  make it flexible.  And who cares if it takes 1 ms or 2 ms to
> query for information on a run, if that's something you do once or
> twice per job.

OK, you simply want a translation mechanism from SQL format to TTree::Draw
format. You can do this by extending TTreeFormula to support an SQL query.
If you provide the function and test it on multiplatforms, I will 
include it in the source.

Rene Brun



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