if you write your tree out in non-split mode, TTree:MakeClass
would produce correct prototype for the analysis macro such that
you would be using plain C++ w/o any shortcuts in the analysis code.
In this case TTree::Draw would have to be sacrificed with.
-best, pasha
Greg Novak wrote:
>
> I'm trying to figure out how to get my data structure stored in a
> TTree. It'd be nice if I could also easily plot all my variables using
> the TTree->Draw() method, but that part is negotiable. The problem is
> that my data structure amounts to a tree of objects and not all of them
> seem to make it into the TTree.
>
> I have a data sructure encoding an event that contains a TClonesArray of
> tracks. The Track object in turn includes at TClonesArray of detectors
> that were involved in constructing the track. The TTree seems to get the
> first TClonesArray (of tracks) but does not get the TClonesArray buried
> inside the Track object. Here are simplified versions of my objects:
>
> class Event : TObject {
> Int_t EventID;
> TClonesArray *track;
> }
> class Track : TObject {
> Float_t angle;
> TClonesArray *detector;
> }
> class Detector : TObject {
> Float_t x,y;
> }
>
> I pack them up w/ code that looks something like:
>
> Event *evt=new Event();
> evt->track = new TClonesArray("Track", 10);
> new( (*track) [0]) Track();
> ((Track *) (*track)[0])->detector = new TClonesArray("Detector", 10);
> new (((Track *) (*track)[0])->detector[0] ) Detector();
> new (((Track *) (*track)[0])->detector[1] ) Detector();
> new( (*track) [1]) Track();
> ((Track *) (*track)[0])->detector = new TClonesArray("Detector", 10);
> new (((Track *) (*track)[1])->detector[0] ) Detector();
> new (((Track *) (*track)[1])->detector[1] ) Detector();
>
> Sorry, some of those lines are rather dense. I have wrapper functions so
> that my real code is much prettier. :-) Now I compile all this, run the
> code that generates all this information, and write it to a root
> file. Then I run root interactively and I can do things like:
> data->Draw("EventID");
> data->Draw("track.angle");
>
> but *not*:
> data->Draw("track.detector.x");
>
> When I do data->MakeClass("foo"); and then inspect foo.C, I find a
> generated class with data structures like:
> class foo {
> Int_t EventID;
> Int_t track_;
> Int_t track_angle[10];
> }
> I can't seem to get to my information about the detectors, if it's
> stored there at all.
>
> So, that's my story. I'm at a loss, I'll really appreciate any help at
> all.
>
> Thanks!
> Greg
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:29 MET