How to pass values from a tree variable to histogram?

Hello everyone,

I want to pass values from a tree variable to the histogram. For that, I wrote the following code,

// Histogram "h"
TH1F *h = new TH1F("h", "h", 100, -150, 150);

// "X_tree" is the tree.
// "X_trck[0]" is the variable of interest.
// -9999. is junk data which I want to exclude.
// This line pass variable information to histogram "h".
// But this also plots it, which I don't want.
X_tree -> Draw("X_trck[0] >> h", "-9999. < X_trck[0]");

As I am using the Draw() command, it is showing the plot of a histogram, which I don’t want.

So, is there any way to do the same thing without plotting a histogram?

Add the option goff

Hi @dastudillo,

Your solution worked, thanks for that. But there are two more lines in my code that are generating the plot.

// "fit" is  TF1 *fit[10];
// for loop starts
fit[i] = new TF1(Form("fit[%d]", i), "gaus", -150, 150);
h[i] -> Fit(Form("fit[%d]", i), "RQ");

Here I am fitting the histogram. But the same thing, it is generating a plot. Any suggestion to suppress that.

My last question has already been answered here: Fit an histogram without drawing it

So, h[i] -> Fit(Form("fit[%d]", i), "0RQ"); solved my problem.

Thank you.