Re: fill tree bombs in a simple case

Rene Brun (Rene.Brun@cern.ch)
Fri, 07 Nov 1997 15:39:01 +0100


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