The difference between htemp got by TTree::Draw() and TH1F object

hi everyone,
I ran into a problem with TTree::Draw() and TH1F.
I got two different mean when using TTree::Draw() and TH1F
The code is following:

TH1F *hist1;
TH1F *hist2;
tree->SetBranchAddress("weight", &weight);
for (int j = 0; j < tree->GetEntries(); j++)

I wonder what’s the difference between them, thank you all.

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

Make sure you use something like this:

int nbins = 100; // set a reasonable value
double xmin = 0., xmax = 100.; // set reasonable values
gROOT->cd(); // newly created histograms should go here
TH1F *hist1 = new TH1F("hist1", "my hist 1;my x;my y", nbins, xmin, xmax);
TH1F *hist2 = new TH1F("hist2", "my hist 2;my x;my y", nbins, xmin, xmax);

Yes,I created the hist just like you did.

TH1F* hist1=new TH1F("hist1","", 100, 0, 100);
TH1F* hist2=new TH1F("hist2","", 100, 0, 100);

Hi @YULianzhou ,

could this be a precision issue in TH1F? Do you still see the problem if you switch to TH1D (with double precision bins)?