RE: [ROOTDEV] subbranches in macros?

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Thu, 01 Mar 2007 01:55:29 -0600


Hi Christian,

You need to generate a dictionary for your vector of TOAStorageTrack. (See rootcint and LinkDef file int the User's Guide).

Cheers,
Philippe

-----Original Message-----
From: owner-rootdev_at_pcroot.cern.ch [mailto:owner-rootdev_at_pcroot.cern.ch] On Behalf Of Christian Hansen
Sent: Tuesday, February 27, 2007 3:17 AM To: Philippe Canal
Cc: 'roottalk'; roottalk_at_pcroot.cern.ch
Subject: [ROOTDEV] subbranches in macros?

Hi again Philippe,

I have another question about subbranches in a tree; can vector subbranches be read in from a macro?

I attached to this email my small test program again, see macroTest.tgz. The macro, treeTestMacro.C, reads in the tree, testTree.root, and it works fine to just use the functions of TTestBranch but when I try to use the size() function of a std::vector<TTestTrack> it complains:

Error: Can't call vector<TOAStorageTrack,allocator<TOAStorageTrack>
>::size() in current scope readGeneralTree.C:27:

What am I doing wrong here?

Cheers
/Christian

> > How can I make it so that BestTrack to have two sub-branches;
> > TPC1Segment and TPC2Segment.
>
> Beside an artefact of the way the information is stored and the
> simple way the TTreeViewer is displaying the information, this
> is already essentially what you have.
>
> There is much you can do to make the display more like what you
> want. (The closest you could get would be to prevent the
> splitting of the TPC1Segment and TPC2Segment datamember (by
> adding the comment //|| just after their declaration) but
> then the TTreeViewer will not longer be able (for now) to
> expand those variable (However the TBrowser would be able to
> do it).
>
> > Is my only solution now to use the approach with
> > TVirtualCollectionProxy that you mentioned
>
> This is __not__ a solution is this case. It would
> not give any visual improvement over what you could
> get with a std::vector.
>
> Cheers,
> Philippe.
>
>
>
> -----Original Message-----
> From: Christian Hansen [mailto:hansen_at_uvic.ca]
> Sent: Monday, February 19, 2007 5:09 PM
> To: Philippe Canal
> Cc: 'roottalk'; roottalk_at_pcroot.cern.ch
> Subject: RE: [ROOTDEV] subbranches?
>
>
> Hi Philippe,
>
> thanks alot for the vector-approach suggestion.
> If you use TTreeViewer to look at the tree inside
> testTree.root (see attached trackTest.tgz) you see
> that it worked for "TPCTracks" that now is a vector
> of TTestTracks.
> But what if I want, as an example, "track segments"
> of the tracks to expand as sub-branches.
> In that case I cannot use a vector since I do not
> want the variables of different segments to be
> histogramed together.
> To explain easier I added a "BestTrack" to the testBranch.
> If you expand the BestTrack with the TTreeViewer
> it looks like BestTrack has one variable called
> BestTrack.TPC1Segment.Momentum
> and another variable called
> BestTrack.TPC2Segment.Momentum.
> How can I make it so that BestTrack to have two sub-branches;
> TPC1Segment and TPC2Segment.
> If these two sub-branches are expandable with the
> TTreeViewer one then could get the "Momentum" of
> each of these segments by expanding them.
>
> Is my only solution now to use the approach with
> TVirtualCollectionProxy that you mentioned?
> If so, where could I find an example where this
> has been done before?
>
> Cheers
> /Chris
>
>
>
>
>
>
> > Hi Christian,
> >
> > Your class TTrackCollection is not known to ROOT as
> > a 'collection' but just as a series of unrelated data
> > member and thus it has no way to collate them the way
> > you want. You __could__ advertize your class as a
> > collection (via a hand code TVirtualCollectionProxy)
> > but this is certainly much more work than the easy
> > alternative.
> >
> > I simply recomment that you replace the 3 data member
> > of TTrackCollection by:
> > std::vector<TTestTrack> Track;
> > (or even maybe replace TTrackCollection entirely by
> > std::vector<TTestTrack>). You could also used any
> > of the other existing/supported collection (all
> > STL collections or TClonesArray).
> >
> > You should then get from TTreeViewer the behavior you
> > want.
> >
> > Cheers,
> > Philippe.
> >
> > -----Original Message-----
> > From: owner-rootdev_at_pcroot.cern.ch [mailto:owner-rootdev_at_pcroot.cern.ch]
> On
> > Behalf Of Christian Hansen
> > Sent: Saturday, February 17, 2007 7:40 PM
> > To: Philippe Canal
> > Cc: 'roottalk'; roottalk_at_pcroot.cern.ch
> > Subject: RE: [ROOTDEV] subbranches?
> >
> >
> > Hi Philippe,
> >
> > thanks a lot for your respond!
> >
> > So if I understood you right the only way to make
> > for example a "collection of tracks" to expand in
> > the TTreeViewer is to make the collection to be a
> > branch. I did a small test program that I attached
> > to this email (see trackCollectionTest.tgz).
> > After compiling and running it produces "testTree.root".
> > When I use the TTreeViewer to look at the tree in
> > testTree.root the collections of tracks (TPCTracks
> > and FGDTracks) expand but in each of these
> > collections I have three TTestTracks that I hoped
> > they would also expand in the TTreeViewer in the same
> > way as the TTrackCollections. But instead the variables
> > of the tracks are seen as leafs of the collections and
> > not as leafs of the tracks. Does this happen also for
> > you when you look at the testTree.root with the
> > TTreeViewer? If then, why is that so?
> >
> > Is this is the only way to have a collection of tracks
> > to expand in the TTreeViewer or is there some other
> > recommended way?
> >
> > Thanks alot!
> > /Christian
> >
> >
> >
> >
> > > Hi Christian,
> > >
> > > A priori, all real sub-branches are shown in the TTreeViewer.
> > >
> > > In the case of test/Event, fLastTrack is a TRef and hence has
> > > __no__ real sub-branches. In addition the TTreeViewer still
> > > needs to be renovated :) to handle some of the newer case
> > > (like the ability to automatic follow the references).
> > >
> > > You may find that the TBrowser is able to better unwind
> > > branches since it is also able to drill though non split
> > > branches (aka unwind objects).
> > >
> > > Cheers,
> > > Philippe
> > >
> > > -----Original Message-----
> > > From: owner-rootdev_at_pcroot.cern.ch
[mailto:owner-rootdev_at_pcroot.cern.ch]
> > On
> > > Behalf Of Christian Hansen
> > > Sent: Saturday, February 17, 2007 7:07 AM
> > > To: roottalk; roottalk_at_pcroot.cern.ch
> > > Subject: [ROOTDEV] subbranches?
> > >
> > >
> > > Dear Rooters,
> > >
> > > I'm having problems expanding sub-branches in the
> > > TreeViewer. Since my program looks very much like
> > > the MainEvent.cxx example provided in the "test"
> > > folder, I can base my question on this example:
> > >
> > > In the "test" folder in root version 5.04/00
> > > I compiled and ran ./Event
> > > Then I used the TreeViewer to look at the TTree
> > > in the Event.root file.
> > > Why does all variables of "event" looks like leafs
> > > in the viewer?
> > > Is it possible to make for example fLastTrack an
> > > expandable sub-branch so that one could reach e.g.
> > > the last tracks fPx, fPy and fPz with the TreeViewer?
> > >
> > > I get some warnings when I open the TreeViewer:
> > > Warning in <TClass::TClass>: no dictionary for class Event is
available
> > > I tried to produce dictionaries with cint, but without
> > > any luck.
> > >
> > > Is there any way I can make the sub-branches expandable
> > > in the TreeViewer?
> > >
> > > With best regards
> > > / Christian Hansen
> > >
> > > PS. I have no problems in reading in a complex TTree,
> > > this is just about using the TreeViewer.
> > >
> > >
> > >
> > >
> > >
> > >
> > > ================================================
> > > Dep. of Phys. Office: +1 250 721 7710
> > > Univ of Victoria Mobile: +1 250 588 0860
> > > PO Box 3055
> > > V8W 3P6 Victoria BC
> > > Canada
> > > ------------------------------------------------
> > > Home Page : http://particle.phys.uvic.ca/~hansen
> > > http://cern.ch/christian.hansen
> > >
> > >
> > >
> >
> > / Christian Hansen
> >
> > ================================================
> > Dep. of Phys. Office: +1 250 721 7710
> > Univ of Victoria Mobile: +1 250 588 0860
> > PO Box 3055
> > V8W 3P6 Victoria BC
> > Canada
> > ------------------------------------------------
> > Home Page : http://particle.phys.uvic.ca/~hansen
> > http://cern.ch/christian.hansen
> >
> >
>
> / Christian Hansen
>
> ================================================
> Dep. of Phys. Office: +1 250 721 7710
> Univ of Victoria Mobile: +1 250 588 0860
> PO Box 3055
> V8W 3P6 Victoria BC
> Canada
> ------------------------------------------------
> Home Page : http://particle.phys.uvic.ca/~hansen
> http://cern.ch/christian.hansen
>
>

/ Christian Hansen


Dep. of Phys.         Office: +1 250 721 7710
Univ of Victoria      Mobile: +1 250 588 0860
PO Box 3055
V8W 3P6 Victoria BC
Canada

Home Page : http://particle.phys.uvic.ca/~hansen

            http://cern.ch/christian.hansen Received on Thu Mar 01 2007 - 08:57:26 CET

This archive was generated by hypermail 2.2.0 : Thu Mar 01 2007 - 11:50:01 CET