Re: fill tree bombs in a simple case

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Nov 07 1997 - 15:39:01 MET


David Urner wrote:

> Hi,
>         I'm trying to write a macro with a very basic tree.
> I first load a simple class called Mytest, which contains just 4 variables
> with .L help.cpp. It has the following form:
>
> #include "help.h"
>
> Mytest::Mytest()
> {
>
> }
> Mytest::~Mytest()
> {
>
> }
>
> void Mytest::Streamer(TBuffer &R__b)
> {
>    // Stream an object of class Geometry.
>
> }
>
> where help.h has the form:
>
>  class Mytest
>     {
>     public:
>       Mytest();
>       virtual ~Mytest();
>
>       void Streamer(TBuffer& R__b);
>       Int_t Run_number;
>       Int_t Record_number;
>       Int_t Fill_number;
>       Int_t Nrhits;
>     };
>
> I'm booking the tree then the following way:
>
> {
>   TFile *hfile = new TFile("Test.root","RECREATE","Junk");
>   TTree *treetrace = new TTree("treetrace","example",1024);
>   Int_t split=0;
>   Int_t bsize = 64000;
>   Mytest *mytest = new Mytest;
>   treetrace->Branch("mytest","Mytest",&mytest,bsize,split);
>   treetrace->Fill();
> }
>
> At the comand treetrace->Fill() I get a segmentation violation.
> What could the reason be?
> I'm running this on a hp system 10.
>

This is not possible unfortunately !
TTree provides 3 member functions TTree::Branch
   1- for basic types
   1- for objects DERIVED from TObject
   1- for TClonesArray objects

Your class is not derived from TObject. We have a VERY IMPORTANT
limitation in the CINT interpreter now. We cannot  craete objects
for which  one part (a class) is defined interactivly and the other part
derives from a compiled class.
We had recently several discussions on this list about this topic.

I strongly hope that our BRAVE Masa will implement one day
this feature that will enhance considerably the power of the interpreter.

If you want to define a simple Tree with only simple data types,
use the class TNtuple instead.

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:22 MET