Just a heads up for anyone stumbling across this as of September 2021: UnityEngine.XR.WSA.WorldManager is deprecated so the line to obtain the rootSpatialCoordinateSystem can be replaced with the following:
rootSpatialCoordinateSystem = SpatialLocator.GetDefault().CreateStationaryFrameOfReferenceAtCurrentLocation().CoordinateSystem;