Functional coverage for three dimensional packed array

In reply to Harshad:

Just one question, sv LRM using “ref” keyword inside sample function like
“…covergroup cg(int min, int max) with function sample(ref int slice);”
So question is that when to use ref and when not ?