Calibrate Z rotation of tool

Hello Community,

I’m trying to develop a function to calibrate the Y rotation of my tool or the Z rotation in the default flange TCP based on a original tool TCP. I need this because the tool con loosely rotate and the rotation can not be guaranteed from run to run. A setup is made where robot moves to a position, turns on freedrive and then the user rotations the tool so it fits into a fixture. This is what it looks like right before placement of the tool into the fixture in freedrive mode:


How do I make this function to set a new TCP based on the original TCP and the new one after the calibration?
My original tool tcp is p[0.0005, 0.001, 0.13741, -1.5324, -0.3603, -0.3585]