Adaptive external gating based on the updating method of internal/external correlation and gating window before each beam delivery