  We present the transverse momentum spectrum for a heavy hadron at threshold
in a groomed jet initiated by a heavy quark. The cross section is doubly
differential in the energy fraction of an identified heavy hadron in the jet
and its transverse momentum measured with respect to the groomed (recoil free)
jet axis. The grooming is implemented using a soft-drop grooming algorithm and
helps us in mitigating the effects of Non-Global logarithms and pile up. For
the particular case of a $B$ meson, we identify two distinct regimes of the
transverse momentum spectrum and develop an EFT within the formalisms of Soft
Collineat Effective Theory (SCET) and Heavy Quark Effective Theory (HQET) for
each of these regions. We show how each region can be matched smoothly into the
other to provide a prediction for the perturbative transverse momentum
spectrum. The EFT also predicts the scaling behavior of the leading
non-perturbative power corrections and implements a simple shape function to
account for hadronization. We work in the threshold region where the heavy
hadron carries most of the energy of the jet since in this regime, we have a
very good discriminating power between heavy quark and gluon initiated jets. We
observe that the shape of the spectrum is independent of the energy of the jet
over a large range of transverse momentum. We propose that this spectrum can be
used as a probe of evolution for heavy quark TMD fragmentation function. At the
same time, it can be treated as a jet substructure observable for probing
Quark-Gluon Plasma (QGP).
