# Projection in THnSparse

**URL:** <https://root-forum.cern.ch/t/projection-in-thnsparse/39025>\
**Category:** ROOT\
**Created:** [April 22, 2020, 6:59am UTC](https://root-forum.cern.ch/t/projection-in-thnsparse/39025 "2020-04-22T06:59:35Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [April 22, 2020, 7:58am UTC](https://root-forum.cern.ch/t/projection-in-thnsparse/39025/2 "2020-04-22T07:58:36Z")

</div>

Some time ago, I wrote various source code (which deals with a creation of a 3D [THnSparse](https://root.cern/doc/master/classTHnSparse.html) and then its 1D and 2D projections) for someone else which you can reuse:

> [@Help on Method/s to create Tree from multi-fold gamma-ray coincidence data](https://root-forum.cern.ch/t/help-on-method-s-to-create-tree-from-multi-fold-gamma-ray-coincidence-data/29704/70):
>
> Maybe this works: #include "TH1.h" #include "TH2.h" #include "THnSparse.h" #include "TAxis.h" #include "TString.h" // Usage example: TH1D \*h1 = Project1D(his3D, 449.5, 452.5, 668.5, 671.5); // Note: in principle, you should set low1 \<= up1 and low2 \<= up2 TH1D \*Project1D(THnSparse \*h, // the ("totally unsymmetric") "cubic" histogram Double\_t low1, Double\_t up1, // the first "window" Double\_t low2, Double\_t up2, // the second "window" Option\_t \*op…

---

_[View the full topic](https://root-forum.cern.ch/t/projection-in-thnsparse/39025)._
