  Doppler spectroscopy has uncovered or confirmed all the known planets
orbiting nearby stars. Two main techniques are used to obtain precision Doppler
measurements at optical wavelengths. The first approach is the gas cell method,
which consists on the least-squares matching of the spectrum of Iodine
imprinted on the spectrum of the star. The second method relies on the
construction of a stabilized spectrograph externally calibrated in wavelength.
The most precise stabilized spectrometer in operation is HARPS, operated by ESO
in La Silla Observatory/Chile. The Doppler measurements obtained with HARPS are
typically obtained using the Cross-Correlation Function technique (CCF). It
consists of multiplying the stellar spectrum with a weighted binary mask and
finding the minimum of such product as a function of the Doppler shift. It is
known that CCF is suboptimal in exploiting the Doppler information in the
stellar spectrum. Here, we describe an algorithm to obtain precision RV
measurements using least-squares matching of each observed spectrum to a high
signal-to-noise ratio template derived from the same observations. Such
algorithm is implemented in our software called HARPS-TERRA (Template Enhanced
Radial velocity Re-analysis Application). New radial velocity measurements on a
representative sample of stars observed by HARPS is used to illustrate the
benefits of the proposed method. We show that, compared to CCF, template
matching provides a significant improvement in accuracy, specially when applied
to M dwarfs.
