We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6babed6 commit 705fea9Copy full SHA for 705fea9
hist/hist/inc/THnSparse.h
@@ -79,6 +79,8 @@ class THnSparse: public THnBase {
79
THnSparse(const char *name, const char *title, Int_t dim, const Int_t *nbins,
80
const std::vector<std::vector<double>> &xbins, Int_t chunksize = 1024 * 16);
81
82
+ THnSparse(const THnSparse& other);
83
+
84
~THnSparse() override;
85
86
static THnSparse* CreateSparse(const char* name, const char* title,
hist/hist/src/THnSparse.cxx
@@ -644,6 +644,26 @@ THnBase(name, title, dim, nbins, xbins),
644
fBinContent.SetOwner();
645
}
646
647
+////////////////////////////////////////////////////////////////////////////////
648
+/// Construct a THnSparse as a copy of "other"
649
650
+THnSparse::THnSparse(const THnSparse& other):
651
+ THnBase(other), fChunkSize(other.fChunkSize), fFilledBins(other.fFilledBins),
652
+ fBinContent(other.fBinContent), fBins(other.fBins), fBinsContinued(other.fBinsContinued),
653
+ fCompactCoord(nullptr) {
654
655
+ fBinContent.SetOwner();
656
657
+ Int_t dim = other.GetNdimensions();
658
+ auto nbins=new Int_t[dim];
659
+ for (Int_t i=0; i<dim; i++)
660
+ nbins[i]=other.GetAxis(i)->GetNbins();
661
662
+ fCompactCoord = new THnSparseCompactBinCoord(dim, nbins);
663
+ delete[] nbins;
664
+}
665
666
667
////////////////////////////////////////////////////////////////////////////////
668
/// Destruct a THnSparse
669
hist/hist/test/THn.cxx
@@ -29,13 +29,15 @@ TEST(THn, Constructors) {
29
THnD hn_v2("hn_v2", "hn_v2", 3, nbins.data(), edges);
30
THnD hn_v3("hn_v3", "hn_v3", axes);
31
THnI hn_v4("hn_v4", "hn_v4", axes);
32
+ THnD hn_v5(hn_v1);
33
34
THnSparseD hs_v1("hs_v1", "hs_v1", 3, nbins.data(), xmin.data(), xmax.data());
35
THnSparseD hs_v2("hs_v2", "hs_v2", 3, nbins.data(), edges);
36
THnSparseD hs_v3("hs_v3", "hs_v3", axes);
37
THnSparseI hs_v4("hs_v4", "hs_v4", axes);
38
+ THnSparseD hs_v5(hs_v1);
39
- std::vector<THnBase*> hns = {&hn_v1, &hn_v2, &hn_v3, &hn_v4, &hs_v1, &hs_v2, &hs_v3, &hs_v4};
40
+ std::vector<THnBase*> hns = {&hn_v1, &hn_v2, &hn_v3, &hn_v4, &hn_v5, &hs_v1, &hs_v2, &hs_v3, &hs_v4, &hs_v5};
41
for (THnBase* hn : hns) {
42
EXPECT_EQ(hn->GetNdimensions(), 3);
43
for (int dim = 0; dim < 3; ++dim) {
0 commit comments