Your issue is the sensor averages all the photon return times it gets to give you a distance.
So if your rod is the only thing in the field of view, then it works fine.
But with a background – especially a reflective background you are stuck.
The other problem is your distances. These sensors really don't do well at zero distance.
(Actually, we spend a lot of time trying to eliminate the signal which comes from the coverglass.)
But from your picture, your tube looks a lot like a coverglass.
Before you keep making experiments, attach a coverglass to your sensor.
Not having one and having the sensor touch stuff is going to cause debris to enter the cavity and it will ruin the sensor and ruin all your results.
I don't think the distance is going to give you good results. But consider using signal strength. Try looking at the signal strengths of the empty gripper and a full one. There might be enough difference to imply that the tube is there.
but to make this experiment, change the GetResult() function to use floating point. The integer arithmetic is simpler, but you need more accuracy.