Howdy Peter. Say you do the following addition in your the source code of BrOutputTreeElement::Event(BrEventNode* event): TClass* cl = gROOT->GetClass(fClassName); TObject*o = arr->New(iE); TBuffer b(TBuffer::kWrite); TObject * obj = table->At(iE); // Cast obj to baseclass fBaseClassName if specified if (!fClassName.IsNull() && cl->InheritsFrom(fClassName) obj = cl->DynamicCast(gROOT->GetClass(fBaseClassName), obj, kTRUE); obj->Streamer(b); b.SetReadMode(); b.SetBufferOffset(); o->Streamer(b); Also you should modify the BrOutputTreeModule::AddElement(...) functions to something like virtual void AddElement(const Char_t* className, const Char_t* name, const Char_t* branchName, const Char_t* baseClassName = NULL, Bool_t isTable = kFALSE, Int_t arrSize = 100, Int_t bufSize = 32000, Int_t splitLevel = 99) virtual void AddElement(const Char_t* className, const Char_t* name, const Char_t* baseClassName = NULL, Bool_t isTable = kFALSE, Int_t arrSize = 100, Int_t bufSize = 32000, Int_t splitLevel = 99) to allow you to specify the base class of an object in a member TString fBaseClassName. I'm not sure it works, but it could be worth a try. Also I may have misunderstood the use of TClass::DynamicCast(...), so you're hereby warned. :) JI Peter H. L. Christiansen wrote: > Hi > > Kris and I noticed that with the new BrOutputTreeModule it is not possible > to "downcast" things in a tree. > > The actual problem is that I want to add the table that contains > BrTpcTrackCandidates ( : BrTrackCandidate : BrTrack : ....) to a tree > branch as BrTrack(s) since I don't need the residuals. In the old code I > believe this used to work, but now it doesn't i.e., adding a table of > BrTracks(s) gives some Streamer/class version conflicts, while adding the > full BrTpcTrackCandidate works. I believe this has to do with the part in > the event method that reads : > > TClass* cl = gROOT->GetClass(fClassName); > TObject*o = arr->New(iE); > TBuffer b(TBuffer::kWrite); > TObject * obj = table->At(iE); > obj->Streamer(b); > b.SetReadMode(); > b.SetBufferOffset(); > o->Streamer(b); > > PC comments : > What is cl used for ? > ie is the index looping over the datatable > arr is a TClonesArray of here BrTracks(s) > obj is of type BrTpcTrackCandidate here > > So somehow I need to tell either obj or o when I stream that I want a > BrTrack instead of the full monty. Does anybody know a fix for this ? > > The lazy way is to use the old, but as FV notes it is 100 times slower! > Or I could just copy everything, but that increases my filesize. > > Cheers > Peter > -- _____________________________________________________ ________| Jens Ivar Jřrdre |_______ \ | Dept. of Physics Office: 521 | / \ | Allégt 55 Phone: +47 55 58 29 92 | / \ | 5007 Bergen Fax: +47 55 58 94 40 | / / | Norway E-mail: jensivar.jordre@fi.uib.no | \ / |_____________________________________________________| \ /__________) (_________\
This archive was generated by hypermail 2b30 : Fri Sep 20 2002 - 09:24:59 EDT