The average of the pointwise product of a signal and a template is large when their signs stay aligned and cancels toward zero when they drift in and out of alignment.
Set the template and signal frequencies in whole cycles per window; the top band overlays the two waveforms and the bottom band shades their pointwise product, whose net area is the correlation readout.