Random track length in a rectangular cuboid

Unfortunately you cannot model this distribution other than discontinuous, since the actual traversal length has non continuous derivative depending on input direction/angles. Actually the procedure to get the analytical formula involves range-based integration: a ray may cross 2 opposite faces or 2 adjacent ones, depending on the entry point and direction. So no “widths” can be meaningful I’m afraid. What you can try is to understand the correlation of the relative heights of the spikes with the cuboid dimensions. The shape between spikes seems simple to model. If you worry about writing a TF1 with ranges, it is possible:

double xmax = sqrt(x1*x1 + x2*x2 + x3*x3);
TF1 f("f", "(x<[0])?func1:(x<[1])?func2:(x<[2])?func3:func4", 0, xmax);
f.SetParameter(0, x1);
f.SetParameter(1, x2);
f.SetParameter(2, x3);