# Disappearing Canvas

**URL:** <https://root-forum.cern.ch/t/disappearing-canvas/52077>\
**Category:** Newbie\
**Tags:** hist, root\
**Created:** [October 25, 2022, 7:13am UTC](https://root-forum.cern.ch/t/disappearing-canvas/52077 "2022-10-25T07:13:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emil\_R](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/emil_r/32/31255_2.png) [@Emil\_R](https://root-forum.cern.ch/u/Emil_R)\
**Post date:** [October 25, 2022, 7:13am UTC](https://root-forum.cern.ch/t/disappearing-canvas/52077/1 "2022-10-25T07:13:51Z")

</div>

Hi everybody,  
I have a problem with saving my data to a root file. I am creating a several canvas in a loop all consisting of three Histogramms, which I all save to a .root file. When I am naming the canvas all the same (e.g. “TCanvas \*c = **new** TCanvas(“Canvas”,“Canvas”,800,1400);”), everything works fine, and the Canvas get labelled as Canvas;1 Canvas ;2 etc. No I tried to change the name doing the following:

> const char\* Canvasname = std::to\_string(Energy).c\_str();  
> TCanvas \*c = new TCanvas(Canvasname,“Canvas”,800,1400);

where Energy is an integer. This leads to the following problem: When opening the root file, I do get the Canvas named as wished but when I try to open them in the TBrowser they appear for a second and then vanish. Also there seems to be only one Histogram in each canvas suddenly. I do not understand, why changing the name should lead to this problem. Maybe somebody knows an answer to this.

Thank you!

_ROOT Version:_ 7  
_Platform:_ MacOs  
_Compiler:_ Not Provided

* * *

---

<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:** [October 25, 2022, 7:18am UTC](https://root-forum.cern.ch/t/disappearing-canvas/52077/2 "2022-10-25T07:18:19Z")

</div>

`TCanvas *c = new TCanvas(TString("Canvas_") + Energy, "Canvas", 800, 1400);`

---

<div class="post-metadata">

**Author:** ![Emil\_R](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/emil_r/32/31255_2.png) [@Emil\_R](https://root-forum.cern.ch/u/Emil_R)\
**Post date:** [October 25, 2022, 7:20am UTC](https://root-forum.cern.ch/t/disappearing-canvas/52077/3 "2022-10-25T07:20:56Z")

</div>

Thank you so much, that solves the problem very quick.  
Have a nice day

---

<div class="post-metadata">

**Author:** ![Emil\_R](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/emil_r/32/31255_2.png) [@Emil\_R](https://root-forum.cern.ch/u/Emil_R)\
**Post date:** [October 26, 2022, 9:27am UTC](https://root-forum.cern.ch/t/disappearing-canvas/52077/4 "2022-10-26T09:27:58Z")

</div>

Sorry to bother everybody again with a similar problem, but I do not understand, what I did wrong this time. Since I have an energy range, I tried to make the title more precise:

> TCanvas \*c = **new** TCanvas(TString(“NoCutsBKGpoly\_”)+EnergyLow+TString(“-”)+EnergyHigh,TString(“NoCutsBKGpoly\_”)+EnergyLow+TString(“-”)+EnergyHigh,800,1400);

This leads to the same problem I had before. Is it not possible to add several TStrings?  
Thanks

---

<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:** [October 26, 2022, 10:11am UTC](https://root-forum.cern.ch/t/disappearing-canvas/52077/5 "2022-10-26T10:11:40Z")

</div>

`TString("NoCutsBKGpoly_") + EnergyLow + "_" + EnergyHigh`
