How to do gain matching from a calibrated data?

Do you have you some preliminary ROOT code already ?