The definition of environment and its relation to the quenching of galaxies at z=1-2 in a hierarchical Universe