2D hist drawing blank

Hi,

I have an ntuple and I use it to draw a 2D hist:

TFile file = new TFile(“block_0_deg_506E08_POT.root”,“READ”);
TNtuple
ntuple = (TNtuple*)file->Get(“ntuple_0deg”);
TH2F
hist = new TH2F(“hist”,“veritices distribution”,40,-31.,31.,40,-11.,11.);
hist->GetXaxis()->SetTitle(“z (mm)”);
hist->GetYaxis()->SetTitle(“x (mm)”);
ntuple->Draw(“x0:z0>>hist”,“1.>0.”,“CONTZ”);

which produces an empty/white canvas. The histogram has entries since cout << hist->Integral() << endl; produces the number 2376.

hist->Draw(“CONTZ”);
c=new TCanvas();
hist->Draw();
c=new TCanvas();
hist->Draw(“SCAT”);

do not work either.

I am using root 5.34/21 on Mac OSX Mavericks, standard installation.

I would be very grateful for any suggestions.

Thank you,

Cristian

Can you provide some example reproducing the problem ?

Hi,

Thank you for your reply. Trying to run the attached script with the attached root file produces 4 blank (white) canvases. Please let me know if you get anything drawn.

Thank you,

Cristian
script.C (729 Bytes)
file.root (748 KB)

You should not close the file at the end of the macro.

Thank you. Sorry about that :blush: I always thought it’s a good practice to close files at the end of the program.

Thank you,

Cristian

The object you draw sits in that file. If you close the file, it is gone … :slight_smile: