[Q] TCut owner?

Hello,

Can someone answer who is the owner of TCut instances?
Say, I want to make a function Cuts() which will list defined cuts,
similar to Paw “cuts” command – see below.
But it does not seem to work, e.g.
if I define a cut

TCut *c1 = new TCut(“c1”, “cut number 1”);
*c1 = “x > 0”;

Cuts();

I got nothing. I looked at gROOT->GetListOfSpecials()->FindObject(“c1”),
could not find the “c1”, who will be the owner of TCut objects?

Regards,
Chul Su

void
Cuts(void)
{
TDirectory* dir = gDirectory;

TIter next(dir->GetList());
TObject *obj;
while( (obj = next()) ) {
if (obj->InheritsFrom(TCut::Class())) {
cout << obj->Print() << endl;
}
}

}

< cout << obj->Print() << endl;

obj->Print();

TCut object are added to none of the list in ROOT. The normal C++ life time rule applies (aka. in your example, you have to manage your own container of cuts).

Cheers,
Philippe

Hi Philippe,

Then, may be manual Section 8 Object Ownership, may be wrong?
It reads, “The Colletion of Specials”
… This collection contains objects of the following classes: Tcut, …

Now I have a working (?) version of Cuts()function, see attachment,
which accept “P” and “-” options and function similar to Paw “cuts”.
Which uses GetList()->Add() function, is this what you mentioned?

Thanks,
Chul Su

[quote=“pcanal”]TCut object are added to none of the list in ROOT. The normal C++ life time rule applies (aka. in your example, you have to manage your own container of cuts).

Cheers,
Philippe[/quote]
Cuts.C (1.32 KB)

As Philippe said, TCut objects are not added to any list.
The documentation is wrong where you indicate. Only TCutG objects are added to gROOT->GetListOfSpecials(). This is now fixed in the manual.

Rene

Who owns THStack? Same as TCut, nobody owns it?

Thanks,
Chul Su

[quote=“brun”]As Philippe said, TCut objects are not added to any list.
The documentation is wrong where you indicate. Only TCutG objects are added to gROOT->GetListOfSpecials(). This is now fixed in the manual.

Rene[/quote]

You are responsible for the memory management of THStack.

Philippe.