How to have different bin widths for a histogram in a .root file?

{
  TH1F *source = new TH1F("source", "source", 100, -3., 3.);
  source->FillRandom("gaus", 1000);
  
  Double_t Lower[5]; // [nbinsx + 1]
  // make sure new bin edges correspond to bin edges in the original histogram
  Lower[0] = source->GetBinLowEdge(1); // xlow
  Lower[1] = source->GetBinLowEdge(source->FindFixBin(-1.));
  Lower[2] = source->GetBinLowEdge(source->FindFixBin(2.));
  Lower[3] = source->GetBinLowEdge(source->FindFixBin(2.5));
  Lower[4] = source->GetBinLowEdge(source->GetNbinsX() + 1); // xup
  if (!source->GetSumw2N()) source->Sumw2(kTRUE); // needed for correct new errors
  TH1 *hist = (TH1*)source->Rebin((sizeof(Lower) / sizeof(Double_t) - 1),
                                  "hist", Lower);
  hist->SetTitle("hist is the rebinned source");
  
  TCanvas *c = new TCanvas("c", "c");
  c->Divide(1, 2);
  c->cd(1);
  source->Draw("HIST");
  c->cd(2);
  hist->Draw("HIST");
  c->cd(0);
}