# Question about TH1F

**URL:** <https://root-forum.cern.ch/t/question-about-th1f/60474>\
**Category:** Newbie\
**Created:** [August 13, 2024, 7:00am UTC](https://root-forum.cern.ch/t/question-about-th1f/60474 "2024-08-13T07:00:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TField](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/tfield/32/36014_2.png) [@TField](https://root-forum.cern.ch/u/TField)\
**Post date:** [August 13, 2024, 7:00am UTC](https://root-forum.cern.ch/t/question-about-th1f/60474/1 "2024-08-13T07:00:08Z")

</div>

```auto
root [8] TH1F *hist=new TH1F("tt","tt",1000,-1,1);
root [9] tree->Draw("nbdt>>hist","track.rgt2[0]/rich.beta*::TMath::Sqrt(1-rich.beta*rich.beta)<-1.5&&track.rgt2[0]/rich.beta*::TMath::Sqrt(1-rich.beta*rich.beta)>-2&&nbdt>-8")
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
(long long) 36313
root [10] hist->Draw()
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1

```

I redirect the drawing to hist, however, hist is empty, why?

---

<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 13, 2024, 7:19am UTC](https://root-forum.cern.ch/t/question-about-th1f/60474/2 "2024-08-13T07:19:36Z")

</div>

Hello,

Can you try to repeat the operation with no selection, and then incrementally add cuts?  
Moreover, please consider using `RDataFrame` for this kind of operations: it is intuitive, performant and well supported and your productivity might increase!

Cheers,  
D

---

<div class="post-metadata">

**Author:** ![TField](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/tfield/32/36014_2.png) [@TField](https://root-forum.cern.ch/u/TField)\
**Post date:** [August 13, 2024, 7:33am UTC](https://root-forum.cern.ch/t/question-about-th1f/60474/3 "2024-08-13T07:33:08Z")

</div>

Hi,  
I repeat it with no selection:  
root [7] TH1F \*hist=new TH1F()  
(TH1F \*) 0x4b14c40  
root [8] Int\_t a=tree-\>Draw(“nbdt\>\>hist”,“”,“goff”)  
(int) 6940509  
root [9] hist-\>GetEntries()  
(double) 0.0000000  
root [10]  
There is still something wrong.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 13, 2024, 7:47am UTC](https://root-forum.cern.ch/t/question-about-th1f/60474/4 "2024-08-13T07:47:40Z")

</div>

Try with:

```auto
   TH1F *hist=new TH1F("tt","tt",1000,-1,1);
   tree->Draw("nbdt>>tt","","goff")

```

Or:

```auto
   TH1F *hist=new TH1F("hist","tt",1000,-1,1);
   tree->Draw("nbdt>>hist","","goff")

```

---

<div class="post-metadata">

**Author:** ![TField](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/tfield/32/36014_2.png) [@TField](https://root-forum.cern.ch/u/TField)\
**Post date:** [August 13, 2024, 7:55am UTC](https://root-forum.cern.ch/t/question-about-th1f/60474/5 "2024-08-13T07:55:44Z")

</div>

Thank you, it works. It seems that the redirect method looking forward to the name of hist instead of the pointer 😃

---

<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 13, 2024, 4:15pm UTC](https://root-forum.cern.ch/t/question-about-th1f/60474/6 "2024-08-13T16:15:36Z")

</div>

Thanks @bellenot ! I did not see that, my bad. Indeed it cannot see the name of the C++ variable, however, the name of the ROOT object yes, it’s registered.

Glad to see you can move forward!
