Re: [ROOT] tree->Branch problem

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Jun 25 2001 - 08:09:04 MEST


Hi Jacek,

You do not identify which version you use. I assume the production version
3.01/05.
The constructor should be called only once. Remember that you must pass the
address of a pointer, not the pointer itself. In your case, you should do:

        tree = new TTree("WireMap", "WireMap");
        WireInfo *globalWireInfo = new WireInfo();
        tree->Branch("WireInfo", "WireInfo", &globalWireInfo);
or

        tree = new TTree("WireMap", "WireMap");
        WireInfo *globalWireInfo = 0;  //must be set to 0
        tree->Branch("WireInfo", "WireInfo", &globalWireInfo);

Rene Brun


Jacek M. Holeczek wrote:
> 
> Hi,
> I think I suffer from the following problem. If I do :
>         tree = new TTree("WireMap", "WireMap");
>         tree->Branch("WireInfo", "WireInfo", globalWireInfo);
> then the "default" constructor of the class WireInfo is called TWO times
> somewhere inside "tree->Branch". This breaks my whole application.
> Can I somehow prevent this ?
> Thanks in advance,
> Jacek.



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:50 MET