# How to draw a histogram with "/" in its name

**URL:** <https://root-forum.cern.ch/t/how-to-draw-a-histogram-with-in-its-name/50825>\
**Category:** ROOT\
**Created:** [July 16, 2022, 8:05am UTC](https://root-forum.cern.ch/t/how-to-draw-a-histogram-with-in-its-name/50825 "2022-07-16T08:05:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marooz\_Malik](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/2acd7d/32.png) [@Marooz\_Malik](https://root-forum.cern.ch/u/Marooz_Malik)\
**Post date:** [July 16, 2022, 8:05am UTC](https://root-forum.cern.ch/t/how-to-draw-a-histogram-with-in-its-name/50825/1 "2022-07-16T08:05:25Z")

</div>

I have a .root file with histograms containing “/” in their name. I referred to this link:  
[https://root-forum.cern.ch/t/how-to-draw-an-object-with-special-characters-in-its-name/28248](https://root-forum.cern.ch/t/how-to-draw-an-object-with-special-characters-in-its-name/28248)

but this is for TObject and I am not able use it for TH1

---

<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:** [July 16, 2022, 8:12am UTC](https://root-forum.cern.ch/t/how-to-draw-a-histogram-with-in-its-name/50825/2 "2022-07-16T08:12:47Z")

</div>

It’s clearer if you include some code that you have tried.

---

<div class="post-metadata">

**Author:** ![Marooz\_Malik](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/2acd7d/32.png) [@Marooz\_Malik](https://root-forum.cern.ch/u/Marooz_Malik)\
**Post date:** [July 16, 2022, 8:17am UTC](https://root-forum.cern.ch/t/how-to-draw-a-histogram-with-in-its-name/50825/3 "2022-07-16T08:17:13Z")

</div>

```auto
void fit()

{ gStyle->SetOptStat(0);

   
 
   TFile *f11 = new TFile("digitrootobjects.root","read");
  // f11->ls();
   
  // get the list of keys
   TList *list = (TList *)f11->GetListOfKeys();
  
   TH1F *h1 = (TH1F *)list->FindObject("Cluster/ClsAmpCh");
  
  // TH1F *h1 = ((TKey *)key)->ReadObj();
 
   h1->Draw();
}

```

---

<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:** [July 16, 2022, 8:24am UTC](https://root-forum.cern.ch/t/how-to-draw-a-histogram-with-in-its-name/50825/4 "2022-07-16T08:24:44Z")

</div>

Does this work?

```auto
  TH1F *h1 = (TH1F *)list->FindObject(Form("%s","Cluster/ClsAmpCh"));

```

(by the way, _make sure_ “Cluster/” is really part of the name of the histo, and not a directory).

---

<div class="post-metadata">

**Author:** ![Marooz\_Malik](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/2acd7d/32.png) [@Marooz\_Malik](https://root-forum.cern.ch/u/Marooz_Malik)\
**Post date:** [July 16, 2022, 8:31am UTC](https://root-forum.cern.ch/t/how-to-draw-a-histogram-with-in-its-name/50825/5 "2022-07-16T08:31:57Z")

</div>

It is indeed name of the histo and the command gives an empty canvas.

---

<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:** [July 16, 2022, 9:14am UTC](https://root-forum.cern.ch/t/how-to-draw-a-histogram-with-in-its-name/50825/6 "2022-07-16T09:14:05Z")

</div>

Try

```auto
void fit()
{
  gStyle->SetOptStat(0); 
  TFile *f11 = new TFile("digitrootobjects.root","read");
  TH1F *h1 = (TH1F*)f11->FindObjectAny("Cluster/ClsAmpCh");
  h1->Draw();
}

```

---

<div class="post-metadata">

**Author:** ![Marooz\_Malik](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/2acd7d/32.png) [@Marooz\_Malik](https://root-forum.cern.ch/u/Marooz_Malik)\
**Post date:** [July 16, 2022, 9:16am UTC](https://root-forum.cern.ch/t/how-to-draw-a-histogram-with-in-its-name/50825/7 "2022-07-16T09:16:30Z")

</div>

Thanks 🙂

---

<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:** [July 30, 2022, 9:16am UTC](https://root-forum.cern.ch/t/how-to-draw-a-histogram-with-in-its-name/50825/8 "2022-07-30T09:16:59Z")

</div>

Closed on July 30, 2022, 9:16am UTC

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