We calculate the masses and sigma terms of the doubly charmed baryons up to next-to-next-to-next-to-leading order (i.e., $mathcal{O}(p^4)$) in a covariant baryon chiral perturbation theory by using the extended-on-mass-shell renormalization scheme. Their expressions both in infinite and finite volumes are provided for chiral extrapolation in lattice QCD. As a first application, our chiral results of the masses are confronted with the existing lattice QCD data in the presence of finite volume corrections. Up to $mathcal{O}(p^3)$ all relevant low energy constants can be well determined. As a consequence, we obtain the physical values for the masses of $Xi_{cc}$ and $Omega_{cc}$ baryons by extrapolating to the physical limit. Our determination of the $Xi_{cc}$ mass is consistent with the recent experimental value by LHCb collaboration, however, larger than the one by SELEX collaboration. In addition, we predict the pion-baryon and strangeness-baryon sigma terms, as well as the mass splitting between the $Xi_{cc}$ and $Omega_{cc}$ states. Their quark mass dependences are also discussed. The numerical procedure can be applied to the chiral results of $mathcal{O}(p^4)$ order, where more unknown constants are involved, when more data are available for unphysical pion masses.