  We calculate, for the first time, the NNLO QCD corrections to identified
heavy hadron production at hadron colliders. The calculation is based on a
flexible numeric framework which allows the calculation of any distribution of
a single identified heavy hadron plus jets and non-QCD particles. As a first
application we provide NNLO QCD predictions for several differential
distributions of $B$ hadrons in $t\bar t$ events at the LHC. Among others,
these predictions are needed for the precise determination of the top quark
mass. The extension of our results to other processes, like open or associated
$B$ and charm production is straightforward. We also explore the prospects for
extracting heavy flavor fragmentation functions from LHC data.
