Trouble with Fill command and THnSparse

I just updated to 5.18 to make use of the THnSparse class. I am having some trouble filling. Here is the test program I am running:

[code]//ROOT includes
#include “TRint.h”
#include “THnSparse.h”

//C++ includes
using namespace std;

int main(int argc, char** argv)

TRint *fApp = new TRint(“Rint”, &argc, argv, 0, 0);

Int_t bins[1] = {1};
Double_t min[1] = {0};
Double_t max[1] = {10};

THnSparseS *h = new THnSparseS("h", "h", 1, bins, min, max);

for(Int_t i=0; i<10; i++)
	if(i % 3 == 0) h->THnSparse::Fill(i, 1);
}//end for

return 0;


I am sure that there is something simple wrong with this, but nothing in the documentation or source files are pointing me to it.

When I compile as is, it tells me that:

TestSparse.cxx: In function ‘int main(int, char**)’: /opt/new/include/root/THnSparse.h:124: error: ‘Long_t THnSparse::Fill(Long_t, Double_t)’ is protected

But if I change the fill to Fill(i); it claims it is ambiguous.

Any ideas?


You need to pass an array of Double_t to Fill.

Please see for the details.

A THnSparse is filled just like a regular histogram, using THnSparse::Fill(x, weight), where x is a n-dimensional Double_t value. To take errors into account, Sumw2() must be called before filling the histogram.

Yeah, that makes sense from the documentation now that I know what I am looking for. Thanks.