  We propose an analytical approach to characterize undulator radiation near
resonance, when the presence of the vacuum-pipe considerably affects radiation
properties. This is the case of the far-infrared undulator beamline at the
Free-electron LASer (FEL) in Hamburg (FLASH), that will be capable of
delivering pulses in the TeraHertz (THz) range. This undulator will allow
pump-probe experiments where THz pulses are naturally synchronized to the VUV
pulse from the FEL, as well as the development of novel electron-beam
diagnostics techniques. Since the THz radiation diffraction-size exceeds the
vacuum-chamber dimensions, characterization of infrared radiation must be
performed accounting for the presence of a waveguide. We developed a theory of
undulator radiation in a waveguide based on paraxial and resonance
approximation. We solved the field equation with a tensor Green's function
technique, and extracted figure of merits describing in a simple way the
influence of the vacuum-pipe on the radiation pulse as a function of the
problem parameters. Our theory, that makes consistent use of dimensionless
analysis, allows treatment and physical understanding of many asymptotes of the
parameter space, together with their region of applicability.
