In Stern-Gerlach experiment, where does wavefunction collapse? I was reading Sakurai's Modern QM and it talks about Stern-Gerlach experiment in chapter 1. As silver atom passes through non-uniform magnetic field and enters detector downstream, a measurement is made and the atom collapses into either Sz+ or Sz- eigenstate.
Now I am a bit confused, does silver atom's wavefunction collapses as it enters B-field or the detector? The former doesn't make sense because there are magnetic field everywhere on earth so does it mean wavefunction is always collapsed (in the direction of local magnetic field gradient)? Sure the non-homogeneity of earth's magnetic field is orders of magnitude smaller than the apparatus in Stern-Gerlach experiment, but if magnitude of B-field gradient is the answer does it imply that that there exist a threshold magnetic gradient below which wavefunction won't collapse? That doesn't sound right either.
I am more inclined to think that the particle detector collapses the wavefunction. If that's the case, what's so special about the detector that causes wavefunction to collapse? I mean, particle detector like scintillators ultimately relies on EM interaction between silver atom and detector material to generate electric signal. If magnetic interaction with the magnet downstream doesn't collapse the wavefunction, how could EM interaction inside the detector collapse the wavefunction?
 A: Wave function collapse is a change of wave function that we do at certain time of experimenting "by hand", "because we get new facts", as opposed to a change of wave function determined by past data and Schroedinger's equation. It is a fix for our inability to get the new fact purely from calculations. One such fact is detection of the atom at one of few possible beams or landing spots.
When the atom passes through magnetic field without interacting with position-revealing devices, we do not invoke collapse, because we have no reason to - it is fine evolving the wave function just using the Schroedinger's equation there.
When the atom is detected at a screen and we get new information about its position (and its spin state), this is more than calculated wave function implies, and this allows us to update the wave function we got from Schroedinger's equation using the new fact.
A: Aside: "Collapse of the wavefunction" unfortunately is a wide spread terminology that appeals to popularization of science articles. In the mathematics of quantum mechanics it means that "the boundary conditions have changed and a new wavefunction must describe the system after the so called collapse" . It is a word that describe an instant in time where the wavefunction changes.
In the experiment the silver atoms travel outside the magnetic field ,( the earth's field is very weak to enter in the calculations for the experiment, if you read the link below) and the beam splits according to the three values of the magnetic moment for the silver atom. So it is the magnetic field that picks the probable path of the individual atom.

In the original experiment, silver atoms were sent through a spatially varying magnetic field, which deflected them before they struck a detector screen, such as a glass slide. Particles with non-zero magnetic moment are deflected, due to the magnetic field gradient, from a straight path. The screen reveals discrete points of accumulation, rather than a continuous distribution,1 owing to their quantized spin.

For the experiment with silver atoms it is its intrinsic magnetic moment that shows up in the experiment. The history is given here.


Figure 12. Sketch of the Stern-Gerlach experimental apparatus. The result expected for atoms in an L=1 state (three components) is shown. From Weinert (1995).

The beam of silver atoms has variously oriented magnetic moments. Passing through the strong magnetic field , classical physics expects  a uniform distribution, but the experiment shows the quantized (3 states for l=1) nature of the magnetic moment.
The wave function of the individual silver atom had the magnetic moment of the atom in a distribution according to the wavefunction describing it. The interaction of the magnetic moment of the individual atom with the magnetic field ( through the exchange of virtual photons) changes(collapses) the wave function to a new one that gives a specific angle for the trajectory according to the probability of the interaction with the magnetic moment. On the screen is a second interaction , of the individual atoms hitting the screen and interacting with its atoms.
