  We describe the calibration and imaging heuristics developed and deployed in
the ALMA interferometric data processing pipeline, as of ALMA Cycle 9. The
pipeline software framework is written in Python, with each data reduction
stage layered on top of tasks and toolkit functions provided by the Common
Astronomy Software Applications package. This framework supports a variety of
tasks for observatory operations, including science data quality assurance,
observing mode commissioning, and user reprocessing. It supports ALMA and VLA
interferometric data along with ALMA and NRO45m single dish data, via different
stages and heuristics. In addition to producing calibration tables, calibrated
measurement sets, and cleaned images, the pipeline creates a WebLog which
serves as the primary interface for verifying the data quality assurance by the
observatory and for examining the contents of the data by the user. Following
the adoption of the pipeline by ALMA Operations in 2014, the heuristics have
been refined through annual development cycles, culminating in a new pipeline
release aligned with the start of each ALMA Cycle of observations. Initial
development focused on basic calibration and flagging heuristics (Cycles 2-3),
followed by imaging heuristics (Cycles 4-5), refinement of the flagging and
imaging heuristics with parallel processing (Cycles 6-7), addition of the
moment difference analysis to improve continuum channel identification (2020
release), addition of a spectral renormalization stage (Cycle 8), and
improvement in low SNR calibration heuristics (Cycle 9). In the two most recent
Cycles, 97% of ALMA datasets were calibrated and imaged with the pipeline,
ensuring long-term automated reproducibility. We conclude with a brief
description of plans for future additions, including self-calibration,
multi-configuration imaging, and calibration and imaging of full polarization
data.
