Dilicus
November 30, 2017, 4:15pm
1
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,
Stefano
Hi,
Do you have a running macro showing what you’re trying to do?
Cheers, Bertrand.
Dilicus
November 30, 2017, 4:32pm
3
This is are the relevant part of my code
The initialization of the TGTextEntry
TPulseViewer::TPulseViewer(){
//code
fEntryCutExpression = new TGTextEntry(fMain,"TCut Expression");
fMain->AddFrame(fEntryCutExpression, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
fEntryCutExpression->Connect("ReturnPressed()","TPulseViewer",this,"Apply()");
//other code
}
And where apply the cut
void TPulseViewer::Apply()
{
fTCutExpression = fEntryCutExpression->GetText();
fChain->Draw(">>list",fTCutExpression))
fEventList=(TEventList*)gROOT->FindObject("list");
if(fEventList->GetN()>0)
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…)
Dilicus
November 30, 2017, 5:00pm
5
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”)
Thanks,
Stefano
Sorry, but there is no easy way of translating a string into an object…
Dilicus
November 30, 2017, 7:45pm
7
Ok, thanks a lot for the help.
Stefano
ksmith
December 1, 2017, 7:38pm
8
I’m confused this is listed as a possibility in the TCut
documentation :
Examples of use:
Root > TCut c1 = "x<1"
Root > TCut c2 = "y<0"
Root > TCut c3 = c1&&c2
Root > ntuple.Draw("x", c1)
Root > ntuple.Draw("x", c1||"x>0")
Root > ntuple.Draw("x", c1&&c2)
Root > ntuple.Draw("x", "(x+y)"*(c1&&c2))
Dilicus
December 1, 2017, 10:02pm
9
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.
system
Closed
December 15, 2017, 10:02pm
10
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.