With the upper still in an upper vise block (such as the open top design) point the barrel bore at a distance target, then look down the sights. Both should be looking at the same point (vertical).
In regards to drifting the barrel in the upper socket for fine-tuning with the rifle completely built, you hold only the upper receiver, and use a leather mallet to make a blow at the base of the sight tower to drift the entire barrel in the upper barrel socket. Unlike a threaded barrel into a receiver, the AR barrel/extension is tension retained by the barrel nut only. The barrel extension pin is used for indexing the barrel, but due to methods of barrel installation, the barrel can rotate due to either the pin slightly bending, slop in the upper socket slot, or the pin digging into the upper pin socket when the barrel nut is tightened. This method of drifting the entire barrel using a leather mallet is very, very faster than pulling the barrel and shimming the pin into a new desired location in the socket slot.
_______________
Some will post saying that shimming the pin is the better way, and at one time I used to correct the final firing for effect zero that way (rear sight centered). This is when I had way too much time on my hands and could screw around resetting the barrel index until I get it just were I want to be in regards to the front tower indexed to center out the rear sight for zero (read hours including fire testing). Now with the leather mallet, the final fine tuning of the index of the front sight tower under live fire takes me around 10 shots, at the range, and is completed in less than a few minutes.
As for the barrel holding it zero by either leather mallet, or removal and shimming, they will both hold index the same. If the barrel takes a hit hard enough to drift the front tower if leather mallet drifted, then even it the extension pin is shimmed tight, it will still either bend the pin or the pin will indent the slot causing a front tower index shift.