//#include /*atrivedi:051313*/ /*The following example creates a THnSparse and is meant to be used to test its "statistics" */ { TFile* f = new TFile("test.root", "RECREATE"); //create h8 Int_t hdim = 8; Int_t bins[8] = {10,10,10,10,10,10,10,10}; Double_t xmin[8] = {1, 1, 1, 1, 1, 1, 1, 1}; Double_t xmax[8] = {11,11,11,11,11,11,11,11}; THnSparse* h8 = new THnSparseF("h8", "8D THnSparse", hdim, bins, xmin, xmax); h8->Sumw2(); Double_t coord1[8] = {1, 1, 1, 1, 1, 1, 1, 1}; Double_t coord2[8] = {10,10,10,10,10,10,10,10}; //fill h8 for (Int_t i=0;i<10;i++){ h8->Fill(coord1); } //now project out h5 Int_t projdims[5] = {0,1,2,3,4}; THnSparse* h5 = (THnSparse*)h8->Projection(5, projdims, "E"); h8->Write(); h5->Write(); f->Write(); }