# Optimal shift value

**URL:** <https://root-forum.cern.ch/t/optimal-shift-value/41366>\
**Category:** Newbie\
**Created:** [September 9, 2020, 6:28pm UTC](https://root-forum.cern.ch/t/optimal-shift-value/41366 "2020-09-09T18:28:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Newbie](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/dc4da7/32.png) [@Newbie](https://root-forum.cern.ch/u/Newbie)\
**Post date:** [September 9, 2020, 6:28pm UTC](https://root-forum.cern.ch/t/optimal-shift-value/41366/1 "2020-09-09T18:28:56Z")

</div>

Dear,

I have two TH1’s, which in the ideal case should be very similar (typical data/MC plot). However, you can see with the naked eye that there is a shift difference between the two.

Is there a function/test/way to find the optimal shift value that would be applied to the MC such that the difference between the two histograms is minimized?

Many thanks!

---

<div class="post-metadata">

**Author:** ![Fanurs](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/fanurs/32/25233_2.png) [@Fanurs](https://root-forum.cern.ch/u/Fanurs)\
**Post date:** [September 15, 2020, 2:44am UTC](https://root-forum.cern.ch/t/optimal-shift-value/41366/2 "2020-09-15T02:44:17Z")

</div>

Have you tried looking into `Double_t TH1::KolmogorovTest()`?

[https://root.cern.ch/doc/master/classTH1.html#aeadcf087afe6ba203bcde124cfabbee4](https://root.cern.ch/doc/master/classTH1.html#aeadcf087afe6ba203bcde124cfabbee4)

The Kolmogorov test returns value between 0 and 1; 0 means incompatible, 1 means compatible.

If you want to use it in some minimizer algorithm, you can choose to minimizer the value given by `1.0 - KolmogorovTest()`.

Cheers!
