nab
May 10, 2017, 9:28am
1
Dear developers,
I am using different cuts on my data set, when I run this macro it will give no error but the canvas is empty. I want to plot selNonIsoMu_pt. Kindly check my macro to fix it.
Thanks
iso.cc (1.1 KB)
source file path : /afs/cern.ch/user/n/nmajeed/public
couet
May 10, 2017, 9:39am
2
it seems t2->Draw is not called … ca you comment the selection tests before and try again ?
(BTW continue
in invalid outside of a loop)
nab
May 10, 2017, 9:45am
3
Still it is not working. It is showing in process but gives a empty canvas.
couet
May 10, 2017, 10:52am
4
If I do:
void iso()
{
TFile *f = new TFile("May26_2.root");
TTree *t2 = (TTree*)f->Get("demo/AnaTree");
TCanvas *c1 = new TCanvas("c1","c1",800,600);
TH1F *h1 = new TH1F("h1","hist_nonIsoMu_cuts",100,0,300);
h1->GetXaxis()->SetTitle("selNonIsoMu_cuts_pt");
h1->GetYaxis()->SetTitle("entries");
t2->Draw("selNonIsoMu_pt >> h1","","Hist");
}
I get a non empty canvas
nab
May 10, 2017, 11:02am
5
yes it is working. But this is not working when I add these lines
void pt_eta_nonIsomu1() {
TFile *f = new TFile("May26_2.root");
TTree *t2 = (TTree*)f->Get("demo/AnaTree");
TH2F *h2 = new TH2F("h2","hist_nonIsoMu",100,0,300,100,-3,3);
h2->GetXaxis()->SetTitle("selNonIsoMu_pt");
h2->GetYaxis()->SetTitle("selNonIsoMu_eta");
float selNonIsoMu_pt, selNonIsoMu_eta;
if(selNonIsoMu_pt>20) continue;
if(selNonIsoMu_eta<2.5) continue;
if(selNonIsoMu_idTight==0) continue;
if(selNonIsoMu_ismuon==0) continue;
if(selNonIsoMu_iso<0.12) continue;
t2->Draw("selNonIsoMu_eta:selNonIsoMu_pt >> h2","","Hist");
}
couet
May 10, 2017, 11:11am
6
Yes, but, as I said, this code is not correct. With ROOT 6 it gives:
$ root pt_eta_nonIsomu1.C
----------------------------------------------------------------
| Welcome to ROOT 6.09/03 http://root.cern.ch |
| (c) 1995-2017, The ROOT Team |
| Built for macosx64 |
| From heads/master@v6-09-02-743-g8daaf5e, May 09 2017, 17:49:57 |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
----------------------------------------------------------------
root [0]
Processing pt_eta_nonIsomu1.C...
In file included from input_line_9:1:
/Users/couet/Downloads/pt_eta_nonIsomu1.C:11:23: error: 'continue' statement not in loop statement
if(selNonIsoMu_pt>20) continue;
^
/Users/couet/Downloads/pt_eta_nonIsomu1.C:12:25: error: 'continue' statement not in loop statement
if(selNonIsoMu_eta<2.5) continue;
^
/Users/couet/Downloads/pt_eta_nonIsomu1.C:13:4: error: use of undeclared identifier 'selNonIsoMu_idTight'
if(selNonIsoMu_idTight==0) continue;
^
/Users/couet/Downloads/pt_eta_nonIsomu1.C:13:28: error: 'continue' statement not in loop statement
if(selNonIsoMu_idTight==0) continue;
^
/Users/couet/Downloads/pt_eta_nonIsomu1.C:14:4: error: use of undeclared identifier 'selNonIsoMu_ismuon'
if(selNonIsoMu_ismuon==0) continue;
^
/Users/couet/Downloads/pt_eta_nonIsomu1.C:14:27: error: 'continue' statement not in loop statement
if(selNonIsoMu_ismuon==0) continue;
^
/Users/couet/Downloads/pt_eta_nonIsomu1.C:15:4: error: use of undeclared identifier 'selNonIsoMu_iso'
if(selNonIsoMu_iso<0.12) continue;
^
/Users/couet/Downloads/pt_eta_nonIsomu1.C:15:26: error: 'continue' statement not in loop statement
if(selNonIsoMu_iso<0.12) continue;
^
root [1]
nab
May 10, 2017, 4:54pm
7
Dear couet, I fixed this issue. I am not fill the containers in a loop that is why it was giving empty canvas.
system
Closed
May 24, 2017, 4:59pm
8
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.