# Help on Method/s to create Tree from multi-fold gamma-ray coincidence data

**URL:** <https://root-forum.cern.ch/t/help-on-method-s-to-create-tree-from-multi-fold-gamma-ray-coincidence-data/29704>\
**Category:** ROOT\
**Created:** [July 9, 2018, 7:06am UTC](https://root-forum.cern.ch/t/help-on-method-s-to-create-tree-from-multi-fold-gamma-ray-coincidence-data/29704 "2018-07-09T07:06:20Z")\
**Posts on this page:** 1\
**Showing post:** 65

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [August 10, 2018, 4:58pm UTC](https://root-forum.cern.ch/t/help-on-method-s-to-create-tree-from-multi-fold-gamma-ray-coincidence-data/29704/65 "2018-08-10T16:58:57Z")

</div>

The “his3D” is a “THnSparseF” and you do not use “weights” when filling it so, it should be 4 bytes per bin.  
There are 128708567 filled bins so, it should be around 491MB (which is significantly less than 1GB).  
Why does it need more than 1 GB then?  
Maybe the chunks’ management uses a lot of memory, too?  
I’m afraid we need @pcanal for further debugging.

@pcanal … Can one somehow write this histogram in “split” mode (so that the 1GB limit is valid for “independent parts” / “data members” of it only)?

In the meantime, you may try the following “brutal fix” …

```auto
  // TFile *f = TFile::Open("cub_sparse_fifT7.root", "RECREATE", "", 101);
  f->cd();
#if 0 /* 0 or 1 */
  his3D->Write(); // warning: we need to "manually" save the THnSparse
#else /* 0 or 1 */
  // save the "his3D" in a tree ...
  TTree *t = new TTree("tree3D", "tree with his3D");
  t->Branch("his3D.", his3D, 32000, 111); // "max" splitting?
  t->Fill();
  t->Write();
  delete t;
#endif /* 0 or 1 */
  f->Write();
  delete f;

```

and if it goes fine, you can retrieve the histogram using:

```auto
{
  TFile *f = TFile::Open("cub_sparse_fifT7.root");
  TTree *t; f->GetObject("tree3D", t);
  THnSparse *his3D = 0;
  t->SetBranchAddress("his3D.", &his3D);
  t->GetEntry(0);
  delete f; // automatically deletes "t", too
  his3D->Print("all"); // "his3D" stays in RAM
}

```

---

_[View the full topic](https://root-forum.cern.ch/t/help-on-method-s-to-create-tree-from-multi-fold-gamma-ray-coincidence-data/29704)._
