Hi Rooters,
I’m trying to use a TCutG in an embedded canvas: I tried 2 solutions.
First:
[code] TCutG* cutg;
gROOT->SetEditorMode("CutG");
cout << "cut begin" << endl;
cutg = (TCutG*)c1->WaitPrimitive("c","CutG");// I named the cut 'c'
cout << "cut finished" << endl;
cutg=(TCutG *)gROOT->FindObject("c");
TH2F *tkeahisto = new TH2F("tkeahisto","tkeahisto",160,40,200,110,100,210);
a->Project("tkeahisto","TKE:A","c");
tkeahisto->DrawNormalized("COLZ" ,1);
c1->Update();
c1->cd(2)->Modified();
[/code]
This produces a segmentation violation
Other try:
[code] TCutG* cutg;
gROOT->SetEditorMode("CutG");
cout << "cut begin" << endl;
cutg = (TCutG*)c1->WaitPrimitive("c","CutG");// I named the cut 'c'
cout << "cut finished" << endl;
cutg=(TCutG *)gROOT->FindObject("c");
TH2F *tkeahisto = new TH2F("tkeahisto","tkeahisto",160,40,200,110,100,210);
a->Project("tkeahisto","TKE:A",cutg);
tkeahisto->DrawNormalized("COLZ" ,1);
c1->Update();
c1->cd(2)->Modified();
[/code]
This produces an error of this type : Error: Can’t call TTree::Project(“tkeahisto”,“TKE:A”,cutg) in current scope
Hoping someone can find the solution to make work an interactive graphical cut in an embedded canvas
Thanks
brun
May 8, 2008, 7:45am
2
Your second approach cannot work (as indicated by the compiler). The third argument to TTree::Project must be a const char*
Your first approach should work. Could you send the shortest possible running script reproducing the problem togather with a small data file/
Rene
Attached two files : a Root file and the code.
please type .L try.cpp
Then embcutG(“root.root”)
A segmentation violation error will occur.
If you find the problem, i will bw very happy!
Thanks
try1.cpp (4.13 KB)
attached
When the program is launched, click on CutG qnd then , draw a contour on the plot. Double click when finished to draw to close the contour. Then , click on draw.
Error!
Hope someone will find.
Thanks
root.root (68.8 KB)
brun
May 8, 2008, 4:43pm
5
I can run your test without problem. I get the following output and also a canvas with a color plot.
Root [0] .L try1.cpp
Root [1] embcutG("root.root")
here 1
root.root
TFile** root.root
TFile* root.root
KEY: TTree t;1 light heavy yield
Slot DoDraw()
Re Draw OK
Root [2]
Unfortunately you do not specify your version of ROOT. In case you use an old version, I suggest trying with version 5.18 or 5.19
Rene
I use Root 5.18//00
But have you launch the graphical cut ? It seems that you didn’t use it when viewing your terminal.
When the canvas appears, click on CutG button and then draw a contour on the first plot.
Then, click on draw button.
Hope it works too.
Thanks
brun
May 9, 2008, 7:03am
7
see my comments in function DoDraw in attachment
Rene
try1.cpp (4.59 KB)