@@ -336,6 +336,70 @@ TEST(RDataFrameHistoModels, HistoND)
336336 }
337337}
338338
339+
340+ TEST (RDataFrameHistoModels, HistoNSparseD)
341+ {
342+ ROOT::RDataFrame tdf (10 );
343+ auto x = 0 .;
344+ auto d = tdf.Define (" x0" , [&x]() { return x++; })
345+ .Define (" x1" , [&x]() { return x + .1 ; })
346+ .Define (" x2" , [&x]() { return x + .1 ; })
347+ .Define (" x3" , [&x]() { return x + .1 ; });
348+ int nbins[4 ] = {10 , 5 , 2 , 2 };
349+ double xmin[4 ] = {0 ., 0 ., 0 ., 0 .};
350+ double xmax[4 ] = {10 ., 10 ., 10 ., 10 .};
351+ auto h1 = d.HistoNSparseD (::THnSparseD (" h1" , " h1" , 4 , nbins, xmin, xmax), {" x0" , " x1" , " x2" , " x3" });
352+ auto h2 = d.HistoNSparseD ({" h2" , " h2" , 4 , nbins, xmin, xmax}, {" x0" , " x1" , " x2" , " x3" });
353+
354+ std::vector<double > edges0{1 , 2 , 3 , 4 , 5 , 6 , 10 };
355+ std::vector<double > edges1{1.1 , 2.1 , 3.1 , 4.1 , 5.1 , 6.1 , 10.1 };
356+ std::vector<double > edges2{1.2 , 2.2 , 3.2 , 4.2 , 5.2 , 6.2 , 10.2 };
357+ std::vector<double > edges3{1.3 , 2.3 , 3.3 , 4.3 , 5.3 , 6.3 , 10.3 };
358+ std::vector<std::vector<double >> edges = {edges0, edges1, edges2, edges3};
359+ int nbinse[4 ];
360+ for (unsigned int idim = 0 ; idim < edges.size (); ++idim) {
361+ nbinse[idim] = edges[idim].size () - 1 ;
362+ }
363+ auto h1e = d.HistoNSparseD (::THnSparseD (" h1e" , " h1e" , 4 , nbinse, edges), {" x0" , " x1" , " x2" , " x3" });
364+ auto h2e = d.HistoNSparseD ({" h2e" , " h2e" , 4 , nbinse, edges}, {" x0" , " x1" , " x2" , " x3" });
365+
366+ THnSparseDModel m0 (" m0" , " m0" , 4 , nbins, xmin, xmax);
367+ THnSparseDModel m1 (::THnSparseD (" m1" , " m1" , 4 , nbins, xmin, xmax));
368+
369+ auto hm0 = d.HistoNSparseD (m0, {" x0" , " x1" , " x2" , " x3" });
370+ auto hm1 = d.HistoNSparseD (m1, {" x0" , " x1" , " x2" , " x3" });
371+ auto hm0w = d.HistoNSparseD (m0, {" x0" , " x1" , " x2" , " x3" , " x3" });
372+ auto hm1w = d.HistoNSparseD (m1, {" x0" , " x1" , " x2" , " x3" , " x3" });
373+
374+ std::vector<double > ref0 ({0 ., 1 ., 2 ., 3 ., 4 ., 5 ., 6 ., 7 ., 8 ., 9 ., 10 .});
375+ std::vector<double > ref1 ({0 ., 2 ., 4 ., 6 ., 8 ., 10 .});
376+ std::vector<double > ref2 ({0 ., 5 ., 10 .});
377+ std::vector<double > ref3 ({0 ., 5 ., 10 .});
378+
379+ std::vector<std::vector<double >> ref = {ref0, ref1, ref2, ref3};
380+
381+ for (unsigned int idim = 0 ; idim < edges.size (); ++idim) {
382+ CheckBins (h1e->GetAxis (idim), edges[idim]);
383+ }
384+ for (unsigned int idim = 0 ; idim < edges.size (); ++idim) {
385+ CheckBins (h2e->GetAxis (idim), edges[idim]);
386+ }
387+ for (unsigned int idim = 0 ; idim < ref.size (); ++idim) {
388+ CheckBins (h1->GetAxis (idim), ref[idim]);
389+ }
390+ for (unsigned int idim = 0 ; idim < ref.size (); ++idim) {
391+ CheckBins (h2->GetAxis (idim), ref[idim]);
392+ }
393+ for (unsigned int idim = 0 ; idim < ref.size (); ++idim) {
394+ CheckBins (hm0->GetAxis (idim), ref[idim]);
395+ }
396+ for (unsigned int idim = 0 ; idim < ref.size (); ++idim) {
397+ CheckBins (hm0w->GetAxis (idim), ref[idim]);
398+ }
399+ }
400+
401+
402+
339403TEST (RDataFrameHisto, FillVecBool)
340404{
341405 const auto n = 10u ;
0 commit comments