TGTextEntry as input for TCut

Hi rooters,
I’m trying to build a GUI and in my code I can insert a string as input using a TGTextEntry .

Now I want to use this string as selection for a tree.

Let’s say my tree has three variables x,y and z.
And if I wrote in my TGTextEntry “x>0” everything works fine.
But I cannot find a way to use a previous declared TCut cut1 =“y>0”.

Is there a way to associate the input string “cut” in TGTextEntry to the TCut variable cut1?
Or also better is it possible convert the input string of the type "cut1 && “z>0” " in a TCut selection?

Many thanks in advance,


Do you have a running macro showing what you’re trying to do?

Cheers, Bertrand.

This is are the relevant part of my code

The initialization of the TGTextEntry



fEntryCutExpression = new TGTextEntry(fMain,"TCut Expression");
fMain->AddFrame(fEntryCutExpression, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
//other code

And where apply the cut

void TPulseViewer::Apply()
    fTCutExpression = fEntryCutExpression->GetText();

        fEventListIndex = 0;

And I have also declared a
TCut DetA = “ModuelID==0”
which is the one I want use as input

TPulseViewer.h (1.9 KB)
TPulseViewer.cpp (7.2 KB)

and what about fEntryCutExpression->SetText(DetA.GetTitle(), kFALSE);, or fEntryCutExpression->SetText(DetA.GetName(), kFALSE); (just trying to guess here…)

Works but not in the way I intended.
I’ll try to explain myself better.

What I’m try to implement is use any string written in the TCut way as an actual TCut.

So if I have declared
TCut DetA=“ModuleID==0”

I’d like to use the string “DetA” or "DetA && “x>0” " for my tree selection.
Like If I wrote

tree->Draw(“x”,DetA) or tree->Draw(“x”,DetA && “x>0”)


Sorry, but there is no easy way of translating a string into an object…

Ok, thanks a lot for the help.


I’m confused this is listed as a possibility in the TCut documentation:

What I want to do is a little do bit different.

It’s like I have already defined a TCut c1 and I’d like to define a new TCut in this way

TCut c2 = "c1 && \"y<1\" ";

Because in the gui can I have only string as input.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.