# 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:** 7

<div class="post-metadata">

**Author:** ![HEPatUTStudent](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/ee59a6/32.png) [@HEPatUTStudent](https://root-forum.cern.ch/u/HEPatUTStudent)\
**Post date:** [July 23, 2007, 2:39pm UTC](https://root-forum.cern.ch/t/change-scale-of-a-th1f-energy-calibration/4971/7 "2007-07-23T14:39:31Z")

</div>

Hi,

I used this trick in a similar situation:

const int nbins = h1-\>GetXaxis()-\>GetNbins();  
double new\_bins[nbins+1];  
for(int i=0; i \< nbins; i++){  
new\_bins[i] = transform\_function( h1-\> GetBinLowEdge(i+1) );  
}

h1-\>Set(nbins, new\_bins);

This will of course result in uneven binwidths if your transoformation is not linear, but does not require rebinning, etc.

Cheers!

---

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