# How to select the histogram inside my root file in TBrowser?

**URL:** <https://root-forum.cern.ch/t/how-to-select-the-histogram-inside-my-root-file-in-tbrowser/41399>\
**Category:** Newbie\
**Tags:** root\
**Created:** [September 11, 2020, 2:24pm UTC](https://root-forum.cern.ch/t/how-to-select-the-histogram-inside-my-root-file-in-tbrowser/41399 "2020-09-11T14:24:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [September 11, 2020, 2:24pm UTC](https://root-forum.cern.ch/t/how-to-select-the-histogram-inside-my-root-file-in-tbrowser/41399/1 "2020-09-11T14:24:44Z")

</div>

Dear All,

I have a root file in which I am able to see all the 24 histograms in “TBrowser”. Now while writing the macro for calibration I have to select only one spectrum. Could you please help?  
What should be the small macro for which it only takes that selected histogram?

Thanks and have a nice day.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 11, 2020, 2:58pm UTC](https://root-forum.cern.ch/t/how-to-select-the-histogram-inside-my-root-file-in-tbrowser/41399/3 "2020-09-11T14:58:29Z")

</div>

```auto
auto f = new TFile("Eu_26Dec.001.root");
TH1F* h = (TH1F*)f->Get("hist_name");

```

---

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [September 11, 2020, 9:17pm UTC](https://root-forum.cern.ch/t/how-to-select-the-histogram-inside-my-root-file-in-tbrowser/41399/4 "2020-09-11T21:17:11Z")

</div>

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [September 13, 2020, 1:27pm UTC](https://root-forum.cern.ch/t/how-to-select-the-histogram-inside-my-root-file-in-tbrowser/41399/5 "2020-09-13T13:27:47Z")

</div>

Hi Robert,

Could you in the future open new topics for new issues? Else we (and other readers) get lost which problem is being solved. Thanks!

Cheers, Axel.

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [September 13, 2020, 1:30pm UTC](https://root-forum.cern.ch/t/how-to-select-the-histogram-inside-my-root-file-in-tbrowser/41399/6 "2020-09-13T13:30:06Z")

</div>

Why don’t you store the peak positions in a `vector`, and then do a loop over the peaks, calling `SetParameter` with each `vector` element? This really looks more like a coding question than a question about ROOT, btw…

---

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [September 13, 2020, 2:54pm UTC](https://root-forum.cern.ch/t/how-to-select-the-histogram-inside-my-root-file-in-tbrowser/41399/7 "2020-09-13T14:54:21Z")

</div>

Thanks @Axel  
Actually I have never used vectors in root macro.  
Can you please tell me that how can I use vectors in my macro to store the peak positions?  
Does using vectors helps in not seting parameters and range again and again?

---

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [September 15, 2020, 9:17pm UTC](https://root-forum.cern.ch/t/how-to-select-the-histogram-inside-my-root-file-in-tbrowser/41399/8 "2020-09-15T21:17:31Z")

</div>

@moneta  
Can you please resolve my query?

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [September 22, 2020, 7:16pm UTC](https://root-forum.cern.ch/t/how-to-select-the-histogram-inside-my-root-file-in-tbrowser/41399/9 "2020-09-22T19:16:15Z")

</div>

Hi Robert,  
With an estimate of 20k users we cannot spend a lot of time in teaching basic C++ (or coding, whatever the language). It’s much more efficient for everyone if you can ask close colleagues or friends for help. Could this work? We’re very happy to help with any issues you have with ROOT!  
Cheers, Axel.
