[SOLVED] Projecting sub-range of THnSparse

Dear all,

I have a 7-dimensional THnSparseD and I am trying to get a TH1D projection, e.g. on the first axis, with a cut on the 7th axis. Typically I want only one bin of the seventh axis to appear in the projection.

I am running ROOT 6.04/08 on Mac OS X
I do something like this, in interactive mode:

root [2] h_sparse->GetAxis(6)->SetRange(1,1);
root [3] TH1D* h_proj = h_sparse->Projection(0);

What I obtain is a projection of the full THnSparse. The h_proj is the same whatever the range I try to set with GetAxis(6)->SetRange(bin1,bin2).

Am I doing something wrong ?

Thanks a lot,
Simon

Update:
In interactive mode, doing this gives the expected result:

root -l my_file.root root [0] Attaching file my_file.root as _file0... (class TFile *) 0x7fe110ebe200 root [1] THnSparseD* my_thn = (THnSparseD*) _file0->Get("thn_name"); root [2] my_thn->GetAxis(6)->SetRange(1,1); root [3] TH1D* my_thn_projE = my_thn->Projection(0); root [4] my_thn_projE->Draw();

While before I was doing:

root -l my_file.root
root [0]
Attaching file my_file.root as _file0...
(class TFile *) 0x7fe110ebe200
root [1] thn_name->GetAxis(6)->SetRange(1,1);
root [2] TH1D* my_thn_projE = thn_name->Projection(0);
root [3] my_thn_projE->Draw();

Not sure I understand the exact reason, but problem solved.