subroutine pitch (b, theta, phi, alpha) c c------------------------------------------------------------------------ c This routine calculates the pitch angle of a particle from a unit c direction defined by a theta (polar ang) and a phi (azimuthal ang) c------------------------------------------------------------------------ c dimension b(3) c c------------------------------------------------------------------------ c all input and output angles are in degrees c------------------------------------------------------------------------ c radeg = 3.14159 / 180.0 thetar = theta * radeg phir = phi * radeg c c------------------------------------------------------------------------ c strip out the b field components c------------------------------------------------------------------------ c bx = b(1) by = b(2) bz = b(3) bmag = sqrt(bx * bx + by * by + bz * bz) c c------------------------------------------------------------------------ c first solve for cos(alpha) c------------------------------------------------------------------------ c uniti = bx * sin(thetar) * cos(phir) unitj = by * sin(thetar) * sin(phir) unitk = bz * cos(thetar) cosalp = (uniti + unitj + unitk) / bmag c c------------------------------------------------------------------------ c calculate the pitch angle in degrees c alpdr is the pitch angle of the detector in radians c------------------------------------------------------------------------ c alpdr = acos(cosalp) alpdd = alpdr / radeg alpha = 180.0 - alpdd c c------------------------------------------------------------------------ c------------------------------------------------------------------------ c return end