# Newbie

**URL:** https://root-forum.cern.ch/c/newbie/26.md?page=46

[Latest](https://root-forum.cern.ch/latest.md) · [Categories](https://root-forum.cern.ch/categories.md) · [Tags](https://root-forum.cern.ch/tags.md)

**Page:** 47

---

## [How to export the data inside a branch in a ttree to a txt file?](https://root-forum.cern.ch/t/how-to-export-the-data-inside-a-branch-in-a-ttree-to-a-txt-file/51399)

<div class="topic-metadata">

**Author:** [@gini](https://root-forum.cern.ch/u/gini)\
**Replies:** 4\
**Last updated:** [August 30, 2022, 2:24pm UTC](https://root-forum.cern.ch/t/how-to-export-the-data-inside-a-branch-in-a-ttree-to-a-txt-file/51399 "2022-08-30T14:24:49Z")

</div>

Hi, I have a ttree. I want to export a particular branch (need to have the X and Y data points) inside the TTree say “Mass” into a txt file. Can someone tell me how to do this ? Thanks in advance !

---

## [How to fill 2D histogram](https://root-forum.cern.ch/t/how-to-fill-2d-histogram/51398)

<div class="topic-metadata">

**Author:** [@Anil\_Kumar](https://root-forum.cern.ch/u/Anil_Kumar)\
**Replies:** 5\
**Last updated:** [August 30, 2022, 9:41am UTC](https://root-forum.cern.ch/t/how-to-fill-2d-histogram/51398 "2022-08-30T09:41:39Z")

</div>

Hello Experts, I defined a 2D histogram as: TH2F \*h3 = new TH2F("h3", "Hist", 100, 0., 1.E5, 100, 1., 2.E7); I have two outputs such as energy and flux. I want to fill energy and flux in X and Y axes respectively. S…

---

## [To find the integartion of area drawn using graphical cut](https://root-forum.cern.ch/t/to-find-the-integartion-of-area-drawn-using-graphical-cut/51386)

<div class="topic-metadata">

**Author:** [@gurmukh\_dhindsa](https://root-forum.cern.ch/u/gurmukh_dhindsa)\
**Replies:** 12\
**Last updated:** [August 29, 2022, 6:38pm UTC](https://root-forum.cern.ch/t/to-find-the-integartion-of-area-drawn-using-graphical-cut/51386 "2022-08-29T18:38:07Z")

</div>

Hi there I am trying to find the number of counts inside the Graphical cut on my 2D histo which I created using graphical cut in gPad and saved that cut as a cut.c file. How can I do that, I already tried to use Integ…

---

## [Https://root-forum.cern.ch/t/unable-to-display-the-histogram-entries-and-standard-deviation/50280](https://root-forum.cern.ch/t/https-root-forum-cern-ch-t-unable-to-display-the-histogram-entries-and-standard-deviation-50280/51388)

<div class="topic-metadata">

**Author:** [@gini](https://root-forum.cern.ch/u/gini)\
**Replies:** 3\
**Last updated:** [August 29, 2022, 11:05am UTC](https://root-forum.cern.ch/t/https-root-forum-cern-ch-t-unable-to-display-the-histogram-entries-and-standard-deviation-50280/51388 "2022-08-29T11:05:32Z")

</div>

Hi, I am trying to make comparison of some already published data with my results. For which I need to extract data (Gaussian shaped histograms mainly). So what I do is I extract the X and Y data points from a graph and…

---

## [Error in \<TNetXNGFile::ReadBuffers\>: \[ERROR\] Socket timeout](https://root-forum.cern.ch/t/error-in-tnetxngfile-readbuffers-error-socket-timeout/51380)

<div class="topic-metadata">

**Author:** [@hsaka](https://root-forum.cern.ch/u/hsaka)\
**Replies:** 1\
**Last updated:** [August 29, 2022, 8:38am UTC](https://root-forum.cern.ch/t/error-in-tnetxngfile-readbuffers-error-socket-timeout/51380 "2022-08-29T08:38:44Z")

</div>

Dear experts, I am trying to access the centrally stored nanoAOD files and I get errors of the following type while opening/accessing a subset of them (TChain or TFile open): Error in \<TNetXNGFile::ReadBuffers\>: \[ERROR…

---

## [Saving plot as root file](https://root-forum.cern.ch/t/saving-plot-as-root-file/51384)

<div class="topic-metadata">

**Author:** [@gurmukh\_dhindsa](https://root-forum.cern.ch/u/gurmukh_dhindsa)\
**Replies:** 2\
**Last updated:** [August 29, 2022, 4:51am UTC](https://root-forum.cern.ch/t/saving-plot-as-root-file/51384 "2022-08-29T04:51:52Z")

</div>

Hi there Assume I have a root file that contains Tree-\> Iris and under this tree, I have branch -\>det and then I have many leaves, like TSd1rEnergy, TSd1rTheta, and so on. Now I want to save the plot generated using Iri…

---

## [How to open/execute .root file](https://root-forum.cern.ch/t/how-to-open-execute-root-file/51366)

<div class="topic-metadata">

**Author:** [@Ema22](https://root-forum.cern.ch/u/Ema22)\
**Replies:** 3\
**Last updated:** [August 28, 2022, 12:59pm UTC](https://root-forum.cern.ch/t/how-to-open-execute-root-file/51366 "2022-08-28T12:59:13Z")

</div>

Hello, I’m trying to open .root file, which is the output file of the classification and parameter optimization that I made in c language. I tried root -l filename which only returns the value of the TFile \*. Can you p…

---

## [TProfile memory usage](https://root-forum.cern.ch/t/tprofile-memory-usage/51368)

<div class="topic-metadata">

**Author:** [@Ziraxis](https://root-forum.cern.ch/u/Ziraxis)\
**Replies:** 1\
**Last updated:** [August 28, 2022, 12:00pm UTC](https://root-forum.cern.ch/t/tprofile-memory-usage/51368 "2022-08-28T12:00:55Z")

</div>

Hello, I am using root to process raw data from a detector and currently trying to find ways to increase precision along with memory usage as well as lower (or at least keep) used disk space. Previously, I have tried s…

---

## [Reading data on ROOT and perform calculations on the data in python](https://root-forum.cern.ch/t/reading-data-on-root-and-perform-calculations-on-the-data-in-python/51319)

<div class="topic-metadata">

**Author:** [@AndreM](https://root-forum.cern.ch/u/AndreM)\
**Replies:** 12\
**Last updated:** [August 26, 2022, 3:10pm UTC](https://root-forum.cern.ch/t/reading-data-on-root-and-perform-calculations-on-the-data-in-python/51319 "2022-08-26T15:10:46Z")

</div>

Hello, i dont have any backgrounds on C++ but i understand the basics of ROOT. I need to read a given set of data, some columns, on a .root file to perform some calculations. The thing is my routine is written in python …

---

## [Drawing TGraphErr](https://root-forum.cern.ch/t/drawing-tgrapherr/51357)

<div class="topic-metadata">

**Author:** [@Dil](https://root-forum.cern.ch/u/Dil)\
**Replies:** 3\
**Last updated:** [August 26, 2022, 3:05pm UTC](https://root-forum.cern.ch/t/drawing-tgrapherr/51357 "2022-08-26T15:05:56Z")

</div>

Hello Rooters, I am trying to draw a TGraphErr for my separate binning(Attached2D histogram).But I got empty canvas.Could you please help me? Please see the snippet. const int nxB=3, nQ2=4; int nbins\_mpipi=5.0; int n…

---

## [How to Write histo in root file with log and colz option](https://root-forum.cern.ch/t/how-to-write-histo-in-root-file-with-log-and-colz-option/51352)

<div class="topic-metadata">

**Author:** [@ajalotra](https://root-forum.cern.ch/u/ajalotra)\
**Replies:** 5\
**Last updated:** [August 26, 2022, 1:51pm UTC](https://root-forum.cern.ch/t/how-to-write-histo-in-root-file-with-log-and-colz-option/51352 "2022-08-26T13:51:07Z")

</div>

How to Write Histogram in Root file with colz and log option: This is how i’m trying but my root file does not have the histo in colz and log option it is just a simple 2D histogram void point() { TString file = “o…

---

## [Relative error of the ratio](https://root-forum.cern.ch/t/relative-error-of-the-ratio/51317)

<div class="topic-metadata">

**Author:** [@Dil](https://root-forum.cern.ch/u/Dil)\
**Replies:** 7\
**Last updated:** [August 24, 2022, 3:11pm UTC](https://root-forum.cern.ch/t/relative-error-of-the-ratio/51317 "2022-08-24T15:11:24Z")

</div>

Hello Rooters, I have two histograms called h\_simu and h\_gen(2D hist). Applied SumW2 option before filling the histograms.Then I took the ratio of these two histograms. h\_ratio= h\_simu/h\_gen I need to calculate the “r…

---

## [TMultiGraph with two Y-axis](https://root-forum.cern.ch/t/tmultigraph-with-two-y-axis/51294)

<div class="topic-metadata">

**Author:** [@NikkieD](https://root-forum.cern.ch/u/NikkieD)\
**Replies:** 13\
**Last updated:** [August 24, 2022, 1:36pm UTC](https://root-forum.cern.ch/t/tmultigraph-with-two-y-axis/51294 "2022-08-24T13:36:50Z")

</div>

Dear All, I’m trying to plot a total of 8 TGraphs in a multigraph with two Y-axes, and that is where the problems started. I managed to draw the two Y-axes, but the axes range of the left Y-axis is wrong (should be 4 -…

---

## [TSelector: documentation disagreement with actual behavior](https://root-forum.cern.ch/t/tselector-documentation-disagreement-with-actual-behavior/51316)

<div class="topic-metadata">

**Author:** [@nefedov](https://root-forum.cern.ch/u/nefedov)\
**Replies:** 1\
**Last updated:** [August 24, 2022, 12:29pm UTC](https://root-forum.cern.ch/t/tselector-documentation-disagreement-with-actual-behavior/51316 "2022-08-24T12:29:20Z")

</div>

Hello, I’m looking for a way to “safely” stop iterating over an event in the TSelector class and store the result (histograms, trees, etc.). TSelector Class Reference: v626/classTSelector.html: Bool\_t TSelector::Proc…

---

## [GetRandom() not working for peak functions](https://root-forum.cern.ch/t/getrandom-not-working-for-peak-functions/51304)

<div class="topic-metadata">

**Author:** [@Erich\_Leistenschneid](https://root-forum.cern.ch/u/Erich_Leistenschneid)\
**Replies:** 3\
**Last updated:** [August 24, 2022, 8:28am UTC](https://root-forum.cern.ch/t/getrandom-not-working-for-peak-functions/51304 "2022-08-24T08:28:22Z")

</div>

Hi y’all, I think I may be doing something stupid with TRandom. I am trying to build a quite complex distribution of random numbers composed of several Lorentzians on top of a polynomial background. However, the outpu…

---

## [Plot with white bin](https://root-forum.cern.ch/t/plot-with-white-bin/51297)

<div class="topic-metadata">

**Author:** [@Dil](https://root-forum.cern.ch/u/Dil)\
**Replies:** 1\
**Last updated:** [August 23, 2022, 7:43pm UTC](https://root-forum.cern.ch/t/plot-with-white-bin/51297 "2022-08-23T19:43:09Z")

</div>

Hello Rooters, I have attached plot.Could some one explain what is this “White bin” represent? If it is 0,It should be dark blue. Thanks Dil

---

## [X axis max/min Tgraph](https://root-forum.cern.ch/t/x-axis-max-min-tgraph/51293)

<div class="topic-metadata">

**Author:** [@robygru](https://root-forum.cern.ch/u/robygru)\
**Replies:** 5\
**Last updated:** [August 23, 2022, 2:26pm UTC](https://root-forum.cern.ch/t/x-axis-max-min-tgraph/51293 "2022-08-23T14:26:05Z")

</div>

Hi, is there a way to take the max and the min X value from a Tgraph? I’ve a TTree and i need the range xmax-xmin of the graph i have from the ttree.

---

## [Using a variable from a loop when saving a histogram](https://root-forum.cern.ch/t/using-a-variable-from-a-loop-when-saving-a-histogram/51286)

<div class="topic-metadata">

**Author:** [@Ramin](https://root-forum.cern.ch/u/Ramin)\
**Replies:** 6\
**Last updated:** [August 23, 2022, 9:59am UTC](https://root-forum.cern.ch/t/using-a-variable-from-a-loop-when-saving-a-histogram/51286 "2022-08-23T09:59:00Z")

</div>

Hello, everyone. I have the following situation: A for loop where I vary a certain variable which contains another loop where I fill the histogram. Then I would like to store the histogram (by means of SaveAs). As I wi…

---

## [Reading leaf from a tree](https://root-forum.cern.ch/t/reading-leaf-from-a-tree/51061)

<div class="topic-metadata">

**Author:** [@Ramin](https://root-forum.cern.ch/u/Ramin)\
**Replies:** 2\
**Last updated:** [August 23, 2022, 8:50am UTC](https://root-forum.cern.ch/t/reading-leaf-from-a-tree/51061 "2022-08-23T08:50:23Z")

</div>

Hi, all. I am trying to read a leaf from a tree (I would like to get data from @size leaf), but without any progress so far. I have tried the following code: void treereader2() { TFile \*f = TFile::Open("bmndst4700\_BM…

---

## [Fitting Signal + Background for Th1F](https://root-forum.cern.ch/t/fitting-signal-background-for-th1f/51279)

<div class="topic-metadata">

**Author:** [@mpokh001](https://root-forum.cern.ch/u/mpokh001)\
**Replies:** 4\
**Last updated:** [August 23, 2022, 7:34am UTC](https://root-forum.cern.ch/t/fitting-signal-background-for-th1f/51279 "2022-08-23T07:34:29Z")

</div>

Please read tips for efficient and successful posting and posting code ROOT Version: 6.18/02 Platform: Macos \_Compiler:\_c++ Hi Experts, I am trying to fit a TH1F with a gaussian signal plus two linear background o…

---

## [Create new root file which contains all histograms , after fitting histograms from old root file](https://root-forum.cern.ch/t/create-new-root-file-which-contains-all-histograms-after-fitting-histograms-from-old-root-file/51262)

<div class="topic-metadata">

**Author:** [@gurmukh\_dhindsa](https://root-forum.cern.ch/u/gurmukh_dhindsa)\
**Replies:** 7\
**Last updated:** [August 22, 2022, 8:05pm UTC](https://root-forum.cern.ch/t/create-new-root-file-which-contains-all-histograms-after-fitting-histograms-from-old-root-file/51262 "2022-08-22T20:05:14Z")

</div>

\#include \<stdio.h\> #include #include #include “TCanvas.h” #include “TF1.h” #include “TFile.h” #include “TGraphErrors.h” #include “TH1.h” #include “TH2.h” #include “TSpectrum.h” using namespace std; Double\_t …

---

## [All generated pdf's into one pdf](https://root-forum.cern.ch/t/all-generated-pdfs-into-one-pdf/51266)

<div class="topic-metadata">

**Author:** [@gurmukh\_dhindsa](https://root-forum.cern.ch/u/gurmukh_dhindsa)\
**Replies:** 2\
**Last updated:** [August 22, 2022, 12:39pm UTC](https://root-forum.cern.ch/t/all-generated-pdfs-into-one-pdf/51266 "2022-08-22T12:39:43Z")

</div>

\#include \<stdio.h\> #include #include #include “TCanvas.h” #include “TF1.h” #include “TFile.h” #include “TGraphErrors.h” #include “TH1.h” #include “TH2.h” #include “TSpectrum.h” using namespace std; int histo…

---

## [Plot Calculated Errors in an existing Histogram](https://root-forum.cern.ch/t/plot-calculated-errors-in-an-existing-histogram/51192)

<div class="topic-metadata">

**Author:** [@Ankur](https://root-forum.cern.ch/u/Ankur)\
**Replies:** 5\
**Last updated:** [August 22, 2022, 8:33am UTC](https://root-forum.cern.ch/t/plot-calculated-errors-in-an-existing-histogram/51192 "2022-08-22T08:33:48Z")

</div>

I plotted the histogram given below: h221=(TH1D\*)f-\>Get("hrate\_all\_rule0"); I calculated the errors (not the one produced by GetBinError, default by ROOT) for the above histogram and stored them in: TH1D \*errACP0NH\_…

---

## [Fitting data](https://root-forum.cern.ch/t/fitting-data/51257)

<div class="topic-metadata">

**Author:** [@flyinpenguin](https://root-forum.cern.ch/u/flyinpenguin)\
**Replies:** 7\
**Last updated:** [August 22, 2022, 7:22am UTC](https://root-forum.cern.ch/t/fitting-data/51257 "2022-08-22T07:22:50Z")

</div>

Dear all, I’m a newbie in root and coding. My purpose is to get data points from an image and using that data create a graph and find the best fitting so that I can get the fit parameters. From the image below I got the…

---

## [Summing a large number of TF1](https://root-forum.cern.ch/t/summing-a-large-number-of-tf1/51249)

<div class="topic-metadata">

**Author:** [@delia](https://root-forum.cern.ch/u/delia)\
**Replies:** 4\
**Last updated:** [August 19, 2022, 1:01pm UTC](https://root-forum.cern.ch/t/summing-a-large-number-of-tf1/51249 "2022-08-19T13:01:22Z")

</div>

Hello, I am new to the forum. To anyone who might be able to help me: thank you in advance! My problem is the following: I have defined my function: TF1 \* eFunc = new TF1(“eFunc” , “(TMath::Erf((x-\[0\])/\[1\]))\*\[2\]”, 21…

---

## [2D Histogram - similar to imshow() in python](https://root-forum.cern.ch/t/2d-histogram-similar-to-imshow-in-python/51109)

<div class="topic-metadata">

**Author:** [@TheScientist](https://root-forum.cern.ch/u/TheScientist)\
**Replies:** 1\
**Last updated:** [August 16, 2022, 8:51am UTC](https://root-forum.cern.ch/t/2d-histogram-similar-to-imshow-in-python/51109 "2022-08-16T08:51:46Z")

</div>

I am trying to create a 2D histogram similar to the one shown below in ROOT/PyROOT. In python, it was made with imshow() as the data structure is in 2D array: wire1/channel number1 \[( ADC1, ADC2, …)\] wire2/channelnumb…

---

## [Using ROOT prompt commands in a C script](https://root-forum.cern.ch/t/using-root-prompt-commands-in-a-c-script/51204)

<div class="topic-metadata">

**Author:** [@theittsco](https://root-forum.cern.ch/u/theittsco)\
**Replies:** 1\
**Last updated:** [August 16, 2022, 8:42am UTC](https://root-forum.cern.ch/t/using-root-prompt-commands-in-a-c-script/51204 "2022-08-16T08:42:34Z")

</div>

Hello, trying to write a root compiled C script to calculate how many files are in a premade root file. My current strategy is to Move into a directory using \<directory name\>-\>cd() Then count the number of contents in…

---

## [Save after setting histogram bin](https://root-forum.cern.ch/t/save-after-setting-histogram-bin/51206)

<div class="topic-metadata">

**Author:** [@abunka](https://root-forum.cern.ch/u/abunka)\
**Replies:** 1\
**Last updated:** [August 16, 2022, 12:05am UTC](https://root-forum.cern.ch/t/save-after-setting-histogram-bin/51206 "2022-08-16T00:05:20Z")

</div>

Hello all, this one should be pretty basic. I can’t seem to get a histogram change to stick: root \[0\] TFile \*\_file0 = TFile::Open("file.root") (TFile \*) 0x408e8d0 root \[1\] hJetPT-\>GetBinContent(17) (double) 11.000000 r…

---

## [TLine: Line in 2D TGraph](https://root-forum.cern.ch/t/tline-line-in-2d-tgraph/51151)

<div class="topic-metadata">

**Author:** [@TheScientist](https://root-forum.cern.ch/u/TheScientist)\
**Replies:** 1\
**Last updated:** [August 15, 2022, 12:01pm UTC](https://root-forum.cern.ch/t/tline-line-in-2d-tgraph/51151 "2022-08-15T12:01:39Z")

</div>

I am trying to draw a vertical line in 2D graph. However, line is not showing up for some reason. I am trying to draw line from x-axis 47 to all the way to top of the y-axis. Here is my code: g = ROOT.TGraph2D() for x …

---

## [Input string/int in a file name](https://root-forum.cern.ch/t/input-string-int-in-a-file-name/51186)

<div class="topic-metadata">

**Author:** [@robygru](https://root-forum.cern.ch/u/robygru)\
**Replies:** 6\
**Last updated:** [August 14, 2022, 7:32pm UTC](https://root-forum.cern.ch/t/input-string-int-in-a-file-name/51186 "2022-08-14T19:32:33Z")

</div>

Hi, is there a way to put an input value into a SaveAs file name? I have lot of saveas and i don’t want to change manually all the name of the file for each canvas i save.

[Previous page](https://root-forum.cern.ch/c/newbie/26.md?page=45)

[Next page](https://root-forum.cern.ch/c/newbie/26.md?page=47)
