# Change scale of a TH1F (energy calibration)

**URL:** <https://root-forum.cern.ch/t/change-scale-of-a-th1f-energy-calibration/4971>\
**Category:** ROOT\
**Created:** [July 3, 2007, 4:01pm UTC](https://root-forum.cern.ch/t/change-scale-of-a-th1f-energy-calibration/4971 "2007-07-03T16:01:34Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![brun](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/b9e5f3/32.png) [@brun](https://root-forum.cern.ch/u/brun)\
**Post date:** [July 4, 2007, 6:50am UTC](https://root-forum.cern.ch/t/change-scale-of-a-th1f-energy-calibration/4971/4 "2007-07-04T06:50:57Z")

</div>

OK now I understand your question. This is possible with some approximation as in principle to make a clean operation you would need to start from teh original unbinned x values. The approximation could be the following

` TH1F *h; //your original histogram
   int nbins = h->GetXaxis()->GetNbins();
   TH1F *hnew = new TH1F("hnew","title",nbins,xminnew,xmaxnew);
   for (int i=1;i<=nbins;i++0 {
      double y = h->getBinContent(i);
      double x = h->GetXaxis()->GetBinCenter(i);
      double xnew = alpha*x + beta; //your transformation
      hnew->Fill(xnew,y);
   }
`  
You may want to look also to TH1::Rebin (case xbins != 0) and see the procedure to recmpute errors in case the original hist has errors.

Rene

---

_[View the full topic](https://root-forum.cern.ch/t/change-scale-of-a-th1f-energy-calibration/4971)._
