Hi Maurik, A TChain is a readonly collection of TFiles containing the same TTree structure. One creates the branches in the TTree, not in TChain. I would suggest to have a look at the classes THbookFile, THbookTree, THbookBranch that are wrapper classes to read PAW/Hbook ntuple files and supporting the query facilities of TTree::Draw. These classes can give you some ideas to implement your "translation classes". See: http://root.cern.ch/root/htmldoc/THbookTree.html http://root.cern.ch/root/htmldoc/THbookBranch.html http://root.cern.ch/root/htmldoc/THbookFile.html http://root.cern.ch/root/htmldoc/THbookKey.html Note that THbookChain does not exist in the current implementation. Rene Brun On 30 Apr 2002, Maurik Holtrop wrote: > Hello Root, > > I am writing a "translation class" that I would like to have mimic the > behavior of a TChain, so that programs that currently use TChain can use > my new class to read non-root data directly. > > My first try, I made a new class derived from TTree, gave this class > some branches, and then fill the branches in an over-written GetEntry(). > This mostly seemed to work, however, to get a program to accept this > "TTree like" object, I need to cast it to a (TChain *). This gives > problems when the programs calls a method that does not exist in TTree > (segfault). > > Second try I figured I just derive from TChain instead of TTree, and > since TChain derives itself from TTree, everything should still work. > Not so. > > The following does not work on a TChain: > > Int_t *myint = new Int_t(); > TChain *ch = new TChain("CLASEVENT","Test me"); > TBranch *chb = ch->Bronch("HEADER","THEADERClass",&myint); > > *** Break *** segmentation violation > > BUT: > TTree *te = new TTree("CLASEVENT","Test me"); > TBranch *chb = te->Bronch("HEADER","THEADERClass",&myint); > > No problem. > > This puzzles me, since the "Bronch" (or "Branch" for that matter) > methods are defined only in TTree, and not overwritten in TChain. > > Could someone explain how I can initialize branches on a TChain, when > they are NOT read from a file, and not even connected to a file? > > Thank you much, > > Maurik Holtrop > > >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:51 MET