I have reorganised your macro because you were setting again and again the title of the histogram. Here is the new version:
void bin_histo() {
TFile *f = new TFile("DtoKpipi0_RS_mc14ri_a_withoutenergy.root");
TTree *tree = (TTree*)f->Get("DstD0PiKPiPi0RS_withcut");
Double_t pi0_m_prefit, pi0_errm;
tree->SetBranchAddress("pi0_m_prefit",&pi0_m_prefit);
tree->SetBranchAddress("pi0_errm",&pi0_errm);
Double_t pi0_M_PDG = 0.1349768;
TH1F *h1 = new TH1F("pi0_M_preFit_0to0.0031","",100, 0.1, 0.18);
h1->GetXaxis()->SetTitle("pi0_M_preFit [GeV/c^{2}]");
h1->GetXaxis()->SetTitleSize(0.05);
h1->GetXaxis()->CenterTitle();
TH1F *h2 = new TH1F("pi0_M_preFit_0.0031to0.00349","",100, 0.1, 0.18);
h2->GetXaxis()->SetTitle("pi0_M_preFit [GeV/c^{2}]");
h2->GetXaxis()->SetTitleSize(0.05);
h2->GetXaxis()->CenterTitle();
TH1F *h3 = new TH1F("pi0_M_preFit_0.00349to0.00375","",100, 0.1, 0.18);
h3->GetXaxis()->SetTitle("pi0_M_preFit [GeV/c^{2}]");
h3->GetXaxis()->SetTitleSize(0.05);
h3->GetXaxis()->CenterTitle();
TH1F *h4 = new TH1F("pi0_M_preFit_0.00375to0.00395","",100, 0.1, 0.18);
h4->GetXaxis()->SetTitle("pi0_M_preFit [GeV/c^{2}]");
h4->GetXaxis()->SetTitleSize(0.05);
h4->GetXaxis()->CenterTitle();
TH1F *h5 = new TH1F("pi0_M_preFit_0.00395to0.00411","",100, 0.1, 0.18);
h5->GetXaxis()->SetTitle("pi0_M_preFit [GeV/c^{2}]");
h5->GetXaxis()->SetTitleSize(0.05);
h5->GetXaxis()->CenterTitle();
TH1F *h6 = new TH1F("pi0_M_preFit_0.00411to0.00424","",100, 0.1, 0.18);
h6->GetXaxis()->SetTitle("pi0_M_preFit [GeV/c^{2}]");
h6->GetXaxis()->SetTitleSize(0.05);
h6->GetXaxis()->CenterTitle();
TH1F *h7 = new TH1F("pi0_M_preFit_0.00424to0.00435","",100, 0.1, 0.18);
h7->GetXaxis()->SetTitle("pi0_M_preFit [GeV/c^{2}]");
h7->GetXaxis()->SetTitleSize(0.05);
h7->GetXaxis()->CenterTitle();
TH1F *h8 = new TH1F("pi0_M_preFit_0.00435to0.00446","",100, 0.1, 0.18);
h8->GetXaxis()->SetTitle("pi0_M_preFit [GeV/c^{2}]");
h8->GetXaxis()->SetTitleSize(0.05);
h8->GetXaxis()->CenterTitle();
TH1F *h9 = new TH1F("pi0_M_preFit_0.00446to0.00456","",100, 0.1, 0.18);
h9->GetXaxis()->SetTitle("pi0_M_preFit [GeV/c^{2}]");
h9->GetXaxis()->SetTitleSize(0.05);
h9->GetXaxis()->CenterTitle();
TH1F *h10 = new TH1F("pi0_M_preFit_0.00456to0.00468","",100, 0.1, 0.18);
h10->GetXaxis()->SetTitle("pi0_M_preFit [GeV/c^{2}]");
h10->GetXaxis()->SetTitleSize(0.05);
h10->GetXaxis()->CenterTitle();
Int_t nentries = (Int_t)tree->GetEntries();
for (Int_t i=0; i<nentries; i++) {
tree->GetEntry(i);
if(pi0_errm > 0 && pi0_errm < 0.0031) h1->Fill(pi0_m_prefit);
if(pi0_errm > 0.0031 && pi0_errm < 0.00349) h2->Fill(pi0_m_prefit);
if(pi0_errm > 0.00349 && pi0_errm < 0.00375) h3->Fill(pi0_m_prefit);
if(pi0_errm > 0.00375 && pi0_errm < 0.00395) h4->Fill(pi0_m_prefit);
if(pi0_errm > 0.00395 && pi0_errm < 0.00411) h5->Fill(pi0_m_prefit);
if(pi0_errm > 0.00411 && pi0_errm < 0.00424) h6->Fill(pi0_m_prefit);
if(pi0_errm > 0.00424 && pi0_errm < 0.00435) h7->Fill(pi0_m_prefit);
if(pi0_errm > 0.00435 && pi0_errm < 0.00446) h8->Fill(pi0_m_prefit);
if(pi0_errm > 0.00446 && pi0_errm < 0.00456) h9->Fill(pi0_m_prefit);
if(pi0_errm > 0.00456 && pi0_errm < 0.00468) h10->Fill(pi0_m_prefit);
}
if (gROOT->IsBatch()) return;
new TBrowser();
}
So according to the value of pi0_errm you fill a different histogram. I you do not have two histograms but ten . The program you sent does not really matches with the explanations you gave.