  Since the preliminary work of Anisimov and co-workers, the Hubbard corrected
DFT+$U$ functional has been used for predicting properties of correlated
materials by applying on-site effective Coulomb interactions to specific
orbitals. However, the determination of the Hubbard $U$ parameter has remained
under intense discussion despite the multitude of approaches proposed. Here, we
define a selection criterion based on the use of polaronic defect states for
the enforcement of the piecewise linearity of the total energy upon electron
occupation. A good agreement with results from piecewise linear hybrid
functionals is found for the electronic and structural properties of polarons,
including the formation energies. The values of $U$ determined in this way are
found to give a robust description of the polaron energetics upon variation of
the considered state. In particular, we also address a polaron hopping pathway,
finding that the determined value of $U$ leads to accurate energetics without
requiring a configurational-dependent $U$. It is emphasized that the selection
of $U$ should be based on physical properties directly associated with the
orbitals to which $U$ is applied, rather than on more global properties such as
band gaps and band widths. For comparison, we also determine $U$ through a
well-established linear-response scheme finding noticeably different values of
$U$ and consequently different formation energies. Possible origins of these
discrepancies are discussed. As case studies, we consider the self-trapped
electron in BiVO$_4$, the self-trapped hole in MgO, the Li-trapped hole in MgO,
and the Al-trapped hole in $\alpha$-SiO$_2$.
