  We describe the design, construction and performance of the PIBETA detector
built for the precise measurement of the branching ratio of pion beta decay,
pi+ -> pi0 e+ nu, at the Paul Scherrer Institute. The central part of the
detector is a 240-module spherical pure CsI calorimeter covering 3*pi sr solid
angle. The calorimeter is supplemented with an active collimator/beam degrader
system, an active segmented plastic target, a pair of low-mass cylindrical wire
chambers and a 20-element cylindrical plastic scintillator hodoscope. The whole
detector system is housed inside a temperature-controlled lead brick enclosure
which in turn is lined with cosmic muon plastic veto counters. Commissioning
and calibration data were taken during two three-month beam periods in
1999/2000 with pi+ stopping rates between 1.3*E3 pi+/s and 1.3*E6 pi+/s. We
examine the timing, energy and angular detector resolution for photons,
positrons and protons in the energy range of 5-150 MeV, as well as the response
of the detector to cosmic muons. We illustrate the detector signatures for the
assorted rare pion and muon decays and their associated backgrounds.
