# Why does changing the suffix in TH1::GetCumulative results in a segmentation violation?

**URL:** <https://root-forum.cern.ch/t/why-does-changing-the-suffix-in-th1-getcumulative-results-in-a-segmentation-violation/60518>\
**Category:** ROOT\
**Tags:** hist\
**Created:** [August 16, 2024, 3:25pm UTC](https://root-forum.cern.ch/t/why-does-changing-the-suffix-in-th1-getcumulative-results-in-a-segmentation-violation/60518 "2024-08-16T15:25:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyoon](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/e47c2d/32.png) [@kyoon](https://root-forum.cern.ch/u/kyoon)\
**Post date:** [August 16, 2024, 3:25pm UTC](https://root-forum.cern.ch/t/why-does-changing-the-suffix-in-th1-getcumulative-results-in-a-segmentation-violation/60518/1 "2024-08-16T15:25:43Z")

</div>

I was getting a very lengthy segmentation violation while using the TH1::GetCumulative method on PyROOT, so I decided to do a simple test.

The following works fine. I can create a histogram that looks like the one shown below.

```auto
import ROOT
h = ROOT.TH1('h', 'h', 100, -3, 3)
h.FillRandom('gaus', 10000)
hc = h.GetCumulative()
hc.Draw()

```

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/f/b/fb81db4bd5a70004d0dd001851f0c95c6f3a48a6.png)

But when I try to change the suffix of the cumulative histogram using the following [method](https://root.cern.ch/doc/v630/classTH1.html#a5709d315b774a89b1f7e6a71b0e9c380), I get a segmentation violation.

```auto
hc = h.GetCumulative(suffix='_mysuffix')

```

Coud this be a bug?

_ROOT Version:_ 6.30/04  
_Platform:_ Linux  
_Compiler:_ GCC 12.3.0  
Using Python 3.10.14 (packaged by conda-forge)

* * *

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [August 16, 2024, 3:51pm UTC](https://root-forum.cern.ch/t/why-does-changing-the-suffix-in-th1-getcumulative-results-in-a-segmentation-violation/60518/2 "2024-08-16T15:51:17Z")

</div>

Hello,

You are instantiating a TH1. Have you tried with a TH1F or TH1D? I am confused because that line should not work.

Cheers,  
D

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [August 16, 2024, 5:21pm UTC](https://root-forum.cern.ch/t/why-does-changing-the-suffix-in-th1-getcumulative-results-in-a-segmentation-violation/60518/3 "2024-08-16T17:21:08Z")

</div>

Also, try with a more recent version of ROOT. With the latest (6.32.04), for instance, we get some information:

```auto
>>> import ROOT
>>> h = ROOT.TH1F('h', 'h', 100, -3, 3)
>>> h.FillRandom('gaus', 10000)
>>> hc = h.GetCumulative(suffix='_mysuffix')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "cppyy_default_compiler", line 1, in <module>
NameError: name 'kTRUE' is not defined
>>>

```

If you provide the “forward” parameter as ROOT.kTRUE (or Python’s True) instead of the default kTRUE, it works:

```auto
>>> hc = h.GetCumulative(suffix='_mysuffix', forward=ROOT.kTRUE)
>>> 

```

---

<div class="post-metadata">

**Author:** ![kyoon](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/e47c2d/32.png) [@kyoon](https://root-forum.cern.ch/u/kyoon)\
**Post date:** [August 17, 2024, 3:51am UTC](https://root-forum.cern.ch/t/why-does-changing-the-suffix-in-th1-getcumulative-results-in-a-segmentation-violation/60518/4 "2024-08-17T03:51:51Z")

</div>

Sorry, I meant to type `TH1F`. The problem still persists in 6.30.04.

@dastudillo Yes, it works with the 6.32 versions if I modify the `forward` parameter. Hopefully, in the future, I won’t need to do that.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [August 31, 2024, 3:55am UTC](https://root-forum.cern.ch/t/why-does-changing-the-suffix-in-th1-getcumulative-results-in-a-segmentation-violation/60518/5 "2024-08-31T03:55:03Z")

</div>

Closed on August 31, 2024, 3:55am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
