  We investigate the wave functions, spectrum, and g-factor anisotropy of
low-energy electrons confined to self-assembled, pyramidal InAs quantum dots
(QDs) subject to external magnetic and electric fields. We present the
construction of trial wave functions for a pyramidal geometry with hard-wall
confinement. We explicitly find the ground and first excited states and show
the associated probability distributions and energies. Subsequently, we use
these wave functions and 8-band $k\cdot p$ theory to derive a Hamiltonian
describing the QD states close to the valence band edge. Using a perturbative
approach, we find an effective conduction band Hamiltonian describing
low-energy electronic states in the QD. From this, we further extract the
magnetic field dependent eigenenergies and associated g factors. We examine the
g factors regarding anisotropy and behavior under small electric fields. In
particular, we find strong anisotropies, with the specific shape depending
strongly on the considered QD level. Our results are in good agreement with
recent measurements [Takahashi et al., Phys. Rev. B 87, 161302 (2013)] and
support the possibility to control a spin qubit by means of g-tensor
modulation.
